Skip to content

Instantly share code, notes, and snippets.

View scruss's full-sized avatar
💭
🦆

Stewart Russell scruss

💭
🦆
View GitHub Profile
@scruss
scruss / brkmat_ssd1306.py
Created January 17, 2025 03:29
benchmark Mandelbrot set (aka Brooks-Matelski set) on OLED - MicroPython
# benchmark Mandelbrot set (aka Brooks-Matelski set) on OLED
# scruss, 2025-01
# MicroPython
# -*- coding: utf-8 -*-
from machine import Pin, I2C, idle, reset, freq
# from os import uname
from sys import implementation
from ssd1306 import SSD1306_I2C
@scruss
scruss / Music.bas
Created December 15, 2024 20:16
Microsoft BASIC for Macintosh "Music" demo: wavetable synthesis + MML parser in BASIC
REM --- Music
REM --- Reads easy to generate music commands and plays them.
REM --- Any four voice song can be played by simply changing the
REM --- DATA statements after the label Song:
DEFINT A-Z
REM --- Display Picture
OPEN "MusicPict" FOR INPUT AS 1
PICTURE (100,50),INPUT$(LOF(1),1)
@scruss
scruss / mqtt_cheerlights.py
Last active December 5, 2024 00:21
a very simple Cheerlights/NeoPixel MQTT client for MicroPython
# -*- coding: utf-8 -*-
# scruss, 2024-12
# MicroPython
"""
a very simple Cheerlights MQTT client for MicroPython
Uses Peter Hinch's MicroPython Asynchronous MQTT library
— https://github.com/peterhinch/micropython-mqtt/
Install it with:
mpremote mip install github:peterhinch/micropython-mqtt
@scruss
scruss / framebuf_pattern_pbm-big2.py
Created November 27, 2024 21:57
write a threatening pattern to a pbm
#!/usr/bin/env micropython
# write a threatening pattern to a pbm
# scruss, 2024-11
# MicroPython has framebuf, but no math.isqrt()
# Python3 has no framebuf, but has math.isqrt()
import framebuf
from math import sqrt
WIDTH = 1280 # original target was a 128 x 64 OLED
@scruss
scruss / threes.py
Last active October 21, 2024 02:03
threes.py - re-split several 3-letter words into (several-1) new 3-letter words
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# scruss, 2024-10
from itertools import combinations
from textwrap import wrap
import random
random.seed(None)
@scruss
scruss / csvthing.py
Created October 12, 2024 13:34
csvthing - clean up header of (slightly) nasty CSV so it'll work with SQLite
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# csvthing - clean up horrid csv so it will work with q and SQLite
# scruss, 2022-06
import sys
import csv
if len(sys.argv) < 2:
@scruss
scruss / capacitor.sh
Created September 18, 2024 15:37
capacitor discharge calculator shell script
#!/bin/zsh -f
# capacitor discharge - scruss, 2023-11
# - this should work with bash too but the formatting may be off
# - weird narrow format was designed for thermal printer output
if
[ "$#" -lt 3 ]
then
echo "usage: $0 resistance capacitance voltage [V₀]"
exit 1
@scruss
scruss / ES100_Arduino.ino
Last active August 18, 2024 20:56
minimally modified EverSet ES100 WWVB board Arduino example
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// es100_host_arduino.c
//
// Xtendwave ES100 Example Host MCU Code for Arduino - version 0002
//
// Copyright 2013 Xtendwave
//
// THIS SOFTWARE IS PROVIDED TO YOU "AS IS," AND WE MAKE NO EXPRESS OR IMPLIED
// WARRANTIES WHATSOEVER WITH RESPECT TO ITS FUNCTIONALITY, OPERABILITY, OR USE,
@scruss
scruss / raincode.sh
Created July 24, 2024 02:01
raincode.sh - create a plausible random UK Ministry of Supply-style "Rainbow Code" name
#!/bin/bash
# raincode.sh - create a plausible random UK Ministry of Supply-style
# "Rainbow Code" name
# see: https://en.wikipedia.org/wiki/Rainbow_Code
# scruss, 2024-07
rainbow=(Black Blue Brown Green Indigo \
Jade Orange Pink Purple Red \
Violet Yellow)
@scruss
scruss / LANDR2.FC
Created June 18, 2024 19:21
Jim Storer's LANDER (Focal) patched to maybe remove ancient bug
01.04 T "CONTROL CALLING LUNAR MODULE. MANUAL CONTROL IS NECESSARY"!
01.06 T "YOU MAY RESET FUEL RATE K EACH 10 SECS TO 0 OR ANY VALUE"!
01.08 T "BETWEEN 8 & 200 LBS/SEC. YOU'VE 16000 LBS FUEL. ESTIMATED"!
01.11 T "FREE FALL IMPACT TIME-120 SECS. CAPSULE WEIGHT-32500 LBS"!
01.20 T "FIRST RADAR CHECK COMING UP"!!!;E
01.30 T "COMMENCE LANDING PROCEDURE"!"TIME,SECS ALTITUDE,"
01.40 T "MILES+FEET VELOCITY,MPH FUEL,LBS FUEL RATE"!
01.50 S A=120;S V=1;S M=32500;S N=16500;S G=.001;S Z=1.8
02.10 T " "%3,L," "FITR(A)," "%4,5280*(A-FITR(A))