Skip to content

Instantly share code, notes, and snippets.

@9nut
9nut / README.md
Created August 28, 2026 19:10
A very basic, but correct and safe UnZip in Go (thanks to Go's standard packages)

Why

It's simple and handles path escaping and quoting of spaces and special characters in file paths correctly.

Build

go build

Run

unzip -f foo.zip -d /tmp
@9nut
9nut / OpenSprinkler HTTPS
Last active August 14, 2024 01:45
OpenSprinkler Firmware (OSPi) mods for HTTPS reverse proxy
This is the gist of the mods to serve OpenSprinkler over https.
@9nut
9nut / concio_ex.c
Created June 20, 2022 21:44
Example concurrent network requests using the Plan 9 threads library
#include <u.h>
#include <libc.h>
#include <thread.h>
int STKSIZE = 2*1024;
struct SleepArgs {
long millies;
Channel *c;
};
@9nut
9nut / dhcpd_diffs.out
Last active June 5, 2020 16:20
Plan 9 dhcpd.c modifications for PXE booting Raspberry Pi 3 and Pi 4
diff ./dhcpd.c /n/sources/plan9/sys/src/cmd/ip/dhcpd/dhcpd.c
1143d1142
< char ipaddrstr[NDB_IPlen];
1263,1267d1261
< case ODtftpserver: /* RPi4s request it for no-SD netbooting without hardcoding TFTP_IP in EEPROM */
< memset(ipaddrstr, 0, sizeof(ipaddrstr));
< sprint(ipaddrstr, "%I", rp->up->laddr);
< stringopt(rp, ODtftpserver, ipaddrstr);
< break;
1289,1308d1282
@9nut
9nut / FM_tone.ino
Created July 7, 2019 23:35
Arduino sketch for controlling NS73M FM transmitter with an ATtiny85
/*
12-1-2007
Cai Maver, caimaver(at)yahoo.com
ARRRduino+NS73M v0.3
This code allows an Arduino Diecimila to control an NS73M FM Transmitter Module (Arrr matey!)
This sets the NS73M (available from Sparkfun, SKU#: WRL-08482) to transmit
at 2mW with 75us pre-emphasis (the standard for North America) on 97.3 MHz.
@9nut
9nut / OpenSSL Cheatsheet.md
Last active May 3, 2019 21:30 — forked from davewongillies/OpenSSL Cheatsheet.md
OpenSSL Cheatsheet

General OpenSSL Commands

These commands allow you to generate CSRs, Certificates, Private Keys and do other miscellaneous tasks.

  • Generate a new private key and Certificate Signing Request
openssl req -out CSR.csr -new -newkey rsa:2048 -nodes -keyout privateKey.key
  • Generate a self-signed certificate (see How to Create and Install an Apache Self Signed Certificate for more info)
@9nut
9nut / filter.rc
Created January 26, 2019 03:02
Prime Sieve - Plan 9 rc script
# prime sieve based on https://swtch.com/~rsc/talks/threads07/
# primes appear on stderr
# example:
# seq 2 100 | filter
fn filter {
p=`{read -n 1}
if (~ $status '') {
echo $p >[1=2]
x=`{read -n 1}
@9nut
9nut / megachess_odroidgo.ino
Created November 2, 2018 05:42
Megachess M5stack adapted to ODROID GO
//ArduinoMega Chess 1.0 M5Stack
//engine 1.4
//Sergey Urusov, ususovsv@gmail.com
//
// Adapted to ODROID GO
#include <odroid_go.h>
#include <Preferences.h>
Preferences prefs;
; Example for the following 8-bit machine simulator
; http://schweigi.github.io/assembler-simulator/index.html
; Enumerate numbers from zero to [C]
start:
MOV C, 10 ; C = 10
MOV D, 232 ; D = 232 ; D is set to output memory location
CALL counter ; enumerate from 0 to C, output to *D
HLT ; Stop execution
; Examples for this simulator
; http://schweigi.github.io/assembler-simulator/index.html
; sum up numbers in the range from-to
JMP start
from: DB 1
to: DB 22
sum: DB 0
start: