Skip to content

Instantly share code, notes, and snippets.

View binarycode's full-sized avatar

Igor Sidorov binarycode

  • Virtuozzo
  • Rishon LeZion
View GitHub Profile
@xdite
xdite / gist:3072362
Created July 8, 2012 19:10
deploy/asset.rb
# -*- encoding : utf-8 -*-
set :assets_dependencies, %w(app/assets lib/assets vendor/assets Gemfile.lock config/routes.rb)
namespace :deploy do
namespace :assets do
desc <<-DESC
Run the asset precompilation rake task. You can specify the full path \
to the rake executable by setting the rake variable. You can also \
@mpapis
mpapis / gist:1789571
Created February 10, 2012 13:05
ruby not preserving order of array elements when sorting
1.9.3p0 :001 > Z=Struct.new(:n,:v)
=> Z
1.9.3p0 :002 > z=[ Z.new('b',1), Z.new('b',2), Z.new('a',1)]
=> [#<struct Z n="b", v=1>, #<struct Z n="b", v=2>, #<struct Z n="a", v=1>]
1.9.3p0 :003 > z.sort_by{ |z| z.n }
=> [#<struct Z n="a", v=1>, #<struct Z n="b", v=2>, #<struct Z n="b", v=1>]
1.9.3p0 :004 > z.each_with_index.sort_by{ |z, i| [z.n, i] }.map{|z,_| z}
# daemonized resque scheduler runner
require 'yaml'
env = ENV['RAILS_ENV'] || 'development'
scheduler_config = YAML.load_file(File.expand_path('../../config/resque_schedule.yml', __FILE__))[env]
puts scheduler_config.inspect
paths = []
paths << stdout_path = scheduler_config['stdout_path']
paths << stderr_path = scheduler_config['stderr_path']
paths << pidfile_path = scheduler_config['pidfile_path']
@mrrooijen
mrrooijen / deploy.rb
Created May 16, 2011 18:12
Unicorn + Bluepill + Capistrano with RVM
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require "rvm/capistrano"
set :application, "my_app"
set :repository, "[email protected]:myuser/myapp.git"
set :branch, "production"
set :rvm_ruby_string, "1.9.2"
set :deploy_to, "/var/applications/"
set :user, "username"