Skip to content

Instantly share code, notes, and snippets.

View a-x-'s full-sized avatar
🛩️

Alexander a-x-

🛩️
View GitHub Profile
{
"root": true,
"levels": {
"common.blocks": {
scheme: "nested",
default: true
},
"desktop.blocks": {
scheme: "nested"
},
@a-x-
a-x- / common-discontinuous-subseqs-count.txt
Created October 18, 2016 13:46
input data sample for yandex shad
2000
800000508
800000281
800001032
800000783
800000010
800000783
800000431
800001185
800000724
@a-x-
a-x- / express.js.init.sh
Last active May 10, 2017 08:56
obsolete express app boilerplate
#!/bin/sh
# RUN latest version:
# wget https://github.yandex-team.ru/gist/invntrm/8e42ab1cd74966541a65/raw/express.js.init.sh && chmod a+x express.js.init.sh && ./express.js.init.sh && rm express.js.init.sh
# **NOT** USE: wget -qO- https://github.yandex-team.ru/gist/invntrm/8e42ab1cd74966541a65/raw/express.js.init.sh | sh
git init
#
# install some npm modules
@a-x-
a-x- / pythonscript.py
Created January 4, 2017 15:18 — forked from idreamsi/pythonscript.py
Python script for Telegram
# -*- coding: utf-8 -*-
#!/usr/bin/python
import subprocess
import os
import picamera
import time
import shlex
from datetime import datetime
from datetime import timedelta
import datetime as dt
const isBalanced = (() => {
const map = {'(':')', '[':']', '{':'}'}
const getPair = char => map[char]
const isOpen = char => ['(','[','{'].includes(char)
return s => {
const stack = []
return Array.from(s).reduce((res, char) => res && (isOpen(char) ? (stack.push(char), true) : (char === getPair(stack.pop()))), true)
&& !stack.length
}
})()
const fuzzycheck = (candidate, origin) =>
!Array.from(origin).reduce((candRest, origChar) => origChar === candRest[0] ? candRest.slice(1) : candRest, candidate)
.length
console.log(fuzzycheck('rw2', 'rogers watson 2'))
const diff = (() => {
let tmp = ''
let cnt = 0
const reduce = (s2, c1, i) => {
c1 !== (tmp = s2.shift()) && (++cnt, console.warn(c1, '<>', tmp, 'at', i))
return s2
}
return (s1, s2) => {
cnt = 0
@a-x-
a-x- / rle.js
Last active March 21, 2017 19:31
const rle = (() => {
let cnt = 1, tmp
const printCnt = cnt => cnt !== 1 ? cnt : ''
const reduce = (res, next) =>
next === res[res.length - 1] ? (++cnt, res) : (tmp = cnt, cnt = 1, res + printCnt(tmp) + next)
return s => Array.from(s).reduce(reduce, '') + printCnt(cnt)
})()
rle('AAAABBBCCXYZDDDDEEEFFFAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBB') === 'A4B3C2XYZD4E3F3A6B28'
@a-x-
a-x- / rpn.js
Created March 30, 2017 07:57
Reverse Polish Notation Calc
const ops = ['+', '-', '*', '/'];
function calc(expr) {
const stack = expr.split(/\s+/)
.reduce((stack, char) => {
if (ops.includes(char)) { // is operator
if (stack.length < 2) throw new Error('There are not enough operands in the stack: ' + stack);
const b = stack.pop(), a = stack.pop();
let res;
const subExpr = `(${a}) ${char} (${b})`;
try { res = eval(subExpr); } catch (e) {
<svg id="svg" width="270" height="270" xmlns="http://www.w3.org/2000/svg" stroke-width="5" stroke="#61B000">
<linearGradient id="mainGradient" gradientUnits="userSpaceOnUse" x1="0%" y1="100%" x2="0%" y2="0%"><stop class="stop-right" offset="0" stop-opacity="0" stop-color="green"></stop><stop class="stop-left" offset="1" stop-color="green" stop-opacity=".6"></stop></linearGradient>
<path id="p1" fill="none" stroke="none"></path>
<path stroke="green" id="p2" fill="none" stroke-width="2"></path>
</svg>
<script>
var vals = [84307, 80323, 86134, 70500];
function plot (svg, vals) {