Skip to content

Instantly share code, notes, and snippets.

Hacking fast and slow.

Anton Vynogradenko Restuta

Hacking fast and slow.
View GitHub Profile
Restuta /
Last active Sep 4, 2021
Sizes of JS frameworks, just minified + minified and gzipped, (React, Angular 2, Vue, Ember)

Below is the list of modern JS frameworks and almost frameworks – React, Vue, Angular, Ember and others.

All files were downloaded from and named accordingly. Output from ls command is stripped out (irrelevant stuff)

As-is (minified)

$ ls -lhS
566K Jan  4 22:03 angular2.min.js
Restuta / the-bind-problem.jsx
Last active Jun 24, 2021
React, removeEventListener and bind(this) gotcha
View the-bind-problem.jsx
/* Sometimes it's pretty easy to run ito troubles with React ES6 components.
Consider the following code: */
class EventStub extends Component {
componentDidMount() {
window.addEventListener('resize', this.onResize.bind(this)); //notice .bind
componentWillUnmount() {
window.removeEventListener('resize', this.onResize.bind(this));
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 /
Last active Apr 22, 2021
How to make git repo to be another's repo subfolder preserving history

Hacky way (let me know if you know better one)

Let's say you have repo Main and repo Proto, you want to put your Proto under Main, so folder structure will be the following:


and you also want to preserve commit history, so everybody can see what you were doing while developing proto, sounds like pretty easy task. The easiest way is to create folder structure similar to Main repo SRC\proto and start working using is as a root, but if you like me, you didn't think about this beforehand, so you path would be harder:

Restuta / HOC.js
Last active Apr 5, 2021
React HOC (Higher Order Component) Example
View HOC.js
/* HOC fundamentally is just a function that accepts a Component and returns a Component:
(component) => {return componentOnSteroids; } or just component => componentOnSteroids;
Let's assume we want to wrap our components in another component that is used for debugging purposes,
it just wraps them in a DIV with "debug class on it".
Below ComponentToDebug is a React component.
//HOC using Class
//it's a function that accepts ComponentToDebug and implicitly returns a Class
let DebugComponent = ComponentToDebug => class extends Component {
Restuta /
Created Jan 21, 2020
How to get IP Ranges for Heroku

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 "Accept:application/vnd.heroku+json; version=3"
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 :
const arrDeviation = deviation(input)
return => ({
zscore: (i - arrMean) / arrDeviation,
item: i,
Restuta /
Last active Sep 25, 2020
GitHub Badges test via Shields

Base PRs


Stacked on top of this PR



Restuta /
Last active Sep 24, 2020
null or undefined

null in javascript is an object, which has few important, arguably confusing implications. Unfortunately JS has two ways to declare that something is "nothing", and the default way to do so is undefined.

Having two ways to declare that something is "nothing" might be confusing and could be unnecessary. I can't come up with a use-case where I'd need two (and Douglas C. thinks the same), therefore we should pick one or another.

Below is why I think we should pick undefined and not null:

ES5 world

We have plenty of code like this:

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
}), => {