Skip to content

Instantly share code, notes, and snippets.

View zliang-min's full-sized avatar

Gimi Liang zliang-min

View GitHub Profile
# Factory girl, relaxed.
#
# Factory.define :user do |f|
# f.login 'johndoe%d' # Sequence.
# f.email '%{login}@example.com' # Interpolate.
# f.password f.password_confirmation('foobar') # Chain.
# end
#
# Factory.define :post do |f|
# f.user { Factory :user } # Blocks, if you must.
@zliang-min
zliang-min / oshi.rb
Created July 8, 2010 14:11 — forked from anonymous/oshi.rb
a websocket example
require 'rubygems'
require 'eventmachine'
require 'em-websocket'
require 'json'
class Connection
attr_accessor :socket, :user_id
def initialize(socket, user_id)
@socket = socket
'''
redis_search.py
Written by Josiah Carlson July 3, 2010
Released into the public domain.
This module implements a simple TF/IDF indexing and search algorithm using
@zliang-min
zliang-min / pws.rb
Created November 2, 2010 17:06 — forked from janlelis/pws.rb
generate password
#!/usr/bin/env ruby
# pws
# see http://rbjl.net/41-tutorial-build-your-own-password-safe-with-ruby for more information
require 'rubygems' if RUBY_VERSION[2] == ?8
require 'openssl'
require 'fileutils'
require 'clipboard' # gem install clipboard
@zliang-min
zliang-min / webapp.rb
Created November 19, 2010 17:18 — forked from igrigorik/webapp.rb
Object webapp
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
@zliang-min
zliang-min / memory_bloat.rb
Created January 25, 2011 08:21 — forked from quake/memory_bloat.rb
一个检查内存泄漏的rack中间件
module Rack
class MemoryBloat
def initialize(app, logger)
@app = app
@logger = logger
end
def call(env)
memory_usage_before = memory_usage
result = @app.call(env)
@zliang-min
zliang-min / ruby-1.9-tips.rb
Created February 6, 2011 03:52 — forked from igrigorik/ruby-1.9-tips.rb
ruby-1.9-tips
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
diff --git a/gc.c b/gc.c
--- a/gc.c
+++ b/gc.c
@@ -77,6 +77,41 @@ void *alloca ();
#ifndef GC_MALLOC_LIMIT
#define GC_MALLOC_LIMIT 8000000
#endif
+#define HEAP_MIN_SLOTS 10000
+#define FREE_MIN 4096
+
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
Ignore the number prefixes on each file. This is just to ensure proper order in the Gist.
module Test
module Unit
TestCase = RSpec::Core::ExampleGroup
end
end
class Test::Unit::TestCase
def self.inherited(host)
host.set_it_up host.name.gsub(/(Spec|Test)/,'')
def host.method_added(name)