Skip to content

Instantly share code, notes, and snippets.

Avatar

Simon Willison simonw

View GitHub Profile
@simonw
simonw / rusage.py
Created Oct 27, 2020
Datasette plugin exposing rusage values
View rusage.py
import resource
from datasette import hookimpl
from datasette.utils.asgi import Response
def rusage():
return Response.text(
repr(resource.getrusage(resource.RUSAGE_SELF))
.replace(", ", ",\n ")
.replace("(", "(\n ")
@simonw
simonw / example-output.txt
Created Oct 22, 2020
Infinite loop of "Requirement already satisfied" with the new pip resolver
View example-output.txt
Requirement already satisfied: datasette>=0.50.2 in /Users/simon/.local/share/virtualenvs/pipnext-HNJm0oR8/lib/python3.8/site-packages (from -r requirements.txt (line 2)) (0.50.2)
Collecting sqlite-utils>=2.17
Using cached sqlite_utils-2.22-py3-none-any.whl (30 kB)
Requirement already satisfied: click-default-group~=1.2.2 in /Users/simon/.local/share/virtualenvs/pipnext-HNJm0oR8/lib/python3.8/site-packages (from datasette>=0.50.2->-r requirements.txt (line 2)) (1.2.2)
Requirement already satisfied: click~=7.1.1 in /Users/simon/.local/share/virtualenvs/pipnext-HNJm0oR8/lib/python3.8/site-packages (from datasette>=0.50.2->-r requirements.txt (line 2)) (7.1.2)
Collecting twitter-to-sqlite~=0.20
Using cached twitter_to_sqlite-0.21.3-py3-none-any.whl (26 kB)
Collecting inaturalist-to-sqlite~=0.2
Using cached inaturalist_to_sqlite-0.2-py3-none-any.whl (9.0 kB)
Requirement already satisfied: click~=7.1.1 in /Users/simon/.local/share/virtualenvs/pipnext-HNJm0oR8/lib/python3.8/site-packages (from datasette>=0.50
@simonw
simonw / earthquakes-to-sqlite.ipynb
Last active Oct 14, 2020
Using Datasette with Jupyter to publish your data - JupyterCon 2020 - rendered here: https://nbviewer.jupyter.org/gist/simonw/656c21b5800d5e4624dec9930f00e093
View earthquakes-to-sqlite.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View penguins.seaborn.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@simonw
simonw / python-environment.md
Last active Oct 7, 2020
Details of the DigitalOcean App Platform Python environment
View python-environment.md

Details of the DigitalOcean App Platform Python environment

I created an app on the DigitalOcean App Platform with a requirements.txt and a Procfile - causing it to detect a Python application and build the app with their Python buildpack.

Here are some details of the resulting environment, from running commands using the DigitalOcean web terminal.

$ uname -a
Linux digital-ocean-app-9c6bd5794-kt9h8 4.4.0 #1 SMP Sun Jan 10 15:06:54 PST 2016 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/issue
View natalian-maps-demo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@simonw
simonw / Earthquakes.ipynb
Created Sep 10, 2020
Earthquakes demo for PyRVA
View Earthquakes.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@simonw
simonw / crontab.txt
Created Sep 10, 2020
Dogsheep crontab.txt as of 10th September 2020
View crontab.txt
# Fetch latest configuration:
*/5 * * * * cd /home/ubuntu/dogsheep-config && python3 git_pull_and_run_scripts.py . && sudo python3 ensure_symlinks.py files-to-symlink
# Goodreads
46 * * * * cd /home/ubuntu && /home/ubuntu/datasette-venv/bin/goodreads-to-sqlite books goodreads.db -a auth.json
# Twitter
1,11,21,31,41,51 * * * * /home/ubuntu/datasette-venv/bin/twitter-to-sqlite user-timeline /home/ubuntu/twitter.db -a /home/ubuntu/auth.json --since
2,7,12,17,22,27,32,37,42,47,52,57 * * * * run-one /home/ubuntu/datasette-venv/bin/twitter-to-sqlite home-timeline /home/ubuntu/timeline.db -a /home/ubuntu/auth.json --since
4,14,24,34,44,54 * * * * run-one /home/ubuntu/datasette-venv/bin/twitter-to-sqlite mentions-timeline /home/ubuntu/twitter.db -a /home/ubuntu/auth.json --since
@simonw
simonw / Datasette and Pandas.ipynb
Created Jul 17, 2020
Using Datasette with Pandas
View Datasette and Pandas.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@simonw
simonw / UK power outages.ipynb
Created Jul 14, 2020
How to create a SQLite database of UK power outages using sqlite-utils
View UK power outages.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.