This file contains 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
# Use git and git+ssh instead of https | |
[url "git://github.com/"] | |
insteadOf = https://github.com/ | |
[url "[email protected]:"] | |
pushInsteadOf = "git://github.com/" | |
[url "[email protected]:"] | |
pushInsteadOf = "https://github.com/" |
This file contains 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
# simple Socket API | |
module EventMachine | |
class Socket | |
class Client < EM::Connection | |
def initialize socket | |
@socket = socket | |
end | |
attr_accessor :socket | |
This file contains 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
## | |
# sync api: return values and exceptions | |
begin | |
images = [] | |
results = RestClient.get('http://google.com/search?q=ruby') | |
Hpricot(results).find('a').each{ |link| | |
page = RestClient.get(link) | |
begin |
This file contains 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
if __FILE__ == $0 | |
require 'em/spec' | |
class TestConnection | |
include EM::P::Memcache | |
def send_data data | |
sent_data << data | |
end | |
def sent_data | |
@sent_data ||= '' |
This file contains 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' | |
### EM::run takes over the process | |
# puts 1 | |
# EM.run{ | |
# require 'mycode' | |
# } | |
# puts 3 # this will never happen |
This file contains 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 |