Skip to content

Instantly share code, notes, and snippets.

View stefanv's full-sized avatar

Stefan van der Walt stefanv

View GitHub Profile
@stefanv
stefanv / omnivore-to-wallabag.py
Created October 31, 2024 18:57
Import Omnivore reading list into Wallabag
"""Convert exported Omnivore reading list to Wallabag v2 JSON format.
This is by no means well checked or perfect, but it should serve as a start for further efforts.
It got my list of articles imported into Wallabag, which is all I wanted.
"""
import json
import csv
from datetime import datetime
import glob
@stefanv
stefanv / org-gh-links.el
Created January 20, 2024 22:02
GitHub links for org mode
@stefanv
stefanv / install-deps
Last active November 4, 2023 21:45
Install build or other dependencies from pyproject.toml
#!/usr/bin/env python
import tomllib
import argparse
import sys
import subprocess
parser = argparse.ArgumentParser()
parser.add_argument(
import numpy as np
from skimage.transform import warp, PolynomialTransform
from skimage import data
import matplotlib.pyplot as plt
def swirl(xy, x0, y0, R):
r = np.sqrt((xy[:,1]-x0)**2 + (xy[:,0]-y0)**2)
a = np.pi*r / R
xy = np.copy(xy)
xy[:, 1], xy[:, 0] = (

Typing Guidance for Python Libraries

Much of Python’s popularity can be attributed to the rich collection of Python libraries available to developers. Authors of these libraries play an important role in improving the experience for Python developers. This document provides some recommendations and guidance for Python library authors.

These recommendations are intended to provide the following benefits:

@stefanv
stefanv / http_server_python
Last active September 23, 2021 07:45
Multi-threaded HTTP server in Python
#!/usr/bin/env python3
# See https://github.com/Nakiami/MultithreadedSimpleHTTPServer/blob/master/MultithreadedSimpleHTTPServer.py
# Python 3.x
from socketserver import ThreadingMixIn
from http.server import SimpleHTTPRequestHandler, HTTPServer
class ThreadingSimpleServer(ThreadingMixIn, HTTPServer):
pass
#!/usr/bin/env python3
import subprocess
import time
import os
from datetime import datetime
# Check after every X minutes
delay = 60
import numpy as np
validators_online = 102
consensus_size = 28
replacement_factor = 4
validators = np.arange(validators_online)
replacement_N = len(validators) // replacement_factor
N = 10000
@stefanv
stefanv / problem10.py
Last active December 10, 2020 17:05
Advent of Code :: Problem 10
adapters = np.sort(adapters)
start = 0
end = np.max(adapters) + 3
cache = {}
def next_in_line(last_link):
if last_link in cache:
return cache[last_link]