Skip to content

Instantly share code, notes, and snippets.

View kennethzfeng's full-sized avatar

Kenneth Feng kennethzfeng

View GitHub Profile
@kennethzfeng
kennethzfeng / right.go
Created September 6, 2015 14:37
Golang Gotchas
package main
import (
"fmt"
"sync"
)
func main() {
wg := &sync.WaitGroup{}
@kennethzfeng
kennethzfeng / Makefile
Last active August 29, 2015 14:22
C++ Exercise
all:
clang++ main.cpp -o main
@kennethzfeng
kennethzfeng / split.py
Created October 1, 2014 15:47
Python Tips
# http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python
def chunks(l, n):
""" Yield successive n-sized chunks from l."""
for i in xrange(0, len(l), n):
yield l[i:i+n]
@kennethzfeng
kennethzfeng / fix_column_name.py
Last active August 29, 2015 14:06
Fix DataFrame Column Names
import re
def fix_column_name(column_name):
temp = column_name.strip()
temp = re.sub('[.,]', '', temp)
temp = temp.replace(' ', '_')
return temp.lower()
@kennethzfeng
kennethzfeng / parse_rst.py
Created August 31, 2014 22:16
rsStructureText to Node Tree using docutils
"""
Parse reStructureText into Node Tree
"""
from docutils.parsers.rst import Parser
from docutils.utils import new_document
from docutils.frontend import OptionParser
import logging
@kennethzfeng
kennethzfeng / text_cleanup.R
Created August 29, 2014 14:18
Clean up comma, period, etc & lowercase the text
# Clean comma and lower case text
cleanup <- function (text) {
temp <- text
# Clean up comma and period
temp <- gsub('[,.! ]', '', temp)
# To Lowercase
temp <- tolower(temp)
return(temp)
@kennethzfeng
kennethzfeng / dynamic.js
Created August 13, 2014 03:11
Dynamically Create Javascript Classes
function AccountFactory(name) {
function AccountClass(accountNumber) {
this.accountNumber = accountNumber;
}
AccountClass.getClassName = function() {
return name + 'Account';
};
return AccountClass;
@kennethzfeng
kennethzfeng / .gitconfig
Last active August 29, 2015 14:04
Command Line Git Log Visualization
[alias]
lg = log --graph --pretty='%C(yellow)%h%Creset%C(blue)%d %Creset%C(white bold)%s %Creset%C(white dim)(by %cn %cr)'
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #