Skip to content

Instantly share code, notes, and snippets.

View scruss's full-sized avatar
💭
🦆

Stewart Russell scruss

💭
🦆
View GitHub Profile
@scruss
scruss / 1000days_concept.md
Last active April 3, 2024 11:16
Thousand Days: Concept

Thousand Days: Concept

Stewart Russell - scruss.com — 2024-03-26, at age 19999 days …

Summary

One's thousand day(s) celebration occurs every thousand days of a person's life. They are meant to be a recognition of getting this far, and are celebrated at the person's own discretion.

@scruss
scruss / esc-pos-image.py
Last active March 25, 2024 21:29
print image files to thermal printer ESC-POS on stdout
#!/usr/bin/env python3
# esc-pos-image.py - print image files given as command line arguments
# to simple ESC-POS image on stdout
# scruss - 2014-07-26 - WTFPL (srsly)
# - 2021-01-09 (made python3 compatible - tvm Carko!)
# if you want a proper CUPS driver for a 58mm thermal printer
# that uses this command set, go here:
# https://github.com/klirichek/zj-58
1 REM TAIPAN - HAYDEN BOOK CO COPYRIGHT 1986
2 REM BY ART CANFIL, KARL ALBRECHT, AND JIM MCCLENAHAN
3 REM TYPED, NOT EXHAUSTIVELY CHECKED, AND MILDLY TWEAKED BY DEAN OISBOID 2022
4 REM REPLACED DIRECT CTRL-G CALLS WITH BP$
5 REM INITIALIZATION (10-50)
10 HOME :A$ = " ":W$ = "ELDER BROTHER YU":LY$ = "LI YUEN":YS$ = "YAMATO & SMYTHE":TC$ = "O, S, T, A, P, OR R"
11 B$ = " "
14 REM OZZY REPLACED JUST BELOW WITH PROPER CTRL-G
15 BP$ = CHR$(7)
20 VTAB 4: INVERSE : PRINT A$: HTAB 15: PRINT "T A I P A N:": NORMAL : HTAB 13: PRINT "_________________"
@scruss
scruss / amazin.bas
Last active November 18, 2023 20:41
AMAZIN - by Jack Hauber. For DEC EDUSYSTEM 20 BASIC, from DEC EDU Newsletter Issue Number 4 (1972)
1 REM amazin
2 REM from https://archive.org/details/digital_edu_number_4/page/n1/mode/2up
100 RANDOMIZE
110 DIM W(25,103),V(25,103)
120 PRINT "WHAT ARE YOUR WIDTH AND LENGTH?"
121 INPUT H,V
122 PRINT
130 IF H<>1 THEN 150
131 IF V<>1 THEN 150
132 PRINT "MEANINGLESS DIMENSIONS, TRY AGAIN"
@scruss
scruss / esc-pos-image-star.py
Created July 27, 2014 03:14
print image files to thermal printer ESC-POS on stdout, using ESC * instead of GS v
#!/usr/bin/python
# esc-pos-image-star.py - print image files given as command line arguments
# to simple ESC-POS image on stdout
# using ESC * \x21
# scruss - 2014-07-26 - WTFPL (srsly)
import sys
from PIL import Image
import PIL.ImageOps
import struct
@scruss
scruss / chamfer_extrude.scad
Created February 24, 2019 21:22
chamfer_extrude - OpenSCAD operator module to approximate chamfered/tapered extrusion of a 2D path
module chamfer_extrude(height = 2, angle = 10, center = false) {
/*
chamfer_extrude - OpenSCAD operator module to approximate
chamfered/tapered extrusion of a 2D path
(C) 2019-02, Stewart Russell (scruss) - CC-BY-SA
NOTE: generates _lots_ of facets, as many as
6 * path_points + 4 * $fn - 4
@scruss
scruss / is_z80.sh
Created February 25, 2023 04:56
linux tool to output the "Z80ness" of a CP/M-80 binary: the higher the number, the more likely the binary will only run on a Z80 chip
#!/bin/bash
# is_z80 - guess if a binary is z80 or 8080
# from frequency of two-byte Z80 instructions
# scruss, 2023-02
# this might need gnu awk. Needs bc for sure
file="$1"
if
[ "$#" -eq 0 ]
@scruss
scruss / hootnanny-cleaned_up.py
Last active December 19, 2022 21:29
Slightly imperfect Python simulation of the "HOOT-NANNY" (or Magic Designer) drawing toy
#!/usr/bin/env python3
# hootnanny.py - simulate Hoot-Nanny / Magic Designer drawing toy
# Currently hard-coded to output figure "25KM" in HP-GL,
# a simple but somewhat obsolete plotting language.
# Output figures as close to actual sizes as I could manage.
# All dimensions in inches, unfortunately, but HP-GL is bilingual.
# scruss, 2022-02 - code cleanup - 2022-12
# Licence: CC-BY-SA - share freely, but credit me and make your
# improvements freely available for all
# -*- coding: utf-8 -*-
@scruss
scruss / STBEESSP.BAS
Created June 15, 2022 03:34
Speaks a limerick from SPO256-AL2 text phonemes: SPO256-AL2 emu on RC2040, CP/M MBasic
10 REM St Bees - scruss, 2022-06 - SPO256-AL2 emu on RC2040, CP/M MBasic
20 KAL$="PA1PA2PA3PA4PA5/OY/AY/EH/KK3/PP/JH/NN1/IH/TT2/RR1/AX/MM/TT1/DH1/IY/EY/DD1/UW1/AO/AA/YY2/AE/HH1/BB1/TH/UH/UW2/AW/DD2/GG3/VV/GG1/SH/ZH/RR2/FF/KK2/KK1/ZZ/NG/LL/WW/XR/WH/YY1/CH/ER1/ER2/OW/DH2/SS/NN2/HH2/OR/AR/YR/GG2/EL/BB2/"
30 ALV$="00*01*02*03*04*05*06*07*08**09*10*11**12*13**14**15*16*17**18**19*20*21**22**23*24*25**26*27**28**29*30*31**32*33**34**35*36**37*38*39**40*41**42**43*44*45*46*47*48*49**50*51**52**53*54**55*56**57**58*59*60*61**62*63***"
40 DEF FNLOOKUP$(N$)=LEFT$(RIGHT$(ALV$,LEN(KAL$)-INSTR(KAL$,N$)+1),2)
50 READ PHON$,TEXT$
60 IF PHON$="end" THEN GOTO 175
70 PRINT "(";TEXT$;")"
80 WHILE (LEN(PHON$)>0)
90 SPCPOS%=INSTR(PHON$," ")
100 IF SPCPOS%=0 THEN P$=PHON$:PHON$="" ELSE P$=LEFT$(PHON$,SPCPOS%-1):PHON$=RIGHT$(PHON$,LEN(PHON$)-SPCPOS%)
@scruss
scruss / collatz-memo.pl
Last active September 29, 2022 20:28
there's something badly wrong with raku ...
#!/usr/bin/env perl
# collatz-memo.pl
# run time: appx 7 s
# output: max: 8400511 steps: 685
use v5.20;
use strict;
use warnings;
my ( $maxsteps, $maxval, $n, $steps, $x ) = qw/0 0 0 0 1/;
my @s;