Tests build confidence. Write 'em. They'll save your ass, and they'll let you take a chainsaw to your code without being afraid of unintended consequences.
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
namespace :db do | |
task :migrate => :clear_load_paths do | |
Dependencies.load_paths = @old_load_paths | |
end | |
task :clear_load_paths do | |
@old_load_paths = Dependencies.load_paths | |
Dependencies.load_paths = [] | |
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
def Object.method_defined_where(method) | |
self.ancestors.detect { |a| a.methods(false).include?(method.to_s) } | |
end | |
#Usage - define in your .irbrc and then: | |
#File.method_defined_where('read') | |
#=> IO | |
#Alternatively it has been added to my copy of utility_belt: http://github.com/timocratic/utility-belt/commit/74397c4f8be135cf46f65ca509ddb90e2e47799e | |
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
def foo(value) | |
"#{value}foo" | |
end | |
[1,2].map &method(:foo) | |
#=> ["1foo", "2foo"] | |
def foo(value) | |
"#{value[0]}foo" | |
end | |
[[1,2],[3,4]].map &method(:foo) |
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
test = Rake::Task['test'] | |
test.clear | |
desc 'Run all units, functionals, integration, libs' | |
task :test do | |
run_sets_of_tests(%w(test:units test:functionals test:integration test:libs)) | |
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
set w1 "weapon 5; bind mouse3 vstr w2; echo ROCKET LAUNCHER" | |
set w2 "weapon 7; bind mouse3 vstr w1; echo RAIL GUN" | |
bind mouse3 vstr w1 | |
seta com_maxfps "125" | |
seta r_finish "0" | |
seta cg_fov "120" | |
seta sensitivity "5" | |
set "zoom1" " cg_fov 60 ; sensitivity 2 ; bind mouse2 vstr zoom0 " | |
set "zoom0" " cg_fov 120 ; sensitivity 5 ; bind mouse2 vstr zoom1 " |
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
#stolen from http://pastie.org/395671 twitter:@seacreature. Just repo'ed here so I can find it again | |
require "irb" | |
IRB.setup(nil) | |
IRB.conf[:MAIN_CONTEXT] = IRB::Context.new(IRB::Irb.new) | |
require "irb/ext/multi-irb" | |
IRB.irb(nil,binding) |
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
class RspecInTU | |
class << self | |
alias it define_method | |
end | |
it "should say hello" do | |
puts "hello" | |
end | |
end | |
RspecInTU.new.send "should say hello" |
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
#Or just check-out: http://github.com/timocratic/test_benchmark/tree/master | |
#It's only one file too: http://github.com/timocratic/test_benchmark/blob/832b2217451b49ed218d2db31dfad2b81a2399eb/lib/test_benchmark.rb | |
#Go ahead and steal anything you want from it - or even better fork it and add what features you like |
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
git filter-branch -f --subdirectory-filter 'directory' #promote | |
git filter-branch -f --index-filter 'git rm -r --cached --ignore-unmatch directory' HEAD #delete | |
#http://git.or.cz/gitwiki/GraftPoint | |
echo "$commit-id $graft-id" >> .git/info/grafts | |
git filter-branch $graft-id..HEAD |
OlderNewer