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 'spec' | |
class Person | |
def awesome? | |
true | |
end | |
end | |
describe Person do | |
it "should return all people" do | |
Person.should_receive(:all).and_return [] |
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 'test/unit' | |
class Strange<Test::Unit::TestCase | |
def test_x | |
assert_raises NameError do | |
strange | |
end | |
begin | |
strange = THIS_CONSTANT_IS_MISSING | |
rescue NameError # we expect this | |
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 'benchmark' | |
class Chad | |
def a_method | |
1 | |
end | |
end | |
c = Chad.new | |
Benchmark.bmbm do |bm| | |
bm.report("send") {100000.times{ c.send(:a_method)}} |
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
# *&^)^(&(&&*^)^(* encoding: utf-8 *)*)&)^)^%*%&*%** | |
ÜglÈÊCÕnsªnt = "HAIUGLYCODEZ" | |
alias :send ∴; alias :get ∵ | |
%w|rubygems sinatra|.each{|_|require _} | |
%w|gem load|.each{|_| ∴ _, 'kitty'} | |
(℧=Kitty).∴ *%w(define_method print) do |*⇧| ⇧.∴:join end | |
∵ %r{\/} do content_type "nialp/txet".reverse and ℧.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
module A | |
overlay_module Integer, MyIntegerCrap | |
class Blah | |
def do_it | |
puts 1.day | |
end | |
end | |
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
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
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
%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
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
module LoggerThingy | |
def self.included(klass) | |
klass.extend LoggerThingy::ClassMethods | |
end | |
module ClassMethods | |
def logger=(logger) | |
@logger = logger | |
end |