Skip to content

Instantly share code, notes, and snippets.

@vdv
vdv / rails_app.conf
Last active August 29, 2015 14:06
Ubuntu 12.04 Rails run scripts
upstream rails_app_upstream {
server unix:/home/deployer/projects/rails_app/shared/tmp/sockets/unicorn.socket fail_timeout=0;
}
server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
server_name localhost my_server.ru;
root /home/deployer/projects/rails_app/current/public;

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
<!-- ENTIRE PAGE -->
<section class="sp-reviews-container">
<header class="sp-reviews-container-header">Отзывы покупателей о товаре "Карталин мазь 100 мл."</header>
<!-- SUMMARY -->
<section class="sp-summary">
<header class="sp-summary-header">Рейтинг покупателей</header>
<!-- STATS -->
<section class="sp-summary-stats">
@vdv
vdv / unicorn
Created November 28, 2013 18:26
upstart config for unicorn
description "My Application"
start on runlevel [2]
stop on runlevel [016]
console log
setuid deployer
chdir /home/deployer/my_app/current
exec /home/deployer/my_app/current/config/unicorn/unicorn_wrapper -c /home/deployer/my_app/current/config/unicorn/unicorn.rb -E production
def resize_nocrop_noscale(image, w,h)
w_original = image[:width].to_f
h_original = image[:height].to_f
if w_original < w && h_original < h
return image
end
# resize
image.resize("#{w}x#{h}")
@vdv
vdv / nginx.rb
Last active December 15, 2015 22:58
homebrew formula for nginx with custom module
require 'formula'
class Nginx < Formula
homepage 'http://nginx.org/'
url 'http://nginx.org/download/nginx-1.2.8.tar.gz'
sha1 'b8c193d841538c3c443d262a2ab815a9ce1faaf6'
devel do
url 'http://nginx.org/download/nginx-1.3.15.tar.gz'
sha1 '16488c527078e26c32b0e467120501abf927fc8f'
# RAILS_ROOT/config/unicorn.rb
# Search for "# SET ME!" and replace these with your own settings!.
HOW_DEEP_WE_R_FROM_RAILS_ROOT = "../.."
# Set environment to development unless something else is specified
RAILS_ROOT = File.expand_path(HOW_DEEP_WE_R_FROM_RAILS_ROOT, File.dirname(__FILE__))
SHARED_PATH = File.expand_path('../shared', RAILS_ROOT)
ENV['BUNDLE_GEMFILE'] = File.expand_path("#{HOW_DEEP_WE_R_FROM_RAILS_ROOT}/Gemfile", File.dirname(__FILE__))
@vdv
vdv / gist:5062763
Created March 1, 2013 06:10
postresql create user
CREATE USER tom WITH PASSWORD 'myPassword';
CREATE DATABASE jerry;
GRANT ALL PRIVILEGES ON DATABASE jerry to tom;
@vdv
vdv / i18n_debug.rb
Created January 17, 2013 07:46
show in rails logger all i18n keys for current page
if Rails.env.development?
module I18n
class << self
alias :translate_orig :translate
def translate(*options)
Rails.logger.debug options.inspect
translate_orig *options
end
@vdv
vdv / model_name.rb
Created September 1, 2012 21:29
Migrate from paperclip to carrierwave
class ModelName
mount_uploader :image, PortfolioCatalogUploader, :mount_on => :image_file_name
def pp_path(style = 'original')
extension = File.extname(image_file_name)
id_partition = ("%09d" % id).scan(/\d{3}/).join("/")
"system/model_name/images/#{id_partition}/#{style}/#{id}#{extension}"
end
end