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

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

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
# Hey coops..
#
# Imagine yourself on the other side of the table: two job openings, hundreds of resumes,
# _all of which_ look friggin' identical. Yeah, the HR departments at your MegaCorp XYZ are using
# automated tools to scan for keywords, and the coop department at your school is trying to beat
# you into submission to follow some "predefined template".. But, unless what you're aspiring to
# is to be an automaton at MegaCorp XYZ, relegated to writing test harnesses for code that will
# never see the light of day.. please do yourself a favor, and _be different_! Be bold, dammit.
#
# (Frankly, I'm falling asleep while reading your resumes.. Wake me up! Srsly.)
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:
#