Skip to content

Instantly share code, notes, and snippets.

View dchentech's full-sized avatar
🎯
Focusing

David Chen dchentech

🎯
Focusing
View GitHub Profile
@dchentech
dchentech / enc_dec_test.py
Last active August 29, 2015 14:20 — forked from justinfx/enc_dec_test.py
Speed test of common serializers on python 2.7.9 (pickle, cPickle, ujson, cjson, simplejson, json, yajl, msgpack, Python builtin)
"""
Dependencies:
pip install tabulate simplejson python-cjson ujson yajl msgpack-python
"""
from timeit import timeit
from tabulate import tabulate
# -*-coding:utf-8-*-
'''cjson, jsonlib, simplejson, and yajl also use C code
demjson did not use C code, but was too painfully slow to benchmark
(took about 20 seconds for these tests)
'''
import json
import sys
import time
@dchentech
dchentech / .gitignore
Last active January 24, 2018 12:22 — forked from miku/.gitignore
*gz
*.txt
(function () {
"use strict";
var copyOwnProperties = function (from, to) {
for (var propertyName in from) {
if (from.hasOwnProperty(propertyName)) {
to[propertyName] = from[propertyName];
}
}
};
#!/bin/sh
#
# https://gist.github.com/mvj3/6973600
#
# unicorn - init.d script for single or multiple unicorn installations. Expects at least one .conf
# chkconfig: - 85 15
# description: Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency,
# high-bandwidth connections and take advantage of features in Unix/Unix-like kernels
# processname: unicorn
# config: /etc/unicorn/*.conf
@dchentech
dchentech / webapp.rb
Created November 8, 2012 10:03 — forked from igrigorik/webapp.rb
Inspired by @JEG2's talk at Rubyconf... Any ruby object, as a webapp! 'Cause we can. :-)
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
@dchentech
dchentech / action.xml.nokogiri
Created June 2, 2011 08:50 — forked from raecoo/action.xml.nokogiri
xml builder by Nokogiri
xml.feed(:xmlns => "http://www.w3.org/2005/Atom") { |feed|
feed.title("#{user.name}'s Private Notification Feed")
feed.link(:href => "http://#{account.subdomain}.domain.com/feeds/#{user.email_alias}.xml", :rel => "self")
feed.link(:href => "http://#{account.subdomain}.domain.com")
}