Skip to content

Instantly share code, notes, and snippets.


Zheng Jia zhengjia

  • Sport Ngin
  • Minneapolis
View GitHub Profile
View capybara cheat sheet
=Clicking links and buttons=
click_link('Link Text')
click('Link Text') # Click either a link or a button
click('Button Value')
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 => [
"/install/vmlinuz ",
"noapic ",
View webrat cheatsheet
== Simulating browser events
# GET a URL, following any redirects, and making sure final page is successful
visit "/some/url"
# In general, elements can be located by their inner text, their 'title'
attribute, their 'name' attribute, and their 'id' attribute.
# They can be selected using a String, which is converted to an escaped Regexp
effectively making it a substring match, or using a Regexp.
# An exception is that using Strings for ids are compared exactly (using ==)
# A list of directories to back up. Put each on its own line
# The rsync command with options
BACKUP_CMD='rsync -Rvurogptl'
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 / 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 / gist:2664048
Created May 12, 2012
variable and thread
View gist:2664048
require 'thread'
@value = 1
@cond =
@mutex =
t = do
value = @value
@mutex.synchronize do
while true
STDOUT.puts value
zhengjia /
Created Mar 31, 2012 — forked from erikh/
OSX For Hackers
#!/usr/bin/env sh
# This is script with usefull tips taken from:
# install it:
# curl -sL | sh
View splat.rb
def match(path, *rest)
puts path.inspect
puts rest.inspect
match(*a, {:via => :get})
zhengjia /
Created Dec 24, 2011
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:// /usr/local/rbenv
# Add rbenv to the path:
You can’t perform that action at this time.