Nat Knight

Reflections, diversions, and opinions from a progressive ex-physicist programmer dad with a sore back.

#web #hypertext

Or “how you can link to arbitrary text on a webpage”.

The syntax is a little weird, but you can add a specially formatted anchor to a URL to link to a snippet of text.

The syntax is:

https://example.com#:~:text=[prefix-,]textStart[,textEnd][,-suffix]

I find it particularly useful for linking to a quote in a longer article.

See MDN for the full documentation.

#til #python #uv

(via epistasis on HN)

Semantic versioning is difficult. Not everyone has the same idea of what “breaking change” means, and depending on your language and tooling “breaking” changes can sneak in despite your best efforts.

One possible mitigation is to record when you resolved your dependencies and ignore anything published after that date. It's crude, and relies on package dependencies not monkeying with stuff that's already been published, but it's easy to understand and you can do it with uv.

It's documented here.

Put a date in your pyproject.toml file and subsequent invocations of uv will ignore anything published after the cutoff:

[tool.uv]
exclude-newer = "2023-10-16T00:00:00Z"

You can also use it in the “inline metadata” format for scripting! From the uv docs:

# /// script
# dependencies = [
#   "requests",
# ]
# [tool.uv]
# exclude-newer = "2023-10-16T00:00:00Z"
# ///

import requests

print(requests.__version__)

This use case seems particularly valuable: if I write a quick script I probably care more about it not breaking than I care about it getting updated dependencies. It's nice that uv offers a way to keep code running rather than forcing me to update it or throw it out.

#links #languagemodels #art #writing

Jamie Brew of Botnik gave a talk at Strange Loop 2023 called Comedy Writing with Small Generative Models.

The talk itself was very entertaining, with musical interludes mashing up “the Beatles” and “Craigslist ads for vehicles”, and while the algorithms were (by Jamie's own admission) pretty straightforward, there was a lot of room for expression in finding good corpuses, mashing them up, and finding fun ways to apply them.

It was an excellent reminder to me that there's an entire world of stuff you can do with computers that isn't commercial, isn't “hard tech” or “cutting edge” but is nevertheless utterly delightful.

#til #s3 #dockercompose

I had to update a Django service to use S3 instead of local file storage recently. Here's how I set up Minio (a self-hostable S3-compatible data store) for local development.

Read more...

#til #llms #claude #modelcontextprotocol

I was checking out the Model Context Protocol, a spec from Anthropic that lets you expose external programs to an LLM, and discovered that you can extend the Claude desktop app in this way. There are a bunch of enterprisey tools (and you can write your own, more interesting stuff), but out-of-the box you can enable URL-fetching, which lets you grab and process arbitrary information with Claude.

Read more...

#python #llm #embeddings #release #simonwillison

I just released version 0.1 of a plugin for Simon Willison's llm called llm-questioncache. It lets you send questions to your default LLM with a system prompt that elicits short, to-the-point answers. It also maintains a cache of answers locally so that you only have to hit the LLM once for each bit of esoteric knowledge.

Read more...

#til #django #djangorestramework #python

On a recent project I found myself needing one classic form-and-template style page in an otherwise API-driven project. I could, of course, [just do it] with a regular view function, but I had a bunch of authentication and suchlike set up for DRF APIViews.

Turns out it's actually pretty easy to make an APIView kick it oldschool!

Read more...

#helix #python

This article describes how to get the [Helix] text editor set up to be a half-decent Python IDE. You'll need to know a little bit about the command line, but if you're using Helix you'll probably be fine.

Read more...

#jargon #semantics

One way that folks talk about “transparency” is as “organizations should share details of their operations with the people they affect” (employees, customers, the public, etc.). This kind of transparency is good! Being able to see things lets people make informed decisions; not being able to hide things prevents bad behaviour.

However, in computer systems transparency tends to mean something like “replacing a component with a different one that has the same interface but a different implementation”. It's a seductive notion: systems that are designed this way can sometimes have one component change without breaking others, or add capabilities by inserting new components that mesh with what's already there.

Read more...

#rust #functionalprogramming #numericalprogramming

[Functional Pearl: Enumerating the Rationals] is a paper that's been on my “to-read” list for a long time. I finally got around to reading it a while back, and ended up implementing the algorithm it describes and publishing it as a [crate]. This article briefly describes that algorithm and some of the Rust-specific details of implementing it.

Read more...