Skip to content

Instantly share code, notes, and snippets.

Ilya Grigorik igrigorik

View GitHub Profile
View gist:136188
require 'rubygems'
require 'benchmark'
require 'fadvise'
string = "abcdefghijklmna"
1000.times do |n|
View nginx-comet.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/;
events {
worker_connections 1024;
View lucene-stats.rb
require 'rubygems'
require 'ruport'
require 'pp'
path = ARGV[0]
stats = {}
types = {
'gen' => 'Segments File: stores information about segments',
'lock' => 'Lock File: the Write lock prevents multiple IndexWriters from writing to the same file.',
View canine.rb
class Canine
VERSION = '1.3'
def initialize(&block)
@commands =
@default = @latest = :commands
@empty = nil
@auto = {
:commands => hash_command("commands","Show a list of commands", {
@commands.each { |cmd| c = cmd[1]
name = c[:name].to_s
View gist:262924
WORKING With Net:Http :
def twitter_oauth_consumer
@consumer ||=['twitter_consumer_key'],APP_CONFIG['twitter_consumer_secret'],{ :site=>"" })
def twitter_oauth_token
@token ||=, oauth_token, oauth_secret)
View url_dsl.rb
require 'open-uri'
# url dsl -- the ultimate url dsl!
# You just can't beat this:
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >>
View README.rdoc

Rails 2.3.5 on App Engine (TinyDS)

Recently, Takeru Sasaki was able to patch the Rails 2.3.5 calls to rubygems, and now we have it working on App Engine. He also created a datastore adapter called TinyDS. I just created an integration plugin called Rails_TinyDS that provides certain ActiveRecord method calls for Rails 2.3.5 generated scaffold.

See the DataMapper version also:

Install the Development Environment

The gems for the development environment include a pre-release appengine-tools gem that provides a pre-release version of jruby-rack.

sudo gem install google-appengine
View gist:290395
# gem install em-proxy
require 'rubygems'
require 'em-proxy'
APP_ROOT = File.expand_path(ARGV[0])
module Unicorn
View iterator.rb
module EventMachine
# A simple iterator for concurrent asynchronous work.
# Unlike ruby's built-in iterators, the end of the current iteration cycle is signaled manually,
# instead of happening automatically after the yielded block finishes executing. For example:
# (0..10).each{ |num| }
# becomes:
View gist:331454
require 'rubygems'
require 'eventmachine'
require 'em-http' # gem install em-http-request
require 'yajl' # gem install yajl-ruby
module ChatClient
def post_init
@name = "anonymous_#{ChatClient.client_num+=1}"
@sid =
@buf = ''
You can’t perform that action at this time.