Skip to content

Instantly share code, notes, and snippets.

View dustinlennon's full-sized avatar

Dustin Lennon dustinlennon

View GitHub Profile
@dustinlennon
dustinlennon / ca_csr.md
Created October 22, 2025 13:54
openssl: create CA and CSR

Site CA

generate rsa private key

openssl genpkey -algorithm RSA -quiet -out $cert_output_path/site.key

create site CA

@dustinlennon
dustinlennon / vscode_ipython_setup.md
Last active September 26, 2025 20:29
vscode: ipython

Run ipython in Microsoft Visual Studio Code

It can be useful to run ipython in a terminal, copying and pasting code snippets as part of the development workflow. Here's how to integrated this pattern into VS Code.

create an integrated terminal profile

Add the following to settings.json:

@dustinlennon
dustinlennon / settings.json
Last active September 26, 2025 20:32
vscode: settings.json
{
"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