#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
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
[user] | |
name = Bill Gao | |
email = viruschidai@gmail.com | |
[core] | |
excludesfile = /home/billg/.gitignore | |
editor = vim | |
[color] | |
ui = true | |
[giggle] | |
main-window-maximized = true |
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
find . -type f -print0 | xargs -0 sed -i 's/Application/whatever/g' |
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
# Base custom error class | |
exports.AbstractError = class AbstractError extends Error | |
constructor: (msg, constr) -> | |
Error.captureStackTrace this, constr or this | |
@message = msg or 'Error' | |
name: 'Abstract Error' | |
exports.InvalidDataError = class InvalidDataError extends AbstractError |
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
filelist=$(git diff --cached --name-only --diff-filter=ACMR) | |
testfiles=$(echo "${filelist[@]}" | grep -E 'test\/.*\.coffee$' | grep -v node_modules) | |
if [[ ${testfiles[@]} ]] | |
then | |
echo | |
echo 'Checking if there are skipped tests ...' | |
echo | |
echo ${testfiles[@]} | xargs cat | grep -E '\.only|\.skip' && echo 'Error: contains skipped tests' && exit 1 || exit 0 | |
fi |
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
You need transaction | |
You need db pagination | |
You need db aggregation functions | |
You want to store document big than 64kb | |
You need joins | |
You don't want to write tools to use dynamodb to fit your need | |
Your data has schema and you need to migrate data to use new schema occasionally | |
You want easily to add indexes whenever you want to a table |
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
1. When it takes less time to read your code than to read your comment | |
2. When your code can be written in a more self-documented way | |
3. When your comment is simply repeat a method name or variable name |
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
exports.pack = (data, cb) -> | |
ret= [] | |
innerRet = [] | |
for index, d of data | |
if d then innerRet.push '1' else innerRet.push '0' | |
if innerRet.length is 32 or index is (data.length - 1) | |
ret.push innerRet | |
innerRet = [] | |
binary = [] |
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 flatten(arr) { | |
if (!arr || !arr.length) return []; | |
var nodes = arr.slice(); | |
var results = []; | |
var node = nodes.pop(); | |
while(node) { | |
if (Array.isArray(node)) { | |
nodes.push.apply(nodes, node); | |
} else { |