Skip to content

Instantly share code, notes, and snippets.

require File.dirname(__FILE__) + '/../ext/fiber18'
require 'bacon'
class Bacon::EventMachineContext < Bacon::Context
alias :_it :it
def it *args
_it(*args){ if block_given? then yield; Fiber.yield end }
end

The Jesus Nut

Run thin:

$ thin -R thin/jesus_nut.ru -p 4000 start

Run the sinatra app:

$ ruby rabbit_rackup.rb
require 'rubygems'
#require "#{File.dirname(__FILE__)}/easy_sin"
require 'rubygems'
require 'mq'
require 'json'
require 'uuid'
require 'rabbited_sinatra'
@careo
careo / snippet.rb
Created February 18, 2009 21:38 — forked from anonymous/snippet.rb
require 'benchmark'
require 'rubygems'
require 'rest_client'
Benchmark.bm(25) do |x|
etag = nil
x.report("(freshen view, fetch etag)") do
resp = RestClient.get "localhost:5984/gateway-development/_view/Image/all?include_docs=true&reduce=false"
require 'rubygems'
require 'eventmachine'
module EventMachine
module ChildProcess
def initialize
@buffer = []
end
require 'rubygems'
require 'eventmachine'
module Dtach
def post_init
puts "starting"
end
def receive_data data
require 'mq'
require 'pp'
EM.run {
def log *args
p args
end
mq = MQ.new

EventMachine Notes

Adapted to Markdown format from rom Aman Gupta's gist at: http://gist.github.com/79224

Using:

require 'rubygems'
require 'eventmachine'

EM::run Takes over the Process

require 'rubygems'
require 'eventmachine'
$stdout.sync = true
$stderr.sync = true
EM.run {
EM.add_periodic_timer(0.1) {
$stdout.write "stdout\n"
require 'pp'
require 'uri'
require 'rubygems'
require 'json/ext'
require 'eventmachine'
require 'dnsruby'
require '/Users/djensen/Projects/em-http-request/lib/em-http'