TILs
Filters: Sorted by date
575 results
«« first
« previous
page 19 / 20
next »
last »»
TIL
Paginating through the GitHub GraphQL API with Python
— (See also [Building a self-updating profile README for GitHub](https://simonwillison.net/2020/Jul/10/self-updating-profile-readme/) on my blog)
TIL
Writing tests for the ASGI lifespan protocol with HTTPX
— Uvicorn silently ignores exceptions that occur during startup against the ASGI lifespan protocol - see [starlette/issues/486](https://github.com/encode/starlette/issues/486).
TIL
Using LD_PRELOAD to run any version of SQLite with Python
— I've been wanting to figure this out for ages. [This thread](https://news.ycombinator.com/item?id=23282684) on Hacker News plus [this Stackoverflow post](https://unix.stackexchange.com/questions/24811/changing-linked-library-for-a-given-executable-centos-6/24833#24833:) gave me some initial clues.
TIL
Asserting a dictionary is a subset of another dictionary
— My [lazy approach to writing unit tests](https://simonwillison.net/2020/Feb/11/cheating-at-unit-tests-pytest-black/) means that sometimes I want to run an assertion against most (but not all) of a dictionary.
TIL
Introspecting Python function parameters
— For https://github.com/simonw/datasette/issues/581 I want to be able to inspect a Python function to determine which named parameters it accepts and send only those arguments.
TIL
Adding project links to PyPI
— I spotted a neat looking project links section on https://pypi.org/project/ExifReader/
TIL
Converting HTML and rich-text to Markdown
— If you copy and paste from a web page - including a full table - into a GitHub issue comment GitHub converts it to the corresponding Markdown for you. Really quick way to construct Markdown tables.
TIL
List all columns in a SQLite database
— Here's a devious trick for listing ALL columns in a SQLite database, using a SQL query that generates another SQL query.
TIL
Use setup.py to install platform-specific dependencies
— For [photos-to-sqlite](https://github.com/dogsheep/photos-to-sqlite) I needed to install `osxphotos` as a dependency, but only if the platform is macOS - it's not available for Linux.
TIL
Search across all loaded resources in Firefox
— You can search for a string in any resource loaded by a page (including across HTML, JavaScript and CSS) in the Debugger pane by hitting Command+Shift+F.
TIL
Installing and upgrading Datasette plugins with pipx
— If you installed `datasette` using `pipx install datasette` you can install additional plugins with `pipx inject` like so:
TIL
Constant-time comparison of strings in Node
— When comparing secrets, passwords etc it's important to use a constant-time compare function to avoid timing attacks.
TIL
Accessing repository dependencies in the GitHub GraphQL API
— [Access to a Repositories Dependency Graph](https://developer.github.com/v4/previews/#access-to-a-repositories-dependency-graph) describes a preview API for accessing GitHub repository dependencies.
TIL
Compile a new sqlite3 binary on Ubuntu
— I wanted to try the `vacuum into` backup command that was released in SQLite3 3.27.0 [on 2019-02-07](https://www.sqlite.org/changes.html#version_3_27_0).
TIL
How to mock httpx using pytest-mock
— I wrote this test to exercise some [httpx](https://pypi.org/project/httpx/) code today, using [pytest-mock](https://pypi.org/project/pytest-mock/).
TIL
Generated a summary of nested JSON data
— I was trying to figure out the shape of the JSON object from https://github.com/simonw/coronavirus-data-gov-archive/blob/master/data_latest.json?raw=true - which is 3.2MB and heavily nested, so it's difficult to get a good feel for the shape.
TIL
Session-scoped temporary directories in pytest
— I habitually use the `tmpdir` fixture in pytest to get a temporary directory that will be cleaned up after each test, but that doesn't work with `scope="session"` - which can be used to ensure an expensive fixture is run only once per test session and the generated content is used for multiple tests.
TIL
Fixing "compinit: insecure directories" error
— Every time I opened a terminal on my new Mac running Catalina with zsh I got the following annoying error:
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.
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:
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
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.
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).
TIL
macOS Catalina sort-of includes Python 3
— Once you have installed the "command line tools" for Catalina using the following terminal command:
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
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.
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.
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.
«« first
« previous
page 19 / 20
next »
last »»