Skip to content

Instantly share code, notes, and snippets.

def create_proc(cofactor)
proc = proc { |arg| arg * cofactor }
end
proc1 = create_proc(3)
proc2 = create_proc(5)
proc1.call(2)
=> 6
proc2.call(2)
class User
include Mongoid::Document
include Mongoid::Timestamps::Created
field :language
has_many :profiles
scope :english, ->() do
where(:language => "english")
describe Account do
contex "given an empty account" do
subject { Account.new(0) }
context "when I put money there" do
before { subject.put_money(120) }
its(:amount) { should == 120 }
it { should_not be_empty }
qsort([Threshold | Tail]) ->
{ Left, Right } = split(Threshold, Tail),
qsort(Left) ++ [Threshold] ++ qsort(Right)
;
qsort([]) -> [].
require "activerecord"
ActiveRecord::Base.establish_connection :adapter => "sqlite3", :database => "test.sqlite"
class CategoriesMigration < ActiveRecord::Migration
def self.up
create_table :categories do |t|
t.string :name
t.string :type
end
var zombie = require("zombie");
var assert = require("assert");
// Load the page from localhost
zombie.visit("http://localhost:3000/", function (err, browser, status) {
// Fill email, password and submit form
browser.
fill("session[email]", "[email protected]").
fill("session[password]", "123456").
Genuine === genuine # => true
Genuine === proxy # => false
proxy = UltimateProxy.new(genuine)
proxy.class # => Genuine (despite this looks good...)
access_granted?(proxy) # => false (... we fail)
genuine = Genuine.new
access_granted?(genuine) # => true
class Genuine; end;
def access_granted?(object)
case object
when Genuine
true
else
false
end
end