Skip to content

Instantly share code, notes, and snippets.

View stecman's full-sized avatar

Stephen Holdaway stecman

View GitHub Profile
stecman /
Last active October 18, 2023 04:08
Micropython example: controlling a motor with rotary encoder and PID

MicroPython motor control on Raspberry Pi Pico

Getting started

See getting started with Raspberry Pi Pico. This walks you through installing Thonny, an editor that supports interacting with MicroPython running on the Pico. The board already has MicroPython installed on it, so you can skip that step.

stecman /
Last active September 5, 2023 00:07
Basics of embedding a file in firmware with GCC

Basics of embedding files in firmware

This is an appendix item for Unicode Input Terminal.

With gcc, the linker can can happily create an object file from arbitrary input files. This is useful for embedding images, fonts, etc into firmware. Full CMake code at the end, but the important parts are:

# Create object file
stecman /
Last active September 5, 2023 00:07
Render glyphs to file with Python

Bake glyphs from fonts to image files (Python)

This is an appendix item for Unicode Input Terminal.

Protoype code to pre-render 240x240 screens, each with a glyph and codepoint metadata.

# Download Unicode metadata
stecman /
Last active September 5, 2023 00:06
Render glyphs to image with Rust

Bake glyphs from fonts to image files (Rust)

This is an appendix item for Unicode Input Terminal.

Find all of the Unicode codepoints a font can represent and renders them to invidiaul image files. Note the output directory is hard-coded to /tmp/rendered.

cargo run <font-file, ...>
stecman /
Last active March 19, 2024 14:08
Buffered write to LTO tape on linux

Writing to LTO tape with a text index and a memory buffer

This script is for writing to LTO tape on Linux with tar and producing a plain text index file. It uses a large memory buffer to keep the destination tape drive fed when the source drive can't consistently match the tape's write speed (eg. when there are a mix of small and large files).

This was written for a small, manually managed tape collection. It writes tape index information and tar listings as text to a file. This file can be stored separately, searched easily, and appended to the end of the tape if you want your tapes to be self-describing:

stecman / config
Last active October 15, 2023 21:34
Scripts to make i3 more natural to use
# Move workspace left and right (swap if conflicting)
bindsym $mod+Ctrl+Shift+Left exec $HOME/.i3/ left
bindsym $mod+Ctrl+Shift+Right exec $HOME/.i3/ right
# Make the next free workspace number, whatever that is
bindsym $mod+Ctrl+Return exec $HOME/.i3/
# Rotate focus through visible workspaces on different monitors
bindsym $mod+x exec $HOME/.i3/
stecman /
Last active April 21, 2024 10:03
Detect audio signal with an AVR attiny13a and emulate a MS-6147-RC 443 MHz remote to turn speaker power on

Automatic speaker power control from multiple audio sources

Switches mains power on for speakers while an audio signal is detected, and times out after a period of silence. Uses the AVR ATTiny13a and a couple of op-amps.

Mains switching is achieved by emulating a MS-6147-RC 433.92 MHz remote control with firmware and a simple simple on-off-keying (OOK) transmit module.

This solves two problems for me:

stecman / hidetitlebar
Created June 9, 2022 23:14
X11 / Linux hide titlebar of a window
# Hide the decorations of a window.
# Defaults to hiding the focused window's decorations.
# Pass -m to use the mouse to select the target window.
# Get the focused window's ID
ID_OPTION="-id $(xdotool getwindowfocus)"
while getopts 'm' flag; do
stecman / NewKittyWindow.scpt
Last active April 19, 2024 23:00
New Kitty terminal window global hotkey on Mac OSX
# Open a new kitty terminal window on MacOS
# 1. Copy this script into AppleScript Editor and save it somewhere
# 2. Use something like Apptivate to run the script on a global hotkey:
# Note this script doesn't work well as a Service through Automator as the
# "click menu" functionality requires accessibility privileges granted.
# Services run as the focused app, so that setup would require every context
# the shortcut is run from to have accessibility granted.
stecman /
Last active December 21, 2022 20:23
ffmpeg streaming examples

FFmpeg streaming

These are some ffmpeg command lines used when developing VHS dubbing controller.

HLS Stream (on Linux)


# Stream a PAL 50i capture, cropped and de-interlaced using ffmpeg