Skip to content

Instantly share code, notes, and snippets.

View coderek's full-sized avatar
👽

Derek Zeng coderek

👽
View GitHub Profile
@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"
@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
// 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
/*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
@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
@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 / vimrc
Last active January 1, 2021 00:57
set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim/
let path='~/vimfiles/bundle'
call vundle#begin(path)
@coderek
coderek / filter_collectionview.js
Last active November 17, 2018 10:08
Implement filter collectionview for marionette
/**
* matchFilter
* @param {Object} term - key:val pairs that model need to match
* @returns {boolean}
*/
Backbone.Model.prototype.matchFilter = function (conditions) {
return _.every(conditions, function (val, key) {
return this.get(key) === val;
}, this);
/**
* get remaining time
* @param {string} start - UTC/ISO time string
* @param {string} end - UTC/ISO time string
*/
function getRemainingTime(start, end) {
start = moment(start), end = moment(end);
var now = moment();
if (now > end) {
var log = console.log.bind(console);
/**
* Given a ad
* calculate max bid rate
*/
function calculate_max_bid_rate(ad) {
var org_chain = get_org_chain(ad);