Skip to content

Instantly share code, notes, and snippets.

View dzaporozhets's full-sized avatar

Dmitriy Zaporozhets dzaporozhets

View GitHub Profile
.hll { background-color: #ffffcc }
.c { color: #586E75 } /* Comment */
.err { color: #93A1A1 } /* Error */
.g { color: #93A1A1 } /* Generic */
.k { color: #859900 } /* Keyword */
.l { color: #93A1A1 } /* Literal */
.n { color: #93A1A1 } /* Name */
.o { color: #859900 } /* Operator */
.x { color: #CB4B16 } /* Other */
.p { color: #93A1A1 } /* Punctuation */

Zero downtime deploys with unicorn + nginx + runit + rvm + chef

Below are the actual files we use in one of our latest production applications at Agora Games to achieve zero downtime deploys with unicorn. You've probably already read the GitHub blog post on Unicorn and would like to try zero downtime deploys for your application. I hope these files and notes help. I am happy to update these files or these notes if there are comments/questions. YMMV (of course).

Other application notes:

  • Our application uses MongoDB, so we don't have database migrations to worry about as with MySQL or postgresql. That does not mean that we won't have to worry about issues with the database with indexes being built in MongoDB or what have you.
  • We use capistrano for deployment.

Salient points for each file:

@dzaporozhets
dzaporozhets / gist:3981157
Created October 30, 2012 15:59 — forked from thijsc/gist:1391107
Select item from chosen js select with Capybara and Selenium
def select_from_chosen(item_text, options)
field = find_field(options[:from])
option_value = page.evaluate_script("$(\"##{field[:id]} option:contains('#{item_text}')\").val()")
page.execute_script("$('##{field[:id]}').val('#{option_value}')")
end
@dzaporozhets
dzaporozhets / console
Created October 11, 2012 08:00 — forked from dmitriy-kiriyenko/console
Init.d to start/stop xvfb. Put it into /etc/init.d and chmod it to 755
apt-get install xvfb
apt-get install firefox
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@dzaporozhets
dzaporozhets / gist:3065552
Created July 7, 2012 08:59 — forked from justincjahn/gist:3062860
Gitlab init.d for RedHat based distributions.
#!/bin/bash
#
# GitLab Runs unicorn and resque for nginx integration.
###
# chkconfig: 35 98 55
# processname: unicorn
# processname: resque
# description: Runs unicorn and resque for nginx integration.
###
@dzaporozhets
dzaporozhets / whitespace.rake
Created June 5, 2012 08:06 — forked from NARKOZ/whitespace.rake
Whitespaaaaaaaace! WHITESPAAAAAAAACE!
namespace :whitespace do
desc 'Removes trailing whitespace'
task :cleanup do
sh %{for f in `find . -type f | grep -v .git | grep -v ./vendor | grep -v ./tmp | egrep ".(rb|js|haml|html|css|sass)"`;
do sed -i '' 's/ *$//g' "$f";
done}, {:verbose => false}
puts "done"
end
desc 'Converts hard-tabs into two-space soft-tabs'
@dzaporozhets
dzaporozhets / gist:2770405
Created May 22, 2012 17:25 — forked from PotHix/gist:640517
remarkable -> shoulda sed helpers :P
grep "should_have_many" spec/* -Ril | xargs sed -i "s/should_have_many\(.*\)/it { should have_many\1 }/g"
grep "should_have_one" spec/* -Ril | xargs sed -i "s/should_have_one\(.*\)/it { should have_one\1 }/g"
grep "should_belong_to" spec/* -Ril | xargs sed -i "s/should_belong_to\(.*\)/it { should belong_to\1 }/g"
grep "should_validate_presence_of.*" spec/* -Ril | xargs sed -i "s/should_validate_presence_of\(.*\)/it { should validate_presence_of\1 }/g"
grep "should_validate_uniqueness_of.*" spec/* -Ril | xargs sed -i "s/should_validate_uniqueness_of\(.*\)/it { should validate_uniqueness_of\1 }/g"
grep "should_validate_numericality_of.*" spec/* -Ril | xargs sed -i "s/should_validate_numericality_of\(.*\)/it { should validate_numericality_of\1 }/g"
grep "should_validate_acceptance_of.*" spec/* -Ril | xargs sed -i "s/should_validate_acceptance_of\(.*\)/it { should validate_acceptance_of\1 }/g"
grep "should have_many :.*through.*" spec/* -Ril | xargs sed -i 's/should have_many :\([a-z_=>]*\),.*:through => :\(.*\)
@dzaporozhets
dzaporozhets / Gemfile
Created April 19, 2012 11:53 — forked from fxposter/Gemfile
Test environment for rails apps
group :development, :test do
gem 'rspec-rails', '~> 2.9' # rails generate rspec:install
gem 'factory_girl_rails'
end
group :test do
gem 'spork-rails' # spork rspec --bootstrap
gem 'capybara'
gem 'launchy'
gem 'timecop'
@dzaporozhets
dzaporozhets / teste_merge.rb
Created March 13, 2012 10:49 — forked from danielweinmann/teste_merge.rb
Testing Git merges using Grit
require 'grit'
require 'fileutils'
# Define our paths.
# We're gonna have 3 paths: one original, one for the fork, and yet another one for the merge
root_path = "#{File.dirname(__FILE__)}/documents"
original_path = "#{root_path}/original_repo.git"
fork_path = "#{root_path}/fork_repo.git"
merge_path = "#{root_path}/merge_repo"