Skip to content

Instantly share code, notes, and snippets.

View billhorsman's full-sized avatar

Bill Horsman billhorsman

View GitHub Profile
@billhorsman
billhorsman / Gemfile
Created April 3, 2014 08:37
Turbolinks and AddThis
# This ensures that jQuery is reinitialized after the page:change event
gem 'jquery-turbolinks'
@billhorsman
billhorsman / capture.rb
Created April 7, 2014 07:55
Captured Groups in Regex and Ruby
# I didn't know that this test made the captured variable available as local variables.
if /(?<x>\d+)/ =~ "foo 123 bar"
puts x
end
# => 123
@billhorsman
billhorsman / gist:10627860
Last active August 29, 2015 13:59
keybase.md
### Keybase proof
I hereby claim:
* I am billhorsman on github.
* I am billhorsman (https://keybase.io/billhorsman) on keybase.
* I have a public key whose fingerprint is D96D 6222 E6CB 8A78 E03F A1A0 6C5C E69B 98D5 42B5
To claim this, I am signing this object:
@billhorsman
billhorsman / application_controller.rb
Created June 13, 2017 10:43
Handling ActionController::UnknownFormat
class ApplicationController < ActionController::Base
# Rather than return a 500 (internal server error) let's just say we can't
# find what they are looking for. Typically, this is when someone hits one
# of our valid routes but asks for the .xml format or something.
rescue_from ActionController::UnknownFormat, with: :raise_unknown_format
def raise_unknown_format
render plain: 'Unknown Format', status: :not_found
end