Skip to content

Instantly share code, notes, and snippets.

View soxofaan's full-sized avatar

Stefaan Lippens soxofaan

View GitHub Profile
@soxofaan
soxofaan / signal_catcher_context.py
Last active April 13, 2019 16:12
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.
import logging
import os
import signal
import time
log = logging.getLogger(__name__)
class SignalCatcher:
@soxofaan
soxofaan / .block
Last active August 15, 2019 21:55
Microphone Spectrum Analyser
license: mit
height: 500
border: no
@soxofaan
soxofaan / .block
Last active November 19, 2023 20:06
Microphone pitch detection
license: mit
height: 400
border: no
@soxofaan
soxofaan / here-jupyter.sh
Last active March 23, 2021 23:34
here-jupyter: launch Jupyter Notebook in background from current directory using tmux
#!/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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@soxofaan
soxofaan / openeo-vito-binary-download.ipynb
Created December 10, 2019 13:13
openEO VITO download binary mask
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@soxofaan
soxofaan / openeo-mask-example.ipynb
Created January 13, 2020 08:35
OpenEO mask example
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@soxofaan
soxofaan / pyrasite-stacktrace-how-to.md
Last active April 25, 2024 10:50 — forked from reywood/how-to.md
How to get a stack trace from a stuck/hanging python script

How to get a stack trace for each thread in a running Python script

Sometimes a Python script will simply hang forever with no indication of what is going wrong. Perhaps it's polling a service that will never return a value that allows the program to move forward.

Here's a way to see where the program is currently stuck, using pyrasite a tool for injecting code into running Python processes.

Install gdb and pyrasite

Install gdb.