Skip to content

Instantly share code, notes, and snippets.

View maxsei's full-sized avatar

Maximillian Schulte maxsei

View GitHub Profile
@maxsei
maxsei / index.ts
Last active June 20, 2026 00:17
discriminated union matching
type AnyVariant = { type: string };
type PayloadOf<U extends AnyVariant, K extends U["type"]> =
Extract<U, { type: K }> extends infer Member
? Member[K & keyof Member]
: never;
type Handler<U extends AnyVariant, R> = {
[K in U["type"]]: (payload: PayloadOf<U, K>) => R;
};
@maxsei
maxsei / index.html
Last active June 18, 2026 05:02
CSS page transitions API
<!-- templates/index.html -->
{{ template "layout" . }}
{{ define "title" }}Home{{ end }}
{{ define "content" }}
<h1>Home</h1>
@maxsei
maxsei / main.go
Created June 17, 2026 20:06
delay showing load spinner with datastar
package main
import (
"log"
"math/rand"
"net/http"
"time"
"github.com/starfederation/datastar-go/datastar"
)
export type JsonObject = { [key: string]: Jsonifiable };
export type Jsonifiable =
| string
| number
| boolean
| null
| undefined
| Jsonifiable[]
| JsonObject;
@maxsei
maxsei / main.ts
Created June 6, 2026 17:03
typed wrangler injection
import {
unstable_readConfig,
unstable_convertConfigBindingsToStartWorkerBindings,
} from "wrangler";
import * as fs from "node:fs";
import * as z from "zod";
import tmp from 'tmp';
const WranglerOverrides = z.object({
@maxsei
maxsei / main.js
Created June 6, 2026 13:47
how to use data external scripts in terraform
console.log(
JSON.stringify({
result: "hello world",
json: JSON.stringify({
hello: "world",
}),
}),
);
#!/usr/bin/env python3
from pathlib import Path
import os
from typing import List
from typing import TypedDict
src = Path("/home/mschulte/Videos/39th-gate-music-video")
dst = Path("/tmp/nix-shell.i4wVnT/tmp.0BRU2RIDOa/overlays")
max_size_mb = 10_000
# nix-kube-generators.url = "github:farcaller/nix-kube-generators";
# ...
# pkgs = import nixpkgs {
# inherit system;
# overlays = [
# (final: prev: {
# lib = prev.lib.extend (
# _: _: {
# kube = nix-kube-generators.lib { pkgs = final; };
# }
klib = nixidy.inputs.nix-kube-generators.lib { inherit pkgs; };
find-crds =
chart:
let
crd-filepath-file =
pkgs.runCommand "find-crds"
{
nativeBuildInputs = with pkgs; [
ripgrep
$ kubectl get svc --all-namespaces | rg 105
kubectl get svc --all-namespaces
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
authelia authelia ClusterIP 10.43.211.45 <none> 80/TCP 3h25m
default docker-registry ClusterIP 10.43.48.244 <none> 5000/TCP 7d1h
default kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 27d
demo postgres ClusterIP 10.43.120.212 <none> 5432/TCP 3h25m
demo trade ClusterIP 10.43.136.135 <none> 80/TCP 3h25m
demo2 drawback-backend ClusterIP 10.43.86.192 <none> 8000/TCP 3h18m
demo2 drawback-frontend ClusterIP 10.43.113.133 <none> 80/TCP