I hereby claim:
- I am haishanh on github.
- I am haishanh (https://keybase.io/haishanh) on keybase.
- I have a public key ASCVAbSwFIkUm68AJW4o64FypapsMcNM3k1jIAoG7viuRwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
#!/usr/bin/env bash | |
set -Eeuo pipefail | |
trap cleanup SIGINT SIGTERM ERR EXIT | |
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) | |
usage() { | |
cat <<EOF | |
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...] |
const fetchUser = userId => | |
fetch(`url/to/user/${userId}`).then(response => response.json()); | |
const userMachine = Machine({ | |
id: 'user', | |
initial: 'idle', | |
context: { | |
userId: 42, | |
user: undefined, | |
error: undefined |
Machine({ | |
id: 'SWAPI', | |
initial: 'idle', | |
context: { | |
user: null | |
}, | |
states: { | |
idle: { | |
on: { | |
FETCH: 'loading' |
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
import { createStore, applyMiddleware, compose } from 'redux'; | |
import thunkMiddleware from 'redux-thunk'; | |
import rootReducer from '../ducks'; | |
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; | |
function configureStore() { | |
const store = createStore( | |
rootReducer, | |
composeEnhancers(applyMiddleware(thunkMiddleware)) |
"use strict"; | |
/** | |
* on Mac you can use system builtin app Console to view syslog | |
* but logProto has to be 'sys' | |
* Note, Console only shows logs with level >= warn by default | |
* | |
* | |
* fatal 60 | |
* error 50 |
import React from "react"; | |
import { Link } from "react-router-dom"; | |
export function createResource(getPromise) { | |
let cache = {}; | |
let inflight = {}; | |
let errors = {}; | |
function load(key) { | |
inflight[key] = getPromise(key) |
'use strict'; | |
const Benchmark = require('benchmark'); | |
const benchmarks = require('beautify-benchmark'); | |
const suite = new Benchmark.Suite(); | |
const util = require('util'); | |
const assert = require('assert'); | |
class A { |