Simon Willison’s Weblog

Subscribe

April 2020

80 posts: 7 entries, 10 links, 3 quotes, 60 beats

April 16, 2020

How Super Graph compiles GraphQL to a single SQL query. Super Graph is a GraphQL server that compiles arbitrarily nested GraphQL queries to “a single fast SQL query”. I’ve always wondered how that could possible work, so I asked author Vikram Rangnekar for an example of a compiled query—it turns out it uses a brilliant sequence of JSON aggregations to glue together results from nested subqueries and left outer joins.

# 10:52 pm / sql, graphql

April 17, 2020

Release twitter-to-sqlite 0.21 — Save data from Twitter to a SQLite database

April 18, 2020

Release github-to-sqlite 1.1 — Save data from GitHub to a SQLite database

April 19, 2020

Release datasette-publish-vercel 0.4.1a — Datasette plugin for publishing data using Vercel
TIL Only run GitHub Action on push to master / main — Spotted in [this Cloud Run example](https://github.com/GoogleCloudPlatform/github-actions/blob/20c294aabd5331f9f7b8a26e6075d41c31ce5e0d/example-workflows/cloud-run/.github/workflows/cloud-run.yml):
TIL Dump out all GitHub Actions context — Useful for seeing what's available for `if: ` conditions (see [context and expression syntax](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions)).
TIL Set environment variables for all steps in a GitHub Action — From [this example](https://github.com/GoogleCloudPlatform/github-actions/blob/20c294aabd5331f9f7b8a26e6075d41c31ce5e0d/example-workflows/cloud-run/.github/workflows/cloud-run.yml) I learned that you can set environment variables such that they will be available in ALL jobs once at the top of a workflow:
TIL Convert a datetime object to UTC without using pytz — I wanted to convert a datetime object (from GitPython) to UTC without adding the `pytz` dependency.
TIL Commit a file if it changed — This recipe runs a Python script to update a README, then commits it back to the parent repo but only if it has changed:
TIL Running a Python ASGI app on Vercel — Vercel really wants you to deploy static assets with [serverless functions](https://vercel.com/docs/serverless-functions/introduction) tucked away in a separate folder. They suggest creating modules like `api/index.py` which will be served up automatically as API backends to your client-side JavaScript.
TIL Lag window function in SQLite — Here's [how to use a lag window…

April 20, 2020

Using a self-rewriting README powered by GitHub Actions to track TILs

Visit Using a self-rewriting README powered by GitHub Actions to track TILs

I’ve started tracking TILs—Today I Learneds—inspired by this five-year-and-counting collection by Josh Branchaud on GitHub (found via Hacker News). I’m keeping mine in GitHub too, and using GitHub Actions to automatically generate an index page README in the repository and a SQLite-backed search engine.

[... 1,100 words]

TIL Running different steps on a schedule — Say you have a workflow that runs hourly, but once a day you want the workflow to run slightly differently - without duplicating the entire workflow.

Estimating COVID-19’s Rt in Real-Time. I’m not qualified to comment on the mathematical approach, but this is a really nice example of a Jupyter Notebook explanatory essay by Kevin Systrom.

# 3:06 pm / jupyter, covid19

TIL 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.

April 21, 2020

TIL Null case comparisons in SQLite — I wanted to say "output this transformed value if it's not null, otherwise nothing". The recipe I figured out was:
TIL macOS Catalina sort-of includes Python 3 — Once you have installed the "command line tools" for Catalina using the following terminal command:
TIL Running pip install -e .[test] in zsh on macOS Catalina — macOS Catalina uses `zsh` rather than `bash` as the default shell (apparently because Apple don't like GPL 3).
Release datasette-template-sql 1.0 — Datasette plugin for executing SQL queries from templates

April 22, 2020

TIL Use labels on Cloud Run services for a billing breakdown — Thanks to [@glasnt](https://github.com/glasnt) for the tip on this one. If you want a per-service breakdown of pricing on your Google Cloud Run services within a project (each service is a different deployed application) the easiest way to do it is to apply labels to those services, then request a by-label pricing breakdown.
Release github-to-sqlite 2.0 — Save data from GitHub to a SQLite database
TIL Get Skitch working on Catalina — I really like Skitch for taking screeshots, mainly because I like to snap a quick shot and then drag the icon onto a Google Doc or similar without saving the file anywhere.
TIL Close terminal window on Ctrl+D for macOS — I always forget how to set this up. It's hidden in Preferences -> Profiles -> Basic -> Shell:
Release datasette-template-sql 1.0.1 — Datasette plugin for executing SQL queries from templates
Release datasette 0.40 — An open source multi-tool for exploring and publishing data

98.css (via) This is pretty beautiful: a CSS library that meticulously styles HTML form elements to look like the Windows 98 interface.

# 4:22 am / css, windows

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

Weeknotes: Datasette 0.40, various projects, Dogsheep photos

A new release of Datasette, two new projects and progress towards a Dogsheep photos solution.

[... 826 words]

April 23, 2020

TIL Restricting SSH connections to devices within a Tailscale network — I'm running an AWS Lightsail instance and I want to only be able to SSH to it from devices connected to my [Tailscale](https://tailscale.com/) network.

Restricting SSH connections to devices within a Tailscale network. TIL how to run SSH on a VPS instance (in this case Amazon Lightsail) such that it can only be SSHd to by devices connected to a private Tailscale VPN.

# 6:28 pm / security, ssh, tailscale, til

2020 » April

MTWTFSS
  12345
6789101112
13141516171819
20212223242526
27282930