Skip to content

Instantly share code, notes, and snippets.


Jethro Larson jethrolarson

  • Tableau
  • Seattle
View GitHub Profile
View string.js
// Take string and get words as an array. Valid split characters are `,` `.` `\s` `/` `\n`
// words :: String -> [String]
export const words = str =>
(str ? str.split(/[\s\n.,/]+/) : []) // split on whitespace
jethrolarson / gist:99ca3c02c0f8c5de85b10843778a580c
Created December 2, 2017 00:57
How moment.js parses falsy values
View gist:99ca3c02c0f8c5de85b10843778a580c
moment(0) // epoc
moment(undefined) // Now
moment(null) // Invalid Date
moment(false) // throw warning, Invalid date
moment(void 0) // Now
moment('') // Invlid Date
moment([]) // Now
moment({}) // Now
View gist:2a28945743668cf828c9eb5a4a924d2f
What is a lens?
pair of getter and setter that perform immutable updates on parameterized data structure
jethrolarson / gist:65732a8ba9b4f620b68930923ec3c48a
Created June 21, 2017 22:49
Big O notation for story estimation
View gist:65732a8ba9b4f620b68930923ec3c48a
O(1) - Trivial, we've done something almost exactly like this and it wont take long to complete at all
O(log n) - Need to add a small capability then it's copy-pasta
O(n) - Simple, It's like things we've done before. No refactoring or architectural changes needed.
O(n^2) - Going to need to rework some things and watch out for regressions
O(n!) - Major rework needed, lots of risk
O(MG) - This is so complex or ill-defined that it may never complete
jethrolarson /
Last active May 10, 2017 22:32
options for async actions in redux

Note: These aren't necessarily mutually exclusive. E.g. we may want to use promise with thunk to get better ergonomics for certain kinds of effects.


Learnability: 4
Testability: 4
Happy path: 4
Purity: 2
SLOC: 14

  • Doesn't do a lot for you. Just makes it easy to do async actions
View immutable_update_techniques.js
// Immutable update techniques
// mutate in place
myData.x.y.z = 7;
mydata.a.b[2] = 3;
// clone and mutate
const newData = deepCopy(myData);
newData.x.y.z = 7;
jethrolarson /
Last active March 26, 2022 01:14
Reactive Stream Library Comparison

License: MIT
Size: 22.4 KB (3.4 KB gzip)
Functions: 16
Project Life: Good
Stars: 1129
Code Quality: Good Functional/Procedural
Comments: JSDoc
Quality Automation: Extensive unit tests, CI

jethrolarson /
Last active January 27, 2017 23:19
presentation on type signatures in js

Type Signatures for your JS


A form of documentation that helps developers understand what a function does.

// toUpper :: String -> String
const toUpper = str => str.toUpperCase()
jethrolarson / index.js
Created January 4, 2017 18:41
Loop fusion with transducers in Ramda
View index.js
import {into, pipe, filter, map, propEq, prop} from 'ramda';
const doStuff = pipe(
filter(propEq('status', 'active')),
// only iterates array once
into([], doStuff, [{status: 'active', name: 'Pam'}, {status: 'bad', name: 'Mancy'}]);
// ['Pam']
jethrolarson / createClass.jsx
Created December 14, 2016 21:31
Bind all solutions
View createClass.jsx
import React, {createClass} from 'react';
class MediaLibrary = createClass({
foo() {
this.setState({foo: !})
render() {
return (<Bar onFoo={} />);