Skip to content

Instantly share code, notes, and snippets.

Avatar

Tony Hirst psychemedia

View GitHub Profile
View jupyter local book hack.ipynb
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 Jul 13, 2021
Convert a pandas dataframe describing a hierarchy to a JSON tree
View table2tree.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View 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
View 07.1 Spreadsheet basics.ipynb
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
Parse nbqa flake8 report and add flake8 errors to notebook code cell outputs
View flake8_report_inliner.py
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()
View tm112-demo-run.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View tm112-demo-rendered.ipynb
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 Feb 21, 2021
Initial sketch of using sfnetworks to see if we can generate a graph from which we can create a rally road book
View road-book-sketch.Rmd
```{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 Oct 22, 2020
Proof of concept sqlite_utils magic
View sqlite_utils_magic.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@psychemedia
psychemedia / NetworkVisualisation.ipynb
Last active Aug 17, 2020
Example of plotting pretty networks using networkx and a force atlas layout
View NetworkVisualisation.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.