This file contains 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 "bundler/setup" | |
require "active_record" | |
begin | |
require "benchmark/ips" | |
rescue LoadError | |
raise LoadError, "Run install `gem install benchmark-ips`" | |
end | |
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
ActiveRecord::Base.connection.create_table(:orders) { |t| } |
This file contains 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 "bundler/setup" | |
require "active_record" | |
require "benchmark/ips" | |
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
ActiveRecord::Base.connection.create_table(:orders) { |t| } | |
ActiveRecord::Base.connection.create_table(:items) do |t| | |
t.references :order, null: false | |
t.references :product, null: false | |
end |
This file contains 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
#!/usr/bin/env ruby | |
working_dir = 'working' | |
Repo = Struct.new(:name, :url, :branch) | |
repos = [ | |
Repo.new('rspec', '[email protected]:rspec/rspec.git'), | |
Repo.new('rspec-core', '[email protected]:rspec/rspec-core.git'), | |
Repo.new('rspec-expectations', '[email protected]:rspec/rspec-expectations.git'), | |
Repo.new('rspec-mocks', '[email protected]:rspec/rspec-mocks.git'), |
This file contains 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
desc "Copies order insertion" | |
task :copy_order_insertion => :environment do | |
current_version = ENV['CURRENT_VERSION'].try(:upcase) | |
raise "Must specify CURRENT_VERSION" unless current_version | |
new_version = ENV['NEW_VERSION'].try(:upcase) | |
raise "Must specify NEW_VERSION" unless new_version | |
# copy files | |
paths = %w[ | |
app/models |
This file contains 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
git commit -m "Removed trailing whitespace" --author="Whitespace Remover <[email protected]>" |
This file contains 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
class Lisp | |
Fs = { | |
:label => lambda {|name,value| Fs[name] = lambda { value } }, | |
:car => lambda {|sexp| sexp.first }, | |
:cdr => lambda {|sexp| sexp.slice(1, sexp.size) }, | |
:cons => lambda {|head,tail| [head] + tail }, | |
:atom => lambda {|sexp| !sexp.is_a?(Array) }, | |
:eq => lambda {|a,b| a == b }, | |
:if => lambda {|cnd,thn,els| cnd ? thn : els } | |
} |
This file contains 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
String.class_eval { def instance_method; "instance method"; end } | |
String.class.class_eval { def class_method; "class method"; end } | |
String.class.class.class_eval { def eigenclass_method; "eigenclass method"; end } | |
"a".instance_method # => "instance method" | |
String.class_method # => "class method" | |
class X < String | |
eigenclass_method | |
end # => "eigenclass method" |