Skip to content

Instantly share code, notes, and snippets.

View amerine's full-sized avatar
🌅
Out West

Mark Turner amerine

🌅
Out West
View GitHub Profile
if ENV['RAILS_ENV'] && !Object.const_defined?('RAILS_DEFAULT_LOGGER')
require 'logger'
RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
end
Bluepill.application("app_name") do |app|
app.process("app_name") do |process|
process.start_command = "cd /u/apps/app_name/current && /usr/local/bin/unicorn_rails -c /u/apps/app_name/current/config/unicorn.conf.rb -E production -D"
process.stop_command = "kill -QUIT `cat /u/apps/app_name/current/tmp/pids/unicorn.pid`"
process.restart = "kill -USR2 `cat /u/apps/app_name/current/tmp/pids/unicorn.pid`"
process.stdout = process.stderr = "/u/apps/app_name/current/log/unicorn.log"
process.pid_file = "/u/apps/app_name/current/tmp/pids/unicorn.pid"
process.checks :mem_usage, :every => 10.seconds, :below => 250.megabytes, :times => [3, 5]
process.uid = "app"
process.gid = "app"
class Project < ActiveRecord::Base
alias :old_read_attribute :read_attribute
def read_attribute(attr)
old_read_attribute(attr) or 'none'
end
end
class Project < ActiveRecord::Base
def name
read_attribute(:name) or 'none'
end
end
development:
adapter: sqlite3
database: db/development.sqlite3
timeout: 5000
test:
adapter: sqlite3
database: db/test.sqlite3
timeout: 5000
module Rack
class Clicky
TRACKING_CODE = <<-EOTC
<script src="http://static.getclicky.com/js" type="text/javascript"></script>
<script type="text/javascript">clicky.init({{CODE}});</script>
<noscript><p><img alt="Clicky" width="1" height="1" src="http://in.getclicky.com/{{CODE}}ns.gif" /></p></noscript>
EOTC
def initialize(app, site_id, options = {})
def signup
user = User.new(blah blah blah)
begin
UserMailer.email_confirmation(user).deliver
rescue Exception => e
handle error
end
end
User.all(:conditions => { :birthday => (Time.now.midnight - 1.day)..(Time.now.midnight + 1.month}, :active => true)
module Rack
class Konami
KONAMI_CODE = <<-EOTC
<div id="rack_konami" style="display:none;position:fixed;top:20%;right:50%;">
{{HTML}}
</div>
<script type="text/javascript">
var Konami=function(){var a={addEvent:function(b,c,d,e){if(b.addEventListener)b.addEventListener(c,d,false);else if(b.attachEvent){b["e"+c+d]=d;b[c+d]=function(){b["e"+c+d](window.event,e)};b.attachEvent("on"+c,b[c+d])}},input:"",pattern:"3838404037393739666513",load:function(b){this.addEvent(document,"keydown",function(c,d){if(d)a=d;a.input+=c?c.keyCode:event.keyCode;if(a.input.length>a.pattern.length)a.input=a.input.substr(a.input.length-a.pattern.length);if(a.input==a.pattern){a.code(b);a.input=
""}},this);this.iphone.load(b)},code:function(b){window.location=b},iphone:{start_x:0,start_y:0,stop_x:0,stop_y:0,tap:false,capture:false,orig_keys:"",keys:["UP","UP","DOWN","DOWN","LEFT","RIGHT","LEFT","RIGHT","TAP","TAP","TAP"],code:function(b){a.code(b)},load:function(b){orig_keys=this.keys;a.addEvent(do
require 'rubygems'
require 'bacon'
describe 'A new array' do
before do
@ary = (1..10).to_a
end
it 'should not be empty' do
@ary.length.should.be > 1