Skip to content

Instantly share code, notes, and snippets.

@D3xx73r
D3xx73r / mount_uploader.rb
Created June 30, 2012 19:35
Mount carrierwave uploader
#This should go in your model
mount_uploader :image, YourUploaderClass
@D3xx73r
D3xx73r / rails_new.sh
Created June 30, 2012 19:15
New Rails project
rails new your_project_name
@D3xx73r
D3xx73r / unicorn_ini.sh
Created May 1, 2012 01:06
Unicorn init shell script
#!/bin/sh
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Manage unicorn server
# Description: Start, stop, restart unicorn server for a specific application.
### END INIT INFO
@D3xx73r
D3xx73r / unicorn.rb
Created May 1, 2012 00:52
Unicorn config file
# Define your root directory
root = "/home/deployer/apps/gifroll/current"
# Define worker directory for Unicorn
working_directory root
# Location of PID file
pid "#{root}/tmp/pids/unicorn.pid"
# Define Log paths
@D3xx73r
D3xx73r / nginx.conf
Created April 30, 2012 21:04
Nginx configuration file
upstream unicorn {
server unix:/tmp/unicorn.<app_name>.sock fail_timeout=0;
}
server {
listen 80 default deferred;
server_name <your_servername>;
if ($host = '<your_servername>' ) {
rewrite ^/(.*)$ http://<your_servername>/$1 permanent;
}
@D3xx73r
D3xx73r / deploy.rb
Created April 30, 2012 20:48
Capistrano deploy file
require "bundler/capistrano"
# Define your server here
server "<server>", :web, :app, :db, primary: true
# Set application settings
set :application, "<app_name>"
set :user, "<deployment_user>" # As defined on your server
set :deploy_to, "/home/#{user}/apps/#{application}" # Directory in which the deployment will take place
set :deploy_via, :remote_cache
@D3xx73r
D3xx73r / server_config
Created April 30, 2012 19:47
Server configuration, running Ubuntu 10.04.4 LTS
# Get the latest packages
apt-get -y update
# Install curl, git and python properties to be able to add repositories to apt
apt-get -y install curl git-core python-software-properties
# Install nginx
add-apt-repository ppa:nginx/stable #add nginx repo to get the latest version
apt-get -y update # update installed packages
apt-get -y install nginx # Install the latest stable nginx