Skip to content

Instantly share code, notes, and snippets.

Avatar

Stefaan Lippens soxofaan

View GitHub Profile
@soxofaan
soxofaan / here-jupyter.sh
Last active Aug 27, 2019
here-jupyter: launch Jupyter Notebook in background from current directory using tmux
View here-jupyter.sh
#!/bin/bash
# Build tmux session name from current directory
SESSION_NAME=$(pwd)
# Strip non-alphanumeric characters
SESSION_NAME=${SESSION_NAME//[^a-zA-Z0-9]/}
# Only keep trailing part
SESSION_NAME=Jupyter-${SESSION_NAME: -20}
# Command to run inside tmux session
@soxofaan
soxofaan / .block
Last active Aug 20, 2019
Microphone pitch detection
View .block
license: mit
height: 400
border: no
@soxofaan
soxofaan / .block
Last active Aug 15, 2019
Microphone Spectrum Analyser
View .block
license: mit
height: 500
border: no
@soxofaan
soxofaan / signal_catcher_context.py
Last active Apr 13, 2019
Python (3.6+) context manager that catches signals (e.g. SIGINT, SIGTERM) and exposes that. Allows writing infinite loops that can be exited in a clean way.
View signal_catcher_context.py
import logging
import os
import signal
import time
log = logging.getLogger(__name__)
class SignalCatcher:
@soxofaan
soxofaan / .block
Last active Dec 29, 2018
Circle of Fifths with Diatonic Seventh Chords
View .block
license: mit
height: 800
border: no
@soxofaan
soxofaan / pandas-timeindex-secondary-y-issue.ipynb
Last active Dec 13, 2017
pandas-timeindex-secondary-y-issue.ipynb
View pandas-timeindex-secondary-y-issue.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@soxofaan
soxofaan / zequals.py
Last active Nov 28, 2017
"Zequals" ruthless rounding: just keep one leading digit.
View zequals.py
import math
def zequals(x):
"""
"Zequals" ruthless rounding: just keep one leading digit.
examples:
123 -> 100
4567 -> 5000
-0.0345 -> -0.03
View README.md

Google Apps Script to automatically delete mails with a certain label after a certain time

Usage

  1. Think of a deletion scheme and create GMail labels accordingly (e.g. I use labels 'todelete/after1week', 'todelete/after1month' and 'todelete/after3months' here)
  2. set up filters in GMail to flag desired mails with these labels
  3. create a Google Apps Script with this script (adapt function names, labels and day offsets appropriatedly) and set up triggers as desired

Disclaimer

@soxofaan
soxofaan / .block
Last active Aug 15, 2017
Four-dimensional hypersphere packing
View .block
license: mit
border: no
@soxofaan
soxofaan / screen-ssh-agent-fix.sh
Created Jan 16, 2017
Script to fix SSH agent environment variables on a remote server after reconnecting to a screen session
View screen-ssh-agent-fix.sh
#!/bin/bash
# Script to fix the SSH agent environment variable after reconnecting to a running screen session.
# Usage: *source* this script (don't just execute).
# For example, if you store it at ~/screen-ssh-agent-fix.sh, create this alias to have it available easily:
# alias screenfix='source ~/screen-ssh-agent-fix.sh'
echo "Updating ssh-agent socket environment.."
echo "Current value: $SSH_AUTH_SOCK"
export SSH_AUTH_SOCK=$(find /tmp/ssh-* -user `whoami` -name agent\* -printf '%T@ %p\n' 2>/dev/null | sort -k 1nr | sed 's/^[^ ]* //' | head -n 1)
You can’t perform that action at this time.