Skip to content

Instantly share code, notes, and snippets.

@aarmea
aarmea / README.md
Created August 1, 2026 13:55
pin-kernel — pick an installed kernel and make it stick.

pin-kernel

Pick an installed Linux kernel on Ubuntu and make it stick: hold its packages so apt can't reap it, make it the GRUB default, and build its initramfs if one is missing.

Ubuntu makes it easy to boot an older kernel once and surprisingly fiddly to keep one. The menu entry indices shift every time a kernel is added or removed, /etc/default/grub gets replaced by package upgrades, and unattended-upgrades will happily autoremove the kernel you were relying on.

#!/usr/bin/env bash
set -euo pipefail
# usb-port-to-pci.sh
# Map a USB device/port to the backing PCI USB controller (BDF like 0000:03:00.0).
# Usage:
# ./usb-port-to-pci.sh --watch
# ./usb-port-to-pci.sh 1:3 # BUS:DEV from `lsusb`
# ./usb-port-to-pci.sh 046d:c332 # VID:PID from `lsusb`
# ./usb-port-to-pci.sh --bus 1 # show which PCI controller owns USB bus 1
@aarmea
aarmea / luks_boot_server_local.sh
Created December 25, 2024 19:09
Script that connects to a server by MAC, rather than IP, address
#!/bin/bash
# Scans all available local networks for the host specified by `MAC_ADDRESS`
# then connects to it over SSH with the provided parameters.
# Useful for hosts whose root partitions are encrypted that also have Dropbear SSH
# set up in the bootloader as described at https://www.cyberciti.biz/security/how-to-unlock-luks-using-dropbear-ssh-keys-remotely-in-linux/
# Replace these values as appropriate
MAC_ADDRESS="01:23:45:67:89:ab" # Letters must be lowercase
SSH_PORT=1234
USER="root"
@aarmea
aarmea / goodbye-reddit.md
Last active September 11, 2023 11:03
How to migrate, not nuke, your Reddit content

I edited my Reddit comments using a version of Power Delete Suite that I modified to do the following:

  • Include a patch by james2432 on GitHub to add a 5 second delay between every write to avoid running into Reddit's (pre-7/1/23) API limits.
  • Backup comments and self-post text as base64 instead of raw text so that the formatting can be restored.
  • Include the URI-encoded permalink in the edited comment to allow deep links to the comment itself in the mirror. To use this, enable the "Edit comments / self posts" option and put %encoded_permalink% somewhere in your text.

My fork is available here. If you want to do this too, make sure to run this scrip

@aarmea
aarmea / wp-force-login.php
Created August 29, 2020 16:52
Wordpress Force Login with special roles
<?php
/*
Plugin Name: Force Login
Plugin URI: https://wordpress.org/plugins/wp-force-login/
Description: Easily hide your WordPress site from public viewing by requiring visitors to log in first. Activate to turn on.
Version: 5.4
Author: Kevin Vess
Author URI: http://vess.me/
Text Domain: wp-force-login
@aarmea
aarmea / config.yaml
Last active January 17, 2018 07:38
AlexaPi config.yaml
# See here for a detailed discussion: https://albertarmea.com/post/alexa-tree/
# See https://github.com/alexa-pi/AlexaPi/wiki/Audio-setup-&-debugging
# to get a better idea of how to set things in here
# Level of log output
# default: INFO
# set to DEBUG for verbose logging
logging: INFO
@aarmea
aarmea / animatronic_mouth.py
Last active March 12, 2025 20:43
Open and close an animatronic mouth on a Raspberry Pi GPIO pin
#!/usr/bin/env python
"""
animatronic_mouth.py
This script animates a motorized mouth on a Raspberry Pi GPIO pin so that it
appears to be speaking alongside the audio on the specified PulseAudio source
(which usually should be a sink's monitor).
Find PA_SOURCE with `pactl list` and look for a monitor device that corresponds
@aarmea
aarmea / 0-readme.md
Last active April 18, 2024 15:20
OpenCV Python example

This is a set of scripts that calibrates and calculates a depth map from a stereo camera. It is primarily written with this ELP stereo camera in mind, but it theoretically should work with other hardware.

See for a full writeup.

@aarmea
aarmea / stereo-camera-test.py
Created August 16, 2017 06:48
OpenCV sample stereo camera usage
import numpy as np
import cv2
# Set up specifically for the ELP 1.0 Megapixel Dual Lens Usb Camera Module ...
# https://www.amazon.com/ELP-Megapixel-Camera-Module-Biometric/dp/B00VG32EC2/ref=sr_1_4?ie=UTF8&qid=1502756603&sr=8-4&keywords=stereo+camera
# This camera enumerates as two separate cameras, hence the separate `left` and
# `right` VideoCapture instances. For a proper stereo camera with a common
# clock, use one VideoCapture instance and pass in whether you want the 0th or
# 1st camera in retrieve().

Keybase proof

I hereby claim:

  • I am aarmea on github.
  • I am aarmea (https://keybase.io/aarmea) on keybase.
  • I have a public key whose fingerprint is 39AC BDA7 9EF6 6E60 8651 5881 6643 7436 E180 7300

To claim this, I am signing this object: