Skip to content

Instantly share code, notes, and snippets.

require 'spec'
class Person
def awesome?
true
end
end
describe Person do
it "should return all people" do
Person.should_receive(:all).and_return []
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
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)}}
# *&^)^(&(&&*^)^(* 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
module A
overlay_module Integer, MyIntegerCrap
class Blah
def do_it
puts 1.day
end
end
end
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] */
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}
%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
require 'logger'
module Loggable
def self.included(klass)
klass.extend ClassMethods
end
module ClassMethods
def logger=(logger)
@logger = logger
module LoggerThingy
def self.included(klass)
klass.extend LoggerThingy::ClassMethods
end
module ClassMethods
def logger=(logger)
@logger = logger
end