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
class BottomlessHash < Hash
def initialize
super &-> h, k { h[k] = self.class.new }
end
def self.from_hash(hash)
new.merge(hash)
end
end
@flyerhzm
flyerhzm / exporter.rb
Last active August 29, 2015 14:14 — forked from jcasimir/exporter.rb
require 'csv'
module Exporter
DEFAULT_EXPORT_TABLES = [ Invoice, InvoiceItem, Item, Merchant, Transaction, User ]
DESTINATION_FOLDER = "tmp/"
def self.included(klass)
klass.extend ClassLevelMethods
end
@flyerhzm
flyerhzm / exporter.rb
Last active August 29, 2015 14:14 — forked from jcasimir/exporter.rb
require 'csv'
module Exporter
DEFAULT_EXPORT_TABLES = [ Invoice, InvoiceItem, Item, Merchant, Transaction, User ]
DESTINATION_FOLDER = "tmp/"
def self.included(klass)
klass.extend ClassLevelMethods
end
@flyerhzm
flyerhzm / image.rb
Last active August 22, 2022 11:37 — forked from basgys/simple_paperclip.rb
paperclip without activerecord
class Image
extend ActiveModel::Naming
extend ActiveModel::Callbacks
include ActiveModel::Validations
include Paperclip::Glue
define_model_callbacks :save, only: [:after]
define_model_callbacks :destroy, only: [:before, :after]
#! /bin/sh
### BEGIN INIT INFO
# Provides: god
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: God initscript
### END INIT INFO
@flyerhzm
flyerhzm / 0-readme.md
Created April 4, 2012 14:42 — forked from burke/0-readme.md
ruby-1.9.3-p125 cumulative performance patch.

Patched ruby 1.9.3-p125 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p125 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Huge thanks to funny-falcon for the performance patches.

Gems:
gem 'cucumber'
gem 'cucumber-rails'
gem 'rspec'
gem 'rspec-rails'
gem 'capybara'
gem 'database_cleaner'
gem 'spork'
gem 'watchr'
#!/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"
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)
daemon off;
worker_processes 6;
user nobody nobody;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {