Serving MBTiles with datasette-media
The [MBTiles](https://github.com/mapbox/mbtiles-spec) format uses SQLite to bundle map tiles for use with libraries such as Leaflet.
160 words
|
1 minute
Adding a CORS policy to an S3 bucket
Amazon S3 buckets that are configured to work as public websites can support CORS, allowing assets such as JavaScript modules to be loaded by JavaS...
550 words
|
3 minutes
Ensure labels exist in a GitHub repository
I wanted to ensure that when [this template repository](https://github.com/simonw/action-transcription) was used to create a new repo that repo wou...
161 words
|
1 minute
Registering new Datasette plugin hooks by defining them in other plugins
I'm experimenting with a Datasette plugin that itself adds new plugin hooks which other plugins can then interact with.
150 words
|
1 minute
Combining substr and instr to extract text
Derek Willis has [a Datasette instance full of political campaign emails](https://political-emails.herokuapp.com/) running on Heroku.
534 words
|
3 minutes
One-liner for running queries against CSV files with SQLite
I figured out how to run a SQL query directly against a CSV file using the `sqlite3` command-line utility:
516 words
|
3 minutes
Calculating the AQI based on the Purple Air API for a sensor
[Purple Air](https://www.purpleair.com/) sensors have an API at `https://www.purpleair.com/map.json?show=SENSOR-ID-HERE`, which returns JSON that l...
353 words
|
2 minutes
Using pprint() to print dictionaries while preserving their key order
While parsing a CSV file using `csv.DictReader` today I noticed the following surprising result:
198 words
|
1 minute
Configuring auto-update for an Electron app
This is _almost_ really simple. I used [electron/update-electron-app](https://github.com/electron/update-electron-app) for it, the instructions for...
391 words
|
2 minutes
Debugging a Click application using pdb
This tip is for when you are working on a Python command-line application that runs using that program's name, as opposed to typing `python my_scri...
265 words
|
1 minute
Ordered group_concat() in SQLite
I was trying to use `group_concat()` to glue together some column values into a stiched together Markdown document. My first attempt looked like this:
231 words
|
1 minute
Safely outputting JSON
Carelessly including the output of `json.dumps()` in an HTML page can lead to an XSS hole, thanks to the following:
81 words
|
1 minute
Replicating SQLite with rqlite
I tried out [rqlite](https://github.com/rqlite/rqlite) today, a "lightweight, distributed relational database, which uses SQLite as its storage eng...
323 words
|
2 minutes
Setting cache-control: max-age=31536000 with a Cloudflare Transform Rule
I ran https://simonwillison.net/ through [PageSpeed Insights](https://pagespeed.web.dev/) and it warned me that my static assets were not being ser...
646 words
|
3 minutes
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.
116 words
|
1 minute
Redirecting a domain using Cloudflare Pages
I wanted to redirect https://global-power-plants.datasettes.com/ to https://datasette.io/ - I decided to spin up a Cloudflare Pages site to do the ...
682 words
|
3 minutes
Limited JSON API for Google searches using Programmable Search Engine
I figured out how to use a JSON API to run a very limited Google search today in a legit, non-screen-scraper way.
538 words
|
3 minutes
Loading lit from Skypack
[Lit 2](https://lit.dev/blog/2021-09-21-announcing-lit-2/) stable was released today, offering a tiny, feature-full framework for constructing web ...
108 words
|
1 minute
Bulk editing status in GitHub Projects
GitHub Projects has a mechanism for bulk updating the status of items, but it's pretty difficult to figure out how to do it.
137 words
|
1 minute
Saving an in-memory SQLite database to a file in Python
I was messing around in Python with an in-memory SQLite database, when I decided I actually wanted to save my experimental database to a file so I ...
126 words
|
1 minute
Writing an Azure Function that serves all traffic to a subdomain
[Azure Functions](https://docs.microsoft.com/en-us/azure/azure-functions/) default to serving traffic from a path like `/api/FunctionName` - for ex...
157 words
|
1 minute
Remember to commit when using datasette.execute_write_fn()
I was writing some code for [datasette-auth-tokens](https://github.com/simonw/datasette-auth-tokens) that used [db.execute_write_fn()](https://docs...
190 words
|
1 minute
shot-scraper for a subset of table columns
For [Datasette issue #1844](https://github.com/simonw/datasette/issues/1844) I wanted to create the following screenshot:
249 words
|
1 minute
GitHub Pages: The Missing Manual
[GitHub Pages](https://pages.github.com/) is an excellent free hosting platform, but the documentation is missing out on some crucial details.
519 words
|
3 minutes