Skip to content

Instantly share code, notes, and snippets.

View ericelliott's full-sized avatar
💭
https://leanpub.com/composingsoftware

Eric Elliott ericelliott

💭
https://leanpub.com/composingsoftware
View GitHub Profile
@ericelliott
ericelliott / new-feature-template.md
Created December 1, 2022 17:50
New Feature Issue Template

Route

/path/to/feature

User story / job story

@ericelliott
ericelliott / pyramid-of-doom.jsx
Created August 30, 2020 03:23
Pyramid of Doom
import FeatureProvider from '../providers/feature-provider';
import EnvProvider from '../providers/env-provider';
import LoaderProvider from '../providers/loader-provider';
import CouponProvider from '../providers/coupon-provider';
import LayoutProvider from '../providers/layout-provider';
import AuthProvider from '../providers/auth-provider';
import RouterProvider from '../providers/RouterProvider';
import MagicLinkProvider from '../providers/magic-link-provider';
import PageComponent from './page-container';
@ericelliott
ericelliott / page-hoc.js
Created August 30, 2020 02:54
pageHOC for EricElliottJS.com
import { compose } from 'lodash/fp';
import withFeatures from './with-features';
import withEnv from './with-env';
import withLoader from './with-loader';
import withCoupon from './with-coupon';
import withLayout from './with-layout';
import withAuth from './with-auth';
import { withRouter } from 'next/router';
import withMagicLink from '../features/ethereum-authentication/with-magic-link';
@ericelliott
ericelliott / jsx-example.jsx
Created August 26, 2020 02:17
JSX Example
const ItemList = ({ items }) => (
<ul>
{items.map((item) => (
<li key={item.id}>
<div>{item.name}</div>
</li>
))}
</ul>
);
@ericelliott
ericelliott / double-list-declarative.js
Created June 26, 2020 22:18
double-list-declarative.js
const doubleList = list => list.map(x => x * 2);
@ericelliott
ericelliott / double-list-imperative.js
Created June 26, 2020 22:04
double-list-imperative.js
const doubleList = list => {
const newList = [];
for (var i = 0; i < list.length; i++) {
newList[i] = list[i] * 2;
}
return newList;
};
@ericelliott
ericelliott / after-immer.js
Created June 4, 2020 03:48
after-immer.js
import produce from 'immer';
const like = item => ({
type: like.type,
payload: item
});
like.type = 'user/like';
const initialState = {
name: 'Anonymous',
const like = item => ({
type: like.type,
payload: item
});
like.type = 'user/like';
const initialState = {
name: 'Anonymous',
avatar: 'Anonymous',
email: '',
@ericelliott
ericelliott / for-await-of-transducers.js
Created April 21, 2020 22:03
for-await-of-transducers
const compose = (...fns) => x => fns.reduceRight((y, f) => f(y), x);
function map(f) {
return async function*(values) {
for await (const x of values) {
yield f(x);
}
};
}
@ericelliott
ericelliott / parallel-fetch.js
Created April 13, 2020 02:10
Parallel requests example
// setup
const wait = value => new Promise(resolve => {
setTimeout(() => resolve(value), 3000);
});
const fetchFoo = () => wait('foo');
const fetchBar = () => wait('bar');
const fetchBaz = () => wait('baz');
const fetchDataSlowly = async time => {