Skip to content

Instantly share code, notes, and snippets.

View webgago's full-sized avatar
🏠
Working from home

Anton Sozontov webgago

🏠
Working from home
  • Huntersville, NC
  • 07:13 (UTC -04:00)
View GitHub Profile
@webgago
webgago / nginx.conf
Created January 21, 2011 09:59
Nginx config
user www-data;
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /opt/nginx/logs/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
@webgago
webgago / xml_utf8_fix.rb
Created April 1, 2011 13:30
fix russian chars in xml/rss builder
class Fixnum #:nodoc:
XChar = Builder::XChar unless defined?(XChar)
# XML escaped version of chr (inlines cyrillic unicode range)
def xchr
n = XChar::CP1252[self] || self
n = 42 unless XChar::VALID.find { |value| value.kind_of?(Range) ? value.include?(n) : (value == n) }
XChar::PREDEFINED[n] or case n
when 0...128
@webgago
webgago / migrations_in_ror.rb
Created April 28, 2011 09:34
Миграции в RoR
# миграции генерятся при генерации модели
# $ rails generate model Post title:string content:text author_id:integer
# генерирует db/migrate/{TIME}_create_posts.rb
class CreatePosts < ActiveRecord::Migration
def self.up
create_table :posts do |t|
t.string :name
t.text :content
t.integer :author_id
end
@webgago
webgago / passwords_generator.rb
Created June 24, 2011 11:59
passwords generator
$file_mode = 'w'
$file_path = 'file.tmp'
$lines = []
def generate_lines
for i in 0..999
$lines << ("0".."z").to_a.sample((10..20).to_a.sample).join('')
end
end
class Post < ActiveRecord::Base
end
@webgago
webgago / nginx.conf
Created June 28, 2011 09:29
nginx config
user www-data;
worker_processes 8;
error_log /var/log/nginx/error.log;
pid /opt/nginx/logs/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
use epoll;
#!/usr/local/bin/ruby
require 'ap'
DOCS = %w{doc docx odt xls}
SCANS = %w{pdf tiff jpg jpeg bmp}
ARCHS = %w{zip rar 7z gz tgz bz2 bz}
MUZ = %w{mp3 wav flac}
dowsdir = '/home/achernikov/Downloads'
docs = []
archs = []
#!/usr/local/bin/ruby
module DocSorter
extend self
require 'ap'
DOC = %w{doc docx xls odt xlsx dwg txt cdr psd ppt eml csv log xslic}
CODE = %w{yml sql mht htm html php rb diff conf}
PDF = %w{pdf}
GRAPH = %w{tiff jpg jpeg bmp gif png}
ARH = %w{zip rar 7z gz tgz bz2 bz exe jnlp msi apk xpi gem ipsw}
def ApplicationController
def blah
@meme.drop!
end
end
class FooController < ApplicationController
@webgago
webgago / deploy.rb
Created July 5, 2012 19:24 — 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