Skip to content

Instantly share code, notes, and snippets.

@mbafford
mbafford / _fastmail-status-check.js
Last active July 18, 2024 12:09
Add Fastmail outages/incidents indicator to fastmail webUI (tampermonkey)
// ==UserScript==
// @name Fastmail Status Checker
// @namespace https://gist.github.com/mbafford/9fbfd4a4bb0c7f67b0910a9556bb65e2
// @version 1.1
// @description Show an icon on Fastmail if there's any active issue from the status API.
// @author Matthew Bafford
// @match https://app.fastmail.com/*
// @grant none
// ==/UserScript==
@mbafford
mbafford / README.md
Last active July 8, 2024 16:53
Compare two PDFs using ImageMagick - provides a visual comaprison and a perceptual hash comparison (numerical)

PDF tools for comparing PDFs visually (overlaying two PDFs to see changed areas) and using a perceptual hash (numerical value indicating visual difference between the two files).

Useful for command line review of PDFs and de-duplication. Configure git to use these tools for better PDF history / comparison in git.

These scripts require imagemagick and poppler. Both installed from homebrew.


Setup git to use a custom diff using:

@mbafford
mbafford / plaid_sync_source.py
Created February 19, 2024 11:55
plaid-sync sqlite Source for beancount-importer
"""
Meant to be used with:
https://github.com/mbafford/plaid-sync/
and:
https://github.com/jbms/beancount-import
Set up as a data source in your beancount-import config:
@mbafford
mbafford / README.md
Created April 8, 2023 13:18
ruleswrapper for beancount-import

Rough guide to using my ruleswrapper.py class to hard-code certain rules in beancount-import.

See the example config - add the ruleswrapper as the data source, and specify the module to be wrapped as wrapped_module.

Any configuration parameters meant for the wrapped module should be added to the config passed to ruleswrapper.

Code may not compile exactly as-is - roughly edited to remove sensitive data.

TODO:

  • split rules into standalone file, so ruleswrapper.py can be shared more easily
@mbafford
mbafford / dcu_opentimetable.py
Last active January 1, 2022 20:11
DCU OpenTimeTable module events scrapy code
import scrapy
import json
import scrapy.http
import re
import datetime
def build_weeks():
ret = []
for weekNo in range(16, 30):
week1 = datetime.date(2021, 9, 20)
@mbafford
mbafford / fix_payee_narration.py
Created November 30, 2021 12:23
Beancount - Fix payee/narration behavior to always have payee first and narration optional
#!python3
"""
Beancount has inconsistent behavior with payee/narrations.
If you have a line like this:
2020-01-01 * "Text1"
Then "Text1" is the narration
@mbafford
mbafford / dockerfile
Last active August 10, 2021 17:39
ical_to_gcal_sync dockerfile
# Quick and dirty docker build for andrewramsay's ical_to_gcal_sync script
# - copy a config.py on the host at /path/to/config.py ( https://github.com/andrewramsay/ical_to_gcal_sync/blob/master/config.py )
# - set all paths to be under /opt/config/ in the container
# - follow the readme steps from the repository
# can run as:
# docker run -it --rm --name 'ical_to_gcal_sync' -v /path/to/config.py:/opt/ical_to_gcal_sync/config.py -v /path/to/config/:/opt/config/ ical_to_gcal_sync
FROM python:3.8-slim-buster
WORKDIR /opt
@mbafford
mbafford / naive-maven-mirror.py
Created May 9, 2020 23:22
A pretty naive mirror which will check a local folder for a Maven artifact, and if not found, fetch from the requested server.
#!/usr/bin/env python3
import sys
import os
import socket
import threading
import socketserver
import mimetypes
import shutil
from urllib import request, error
@mbafford
mbafford / osm-bulk-change-node-tags.py
Last active November 11, 2018 13:20
OSM API - search and bulk change
#!.env/bin/python
import overpass # https://github.com/mvexel/overpass-api-python-wrapper
import osmapi # http://osmapi.metaodi.ch/#osmapi.OsmApi.OsmApi.ChangesetClose
opass = overpass.API()
osm = osmapi.OsmApi( username = "USERNAME", password = "PASSWORD")
# nodes of interest were manually determined using a query on
# https://overpass-turbo.eu/
@mbafford
mbafford / journey_cloud_json_to_evernote_enex.py
Last active August 20, 2022 12:08
Convert Journey.Cloud (Diary) JSON Export to Evernote Export (ENEX)
#!/usr/bin/env python3
# Converts the JSON export of Journey.Cloud diary entries into an Evernote Note Export format (ENEX) for easy import back into Evernote.
#
# This was a quick and dirty script to save someone the trouble of doing this process manually.
#
# Create/update date, journal text, location, and photos are preserved in the resulting Evernote Note.
import sys
import os