Skip to content

Instantly share code, notes, and snippets.

View tmm1's full-sized avatar

Aman Gupta Karmani tmm1

View GitHub Profile
require 'rubygems'
require 'mq'
EM.run do
def log(*args)
p args
end
amq = MQ.new
#require 'rubygems'
require 'amqp/lib/mq'
EM.run do
def log(*args)
p args
end
# AMQP.logging = true
@tmm1
tmm1 / client.rb
Created October 31, 2008 21:21 — forked from bmizerany/client.rb
require 'rubygems'
require 'eventmachine'
module TapsClient
def connection_completed
p [Time.now, :connected]
send_data("hey!")
end
def receive_data(data)
@tmm1
tmm1 / gist:80053
Created March 16, 2009 20:27 — forked from raggi/gist:79926
# async_sinatra_example.ru
require 'sinatra'
# Normally Sinatra::Base expects that the completion of a request is
# determined by the block exiting, and returning a value for the body.
#
# In an async environment, we want to tell the webserver that we're not going
# to provide a response now, but some time in the future.
#
# The a* methods provide a method for doing this, by informing the server of
@tmm1
tmm1 / example_note_keeping_app.rb
Created April 11, 2009 13:48 — forked from pietern/example_note_keeping_app.rb
sinatra + redis note keeping app
require 'rubygems'
require 'sinatra'
require 'redis'
# To use, simply start your Redis server and boot this
# example app with:
# ruby example_note_keeping_app.rb
#
# Point your browser to http://localhost:4567 and enjoy!
#
@tmm1
tmm1 / gist:111491
Created May 14, 2009 04:55 — forked from mattetti/gist:111453
net/http vs fibered em-http
require 'net/http'
require 'uri'
url = URI.parse 'http://localhost:5984/test/test'
req = Net::HTTP::Get.new(url.path)
start = Time.now
100.times do
http = Net::HTTP.start(url.host, 5984)
http.request(req)
# What is the best way to get it to put out a, b, c
# without erroring about the superclass. The module
# inclusion order should not matter. In other words,
# I should be able to include A then B or B then A
# and either way all the letters a, b, and c are
# printed out (though not necessarily in that exact order)
module A
def foo
super
@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 / dpkg.rb
Created September 13, 2011 02:40 — forked from benburkert/dpkg.rb
homebrew formula to get dpkg working a mac
require 'formula'
class Dpkg <Formula
url 'http://ftp.de.debian.org/debian/pool/main/d/dpkg/dpkg_1.16.0.3.tar.bz2'
homepage 'http://en.wikipedia.org/wiki/Dpkg'
md5 '0266b06ef9da8278cea008d21e17e5f6'
depends_on 'gnu-tar'
# depends_on 'cmake'
diff --git a/ext/ruby_http_parser/ruby_http_parser.c b/ext/ruby_http_parser/ruby_http_parser.c
index 119d7e1..5650652 100644
--- a/ext/ruby_http_parser/ruby_http_parser.c
+++ b/ext/ruby_http_parser/ruby_http_parser.c
@@ -320,6 +320,9 @@ VALUE Parser_execute(VALUE self, VALUE data) {
size_t nparsed = ryah_http_parser_execute(&wrapper->parser, &settings, ptr, len);
if (wrapper->parser.upgrade) {
+ if (RTEST(wrapper->stopped))
+ nparsed += 1;