Skip to content

Instantly share code, notes, and snippets.

@mm53bar
mm53bar / app_vhost
Created April 13, 2012 01:39
Instead of using capistrano's deploy:web:disable (http://capitate.rubyforge.org/recipes/deploy-web.html#deploy:web:disable), why not just have the maintenance page displayed anytime the upstream server isn't available?
...
try_files $uri.html $uri @app;
error_page 502 503 =503 @maintenance;
location @app {
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;
@mm53bar
mm53bar / Gemfile
Created March 26, 2012 18:41
Automagically launch an EC2 image and then provision it using sunzi
source 'http://rubygems.org'
gem 'sunzi'
gem 'rake'
gem 'fog'
[alias]
stage = !sh -c '[[ -z "$@" ]] && git add -u || git add "$@" && git add -u "$@" ' -
unstage = reset HEAD --
rewind = ![[ -z "$@" ]] && git reset --hard HEAD || git checkout HEAD
@mm53bar
mm53bar / delicious.coffee
Created January 16, 2012 15:36
CoffeeScript for a delicious class
class Delicious
constructor: (robot, user, password) ->
@robot = robot
@user = user
@password = password
feed_url: ->
"https://delicious.com/v2/rss/#{@user}"
authdata: ->
@mm53bar
mm53bar / deploy.rb
Created November 4, 2011 14:40
Log your servers with Capistrano
require File.join(File.dirname(__FILE__), 'deploy/log')
# ....
# insert the rest of your capistrano script here
@mm53bar
mm53bar / molly.sh
Last active September 27, 2015 19:38
Molly - a quick little bash script to clean out your downloads and trash occasionally.
#!/bin/bash
# Installation:
#
# Clone Molly & add her to your crontab
#
# mkdir -p $HOME/bin && cd $HOME/bin && git clone git://gist.github.com/1321407.git molly
# cat <(crontab -l) <(echo "0 * * * * $HOME/bin/molly/molly.sh >/dev/null 2>&1") | crontab -
#
# Note: the /dev/null piece in the crontab just ensures that crontab won't send an email.
@mm53bar
mm53bar / nginx_rails_3_1
Created October 16, 2011 16:10 — forked from shapeshed/nginx_rails_3_1
Nginx Config for Rails 3.1 with Unicorn and Asset Pipeline
upstream app {
server unix:/srv/app/current/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name www.app.com;
rewrite ^/(.*) http://app.com/$1 permanent;
}
server {
@mm53bar
mm53bar / routes.rb
Created October 9, 2011 21:29
Voting code from filter
match "/upvote/:posting_id/:candidate_id" => "votes#upvote", :as => :upvotes
@mm53bar
mm53bar / deploy.rb
Created October 7, 2011 21:05
My capistrano deployment
require File.join(File.dirname(__FILE__), 'deploy/nginx')
require File.join(File.dirname(__FILE__), 'deploy/log')
default_run_options[:pty] = true
set :ssh_options, { :forward_agent => true }
set :application, "appname"
set :repository, "git@giturl"
set :scm, :git
@mm53bar
mm53bar / nginx.erb
Created October 1, 2011 17:45
nginx vhost file that I use in sprinkles recipe
upstream app_server {
server unix:/var/applications/<%= APP_NAME %>/current/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name www.<%= HOST %>;
rewrite ^/(.*) http://<%= HOST %>/$1 permanent;
}