Skip to content

Instantly share code, notes, and snippets.

View floere's full-sized avatar
😁
Open Sourcing

Florian R. Hanke floere

😁
Open Sourcing
View GitHub Profile
# Encoding: UTF-8
#
require 'fiber'
# This accepts generated frames and prints them.
#
target = Fiber.new do
loop do
frame = Fiber.yield
puts "Frame received: #{frame}."
# puts (s="puts (s=%s)%%s.dump")%s.dump
require 'rspec'
RSpec::Core::Runner.disable_autorun!
describe "foo" do
it "bar" do
end
it "baz", :banane => true do
end
@floere
floere / webapp.rb
Created November 13, 2010 23:57 — forked from igrigorik/webapp.rb
require 'rubygems'
require 'rack'
class Object
def webapp
def call(env)
func, *attrs = env['REQUEST_PATH'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
self
module Kernel
def memory_consumption
`ps -o rss= -p #{Process.pid}`.to_i
end
alias :require_without_profiling :require
def require(file,*args)
mem_before = memory_consumption
require_without_profiling(file, *args)
class FooError < StandardError; end
module BulletProof
def self.included(base)
base.extend ClassMethods
end
# blatantly stolen: http://blog.codefront.net/2008/01/14/retrying-code-blocks-in-ruby-on-exceptions-whatever/
def retryable(options = {}, &block)
class LazyProxy
instance_methods.each do |method|
undef_method(method) if method !~ /^__/
end
def initialize &lazy_proxy_block
@lazy_proxy_block = lazy_proxy_block
end
@floere
floere / floppy.rb
Created February 8, 2010 23:18 — forked from pjb3/floppy.rb
class Floppy
def method_missing(method, *args)
super unless args.length > 0 && method.to_s[-1..-1] == "="
if args.first.is_a?(Proc)
(class << self; self; end).class_eval do
define_method(method.to_s[0..-2].to_sym, args.first)
end
else
(class << self; self; end).send(:attr_accessor, method.to_s[0...-1])
@floere
floere / ministubs.rb
Created January 28, 2010 13:29
ministubs, based on nikos ministubs
require 'rubygems'
require 'minitest/unit'
require 'minitest/spec'
MiniTest::Unit.autorun
# This walks the given stub strings and sets up partial stub responder chains.
#
class StubBuilder