Skip to content

Instantly share code, notes, and snippets.

View garybernhardt's full-sized avatar

Gary Bernhardt garybernhardt

View GitHub Profile
set conf_name to text returned of ¬
(display dialog ¬
"Enter conference name:" with title ¬
"Schedule Conference" default answer ¬
"" default button 2)
tell application "OmniFocus"
tell default document
set newProject to make new project with properties {name:conf_name}
require 'download_policy'
describe DownloadPolicy do
let(:screencast) { stub(:free? => false) }
let(:anonymous_user) { nil }
let(:user_with_access) { stub(:has_screencast_access? => true) }
let(:user_without_access) { stub(:has_screencast_access? => false) }
it "is disallowed for anonymous users" do
subject.allow_download_for?(screencast, anonymous_user).should be_false
@garybernhardt
garybernhardt / lightning.txt
Created October 7, 2011 19:00 — forked from pycodeconf/lightning.txt
PyCodeConf 2011 Lightning Talk Signup
I want to give a lightning talk about:
"Wat?"
I need the projector: yes / no
Yes
@garybernhardt
garybernhardt / after.rb
Created September 27, 2011 04:02
Before/after let comparison
class Delegator
takes :request, :route_path, :resource, :delegate_name
let(:delegate_method) { @resource.record_class.method(method_name) }
let(:method_name) { @delegate_name.split('.').last.to_sym }
def delegate
delegate_method.call(*delegate_args)
end
Given /^I'm subscribed as a group host for ([^ ]*) users?$/ do |users|
users = users.to_i
steps %Q{
Given I'm on the account page
Given I enter valid billing details
}
choose("for_many") # THIS FAILS
fill_in "people ($9 per month each)", :with => users
steps('And I press "Subscribe"')
end
CantTouchThis = Class.new do
def to_s
'<CantTouchThis>'
end
end.new
class Stripper
def self.strip(klass)
klass.class_eval do
Stripper::constants_to_remove.each do |c|
# mock-based (interaction)
# db independent, but tied to implementation (I can change the AR call without affecting the behavior and this will fail)
context "data gathering" do
it "finds all indicators associated with the given sector and includes indicators not associated with any sectors" do
sector = stub_model(Sector, :id => 6)
Indicator.should_receive(:where).with("sector_id is null or sector_id = ?", sector.id)
Indicator.for_sector(sector)
end
module Rack
module Utils
def parse_nested_query(qs, d = nil)
params = ActiveSupport::OrderedHash.new
(qs || '').split(d ? /[#{d}] */n : DEFAULT_SEP).each do |p|
k, v = unescape(p).split('=', 2)
normalize_params(params, k, v)
end
task :cron => :environment do
DatabaseBackup.back_up_to_s3!
end
$grid_column_width: 40px
$grid_column_margin: 10px
$grid_columns: 12
$grid_width: $grid_columns * ($grid_column_width + $grid_column_margin * 2)
=container
margin-left: auto
margin-right: auto
width: $grid_width