Skip to content

Instantly share code, notes, and snippets.

When considering the leap into freelancing, it's easy to get overwhelmed by the details. The Rails Freelancing Handbook is a great collection of wisdom from someone who's been there before and lived to tell the tale.
class ActiveRecord::Base
def self.bulk_import(flush_after=50, &blk)
@bulk_import_columns = Set.new
@bulk_import_rows = []
@bulk_import_flush_after = flush_after
class << self
# this is essentially alias_method_chain written out for symmetry
# with the part that undoes it
class Node
attr_reader :children
attr_reader :value
def initialize(value)
@children = []
@value = value
end
def add_children(*values)
Scenario: User is signed up and requests password reset # features/password_reset.feature:11
Given I signed up with "email@person.com/password" # features/step_definitions/clearance_steps.rb:13
When I request password reset link to be sent to "email@person.com" # features/step_definitions/clearance_steps.rb:95
Failed to load /Users/david/Code/gemcutter/vendor/gems/qrush-clearance-0.7.0/app/models/clearance_mailer using extensions rb, treetop, tt (MissingSourceFile)
/Library/Ruby/Gems/1.8/gems/polyglot-0.2.7/lib/polyglot.rb:44:in `load'
/Library/Ruby/Gems/1.8/gems/polyglot-0.2.7/lib/polyglot.rb:60:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:158:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:265:in `require_or_load'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:425:in `load_missing_constant'
/L
[ddollar@uranium.local] [00:15] [dependency-types]
[~/Code/gemcutter] rake gemcutter:import:process server/gems
(in /Users/ddollar/Code/gemcutter)
Processing 7 gems...
Processing server/gems/test-1.0.0.gem
Processing server/gems/test-0.0.0.gem
Processing server/gems/gem-github-0.4.2.gem
Processing server/gems/RGem-1.2.3.gem
Processing server/gems/PGem-1.0.0.gem
Processing server/gems/BGem-3.0.0.gem
@ddollar
ddollar / gist:174155
Created August 24, 2009 20:28
Solo Rails Rumble Teams
Aaron Longwell - http://linediet.r09.railsrumble.com
andrew - http://rostered.r09.railsrumble.com
Bigfoot Autopsy - http://sourceportfolio.r09.railsrumble.com
Chalkers the Wonder Loner - http://touch.r09.railsrumble.com
Cheap Developer Dude - http://laterz.r09.railsrumble.com
couch potato - http://alertmetv.r09.railsrumble.com
Cramanation Station - http://jafm.r09.railsrumble.com
David Dollar - http://twoll-me.r09.railsrumble.com
Do It The Right Way - http://phratty.r09.railsrumble.com
emusoft - http://twitterstats.r09.railsrumble.com
@ddollar
ddollar / gist:174156
Created August 24, 2009 20:30
Display the solo teams for Rails Rumble 2009
require 'httparty'
API_KEY = 'YOUR_API_KEY'
class Hash
def method_missing(key)
self[key.to_s] || super
end
end
require 'httparty'
require 'rack'
class Rack::Validate
attr_reader :app, :options
def initialize(app, options={})
@app = app
@options = options
context "On DELETE to subscription for a gem that the user is not subscribed to" do
setup do
@gem = Factory(:rubygem)
Factory(:version, :rubygem => @gem)
delete :subscription, :id => @gem.to_param
end
should_assign_to(:gem) { @gem }
should_respond_with 500
end
# truncates html text to the desired text length.
# Like the Rails _truncate_ helper but doesn't break HTML tags or entities.
#
# accepts options:
# :link_to => url
def truncate_html(text, max_length = 400, options = {})
elipsis = '&hellip;'
tag_delimiter_count = 0
in_html_entity = false
character_count = 0