View gist:8ed895c2de3cff57bcb5ae9f256f5268
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| } |
View gist:06c9655209b1cc85df87ae8894a6dcd4
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 |
View merge.rb
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', 'git@github.com:rspec/rspec.git'), | |
Repo.new('rspec-core', 'git@github.com:rspec/rspec-core.git'), | |
Repo.new('rspec-expectations', 'git@github.com:rspec/rspec-expectations.git'), | |
Repo.new('rspec-mocks', 'git@github.com:rspec/rspec-mocks.git'), |
View gist:0b308317c45c7d9d10ec01fc59b30fe6
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 |
View gist:6493058
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 <whitespace-remover@example.com>" |
View lithp.rb
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 } | |
} |
View eigenclass
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" |