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
def distributed_number(num) | |
k = 9 # number of distributed groups | |
start = 216000 | |
stop = 1521368 | |
total = stop - start | |
((total / k) * (num % k) + num / k) + start - start / k | |
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
def mark_html_links!(html) | |
link_regexp = %r{(<a.*?href=["']?[^"']*["']?)(.*?)(>.*?<\/a>)} | |
html.gsub!(link_regexp, '\1 data-test="true"\2\3') | |
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
" load up pathogen and all bundles | |
call pathogen#infect() | |
call pathogen#helptags() | |
syntax on " show syntax highlighting | |
filetype plugin indent on | |
set autoindent " set auto indent | |
"set smartindent | |
set nu |
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
def replace_name(body, name) | |
body | |
.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '') | |
.gsub(/joel/, name) | |
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
# psql -h localhost postgres | |
postgres=# create database mydb_test with lc_collate='C'; | |
ERROR: new collation (C) is incompatible with the collation of the template database (ru_RU.UTF-8) | |
HINT: Use the same collation as in the template database, or use template0 as template. | |
postgres=# UPDATE pg_database SET datallowconn = TRUE WHERE datname = 'template0'; | |
postgres=# create database mydb_test with lc_collate = 'C' template = template0; |