Skip to content

Instantly share code, notes, and snippets.

View xpl's full-sized avatar

Vitalik Gordon xpl

View GitHub Profile
@xpl
xpl / watch.sh
Last active October 22, 2021 17:39
Restart a binary upon change (bash script)
#!/bin/bash
# ---------------------------------------
# EXAMPLE USE:
#
# ./watch.sh target/debug/my-server-app
# ---------------------------------------
kill_prev_pid () {
echo Killing prev pid $(cat .pid)
@xpl
xpl / encrypt.md
Last active April 24, 2022 17:23
How to Encrypt/Decrypt A String

Encrypt

echo 'unencrypted' | openssl aes-256-cbc -a -salt -pbkdf2

Decrypt

echo 'encrypted' | openssl aes-256-cbc -d -a -pbkdf2
@xpl
xpl / how-to-squash.md
Last active February 5, 2021 15:57
Squash My Commits (In A Feature Branch)

Squash My Commits (In A Feature Branch)

Here's a script for squashing up to the first commit coming after a merge commit (with confirmation). Useful for working in a branch and then squashing temporary commits before merging into trunk.

Save the script as squash. Upon executing, it brings your git editor (vim/nano/whatever) to confirm the prepped rebase todo — so you would only need to simply save-and-exit (in most cases).

#!/usr/bin/env python3
# flake8: noqa
@xpl
xpl / stacky-lang-v3.js
Last active April 23, 2021 16:08
Stacky Language (For Educational Purposes) V.3 – With Stack Machine Back-End
// -----------------------------------------------------------------
'use strict'
// -----------------------------------------------------------------
function replicate (times, n) {
let arr = []
if (times <= 0) { return arr }
arr.push (n)
0xF4B9d98828dF938ccf16b644Be471cF23816AB9F
@xpl
xpl / mip.md
Last active December 18, 2019 09:16
Mixed Integer Programming Example In Python

Mixed Integer Programming Example (Python)

import pandas as pd
import numpy  as np

from scipy.spatial import distance
from mip.model     import *

factories = pd.DataFrame ([
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
### Keybase proof
I hereby claim:
* I am xpl on github.
* I am xpl (https://keybase.io/xpl) on keybase.
* I have a public key ASCbmgidGUS8v1jHmPMQmSQEqPMHxAmeQERrU2XSi1jyOAo
To claim this, I am signing this object: