Skip to content

Instantly share code, notes, and snippets.

View quad's full-sized avatar

Scott Robinson quad

View GitHub Profile
@quad
quad / transcript.md
Last active January 3, 2025 12:36
Nintendo Opus to Xiph Converter (Claude 3.5 Sonnet)
vgmstream/src/meta/opus.c
#include "meta.h"
#include "../coding/coding.h"
#include "../layout/layout.h"
#include "opus_interleave_streamfile.h"

/* Nintendo OPUS - from Switch games, including header variations (not the same as Ogg Opus) */
@quad
quad / 0-design.md
Last active October 3, 2024 21:37
A heterodox sketch of supervisor trees in Rust

cinch: supervisor trees for Rust

Constraints

  1. Intra-task concurrent, because the child tasks can opt-in to multi-task concurrency.

Types

pub trait Service {
@quad
quad / example-yubikey-secp256k1.py
Created July 7, 2024 21:15
How to sign messages with secp256k1 on a YubiKey
from cryptography.hazmat.primitives.asymmetric.ec import ECDSA
from cryptography.hazmat.primitives.hashes import SHA256
from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat
from ykman.device import list_all_devices
from ykman.logging import init_logging
from yubikit.core import TRANSPORT
from yubikit.core.smartcard import SmartCardConnection
from yubikit.logging import LOG_LEVEL
from yubikit.management import CAPABILITY
from yubikit.openpgp import EcAttributes, KEY_REF, OID, OpenPgpSession
@quad
quad / Code.gs
Last active March 7, 2025 12:59
Block out work calendar from personal calendar
function sync() {
const srcId = "[email protected]";
const syncWindowInDays = 7;
const syncStatuses = [
null,
CalendarApp.GuestStatus.MAYBE,
CalendarApp.GuestStatus.OWNER,
CalendarApp.GuestStatus.YES,
];
@quad
quad / 0-a-logging-api.md
Last active September 13, 2024 06:40
Don't use log levels, use structured logging [DRAFT]

Don't use log levels, use structured logging

I read [an argument for only two log levels: INFO and ERROR][only-info-error]. I [responded][log-response] essentially saying:

  1. I lightly agree that we could get away with two log levels.
  2. I strongly disagree that we only need two ways to log.

Like the blog post's author, most of systems that I've worked on have had poor logging practices. But unlike the blog post's author, I strongly suspect that's because most logging APIs offer poor affordances.

@quad
quad / 0-hybrid-service-architecture.md
Last active March 16, 2024 02:04
The Hybrid Service Architecture

The Hybrid Service Architecture

I haven't found a description of the service architecture I frequently see; but, the Internet is lousy with descriptions of three tier and event driven architectures.

This write-up is for Future Me to point at when asked how to design a network service.

tl;dr

  • A server cluster, scaled horizontally
  • A queue cluster, scaled vertically or sharded
@quad
quad / 0-unnamed-architecture.md
Last active April 14, 2024 05:45
What is this architecture called?

What is this architecture called?

I rarely see the classical three-tier architecture in the wild; I frequently see a different architecture.

I don't know this architecture's name. Do you?

The Three-Tier Architecture

The "three-tier architecture" has been the reference pattern for Internet services:

@quad
quad / classics.md
Created December 29, 2023 10:09
The Classics
@quad
quad / 0-service-start.md
Last active December 13, 2023 09:17
Why can't I start a service?

Why can't I start a service?

  • I can start a thread, if I want shared memory parallelism
  • I can start a process, if I want shared storage parallelism
  • I cannot start a service, if I want shared network parallelism

What would it take to add a start API?

Overly literal examples

@quad
quad / 0-interceptors-are-functions-too.md
Last active April 10, 2024 09:06
Interceptors Are Functions Too

Interceptors Are Functions Too

I could not agree more with my colleague and friend Travis Johnson's opinion that "[INTERCEPTORS ARE SO COOL][iasc]!" In that post, he succinctly describes the [Interceptor pattern][pattern] as used adroitly by [OkHttp][okhttp]. But, as is often the case, I believe a complicated object-oriented pattern obscures the simple functional gem within it.

What is an Interceptor?

I'll quote liberally from [OkHttp's documentation on the topic][okhttp-interceptor]:

Interceptors are a powerful mechanism that can monitor, rewrite, and retry calls. […] >