Skip to content

Instantly share code, notes, and snippets.

View galchenkov's full-sized avatar
💻
Working hard

Aleksandr Galchenkov galchenkov

💻
Working hard
View GitHub Profile
# Округление (результат 18)
0 | 18.93
# Генерация произвольной цифро-символьной строки
Math.random().toString(36).substr 2, 4
# Так в вундерлисте генерится ключ
"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace /[xy]/g, (e) ->
t = 0 | 16 * Math.random()
n = "x" == e ? t : 8 | 3 & t
- (NSString *)terminationForValue:(int)value withWords:(NSArray *)words {
if (words.count != 3) {
return nil;
}
int dd = (int)floor(value) % 100;
int d = (int)floor(value) % 10;
if(d == 0 || d > 4 || dd == 11 || dd == 12 || dd == 13 || dd == 14) return words[0];
if(d != 1 && d < 5) return words[1];
if(d == 1) return words[2];
@galchenkov
galchenkov / gist:6387213
Created August 30, 2013 07:36
Input placeholders
::-webkit-input-placeholder { /* WebKit browsers */
color: #999;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
color: #999;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
color: #999;
}
:-ms-input-placeholder { /* Internet Explorer 10+ */
@galchenkov
galchenkov / Vim commands
Created September 5, 2013 06:55
Vim commands
set tabstop=4
set shiftwidth=4
set expandtab
set listchars=tab:→\ ,trail:·,nbsp:·
@galchenkov
galchenkov / Keyboard codes
Last active August 29, 2015 14:09
Keyboard codes
var keyCode = {
ALT: 18,
BACKSPACE: 8,
CAPS_LOCK: 20,
COMMA: 188,
COMMAND: 91,
COMMAND_LEFT: 91, // COMMAND
COMMAND_RIGHT: 93,
CONTROL: 17,
DELETE: 46,
function morphology(number, n0, n1, n2) {
number = number % 100;
if (number > 19) {
number = number % 10;
}
if (number >= 2 && number <= 4) return n2;
if (number == 1) return n1;
return n0;
}
Перевод организационно-правовых форм юридических лиц
http://www.alba-translating.ru/index.php/ru/articles/glossary/legalentity.html
ОАО (Открытое акционерное общество)
OJSC (Open Joint-Stock Company)
АО (Акционерное общество)
JSC (Joint-Stock Company)
ООО (Общество с ограниченной ответственностью)

How to install PhantomJS on Ubuntu

Version: 1.9.7

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get update
sudo apt-get install libfreetype6 libfreetype6-dev libfontconfig
# /etc/apt/sources.list should contain these:
# deb http://us.archive.ubuntu.com/ubuntu/ lucid multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ lucid multiverse
# deb http://us.archive.ubuntu.com/ubuntu/ lucid-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ lucid-updates multiverse
sudo echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections
@galchenkov
galchenkov / image base64 encode
Created February 9, 2015 10:45
Get base64 encoded image
request.get imageUrl, (error, response, body) ->
if not error and response.statusCode == 200
data = "data:" + response.headers["content-type"] + ";base64," + new Buffer(body).toString('base64')