Skip to content

Instantly share code, notes, and snippets.

View garybernhardt's full-sized avatar

Gary Bernhardt garybernhardt

View GitHub Profile
def tweet(o)
match(o) {
with(o.name == "garybernhardt") { raise TrollError }
with(Image i) { tweet ShortLink.for_image(i) }
with(Text t) { actually_tweet_here }
}
end
@garybernhardt
garybernhardt / gist:2287086
Created April 2, 2012 20:45
I asked Comcast to stop leaving me two four-second voice mails every day. This is their response.
Dear Gary,
Thank you for contacting Comcast Email Support. My name is Jean and I
appreciate your time and effort in contacting us. I hope you are having
a great day.
I understand that you would like us to put your name and your number,
xxx-xxx-xxxx, right at this moment. I truly understand how this must
have been frustrating to you and I do apologize for any inconvenience
this has caused you. I can certainly understand how important it is for
describe 'a' do
it "raises an error when no source is found for an argument" do
klass = Class.new { def f(unknown_argument); end }
expect do
injector.call(klass.new.method(:f))
end.to raise_error(Syringe::UnknownInjectable)
end
end
failbowl:temp(master+!?) $ git st
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: a
# new file: c
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
#!/bin/ruby
guard 'spork' do
watch(%r{^config/.*\.rb$})
watch(%r{^config/environments/.*\.rb$})
watch(%r{^config/initializers/.*\.rb$})
watch(%r{^features/support/.*\.rb$})
watch('spec/spec_helper.rb')
end
Last login: Mon Jan 30 16:54:38 on ttys000
failbowl:~(master!?) $ rvm install ree
Installing Ruby Enterprise Edition from source to: /Users/grb/.rvm/rubies/ree-1.8.7-2011.12
ree-1.8.7-2011.12 - #fetching (ruby-enterprise-1.8.7-2011.12)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 7773k 100 7773k 0 0 2447k 0 0:00:03 0:00:03 --:--:-- 2513k
ree-1.8.7-2011.12 - #extracting ruby-enterprise-1.8.7-2011.12 to /Users/grb/.rvm/src/ree-1.8.7-2011.12
Applying patch 'tcmalloc' (located at /Users/grb/.rvm/patches/ree/1.8.7/tcmalloc.patch)
Applying patch 'stdout-rouge-fix' (located at /Users/grb/.rvm/patches/ree/1.8.7/stdout-rouge-fix.patch)
# Hash form:
{
:current_user => "CurrentUser.current_user"
}
# Discovery form with inverted app structure:
module Injectables
def current_user(session)
User.find(:id => session['current_user_id'])
end
# Rails controller
def create
@profile = ProfileManager.create(params[:profile])
rescue ProfileManager::CreationFailed => e
render :new, :errors => e.errors
end
# Raptor route
create :to => "ProfileManager#create", ProfileManager::CreationFailed => render(:new)
Python array methods:
>>> [m for m in dir([]) if not m.startswith("_")]
['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse',
'sort']
Ruby array methods:
>> ([].methods - Object.methods).sort
=> ["&", "*", "+", "-", "<<", "[]", "[]=", "all?", "any?", "assoc", "at",
# Make a user that we'll add a book to.
user = User.create!
controller.stub(:current_user) { user }
# This prints []. The book list is empty.
p user.books
# Expect a book to be added to the user. This fails (see below)
expect {
post :create, :id => asin