Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Given this result set (this cannot be modified) that looks like:
[{"client name"=>"Adenbrook (Avalon Franchising Pty Ltd)", "job status wip c"=>"WIP", "job owner"=>"TCo", "job name"=>"INTR - 1300 Phone Charges 2010", "job billable"=>"Yes", "__uid"=>#, "invoice lock"=>nil, "job no"=>"ADN2611"}, {"client name"=>"Adenbrook Homes (Morris Family Building Trust)", "job status wip c"=>"WIP", "job owner"=>"NSe", "job name"=>"PREL: Fixed Display Centre: Port Macquarie", "job billable"=>"Yes", "__uid"=>#, "invoice lock"=>nil, "job no"=>"MBT2763"}, {"client name"=>"Media Shop", "job status wip c"=>"WIP", "job owner"=>"TCo", "job name"=>"Media Shop: Polypropylene folder - Contract & Documents", "job billable"=>"Yes", "__uid"=>#, "invoice lock"=>nil, "job no"=>"MED2801"}, {"client name"=>"Adenbrook Homes (Toolona NSW Pty Ltd)", "job status wip c"=>"WIP", "job owner"=>"CCo", "job name"=>"Media Shop: Tweed Richmond June 2010", "job billable"=>"Yes", "__uid"=>#, "invoice lock"=>nil, "job no"=>"ATR2817"}, {"client name"=>"Ad
@coop
coop / .gitconfig
Created May 16, 2011 03:36
Git Config
[github]
user = coop
token = 1234
[user]
name = Tim Cooper
email = coop@latrobest.com
[apply]
whitespace = nowarn
[alias]
tug = pull
require 'goliath'
class Hello < Goliath::API
def on_close(env)
env.logger.info "Connection closed."
end
def response(env)
i = 0
pt = EM.add_periodic_timer(1) do
class LineItemObserver < ActiveRecord::Observer
def before_save record
current_date = record.order.start
reservations = record.product.reservations
while current_date < record.order.end
reservation = reservations.where(:day => current_date).first
if reservation.nil?
reservations.create :quantity => record.quantity, :day => current_date
class Order < ActiveRecord::Base
def each_day_in_period &block
current_date = start
while current_date < self.end
block.call current_date
current_date += 1.day
end
end
end
@coop
coop / Deploy
Created August 2, 2011 22:55
Deploy to S3 - Asset Pipeline, S3 and Heroku
namespace :deploy do
desc "Deploy to Heroku"
task :heroku do
Rake::Task["deploy:precompile_assets_and_upload_to_s3"].invoke
Rake::Task["deploy:push_heroku"].invoke
end
desc "Precompile assets and upload to s3"
task :precompile_assets_and_upload_to_s3 do
storage = Fog::Storage.new :provider => 'AWS', :aws_access_key_id => "123", :aws_secret_access_key => "123"
# ~/.zshrc
setopt auto_cd
cdpath=($HOME/Code)
$ pwd
/Users/timc
$ cd command_centre
$ pwd
/Users/timc/Code/command_centre
// Controller for fetching the records
App.leaderboardController = SC.ArrayProxy.create({
content: [],
loadUsers: function() {
var self = this;
$.getJSON('/leaderboard/username/year/month', function(data) {
data.forEach(function(leader) {
self.pushObject(leader.leader);
class FeaturesHash < HashWithIndifferentAccess
def with_features features
current = dup
replace features
yield
ensure
replace current
end
def method_missing method, *args, &block
$ curl -i -H "Authorization: token my_token" https://api.github.com/orgs/everydayhero/repos
HTTP/1.1 200 OK
Server: nginx/1.0.4
Date: Sun, 30 Oct 2011 01:02:50 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Status: 200 OK
X-RateLimit-Limit: 5000
ETag: "55fef90d58683e3270408d09eae6ee71"
X-OAuth-Scopes: