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 Test::Unit::TestCase # Or ActiveSupport::TestCase if you are using Rails | |
# This is a debugging utility to find slow tests. | |
# Usage: rake FIND_SLOW_TESTS=true test:units | |
unless ENV["FIND_SLOW_TESTS"].blank? | |
alias_method :old_run, :run | |
def run(*args, &block) | |
start_time = Time.now | |
old_run *args, &block | |
test_time = Time.now - start_time | |
puts "\nSLOW TEST: #{self.name}, #{test_time}s" if test_time > 0.5 |
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
module ActiveRecord | |
module ConnectionAdapters | |
class AbstractAdapter | |
protected | |
# Turn: | |
# User Load (6.3ms) SELECT * FROM "users" | |
# Into: | |
# User Load /app/views/_partial.erb:27 (6.3ms) in `_app_views_partial_erb` SELECT * FROM "users" |
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
#content ul { | |
margin: 0; | |
padding: 8px 21px 8px 21px; | |
width: 718px; | |
list-style: none; | |
display: block; | |
clear : both; | |
} | |
#content li { |
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
function insert_fields(link, method, content) { | |
var new_id = new Date().getTime(); | |
var regexp = new RegExp("new_" + method, "g") | |
$(link).up().insert({ | |
before: content.replace(regexp, new_id) | |
}); | |
} | |
function remove_fields(link) { | |
var hidden_field = $(link).previous("input[type=hidden]"); |
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
describe ApplicationHelper | |
describe "current_page?" do | |
it "should ignore anchors in request_uri" do | |
@controller.request.request_uri = "/page/url#anchor" | |
helper.current_page?("/page/url").should be_true | |
end | |
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
def can_edit?(this_user) | |
return true unless locked? | |
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
class ControllerHelper | |
include Singleton | |
include ActionView::Helpers | |
end | |
def url_helpers | |
ControllerHelper.instance | |
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
def para (attributes = {}, &block) | |
method_missing(:p, attributes, &block) | |
end | |
para do | |
<<-END_PARAGRAPH | |
Hello there. I love #{input 'inputting VARIOUS things'}. I also get a kick | |
out of #{code 'coding various things'}. There's such a thrill in | |
seeing all of the exciting #{output 'output you can get'} from a | |
well-written program. |
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
def para (attributes = {}, &block) | |
method_missing(:p, attributes, &block) | |
end | |
para do | |
foo = <<-END_PARAGRAPH | |
Hello there. I love #{input 'inputting VARIOUS things'}. I also get a kick | |
out of #{code 'coding various things'}. There's such a thrill in | |
seeing all of the exciting #{output 'output you can get'} from a | |
well-written program. |
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
>> e = DateTime.strptime('2009-05-07T01:33:23+01:00') | |
=> Thu, 07 May 2009 01:33:23 0100 | |
>> f = DateTime.strptime('2009-05-06T23:33:23+01:00') | |
=> Wed, 06 May 2009 23:33:23 0100 | |
>> e - f | |
=> Rational1, 12 | |
>> a = Time.now | |
=> Thu May 07 10:25:53 -0400 2009 | |
>> b = Time.now |
NewerOlder