Skip to content

Instantly share code, notes, and snippets.

View gmcnaughton's full-sized avatar

Gordon McNaughton gmcnaughton

View GitHub Profile
require 'uri'
require 'net/http'
require 'openssl'
class UrlResolver
def self.resolve(uri_str, agent = 'curl/7.43.0', max_attempts = 10, timeout = 10)
attempts = 0
cookie = nil
until attempts >= max_attempts
@gmcnaughton
gmcnaughton / month.rb
Created November 18, 2015 14:59 — forked from henrik/month.rb
Ruby Month class.
require "attr_extras" # gem
class Month
vattr_initialize :year, :month_number
def self.from(object)
case object
when Month then object
else new(object.year, object.month)
end