My Today I Learned snippets. Inspired by jbranchaud/til, which I spotted on Hacker News.
Search these TILs at https://til.simonwillison.net/
173 TILs so far. Atom feed here.- Only run GitHub Action on push to master / main - 2020-04-19
- Dump out all GitHub Actions context - 2020-04-19
- Set environment variables for all steps in a GitHub Action - 2020-04-19
- Commit a file if it changed - 2020-04-19
- Running different steps on a schedule - 2020-04-20
- Updating a Markdown table of contents with a GitHub Action - 2020-07-22
- Using grep to write tests in CI - 2020-08-19
- Skipping a GitHub Actions step without failing - 2020-08-22
- Open a debugging shell in GitHub Actions with tmate - 2020-09-14
- Talking to a PostgreSQL service container from inside a Docker container - 2020-09-18
- Using Prettier to check JavaScript code style in GitHub Actions - 2020-12-31
- Running tests against PostgreSQL in a service container - 2021-02-23
- Installing different PostgreSQL server versions in GitHub Actions - 2021-07-05
- Convert a datetime object to UTC without using pytz - 2020-04-19
- macOS Catalina sort-of includes Python 3 - 2020-04-21
- Generated a summary of nested JSON data - 2020-04-28
- Installing and upgrading Datasette plugins with pipx - 2020-05-04
- Use setup.py to install platform-specific dependencies - 2020-05-05
- Build the official Python documentation locally - 2020-05-08
- Introspecting Python function parameters - 2020-05-27
- Password hashing in Python with pbkdf2 - 2020-07-13
- How to call pip programatically from Python - 2020-08-11
- Outputting JSON with reduced floating point precision - 2020-08-21
- Debugging a Click application using pdb - 2020-09-03
- Understanding option names in Click - 2020-09-22
- Explicit file encodings using click.File - 2020-10-16
- Decorators with optional arguments - 2020-10-28
- Running Python code in a subprocess with a time limit - 2020-12-06
- Controlling the style of dumped YAML using PyYAML - 2020-12-07
- Relinquishing control in Python asyncio - 2020-12-29
- Packaging a Python app as a standalone binary with PyInstaller - 2021-01-04
- Handling CSV files with wide columns in Python - 2021-02-15
- Using io.BufferedReader to peek against a non-peekable stream - 2021-02-15
- Tracing every executed Python statement - 2021-03-21
- Running a Python ASGI app on Vercel - 2020-04-19
- Redirecting all paths on a Vercel instance - 2021-03-27
- Lag window function in SQLite - 2020-04-19
- Null case comparisons in SQLite - 2020-04-21
- Compile a new sqlite3 binary on Ubuntu - 2020-04-30
- List all columns in a SQLite database - 2020-05-06
- Using LD_PRELOAD to run any version of SQLite with Python - 2020-06-17
- SQLite BLOB literals - 2020-07-29
- Enabling WAL mode for SQLite database files - 2020-08-09
- Compiling the SQLite spellfix.c module on macOS - 2020-09-19
- Figuring out if a text value in SQLite is a valid integer or float - 2020-09-27
- Replicating SQLite with rqlite - 2020-12-28
- Identifying column combination patterns in a SQLite table - 2021-01-12
- Fixing broken text encodings with sqlite-transform and ftfy - 2021-01-18
- Splitting on commas in SQLite - 2021-02-01
- Querying for items stored in UTC that were created on a Thursday in PST - 2021-03-12
- Using pysqlite3 on macOS - 2021-07-10
- Importing CSV data into SQLite with .import - 2021-07-13
- Running pip install -e .[test] in zsh on macOS Catalina - 2020-04-21
- Get Skitch working on Catalina - 2020-04-21
- Close terminal window on Ctrl+D for macOS - 2020-04-21
- Fixing "compinit: insecure directories" error - 2020-04-26
- Finding the largest SQLite files on a Mac - 2020-08-19
- Shrinking PNG files with pngquant and oxipng - 2021-02-07
- Running Docker on an M1 Mac - 2021-05-25
- Use labels on Cloud Run services for a billing breakdown - 2020-04-21
- How to deploy a folder with a Dockerfile to Cloud Run - 2020-08-04
- Using the gcloud run services list command - 2020-09-01
- Listing files uploaded to Cloud Build - 2021-04-14
- Switching between gcloud accounts - 2021-05-18
- Increasing the time limit for a Google Cloud Scheduler task - 2021-07-08
- Session-scoped temporary directories in pytest - 2020-04-26
- How to mock httpx using pytest-mock - 2020-04-29
- Asserting a dictionary is a subset of another dictionary - 2020-05-28
- Registering temporary pluggy plugins inside tests - 2020-07-21
- Code coverage using pytest and codecov.io - 2020-08-15
- Start a server in a subprocess during a pytest session - 2020-08-31
- Accessing repository dependencies in the GitHub GraphQL API - 2020-04-30
- Paginating through the GitHub GraphQL API with Python - 2020-07-09
- Searching for repositories by topic using the GitHub GraphQL API - 2020-10-09
- Bulk fetching repository details with the GitHub GraphQL API - 2021-01-17
- Syntax highlighting Python console examples with GFM - 2021-01-18
- Constant-time comparison of strings in Node - 2020-05-01
- Search across all loaded resources in Firefox - 2020-05-05
- Converting HTML and rich-text to Markdown - 2020-05-09
- Rendering Markdown with the GitHub Markdown API - 2020-08-22
- Useful Markdown extensions in Python - 2021-04-03
- Adding project links to PyPI - 2020-05-11
- Using heroku pg:pull to restore a backup to a macOS laptop - 2020-07-10
- Upgrading a Heroku PostgreSQL database with pg:copy - 2020-07-20
- Programatically accessing Heroku PostgreSQL from GitHub Actions - 2020-08-18
- Implementing a "copy to clipboard" button - 2020-07-23
- Working around the size limit for nodeValue in the DOM - 2020-08-21
- Dynamically loading multiple assets with a callback - 2020-08-21
- Minifying JavaScript with npx uglify-js - 2020-08-30
- Manipulating query strings with URLSearchParams - 2020-10-04
- Writing JavaScript that responds to media queries - 2020-10-21
- Dropdown menu with details summary - 2020-10-31
- Using Jest without a package.json - 2020-12-30
- Scroll page to form if there are errors - 2021-05-08
- Preventing double form submissions with JavaScript - 2021-07-08
- PostgreSQL full-text search in the Django Admin - 2020-07-25
- Adding extra read-only information to a Django admin change page - 2021-02-25
- Writing tests for the Django admin with pytest-django - 2021-03-02
- Show the timezone for datetimes in the Django admin - 2021-03-02
- Pretty-printing all read-only JSON in the Django admin - 2021-03-07
- How to almost get facet counts in the Django admin - 2021-03-11
- Efficient bulk deletions in Django - 2021-04-09
- Enabling the fuzzystrmatch extension in PostgreSQL with a Django migration - 2021-04-18
- Usable horizontal scrollbars in the Django admin for mouse users - 2021-04-20
- Filter by comma-separated values in the Django admin - 2021-04-21
- Django Admin action for exporting selected rows as CSV - 2021-04-25
- migrations.RunSQL.noop for reversible SQL migrations - 2021-05-02
- Enabling a gin index for faster LIKE queries - 2021-05-16
- Django data migration using a PostgreSQL CTE - 2021-05-17
- Attaching a bash shell to a running Docker container - 2020-08-10
- Running gdb against a Python process in a running Docker container - 2021-03-21
- Installing packages from Debian unstable in a Docker image based on stable - 2021-03-22
- Docker Compose for Django development - 2021-05-24
- Packaging a Python CLI tool for Homebrew - 2020-08-11
- Browsing your local git checkout of homebrew-core - 2020-08-27
- Upgrading Python Homebrew packages using pip - 2020-10-14
- Running a MySQL server using Homebrew - 2021-06-11
- Customizing my zsh prompt - 2020-08-12
- Pointing a custom subdomain at Read the Docs - 2020-08-14
- Read the Docs Search API - 2020-08-16
- Using custom Sphinx templates on Read the Docs - 2020-12-07
- Creating a dynamic line chart with SVG - 2020-08-22
- Piping echo to a file owned by root using sudo and tee - 2020-08-24
- Basic strace to see what a process is doing - 2020-09-07
- Converting Airtable JSON for use with sqlite-utils using jq - 2020-08-28
- Loading radio.garden into SQLite using jq - 2021-02-17
- Flattening nested JSON objects with jq - 2021-03-11
- Converting no-decimal-point latitudes and longitudes using jq - 2021-03-11
- Turning an array of arrays into objects with jq - 2021-05-25
- Looping over comma-separated values in Bash - 2020-09-01
- Escaping strings in Bash using !:q - 2020-10-01
- Escaping a SQL query to use with curl and Datasette - 2020-12-08
- Skipping CSV rows with odd numbers of quotes using ripgrep - 2020-12-11
- Finding CSV files that start with a BOM using ripgrep - 2021-05-28
- Very basic tsc usage - 2020-09-06
- Display EC2 instance costs per month - 2020-09-06
- Recovering data from AWS Lightsail using EC2 - 2021-01-16
- Installing Selenium for Python on macOS with ChromeDriver - 2020-10-02
- Using async/await in JavaScript in Selenium - 2020-10-02
- Running Datasette on DigitalOcean App Platform - 2020-10-06
- Redirects for Datasette - 2020-11-25
- Serving MBTiles with datasette-media - 2021-02-03
- Querying for GitHub issues open for less than 60 seconds - 2021-03-12
- Running Datasette on Replit - 2021-05-02
- Embedding JavaScript in a Jupyter notebook - 2021-01-22
- Testing cookiecutter templates with pytest - 2021-01-27
- Conditionally creating directories in cookiecutter - 2021-01-27
- Downloading MapZen elevation tiles - 2021-02-04
- Using sphinx.ext.extlinks for issue links - 2021-02-17
- Show the SQL schema for a PostgreSQL database - 2021-02-23
- Granting a PostgreSQL user read-only access to some tables - 2021-02-26
- Closest locations to a point - 2021-03-22
- Using unnest() to use a comma-separated string as the input to an IN query - 2021-04-10
- Using json_extract_path in PostgreSQL - 2021-04-13
- Constructing GeoJSON in PostgreSQL - 2021-04-24
- How to run MediaWiki with SQLite on a macOS laptop - 2021-03-06
- Language-specific indentation settings in VS Code - 2021-04-04
- The Wikipedia page stats API - 2021-05-13
- Vega-Lite bar charts in the same order as the data - 2021-05-15
- KNN queries with SpatiaLite - 2021-05-16
- Finding duplicate records by matching name and nearby distance - 2021-05-19
- Building a Markdown summary of Django group permissions - 2021-06-03
- Exporting Amplitude events to SQLite - 2021-06-06
- Mouse support in vim - 2021-06-19
- Scraping Reddit via their JSON API - 2021-06-21
- Using nginx to proxy to a Unix domain socket - 2021-07-10
- Using the tesseract CLI tool - 2021-07-18