Skip to content

Instantly share code, notes, and snippets.

View psychemedia's full-sized avatar

Tony Hirst psychemedia

View GitHub Profile
@psychemedia
psychemedia / lang-fairy-books-db.ipynb
Last active November 17, 2021 18:43
Scrape and build a simple full text searchable database over Lang's Fairy Books
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@psychemedia
psychemedia / jupyter local book hack.ipynb
Created August 17, 2021 12:56
Hack for local Jupyter book
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@psychemedia
psychemedia / table2tree.ipynb
Last active June 12, 2023 08:34
Convert a pandas dataframe describing a hierarchy to a JSON tree
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@psychemedia
psychemedia / pindent.py
Created June 21, 2021 13:39
pindent.py
#! /usr/bin/env python3
# Via: https://github.com/python/cpython/blob/main/Tools/scripts/pindent.py
# See also: https://stackoverflow.com/a/118744/454773
# This file contains a class and a main program that perform three
# related (though complimentary) formatting operations on Python
# programs. When called as "pindent -c", it takes a valid Python
# program as input and outputs a version augmented with block-closing
# comments. When called as "pindent -d", it assumes its input is a
@psychemedia
psychemedia / 07.1 Spreadsheet basics.ipynb
Created May 14, 2021 20:14
example borked in nbqal?
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@psychemedia
psychemedia / flake8_report_inliner.py
Last active May 11, 2021 17:17
Parse nbqa flake8 report and add flake8 errors to notebook code cell outputs
import nbformat
def flake8_report_insertion(report_file, overwrite=False, tags=True):
"""Parse flake8 report file into notebook output cells."""
# Read in report file generate as eg:
# nbqa flake8 notebooks/*.ipynb > flake8_reports.txt
with open(report_file, 'r') as f:
lines = f.read().splitlines()
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@psychemedia
psychemedia / road-book-sketch.Rmd
Last active February 21, 2021 16:42
Initial sketch of using sfnetworks to see if we can generate a graph from which we can create a rally road book
```{r, cache = F, echo = F, message=F}
# Allow knitr to continue to execute even in the presence of errors
knitr::opts_chunk$set(error = TRUE)
knitr::opts_chunk$set(fig.path = "images/creating-road-book-")
knitr::opts_chunk$set(engine.path = list(python = '/usr/local/bin/python3'))
options(rgl.useNULL = TRUE,
rgl.printRglwidget = TRUE)
```
# Creating A Road Book
@psychemedia
psychemedia / sqlite_utils_magic.ipynb
Last active October 22, 2020 06:36
Proof of concept sqlite_utils magic
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.