Skip to content

Instantly share code, notes, and snippets.

View flyerhzm's full-sized avatar
🏠
Working from home

Richard Huang flyerhzm

🏠
Working from home
View GitHub Profile
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
daemon off;
worker_processes 6;
user nobody nobody;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
As the nightly build will fail with nginx-gridfs, we have to compile mongodb
from scratch and use the fresh libmongoclient.a version.
1) Install neccessary dependencies for Ubuntu
apt-get -y install tcsh git-core scons g++
apt-get -y install libpcre++-dev libboost-dev libreadline-dev libmozjs-dev
2) Get the source from github and compile it (Note we do not need to run scons
install, because we only need the libmongoclient.a)
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
require "rubygems"
require "benchmark"
require "mongoid"
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db("mongoid_perf_test", :logger => Logger.new($stdout, :info))
end
Mongoid.master.collection("people").drop
#!/usr/bin/env ruby
while (input = STDIN.read) != ''
rev_old, rev_new, ref = input.split(" ")
url = nil
if ref == "refs/heads/master"
url = "http://172.23.0.150:8080/job/Project%20Master/build"
elsif ref == "refs/heads/other-branch"
url = "http://172.23.0.150:8080/job/Project%20Other/build"
# it is forked from https://github.com/xijo/reverse-markdown/blob/master/reverse_markdown.rb
require 'rexml/document'
require 'benchmark'
include REXML
include Benchmark
class ReverseMarkdown
# set basic variables:
# - @li_counter: numbering list item (li) tags in an ordered list (ol)
var images = document.getElementsByTagName('img');
var image;
for (var i = 0; i < images.length; i++) {
image = images[i];
image.removeAttribute("width");
image.removeAttribute("height");
}
Gems:
gem 'cucumber'
gem 'cucumber-rails'
gem 'rspec'
gem 'rspec-rails'
gem 'capybara'
gem 'database_cleaner'
gem 'spork'
gem 'watchr'
@flyerhzm
flyerhzm / commit-msg
Created June 25, 2011 09:51
git commit-msg hook to promise containing jira ticket
###################################################################################
# please add the following codes to .git/hooks/commit-msg, make it be an executable
###################################################################################
#!/usr/bin/env ruby
commit_message = File.read ARGV[0]
unless commit_message =~ /ENGINEERING-\d+/
puts "ERROR: please add jira ticket on git commit message"
exit(1)
@flyerhzm
flyerhzm / gist:1357284
Created November 11, 2011 05:35
git commit-msg hook to promise not committing conflicts
#!/usr/bin/env ruby
`git diff-index --name-only --cached HEAD`.split("\n").each do |filename|
File.open(filename) do |file|
while line = file.gets
if line.include?("<<<<<<<") || line.include?(">>>>>>>")
puts "ERROR: #{filename} is conflict"
exit(1)
end
end
end