Skip to content

Instantly share code, notes, and snippets.

View jfeldstein's full-sized avatar

Jordan Feldstein jfeldstein

View GitHub Profile
@dnagir
dnagir / timezone.rb
Last active December 16, 2019 15:37
Rspec time zones sledgehammer
# spec/support/timezone.rb
module TimeZoneHelpers
extend ActiveSupport::Concern
def self.randomise_timezone!
offsets = ActiveSupport::TimeZone.all.group_by(&:formatted_offset)
zones = offsets[offsets.keys.sample] # Random offset to better vary the time zone differences
Time.zone = zones.sample # Random zone from the offset (can be just 1st, but let's do random)
puts "Current rand time zone: #{Time.zone}. Repro: Time.zone = #{Time.zone.name.inspect}"
end
@kennethreitz
kennethreitz / mongo.py
Created March 13, 2012 22:54 — forked from lstoll/mongo.py
MongoHQ w/ pymongo on Heroku
import os
import pymongo
MONGO_URL = os.environ.get('MONGOHQ_URL')
if MONGO_URL:
# Get a connection
conn = pymongo.Connection(MONGO_URL)
# Get the database