Skip to content

Instantly share code, notes, and snippets.

View carllerche's full-sized avatar
😎
working

Carl Lerche carllerche

😎
working
View GitHub Profile
module Rails
module Initializable
# A collection of initializers
class Collection
def initialize(context)
@context = context
@keys = []
@values = {}
@ran = false
class Rails::Application
initializer :require_frameworks do
require "action_pack"
end
end
class Rails::Application::Sinatra
initializer :load_in_file_templates do
# Go through app code files and check for templates
end
clear_sources
bundle_path "vendor/bundler_gems"
bin_path "vendor/bin"
source "http://gemcutter.org"
source "http://gems.github.com"
gem "rails", "2.3.4", :only => :bundle
gem "clearance"
gem "will_paginate"
class User
include DataMapper::Resource
def w0t
User.create
end
end
u1 = nil
u2 = nil
# heredocs can continue the code on the same line:
class SomeController
def render opts
p opts
end
def setup; false; end
def action_a
###
class Foo
def initialize
self.im_private # FAIL
end
private
def im_private
puts "PRIVATE"
end
end
require "rubygems"
require "rbench"
def omg_slow
return 1
end
def omg_fast
1
end
require "benchmark"
def do_it
i = 0
while i < 10_000_000
Object.allocate
Object.new
i+=1
end
end
def hello
my_proc = do |a, b|
a + b
end
my_proc[1, 2]
my_proc[2, 4]
end
require "rubygems"
require "spec"
module MatcherComposition
include Spec::Matchers
def +(other_matcher)
# Build a new simple matcher that combines self and the other matcher
simple_matcher("#{description} and #{other_matcher.description}") do |given, matcher|
matcher.negative_failure_message = ""