Skip to content

Instantly share code, notes, and snippets.

View Restuta's full-sized avatar
🦄
Hacking fast and slow.

Anton Vynogradenko Restuta

🦄
Hacking fast and slow.
View GitHub Profile
@Restuta
Restuta / observables.ts
Last active December 28, 2022 19:43
run promises sequentially or not using observables
View observables.ts
import * as O from 'rxjs';
const delay = ms => new Promise((resolve) => setTimeout(() => resolve(ms), ms));
O.from([1,2,3])
.pipe(
O.map(x => O.defer(() => delay(1000))),
O.mergeAll(1)
).subscribe(x => console.log(x))
View keybase.md

Keybase proof

I hereby claim:

  • I am restuta on github.
  • I am restuta (https://keybase.io/restuta) on keybase.
  • I have a public key ASDPbUkAXpS7m7MrLZeRf83VBDVZqJaQe6ycN-pfoiJSCQo

To claim this, I am signing this object:

@Restuta
Restuta / map-reduce-pipe.js
Created October 8, 2021 19:55
map/reduce/pipe in 3m
View map-reduce-pipe.js
// map, reduce, pipe in 3 minutes
const reduce = (reducer, defaultAcc, list) => {
let acc = defaultAcc
for(let item of list) {
acc = reducer(acc, item)
}
return acc
View tourist-code.cpp
/**
* author: tourist
* created: 08.08.2020 17:11:40
**/
#include <bits/stdc++.h>
using namespace std;
template <typename T>
class graph {
@Restuta
Restuta / modified-z-score.js
Last active November 22, 2020 02:06
Outliers: z-score and modified z-score method in JavaScript
View modified-z-score.js
// z-score
const { mean, deviation } = require('d3-array')
const zscore = input => {
const arrMean = mean(input)
// here the n-1 : http://duramecho.com/Misc/WhyMinusOneInSd.html
const arrDeviation = deviation(input)
return input.map(i => ({
zscore: (i - arrMean) / arrDeviation,
item: i,
@Restuta
Restuta / readme.md
Last active September 25, 2020 19:46
GitHub Badges test via Shields
View readme.md

Base PRs

#20

Stacked on top of this PR

#23

#24

@Restuta
Restuta / tranducers-experiments.js
Created August 13, 2020 06:32
Tranducers and mergeWith experiments
View tranducers-experiments.js
const R = require('ramda')
const numbers = [1, 2, 8, 9]
const transducer = R.compose(
R.filter(x => {
console.log('filter', x)
return x > 3
}),
R.map(x => {
@Restuta
Restuta / neat-stack.js
Last active March 12, 2020 19:46
neat-stack.js
View neat-stack.js
import cleanStack from 'clean-stack';
// dims non-useful log lines in stack traces
const neatStack = (colorize, stack) => {
// add parts of stack trace lines here that should be ignored
const regexParts = [
'(node_modules)',
'(WEBPACK_IMPORTED)',
'(next_tick.js)',
'(domain.js)',
@Restuta
Restuta / README.md
Created January 21, 2020 23:49
How to get IP Ranges for Heroku
View README.md

Ip Ranges

Sometimes it's useful to know what IP ranges our servers are operating in. Since we run on Heroku, it's a little complicated. However, Heroku runs on AWS, which has this page dedicated to IP Ranges by Region.

Heroku recommends using this to identify which region are bing in use. If dynos are run in common spaces in US region, we can look up information about this region using Heroku's API:

using httpie:

 http https://api.heroku.com/regions/us "Accept:application/vnd.heroku+json; version=3"
@Restuta
Restuta / logger.js
Created November 5, 2019 22:57
Logger
View logger.js
const util = require('util');
const R = require('ramda');
const chalk = require('chalk');
const jsondiffpatch = require('jsondiffpatch');
const toJson = require('./to-json');
let prefix;
let coloredOutput = false;