Skip to content

Instantly share code, notes, and snippets.

View dougalcorn's full-sized avatar

Doug Alcorn dougalcorn

View GitHub Profile

Keybase proof

I hereby claim:

  • I am dougalcorn on github.
  • I am dougalcorn (https://keybase.io/dougalcorn) on keybase.
  • I have a public key whose fingerprint is 4AFA 9F41 2256 E31E B97F 86AA 7EBC 2B80 3393 094A

To claim this, I am signing this object:

@dougalcorn
dougalcorn / gist:11060606
Created April 18, 2014 19:29
Infuriating error
$ brew update libyaml
This command updates brew itself, and does not take formula names.
Use `brew upgrade <formula>`.
@dougalcorn
dougalcorn / README.md
Last active August 29, 2015 14:05
rspec contexts

The lets are evaluated from inner-most to outer; but the before are evaluated from outer to inner. With rspec-given the point is to use When as just the bit of code that's "under test". All of the Givens are pre-conditions or setup. That's one of the things I like most about rspec-given, it separates setup code from code under test. The other thing I like about it is the brevity of the individual tests. I find the description on it blocks often quite redundant with the code in the block. I like how Then removes that duplication. Another benefit of rspec-given is that is has natural language failures built in. That's pretty cool.

@dougalcorn
dougalcorn / Vote for BudgetSketch.rb
Created June 9, 2009 18:19
Vote for BudgetSketch
# This is for voting for the budgetsketch project on http://cinciinnovates.com
# You can vote daily. This stupid simple mechanize script will simply submit
# your vote. You still have to confirm the vote from your email inbox. I
# figure a cron job to submit my vote keeps me from forgetting to vote daily
# and I (as a human) am still confirming; so not cheating. YMMV
require 'rubygems'
require 'mechanize'
require 'pp'
rec_td_stat_name = StatName.find_by_title("Reception Touchdowns")
rush_td_stat_name = StatName.find_by_title("Rush Touchdowns")
rrtd_stat_name = StatName.find_by_title("Rushing and Receiving Touchdowns")
GameStat.find_all_by_stat_name_id(rrtd_stat_name.id).each do |game_stat|
rec_td_game_stat = GameState.find_by_game_id_and_player_id_and_stat_name_id(game_stat.game_id, game_stat.player_id, rec_td_stat_name.id)
rush_td_game_stat = GameState.find_by_game_id_and_player_id_and_stat_name_id(game_stat.game_id, game_stat.player_id, rush_td_stat_name.id)
game_stat.update_attributes(:value => rec_td_game_stat.value.to_i + rush_td_game_stat.value.to_i)
end
@dougalcorn
dougalcorn / simple-startup-template.rb
Created October 26, 2009 17:03
Very thin rails setup template
file '.gitignore', %q{
log/*.log
tmp/**/*
doc/api
doc/app
}
run "touch log/.gitignore"
run "touch tmp/.gitignore"
post '/events' do
data = request.body.read
File.open(File.join(EVENTS_PATH, "#{Time.now.strftime('%Y%m%dT%H%M%S')}.xml"), "w") do |f|
f.write data
end
end
# at the bottom of test_helper.rb
module ActiveSupport
class BacktraceCleaner
def remove_filters!
@filters = []
end
end
end
# put this method definition in your .irbrc
def log_to(stream = STDOUT)
ActiveRecord::Base.logger = Logger.new(stream)
ActiveRecord::Base.clear_active_connections!
end