This file contains hidden or 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
% rails g model m `ruby -e "801.times {|i| print %(c#{i} )}"` && rake db:migrate | |
% rails r 'p M.new.methods.length' | |
#=> 10000 |
This file contains hidden or 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
if false | |
a = 2 | |
p a | |
else | |
Proc.new do |a| | |
p a | |
end | |
end |
This file contains hidden or 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
+----------------------+--------+--------+---------+---------+-----+-------+ | |
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M | | |
+----------------------+--------+--------+---------+---------+-----+-------+ | |
| Controllers | 48726 | 39215 | 522 | 3970 | 7 | 7 | | |
| Helpers | 14795 | 12125 | 15 | 1399 | 93 | 6 | | |
| Models | 96678 | 76140 | 1747 | 8548 | 4 | 6 | | |
| Mailers | 2208 | 1766 | 44 | 206 | 4 | 6 | | |
| Workers | 639 | 540 | 20 | 31 | 1 | 15 | | |
| Chanko units | 11713 | 9644 | 6 | 247 | 41 | 37 | | |
| Libraries | 50409 | 41650 | 592 | 3741 | 6 | 9 | |
This file contains hidden or 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
# put this piece of code in your spec/spec_helper.rb or spec/support/any_rb_file.rb | |
# then run `rake spec` | |
module CleanerBench | |
def clean(*) | |
now = Time.now | |
super | |
@time_spent ||= 0 | |
@time_spent += Time.now - now | |
end |
This file contains hidden or 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
Kernel.class_eval do | |
#FIXME this is terrible | |
def static(meth) | |
define_singleton_method(meth) do |*args, &b| | |
new.send meth, *args, &b | |
end | |
meth | |
end | |
def abstract(meth) |
This file contains hidden or 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
if false | |
a = 1 | |
end | |
p a | |
#=> nil | |
p b | |
#=> undefined local variable or method `b' for main:Object (NameError) |
This file contains hidden or 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
S = 'foo' | |
class A | |
def a() S; end | |
end | |
class B < BasicObject | |
# needs to be ::S | |
def b() ::S; end | |
end |
This file contains hidden or 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 'cases/helper' | |
require 'cases/migration/helper' | |
require MIGRATIONS_ROOT + '/valid/2_we_need_reminders' | |
class Reminder < ActiveRecord::Base; end | |
class FailingMigrationTest < ActiveRecord::TestCase | |
self.use_transactional_fixtures = false |
This file contains hidden or 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
% rake stats | |
+----------------------+-------+-------+---------+---------+-----+-------+ | |
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M | | |
+----------------------+-------+-------+---------+---------+-----+-------+ | |
| Controllers | 4327 | 3478 | 110 | 361 | 3 | 7 | | |
| Helpers | 384 | 331 | 0 | 35 | 0 | 7 | | |
| Models | 2912 | 2177 | 84 | 226 | 2 | 7 | | |
| Libraries | 281 | 230 | 8 | 39 | 4 | 3 | | |
| Model specs | 3096 | 2663 | 0 | 0 | 0 | 0 | | |
| Controller specs | 1005 | 783 | 0 | 3 | 0 | 259 | |
This file contains hidden or 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
# do not shallow_clone from Git repo | |
namespace :deploy do | |
namespace :assets do | |
# perform precompile only when any of the asset files has changed since the last deploy | |
task :precompile, :roles => :web, :except => {:no_release => true} do | |
from = source.next_revision(current_revision) | |
asset_changing_files = ['vendor/assets/', 'app/assets/', 'lib/assets', 'Gemfile', 'Gemfile.lock'].select {|f| File.exists? f} | |
if capture("cd #{latest_release} && #{source.local.log(from)} #{asset_changing_files.join(' ')} | wc -l").to_i > 0 |