Skip to content

Instantly share code, notes, and snippets.

View quad's full-sized avatar

Scott Robinson quad

View GitHub Profile
@quad
quad / 0-modular-errors-with-rusts-thiserror.md
Last active September 22, 2024 02:32
Modular Errors with Rust's thiserror

I've been writing Rust full-time with a small team for over a year now. Throughout, I've lamented the lack of clear best practices around defining error types. One day, I'd love to write up my journey and enumerate the various strategies I've both seen and tried. Today is not that day.

Today, I want to reply to a blog post that almost perfectly summarised my current practice.

Go read it; I'll wait!


@quad
quad / 0-design.md
Created September 15, 2024 05:19
A heterodox sketch of supervisor trees in Rust

cinch: supervisor trees for Rust

Constraints

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

Problem Encountered

Matching -> impl Future with <F: Future>

Owning Future Lifetimes

@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 / Code.gs
Last active August 21, 2024 00:29
Block out work calendar from personal calendar
function sync() {
const srcId = "you@example.com";
const syncWindowInDays = 7;
const syncStatuses = [
CalendarApp.GuestStatus.MAYBE,
CalendarApp.GuestStatus.OWNER,
CalendarApp.GuestStatus.YES,
];
const now = new Date();
@quad
quad / update.sh
Last active August 20, 2024 16:36
Idempotent macOS development meta-environment configuration
#!/bin/zsh
set -euo pipefail
start_sudo_session() {
sudo --validate
while :; do
kill -0 $$ &>/dev/null
sudo --non-interactive --validate
@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 / 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 / 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. […] >

@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 / hey.rb
Created December 8, 2012 19:04
hey! a minimalist CRM
#!/usr/bin/env ruby
#
# hey! a minimalist CRM for http://todotxt.com/
#
# hey tells you one thing you should do regularly, but haven't done lately.
#
# $ todo.sh lf hey
# 1 @phone Mom (+1 234 567 8901) +family
# 2 @skype Dad +family
# 3 @email mentor