Skip to content

Instantly share code, notes, and snippets.

View omarramos's full-sized avatar

Omar Ramos omarramos

View GitHub Profile
@omarramos
omarramos / socksify_faraday.rb
Created November 11, 2020 03:27 — forked from shannonwells/socksify_faraday.rb
Faraday + SOCKS
require 'rubygems'
require 'faraday'
require 'socksify'
require 'socksify/http'
require 'awesome_print'
# This is a SOCKS monkey patch for Faraday, with example use/unit test.
# Notes:
# * It is altered to work with SOCKS5 authentication.
# * net_http_class must return a Faraday::Adapter::NetHttp instance.

Keybase proof

I hereby claim:

  • I am omarramos on github.
  • I am omarramos (https://keybase.io/omarramos) on keybase.
  • I have a public key whose fingerprint is 8EEC A272 46AC 45B8 401A C85C 1464 E21B 35A2 B409

To claim this, I am signing this object:

TODO: make gem for this

This was tested using Rails 3.2 and Rails 4.0 on Ruby 2.0.0.

Bower

  1. Set the install directory for Bower components:

// .bowerrc

@omarramos
omarramos / gist:1707067
Created January 30, 2012 22:02 — forked from moiristo/gist:1245170
Rails3 way to redirect non-www domain to www domain
# Rails3 way to redirect non-www domain to www domain
# Single domain redirect
'example.com'.tap do |host|
constraints(:host => host) do
root :to => redirect {|params, req| URI.escape(req.query_string.present? ? "#{req.protocol}www.#{host}?#{req.query_string}" : "#{req.protocol}www.#{host}") }
match '/*path', :to => redirect {|params, req| URI.escape(req.query_string.present? ? "#{req.protocol}www.#{host}/#{params[:path]}?#{req.query_string}" : "#{req.protocol}www.#{host}/#{params[:path]}") }
end
end
@omarramos
omarramos / nginx
Created January 22, 2012 19:01
Modified Nginx init scrip to work with default nginx passenger module instalation path
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: nginx init.d dash script for Ubuntu or other *nix.
# Description: nginx init.d dash script for Ubuntu or other *nix.
### END INIT INFO
@omarramos
omarramos / backbone.rails.js
Created May 5, 2011 17:31 — forked from trydionel/backbone.rails.js
Makes Backbone.js play nicely with default Rails setup
//
// Backbone.Rails.js
//
// Makes Backbone.js play nicely with the default Rails setup, i.e.,
// no need to set
// ActiveRecord::Base.include_root_in_json = false
// and build all of your models directly from `params` rather than
// `params[:model]`.
//
// Load this file after backbone.js and before your application JS.
@omarramos
omarramos / rtm_badges.user.js
Created March 26, 2011 15:17
Displays a dock badge for items in a certain Remember The Milk list.
// ==UserScript==
// @name Due Badge
// @namespace http://fluidapp.com
// @description Displays a dock badge for items in a certain Remember The Milk list.
// @include *
// @author Edd Morgan <trquadrant.com>
// ==/UserScript==
(function () {
if (window.fluid) {