Skip to content

Instantly share code, notes, and snippets.

@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
@mbafford
mbafford / summarizejson
Last active April 5, 2024 17:54
summarizejson - Summarize JSON Structure (keys and data types)
#!/usr/bin/env python
# Gives a quick summary of the structure of a JSON file, including the keys, object types, and
# leaf node types. Provides a count of each data type so you can quickly tell which data points
# are common.
#
# Example:
#
# $ curl -sS 'https://raw.githubusercontent.com/johan/world.geo.json/master/countries.geo.json' | python summarizejson
# 9191 {features}.[].{geometry}.{coordinates}.[].[].[].[].float
# 41 {features}.[].{geometry}.{coordinates}.[].[].[].[].int
@mbafford
mbafford / owntracks_mqtt_connect_error.md
Created April 9, 2015 01:35
owntracks: Invalid protocol "MQTT" in CONNECT

In case someone else is trying to search for this error and can't get it figured out.

In trying to set up Owntracks ( http://owntracks.org/ ) I was running into an error on connection.

The error logs from Mosquitto:

1428534995: New connection from 10.10.10.1 on port 8883.
1428534995: OpenSSL Error: error:140D9115:SSL routines:SSL_GET_PREV_SESSION:session id context uninitialized
1428534995: Socket read error on client (null), disconnecting.

1428535258: New connection from 10.10.10.1 on port 8883.