Skip to content

Instantly share code, notes, and snippets.

View killreal17's full-sized avatar
🎯
Focusing

Sokolov Kirill killreal17

🎯
Focusing
  • Яндекс.Маркет
  • Moscow
View GitHub Profile
const rejectOnTime = (func, time) => Promise
.race([
func,
new Promise((res, rej) => {
setTimeout(() => rej('Не успел'), time)
})
])
const foo = (time) => new Promise ((res, rej) => {
setTimeout(() => res('Успел'), time)
class Query {
body: string;
constructor () {
this.body = '<type>'
};
pipe (...args) {
this.body = args.reduce((acc, arg) => {
return acc.replace(arg.tag, arg.body)
}, this.body);
return this;
@killreal17
killreal17 / main.py
Last active May 18, 2020 17:50
Поиск путей в направленном нецикличном графе
'''
example of graph in input.json
{
"start": "1",
"end": "12",
"nodes": {
"1": ["2", "3"],
"2": ["4", "7"],
"3": ["5", "11"],
@killreal17
killreal17 / main.py
Created February 25, 2020 17:55
Поиск подстроки в строке
def entry (str, substr):
if len(str) < len(substr):
return False
else:
if str[:len(substr)] != substr:
return entry(str[1:], substr)
else:
return True
@killreal17
killreal17 / main.py
Created August 1, 2019 13:00
smart calc
### special for iVan
def reformat(line):
expression = []
element = '&'
line.replace(' ', '')
for item in line:
if item in '0123456789':
if element == '&':
element = int(item)
@killreal17
killreal17 / gist:4258fb137d565c0567a8e6b8efcc0185
Created April 2, 2019 19:11
Exercises by Petr Kalinin for JS
/*
Задача №3152. Четные индексы
let mas = [1, 2, 3, 4, 5, 6];
for (item in mas) { // итерация по ключу
if (item % 2 == 0) {console.log(mas[item])}
}*/
/*
Задача №3153. Четные элементы
let mas = [1, 2, 2, 3, 4, 5, 3, 2];
@killreal17
killreal17 / main.js
Last active February 27, 2019 14:25
fifteen version 2
'use strict'
const readline = require('readline')
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
function get_random_arbitrary(min, max) {