Skip to content

Instantly share code, notes, and snippets.

@kkdeploy
kkdeploy / ruby_install.sh
Created June 27, 2012 20:04
rvm bootstrap
#!/bin/bash
DEFAULT_RUBY_VERSION="1.9.3-p125"
if [ -e /etc/redhat-release ]; then
echo "Rhel 5 based distr"
sudo yum update -y
sudo rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
sudo yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison git curl
else
@kkdeploy
kkdeploy / gist:2950619
Created June 18, 2012 20:47
Capistrano fast assets precompile
namespace :assets do
task :precompile, :roles => :web, :except => { :no_release => true } do
if capture("diff -r #{latest_release}/app/assets/ #{current_release}/app/assets/ | wc -l").to_i > 0
run %Q{cd #{current_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile}
else
logger.info "Skipping asset pre-compilation because there were no asset changes"
end
end
end
@kkdeploy
kkdeploy / pg_dump_tables.sh
Created June 18, 2012 16:51
pg_dump all tables not consistently (!!!)
#!/bin/bash
mydir=/var/lib/pgsql/backups/`date +%Y-%m-%d_%H-%M`
function dumpdb {
mkdir -p $mydir/$1
for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" $1` ; do
pg_dump -t $tbl $1 | gzip > $mydir/$1/$tbl.sql.gz;
done
}
id | site_id | city_id | hold | delivery_at | sent_at | created_at | updated_at | main_deal_id |
batch_name | external_flag | banner_id | start_at | plain_html | plain_text
------+---------+---------+------+---------------------+----------------------------+----------------------------+----------------------------+--------------+------------
-----------------------------------------+---------------+-----------+----------------------------+------------+------------
4411 | 1 | 1 | f | 2012-04-27 02:33:00 | 2012-04-27 16:02:33.049718 | | 2012-04-27 16:02:33.049718 | 33816 |
| f | 31 | 2012-04-27 16:02:26.995216 | |
5346 | 2 | 23 | f | 2012-05-30 04:00:00 | | 2012-05-29 21:59:05.610717 | 2012-05-30 04:03:25.431067 |
cache_production: redis://localhost:6379/0
cache_staging: redis://localhost:6379/1
resque_production: redis://db1.kupikupon.ru:6379/0
resque_staging: redis://db1.kupikupon.ru:6379/1
@kkdeploy
kkdeploy / gist:2365742
Created April 12, 2012 09:06 — forked from dmexe/gist:1508019
Git workflow

После установки

Указываем свое имя и почту

git config --global user.name "Your Name Comes Here"
git config --global user.email you@yourdomain.example.com

Делаем алиасы на команды

@kkdeploy
kkdeploy / Gemfile
Created March 22, 2012 08:55 — forked from releu/Gemfile
State Validator for ActiveModel
source 'http://rubygems.org'
gem 'activemodel', '>= 3.0.0', :require => 'active_model'
gem 'state_machine', '>= 1.0.0'
gem 'rspec', '~> 2.8.0'