Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am benmac3 on github.
  • I am benmac (https://keybase.io/benmac) on keybase.
  • I have a public key ASDrD2oFrwGxCNujqQ2iK8NCzxB1z79-TJf_XGS6m-Veqgo

To claim this, I am signing this object:

@benmac3
benmac3 / gist:3780211
Created September 25, 2012 05:54
Generic content transform for URL
require 'httparty'
class TransformHttpResponse
include HTTParty
def scrape(url)
response = self.class.get(url)
if block_given?
yield response
return
def handle_500_errors
yield
# we catch MissingTemplate errors so Applet Tab development errors are handled more cleanly.
# we could potentially do more here.
#rescue ActionView::MissingTemplate => error
# respond_to do |format|
# format.html {raise error}
# format.js {render :partial => "/service_errors/generic", :locals => {:message => "#{error.message}"}}
# end
end
actionpack (3.2.6) lib/action_view/template.rb:165:in `refresh'
actionpack (3.2.6) lib/action_view/template.rb:318:in `handle_render_error'
actionpack (3.2.6) lib/action_view/template.rb:148:in `rescue in render'
actionpack (3.2.6) lib/action_view/template.rb:143:in `render'
actionpack (3.2.6) lib/action_view/renderer/partial_renderer.rb:265:in `render_partial'
actionpack (3.2.6) lib/action_view/renderer/partial_renderer.rb:238:in `block in render'
actionpack (3.2.6) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (3.2.6) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.6) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.6) lib/active_support/notifications.rb:123:in `instrument'