Skip to content

Instantly share code, notes, and snippets.

View andycarrell's full-sized avatar

Andy Carrell andycarrell

View GitHub Profile
const compose = (...fns) => x => [...fns].reverse().reduce((acc, fn) => fn(acc), x);
const compose = (...fns) => {
const [first, ...rest] = [...fns].reverse();
return (...args) => rest.reduce((acc, fn) => fn(acc), first(...args));
}
import React, { Component } from 'react';
import fetch from 'unfetch'
class FetchAsync extends Component {
constructor(props) {
super(props);
this.state = { isFetching: false };
}
async fetch = () => {
@andycarrell
andycarrell / BigOleComponent.js
Last active October 26, 2017 07:46
Circular imports
import ...
import { SmolComponent } from './SmolComponent';
export class BigOleComponent { }
export const createContext = value => {
const context = reactCreateContext(value);
export const withContext = Component => {
const C = props => (
<context.Consumer>
{context => <Component {...context} {...props} />}
</context.Consumer>
);
.container-layout {
min-height: 60px;
max-width: 600px;
margin: auto;
padding: 0 5px;
}
.container-flex {
display: flex;
justify-content: space-between;
{
"singleQuote": true,
"trailingComma": "all",
"useTabs": true,
"tabWidth": 4,
"printWidth": 100
}
const AppContextConsumer = ({ children }) => (
<PermissionContext.Consumer>
{permissions => (
<ThemeContext.Consumer>
{theme => children({ permissions, theme })}
</ThemeContext.Consumer>
)}
</PermissionContext.Consumer>
);
const cached = fn => {
const c = Object.create(null);
return a => {
if (a in c) return c[a];
const value = fn(a);
c[a] = value;
return value;
};
alias dkr-die="docker ps -a -q | xargs docker stop | xargs docker rm"
// could you do something like this:
const actionsToTake = actions.filter(({ type }) => type.endsWith('_FAILURE'));
yield actionsToTake.map(action => takeEvery(action.type, genericSaga));