Skip to content

Instantly share code, notes, and snippets.

@johnmee
johnmee / upbank_importer.py
Created September 7, 2022 23:06
Beancount importer of Up Bank json files.
import json
from datetime import date
import beancount
from beancount.core import data
from beancount.core import flags
from beancount.core import (account, amount, number)
from beancount.ingest import importer
@johnmee
johnmee / stgeorge_importer.py
Created September 7, 2022 23:04
Beancount importer of St George Bank CSV files.
import csv
import decimal
import re
from dataclasses import dataclass
from datetime import date, datetime, timedelta
import beancount
from beancount.core.data import EMPTY_SET, Posting, Transaction, new_metadata, Balance
from beancount.core import flags, amount, number
@johnmee
johnmee / keymap.c
Created August 17, 2019 07:04
niumini qmk layout with adjust layer that doesn't work.
#include QMK_KEYBOARD_H
// Defines the keycodes used by our macros in process_record_user
#define _QWERTY 0
#define _LOWER 1
#define _RAISE 2
#define _ADJUST 16
enum custom_keycodes {
QWERTY = SAFE_RANGE,
@johnmee
johnmee / test_runner.py
Created October 3, 2016 23:49
Django Test Runner with timings of each individual test
from time import sleep
from time import time
from psycopg2 import OperationalError
from django.test.runner import DiscoverRunner
import django.db.backends.postgresql_psycopg2.base
from unittest.runner import TextTestRunner
from unittest.runner import TextTestResult
@johnmee
johnmee / Nearmap.com Test
Last active August 29, 2015 14:05
Nearmap.com Test
Python version of the Nearmap.com technical test
https://github.com/izevaka/nearmap-test
The test is set in C#. I suggested that was a bit silly for a Python candidate, and they agreed. So I translated it into a Python test for them.
They were intrigued by this solution, but, after much internal discussion, ultimately concluded they didn't like it. The primary objection was "why didn't you just use a conventional lock?". The question successfully exposed that I was completely unaware of what convention dictated. Nonetheless, I defend this solution, because, and I didn't enunciate it eloquently at the time, it does not create the bottleneck that a conventional lock would; in a typical lock/release solution all threads must pass through a common gate, creating a potential bottleneck.
This solution implements no gate and no bottleneck. Threads seeking known keys can get on with their life without queuing for a lock. Threads seeking unknown keys sleep until, the single thread that is fetching the valu
@johnmee
johnmee / Paypal API
Last active August 29, 2015 14:03
Dealing with the Paypal API - as made for CA.
Paypal API and python/django