This file contains hidden or 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
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") |
This file contains hidden or 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
defaults write com.macromates.textmate OakDefaultLanguage E00B62AC-6B1C-11D9-9B1F-000D93589AF6 |
This file contains hidden or 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
# 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 |
This file contains hidden or 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 '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 |
This file contains hidden or 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
module LoggerThingy | |
def self.included(klass) | |
klass.extend LoggerThingy::ClassMethods | |
end | |
module ClassMethods | |
def logger=(logger) | |
@logger = logger | |
end |
This file contains hidden or 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 'logger' | |
module Loggable | |
def self.included(klass) | |
klass.extend ClassMethods | |
end | |
module ClassMethods | |
def logger=(logger) | |
@logger = logger |
This file contains hidden or 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
%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 |
This file contains hidden or 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
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} |
This file contains hidden or 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
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] */ |
This file contains hidden or 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
module A | |
overlay_module Integer, MyIntegerCrap | |
class Blah | |
def do_it | |
puts 1.day | |
end | |
end | |
end | |