Skip to content

Instantly share code, notes, and snippets.

View edthrn's full-sized avatar

ed edthrn

  • Europe
View GitHub Profile
@edthrn
edthrn / nvtop.py
Created February 13, 2026 17:00
A htop-like program for NVIDIA GPU usage, based on nvidia-smi
#!/usr/bin/env python3
"""
nvtop.py - Terminal-based NVIDIA GPU monitor (htop-style).
Zero dependencies beyond Python 3 stdlib + nvidia-smi on PATH.
Controls:
q / Esc - Quit
Up / Down - Select GPU (when multiple)
p - Toggle process list sort (pid / memory)
h - Toggle help overlay
@edthrn
edthrn / wol.py
Created February 5, 2026 16:55
A Python Script to Wake-On-Lan
"""
Wake-on-LAN (WoL) Utility
This script sends a Wake-on-LAN magic packet to a target network device,
allowing it to be powered on remotely. The magic packet is constructed
using the device's MAC address and sent via UDP broadcast to the specified
IP address and port.
Features:
- Validates MAC address, IP address, and port inputs.
@edthrn
edthrn / recovery.gpg
Created October 27, 2025 18:04
Disaster Recovery
jA0ECQMCCXhjcXVYcx7/0u0BIZ9YBEfcXXAZOt710mxZp/Rr0Iq5TiPF0qgBWRzC8Ddp9XiE8lXs
4nfTtHfOIDZ+MQazor1npGXQS8qXMCQjDeGjkyKtnUiBxdOJ5MVQPfWHsQI9m21BRaNzpg2LrAOx
qqTQNm2IiYQm6PtRF9Zjy8V6Q8M6RsTwRRqMD1AC2Zsh11ipCPgS0R//0qEx2BbdLUfzbdaOaYue
sbufvtqFmo4E+rBHsNzY6TqSbmVM1kQoieCp9wzfM22xN9anVTTj18AKb5wlAQuqoJ0vCi9JhV+M
Cn/Q/IliYT9Iy1tbNzgeuGsUc5fOQDjcNsSBki49Rluc4mmHzOeJdgnUU4VPIAOz8IZ9NUFpcUdX
lGjRofc7AolgnxkMRMg93hzmVGEu/ijiBPZWAV2u0wDxcZeKH/USKlqYYPvMopgZ5sJb9AWIYiTa
H2xf06rY7OnfoAqfoNzCrmgZO/zpPeh/VCglZcCDWX8HBGjgcq7OudkSTbPtkefQ4iOlQGAWWrbH
ApRPrmRbm95PAq/6y+lQPPqn7mAwKM+Cto63viw+LI+nB/gcSO+mF+q6aLMc+1ZtOI7j/EJjiSk+
gJ5+t3So0ywLPsOUbSUmMqMVvT6BQAMBzZkrbs/SDql6rYOwiVsnRDHYlg8tRv0OqoZqJ7WbSBNB
SyJGuVSe/CqDp/oUxwZa1X05jSqGK1Kp0rYgp8YD/V/SVwnPnxQVeTvdoPTYpLS1UD2vdBG0TX2K
@edthrn
edthrn / aes.sh
Last active August 30, 2025 11:08
AES encryption/decryption using openssl
#!/bin/bash
function encrypt {
input=$1
echo "Encrypting $input..."
openssl enc -aes-256-cbc -pbkdf2 -iter 800000 -in "$input" -out cipher.bin
echo "Encrypted file saved to: $(pwd)/cypher.bin"
}
function decrypt {
@edthrn
edthrn / Strong_Opinions_Weakly_Held.md
Created November 30, 2024 12:29
Paul Saffo's Essay / Strong Opinions weakly held

Strong Opinions weakly held

Orginally posted on 07.26.02008 by Paul Saffo, at https://saffo.com

The point of forecasting is not to attempt illusory certainty, but to identify the full range of possible outcomes. Try as one might, when one looks into the future, there is no such thing as “complete” information, much less a “complete” forecast. As a consequence, I have found that the fastest way to an effective forecast is often through a sequence of lousy forecasts. Instead of withholding judgment until an exhaustive search for data is complete, I will force myself to make a tentative forecast based on the information available, and then systematically tear it apart, using the insights gained to guide my search for further indicators and information. Iterate the process a few times, and it is surprising how quickly one can get to a useful forecast.

Since the mid-1980s, my mantra for this process is “strong opinions, weakly held.” Allow your intuition to guide you to a conclusion, no matter how imperfec

@edthrn
edthrn / 1-Unit-testing with PyGithub.md
Last active October 19, 2023 05:09
Unit-testing with PyGithub

Intro

Lately, I've been building a Python platform that relies heavily on interactions with Github. Instead of re-inventing the wheel, I decided to go with PyGithub as a wrapper around Github v3 API.

The problem

This library implements the full API, which allows me to be very productive when I need to add a workflow in my platform that involves Github. However, it quickly became a real PITA to write unit tests. Even if the package comes with its own testing Framework, it is not documented yet and I didn't manage to crack it up in a decent amount of time.

I decided to hack the testing a little bit, using another very cool package, httpretty. Httpretty allows you to monkey patch the socket module during testing, so you can respond anything you want to any kind of network requests. Here's what I came up with, do not hesitate to give any feedback.


@edthrn
edthrn / execute.py
Last active January 26, 2023 18:08
Execute Shell command on EC2 Linux instance with Python and Boto3
# Following https://stackoverflow.com/questions/34028219/how-to-execute-commands-on-aws-instance-using-boto3
import boto3
ssm = boto3.client('ssm')
response = ssm.send_command(
InstanceIds=['i-abcde12345...'],
DocumentName='AWS-RunShellScript',
Parameters={'commands': ['echo "This command ran on $(date)"']
)
@edthrn
edthrn / remove-from-git.sh
Created February 10, 2021 20:15
Remove old data from Git repo and Git history
# Taken from https://docs.github.com/en/github/authenticating-to-github/removing-sensitive-data-from-a-repository
# Warning:
# --------
# All stashes may be lost!
PATH_TO_REMOVE=big-folder/commited/by/error
# 1. Force Git to process, but not check out, the entire history of every branch and tag
# 2. Remove the specified file, as well as any empty commits generated as a result
@edthrn
edthrn / redis.clj
Created February 20, 2021 16:27 — forked from ragnard/redis.clj
Using Redis for persistent memoization of Clojure functions
(ns util.redis
(:refer-clojure :exclude [memoize])
(:require [taoensso.carmine :as car]))
;; boilerplate stuff that is not in Carmine
(def ^:dynamic ^:private *pool*)
(def ^:dynamic ^:private *spec*)
(defmacro with-redis
@edthrn
edthrn / pw.sh
Last active November 20, 2019 20:31
Put a password stored in `1password` to clipboard
# Usage: ./pw.sh Github.com
op get item $1 | jq -r '.details.fields[] | select(.designation=="password").value' | xclip -selection c