Skip to content

Instantly share code, notes, and snippets.

@pete
pete / afill
Created August 17, 2025 19:53
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 / 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 / causes-icd.awk
Last active March 15, 2018 08:42
Fact-checking the New Yorker
BEGIN {
# X40-X44 is accidental overdose.
# X60-X64 is intentional (i.e., suicide)
# Y10-Y14 is unknown intent.
for(i = 0; i < 5; i++) {
cs["X4" i]++
cs["X6" i]++
cs["Y1" i]++
}
for(i in cs)
@pete
pete / Makefile
Last active October 7, 2017 01:23
# This gives you the ability to do
# git tag -a -m '1.0' 1.0
# make upload-release-1.0
# Written off the top of my head and not tested.
# Use at your own peril.
.PHONY: release
release:
mkdir -p release
@pete
pete / gist:dffed6d4c513c3877a1ab4cc9b8b6c30
Created August 1, 2016 00:28
Basic no-op version of Rack Middleware
class SomeMiddleware
attr_accessor :app
def initialize app
# The arguments passed to use() will end up here.
self.app = app
end
def call env
# This gets called when there's a request. It
#!/dis/sh
load std regex
drx = '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]'
cfn = `{ls tw-days|sort -r|sed 1q}
dn = `{basename $cfn .log}
echo -n > $cfn
sed -n (
'/^! day changed, ' ^ $dn ^ '/,$ { s///g; s/$/\n/; p; }'
implement A;
include "sys.m"; sys: Sys;
include "draw.m";
A: module {
init: fn(nil: ref Draw->Context, nil: list of string);
};
init(nil: ref Draw->Context, nil: list of string)
@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 / 0README
Created March 11, 2013 21:34
See 0README. Power management.
These change the background color in X (and I think they don't work if you are
using a desktop system, so the `xset` command ought to be changed for whatever
Gnome/KDE/LXDE/XFCE/ASDFJKLSEMICOLON thing you are using if you are using such a
thing) based on battery power remaining. The Lua one requires luaposix to be
installed.
The reason there are two versions is that Ruby was, when it ought to have been
sleeping, doing some select() loop. I figured Lua would not do that to me, and
it does not. (Porting is usually more fun than fighting the language.)