Skip to content

Instantly share code, notes, and snippets.

Ilya Grigorik igrigorik

Block or report user

Report or block igrigorik

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:136188
# http://www.iit.edu/~kbloom1/blog/posix_fadvise.html
# http://www.lucas-nussbaum.net/blog/?p=313
# http://rubyforge.org/frs/?group_id=2338&release_id=35811
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/nginx.pid;
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 = Hash.new
@default = @latest = :commands
@empty = nil
@auto = {
:commands => hash_command("commands","Show a list of commands",Proc.new {
@commands.each { |cmd| c = cmd[1]
name = c[:name].to_s
View gist:262924
WORKING With Net:Http :
def twitter_oauth_consumer
@consumer ||= OAuth::Consumer.new(APP_CONFIG['twitter_consumer_key'],APP_CONFIG['twitter_consumer_secret'],{ :site=>"http://twitter.com" })
@consumer
end
def twitter_oauth_token
@token ||= OAuth::AccessToken.new(self.twitter_oauth_consumer, oauth_token, oauth_secret)
@token
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
# >> http://github.com/defunkt.json
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: gist.github.com/268192

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 = ChatClient.channel.subscribe(method(:send_msg))
@buf = ''
You can’t perform that action at this time.