- Mac OS X Mountain Lion (10.8.2)
- Homebrew
- readline
- rbenv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Nginx+Unicorn best-practices congifuration guide. Now with SPDY! | |
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies. | |
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module | |
# | |
# Deployment structure | |
# | |
# SERVER: | |
# /etc/init.d/nginx (1. nginx) | |
# /home/app/public_html/app_production/current (Capistrano directory) | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'faraday' | |
require 'net/http/digest_auth' | |
module Faraday | |
# Public: A Faraday middleware to use digest authentication. Since order of | |
# middlewares do care, it should be the first one of the Request middlewares | |
# in order to work properly (due to how digest authentication works). | |
# | |
# If some requests using the connection don't need to use digest auth you |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'faraday' | |
require 'zlib' | |
module Faraday | |
class Response::Gzip < Response::Middleware | |
def on_complete(env) | |
encoding = env[:response_headers]['content-encoding'].to_s.downcase | |
case encoding | |
when 'gzip' | |
env[:body] = Zlib::GzipReader.new(StringIO.new(env[:body]), encoding: 'ASCII-8BIT').read |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
module Utils | |
module Qwerty | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
EN = %W(q w e r t y u i o p [ ] a s d f g h j k l ; ' \\ z x c v b n m , . ') | |
RU = %w(й ц у к е н г ш щ з х ъ ф ы в а п р о л д ж э ё я ч с м и т ь б ю) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QuickFind | |
def initialize(n) | |
@ids = [] | |
0.upto(n-1) {|i| @ids[i] = i} | |
end | |
def connected?(id1,id2) | |
@ids[id1] == @ids[id2] | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require 'oj' | |
class WrapperSerializer < ActiveModel::Serializer | |
attributes :seq | |
end | |
class Wrapper | |
include ActiveModel::SerializerSupport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'sinatra' | |
gem 'sinatra-contrib', require: 'sinatra/streaming' | |
group :development do | |
gem 'thin' | |
gem 'pry-rails' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ redis-cli | |
> config set stop-writes-on-bgsave-error no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Search by polygons | |
t = Tire.search('places', load:false) do | |
query { all } | |
sw = [55.524508, 36.414773] #lat, lng | |
ne = [55.974333, 38.886697] | |
nw = [55.974333, 36.414773] | |
se = [55.524508, 38.886697] | |
filter :geo_polygon, lat_lng: {points: [sw, ne, nw, se, sw]} | |
end.results |