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 { Store } from 'src/store'; | |
type TagWithKey<TagName extends string, T> = { [K in keyof T]: { [_ in TagName]: K } & { params: T[K] } }; | |
type Unionize<T> = T[keyof T]; | |
type ActionHandlers<TParams, TParamsKey extends keyof TParams> = { | |
[Key in TParamsKey]: (params: TParams[Key]) => void | |
}; |
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
git config --global alias.co checkout | |
git config --global alias.br branch | |
git config --global alias.brv branch -vv | |
git config --global alias.ci commit | |
git config --global alias.st status | |
git config --global alias.fix commit --amend | |
git config --global alias.pr pull --rebase | |
// always rebase for pull | |
git config --global branch.autosetuprebase always |
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 compose = (...fns) => (...args) => fns.reduceRight((input, fn) => fn.apply(null, [].concat(input)), args) | |
const combine = (...args) => args.join(" ") | |
const shout = (x) => x.toUpperCase() | |
const emphasize = (x) => `${x}!` | |
const yell = compose(emphasize, shout, combine) | |
console.log(yell("hello", "world")); // "HELLO WORLD!" |
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 curry(fn) { | |
return (...args) => { | |
if (args.length >= fn.length) { | |
return fn.apply(null, args) | |
} | |
return function internal(...args1) { | |
args = args.concat(args1) | |
if (args.length >= fn.length) { |
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 createContext (config, onLoginError) { | |
var defaultConfig = { | |
postLogoutRedirectUri: window.location.origin, | |
}; | |
var finalConfig = Object.keys(config).reduce(function(configCopy, curKey) { | |
configCopy[curKey] = config[curKey]; | |
return configCopy; | |
}, defaultConfig); | |
var authContext = new AuthenticationContext(finalConfig); |
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
Disclaimer: The instructions are the collective efforts from a few places online. | |
Nothing here is my original. But I want to put them together in one place to save people from spending the same time as I did. | |
First off, bundle. | |
================== | |
1. cd to the project directory | |
2. Start the react-native packager if not started | |
3. Download the bundle to the asset folder: | |
curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle" |
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
should = require 'should' | |
sinon = require 'sinon' | |
myModule = {} | |
myModule.asyncMethod = (callback) -> | |
timeout = 1000 | |
setTimeout (-> | |
process.nextTick -> |
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
vows = require 'vows' | |
should = require 'should' | |
sinon = require 'sinon' | |
class FakeTicker | |
constructor: -> | |
@_originalTick = process.nextTick | |
sinon | |
.stub(process, 'nextTick', (callback)-> | |
setTimeout (-> |