Skip to content

Instantly share code, notes, and snippets.

View igrigorik's full-sized avatar
:octocat:

Ilya Grigorik igrigorik

:octocat:
View GitHub Profile
class Proc
def <<(other)
case other
when Proc
Proc.new do |*args|
call(other.call(*args))
end
else
call(other)
end
/*-------- Here's how your Gists render in #newtwitter's details pane --------*/
twttr.mediaType('twttr.media.types.Gist')
.url('http://gist.github.com')
.matcher(/\b(?:https?\:\/\/)?gist\.github\.com\/(\S+)/g)
.icon('generic')
require 'java'
begin
require 'jar/netty-3.2.2.Final'
rescue LoadError
require 'fileutils'
FileUtils.mkdir_p 'jar'
system "wget -O jar/netty-3.2.2.Final.jar http://repository.jboss.org/nexus/content/groups/public-jboss/org/jboss/netty/netty/3.2.2.Final/netty-3.2.2.Final.jar"
require 'jar/netty-3.2.2.Final'
end
@tmm1
tmm1 / gist:630606
Created October 17, 2010 06:42
changes made to mongrel ragel parser in Thin
--- mongrel/ext/http11/http11_parser_common.rl 2010-10-13 01:08:57.000000000 -0700
+++ thin/ext/thin_parser/common.rl 2010-06-18 18:36:01.000000000 -0700
@@ -11,11 +11,12 @@
safe = ("$" | "-" | "_" | ".");
extra = ("!" | "*" | "'" | "(" | ")" | ",");
reserved = (";" | "/" | "?" | ":" | "@" | "&" | "=" | "+");
- unsafe = (CTL | " " | "\"" | "#" | "%" | "<" | ">");
+ sorta_safe = ("\"" | "<" | ">");
+ unsafe = (CTL | " " | "#" | "%" | sorta_safe);
national = any -- (alpha | digit | reserved | extra | safe | unsafe);
export RUBY_HEAP_MIN_SLOTS=1000000
export RUBY_HEAP_SLOTS_INCREMENT=1000000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=1000000000
export RUBY_HEAP_FREE_MIN=500000
@tmm1
tmm1 / gist:648512
Created October 27, 2010 05:37
http proxymachine api brainstorm
# load balancing
# send incoming requests to one of 10 backends running on ports 5000-5009
HttpProxyMachine.start do
{ :host => 'localhost', :port => 5000 + rand(10) }
end
# host based routing
# send requests for media.server/file to localhost:3000/media/file
# all other requests are unmodified
HttpProxyMachine.start do |request|
@iragsdale
iragsdale / async_resolver.rb
Created November 4, 2010 22:07
Asynchronous DNS resolver based on EventMachine and net-dns
require 'eventmachine'
require 'net/dns'
require 'net/dns/resolver'
module EM # :nodoc:
module Protocols
include Logger::Severity
class AsyncResolver < Net::DNS::Resolver
@guenter
guenter / move_to_rds.rb
Created November 11, 2010 02:14
A quick and dirty script to move a database into Amazon RDS (or any other database). Can transfer part of the data beforehand.
require 'fileutils'
start_time = Time.now
SOURCE_DB = {
:name => 'db_name',
:user => 'db_user',
:password => 'db_pass',
:host => 'localhost'
@woodie
woodie / .SETUP
Created November 23, 2010 08:23
gem install dubious
$ sudo jruby -S gem install dubious
Successfully installed bitescript-0.0.7
Successfully installed mirah-0.0.4-java
Successfully installed thor-0.13.8
Successfully installed activesupport-3.0.3
Successfully installed i18n-0.4.2
Successfully installed appengine-sdk-1.3.8
Successfully installed dubious-0.0.1-java
7 gems installed
@karmi
karmi / .gitignore
Created December 1, 2010 10:06
Simple ping:pong WebSockets server and client in Ruby (em-http and em-websocket
Gemfile.lock