Skip to content

Instantly share code, notes, and snippets.

@ahsandar
ahsandar / URI-monkey-patch.rb
Created October 13, 2017 04:38 — forked from psychocandy/URI-monkey-patch.rb
Fix ArgumentError invalid %-encoding for malformed URLs
# The following should prevent an ArgumentError "invalid %-encoding (...%)" exception from being raised for malformed URLs.
# To use this code simply drop this in your rails app initializers.
# See: https://github.com/rack/rack/issues/337
# Taken from: http://stackoverflow.com/a/11162317/1075006
module URI
major, minor, patch = RUBY_VERSION.split('.').map { |v| v.to_i }
@ahsandar
ahsandar / gist:da5b78d01c94e2d5ebea7737a7870b1c
Created October 3, 2017 03:47 — forked from jrochkind/gist:59b6330e3f52710cc49e
Monkey patch to ActiveRecord to forbid
######################
#
# Monkey patch to ActiveRecord to prevent 'implicit' checkouts. Currently tested with Rails 4.0.8, prob
# should work fine in Rails 4.1 too.
#
# If you create a thread yourself, if it uses ActiveRecord objects without
# explicitly checking out a connection, one will still be checked out implicitly.
# If it is never checked back in with `ActiveRecord::Base.clear_active_connections!`,
# then it will be leaked.
#