Skip to content

Instantly share code, notes, and snippets.

View tjh's full-sized avatar

Tim Harvey tjh

View GitHub Profile
Comment styles
comh1
# #######################################################
#
#
#
# #######################################################
set autolist
set autoeval
set autoreload
# This method allows the app to figure out what username and password were passed
# via basic http auth. Because calling #authenticate_or_request_with_http_basic will
# fail if no password was sent, I had to hack in my own check (taken from the Rails
# source) to make sure that they tried to auth.
def get_credentials
log_it
# Grabbed from the rails source...if the user sent auth data...
if ( request.env['HTTP_AUTHORIZATION'] ||
# -----------------------------------------
# Cucumber formatter that outputs the file
# and line number for each test.
#
# Useful for Hudson CI which only flushes
# the output to the log after a line return
# so that you can see what's failed before
# a long build finishes.
# -----------------------------------------
#
var delay = 5000;
var transition = 40;
var imageContainer = 'jw-sir';
var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;
function init() {
if(!d.getElementById || !d.createElement)return;
imgs = d.getElementById(imageContainer).getElementsByTagName("img");
for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
imgs[0].style.display = "block";
#
# EC2 / Chef command cheat sheet
#
# Uses cookbooks and templates from:
# http://github.com/tjh/chef-repo
# Fire up a new instance on EC2
# - Super-fast large instance
# - Uses a template that uses RVM/REE for the system ruby (optional)
Order.class_eval do
def has_site_approvals?
line_items.each do |item|
return true if item.approval && item.approval.approved?
end
false
end
end
Approval.class_eval do
# Monkeypatch paperclip to handle local file attachment. Didn't add this to
# the class itself as we only need local loading during the population
AssetItem.class_eval do
require 'open-uri'
attr_accessor :source_filename, :source_url, :source_path, :existing_cache_file, :new_cache_file
before_validation :import_source_file, :if => :source_filename_provided?
private
ENV["WATCHR"] = "1"
$spec_cmd = "spec --colour --format nested"
def growl(message)
if message.match(/\s0\s(errors|failures)/)
title = 'Watchr: All tests passed'
image = File.join(File.expand_path(File.dirname(__FILE__)), '.watchr_images', 'pass.png')
else
title = 'Watchr: Tests are failing'
image = File.join(File.expand_path(File.dirname(__FILE__)), '.watchr_images', 'pass.png')
@tjh
tjh / gist:1051092
Created June 28, 2011 13:07
Watchr script for Cucumber, Rspec, and Evergreen
require 'growl'
ENV["WATCHR"] = "1"
$spec_cmd = "rspec --colour --format nested -d"
$evergreen_cmd = "evergreen run"
def growl(message)
if message == 'true' || message.match(/\s0\s(errors|failures)/)
title = 'Watchr: All tests passed'
priority = 4