Skip to content

Instantly share code, notes, and snippets.

View pete's full-sized avatar

Pete pete

View GitHub Profile
@pete
pete / the-hell-was-that
Created July 18, 2026 02:05
Ask your computer what the hell just happened.
#!/bin/rc
# "The hell was *that*?"
# A substitute for mashing the error message into a search engine:
# · Reads /dev/text by default; see -i and -a.
# · Tells the clanker to explain what the hell is going on.
# · The clanker attempts to explain what the hell is going on.
# · Dumps some stuff in /tmp to debug and also to integrate with other
# local tools.
@pete
pete / afill
Last active April 5, 2026 00:37
ollama on Plan 9
#!/bin/rc
# This script was written entirely out of perversity:
# it is LLM code-completion for acme under Plan 9.
# It will attempt to fill in a chunk of code under the cursor,
# in acme
# under Plan 9
# using only tools available in Plan 9
# to talk to ollama.
# I have mixed the sacred and the profane.
# You just put it in the tag in the acme window, and then you
@pete
pete / me.sh
Last active December 15, 2025 22:52
echo '++++[->++++<]>[-<+++++>>+++++++>++<<]<------.>>+++++.--.+.>.<[-<+>>>+<<]>[--<++>>-<]>---.+++++++++++++.+.<<<.>>>-------.---.<<<--.>.>>+++.-------.++.++[->+<<+>]>++++++.<<.<<.>[-<<->>]<<++++.[>>>--<<<-]>>>+.' | \
sed -E 's/(.)/\1\n/g' | \
awk 'BEGIN{print "BEGIN{p=0;"}END{print "}"}/\./{print "printf \"%c\",a[p]"}/\+/{print "a[p]++"}/-/{print "a[p]--"}/</{print "p--"}/>/{print "p++"}/\[/{print "while(a[p]){"}/\]/{print "}"}' | \
awk -f /dev/fd/0
@pete
pete / make.awk
Created August 15, 2025 15:13
Make in a few lines of awk
#!/usr/bin/awk
# Friend on fedi just showed me https://github.com/xonixx/makesure , I speculated that you could do make in ~10 lines of awk.
# You basically can: 9 lines, not counting comments.
# File format is a subset of make, "targ1: dep1 ... depN\n\tline1\n\tline2\ntarg2: ..."
# Invocation is different: `make.awk 'targ=whatever' Makefileish`
# To run it on Plan 9, change /usr/bin/awk to /bin/awk and "stat -c %Y" to just "mtime"
# I have not executed this code; it is a stunt-hack. I just thought it would be funny.
BEGIN{if(!length(targ))targ="all"}
/^\t/{if(length(cur) < 1) { print "no targ"; exit }; ts[cur] = ts[cur] "&&" $0; next }
!NF{cur=""; next}
@pete
pete / .conkyrc
Created September 25, 2024 04:59
The .conkyrc I am using on my DevTerm.
conky.config = {
border_width = 1,
cpu_avg_samples = 2,
default_color = 'white',
minimum_width = 5,
default_graph_width = 200,
default_graph_height = 40,
default_gauge_width = 200,
alignment = 'top_left',
background = false,
@pete
pete / 0-README
Last active February 10, 2024 07:12
Various implementations of the 'cat' command, for comparison.
I turned this gist into a "real" repository. It is here: http://github.com/pete/cats .
Here, placed side-by-side for comparison, are GNU's implementation of
cat, Plan 9's implementation, Busybox's implementation, and NetBSD's
implementation, Seventh Edition Unix (1979), and 4.3BSD.
For good measure (and because I suppose I am now committed to collecting
cats) also included are Second Edition Unix (in assembly) and Inferno's
implementation (in Limbo) for good measure.
#! /usr/bin/env ruby
# "Fork and Forget"
# Don't wait if you don't have to: A mini-tutorial about concurrency
# mechanisms in Ruby and basic Unix systems programming, and how you can use
# them to avoid waiting.
#
# I have heard that people are occasionally unfamiliar with this strategy.
# It's a common idiom, regardless of language, and it is also essentially built
# into Erlang (and Termite Scheme, etc.).
#
@pete
pete / 0readme
Created August 23, 2013 03:50
Numbers that mean absolutely nothing.
I was waiting for a Linux kernel to build. It seems to take
longer to configure a new kernel every time, like the number
of options have been steadily increasing. I thought I might
be hallucinating, you know? Maybe I have just gotten
impatient and the bloat wasn't that bad. Or maybe it is
the case that the options have gotten horribly numerous and
increasingly arcane. In any case, I did this:
for m in $list_of_linux_machines_here; do
ssh $m wc -l '/usr/src/linux-*/.config'
@pete
pete / gist:4694295
Created February 1, 2013 21:31
Ridiculous nonsense.
#!/usr/bin/env ruby
# Hey, wanna see something fun?
#
# My disk broke. Thinking quickly, I decided to harness the unlimited power of
# User Error, and partially wreck my backup.
#
# Don't ask.
#
# md0 had most of the data. But the filesystem and partition table were
# wrecked, and some unknown amount of data had been exchanged between it and
Experiments in revision control: Curry recipe.
My personal recipe for Japanese curry, which has mutated over the years and is
now open-source thanks to github, hot damn. Some of the ingredients are not
very Japanese, but curry came to Japan from England which got it from India to
begin with, so whatever.
1.5 - 2 lbs. of meat, prefer thin-sliced beef (komagire), pork works, too.
Thin-sliced stuff is always best, but in a pinch stewing beef works. Bacon
works surprisingly well. Chicken will work, technically, but if you must,