Skip to content

Instantly share code, notes, and snippets.

View stepankuzmin's full-sized avatar
⛏️

Stepan Kuzmin stepankuzmin

⛏️
View GitHub Profile
@stepankuzmin
stepankuzmin / fixup.sh
Last active April 27, 2021 09:49
Git alias for squashing last N commits into it's parents
git config --global alias.fixup "\!f(){ git reset --soft HEAD~${1} && git commit --amend -C HEAD; };f"
git fixup 1 # squashes last commit into it's parent
@stepankuzmin
stepankuzmin / parse-mbox.js
Created December 25, 2020 12:30
Parse Mbox
const fs = require("fs");
const Mbox = require("node-mbox");
const { simpleParser } = require("mailparser");
const mbox = new Mbox("./some.mbox/mbox");
const stream = fs.createWriteStream("./emails.json");
stream.write("[");
mbox.on("message", function (msg) {
brew cask install oracle-jdk
export JAVA_HOME=$(/usr/libexec/java_home)

Keybase proof

I hereby claim:

  • I am stepankuzmin on github.
  • I am stepankuzmin (https://keybase.io/stepankuzmin) on keybase.
  • I have a public key ASCWLpkncB3DnGAurt2ByOWZzp4u9bSulAlEeF3A_wBELQo

To claim this, I am signing this object:

@stepankuzmin
stepankuzmin / DiscriminatedUnionOfReturnTypes.d.ts
Last active April 29, 2020 15:48
TypeScript Discriminated Union of ReturnTypes
/* eslint-disable @typescript-eslint/no-explicit-any */
type DiscriminatedUnionOfReturnTypes<T> =
T[keyof T] extends (...args: any[]) => any ? ReturnType<T[keyof T]> : never;
type Immutable<T> = {
readonly [K in keyof T]: Immutable<T[K]>;
};
onMoveEnd = (event) => {
const map = this._mapRef.current.getMap();
map.off('moveend', this.onMoveEnd);
const zoom = map.getZoom();
const { lat, lng } = map.getCenter();
const viewport = { longitude: lng, latitude: lat, zoom };
this.props.onViewportChange(viewport);
};
@stepankuzmin
stepankuzmin / GPG and git on macOS.md
Created October 11, 2019 12:14 — forked from danieleggert/GPG and git on macOS.md
How to set up git to use the GPG Suite

GPG and git on macOS

Setup

No need for homebrew or anything like that. Works with https://www.git-tower.com and the command line.

  1. Install https://gpgtools.org -- I'd suggest to do a customized install and deselect GPGMail.
  2. Create or import a key -- see below for https://keybase.io
  3. Run gpg --list-secret-keys and look for sec, use the key ID for the next step
  4. Configure git to use GPG -- replace the key with the one from gpg --list-secret-keys
@stepankuzmin
stepankuzmin / expand.js
Last active November 10, 2019 13:59
Expand PostgreSQL hstore columns into plain columns with NodeJS
const { Pool, Client } = require('pg');
const groupBy = require('lodash.groupby');
const pool = new Pool({
host: 'localhost',
database: 'db'
});
const oldPoolQuery = pool.query;
pool.query = (...args) => {
@stepankuzmin
stepankuzmin / README.md
Created September 26, 2019 08:09
Selectel + Let’s Encrypt Certbot

Selectel + Let’s Encrypt Certbot

Manual issue certificate:

sudo certbot certonly \
	--agree-tos \
	--email email@domain.tld \
	--manual \
	-d domain.tld