Skip to content

Instantly share code, notes, and snippets.

View toddsampson's full-sized avatar

Todd Sampson toddsampson

View GitHub Profile

Keybase proof

I hereby claim:

  • I am toddsampson on github.
  • I am toddsampson (https://keybase.io/toddsampson) on keybase.
  • I have a public key whose fingerprint is 0D00 6D5F 7185 F61E 1F77 94BE 5BD0 7586 9554 85A9

To claim this, I am signing this object:

Then /^it should return a response code of "(.+)"$/ do |resp_code|
response.code.should == resp_code
end
sudo gem install rubygems-update -v 1.2.0
show table status;
after "deploy:symlink", :update_config_file
after "deploy:symlink", :update_database_yml
def reader(record, previous_ids = [])
raise "loop" if previous_ids.include?(record.id)
...
return reader(next_record, previous_ids + [record.id])
end
@toddsampson
toddsampson / DefaultScope.rb
Created November 13, 2013 21:08
Default scope with Sunspot blog post: 2010/01/15/default-scope-with-sunspot/
class Item
# simple default scope to add an order_by to all queries
def self.default_search_scope(&additional)
search = Sunspot.new_search(Item)
search.build(&additional)
search.build do
order_by :created_at, :desc
end
search.execute
search.results
@toddsampson
toddsampson / IsThisGemInstalled.rb
Created November 13, 2013 21:04
Gist for Discovering if a Gem was Installed blog post: http://www.cloudspace.com/blog/?s=Is+this+gem+installed%3F
dependency = Gem::Dependency.new "authlogic", ">2"
specs = Gem.source_index.search dependency
puts "the gem is not installed" if specs.empty?
Rehearsal ------------------------------------
Benchmarking fruit_names_1:
4.040000 1.750000 5.790000 ( 5.852924)
Benchmarking fruit_names_2:
3.990000 2.060000 6.050000 ( 6.092260)
-------------------------- total: 11.840000sec
user system total real
Benchmarking fruit_names_1:
4.030000 1.750000 5.780000 ( 5.806661)