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 / 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
#
@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 / 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
@zhengjia
zhengjia / rails_test_box_prepackaged.sh
Created July 10, 2011 03:14 — forked from jeroenvandijk/rails_test_box_prepackaged.sh
Instructions for setting up the prepackaged Rails test environment
# 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
@zhengjia
zhengjia / node-and-npm-in-30-seconds.sh
Created June 30, 2011 01:27 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
require 'mongoid'
require 'rspec'
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db('testing')
config.autocreate_indexes = true
end
class User
include Mongoid::Document
#!/usr/bin/env ruby
# Command line util for acquiring a one-off Twitter OAuth access token
# Based on http://blog.beefyapps.com/2010/01/simple-ruby-oauth-with-twitter/
require 'rubygems'
require 'oauth'
puts <<EOS
Set up your application at https://twitter.com/apps/ (as a 'Client' app),