Skip to content

Instantly share code, notes, and snippets.

@kmcallister
kmcallister / rust-backtrace
Last active July 30, 2026 00:15
Run a Rust program and print a stack backtrace on failure (old)
#!/bin/bash
### NOTE ### You probably don't need this anymore!
# Just set RUST_BACKTRACE=1
# Usage: rust-backtrace ./my-rust-prog args...
exec gdb -batch -n -x /dev/fd/3 --args "$@" 3<<ENDGDB
set height 0
set breakpoint pending on
@kmcallister
kmcallister / midi-wled.py
Created December 2, 2025 04:21
MIDI to WLED UDP gateway
import mido
import socket
UDP_ADDRESS = "xmastree.local"
UDP_PORT = 21324
NUM_LEDS = 150
COLORS = [
[255, 0, 0],
[ 0, 255, 0],
@kmcallister
kmcallister / gist:3808d82f86045d95a157
Created September 17, 2014 23:00
codegen plugin demo
#![crate_type="dylib"]
#![feature(plugin_registrar)]
extern crate libc;
extern crate syntax;
extern crate rustc;
extern crate "rustc_llvm" as llvm;
use libc::{c_uint, uint64_t};
use syntax::ast;
@kmcallister
kmcallister / build.sh
Created August 24, 2014 23:41
68k Mac boot floppy example
#!/bin/bash -xe
m68k-unknown-elf-gcc -o demo demo.s -nostdlib
m68k-unknown-elf-objcopy -O binary demo floppy.img
#!/usr/bin/env python3
import sys
temps = sys.argv[1:]
for ln in sys.stdin:
if ln.rstrip() == 'M600':
sys.stdout.write('M104 S' + temps.pop(0) + '\n')
else:
sys.stdout.write(ln)
#!/usr/bin/env python3
import random
from colormath.color_objects import LabColor, sRGBColor
from colormath.color_conversions import convert_color
from colormath.color_diff import delta_e_cie2000
print("<style>body { font-size: 24pt; font-family: monospace; }</style>");
def random_srgb():
return sRGBColor(
#!/usr/bin/env python3
import sys
temps = sys.argv[1:]
for ln in sys.stdin:
if ln.rstrip() == 'M600':
sys.stdout.write('M104 S' + temps.pop(0) + '\n')
else:
sys.stdout.write(ln)
@kmcallister
kmcallister / slant-rack.scad
Created March 27, 2021 03:33
Parametric culture slant rack
// Copyright 2021 Keegan McAllister
// License: CC-BY 4.0
// https://creativecommons.org/licenses/by/4.0/
include <MCAD/units.scad>
/* [Part selection] */
// Part selection
part = "assembly"; // [assembly, plate, grid, rail, base]
@kmcallister
kmcallister / bot.py
Created June 12, 2019 21:35
LED strip code
#!/usr/bin/env python
import itertools
import colorsys
import datetime
import irc.bot
import random
import socket
import struct
import sys
import re
module menger_sponge(n) {
if (n <= 0) {
cube(center=true);
} else {
for (x=[-1:1]) {
for (y=[-1:1]) {
for (z=[-1:1]) {
if (abs(x)+abs(y)+abs(z) >= 2) {
scale(1/3)
translate([x,y,z])