Skip to content

Instantly share code, notes, and snippets.

@itchy
itchy / intersection_spec.rb
Created February 27, 2013 02:09
Hack Club Traffic Light
class Light
attr_reader :state
def initialize()
@state = :red
end
def tick(count=1)
count.times do
@itchy
itchy / gist:5363607
Last active December 16, 2015 02:38 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts (Mac OS X)

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
@itchy
itchy / application_controller.rb
Last active December 21, 2015 23:39
Setting I18n localizations to format times based on user's timezone
class ApplicationController < ActionController::Base
around_filter :set_i18n_locale_from_current_user
def set_i18n_locale_from_current_user
org_timezone = I18n.current_timezone
if current_user
I18n.current_timezone = current_user.timezone
end
yield
ensure
@itchy
itchy / background.rb
Created June 18, 2014 04:44
poor man's background job
system("bash", "-c", "cd #{Rails.root} && bundle exec rake tasks:regenerate['#{current_practice.id}'] &")