Skip to content

Instantly share code, notes, and snippets.

View akirill0v's full-sized avatar

Alexander Kirillov akirill0v

View GitHub Profile
@akirill0v
akirill0v / Gemfile
Created May 11, 2011 16:41 — forked from victusfate/Gemfile
Rails 3.1 Beta 1 on Heroku Working Config
# source 'http://rubygems.org'
source :gemcutter
gem 'rails', '3.1.0.beta1'
# Asset template engines
gem 'json'
gem 'sass'
gem 'coffee-script'
gem 'uglifier'
@akirill0v
akirill0v / gist:1596827
Created January 11, 2012 21:20 — forked from Watson1978/gist:1062455
MacRuby : Build UniversalBinary

Build LLVM 2.9

$ svn co https://llvm.org/svn/llvm-project/llvm/branches/release_29@127367 llvm-2.9
$ cd llvm-2.9
$ env UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" CC=/usr/bin/gcc CXX=/usr/bin/g++ ./configure --enable-bindings=none --enable-optimized --with-llvmgccdir=/tmp
$ env UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" CC=/usr/bin/gcc CXX=/usr/bin/g++ make 
$ sudo env UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" CC=/usr/bin/gcc CXX=/usr/bin/g++ make install

Build MacRuby

@akirill0v
akirill0v / 0-readme.md
Created January 31, 2012 19:13 — forked from burke/0-readme.md
ruby-1.9.3-p0 cumulative performance patch.

Patched ruby 1.9.3-p0 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p0 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84).

Huge thanks to funny-falcon for the performance patches.

@akirill0v
akirill0v / gist:2366922
Created April 12, 2012 12:30 — forked from realmyst/gist:1262561
Склонение числительных в javascript
function declOfNum(number, titles) {
cases = [2, 0, 1, 1, 1, 2];
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
}
use:
declOfNum(count, ['найдена', 'найдено', 'найдены']);
@akirill0v
akirill0v / gist:2366996
Created April 12, 2012 12:46 — forked from realmyst/gist:2366995
rails pluralization
#yml:
in_count_complex:
one: "в %{count} комплексе"
few: "в %{count} комплексах"
many: "в %{count} комплексах"
#view:
= t :in_count_complex, :count => projects.count
@akirill0v
akirill0v / gist:3340977
Created August 13, 2012 13:51 — forked from kosmatov/image-preview-html5.js
File preview on HTML5/JS/jQuery
$('form').on('change', 'input[type="file"]', function(e) {
var files = e.target.files,
f = files[0],
reader = new FileReader(),
t = this
;
reader.onload = (function(file) {
# gem install capybara --pre
# gem install rspec
# rspec capybara_test.rb
require 'rubygems'
require 'capybara'
require 'capybara/rspec'
Capybara.configure do |c|
c.current_driver = :selenium
@akirill0v
akirill0v / example.rb
Created October 31, 2012 09:45 — forked from joakimk/example.rb
A simple form object built on top of virtus.
class Filter
include FormObject
# Proc because Date.yesterday changes every day :)
attribute :from, Date, default: Proc.new { Date.yesterday }
attribute :to, Date, default: Proc.new { 1.month.from_now - 1.day }
end
# in controller
@filter = Filter.new(params[:filter])
@akirill0v
akirill0v / example.rb
Created November 13, 2012 19:21 — forked from joakimk/example.rb
A simple form object built on top of virtus.
class Filter
include FormObject
# Proc because Date.yesterday changes every day :)
attribute :from, Date, default: Proc.new { Date.yesterday }
attribute :to, Date, default: Proc.new { 1.month.from_now - 1.day }
end
# in controller
@filter = Filter.new(params[:filter])

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: