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
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"
development:
adapter: sqlite3
database: db/development.sqlite3
timeout: 5000
test:
adapter: sqlite3
database: db/test.sqlite3
timeout: 5000
def signup
user = User.new(blah blah blah)
begin
UserMailer.email_confirmation(user).deliver
rescue Exception => e
handle error
end
end
desc "Rebuild localhosts"
task(:rebuild_localhosts => :environment) do
ClientDomain.rebuild_localhosts
end
@amerine
amerine / app.rb
Created February 22, 2011 07:25 — forked from densone/gist:838331
require 'rubygems'
require 'bundler'
Bundler.require(:default)
REST OF YOUR APP
@amerine
amerine / rspec-syntax-cheat-sheet.rb
Created July 1, 2011 23:20 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@amerine
amerine / gist:1265199
Created October 5, 2011 18:10 — forked from kalv/gist:913392
Clear out Resque messages that have Decode errors.
# Use from console, was required as old messages were incorrectly encoded and placed on the failed queue
# preventing us to view the failed queue.
include Resque::Helpers
Resque::Failure.count.times do |index|
puts "Checking #{index}"
begin
decode Resque.redis.lindex(:failed, index)
rescue Resque::Helpers::DecodeException
@amerine
amerine / connection_fix.rb
Created December 31, 2011 00:28 — forked from defunkt/connection_fix.rb
MySQL server has gone away fix
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
@amerine
amerine / tpl-basicapp.rb
Created May 15, 2012 07:28 — forked from jetspeed/tpl-basicapp.rb
Rails 3, RSpec, Factory_Girl, HAML, SASS, Devise, JQuery, Backbone.js, jammit, haml.js
## Rails App Template
## Useful for Rails 3.0.x and Ruby 1.9.2
## Run using $ rails new [appname] -JT -m tpl-basicapp.rb
# ========
# = Gems =
# ========
# pre-install spork, dydram and elastic_searchable
run "gem install spork -v 0.9.0.rc --pre"
Host *+*
ProxyCommand ssh $(echo %h | sed 's/+[^+]*$//;s/\([^+%%]*\)%%\([^+]*\)$/\2 -l \1/;s/:/ -p /') nc $(echo %h | sed 's/^.*+//;/:/!s/$/ %p/;s/:/ /')
StrictHostKeyChecking no
UserKnownHostsFile /dev/null