Skip to content

Instantly share code, notes, and snippets.

View antonfefilov's full-sized avatar
🚀
To infinity and beyond!

Anton Fefilov antonfefilov

🚀
To infinity and beyond!
  • ScienceCast
  • Georgia, Tbilisi
View GitHub Profile

A Capistrano Rails Guide

by Jonathan Rochkind, http://bibwild.wordpress.com

why cap?

Capistrano automates pushing out a new version of your application to a deployment location.

I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".

@antonfefilov
antonfefilov / gist:5796238
Last active December 18, 2015 14:19
Как то так ...
old_string = "312211"
counter = 1
new_string = ""
for index_of_char in 0..old_string.size-1
char = old_string[index_of_char]
if old_string[index_of_char] == old_string[index_of_char+1]
counter += 1
class Seq
def initialize(string)
@string = string.to_s
end
def next
@string = generate(@string)
self
end
@antonfefilov
antonfefilov / unicorn.rb
Created September 13, 2013 07:08
Unicorn on Heroku config
# config/unicorn.rb
worker_processes Integer(ENV['WEB_CONCURRENCY'] || 3)
timeout Integer(ENV['WEB_TIMEOUT'] || 15)
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install postgresql-9.2 postgresql-server-dev-9.2 postgresql-contrib-9.2
sudo su -l postgres
psql -d template1 -p 5433
CREATE EXTENSION IF NOT EXISTS hstore;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
service postgresql stop
/usr/lib/postgresql/9.2/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.2/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.2/main/ -O "-c config_file=/etc/postgresql/9.2/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"
#install required packages
apt-get update
apt-get upgrade -y
apt-get install -y git curl build-essential libssl-dev libcurl4-openssl-dev nodejs
#install sqlite3 (optional)
apt-get install libsqlite3-dev sqlite3
#install postgres (optional)
sudo apt-get install postlibpq-dev
@antonfefilov
antonfefilov / Subscription
Created January 10, 2014 15:04
Stripe subscription object
#<Stripe::StripeObject id=sub_3Hg6e9n909QzDb 0x00000a> JSON: {
"id": "sub_3Hg6e9n909QzDb",
"plan": {
"interval": "week",
"name": "Team up",
"amount": 100,
"currency": "usd",
"id": "team_up",
"object": "plan",
"livemode": false,
@antonfefilov
antonfefilov / deploy.rb
Created January 11, 2014 08:48 — forked from reu/deploy.rb
# Bundler Integration
require "bundler/capistrano"
# Application Settings
set :application, "yourapplicationname"
set :user, "serveruser"
set :deploy_to, "/home/#{user}/rails-applications/#{application}"
set :rails_env, "production"
set :use_sudo, false
set :keep_releases, 3
# config/initializers/active_admin.rb
require 'active_admin_custom_filter'
ActiveAdmin.setup do |config|
# ...
end