Skip to content

Instantly share code, notes, and snippets.

View masonforest's full-sized avatar

Mason Fischer masonforest

View GitHub Profile
@masonforest
masonforest / gist:2399483
Created April 16, 2012 15:30
Tracks per Disc API Call without token
curl "localhost:3000/api/discs/1636.json"
# =>
{
"disc": {
"album_id": 1515,
"amazon_id": null,
"amazon_purchase": false,
"comment": null,
"created_at": "2012-04-04T20:47:22Z",
"id": 1636,
@masonforest
masonforest / Log of just Web.3
Created April 18, 2012 14:11
heroku logs --tail --ps web.3 --app murfie
2012-04-18T14:07:45+00:00 heroku[web.3]: Error R14 (Memory quota exceeded)
2012-04-18T14:07:50+00:00 app[web.3]:
2012-04-18T14:07:50+00:00 app[web.3]:
2012-04-18T14:07:50+00:00 app[web.3]: Started GET "/shop.Scott1" for 10.117.7.179 at 2012-04-18 14:07:50 +0000
2012-04-18T14:07:51+00:00 app[web.3]: Processing by ShopController#index as
2012-04-18T14:07:51+00:00 app[web.3]: Rendered layouts/application.html.haml (5.0ms)
2012-04-18T14:07:51+00:00 app[web.3]: Rendered shared/_user_nav.html.haml (0.9ms)
2012-04-18T14:07:51+00:00 app[web.3]: Rendered content/_nav.html.haml (0.5ms)
2012-04-18T14:07:51+00:00 app[web.3]: Rendered shared/_footer.html.haml (1.8ms)
2012-04-18T14:07:51+00:00 app[web.3]: Rendered shared/_google_analytics.html.haml (0.0ms)
@masonforest
masonforest / old_way.rb
Created October 12, 2012 23:03
Connascence of Position (CoP) Problem Ruby 1.9
def do_things(puppie_count, missle_count)
puts "Played with #{puppie_count} puppies"
puts "Launched #{missle_count} missles"
end
puts "Everything is Fine"
do_things(5,0)
do_things(10,0)
do_things(12,0)
@masonforest
masonforest / new_way.rb
Created October 12, 2012 23:06
Connascence of Position (CoP) Problem - Fixed with named parameters in Ruby 2.0
=begin
Our "Connascence of Position" problem can be solved with named parameters available in Ruby 2.0
=end
def do_things(puppie_count: 0, missle_count: 0)
puts "Played with #{puppie_count} puppies"
puts "Launched #{missle_count} missles"
end
puts "Everything is Fine"
[~/tmp] gem install xcodeproj --pre
gem:14: /usr/local/bin/gem: bad interpreter: /usr/local/bin/ruby: no such file or directory
Fetching: xcodeproj-0.2.0.rc3.gem (100%)
Building native extensions. This could take a while...
Successfully installed xcodeproj-0.2.0.rc3
1 gem installed
[~/tmp] irb
zsh: /usr/local/bin/irb: bad interpreter: /usr/local/bin/ruby: no such file or directory
1.9.3-p194 :001 > project = Xcodeproj::Project.new
NameError: uninitialized constant Xcodeproj
@masonforest
masonforest / gist:4107758
Created November 18, 2012 21:55
The First Runnable Gist!
name = params['name'];
callback("Hello "+name)
@masonforest
masonforest / gist:4226421
Created December 6, 2012 17:42
jQuery spies
describe "Quickpay.startQuickPay", ->
it "calls animate on .single_item_quick_pay", ->
quickPay = new Threadflip.QuickPay()
event = new jQuery.Event("click")
animateSpy = spyOn($.fn, "animate")
quickPay.startQuickPay(event)
expect($.fn.animate).toHaveBeenCalledWith({height: "300px"})
expect(animateSpy.mostRecentCall.object.selector).toEqual('.single_item_quick_pay')
@masonforest
masonforest / gist:4226449
Created December 6, 2012 17:46
How jQuery spies should work
describe "Quickpay.startQuickPay", ->
it "calls animate on .single_item_quick_pay", ->
quickPay = new Threadflip.QuickPay()
event = new jQuery.Event("click")
$('.single_item_quick_pay').spyOn('animate')
quickPay.startQuickPay(event)
expect($('.single_item_quick_pay').animate).toHaveBeenCalledWith({height: "300px"})
@masonforest
masonforest / gist:5199929
Last active December 15, 2015 04:09
validate USPS tracking numbers in Ruby
def valid(tracking_number)
chars = tracking_number.chars.to_a
expected_check_digit = chars.pop.to_i
total = 0
chars.reverse.each_with_index do |digit, index|
if index.even?
total += digit.to_i * 3
else
total += digit.to_i
{"ref":"refs/heads/master","after":"71875ba99b5109cbdfef770e590ba7504536eb53","before":"bb86ebb305cf27a94e2249ee1b0c8a96919bfa03","created":false,"deleted":false,"forced":false,"compare":"https://github.com/21x9/ServiceLog/compare/bb86ebb305cf...71875ba99b51","commits":[{"id":"171bbbae6646c0bc6bdabf2e0b0ea04392c86ce1","distinct":true,"message":"Fixed another bug related to the status bar disappearing after resigning from the photo view controller while the bars are hidden","timestamp":"2012-01-24T10:48:58-08:00","url":"https://github.com/21x9/ServiceLog/commit/171bbbae6646c0bc6bdabf2e0b0ea04392c86ce1","author":{"name":"Mark Adams","email":"mark.adams86@gmail.com","username":"21x9"},"committer":{"name":"Mark Adams","email":"mark.adams86@gmail.com","username":"21x9"},"added":[],"removed":[],"modified":["ServiceLog/PhotoViewerViewController.m"]},{"id":"417939bf185774585cedacf91dfc111260d30d8b","distinct":true,"message":"Fixed some interface stuff like disclosure indicators and the ability to select maintenance e