Skip to content

Instantly share code, notes, and snippets.

View simonw's full-sized avatar

Simon Willison simonw

View GitHub Profile
@simonw
simonw / ubuntu-python-upgrade.md
Created March 28, 2020 19:45
How to run Python 3.7 on Ubuntu 16.04
@simonw
simonw / readme.md
Created March 26, 2020 16:16
Making a Datasette of Finnish coronavirus data
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
datasette
sqlite-utils
sqlite-transform
csvs-to-sqlite
geojson-to-sqlite
socrata2sql
datasette-cluster-map
datasette-vega
datasette-json-html
datasette-jellyfish
@simonw
simonw / datasette.service
Last active December 4, 2019 17:47
Files I use to run Datasette under systemd, inspired by https://github.com/simonw/datasette/issues/514#issuecomment-504662904
# This file lives in /etc/systemd/system/datasette.service
[Unit]
Description=Datasette
After=network.target
[Service]
Type=simple
User=ubuntu
Environment=GITHUB_CLIENT_ID=...
Environment=GITHUB_CLIENT_SECRET=...
{
"title": "This is the title"
}
async def data(
self,
request,
database, # Name of the database
hash, # Hash component of the database URL (usually ignored)
table, # Name of the table
default_labels=False, # HTML views default to expanding all foreign key labels
_next=None,
_size=None,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@simonw
simonw / autoescape.js
Created October 21, 2019 18:02
An autoescaping JavaScript template tagged literal
class Safe extends String {}
function safe(s) {
if (!(s instanceof Safe)) {
return new Safe(s);
} else {
return s;
}
}
@simonw
simonw / deepest.sql
Created October 6, 2019 17:15
Query a twitter-to-sqlite database and find the "deepest" tweets in a reply thread, adapted from https://gist.github.com/robinhouston/f689a4b833dc027a3fd97e3de855927b
with recursive thread as (
select id, in_reply_to_status_id, 0 as depth
from tweets
where in_reply_to_status_id is null
union
select tweets.id, tweets.in_reply_to_status_id, 1 + thread.depth as depth
from thread join tweets on tweets.in_reply_to_status_id = thread.id)
select * from thread order by depth desc