Skip to content

Instantly share code, notes, and snippets.

@srcreigh
srcreigh / diagnostics.zig
Last active February 18, 2026 18:43
Zig union(enum)-based diagnostics
// =============================================================================
// diagnostics.zig: Generic union(enum) Diagnostics error
// payloads library
//
// MIT LICENSE (C) 2026 Shane Creighton-Young
//
// Project Link: https://gist.github.com/srcreigh/1d05f1e74150e9c50938c1b6e7bcdff6
//
// HOW TO USE
// - Read the article https://srcreigh.ca/posts/error-payloads-in-zig/
@srcreigh
srcreigh / m3-arm-k3s-cilium-kata-qemu-guide.md
Created October 22, 2025 22:00
M3 MacBook Pro - Ubuntu VM running k3s/cilium/kata-qemu

Install tart to get a ubuntu VM with nested vert.

brew install cirruslabs/cli/tart
tart clone ghcr.io/cirruslabs/ubuntu:latest ubuntu
tart run ubuntu --nested

SSH in

import json
import traceback
from mitmproxy import ctx, http
def response(flow: http.HTTPFlow) -> None:
assert flow.response is not None
assert flow.response.content is not None
if (flow.request.method, flow.request.host) != ("POST", "gql-fed.reddit.com"):
return
@srcreigh
srcreigh / errors.rkt
Created September 4, 2021 02:24
Display multiple syntax errors in Racket
#lang racket/base
(require racket/list)
(provide report-all-errors
save-error-message)
;; Taken from Typed Racket codebase tc-util.rkt
(define-struct err (msg stx) #:prefab)
(define delayed-errors null)
@srcreigh
srcreigh / syntax-error.rkt
Created February 2, 2021 23:19
How to add static compilation errors to Racket
#lang racket/base
(require (for-syntax racket/base syntax/parse))
(define-syntax (error stx)
(syntax-parse stx
[(_ ...) (raise-syntax-error #f "This is an error." stx)]))
;; The following line will be highlighted in the IDE and say "This is an error."
;; in DrRacket or racket-xp-mode for emacs.
(error 'hi)
@srcreigh
srcreigh / who-needs-latex.txt
Created January 14, 2016 20:49
notes from my compiler construction course
January 14, 2016
Thursday
COMPILER CONSTRUCTION
1. TOKENS AND KINDS
===================
from xml.dom import minidom
import json
xmldoc = minidom.parse('changelogs.xml')
items = []
itemsxml = xmldoc.getElementsByTagName('string-array')
versions = itemsxml[0].getElementsByTagName('item')
dates = itemsxml[1].getElementsByTagName('item')
descs = itemsxml[2].getElementsByTagName('item')
public static final int ITEM_VIEW_TYPE_LARGE = 0;
public static final int ITEM_VIEW_TYPE_SMALL = 1;
@Override
public int getItemViewType(int position) {
if (isCategoryLarge(categories.get(position)) {
return ITEM_VIEW_TYPE_LARGE;
} else {
return ITEM_VIEW_TYPE_SMALL;
package com.hackthenorth.android.util;
import android.animation.Animator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.view.View;
/**
* "Because, honestly, why isn't android.animation.ViewPropertyAnimator an Animator in
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/listview_background_shape" >
<item android:drawable="@drawable/card_background" />
<item>
<shape>
<padding
android:bottom="12dp"
android:left="12dp"
android:top="12dp"