Skip to content

Instantly share code, notes, and snippets.

View dustinlennon's full-sized avatar

Dustin Lennon dustinlennon

View GitHub Profile
@dustinlennon
dustinlennon / settings.json
Last active March 13, 2025 18:56
vscode settings
{
"editor.minimap.enabled": false,
"terminal.integrated.fontSize": 13,
"[markdown]": {
"editor.unicodeHighlight.ambiguousCharacters": false,
"editor.unicodeHighlight.invisibleCharacters": false,
"diffEditor.ignoreTrimWhitespace": false,
"editor.wordWrap": "bounded",
"editor.wordWrapColumn": 100,
"editor.quickSuggestions": {
@dustinlennon
dustinlennon / mirror
Last active February 16, 2025 13:15
Mirror directory structures on remote and local machines.
#!/bin/bash
#
# Mirror directory structures on remote and local machines.
#
# This requires "mirror" accounts with sudo privileges having NOPASSWD for
# /usr/bin/rsync. This enables rsync to read/write files not owned by the
# mirror. The corresponding sudoers entry (visudo sudoers):
#
# mirror ALL=(ALL) NOPASSWD: /usr/bin/rsync
#
@dustinlennon
dustinlennon / reservoir_sampler.py
Last active January 30, 2025 00:25
reservoir sampler (pyton)
"""
A simple reservoir sampler class adapted from Wikipedia pseudocode.
cf. https://en.wikipedia.org/wiki/Reservoir_sampling
"""
import numpy as np
class ReservoirSampler(object):
def __init__(self, seed : int = None):
self.rng = np.random.default_rng(seed = seed)
@dustinlennon
dustinlennon / qr.py
Last active October 5, 2024 22:04
qr code from url
#!/usr/bin/env python3
"""Generate a QR code from a URL
usage: qr.py [-h] [--url URL] [--interactive] [--output OUTPUT] [--size SIZE]
options:
-h, --help show this help message and exit
--url URL
--interactive
--output OUTPUT a PNG file
@dustinlennon
dustinlennon / fork2.py
Created October 5, 2024 21:02
a fork and monitor pattern using asyncio and named sockets
"""A fork and monitor pattern, asyncio with named sockets
author: Dustin Lennon
email: dustin.lennon@gmail.com
Generate heartbeats in a parent process; check heartbeats in a child process. The
most recent heartbeat is saved in a file. The child exits when the parent terminates,
specifically when its parent pid changes.
This code also sets up a named socket in the filespace which enables shell interaction with