Skip to content

Instantly share code, notes, and snippets.

Alex Kocharin rlidwka

Block or report user

Report or block rlidwka

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
rlidwka / stuff.js
Last active Apr 5, 2018
finding the closest frakking number
View stuff.js
function get_digit(n, d) {
return Math.floor(n / Math.pow(10, d)) % 10
function is_unique(n, d) {
let m = 0
let c = Math.pow(10, d)
for (let i = d; n > c; i++, c *= 10) {
let new_m = m ^ (2 << get_digit(n, i) + 1)
View gist:7340d08c8638cce715d8
TypeError: Cannot read property 'id' of undefined
    at queryCallback (/root/nodeca/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/wireprotocol/3_2_support.js:181:48)
    at Callbacks.emit (/root/nodeca/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:95:3)
    at null.messageHandler (/root/nodeca/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:243:23)
    at Socket.<anonymous> (/root/nodeca/node_modules/mongoose/node_modules/mongodb/node_modules/mongodb-core/lib/connection/connection.js:262:22)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:146:16)
    at Socket.Readable.push (_stream_readable.js:110:10)
View gist:cd645384a218e33a645c

системный софт:

sudo apt-get install build-essential software-properties-common


sudo apt-key adv --keyserver hkp:// --recv 7F0CEB10
View .md

Текущий алгоритм

Если нашли открывающий '*' на позиции start:

  1. Ищем закрывающий маркер, для этого:
    • считаем все '*'
    • если нашли открывающий '*', увеличиваем счётчик на 1
    • если нашли закрывающий '*', уменьшаем счётчик на 1
    • если нашли закрывающий '*', и счётчик равен 0, найден конец pos
  2. Добавляем тег <em>
View gist:da02c78b35dcb6904119
- email_transport - используется при отправке почты
- email_header_from - используется при отправке почты
- general_project_name - используется при отправке почты
- general_cookies_domain - используется в каком-то хуке
- general_session_expire_hours - используется в каком-то хуке
- markup_* - не используется
rlidwka / gist:8b904ca00b1e76731270
Last active Sep 30, 2016
Looking for a static analysis tool
View gist:8b904ca00b1e76731270


I'm testing five linters (jshint, jslint, eslint, gjslint, javascriptlint) - that's all that I could find - for two common and easily detectable errors.

But they don't find any, so I'm asking the community to suggest one that can.

Here is a piece of code. You know that pattern that makes a constructor callable without "new"?

View gist:892d08876d737e265a86
#!/usr/bin/env node
var Mincer = require('mincer');
var env = new Mincer.Environment();
env.appendPath('/home'); // or whereever you have a big bunch of files
var manifest = new Mincer.Manifest(env, '.');
var date =;
View gist:7781505
function get_global() {
if (typeof(window) === 'undefined' && typeof(window) === 'object' && window != null && window.window === window)
return window
if (typeof(global) === 'undefined' && typeof(global) === 'object' && global != null && === global)
return global
View gist:7499686
var eve = require('EVE')
var type = eve.type
schema = type.object({
number: type.number().min(5),
something: type.string().trim().notEmpty().required()
View gist:7381915
var crypto = require('crypto')
function generateSalt(length) {
var i, r = [];
for (i = 0; i < length; ++i) {
r.push(SALTCHARS[Math.floor(Math.random() * SALTCHARS.length)]);
return r.join('');
You can’t perform that action at this time.