Skip to content

Instantly share code, notes, and snippets.

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

Yuriy Kharchenko letmein

🏠
Working from home
  • Armenia, Yerevan
  • 14:22 (UTC +04:00)
View GitHub Profile
@letmein
letmein / id_rsa.pub
Created February 28, 2012 15:47
public key (hp)
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJsyeuMBzdVZzm83ni90Q16biMQD/xS4gJtkt89elbIERKerWZdPD1H0T+xM5IjM//0Hjelk8jagn8exEt3KaR8+KszwMPO6R0lEwSl6MsiKWwrVsUpO/wRT9x/xCTYz+QWsRP69s8N9HOpljfmJmCwfoJt32TuVt/rhevJrGvrDQgsQVSlU7ZUOrUCAWpxLiEEwMPUDkrWjl1f3HM3f6vUnYNUpxgEnLEcayfGK0zxT8sYNRmcKRmDHw4hb43gX/hRD3M20LkCN48fRUE2Lc0rQDE3oZfANuozENMaFfKqU4zGESMAT1PLi3LKshBv2S7Pj4DT6Vnh0WEOkG3eD4f yura@Yura-HP-Pavilion-DV7
@letmein
letmein / active_record_initializer.rb
Created March 2, 2012 16:41
Make Rails 3.0.11 support PostgreSQL temporary tables
class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
def table_exists?(name)
name = name.to_s
schema, table = name.split('.', 2)
unless table
table = schema
schema = nil
end
@letmein
letmein / id_rsa.pub
Created March 27, 2012 07:00
public key (asus)
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAyTKOQBxGZjvxAaJWrIBI/ljyxfPmcxQdpDgPXShPdyG49W08i/OJf6Fs+feKJIFjMe0/Z4i/iACU1Lgu5E4iBOXBUXYEyeCv4t6eKQMN9vj/2AFRJQ6nBsVengZWd1ORoB/fyZW0CmR0sLmHO9l98Rmu81OE+FYzlsjkL2Vc8i8SskR+U1tJT27xR1C5L0uxhTgX1Dh3t+O7pQ9NWHKBwAg2Fy2/N/X8sieXohoke+CfeJnd+rqNtbqTT7VUspQxdVFj3RYYVpV3XnEGtQvsxciUENacDPxXmvR5p7LYKzCzhoW6Jr9I3sst8maTBFVxFvYe7x57dp83aQs+1nIDPw== yura@dev
@letmein
letmein / database.rb
Created September 18, 2012 11:53
Read database config from database.yml in a padrino app
# On Heroku we'll read the config from ENV
if postgres = URI.parse(ENV['DATABASE_URL'] || '')
ActiveRecord::Base.configurations[:production] = {
:adapter => 'postgresql',
:encoding => 'utf8',
:database => postgres.path[1..-1],
:username => postgres.user,
:password => postgres.password,
:host => postgres.host
}
@letmein
letmein / database_tasks.rb
Created October 26, 2012 18:40
Port db:structure:load and db:structure:dump rake tasks from Rails 3.2 to Padrino
module ActiveRecord
module Tasks # :nodoc:
module DatabaseTasks # :nodoc:
extend self
attr_writer :current_config
LOCAL_HOSTS = ['127.0.0.1', 'localhost']
def register_task(pattern, task)
@letmein
letmein / .vimrc
Created September 5, 2013 13:24
virmrc
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
"if has("gui_running")
" GUI is running or is about to start.
" Maximize gvim window.
@letmein
letmein / pg-ram-off.sh
Created September 17, 2013 13:20
Postgresql ramdisk script
#!/bin/bash
/etc/init.d/postgresql stop
TMPDIR=/tmp/tmpfs; # the actual mount point for the tmpfs
MOUNTPOINT=/var/lib/postgresql/
umount $MOUNTPOINT
umount $TMPDIR
@letmein
letmein / json_schema_matcher.rb
Last active December 28, 2015 00:19
RSpec matcher for json-schema
RSpec::Matchers.define :match_schema do |schema_name|
match do |json|
schema = Rails.root.join("/path/to/your/schemas/#{schema_name}.json")
@errors = JSON::Validator.fully_validate(schema, json)
@errors.none?
end
failure_message_for_should do
@errors.first
@letmein
letmein / dump.sh
Last active January 4, 2016 08:39
Debugging cross-test dependencies
rspec --require ./lib/rspec_debug_formatter.rb --format RSpecDebugFormatter --seed 8812 --fail-fast spec/
@letmein
letmein / pre-commit
Last active August 29, 2015 13:56
pre-commit hook
#!/bin/sh
# put this to .git/hooks/pre-commit
function check_commit_stopper {
COMMIT_STOPPER=$1
if [ `git diff HEAD | grep $COMMIT_STOPPER | wc -l` -gt 0 ]; then
echo "$COMMIT_STOPPER detected, aborting commit."
echo ""
git grep -n --heading --break $COMMIT_STOPPER -- `git diff HEAD --name-only`
exit 1