Skip to content

Instantly share code, notes, and snippets.

View tef's full-sized avatar
💭
Please don't try to contact me over GitHub.

tef tef

💭
Please don't try to contact me over GitHub.
View GitHub Profile
@tef
tef / grimoire.md
Last active January 13, 2025 22:37

Some notes on "Borrow checking, RC, GC, and the Eleven (!) Other Memory Safety Approaches"

https://verdagon.dev/grimoire/grimoire

I've nothing against the post, it just irks me to see a big unorganized list like a pile of christmas tree lights.

It's an interesting blog post with comprehensive references, but it's also like a travel brochure with a list of destinations. In practice you want something more like a route map: A rough overview of how different approaches complement each other, or overlap each other. A jigzaw puzzle is much easier to solve when there's a picture on the front of the box.

Here's a modest propsoal for a better table of contents:

fair, fine grained, and deadlock free locking

first, a spin lock

you know what a spinlock is, right?

here's a spinlock:

@tef
tef / histo.md
Created November 30, 2024 23:46

to be clear: histogram diff doesn't work like patience diff

By always selecting a LCS position with the lowest occurrence count, this algorithm behaves exactly like Bram Cohen's patience diff whenever there is a unique common element available between the two sequences.

This isn't true. It behaves the same when all unique tokens in the first file happen to be unique tokens in the second file. If the unique tokens in the first file aren't unique in the second file, histogram doesn't work like patience at all:

% cat a
2
@tef
tef / undo.py
Last active February 11, 2025 13:12
"""
a write-ahead-log with undo and redo
undo and redo can be implemented atop list of actions, where
each new action adds onto the list, and undo removes it from
the list, and updates the predecessor with the new redo option,
and redo does the opposite process
say we have some history:
func MakeFunc(out any) error {
handle := func(args []any) ([]any, error) {
// the func we're wrapping
return args
}
outFn := reflect.ValueOf(out).Elem()
outType := outFn.Type()
from contextlib import contextmanager
class Node:
def __init__(self, name, args, children):
self.name = name
self.args = args
self.children = children
def __str__(self):
out = []
@tef
tef / photo.md
Last active January 19, 2024 03:24

Blockquotes are awful in markdown, because they're semi optional in continuation lines.

There are three options i've considered:


Option A: Blockquote at start of para, and on every continuation line.

> a

Here is an indented block:

One Space, One Tab
One Tab
 One Tab, One Space.
 Five Spaces

Now prefixed with '> ', Here the's the indented block:

'> ', One Space, One Tab