til

320 posts tagged “til”.

  1. 2023
  2. Passing command arguments using heredoc syntax

    This trick works for both Bash and zsh. I wanted to pass the following as an argument to the sqlite-utils CLI tool: Problem: this contains both single AND double quotes, which makes string escaping a…

    1 min read
  3. Loading SQLite extensions in Python on macOS

    I finally found a workaround for this error when attempting to load a SQLite extension in Python on macOS: The fix is to install Python using Homebrew, and then use that version of Python.

    1 min read
  4. Using packages from JSR with esbuild

    JSR is a brand new package repository for "modern JavaScript and TypeScript", launched on March 1st by the Deno team as a new alternative to npm My JavaScript ecosystem fluency isn't great, so it took…

    3 min read
  5. Interpreting photo orientation and locations in EXIF data

    I upgraded my Niche Museums site to use PhotoSwipe for its photo galleries today. Here's my issue. This lead me down a bit of a rabbit hole of photo EXIF data.

    3 min read
  6. Relinquishing control in Python asyncio

    in Python is a form of co-operative multitasking, where everything runs in a single thread but asynchronous tasks can yield to other tasks to allow them to execute.

    1 min read
  7. Shrinking PNG files with pngquant and oxipng

    I usually use Squoosh.app to reduce the size of my PNGs, but in this case I had a folder with nearly 50 images in it so I wanted to do it using the command-line.

    1 min read
  8. Using the Chrome DevTools console as a REPL for an Electron app

    I figured out how to use the Chrome DevTools to execute JavaScript interactively inside the Electron main process.

    1 min read
  9. Using pysqlite3 on macOS

    While trying to use pysqlite3 on macOS I got the following error: Thanks to this tip on Stack Overflow I found that installing a fresh SQLite with and then running the following first fixed the error…

    1 min read
  10. Ignoring a line in both flake8 and mypy

    I needed to tell both and to ignore the same line of code. This worked: The order here mattered. This did not get picked up by both tools: noqa: F401 type: ignore But this did: type: ignore noqa: F401

    1 min read
  11. Using pipenv and Docker

    I had a Django project that used (in particular a ) to manage dependencies and I wanted to build a Docker container for it.

    1 min read
  12. Programatically accessing Heroku PostgreSQL from GitHub Actions

    My db-to-sqlite tool can connect to a PostgreSQL database, export all of the content and write it to a SQLite database file on disk.

    1 min read
  13. Testing HTML tables with Playwright Python

    I figured out this pattern today for testing an HTML table dynamically added to a page by JavaScript, using Playwright Python: there is a fixture that starts Datasette running on a local port and…

    1 min read
  14. Use setup.py to install platform-specific dependencies

    For photos-to-sqlite I needed to install as a dependency, but only if the platform is macOS - it's not available for Linux. Here's the magic incantation to do that: So in the install requires line.

    1 min read
  15. Running nanoGPT on a MacBook M2 to generate terrible Shakespeare

    nanoGPT is Andrej Karpathy's "simplest, fastest repository for training/finetuning medium-sized GPTs".

    2 min read
  16. Running tests against PostgreSQL in a service container

    I wanted to run some Django tests - using and with Django configured to pick up the environment variable via dj-database-url - against a PostgreSQL server running in GitHub Actions.

    1 min read
  17. Tommy's Margarita

    A few years ago I decided to learn how to make some classic cocktails. It is a very rewarding hobby. Of all of the drinks that I have learned to make, by far the biggest crowd pleaser is the Tommy's…

    2 min read
  18. nullglob in bash

    I ran into a tricky problem while working on this issue: the following line was behaving in an unexpected way for me: datasette content.db .db –create What I expect this to do is to create a database…

    1 min read
  19. Language-specific indentation settings in VS Code

    When I'm working with Python I like four space indents, but for JavaScript or HTML I like two space indents. Today I figured out how to teach VS Code those defaults. 1.

    1 min read
  20. Writing tests with Copilot

    I needed to write a relatively repetitive collection of tests, for a number of different possible error states.

    1 min read
  21. Running prompts against images, PDFs, audio and video with Google Gemini

    I'm still working towards adding multi-modal support to my LLM tool. In the meantime, here are notes on running prompts against images and PDFs and audio and video files from the command-line using…

    3 min read