Skip to content

Instantly share code, notes, and snippets.

namespace :test do
desc 'Measures test coverage'
task :coverage do
rm_f "coverage"
rm_f "coverage.data"
rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib -Itest -x /ruby\/1.8\/gems -x /Gems\/1\.8 -x /Library\/Ruby -x /Library\/Frameworks"
system("#{rcov} --no-html test/unit/*_test.rb")
system("#{rcov} --no-html test/functional/*_test.rb")
system("#{rcov} --html test/integration/*_test.rb")
defaults write com.macromates.textmate OakDefaultLanguage E00B62AC-6B1C-11D9-9B1F-000D93589AF6
# This FSM recognizes the sequence 1 2 3 anywhere in the
# input. Note that 1 2 1 2 3 and 1 1 2 3 and both valid.
class FSM
class State
def initialize(name)
@name = name
@hash = {}
end
# require 'ostruct'
# OpenStruct
class OStruct
def initialize
@attributes = {}
end
def method_missing(name, arg = nil)
if name.to_s =~ /=/
@attributes[name.to_s.sub(%r{=}, '')] = arg
module LoggerThingy
def self.included(klass)
klass.extend LoggerThingy::ClassMethods
end
module ClassMethods
def logger=(logger)
@logger = logger
end
require 'logger'
module Loggable
def self.included(klass)
klass.extend ClassMethods
end
module ClassMethods
def logger=(logger)
@logger = logger
%w|rubygems sinatra|.each{|_|require _}
%w|gem load|.each{|_| send _, 'kitty'}
(k=Kitty).send *%w(define_method print) do |*a| a.join end
get "/" do content_type "text/plain" and k.new.random_kitty end
# gem install kitty
# ruby kitty_server.rb &
# curl http://localhost:4567
threads = []
10.times do |n|
threads << Thread.new do
sleep rand(3)
puts "Hell from thread number #{n}"
end
end
threads.each{|t| t.join}
typedef struct {
VALUE *pc; /* cfp[0] */
VALUE *sp; /* cfp[1] */
VALUE *bp; /* cfp[2] */
rb_iseq_t *iseq; /* cfp[3] */
VALUE flag; /* cfp[4] */
VALUE self; /* cfp[5] / block[0] */
VALUE klass; /* cfp[6] / block[1] */
VALUE *lfp; /* cfp[7] / block[2] */
VALUE *dfp; /* cfp[8] / block[3] */
module A
overlay_module Integer, MyIntegerCrap
class Blah
def do_it
puts 1.day
end
end
end