Skip to content

Instantly share code, notes, and snippets.

View supairish's full-sized avatar
🏂
Shreddin

Chris Irish supairish

🏂
Shreddin
View GitHub Profile

Goals of this tutorial:

  • deploy a new Rails app with capistrano
  • make it fast (total process takes less than 5 minutes)
  • make it simple (no unecessary config)
  • manual ssh to the server not required

Rails application stack:

  • nginx
  • unicorn
  • postgresql
@supairish
supairish / ember_deploy.sh
Last active September 14, 2015 17:07 — forked from skwp/ember_deploy.sh
#!/bin/bash
# Fail if any commands fail
set -e
set -o pipefail
# These are ec2 tags from which we will determine where to deploy
ec2_stage=$DEPLOY_STAGE
ec2_app="core"
ec2_role="app"
@supairish
supairish / gist:1033379
Created June 18, 2011 18:32 — forked from bgkittrell/gist:704674
Reorder Multiple Elements ala Netflix
images = @album.image_assignments
changed = Array.new
# Get the images that changed order
for image in images
order = params["order_#{image.image_id}".to_sym]
if !order.blank? && order =~ /^\d+$/ && image.position.to_i != order.to_i
image.position = order.to_i
changed << image
@supairish
supairish / gist:1521680
Created December 26, 2011 17:25 — forked from parndt/gist:1011435
How to cache pages and clear them in Refinery CMS
# put in config/application.rb
config.to_prepare do
::PagesController.module_eval do
caches_page :show, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
caches_page :home, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
end
::Page.module_eval do
after_save :clear_static_caching!
after_destroy :clear_static_caching!
@supairish
supairish / arel_or.rb
Created January 30, 2012 08:16 — forked from philsmy/arel_or.rb
or scopes - add this to your model to be able to or scopes together (eg: Model.or(Model.scope1, Model.scope2). Stolen and adapted from fake_arel
__or_fn = lambda do |*scopes|
where = []
joins = []
includes = []
# for some reason, flatten is actually executing the scope
scopes = scopes[0] if scopes.size == 1
scopes.each do |s|
w = []
s.where_clauses.each do |where_clause|
@supairish
supairish / ubuntu_steps.sh
Created March 25, 2012 04:05 — forked from johnrees/_ubuntu_steps.sh
Standard Rails 3.* setup for Ubuntu 10.04 LTS 32
# As root user
# Update the OS
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
# Setup Hostname & TimeZone
echo "{{HOSTNAME}}" > /etc/hostname
hostname -F /etc/hostname
dpkg-reconfigure tzdata
@supairish
supairish / application.rb
Created May 18, 2012 00:18 — forked from steve9001/application.rb
Rails middleware to provide information about errors during requests
module MyApp
class Application < Rails::Application
if Rails.env == 'test'
require 'diagnostic'
config.middleware.use(MyApp::DiagnosticMiddleware)
end
end
end
@supairish
supairish / installation.sh
Created June 6, 2012 16:56 — forked from mikhailov/installation.sh
nginx+passenger (real production config)
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.0.15.tar.gz
$ tar xzvf ./nginx-1.0.15.tar.gz
$ rm -f ./nginx-1.0.15.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
$ tar xzf openssl-1.0.1c.tar.gz && rm -f openssl-1.0.1c.tar.gz
namespace :attachments do
task :migrate_to_s3 => :environment do
require 'aws/s3'
# Load credentials
s3_options = YAML.load_file(File.join(Rails.root, 'config/s3.yml')).symbolize_keys
bucket = s3_options[:bucket_name]
# Establish S3 connection
0. rails new my_store && cd my_store
1. to Gemfile
remove gem 'rais', gem 'jquery-rails'
and add folowing rows:
-------------------------------------------------------------------------------------------------------
gem 'liquid', :git => 'git://github.com/Shopify/liquid.git'
gem 'spree', :git => "git://github.com/spree/spree.git", :branch => "1-3-stable"
gem 'spree_i18n', :git => 'git://github.com/spree/spree_i18n.git'
gem 'refinerycms', :git => "git://github.com/refinery/refinerycms.git"#, :branch => "2-0-stable"