Skip to content

Instantly share code, notes, and snippets.

Avatar
🦄
Hacking fast and slow.

Anton Vynogradenko Restuta

🦄
Hacking fast and slow.
View GitHub Profile
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 Oct 8, 2021
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 Nov 22, 2020
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 Sep 25, 2020
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 Aug 13, 2020
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 Mar 12, 2020
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 Jan 21, 2020
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"
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;
@Restuta
Restuta / ora-progress-bar.js
Last active Nov 8, 2019
Ora based progress bar
View ora-progress-bar.js
/* eslint-disable no-return-assign */
const chalk = require('chalk');
const ora = require('ora');
const prettyMs = require('pretty-ms');
const throttle = require('lodash/throttle');
const getHeapUsed = throttle(
() => {
const heapUsed = process.memoryUsage().heapUsed / 1024 / 1024;
return Math.round(heapUsed, 2);