Skip to content

Instantly share code, notes, and snippets.

View jimbol's full-sized avatar
🕵️‍♂️
Working on a secret project

Jim Hall jimbol

🕵️‍♂️
Working on a secret project
View GitHub Profile
@jimbol
jimbol / transformer.js
Last active March 27, 2017 22:02
Transform data with dependencies and overrides
const lookUp = ({ hash, ids }) => ids.map((id) => hash[id]);
createTransformer({
hash: getHash,
ids: getIds,
}, lookUp, []);
const createTransformer = (dependencies, transformer, fallbackValue) => {
return function(state, props, overrides) {
const keys = Object.keys(dependencies);
@jimbol
jimbol / make-optimistic.js
Created March 27, 2017 21:20
Action-based optimistic reducer enhancer
// ACTION FORMAT
// const scope = 'MY_SCOPE';
// const createAction = (id, payload) => ({
// type: 'START_LOADING',
// payload,
// meta: {
// scope,
// type: EXPECT,
// id,
// },
@jimbol
jimbol / hash-reducer-helpers.js
Created March 28, 2017 21:34
Helpers for hash reducers
const update = (id, hash, changes) => {
const newHash = hash;
const updateEntity = { ...newHash[id], ...changes };
newHash[id] = updateEntity;
return newHash;
};
const replace = (id, nextEntity, hash) => {
let newHash = hash;
newHash = remove(id, newHash);
@jimbol
jimbol / feature-flags.md
Last active March 30, 2017 13:20
A simple feature flag implementation

Feature flags

A simple feature flag implementation

Setup

A hash is provided for the current environment in the application setup.

type Features = { [FLAG_NAME]: Boolean | Function };
const features: Features = (NODE_ENV === 'production') ? productionFeatures : testingFeatures;
export featureFlag = setUpFeatureFlags(features, platform);
@jimbol
jimbol / bill-summarization-journal.md
Last active April 15, 2017 18:12
Bill summarization journal

Bill summarization with gensim

Goals

Following this tutorial

  • Take whole bills
  • Summarize into layman readable content
  • Summarize changes

Domain - Michigan Laws

Terms:

@jimbol
jimbol / word-predictor.js
Created April 17, 2017 13:47
Word predictor
// Sentence predictor
// Given some data
let data = 'A Stop on the Salt Route 1000 B.C. As they rounded a bend in the path that ran beside the river, Lara recognized the silhouette of a fig tree atop a nearby hill. The weather was hot and the days were long. The fig tree was in full leaf, but not yet bearing fruit. Soon Lara spotted other landmarks—an outcropping of limestone beside the path that had a silhouette like a mans face, a marshy spot beside the river where the waterfowl were easily startled, a tall tree that looked like a man with his arms upraised. They were drawing near to the place where there was an island in the river. The island was a good spot to make camp. They would sleep on the island tonight. Lara had been back and forth along the river path many times in her short life. Her people had not created the path—it had always been there, like the river—but their deerskin-shod feet and the wooden wheels of their handcarts kept the path well worn. Laras people were salt traders, and their livel
@jimbol
jimbol / bills-data-structure.json
Created April 30, 2017 20:56
Data structures for MI bills
/* Bills */
{
"2017-SB-0149": {
"id": "2017-SB-0149",
"sponsors": ["goeff-hansen"],
"categories": [
{
"name": "Appropriations: zero budget",
"url": "yadda yadda"
},{
@jimbol
jimbol / managed-flow-vs-branched-flow.md
Last active July 14, 2017 14:24
Managed Flow vs. Branched Flow with Redux Saga

Managed Flow vs. Branched Flow with Redux Saga

Rather than dispatching actions to get us to the next step of an effect, we should manage the async flow in a single effect whenever possible.

Chaining effects and sagas in this manner leads to unexpected side effects.

GOOD

Managed Flow

Function called
i = 0
def multiply(a, b):
i = i + 1
print(i)
return a * b
def memoize_multiply(a, b):
# do stuff here
return multiply(a, b)
@jimbol
jimbol / pass-comp-as-prop.js
Created October 5, 2017 15:26
Passing a component as a prop
import { UserComp, OtherPersonComp } from './components';
const PersonComp = ({ InnerComp, person }) => {
return <section>
<InnerComp person={person}>
</section>;
}
const mapState = (state) => ({
InnerComp: state.person.isUser ? UserComp : OtherPersonComp,