Skip to content

Instantly share code, notes, and snippets.

Zheng Jia zhengjia

  • Sport Ngin
  • Minneapolis
Block or report user

Report or block zhengjia

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@zhengjia
zhengjia / gist:3185447
Created Jul 27, 2012 — forked from botchagalupe/gist:737501
Setup a Three Server HAPROXY/APACHE2 Setup (New)
View gist:3185447

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 — forked from postmodern/http_parser.rb
A pure Ruby HTTP parser using Parslet.
View http_parser.rb
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
variable and thread
View gist:2664048
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 Mar 31, 2012 — forked from erikh/hack.sh
OSX For Hackers
View hack.sh
#!/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
#
View splat.rb
def match(path, *rest)
puts path.inspect
puts rest.inspect
end
a=[:inspect]
match(*a, {:via => :get})
@zhengjia
zhengjia / definition.rb
Created Jan 6, 2012
Vagrant box with 'ubuntu' as the default user
View definition.rb
# 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 Dec 24, 2011
rbenv install and system wide install on Ubuntu 10.04 LTS.
View rbenv-install-system-wide.sh
# 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:
View gist:1115122
require 'autotest/growl'
require 'autotest/fsevent'
@zhengjia
zhengjia / mail_queue.rb
Created Jul 30, 2011 — forked from scottwater/mail_queue.rb
A really simple general purpose mail queue for resque
View mail_queue.rb
module MailQueue
extend self
def queue
:default
end
def perform(options = {})
options = options.with_indifferent_access
@zhengjia
zhengjia / rails_test_box_prepackaged.sh
Created Jul 10, 2011 — forked from jeroenvandijk/rails_test_box_prepackaged.sh
Instructions for setting up the prepackaged Rails test environment
View rails_test_box_prepackaged.sh
# These commands will help you setup the Rails test environment without problems
#
# MAKE SURE YOU HAVE VIRTUAL BOX INSTALLED http://www.virtualbox.org/wiki/Downloads
#
# Copy paste all of following commands in your normal terminal and the following things will happen:
# - rails_test_box dir is created
# - rails master branch is checkout in the dir rails
# - A Gemfile is created and all the gems to run the virtualbox are installed using bundler
# - The rails vagrant box is downloaded and added to your vagrant boxes
# - A Vagrantfile is created for vagrant
You can’t perform that action at this time.