Skip to content

Instantly share code, notes, and snippets.

View tclh123's full-sized avatar
💭
Be an artist

Harry Lee tclh123

💭
Be an artist
View GitHub Profile
@menghan
menghan / Makefile
Last active December 23, 2015 20:09
bench:
go test benchmark_test.go --bench=. | tee result
/*
* call-seq:
* Rugged::Repository.new(name, options = {}) -> repository
*
* Open a Git repository with the given +name+ and return a +Repository+ object
* representing it.
*
*/
static VALUE rb_git_repo_new(int argc, VALUE *argv, VALUE klass)
{
@tclh123
tclh123 / frange2
Created November 22, 2012 15:50
"A faster range-like function that does accept float increments" from http://wiki.woodpecker.org.cn/moin/PyCkBk-1-16
def frange2(start, end=None, inc=1.0):
"A faster range-like function that does accept float increments..."
if end == None:
end = start + 0.0
start = 0.0
else: start += 0.0 # force it to be a float
count = int((end - start) / inc)
if start + count * inc != end:
# Need to adjust the count. AFAICT, it always comes up one short.
@unionx
unionx / iter.lisp
Created July 21, 2012 01:07
Iteration in Common Lisp
;;;;;; iteration in common lisp
;;;; do
;; `do` is like `if` in c
(do ((x 1 (+ x 1))
(y 1 (* y 2)))
((> x 5) y) ;; when x is bigger than 5, return y
(print y)
@nvie
nvie / gzip_middleware.py
Created May 22, 2012 15:11
A WSGI middleware wrapper to add gzip to your WSGI app
from gzip import GzipFile
from wsgiref.headers import Headers
import re
import cStringIO as StringIO
# Precompile the regex to check for gzip headers
re_accepts_gzip = re.compile(r'\bgzip\b')
# Precompile the regex to split a comma delimitered string of Vary headers
@haschek
haschek / .jshintrc
Created May 4, 2012 16:08
JSHint Configuration, Strict Edition
{
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
//
// This is a options template for [JSHint][1], using [JSHint example][2]
// and [Ory Band's example][3] as basis and setting config values to
// be most strict:
//
// * set all enforcing options to true
@kenchan
kenchan / agig
Created April 2, 2012 07:27
agig with daemontools(gentoo and rbenv)
#!/bin/bash
unset RUBYOPT
exec \
setuidgid kenchan \
/home/kenchan/.rbenv/shims/agig -p 6699 -h sakura.shu-cream.net
@fernandoaleman
fernandoaleman / Linux Static IP
Created March 23, 2012 16:20
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@kirbysayshi
kirbysayshi / mass-aggregation-change.sh
Created November 23, 2011 17:14
quick examples of how to change many many wsp (graphite/whisper) files settings
for f in $(find $1 -iname "*.wsp"); do
if [ -a $f ];
then /opt/graphite/bin/whisper-set-aggregation-method.py $f max;
fi;
done
@mikeyk
mikeyk / gist:1329319
Created October 31, 2011 22:56
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])