Skip to content

Instantly share code, notes, and snippets.

View dougalcorn's full-sized avatar

Doug Alcorn dougalcorn

View GitHub Profile
# put this method definition in your .irbrc
def log_to(stream = STDOUT)
ActiveRecord::Base.logger = Logger.new(stream)
ActiveRecord::Base.clear_active_connections!
end
# at the bottom of test_helper.rb
module ActiveSupport
class BacktraceCleaner
def remove_filters!
@filters = []
end
end
end
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
@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"
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 / 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'