Simon Willison’s Weblog

Subscribe

March 2021

72 posts: 13 entries, 15 links, 3 quotes, 41 beats

March 15, 2021

sqlite-spellfix (via) I really like this pattern: “pip install sqlite-spellfix” gets you a Python module which includes a compiled (on your system when pip install ran) copy of the SQLite spellfix1 module, plus a utility variable containing its path so you can easily load it into a SQLite connection.

# 2:52 am / python, sqlite

sqlite-uuid (via) Another Python package that wraps a SQLite module written in C: this one provides access to UUID functions as SQLite functions.

# 2:55 am / python, sqlite, uuid

Release django-sql-dashboard 0.2a1 — Django app for building dashboards using raw SQL queries
Release django-sql-dashboard 0.2a2 — Django app for building dashboards using raw SQL queries
Release django-sql-dashboard 0.3a0 — Django app for building dashboards using raw SQL queries

VIAL is now live, plus django-sql-dashboard

Our new Django backend has now officially graduated from preview mode! We’ve been running it to collect caller reports for Oregon for over a week now, and today we finally turned off the old Heroku app and promoted https://vial.calltheshots.us/ to be the place that our caller app writes to.

[... 672 words]

March 16, 2021

Release django-sql-dashboard 0.3a1 — Django app for building dashboards using raw SQL queries

March 17, 2021

logpaste (via) Useful example of how to use the Litestream SQLite replication tool in a Dockerized application: S3 credentials are passed to the container on startup, it then attempts to restore the SQLite database from S3 and starts a Litestream process in the same container to periodically synchronize changes back up to the S3 bucket.

# 3:48 pm / replication, s3, sqlite, docker, litestream

When you have to mock a collaborator, avoid using the Mock object directly. Either use mock.create_autospec() or mock.patch(autospec=True) if at all possible. Autospeccing from the real collaborator means that if the collaborator's interface changes, your tests will fail. Manually speccing or not speccing at all means that changes in the collaborator's interface will not break your tests that use the collaborator: you could have 100% test coverage and your library would fall over when used!

Thea Flowers

# 4:44 pm / mocking, python, testing

March 18, 2021

How we found and fixed a rare race condition in our session handling. GitHub had a terrifying bug this month where a user reported suddenly being signed in as another user. This is a particularly great example of a security incident report, explaining how GitHub identified the underlying bug, what caused it and the steps they are taking to ensure bugs like that never happen in the future. The root cause was a convoluted sequence of events which could cause a Ruby Hash to be accidentally shared between two requests, caused as a result of a new background thread that was introduced as a performance optimization.

# 11:06 pm / github, security, threads

March 19, 2021

Release django-sql-dashboard 0.4a0 — Django app for building dashboards using raw SQL queries
Release datasette-auth-passwords 0.4 — Datasette plugin for authentication using passwords

March 20, 2021

Release datasette-publish-vercel 0.9.2 — Datasette plugin for publishing data using Vercel

March 21, 2021

Release django-sql-dashboard 0.4a1 — Django app for building dashboards using raw SQL queries

GitHub, by default, writes five replicas of each repository across our three data centers to protect against failures at the server, rack, network, and data center levels. When we need to update Git references, we briefly take a lock across all of the replicas in all of our data centers, and release the lock when our three-phase-commit (3PC) protocol reports success.

Scott Arbeit

# 12:57 am / github

Weeknotes: django-sql-dashboard widgets

Visit Weeknotes: django-sql-dashboard widgets

A few small releases this week, for django-sql-dashboard, datasette-auth-passwords and datasette-publish-vercel.

[... 1,025 words]

Release django-sql-dashboard 0.4a2 — Django app for building dashboards using raw SQL queries
Release c64 0.1a0 — Experimental package of ASGI utilities extracted from Datasette

March 22, 2021

The Accountability Project Datasettes. The Accountability Project “curates, standardizes and indexes public data to give journalists, researchers and others a simple way to search across otherwise siloed records”—they have a wide range of useful data, and they’ve started experimenting with Datasette to provide SQL access to a subset of the information that they have collected.

# 12:07 am / data-journalism, datasette

Release tableau-to-sqlite 0.2.1 — Fetch data from Tableau into a SQLite database
TIL Running gdb against a Python process in a running Docker container — While investigating [Datasette issue #1268](https://github.com/simonw/datasette/issues/1268) I found myself with a Python process that was hanging, and I decided to try running `gdb` against it based on tips in [Debugging of CPython processes with gdb](https://www.podoliaka.org/2016/04/10/debugging-cpython-gdb/)
TIL Tracing every executed Python statement — Today I learned how to use the Python [trace module](https://docs.python.org/3/library/trace.html) to output every single executed line of Python code in a program - useful for figuring out exactly when a crash or infinite loop happens.
TIL Installing packages from Debian unstable in a Docker image based on stable — For [Datasette #1249](https://github.com/simonw/datasette/issues/1249) I wanted to build a Docker image from the `python:3.9.2-slim-buster` base image ("buster" is the current stable release of Debian) but include a single package from "sid", the unstable Debian distribution.

March 23, 2021

A Complete Guide To Accessible Front-End Components. I’m so excited about this article: it brings together an absolute wealth of resources on accessible front-end components, including many existing component implementations that are accessible out of the box. Date pickers, autocomplete widgets, modals, menus—all sorts of things that I’ve been dragging my heels on implementing because I didn’t fully understand their accessibility implications.

# 1:06 am / accessibility, javascript

TIL Closest locations to a point — Here's a PostgreSQL SQL query that returns the closest locations to a point, based on a brute-force approach where the database calculates the distance (in miles) to every single row and then sorts by that distance.

The Airtable formulas at the heart of everything

While working on building a Counties.json API endpoint for VIAL I realized I wasn’t entirely sure how the “Total reports” and “Yeses” numbers in this piece of JSON were calculated:

[... 323 words]

March 24, 2021

Release iam-to-sqlite 0.1 — Load Amazon IAM data into a SQLite database

Understanding JSON Schema (via) Useful, comprehensive short book guide to JSON Schema, which finally helped me feel like I fully understand the specification.

# 2:57 am / json, jsonschema

Release django-sql-dashboard 0.5a0 — Django app for building dashboards using raw SQL queries
Release sqlite-transform 0.5 — Tool for running transformations on columns in a SQLite database