Skip to content

Instantly share code, notes, and snippets.

View coderek's full-sized avatar
👽

Derek Zeng coderek

👽
View GitHub Profile
@coderek
coderek / useful.sh
Last active August 29, 2015 14:18
useful shell commands
# number lines for all javascript files
find . -type f \( -name "*.js" -or -name "*.jsx" \) \
! -path "./node_modules/*" ! -path "./vendor/*" \
! -path "./generated-public/*" \
! -path "./design/*" \
! -path "./test/*" \
! -path "./app/statics/*" -print | xargs -L 1 wc -l | awk '{s+=$1} END {print s}'
@coderek
coderek / pbxproj-parser.coffee
Created July 12, 2015 22:01
parse pbxproj file to JSON
fs = require('fs')
[
KEY,
VALUE,
OBJECT_START,
OBJECT_END,
ARRAY_START,
ARRAY_END,
ASSIGN
/*global self*/
/*jshint latedef: nofunc*/
/*
Distributed under both the W3C Test Suite License [1] and the W3C
3-clause BSD License [2]. To contribute to a W3C Test Suite, see the
policies and contribution forms [3].
[1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license
[2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license
[3] http://www.w3.org/2004/10/27-testcases
// js-test now supports lazily printing test results which dumps all test
// results once at the end of the test instead of building them up. To enable
// this option, call setPrintTestResultsLazily() before running any tests.
var _lazyTestResults; // Set by setPrintTestResultsLazily().
// svg/dynamic-updates tests set enablePixelTesting=true, as we want to dump text + pixel results
if (self.testRunner) {
if (self.enablePixelTesting)
testRunner.dumpAsTextWithPixelResults();
else
@coderek
coderek / .bashrc
Last active December 30, 2017 19:36
bashrc
#! /bin/sh
alias today='date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S %Z"'
if hash ggrep 2>/dev/null; then
alias grep='ggrep --color=auto -n -P'
fi
alias get='git grep --color=auto -n -P'
unset work
@coderek
coderek / .gitconfig
Last active August 18, 2021 01:53
gitconfig
[alias]
fix = "!vim `git diff --name-only --diff-filter=U`"
co = checkout
l = log --decorate --graph --pretty='format:%C(auto)%h %s, %d%n🙇 %Cgreen%aN %Cred%ar (%aI)%n' --color --date-order
lg = log --pretty=oneline --abbrev-commit
la = log --all --date-order --decorate --graph --pretty='format:%C(auto)%h %s, %d%n🙇 %Cgreen%aN %Cred%ar (%aI)%n' --color
all = l --all --simplify-by-decoration
ba = "!f() { \
git for-each-ref --format='%(committerdate) %09 %(authorname) %09 %(refname)' | sort -k5n -k2M -k3n -k4n; \
}; f"
[alias]
co = checkout
l = log --no-merges --pretty=medium --branches=develop,HEAD
lg = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --no-merges --branches=develop,HEAD
s = status
last = log -1 HEAD
b = branch
br = branch -r
cb = checkout -b
ss = stash save
[{"body":"It is indeed amazing how much of an impact art has in helping someone find their way around in life. \n\nHere is an example: Mr Barry Yeow had spent over 20 years of his life behind bars for various drug and gang-related activities. He was finally able to turn his life around after he discovered his passion for art.\n\n#SpreadYRLove\n#SecondChancesEveryday\n\nhttps://www.youtube.com/watch?v=rSkOXnHuxZE","liked":false,"link":"https://www.youtube.com/watch?v=rSkOXnHuxZE","likes":46,"from":{"name":"Yellow Ribbon Project Singapore","id":"321854601115"},"image":"https://external.xx.fbcdn.net/safe_image.php?d=AQBHsYQa46pHxS8V&w=720&h=720&url=https%3A%2F%2Fi.ytimg.com%2Fvi%2FrSkOXnHuxZE%2Fmaxresdefault.jpg&cfs=1","create_at":"2016-05-19T23:50:00+0000","id":"321854601115_10153353945481116","shares":7,"comments":1},{"body":"Often times, we judge others without knowing the story behind their actions. This may sometimes cause us more harm, as many of our problems are caused by how we process things around us.\
# https://code.google.com/codejam/contest/dashboard?c=635101#s=p0
def solve(inputs):
itr = iter(input)
a = int(itr.next())
for i in range(a):
m, n = map(lambda c: int(c), itr.next().split(' '))
exists = [itr.next() for j in range(m)]
targets = [itr.next() for k in range(n)]
print 'Case #{}: {}'.format(i+1, _solve(exists, targets))
@coderek
coderek / list_merge_sort.py
Last active September 27, 2017 17:12
Shortest merge sort (in place, stable)
def list_merge_sort(l, start, end):
if start >= end - 1: return l
m = (start + end) // 2
l = list_merge_sort(l, start, m)
l = list_merge_sort(l, m, end)
start_head = l
start_parent = None
mid_head = l