This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'mq' | |
EM.run do | |
def log(*args) | |
p args | |
end | |
amq = MQ.new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#require 'rubygems' | |
require 'amqp/lib/mq' | |
EM.run do | |
def log(*args) | |
p args | |
end | |
# AMQP.logging = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'eventmachine' | |
module TapsClient | |
def connection_completed | |
p [Time.now, :connected] | |
send_data("hey!") | |
end | |
def receive_data(data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'eventmachine' | |
module ProxyConnection | |
def initialize(client) | |
@client = client | |
end | |
def post_init | |
proxy_incoming_to(@client) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
OlderNewer