Skip to content

Instantly share code, notes, and snippets.

Avatar

Ivan Evtuhovich evtuhovich

View GitHub Profile
View zabbix
<?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 Oct 17, 2013
Платный интернет на Кипре
View gist:7022395
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 Dec 15, 2015
script to edit encrypted data bags secret key should be at .chef/encrypted_data_bag_secret
View edit_data_bag.rb
#!/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 Dec 18, 2012
Код к докладу "Нетрадиционное использование Ruby и PostgreSQL" http://www.slideshare.net/evtuhovich/ruby-postgresql
View rmongo.rb
require 'rubygems'
require 'pg'
require 'yaml'
class DB
def initialize(debug = true)
@conn = PG::Connection.open()
@debug = debug
end
@evtuhovich
evtuhovich / gist:1134998
Created Aug 9, 2011
Список вопросов для собеседования
View gist:1134998
Ruby
принципиальное различие скриптовых и “обычных” языков
3 принципа ООП
реализация множественного наследования в ruby
duck typing
многопоточность в ruby
Rails
что такое MVC и зачем это нужно
локига в контроллере, должна ли быть и почему
синхронные и асинхронные операции — предложить варианты решения
@evtuhovich
evtuhovich / gist:988261
Created May 24, 2011
Enabling russian in IRB
View gist:988261
$ 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 Mar 22, 2011
My Irbrc file
View .irbrc
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 Dec 8, 2010
Логи для 1-ого варианта https://gist.github.com/733842
View gist:733882
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 Dec 8, 2010
Working rollback of nested transaction
View gist:733876
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 Dec 8, 2010
Rails 2.3.x nested transaction rollback
View gist:733842
# 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
You can’t perform that action at this time.