Skip to content

Instantly share code, notes, and snippets.

@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
@jgwhite
jgwhite / Gemfile
Created November 9, 2012 16:05
Testing Static HTML with RSpec & Capybara
source :rubygems
gem 'capybara'
gem 'rack'
gem 'rspec'
@jaboc83
jaboc83 / sigPadCompression.js
Last active May 3, 2021 16:01
jQuery Signature Pad Compression/Decompression algorithm
/** Reinflates a compressed signature string:
resolution = a representation of the resolution in
pixels of the canvas which this signature will be drawn
e.g. {x:800,y:200}
*/
var inflateToJsonSignature = function (deflatedSig, resolution) {
var components = [],
modifier = 1,
compressWithResolution = /^(?:\[(\d+)x(\d+)\])?([\w\W]*)/,
parsedSigString = deflatedSig.match(compressWithResolution),
@coreyhaines
coreyhaines / .rspec
Last active August 15, 2024 15:13
Active Record Spec Helper - Loading just active record
--colour
-I app
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@mlc
mlc / index.haml
Created August 3, 2011 15:39
quick barcode generation in Rails
# put into your Gemfile
gem 'chunky_png'
gem 'barby', :require => ['barby', 'barby/outputter/chunky_png_outputter']