Skip to content

Instantly share code, notes, and snippets.

View stevegraham's full-sized avatar
🛠️
Building @tellerhq

Stevie Graham stevegraham

🛠️
Building @tellerhq
View GitHub Profile
subject { App.new }
App::PURPOSES.each do |p,_|
context do
before { subject.purpose = p }
its(:purpose){ should == p }
end
end
App::PLATFORMS.each do |p,_|
@stevegraham
stevegraham / 1.rb
Created September 20, 2012 00:25
Symbol#to_proc
%w(john paul ringo george).map { |p| p.capitalize }
# => ["John", "Paul", "Ringo", "George"]
@stevegraham
stevegraham / 1.rb
Created September 20, 2012 00:20
splat
hash = { :name=>"Steve Graham", :age=>24 }
# => { :name=>"Steve Graham", :age=>24 }
array = *hash
# => [[:name, "Steve Graham"], [:age, 24]]
@stevegraham
stevegraham / 1.rb
Created September 20, 2012 00:14
Object#tap
def logger
@logger ||= Logger.new(STDOUT)
end
@stevegraham
stevegraham / 1.rb
Created September 20, 2012 00:08
quines
s='s=;puts s[0,2]+39.chr+s+39.chr+s[2,36]';puts s[0,2]+39.chr+s+39.chr+s[2,36]
def gen_times(factor)
return Proc.new { |n| n * factor }
end
times3 = gen_times(3)
times5 = gen_times(5)
times3.call(12) #=> 36
times5.call(5) #=> 25
times3.call(times5.call(4)) #=> 60
@stevegraham
stevegraham / gist:3735355
Created September 17, 2012 03:09
dpkg fails
==> Downloading http://ftp.debian.org/debian/pool/main/d/dpkg/dpkg_1.15.8.12.tar.bz2
Already downloaded: /Library/Caches/Homebrew/dpkg-1.15.8.12.tar.bz2
/usr/bin/tar xf /Library/Caches/Homebrew/dpkg-1.15.8.12.tar.bz2
==> Patching
/usr/bin/patch -f -p1 -i 000-homebrew.diff
patching file configure
patching file lib/dpkg/dpkg.h
Hunk #1 succeeded at 97 with fuzz 1.
==> ./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/dpkg/1.15.8.12 --disable-compiler-warnings --disable-linker-optimisations --disable-compiler-optimisations --without-start-stop-daemon
./configure --disable-dependency-tracking --prefix=/usr/local/Cellar/dpkg/1.15.8.12 --disable-compiler-warnings --disable-linker-optimisations --disable-compiler-optimisations --without-start-stop-daemon
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking iloveyoubiebs.herokuapp.com (be patient).....done
Server Software: thin
Server Hostname: iloveyoubiebs.herokuapp.com
Server Port: 80
{
"BundleType": "Application",
"BundleIdentifier": "request",
"AppIcon": {
"36x18": "tutorial.png"
},
"AppName": {
"en": "Request Line"
},
"SupportedLanguages": [
@stevegraham
stevegraham / gist:2851034
Created June 1, 2012 10:27
Proposed node.js interface
var Twilio = require('twilio-js');
Twilio.AccountSid = "xxxxxxxxxxxxxxxxxxxxxx";
Twilio.AuthToken = "xxxxxxxxxxxxxxxxxxxxxx";
Twilio.SMS.create({from: "+12125550000", to: "+16465551234", body: "OMG, my app can text!"}, function (err, res) {
// err is an Error object or null
// res is a an object containing the response e.g.
// { sid: "SMxxxxxxxxxxxxxxxxxxxxxxx", body: "OMG, my app can text!", ... }