til

320 posts tagged “til”.

  1. 2025
  2. Packaging a Python CLI tool for Homebrew

    I finally figured out how to package Datasette for installation with Homebrew. My package was accepted into Homebrew core, which means you can now install it like this: brew install datasette Prior to…

    2 min read
  3. struct endianness in Python

    TIL the Python standard library struct module defaults to interpreting binary strings using the endianness of your machine. Which means that this code: Behaves differently on big-endian v.s.

    1 min read
  4. Using tree-sitter with Python

    tree-sitter is a "parser generator tool and an incremental parsing library". It has a very good reputation these days.

    1 min read
  5. Identifying column combination patterns in a SQLite table

    Given a large, heterogeneous table I wanted to identify patterns in the rows in terms of which columns were not null.

    1 min read
  6. Using macOS stickies to display a workshop link on the screen

    When giving a workshop it's often useful to have a URL to the workshop materials visible on screen at all times. I use a bit.ly link for these.

    1 min read
  7. Reformatting text with Copilot

    I wanted to write alt text for the following screenshot (of this page), so I could include it in this post on Mastodon.

    1 min read
  8. Snapshot testing with Syrupy

    I'm a big fan of snapshot testing - writing tests where you compare the output of some function to a previously saved version, and can re-generate that version from scratch any time something changes.

    2 min read
  9. Testing a Click app with streaming input

    For sqlite-utils 364 I needed to write a test for a Click app which dealt with input streamed to standard input.

    1 min read
  10. Running Varnish on Fly

    The goal: run Varnish in a Fly container as a caching proxy in front of another Fly application. I ended up switching to Cloudflare for running a Varnish-style cache in front of my Fly application…

    1 min read
  11. Open external links in an Electron app using the system browser

    For Datasette.app I wanted to ensure that links to external URLs would open in the system browser. This recipe works: The event fires before any in-browser navigations, which means they can be…

    1 min read
  12. Ignoring errors in a section of a Bash script

    For simonw/museums 32 I wanted to have certain lines in my Bash script ignore any errors: lines that used to add columns and configure FTS, but that might fail with an error if the column already…

    1 min read
  13. Mocking a Textract LimitExceededException with boto

    For s3-ocr issue 21 I needed to write a test that simulates what happens when Amazon Textract returns a "LimitExceededException".

    1 min read
  14. Upgrading a Heroku PostgreSQL database with pg:copy

    Figured this out in https://github.com/simonw/simonwillisonblog/issues/132 - I was running PostgreSQL 9.x and I wanted 11.x in order to use the new option in Django 3.1.

    1 min read
  15. Using llama-cpp-python grammars to generate JSON

    llama.cpp recently added the ability to control the output of any model using a grammar. This is an incredibly powerful technique for working with a Large Language Model.

    3 min read
  16. Redirecting a whole domain with Cloudflare

    I had to run this site on for 24 hours due to a domain registration mistake I made. Once I got working again I wanted to permanently redirect the URLs on the temporary site to their equivalent on the…

    1 min read
  17. Using io.BufferedReader to peek against a non-peekable stream

    When building the –sniff option for (which attempts to detect the correct CSV delimiter and quote character by looking at the first 2048 bytes of a CSV file) I had the need to peek ahead in an…

    1 min read
  18. Using custom Sphinx templates on Read the Docs

    I wanted to make a small customization to one of my documentation templates on Read the Docs. It turns out you can over-ride the default templates by creating a directory in your documentation folder…

    1 min read
  19. Publishing a simple client-side JavaScript package to npm with GitHub Actions

    The code is in simonw/prompts-js on GitHub. The NPM package is prompts-js. A simple single file client-side package For this project, I wanted to create an old-fashioned JavaScript file that you could…

    2 min read
  20. Streaming output of an indented JSON array

    For paginate-json I wanted to implement streaming output of an indented JSON array to my terminal. The final output should look like this: But I needed this to work for an arbitrarily long sequence of…

    2 min read
  21. Testing against Python 3.11 preview using GitHub Actions

    I used the new GitHub Code Search to figure out how to do this. I searched for: 3.11 path:workflows/ .yml And found this example from which showed that the version tag to use is: 3.11-dev Update 28th…

    1 min read