Skip to content

Instantly share code, notes, and snippets.

View sjvrijn's full-sized avatar

Sander van Rijn sjvrijn

View GitHub Profile
@sjvrijn
sjvrijn / recreate.py
Created November 4, 2019 13:23
recreation of a drawing I saw somewhere
# coding: utf-8
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import Normalize
def recreate(n=8000, s=5, scale=1.45, ymax=.68):
norm = Normalize(vmin=0, vmax=1, clip=True)
origin = np.array([.5, 0])
@sjvrijn
sjvrijn / invert.sh
Created December 11, 2019 14:42
invert directory hierarchy: A/B/* -> B/A/*
#!/bin/bash
for a in */; do
for b in $a/*/; do
dir=${b##*//}
mkdir -p $dir$a
mv $a$dir* $dir$a
done
rm -rf $a
done
# source: https://twitter.com/Pen_Bird/status/1218965711780904960
# it supports map['foo'] = 42, AND http://map.foo = 42, because its __dict__ is itself
class Map(dict):
def __init__(self, **kwargs):
super(Map, self).__init__(**kwargs)
self.__dict__ = self
# Python dependencies
sudo apt install build-essential libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev tk-dev libffi-dev
# install curl if not already present
sudo apt instal curl
curl https://pyenv.run | bash
# add recommended lines to .bashrc and restart shell
echo '' >> ~/.bashrc
echo 'export PATH="/home/svrijn/.pyenv/bin:$PATH"' >> ~/.bashrc
git remote add SECOND [SECOND_URL]
git push SECOND master
git remote add BOTH [ORIG_URL]
git remote set-url --push BOTH [ORIG_URL]
git remote set-url --push --add BOTH [SECOND_URL]
git push BOTH
@sjvrijn
sjvrijn / .bash_aliases
Created January 22, 2021 14:12
Launch a jupyter lab instance on a remote machine while accessing locally with 'remotenotebook jupyter-remote':
# Add this function in your ~/.bash_aliases file, which takes the desired remote machine as argument:
remotenotebook() { ssh -4 -L 8891:localhost:8891 $1 -t "~/.ipynb"; }
@sjvrijn
sjvrijn / git_aliases.sh
Created June 13, 2022 08:37
git aliases
git config --global alias.unstage 'reset HEAD --'
git config --global alias.lg 'log --oneline --graph --all'
@sjvrijn
sjvrijn / .zshrc
Last active May 20, 2024 23:03
pyenv display oh-my-zsh
# User configuration
export PATH="$HOME/.pyenv/bin/:$HOME/.pyenv/shims/:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
export PYENV_VIRTUALENV_DISABLE_PROMPT=1
# Theme customisation
prompt_virtualenv() { # show pyenv version-name if not using 'system'
local version="$(pyenv version-name)"
if [[ $version != "system" ]]; then