Skip to content

Instantly share code, notes, and snippets.

View soxofaan's full-sized avatar

Stefaan Lippens soxofaan

View GitHub Profile
sankeyDraw(
{
'nodes': [
{name: "a"},
{name: "b"},
{name: "c"},
{name: "d"},
{name: "e"},
{name: "f"},
{name: "g"},
@soxofaan
soxofaan / python-version-dump.py
Last active August 29, 2015 14:23
python version dump snippet
"""
Snippet to list Python installation/packaging related version information.
Execute it with the Python executable you want to inspect.
Usage example with curl/wget tricks straight from this github gist
(optionally replace `python` at the end with the desired alternative):
curl -s https://gist.githubusercontent.com/soxofaan/cc4986cc507cb10f962d/raw/python-version-dump.py | python
@soxofaan
soxofaan / ssh_reconnect.xonsh
Created September 7, 2016 22:01
.xonshrc snippet with alias to reconnect SSH sockets (after reconnecting a screen session)
def _reconnect_ssh_agent_socket(args, stdin=None):
import re
print("Updating ssh-agent socket environment. Current value: $SSH_AUTH_SOCK = %s" % $SSH_AUTH_SOCK)
# Use find to list candidate paths with timestamp (as float).
raw = $(find /tmp/ssh-* -user @$(whoami) -name 'agent*' -printf '%T@:%p;')
candidates = [(float(m.group(1)), m.group(2)) for m in re.finditer('([0-9.]*):(.*?);', raw)]
# Take latest.
$SSH_AUTH_SOCK = max(candidates)[1]
@soxofaan
soxofaan / README.md
Last active May 2, 2025 22:26
Simple pretty CSV and TSV file viewer.
@soxofaan
soxofaan / screen-ssh-agent-fix.sh
Created January 16, 2017 12:50
Script to fix SSH agent environment variables on a remote server after reconnecting to a screen session
#!/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)
@soxofaan
soxofaan / .block
Last active August 15, 2017 12:23
Four-dimensional hypersphere packing
license: mit
border: no

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 / zequals.py
Last active November 28, 2017 08:52
"Zequals" ruthless rounding: just keep one leading digit.
import math
def zequals(x):
"""
"Zequals" ruthless rounding: just keep one leading digit.
examples:
123 -> 100
4567 -> 5000
-0.0345 -> -0.03
@soxofaan
soxofaan / pandas-timeindex-secondary-y-issue.ipynb
Last active December 13, 2017 17:25
pandas-timeindex-secondary-y-issue.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@soxofaan
soxofaan / .block
Last active December 29, 2018 17:06
Circle of Fifths with Diatonic Seventh Chords
license: mit
height: 800
border: no