Skip to content

Instantly share code, notes, and snippets.

@Jonty
Jonty / github_org_active_committers.py
Last active July 10, 2024 17:30
Outputs the number of people who have committed to each repo in a github org in the last 90 days, as well as the total count of unique people who have committed to the org in the last 90 days. Useful for estimating seat-counts for tools like Snyk.
import os
import github
from datetime import datetime, timedelta, timezone
START_TIME = datetime.now(timezone.utc) - timedelta(days=90)
# USAGE:
# IGNORE_REPOS=repo1,repo2,repo3 GITHUB_TOKEN=foobarbaz GITHUB_ORG=gchq,nsa python github_org_active_users.py
g = github.Github(os.environ["GITHUB_TOKEN"])
@Jonty
Jonty / bridge-strikes-2020-2024.csv
Created June 7, 2024 12:06
Bridge strike incidents reported to Network Rail from Jan 2020 - June 2024, as obtained from this FOI: https://www.whatdotheyknow.com/request/bridge_strike_incidents
We can't make this file beautiful and searchable because it's too large.
Start Date of Incident,Network Region,Network Rail Route,ELR,Railway ID,ELR/ Structure Number,Asset Description,Asset Type ,Start Mileage,Latitude,Longitude
00/01/1900,Eastern,ANG,EMP,1816,EMP/1816,STONEA ROAD (B1098),Underline Bridge,82.0066,52.518212,0.149384
00/01/1900,Eastern,ANG,MAH,1043,MAH/1043,"MANNINGTREE ROAD, MISTLEY",Underline Bridge,59.1474,51.947362,1.053891
00/01/1900,NW&C,CEN,CNN,39,CNN/39,COVENTRY OR SPON END VIADUCT,Viaduct,0.1022,,
00/01/1900,NW&C,CEN,MJI2,7,MJI2/7,CHERRY TREE HILL,Underline Bridge,161.11,52.642012,-2.489306
02/01/2020,NW&C,CEN,ALC2,35,ALC2/35,BIRMINGHAM ROAD A5127,Underline Bridge,12.0352,52.65999,-1.834098
02/01/2020,Southern,SUS,SMS2,12,SMS2/12,LONDON ROAD,Underline Bridge,9.0484,51.39728153,-0.200152363
03/01/2020,Eastern,ANG,ETN,1601,ETN/1601,ABBEY FARM,Underline Bridge,93.0858,52.419468,0.742588
03/01/2020,Eastern,EC,ECM1,246,ECM1/246,BARROWBY ROAD,Underline Bridge,106.0215,52.915536,-0.648302
03/01/2020,Southern,KNT,RTT,64,RTT/64,BOUGH BEECH,Overline Bridge,36.0154,,
@Jonty
Jonty / deredactatron.py
Last active October 10, 2023 20:39
The Deredactatron: De-redacts PDF's redacted by drawing rectangles over the text. Needs Python3 and PyMuPDF
#!/usr/bin/env python3
# De-redacts PDF's that have been redacted by drawing PDF-native rectangles over the text
# This removes ALL rectangles so might also nuke any shape diagrams a bit
# python deredactatron.py a_redacted_doc.pdf
# Outputs: deredacted-a_redacted_doc.pdf
import sys
import re
@Jonty
Jonty / remaining_museum_domains.md
Last active November 24, 2022 18:38
Every remaining website using the .museum TLD

Every remaining website using the .museum TLD

The .museum TLD was created by the International Council of Museums (ICOM) in 2001 and is managed by The Museum Domain Management Association (MuseDoma). At the beginning the Museum Domain Management Association was shortened to its initials (MDMA) until the management team was advised to change it.

Anyone "of a nature to serve the interests of the world museum community" can register a .museum name. Each domain costs €35/year.

Over 1000 museum domains have been registered at both the second and third level, but at the time of writing in 2021 almost all are either defunct or redirect to another domain.

Below are the only remaining .museum websites using the TLD for their primary domain. This list was obtained by checking all 1134 domains listed on index.museum.

@Jonty
Jonty / gist:263b7d5a637fc4f22dcfcdee6fd53b9a
Created May 26, 2021 01:01
Freenode server sponsors on 26th May 2021
Linkname
Hostname
Port SSL Date Time
card.freenode.net
chat.freenode.net
6697 on May 26 00:00
tildes.freenode.net
chat.freenode.net
6667 off May 25 22:00
Type Name
metropolitan_district Barnsley Borough Council
metropolitan_district Birmingham City Council
metropolitan_district Bolton Borough Council
metropolitan_district Bradford City Council
metropolitan_district Bury Borough Council
metropolitan_district Calderdale Borough Council
metropolitan_district Coventry City Council
metropolitan_district Doncaster Borough Council
metropolitan_district Dudley Borough Council
Year Food, Vets & Ancillary Costs Staffing Total
2015 4,301.83 31,310.00 35,611.83
2016 3,694.56 32,093.00 35,787.56
2017 4,508.96 32,895.00 37,403.96
2018 8,084.32 33,717.00 41,801.32
2019 7,828.90 34,560.00 42,388.90
@Jonty
Jonty / extract_code_from_doxygen.py
Created December 28, 2020 19:11
Extract all code from a set of Doxygen generated documentation, for use when recovering code that has otherwise been lost
# This extracts all the code from a set of Doxygen generated documentation
# where the code is embedded and highlighted. You really only need to use this
# when attempting to recover lost code and you still have the docs.
# Writes all code out into the original directory structure relative to where
# the script is executed.
# Run: `python extract_code_from_doxygen.py URL_TO_DOXYGEN_FILES_PAGE`
# e.g. `python extract_code_from_doxygen.py http://swf2svg.sourceforge.net/azar/doc/files.html`
@Jonty
Jonty / eb_dump_env_vars.py
Created December 17, 2020 00:18
Dump environment variables for all Elastic Beanstalk apps in an AWS account, redacting passwords/secrets/keys/tokens
import boto3
client = boto3.client("elasticbeanstalk")
apps = client.describe_applications()
for app in apps["Applications"]:
envs = client.describe_environments(ApplicationName=app["ApplicationName"])
for env in envs["Environments"]:
env_name = env["EnvironmentName"]
@Jonty
Jonty / open_house_london_api.md
Last active March 4, 2024 01:40
Open House London API (Or any open-city.org.uk city)