Skip to content

Instantly share code, notes, and snippets.

Когда мы хотим скопировать данные из production окружения Ruby on Rails приложения в development или staging, обычно, нам нужно скопировать дамп базы данных и статические файлы (например, изображения загруженные пользователями). Копирование базы может не представляет проблем (например, ее можно копировать из бэкапов или резервных серверов БД). А вот копирование статических файлов занимает много времени и ресурсов сервера с которого копируют (и на который копируются) файлы.

В рассылке ror2ru Макс Лапшин предложил

@afa
afa / README
Created May 31, 2013 09:22 — forked from andoriyu/README
unicorn_profiles="dev prod"
unicorn_dev_enable="yes"
unicorn_dev_user="devuser"
unicorn_dev_listen="/tmp/unicorn.dev.socket"
unicorn_dev_dir="/usr/local/www/dev"
unicorn_dev_config="/usr/local/www/dev/config.ru"
unicorn_dev_env="development"
unicorn_dev_flags="" # any additional flags
unicorn_dev_rails="YES" # For rails
class Symbol
def | other
if other.is_a? Proc
-> arg { other.call(arg.send(self)) }
else
-> arg { arg.send(self).send(other) }
end
end
def call *args
@afa
afa / 0. nginx_setup.sh
Created July 30, 2012 13:07 — forked from mikhailov/0. nginx_setup.sh
Nginx + secure pseudo-streaming
# Nginx can serve FLV/MP4 files by pseudo-streaming way without any specific media-server software.
# To do the custom build we use 2 modules: --with-http_secure_link_module --with-http_flv_module
# This module "secure-link" helps you to protect links from stealing away.
#
# NOTE: see more details at coderwall: http://coderwall.com/p/3hksyg
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.2.tar.gz
$ tar xzvf ./nginx-1.2.2.tar.gz && rm -f ./nginx-1.2.2.tar.gz
@afa
afa / deploy.rb
Created July 5, 2012 11:01 — forked from mikhailov/0. nginx_setup.sh
Nginx+Unicorn (production-ready setup)
# Capistrano configuration
#
# require 'new_relic/recipes' - Newrelic notification about deployment
# require 'capistrano/ext/multistage' - We use 2 deployment environment: staging and production.
# set :deploy_via, :remote_cache - fetch only latest changes during deployment
# set :normalize_asset_timestamps - no need to touch (date modification) every assets
# "deploy:web:disable" - traditional maintenance page (during DB migrations deployment)
# task :restart - Unicorn with preload_app should be reloaded by USR2+QUIT signals, not HUP
@afa
afa / bluepill.rb
Created July 5, 2012 10:35 — forked from bopm/bluepill.rb
bluepill unicorn pill
# http://devmull.net/articles/unicorn-resque-bluepill
# http://www.jamievandyke.com/want-some-campfire-with-that-bluepill
app_name = 'rails'
app_env = 'production'
Bluepill.application(app_name) do |app|
RAILS_ROOT = "/var/www/#{app_name}/"
app.uid = app.gid = "www-rails"
app.working_dir = RAILS_ROOT
worker_queues = %w[queue]
@afa
afa / gist:2497280
Created April 26, 2012 07:44 — forked from dhh/gist:2492118
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@afa
afa / gist:2043722
Created March 15, 2012 11:18
зачистка всех непозволенных ключей из хэша
{1=>2, 3=>4}.select{|a, b| [1].include? a }.inject({}){|r, v| r.merge(v[0] => v[1]) }
@afa
afa / xmpp.rb
Created February 3, 2012 10:19
xmpp example
require 'rubygems'
require 'xmpp4r/client'
include Jabber
server, login, password = "qip.ru", "my_login", "my_password"
to, subject, body = "someone@qip.ru", "XMPP4R test", "Hi, this is my first try from XMPP4R!!!"
Jabber::debug = true
jid=JID::new "#{login}@#{server}"
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2008 Jul 02
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc