Skip to content

Instantly share code, notes, and snippets.

Avatar

James Tucker raggi

View GitHub Profile
View bbsterm.rb
require 'eventmachine'
require 'kconv'
class BBSTerm < EM::Connection
def post_init
@read_buffer = ""
@initialization = true
end
def receive_data(data)
View Example.rb
# Example of the implementation
class Template
module CompileSite; end
def compile(klass, name, source)
klass.class_eval <<-RUBY
lambda {}.binding.__send__ :eval, <<-RB
def \#{name}(locals)
\#{source}
View return.rb
module Enumerable
def return
each do |i|
value = yield(i)
return value if value
end
nil
end
end
View benchmark.rb
require "benchmark"
class Hash
# Performs the opposite of <tt>merge</tt>, with the keys and values from the first hash taking precedence over the second.
def reverse_merge(other_hash)
other_hash.merge(self)
end
# Performs the opposite of <tt>merge</tt>, with the keys and values from the first hash taking precedence over the second.
# Modifies the receiver in place.
def reverse_merge!(other_hash)
View gist:61367
class FiberedMutex
#
# Creates a new FiberedMutex
#
def initialize
@waiting = []
@locked = false
end
#
View config.ru
#!/usr/bin/env rackup
require 'forward'
run Rack::Forwarder.new('google.com')
View config.ru
#!/usr/bin/env thin -e production -R config.ru -V start
# config.ru
# N.B. Rack::Lint doesn't yet support the api, use production mode rack.
require 'eventmachine'
class AsyncApp
class DeferrableBody
include EventMachine::Deferrable