Skip to content

Instantly share code, notes, and snippets.

@mrrooijen
mrrooijen / gist:913056
Created Apr 11, 2011
My Heroku Asset Packager setup
View gist:913056
# Gemfile
gem 'jammit-s3', :git => 'git://github.com/meskyanichi/jammit-s3.git'
# config/assets.yml
s3_bucket: mybucket
s3_access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %>
s3_secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %>
s3_permission: public_read
embed_assets: on
@mrrooijen
mrrooijen / sendgrid-smtp.rb
Created May 12, 2011
SMTP Settings for SendGrid
View sendgrid-smtp.rb
# This is what people apparently use:
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => 25,
:domain => 'mysite.com',
:authentication => :plain,
:user_name => 'sendgrd_username@mysite.com',
:password => 'sendgrid_password'
}
@mrrooijen
mrrooijen / unicorn.pill
Created May 16, 2011
Bluepill Process Monitoring configuration for Unicorn Ruby App Server.
View unicorn.pill
#! /usr/bin/env ruby
Bluepill.application("app_name-production") do |app|
app.process("unicorn") do |process|
process.pid_file = File.join(RAILS_ROOT, 'tmp', 'pids', 'unicorn.pid')
process.working_dir = RAILS_ROOT
process.start_command = "/usr/bin/env UNICORN_SERVERS=#{ENV['UNICORN_SERVERS']} #{UNICORN_PATH} -D -c config/unicorn.rb -E production"
process.stop_command = "kill -QUIT {{PID}}"
process.restart_command = "kill -USR2 {{PID}}"
@mrrooijen
mrrooijen / unicorn.rb
Created May 16, 2011
Unicorn sample configuration file
View unicorn.rb
# encoding: utf-8
# Spawn 3 workers
worker_processes ENV['UNICORN_SERVERS'].nil? ? 3 : ENV['UNICORN_SERVERS'].to_i
# Restart any workers that haven't responded in 30 seconds
timeout 30
# Listen on a Unix data socket
listen File.join(ENV['HOME'], 'tmp', 'sockets', 'rails', 'unicorn.sock'), :backlog => 2048
@mrrooijen
mrrooijen / deploy.rb
Created May 16, 2011
Unicorn + Bluepill + Capistrano with RVM
View deploy.rb
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require "rvm/capistrano"
set :application, "my_app"
set :repository, "git@trunksapp.com:myuser/myapp.git"
set :branch, "production"
set :rvm_ruby_string, "1.9.2"
set :deploy_to, "/var/applications/"
set :user, "username"
@mrrooijen
mrrooijen / nginx.conf
Created May 23, 2011
Faye + PrivatePub + HTTPS (SSL) Protocol
View nginx.conf
location /faye {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
root /var/applications/current/faye;
proxy_pass http://127.0.0.1:4001; # im running faye on port 4001
break;
}
@mrrooijen
mrrooijen / Gemfile
Created Jun 9, 2011
Compass with Rails 3.1
View Gemfile
gem 'compass', :git => 'https://github.com/chriseppstein/compass.git', :branch => 'rails31'
@mrrooijen
mrrooijen / force-ssl.rb
Created Jun 20, 2011
Secure with SSL (Subdomain and Protocol) in Rails 3.1
View force-ssl.rb
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :secure_with_ssl
private
def secure_with_ssl
if request.subdomain != 'secure' or request.protocol != 'https'
redirect_to :subdomain => 'secure', :protocol => 'https'
@mrrooijen
mrrooijen / Gemfile
Created Jun 23, 2011
Heroku CoffeeScript, Compass, Sprockets in Rails 3.1.rc4
View Gemfile
source 'http://rubygems.org'
gem 'rails', '3.1.0.rc4'
gem 'sprockets', '!= 2.0.0.beta.11'
gem 'haml-rails'
gem 'sass-rails'
gem 'compass', :git => 'https://github.com/chriseppstein/compass.git', :branch => 'rails31'
gem 'coffee-script'
gem 'uglifier'
gem 'therubyracer'
@mrrooijen
mrrooijen / deploy.rb
Created Jun 26, 2011
Capistrano with Foreman Capfile
View deploy.rb
# encoding: utf-8
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require 'rvm/capistrano'
set :application, "hirefireapp"
set :repository, "git@codeplane.com:meskyanichi/myapp.git"
set :branch, "develop"
set :rvm_ruby_string, "1.9.2"