Skip to content

Instantly share code, notes, and snippets.

@dtornow
dtornow / foo.py
Created August 27, 2025 11:39
Getting Started
# run with uv run --with 'resonate-sdk>=0.6.2' foo.py
from resonate import Resonate, Context
resonate = Resonate.local()
@resonate.register
def foo(ctx, greeting):
print("running foo")
# async
@dtornow
dtornow / sim.py
Created March 3, 2025 17:21
Minimal Distributed Systems Simulator
from typing import List, Any, Callable
class FilterableList(List[Any]):
def remove(self, predicate: Callable[[Any], bool]) -> List[Any]:
removed = [item for item in self if predicate(item)]
self[:] = [item for item in self if not predicate(item)]
return removed
@dtornow
dtornow / benchmark.py
Created July 25, 2024 17:03
Batching Benchmark
import sqlite3
import time
import os
def create_table(conn):
conn.execute('''CREATE TABLE IF NOT EXISTS benchmark (id INTEGER PRIMARY KEY, value TEXT)''')
conn.commit()
def non_batched_insert(conn, n):
for i in range(n):
@dtornow
dtornow / rename.md
Created March 30, 2023 18:55
Rename PDF Document

Rename PDF Document

Simple script to rename a pdf document to its most likely title via openai, written by, you guessed, openai :)

You will need an openai key

Why

I like to read and collect a lot of papers, but they almost always come with names like 0909.1788.pdf, so I rename each and every one.

@dtornow
dtornow / file.md
Last active January 15, 2021 14:04

For each Node N, Daemon D, Pod P, and Container C of P

  • if N hosts D and N hosts P and P's address is a and C listens on port p then
    • if there is a Send Event observed at D with a target-address a and a target-port p then
  • there is a Recv Event observed at C with a target-address a and a target-port p
Ref(Rollbinding, Role) ≝
∧ RoleBinding.RoleRef.Kind = Role.Kind
∧ RoleBinding.RoleRef.Name = Role.Name
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: GrowPods
subjects:
- kind: Group
name: Editor
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: ClusterRole
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: SowChaos
namespace: default
subjects:
- kind: ServiceAccount
name: ChaosMonkey
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: default
name: SowChaos
rules:
- apiGroups: [""] # indicates the core API group
resources: ["pods"]
verbs: ["list", "delete"]
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: GrowPods
rules:
- apiGroups: [""] # indicates the core API group
resources: ["pods"]
verbs: ["*"]