Skip to content

Instantly share code, notes, and snippets.

View philspitler's full-sized avatar
💻
Coding all the things!

Phillip Spitler philspitler

💻
Coding all the things!
View GitHub Profile
@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
@igrigorik
igrigorik / rack_routes.rb
Created March 29, 2011 04:17
Goliath + http_router.rb
require 'goliath'
require 'http_router'
# https://github.com/joshbuddy/http_router
HttpRouter::Rack.override_rack_builder!
class RackRoutes < Goliath::API
map('/get/:id') do |env|
[200, {'Content-type' => 'text/plain'}, ["My id is #{env['router.params'][:id]}\n"]]
end
def reify_has_manys(model, lookback)
model.class.reflect_on_all_associations(:has_many).each do |assoc|
# Get live children.
children = model.send assoc.name
# Ensure child models are using PaperTrail.
if children.first.respond_to? :version_at
# Handle updated children, and children created since the parent's version.
children_then = []
children.each do |child|
if (child_as_it_was = child.version_at(created_at - lookback.seconds))
@Sutto
Sutto / setup_load_paths.rb
Created July 17, 2010 23:36
Automatic .rvmrc detection + bundler setup on passenger
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
# Differentiate between new and old passenger versions
if File.exist?(File.join(rvm_lib_path, "rvm", "environment.rb"))
$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! Dir.pwd # Passenger starts in the app root
end
end