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 / mint.ts
Created April 8, 2024 04:43
Mint Solana SPL token + Metadata
import {
percentAmount,
generateSigner,
signerIdentity,
createSignerFromKeypair,
} from '@metaplex-foundation/umi';
import { mplToolbox, setComputeUnitPrice } from '@metaplex-foundation/mpl-toolbox';
import {
TokenStandard,
createAndMint,
@Restuta
Restuta / the-bind-problem.jsx
Last active March 16, 2024 00:22
React, removeEventListener and bind(this) gotcha
/* 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));
@Restuta
Restuta / framework-sizes.md
Last active March 7, 2024 00:01
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 https://cdnjs.com 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
Restuta / README.md
Created January 21, 2020 23:49
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 https://api.heroku.com/regions/us "Accept:application/vnd.heroku+json; version=3"
@Restuta
Restuta / observables.ts
Last active December 28, 2022 19:43
run promises sequentially or not using observables
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))

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 / HOC.js
Last active February 27, 2022 06:56
React HOC (Higher Order Component) Example
/* 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
Restuta / map-reduce-pipe.js
Created October 8, 2021 19:55
map/reduce/pipe in 3m
// 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
/**
* author: tourist
* created: 08.08.2020 17:11:40
**/
#include <bits/stdc++.h>
using namespace std;
template <typename T>
class graph {
@Restuta
Restuta / howto-put-git-repo-into-another-repo.md
Last active April 22, 2021 16:43
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:

|-SRC
   |---proto

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: