Skip to content

Instantly share code, notes, and snippets.

View Saicheg's full-sized avatar

Valentine Zavadsky Saicheg

View GitHub Profile
### Nginx upstart script
### source: http://serverfault.com/a/391737/70451
### /etc/init/nginx.conf
description "nginx http daemon"
start on (filesystem and net-device-up IFACE=lo)
stop on runlevel [!2345]
env DAEMON=/usr/local/sbin/nginx
@Saicheg
Saicheg / 1.md
Last active January 2, 2016 02:09
2.0 vs 2.1

2.0

time rspec spec
7.26s user 2.04s system 82% cpu 11.265 total
time rails runner "puts 3"
3.91s user 1.34s system 89% cpu 5.852 total
# A small DSL for helping parsing documents using Nokogiri::XML::Reader. The
# XML Reader is a good way to move a cursor through a (large) XML document fast,
# but is not as cumbersome as writing a full SAX document handler. Read about
# it here: http://nokogiri.org/Nokogiri/XML/Reader.html
#
# Just pass the reader in this parser and specificy the nodes that you are interested
# in in a block. You can just parse every node or only look inside certain nodes.
#
# A small example:
#
#!/usr/bin/env ruby
require 'rubygems'
gempaths = Gem::default_path
puts
puts "Scanning paths in Gem::default_path for RubyGems with native extensions ..."
puts
@Saicheg
Saicheg / gist:5127280
Created March 10, 2013 05:43
Nginx configure options for Rails on Ubuntu
./configure --prefix=/etc/nginx --sbin-path=/usr/local/sbin --pid-path=/var/lock/nginx/nginx.pid --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --conf-path=/etc/nginx/nginx.conf --with-http_ssl_module --with-http_gzip_static_module
#!/bin/bash
# Checks the files to be committed for the presence of binding.pry
# The array below can be extended for further checks
checks[1]="binding.pry"
checks[2]="console.log"
element_count=${#checks[@]}
let "element_count = $element_count + 1"
@Saicheg
Saicheg / screenshare
Created December 7, 2012 07:46
Share screenshots on Ubuntu using Dropbox
#!/bin/bash
################
# Description:
# This script will take screenshot of your desktop
# or only active window ( running with -u param ),
# copy it to /Dropbox/Public/share/ with uniq name
# and save path to clipboard
#################
# Requirements:
# Dropbox
@Saicheg
Saicheg / gist:3806285
Created September 30, 2012 08:51
Song
Как ломались огни чей-то жизни навзрыд,
как купались ангелы вдоль стиксовых вод.
Как упилися мы у родных нам могил,
Как кружились собаки да в ночь хоровод.
@Saicheg
Saicheg / gist:3754626
Created September 20, 2012 08:15
I18n hack
require 'i18n'
if (Rails.env.development? || Rails.env.test?) && ENV['SHOW_TR']
module I18n
class << self
def translate_with_debug(*args)
result = translate_without_debug(*args)
puts "[\e[32mTranslate\e[0m] #{args.inspect}\t [\e[31mResult\e[0m] #{result}"
end
alias_method_chain :translate, :debug