Skip to content

Instantly share code, notes, and snippets.

View maxsei's full-sized avatar

Maximillian Schulte maxsei

View GitHub Profile
@maxsei
maxsei / README.md
Created July 9, 2026 17:19
cloudflare worker cancellation and request completion

cf-disconnects

The idea of this experiment is to show that even if a client disonnects from a coudflare worker, the request will run to completion. To test that this is the case you can spam the sleep button in the UI which will cause the current in progress request to be cancelled by datastar. However, if you check the logs, you will see that sleeping will start and finish successfully.

{ reqId: 'dfacc03c-93e1-41eb-849b-999894e0628d', sleeping: 'start' }
{ reqId: 'dfacc03c-93e1-41eb-849b-999894e0628d', sleeping: 'end' }
{ reqId: 'ffecc601-3a04-4799-9812-58d30362c10c', sleeping: 'start' }
{ reqId: 'ffecc601-3a04-4799-9812-58d30362c10c', sleeping: 'end' }
{ reqId: '29183137-cd48-400c-b3f5-431e6bbf4df2', sleeping: 'start' }
@maxsei
maxsei / index.html
Last active July 3, 2026 18:08
editable select box
<html data-theme="light">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Combobox</title>
<link
rel="stylesheet"
href="https://unpkg.com/open-props@1.7.23/normalize.min.css"
/>
<link
@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; };
# }