Skip to content

Instantly share code, notes, and snippets.

View FreddieRidell's full-sized avatar
🤔
Thinkin' bout them codes

Freddie Ridell FreddieRidell

🤔
Thinkin' bout them codes
View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>test</title>
<link>https://gist.github.com/FreddieRidell/d17719b4dc61855b2ca0b358c6f29433/raw/0e8b0eb980016c6460ea341eb06cb7567918b3c2/rss.xml</link>
<item>
<title>After Laughter</title>
<description>test</description>
<guid>6DE5B3D36A9F0FFD90DE386456B080EB3F20871B</guid>
version: '2'
services:
nginx-proxy:
restart: always
image: jwilder/nginx-proxy
ports:
- "80:80"
- "443:443"
volumes:
//// REACT VERSION
const JsonEditor = ({ valueObject, onChange }) => {
return <input
value = {JSON.stringify(valueObject)}
onChange = { e => onChange(JSON.parse(e.target.value))}
/>
};
const Parent = () => {
const [objState, setObjState] = React.useState({});
// current:
() => {
// good, vast improvment over previous validation system.
// However, this now validates by passing a mutable refference down to children,
// then reading mutated properties on that reference: not very react-y
const validator = useMemo(() => new Validator(validations), []);
const [state, onChange] = useState("");
const errors = validator.errors;
@FreddieRidell
FreddieRidell / Alternative Valiration Handling.tsx
Created November 22, 2019 12:45
Alternative Valiration Handling.tsx
dwadwadwa
/// reselect version:
const selectFoo = storeState => storeState.foo;
const selectProp = (_, props) => props.id;
export const selectBar = createSelector(
selectFoo,
selectProp,
(foo, propId) =>
Object.keys(foo).map(id => ({
id,
...foo[id],
"foo Bar ' baz".replace( /[A-Z]/g, x => x.toLowerCase()).replace( /[^a-z0-9-\s]/g, "").replace( /\s+/g, "-" )
//------------------------------
// Before
//------------------------------
class ShouldntBeInAClass {
public getBalance = (locals: ILocals): Promise<IBalanceResponse> => { //type definition located in another file
const {url, options, transform} = GET_BALANCE_CONFIG; //defined at the top of this file, used nowhere else
return this.fetch<IResponse>(url, {dynamics: locals, ...options})
.then(authoriseResponse) //called in 90% of methods
const {format: formatDate} = require('date-fns/fp');
const createGlot = dictionary => {
const parseStrings = (lang, value, strs, exprs) => {
const key = strs.map((str, i) => str + (exprs[i] || '')).join('');
const found = dictionary[lang][key];
if (found === undefined) {
return `~~NO GLOT FOUND FOR ${key}!!!~~`;
}
const R = require("ramda");
let stamps = [];
let i = 0;
while (++i) {
stamps = R.pipe(
R.append(i),
R.groupBy(x => Math.floor(3 * Math.log(i - x + 1, 2))),
R.values,
R.map(R.head),