Skip to content

Instantly share code, notes, and snippets.

View andycarrell's full-sized avatar

Andy Carrell andycarrell

View GitHub Profile
{
"singleQuote": true,
"trailingComma": "all",
"useTabs": true,
"tabWidth": 4,
"printWidth": 100
}
.container-layout {
min-height: 60px;
max-width: 600px;
margin: auto;
padding: 0 5px;
}
.container-flex {
display: flex;
justify-content: space-between;
export const createContext = value => {
const context = reactCreateContext(value);
export const withContext = Component => {
const C = props => (
<context.Consumer>
{context => <Component {...context} {...props} />}
</context.Consumer>
);
@andycarrell
andycarrell / BigOleComponent.js
Last active October 26, 2017 07:46
Circular imports
import ...
import { SmolComponent } from './SmolComponent';
export class BigOleComponent { }
import React, { Component } from 'react';
import fetch from 'unfetch'
class FetchAsync extends Component {
constructor(props) {
super(props);
this.state = { isFetching: false };
}
async fetch = () => {
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 { connect } from 'react-redux';
import * as selectors from '../selectors';
const fnNameFor = ([first, ...rest]) => (`get${first.toUpperCase()}${rest.join('')}`);
const selectFor = key => selectors[fnNameFor(key)];
const getMapStateFor = stateKeys => state => stateKeys.reduce(
(acc, key) => ({ ...acc, [key]: selectFor(key)(state) }),
{},
// Settings
{
"breadcrumbs.enabled": false,
"editor.fontFamily": "FiraCode-Retina, FiraCode-Retina", // Need to download this font
"editor.fontLigatures": true,
"editor.insertSpaces": false,
"editor.renderWhitespace": "all",
"editor.wordWrap": "off",
"explorer.confirmDelete": false,
"explorer.enableDragAndDrop": false,
const spicify = ([first, ...rest]) => [...rest].reduce((acc, i) => `${acc} ${i.toUpperCase()}`, first.toUpperCase());
spicify('spicey');
// Still not sure why object spread is not full spec...
const spread = (...objs) => Object.assign({}, ...objs);
const safeSpread = (...objs) => Object.assign({}, ...objs.map(o => o || {}));