Skip to content

Instantly share code, notes, and snippets.

/Users/galvatron/Sites/project/vendor/ruby/1.9.1/gems/cucumber-rails-1.0.2/lib/cucumber/rails.rb:4:in `dirname': can't convert nil into String (TypeError)
»·······from /Users/galvatron/Sites/project/vendor/ruby/1.9.1/gems/cucumber-rails-1.0.2/lib/cucumber/rails.rb:4:in `<top (required)>'
»·······from /Users/galvatron/.rvm/gems/ruby-1.9.2-p180-fastrequire/gems/bundler-1.1.pre.9/lib/bundler/runtime.rb:76:in `require'
»·······from /Users/galvatron/.rvm/gems/ruby-1.9.2-p180-fastrequire/gems/bundler-1.1.pre.9/lib/bundler/runtime.rb:76:in `rescue in block in require'
»·······from /Users/galvatron/.rvm/gems/ruby-1.9.2-p180-fastrequire/gems/bundler-1.1.pre.9/lib/bundler/runtime.rb:62:in `block in require'
»·······from /Users/galvatron/.rvm/gems/ruby-1.9.2-p180-fastrequire/gems/bundler-1.1.pre.9/lib/bundler/runtime.rb:55:in `each'
»·······from /Users/galvatron/.rvm/gems/ruby-1.9.2-p180-fastrequire/gems/bundler-1.1.pre.9/lib/bundler/runtime.rb:55:in `require'
»·······from /Users/galvatron/.rvm/gems/ruby-1.9.2-p180-fast
@ldenman
ldenman / gist:1047307
Created June 26, 2011 06:18
Hacker News NodeJS
#!/usr/bin/env node
// USAGE
// if you have given this executable permissions
// and you named the file something like "hn"
// then you can run "hn" which will
// print all of the news items on hackernews.
// You could also run "hn 1" which opens the first url.
// Make sure $BROWSER is set to a value.
@ldenman
ldenman / ar_patch.rb
Created May 13, 2011 20:29 — forked from amw/ar_patch.rb
A patch that allows lambda arguments to default_scope in rails ~> 3.0.0
module ActiveRecord
class Base
class << self
def default_scope(options = {})
reset_scoped_methods
default_scoping = self.default_scoping.dup
previous = default_scoping.pop
if previous.respond_to?(:call) or options.respond_to?(:call)
def pending_total
if not_needed?
0.00
else
# everyone gets the member pricing
daily_rate = ACCOMMODATION_RATES[room_type][:member]
departure_date = departure.to_date
arrival_date = arrival.to_date
total_days = departure_date - arrival_date
before_discounted_days = [[start_date - arrival_date, 3].min, 0].max
@ldenman
ldenman / gist:292955
Created February 2, 2010 19:50 — forked from anonymous/gist:292948
test
# for testing validates_length_of :name, :within => 3..100, :allow_nil => true
it "should not be valid with a name having less than 3 or more than 100 characters, if name is given" do
@category = Category.new @valid_attributes
@category.name = 'to'
@category.should have(1).errors_on(:name)
@category.errors.on(:name).should include "too short"
@category = Category.new @valid_attributes
@category.name = 't'*101
@category.should have(1).errors_on(:name)
@category.errors.on(:name).should include "too long"
@ldenman
ldenman / gist:203225
Created October 6, 2009 17:31
Common Validations
# app/models/student.rb
class Student < ActiveRecord::Base
include CommonValidations::StudentTeacherValidations
end
# app/models/teacher.rb
class Teacher < ActiveRecord::Base
include CommonValidations::StudentTeacherValidations
end
@ldenman
ldenman / gist:1718
Created July 23, 2008 13:09
Center a Div
/* Centering a DIV */
body {
text-align: center;
min-width: 600px;
}
#wrapper {
margin:0 auto;
width:600px;