Skip to content

Instantly share code, notes, and snippets.

View igrigorik's full-sized avatar
:octocat:

Ilya Grigorik igrigorik

:octocat:
View GitHub Profile
# 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|
#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;
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.',
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
@igrigorik
igrigorik / gist:262924
Created December 24, 2009 00:09 — forked from penso/gist:262598
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
@igrigorik
igrigorik / url_dsl.rb
Created December 26, 2009 23:23 — forked from defunkt/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

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
# gem install em-proxy
require 'rubygems'
require 'em-proxy'
APP_ROOT = File.expand_path(ARGV[0])
module Unicorn
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:
#
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 = ''