This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function longestIncreasingSubsequence(arr) { | |
return arr.slice(0, arr.lastIndexOf(-1)).reduce( | |
(acc, val) => { | |
if (acc.prev == null) { | |
return { ...acc, prev: val } | |
} | |
if (val > acc.prev) { | |
return { ...acc, count: acc.count + 1, prev: val } | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sortUrls(urls) { | |
return urls | |
.map(link => { | |
const normalizedLink = /^(https?:\/\/)?(www\.)?/.exec(link)[0] | |
return [link.replace(normalizedLink, ''), normalizedLink] | |
}) | |
.sort(([a], [b]) => { | |
if(a < b) return -1 | |
if(a > b) return 1 | |
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const FastSimplexNoise = require('fast-simplex-noise').default | |
const fill2d = | |
(rows, cols, fn) => Array(rows) | |
.fill(true) | |
.map((_, x) => { | |
return Array(cols) | |
.fill(true) | |
.map((_, y) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { componentFromStream, setObservableConfig } from 'recompose' | |
import xstreamConfig from 'recompose/xstreamObservableConfig' | |
import { h, p, div, h1, h2 } from 'react-hyperscript-helpers' | |
import { render } from 'react-dom' | |
import xs from 'xstream' | |
setObservableConfig(xstreamConfig) | |
const Users = componentFromStream((props$) => { |
After a style dispatch, the middleware hashes the style object and looks up if its already in the cache. If not, add the given classname to the document and add it to the cache:
- Dispatch action to store { type: '...', payload: { ...styles }}
- Hash StyleObject -> '646efd54'
- Check if style is already in cache
- Store renders style to client (or could be anything: server-side to string etc.)
- Return hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createElement } from 'react' | |
const isChildren = arr => typeof arr == 'string' || Array.isArray(arr) | |
const create = (tag, props, children) => { | |
if (Array.isArray(children)) { | |
return createElement(tag, props, ...children) | |
} else { | |
return createElement(tag, props, children) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
em | |
} from './utils' | |
import zyle from 'zyle' | |
function initStyles(dispatch) { | |
const gen = zyle(dispatch) | |
function contain (width = 56) { |
http://stackoverflow.com/questions/3579035/why-are-there-wrapper-classes-in-java
- So that a null value is possible
- To include in a Collection
- To treat generically / polymorphically as an Object along with other Objects
NewerOlder