Skip to content

Instantly share code, notes, and snippets.

View simonw's full-sized avatar

Simon Willison simonw

View GitHub Profile
@simonw
simonw / datasettes-osx.md
Last active June 19, 2018 18:42
Some interesting datasettes on OS X

Not sure what these are:

datasette ~/Library/Suggestions/*.db

Safari stuff:

datasette ~/Library/Safari/*.db

Your desktop background:

@simonw
simonw / vice-news-police-shootings-datasette.md
Last active January 5, 2018 16:35
VICE News Police Shootings data with Datasette
@simonw
simonw / spatialite-support.md
Created December 13, 2017 17:59
Query to see what SpatiaLite features are supported
select spatialite_version(), spatialite_target_cpu( ), proj4_version( ), geos_version( ), lwgeom_version( ), libxml2_version( ), HasIconv( ), HasMathSQL( ), HasGeoCallbacks( ), HasProj( ), HasGeos( ), HasGeosAdvanced( ), HasGeosTrunk( ), HasLwGeom( ), HasLibXML2( ), HasEpsg( ), HasFreeXL( ), HasGeoPackage( );

e.g. https://timezones-api.now.sh/timezones-4fbc08f?sql=select+spatialite_version%28%29%2C+spatialite_target_cpu%28+%29%2C+proj4_version%28+%29%2C+geos_version%28+%29%2C+lwgeom_version%28+%29%2C+libxml2_version%28+%29%2C+HasIconv%28+%29%2C+HasMathSQL%28+%29%2C+HasGeoCallbacks%28+%29%2C+HasProj%28+%29%2C+HasGeos%28+%29%2C+HasGeosAdvanced%28+%29%2C+HasGeosTrunk%28+%29%2C+HasLwGeom%28+%29%2C+HasLibXML2%28+%29%2C+HasEpsg%28+%29%2C+HasFreeXL%28+%29%2C+HasGeoPackage%28+%29%3B

@simonw
simonw / pony.md
Created December 18, 2017 21:47
How to compile and run a Pony program using Docker

How to compile and run a Pony program using Docker

Create a /tmp/helloworld directory and put the following in main.pony:

actor Main
  new create(env: Env) =>
    env.out.print("Hello, world!")

Now compile it like this (the Docker image will be downloaded if necessary):

@simonw
simonw / darkflow-osx.md
Last active July 22, 2023 19:05
How I got darkflow working on my OS X Laptop

How I got darkflow working on my OS X Laptop

Darkflow is a Python 3 tool that makes the Darknet open source neural networks available in Python using Tensorflow.

Here's how I got it working on my laptop:

cd /tmp
git clone https://github.com/thtrieu/darkflow
cd darkflow

virtualenv --python=python3 .venv

@simonw
simonw / json-objects-into-a-datasette.md
Last active September 19, 2025 04:16
How to turn a list of JSON objects into a Datasette

How to turn a list of JSON objects into a Datasette

This repository has a dataset of 184.879 crimes committed in Buenos Aires: https://github.com/ramadis/delitos-caba

Download the raw data like this:

wget 'https://github.com/ramadis/delitos-caba/releases/download/3.0/delitos.json'

Now use Pandas to load that into a dataframe:

@simonw
simonw / datasette-freebase-species.md
Last active January 25, 2018 05:13
Making a Datasette out of Freebase species data
@simonw
simonw / whosonfirst_sqlite_subset.md
Last active February 20, 2018 18:23
How I made a Who's On First subset database

How I made a Who's On First subset database

Using whosonfirst-data-latest.db from https://dist.whosonfirst.org/sqlite/ - technique inspired by Paul Ford: https://twitter.com/ftrain/status/957833410017361921

If you fire up the sqlite3 CLI against an existing database you can and then mount a brand new database using attach database - then you can create tables in that new database and populate them using a select statement, extracting data from JSON columns using the json_extract() function.

Having populated the new table, I also create a full-text index against the name column.

Here's an example query against the resulting database, using a wildcard to implement prefix autocomplete: https://whosonfirst-metadata-only.now.sh/whosonfirst-metadata-only-c11ebe3/whosonfirst?_search=san+fra%2A

@simonw
simonw / tricky-merge-conflict.md
Created February 3, 2018 20:47
How I fixed a tricky merge conflict

How I fixed a tricky merge conflict

I switched to another branch before the conflict.

git checkout -b fixbranch

Then I cherry-picked each commit that was failing to merge, one at a time.

For each of those cherry-picked commits I manually cleaned up any conflicts.

@simonw
simonw / la-times-feather.md
Created February 4, 2018 17:16
How I mada a Datasette out of a feather file

How I mada a Datasette out of a feather file

Fantastic data journalism by Christine Zhang at the LA Times: https://github.com/datadesk/homeless-arrests-analysis

First I grabbed the data - a zipped feather file:

wget https://github.com/datadesk/homeless-arrests-analysis/blob/master/arrests.zip?raw=true
mv arrests.zip\?raw\=true arrests.zip
unzip arrests.zip