Skip to content

Instantly share code, notes, and snippets.

View zhengjia's full-sized avatar

Zheng Jia zhengjia

  • Sport Ngin
  • Minneapolis
View GitHub Profile
@zhengjia
zhengjia / list.md
Created November 14, 2020 15:49 — forked from ih2502mk/list.md
Quantopian Lectures Saved
@zhengjia
zhengjia / gist:3185447
Created July 27, 2012 00:38 — forked from botchagalupe/gist:737501
Setup a Three Server HAPROXY/APACHE2 Setup (New)

Setup a Three Server HAPROXY/APACHE2 Setup

Ubuntu Image used in class

image: ami-2e7e8747

Notes:  For Chef Clinet install use "sudo gem install chef --no-ri --no-rdoc" 

        Instead of knife ec2 .. use 
@zhengjia
zhengjia / http_parser.rb
Created May 30, 2012 03:29 — forked from postmodern/http_parser.rb
A pure Ruby HTTP parser using Parslet.
require 'parslet'
require 'pp'
class HTTPParser < Parslet::Parser
#
# Character Classes
#
rule(:digit) { match('[0-9]') }
rule(:digits) { digit.repeat(1) }
rule(:xdigit) { digit | match('[a-fA-F]') }
@zhengjia
zhengjia / gist:2664048
Created May 12, 2012 04:01
variable and thread
require 'thread'
@value = 1
@cond = ConditionVariable.new
@mutex = Mutex.new
t = Thread.new do
value = @value
@mutex.synchronize do
while true
STDOUT.puts value
@zhengjia
zhengjia / hack.sh
Created March 31, 2012 15:53 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
def match(path, *rest)
puts path.inspect
puts rest.inspect
end
a=[:inspect]
match(*a, {:via => :get})
@zhengjia
zhengjia / definition.rb
Created January 6, 2012 00:53
Vagrant box with 'ubuntu' as the default user
# modify from veewee
require 'digest/md5'
CURRENT_DIR = File.dirname(__FILE__)
PRESEED_MD5 = "#{Digest::MD5.file("#{CURRENT_DIR}/preseed.cfg").hexdigest}"
Veewee::Session.declare( {
:boot_cmd_sequence => [
"<Esc><Esc><Enter>",
"/install/vmlinuz ",
"noapic ",
@zhengjia
zhengjia / rbenv-install-system-wide.sh
Created December 24, 2011 17:16
rbenv install and system wide install on Ubuntu 10.04 LTS.
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Install rbenv
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
# Add rbenv to the path:
@zhengjia
zhengjia / gist:1115122
Created July 30, 2011 02:26
.autotest
require 'autotest/growl'
require 'autotest/fsevent'
@zhengjia
zhengjia / mail_queue.rb
Created July 30, 2011 01:10 — forked from scottwater/mail_queue.rb
A really simple general purpose mail queue for resque
module MailQueue
extend self
def queue
:default
end
def perform(options = {})
options = options.with_indifferent_access