Skip to content

Instantly share code, notes, and snippets.

View amalagaura's full-sized avatar

Ankur Sethi amalagaura

View GitHub Profile
# requires socksify gem
require "socksify"
require 'socksify/http'
# use w/ OAuth2 like OAuth2::Client.new(id, secret, connection_opts: { proxy: 'socks://127.0.0.1:9050' })
class Faraday::Adapter::NetHttp
def net_http_connection(env)
if proxy = env[:request][:proxy]
if proxy[:uri].scheme == 'socks'
Net::HTTP.SOCKSProxy(proxy[:uri].host, proxy[:uri].port)
@amalagaura
amalagaura / ability.rb
Created December 13, 2011 20:23 — forked from watson/ability.rb
Active Admin CanCan integration with shared front/backend User model and multi-level autherization
# app/models/ability.rb
# All front end users are authorized using this class
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
can :read, :all