Skip to content

Instantly share code, notes, and snippets.

View tmm1's full-sized avatar

Aman Karmani tmm1

View GitHub Profile
diff --git a/Gemfile b/Gemfile
index 3e1c3e6..2a45190 100644
--- a/Gemfile
+++ b/Gemfile
@@ -20,6 +20,8 @@ gem "system_timer", "1.0"
gem "will_paginate", "3.0.pre2"
gem "xml-simple", "1.0.12"
+gem "memprof", "0.3.10.beta.1"
+
@tmm1
tmm1 / README.md
Created February 10, 2011 05:33
no longer requires any proxies! just replace your enhancers.js. also see https://gist.github.com/821736
@tmm1
tmm1 / gist:818340
Created February 9, 2011 11:31
working prototype of rbtrace
~/code/rbtrace (master*) % cat server.rb
require 'rbtrace'
while true
Dir.chdir("/tmp") do
sleep rand*0.5
end
end
~/code/rbtrace (master*) % ruby server.rb &
@tmm1
tmm1 / sigh.rb
Created January 2, 2011 23:31 — forked from hobodave/sigh.rb
require 'rubygems'
require 'eventmachine'
module ProxyConnection
def initialize(client)
@client = client
end
def post_init
proxy_incoming_to(@client)
@tmm1
tmm1 / http_response_parser.rb
Created November 7, 2010 00:07
simple http response parser
module MyHttpConnection
def connection_completed
@parser = Http::Parser.new(self)
end
def receive_data(data)
@parser << data
unless @headers_done
@raw_headers << data
@tmm1
tmm1 / gist:650761
Created October 28, 2010 06:21
patch to use ruby_http_parser in em-http (add jruby support to em-http)
diff --git a/Gemfile b/Gemfile
index c0358ae..f25380e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,14 +1,29 @@
-source :gemcutter
+source :rubygems
-gem 'eventmachine', '~> 0.12.9'
+gem 'eventmachine', '~> 0.12.11'
@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|
$ ruby -v
jruby 1.5.3 (ruby 1.8.7 patchlevel 249) (2010-09-28 7ca06d7) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_20) [x86_64-java]
$ ruby -e' require "lib/http11.jar"; p Mongrel '
-e:1: uninitialized constant Mongrel (NameError)
$ ruby -I lib -e' require "http11.jar"; p Mongrel '
Mongrel
@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);
@tmm1
tmm1 / gist:623663
Created October 13, 2010 08:16
changes made to mongrel parser in Thin
--- /tmp/http11.c 2010-10-13 01:16:03.000000000 -0700
+++ /tmp/thin.c 2010-10-13 01:16:14.000000000 -0700
@@ -1,22 +1,22 @@
/**
- * Copyright (c) 2005 Zed A. Shaw
+ * Mongrel Parser adpated to Thin and to play more nicely with Rack specs.
+ *
+ * Orignal version Copyright (c) 2005 Zed A. Shaw
* You can redistribute it and/or modify it under the same terms as Ruby.
*/