Skip to content

Instantly share code, notes, and snippets.

View fairchild's full-sized avatar

Michael Fairchild fairchild

  • Procore
  • California
View GitHub Profile
in routes.rb
map.resources :staff, :member => {:graph_code=>:get}
in controller,
@graph = open_flash_chart_object(500,300, graph_code_staff_path( {:title=>'Timesheet', :conditions=>@conditions}))
in view, error:
it "should get another hmac" do
bs = 'GET&http%3A%2F%2Fterm.ie%2Foauth%2Fexample%2Frequest_token.php&oauth_consumer_key%3Dkey%26oauth_nonce%3DuhnyjcnYEyO9vUxPAcdttE0OqbFPgBOp2xv7XmN6bw%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1223595784%26oauth_token%3Dtoken%26oauth_version%3D1.0'
@oa.signature(bs, 'secret', '').should == "cumMcmS4gQG5pcrtlgckPv/V0WU="
end
end
#!/usr/bin/env ruby
require 'rubygems'
require 'thor'
require 'fileutils'
require 'yaml'
# TODO
# - pulling a specific UUID/Tag (gitspec hash) with clone/update
# - a 'deploy' task (in addition to 'redeploy' ?)
# - add merb:gems:refresh to refresh all gems (from specifications)
class Project < Sequel::Model
one_to_many :milestones
one_to_many :tickets
def self.update_from_lighthouse(project_id=nil, updated_at=nil)
#TODO: allow scoping this call to only records updated_at>?
Lighthouse::Project.find(:all).each do |lh_project|
if project=Project[lh_project.id]
project.update_from_lighthouse
else
class TicketNumbersMigration < Sequel::Migration
def up
alter_table(:tickets) do
add_column 'number', :integer
end
end
def down
alter_table(:tickets) do
@fairchild
fairchild / bugflow
Created October 17, 2008 13:57 — forked from jdhuntington/bugflow
shell script to assist in working with lighthouse and git
#!/usr/bin/env ruby
# 2008.10.03
# JD Huntington
# shell script to assist in working with lighthouse and git
# requires lighthouse api ruby wrapper from http://github.com/Caged/lighthouse-api/tree/master
LIB_DIR='~/lib' # Absolute location of lighthouse.rb and lighthouse-api.rb
TOKEN='' # Insert your lighthouse token
ACCOUNT='' # Insert your lighthouse account name
abbot(fairchild@abbot) :~/WebApps/lightsheet2
> ls gems/gems/httparty-0.1.3/lib/
httparty/ httparty.rb
abbot(fairchild@abbot) :~/WebApps/lightsheet2
> merb -i
Warning: please use bin/merb to load merb-core-0.9.9 from ./gems
Loading init file from /home/fairchild/WebApps/lightsheet2/config/init.rb
Loading /home/fairchild/WebApps/lightsheet2/config/environments/development.rb
~ Loaded DEVELOPMENT Environment...
~
@fairchild
fairchild / gist:18334
Created October 21, 2008 15:55
sequel versioning
class Ticket < Sequel::Model
set_schema do
foreign_key :ticket_version_id, :table => :ticket_version
end
is(:versioned_fact, {:dimensions => [TicketVersion]})
one_to_many :ticket_versions
end
class TicketVersion < Sequel::Model
set_schema do
#Query LH for ticket, and update db cache. Allow ticket number or lh ticket object
def self.update_or_create_from_lighthouse(ticket, project_id)
lh_ticket = case ticket.class
when Fixnum: Ticket.retrieve_from_lh(ticket, project_id)
when Lighthouse::Ticket: Ticket.retrieve_from_lh(ticket.number, project_id)
else return false
end
if lh_ticket == 404 #delete ticket if it was deleted from LH
class Spec::Example::ExampleGroup
def execute(*args, &block)
# DB = Merb::Orms::Sequel.connect
Merb::Orms::Sequel.connect.transaction do
super(*args, &block)
raise Sequel::Error::Rollback
end
end
end