Skip to content

Instantly share code, notes, and snippets.

View evtuhovich's full-sized avatar

Ivan Evtuhovich evtuhovich

View GitHub Profile
<?php
/* This file is used by the Zabbix PHP web frontend.
* It is pre-filled with the information asked during
* installation of the zabbix-server-* package.
*/
global $DB;
$DB["TYPE"] = "pgsql";
@evtuhovich
evtuhovich / gist:7022395
Created October 17, 2013 10:12
Платный интернет на Кипре
ping ya.ru
PING ya.ru (87.250.250.3): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
64 bytes from 87.250.250.3: icmp_seq=0 ttl=54 time=2497.125 ms
64 bytes from 87.250.250.3: icmp_seq=0 ttl=55 time=2497.153 ms (DUP!)
64 bytes from 87.250.250.3: icmp_seq=0 ttl=54 time=2497.483 ms (DUP!)
64 bytes from 87.250.250.3: icmp_seq=0 ttl=55 time=2497.488 ms (DUP!)
64 bytes from 87.250.250.3: icmp_seq=1 ttl=54 time=2136.664 ms
Request timeout for icmp_seq 4
@evtuhovich
evtuhovich / edit_data_bag.rb
Last active December 15, 2015 13:49
script to edit encrypted data bags secret key should be at .chef/encrypted_data_bag_secret
#!/usr/bin/env ruby
#Dir.chdir File.join(__FILE__, "../..")
require 'openssl'
unless ENV['EDITOR']
puts "No EDITOR found. Try:"
puts "export EDITOR=vim"
exit 1
end
@evtuhovich
evtuhovich / rmongo.rb
Created December 18, 2012 11:58
Код к докладу "Нетрадиционное использование Ruby и PostgreSQL" http://www.slideshare.net/evtuhovich/ruby-postgresql
require 'rubygems'
require 'pg'
require 'yaml'
class DB
def initialize(debug = true)
@conn = PG::Connection.open()
@debug = debug
end
@evtuhovich
evtuhovich / gist:1134998
Created August 9, 2011 19:43
Список вопросов для собеседования
Ruby
принципиальное различие скриптовых и “обычных” языков
3 принципа ООП
реализация множественного наследования в ruby
duck typing
многопоточность в ruby
Rails
что такое MVC и зачем это нужно
локига в контроллере, должна ли быть и почему
синхронные и асинхронные операции — предложить варианты решения
@evtuhovich
evtuhovich / gist:988261
Created May 24, 2011 07:28
Enabling russian in IRB
$ cd .rvm/src/ree-1.8.7-2011.03/source/ext/readline/
~/.rvm/src/ree-1.8.7-2011.03/source/ext/readline$ ls
~/.rvm/src/ree-1.8.7-2011.03/source/ext/readline$ brew install readline
Warning: Formula already installed: readline
~/.rvm/src/ree-1.8.7-2011.03/source/ext/readline$ ruby extconf.rb --with-readline-dir=/usr/local/Cellar/readline/6.2.1/
checking for tgetnum() in -lncurses... yes
[...skiped...]
creating Makefile
~/.rvm/src/ree-1.8.7-2011.03/source/ext/readline$ make
cc -dynamic -bundle -undefined suppress -flat_namespace -o readline.bundle readline.o -L. -L/Users/brun/.rvm/rubies/ree-1.8.7-2011.03/lib -L/usr/local/Cellar/readline/6.2.1//lib -L. -lreadline -lncurses -L/opt/local/lib -ldl -lobjc
@evtuhovich
evtuhovich / .irbrc
Created March 22, 2011 11:33
My Irbrc file
require 'rubygems'
# Rails on-screen logging
def change_log(stream)
ActiveRecord::Base.logger = Logger.new(stream)
ActiveRecord::Base.clear_active_connections!
end
def show_log
@evtuhovich
evtuhovich / gist:733882
Created December 8, 2010 20:39
Логи для 1-ого варианта https://gist.github.com/733842
SQL (0.1ms) SET client_min_messages TO 'panic'
SQL (0.1ms) SET standard_conforming_strings = on
SQL (0.1ms) SET client_min_messages TO 'notice'
SQL (0.3ms) SELECT count(*) AS count_all FROM "messages"
SQL (0.1ms) BEGIN
SQL (0.3ms) INSERT INTO "messages" ("created_at", "author", "updated_at", "text") VALUES('2010-12-08 20:37:39.876065', 'test', '2010-12-08 20:37:39.876065', 'test') RETURNING "id"
SQL (0.2ms) INSERT INTO "messages" ("created_at", "author", "updated_at", "text") VALUES('2010-12-08 20:37:39.879843', 'test', '2010-12-08 20:37:39.879843', 'test') RETURNING "id"
SQL (22.8ms) COMMIT
SQL (0.2ms) SELECT count(*) AS count_all FROM "messages"
@evtuhovich
evtuhovich / gist:733876
Created December 8, 2010 20:36
Working rollback of nested transaction
require 'config/environment'
puts Message.count
Message.transaction do
Message.create! :author => 'test', :text => 'test'
Message.transaction(:requires_new => true) do
Message.create! :author => 'test', :text => 'test'
@evtuhovich
evtuhovich / gist:733842
Created December 8, 2010 20:19
Rails 2.3.x nested transaction rollback
# File 1.rb, use rails 2.3.10
require 'config/environment'
puts Message.count
Message.transaction do
Message.create! :author => 'test', :text => 'test'
Message.transaction do