Skip to content

Instantly share code, notes, and snippets.

View ben196888's full-sized avatar

Ben Liu ben196888

  • Agoda
  • Bangkok
View GitHub Profile
// Common part
// index.js
import { combineReducer } from 'redux';
import reducer from './reducer';
export default combineReducer({
deep: reducer,
});
// reducer.js
import { combineReducer } from 'redux';
const idsReducer = (state = EMPTY_LIST, action) => {
#!/bin/sh
REMOTE=${1:-'origin'}
echo "git fetch $REMOTE"
git fetch $REMOTE
echo "git checkout $REMOTE/master"
git checkout $REMOTE/master
echo "yarn run build"
yarn run build
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.xml with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
# python simple-https-server.py
# then in your browser, visit:
# https://localhost:4443
import BaseHTTPServer, SimpleHTTPServer
import ssl
@ben196888
ben196888 / StateBuilderIdea.js
Last active November 23, 2018 05:25
Provide a simple solution to create big portion of state when given some small portions
sb = new StateBuilder()
state = sb.setQuery({})
.setConverstion.setMultipleChoiceQuestion({})
.setConverstion.setFreeTextQuestion({})
.build()
class StateBuilder extends GenericStateBuilder {
constructor(args) {
super(args)
#!/bin/bash
set -euo pipefail
# Install nodejs and npm
curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
sudo yum install -y -q nodejs
# Install yarn
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg

Promise Expression

A String expression of the Promise chain.

Promise Methods

Mapping promise methods to a string expression.

Criteria

Pipeline would always pass the result to the down stream.

const SCALE = 1000;
const rounds = 10;
// Standard Normal variate using Box-Muller transform.
function randn_bm() {
let u = 0, v = 0;
while(u === 0) u = Math.random(); //Converting [0,1) to (0,1)
while(v === 0) v = Math.random();
let num = Math.sqrt( -2.0 * Math.log( u ) ) * Math.cos( 2.0 * Math.PI * v );
num = num / 10.0 + 0.5; // Translate to 0 -> 1

Abu learning plan

Client side project deployment

CI

Lint + Unit test on Gitlab

CD