Skip to content

Instantly share code, notes, and snippets.

View henrik's full-sized avatar

Henrik Nyh henrik

View GitHub Profile
@monde
monde / honeybadger_resque.rb
Created August 4, 2012 05:09
Honeybadger based error reporting backend for Resque
# for Rails place in config/initializers/honeybadger_resque.rb
%w( resque honeybadger ).each do |gem|
begin
require gem
rescue LoadError
raise "Can't find '#{gem}' gem. Please add it to your Gemfile or install it."
end
end
@joakimk
joakimk / separate_id_series.rb
Created April 13, 2012 10:39
RSpec: Separates id series for each table so that tests does not accidentally pass when rows in different tables have the same ID
class RSpec::SeparateIdSeries
# Separates id series for each table so that tests does not
# accidentally pass when rows in different tables have the same ID
def self.setup
# This takes almost a second when using spork for some reason, so skipping it there.
return if Spork.using_spork?
t = Time.now
tables.each_with_index do |table, i|
@peterhellberg
peterhellberg / Gemfile
Created April 10, 2012 11:51
Sinatra acceptance testing, using minitest/spec and capybara-webkit
source :rubygems
gem "sinatra", "~> 1.3.2"
group :test do
gem "minitest", "~> 2.10"
gem "rack-test", "~> 0.6.1"
gem "capybara", "~> 1.1"
gem "capybara-webkit", "~> 0.11"
gem "capybara_minitest_spec", "~> 0.2"
@joakimk
joakimk / script-bootstrap.rb
Created March 31, 2012 10:01
Bootstrap script (script/bootstrap) from a small rails project I'm working on. Designed to be quick to run when nothing changed. Intended to be used in CI builds and on dev machines.
$ time script/bootstrap
Bundler missing, installing.
Fetching: bundler-1.1.3.gem (100%)
Successfully installed bundler-1.1.3
1 gem installed
Gemfile changed, bundling.
Schema changed, updating databases.
real 0m9.163s
user 0m3.762s
@swrobel
swrobel / gemfile_changelog.rb
Created March 23, 2012 01:21
Get Changelogs for outdated gems in Gemfile
#!/usr/bin/env ruby
def changelog_for_gem(gem)
changelogs = `bundle exec gem contents #{gem}`.lines.grep(/history|changelog|news/i)
if changelogs.empty?
puts "No changelog found for gem #{gem}"
return nil
end
@avdi
avdi / apology101.markdown
Created March 22, 2012 17:36
How to apologize

Chances are your head's spinning right now. That accusation of bias caught you off guard, you got kind of defensive, and now all hell has broken loose. You're feeling attacked on all sides. You're a good person at heart, and having all these people treat you like the antichrist is pretty upsetting.

You need to say something, but you're probably not in the best headspace to write copy right now. So to help you along, here's my 100% guaranteed-or-you-money-back scandal defusement apology template:

@wrburgess
wrburgess / gist:2086949
Created March 19, 2012 00:20
Setting up New Relic for Sinatra on Heroku #newrelic #sinatra #heroku
@coreyhaines
coreyhaines / .rspec
Last active April 11, 2024 00:19
Active Record Spec Helper - Loading just active record
--colour
-I app
@joakimk
joakimk / controller.rb
Created February 17, 2012 10:40
A way to lazy load partials in Rails 3
class Controller
include LazyLoad
def show
@model = Model.find(...)
respond_to do |format|
format.html do
@html_specific_data = Model.find(...)
end
@kagemusha
kagemusha / gist:1569836
Created January 6, 2012 09:20
Dump Heroku Postgres DB and load locally
Get the Heroku db as detailed here:
http://devcenter.heroku.com/articles/pgbackups#exporting_via_a_backup
1. heroku pgbackups:capture
2. heroku pgbackups:url <backup_num> #=>backup_url
- get backup_num with cmd "heroku pgbackups"
3. curl -o latest.dump <backup_url>
Then locally do:
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump