Skip to content

Instantly share code, notes, and snippets.

View dougalcorn's full-sized avatar

Doug Alcorn dougalcorn

View GitHub Profile
@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
class User < ActiveRecord::Base
has_one :candidate_profile
alias_method :candidate_profile_without_initialization :candidate_profile
def candidate_profile
candidate_profile_withough_intitialization || build_candidate_profile
end
end
1. Setup javaCache.cmake below
2. ./bootstrap --prefix=/usr/local --system-libs --datadir=/share/cmake --docdir=/share/doc/cmake --mandir=/share/man --init=javaCache.cmake
3. make && make install
@dougalcorn
dougalcorn / copy_key.sh
Created November 5, 2010 20:05
Copy and append your public ssh key to a new host/account's authorized_keys file
#!/bin/sh
# Shell script to install your public key on a remote machine
# Takes the remote machine name as an argument.
# Obviously, the remote machine must accept password authentication,
# or one of the other keys in your ssh-agent, for this to work.
ID_FILE="${HOME}/.ssh/id_rsa.pub"
if [ "-i" = "$1" ]; then