Skip to content

Instantly share code, notes, and snippets.

View aboisvert's full-sized avatar

Alex Boisvert aboisvert

View GitHub Profile
@aboisvert
aboisvert / abstraction-SKILL.md
Created September 14, 2026 22:39
abstraction-SKILL.md

A high-quality abstraction simplifies a system without misrepresenting how it behaves. It hides incidental implementation detail while preserving the semantics, constraints, failure modes, and material costs that clients need to use it correctly.

There is no universal scalar measure of abstraction quality. It is purpose-relative: the right abstraction for a one-off local tool may differ from the right one for a long-lived distributed platform API. But a robust evaluation usually spans the dimensions below.

Practical quality model

Dimension Core question What good looks like Typical failure
Leakiness and fidelity Does the simplified interface accurately predict relevant real behavior? Clients need not understand internals for normal correctness; consequential costs, failures, and limits are explicit A “simple” API conceals network calls, unbounded work, transaction boundaries, or retry behavior until production
Orthogonality and minimality Does the interface
@aboisvert
aboisvert / instructions.md
Created May 26, 2026 21:00
Instructions to show that Metals doesn't recompile a project upon restart
  1. Clone this random scala repository (just one of my open-source scala projects)

     % git clone https://github.com/aboisvert/hotmetal.git
    
  2. Open the project in VSCode

     % cd hotmetal
     % code .
    
  3. When prompted, click Import build

@aboisvert
aboisvert / preventNestedTransaction.scala
Created February 17, 2025 01:49
Illustration of using Scala macro to statically prevent nested transactions using the scalasql library
// See https://github.com/com-lihaoyi/scalasql
import scalasql.*
/** Shorthand for delimited transaction:
*
* ```
* db.txn:
* val data = runSomeQuery()
* doSomeUpdate(...)
* ```
@aboisvert
aboisvert / fish-heredoc-example.fish
Last active January 18, 2021 18:51
Example workaround for the lack of native "heredoc" support in fish shell
#!/usr/bin/env fish
#
# Example working with 'heredoc' documents
#
# Recommended: Define the heredoc using single quotes
#
# Use the `fish-heredoc-quote` script to generate quoted document
#
import zip/zlib
import streams
const BufferSize = 16384*2
type
GZipInputStream* = ref GZipInputStreamObj
GZipInputStreamObj* = object of Stream
source: Stream
zstream: ZStream
type
SharedString* = object
str: cstring
proc newSharedString*(s: string): SharedString =
result = SharedString(str: cast[cstring](allocShared(s.len + 1)))
copyMem(result.str, s.cstring, s.len)
proc deallocSharedString*(s: SharedString) =
deallocShared(s.str)
@aboisvert
aboisvert / avxcount.nim
Last active August 21, 2023 10:59
Nim port of Daniel Lemire's fast newline count `avxcount` .
# Nim port of Daniel Lemire's fast newline count `avxcount`
#
# See https://lemire.me/blog/2017/02/14/how-fast-can-you-count-lines/
# https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/blob/master/2017/02/14/newlines.c
import os, memfiles, times, strutils
{.passc: "-march=native".}
{.pragma: imm, header:"immintrin.h".}
import os, sets, hashes, strutils, sequtils
type
HString = object
str: string
hash: Hash
proc hash*(str: HString): Hash =
str.hash
import strutils
const SHA512Len = 64
proc SHA512(d: cstring, n: culong, md: cstring = nil): cstring {.cdecl, dynlib: "libssl.dylib", importc.}
proc SHA512(s: string): string =
result = ""
let s = SHA512(s.cstring, s.len.culong)
for i in 0 .. < SHA512Len:

sudo apt-get install compiz-plugins # needed for ring switcher and such.