Skip to content

Instantly share code, notes, and snippets.

View jstr's full-sized avatar

James Stradling jstr

  • Nelson, New Zealand
  • 03:18 (UTC +12:00)
View GitHub Profile
@terrcin
terrcin / gist:0745f2c6240aad291077
Last active August 29, 2015 14:17
Granting readonly access to rails production console by default
# In our config/deploy.rb we have the below for an easy prod console.
# There are various ways of doing it.
desc "Remote console"
task :console, roles: :app do
server = find_servers(roles: [:app]).first
run_with_tty server, %W( ./script/rails console #{rails_env} )
end
# Turns out there is a '--sandbox' option for the console that will roll back any changes on exit
@jinthagerman
jinthagerman / UIColor+Addition.m
Created May 16, 2012 05:26
UIColor from hex
// http://stackoverflow.com/questions/1560081/how-can-i-create-a-uicolor-from-a-hex-string
+ (UIColor *) colorWithHex:(int)hex {
return [UIColor colorWithRed:((float)((hex & 0xFF0000) >> 16))/255.0
green:((float)((hex & 0xFF00) >> 8))/255.0
blue:((float)(hex & 0xFF))/255.0 alpha:1.0];
}
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session