Skip to content

Instantly share code, notes, and snippets.

View simonmichael's full-sized avatar

Simon Michael simonmichael

View GitHub Profile
@simonmichael
simonmichael / sm-Ledger.st
Created May 3, 2014 17:15
a prototype squeak port of Ledger, 2007
"
prototype ledger file parser in squeak
Simon Michael
test scripts:
s1 := LedgerParserTests sample1 readStream
PositionableStream
2007/10/7 the fairmont sonoma mission inn & spa
expenses:food:dining $11
@simonmichael
simonmichael / .bashrc.task
Last active January 18, 2022 17:55
taskwarrior config 2016/01
# Simon's taskwarrior aliases
########################################
# general commands
alias t="task"
alias ta="task add"
alias td="task done"
alias t-="task delete"
alias tm="task modify"
@simonmichael
simonmichael / hledger-number.sh
Last active December 2, 2021 20:53
hledger-number - extract one number from hledger
#!/usr/bin/env bash
# hledger-number - try to extract just one single machine-readable number from hledger:
# the grand total of `hledger balance` run with any provided arguments.
# Requires hledger 1.24 or newer (the December 2021 release, see https://hledger.org/download.html )
# https://gist.github.com/simonmichael/feee7fc1567c5f10355f952b87bd3090
VALUATION_COMMODITY="$"
hledger bal -0 -N -X "$VALUATION_COMMODITY" --infer-market-prices -c "$VALUATION_COMMODITY 1000" --layout=bare "$@" | awk '{print $1}'
# Tired of complex financial reports ? This is a silly but fun and
@simonmichael
simonmichael / budget.ledger
Last active November 21, 2021 17:52
seeking minimal ledger budget examples
; whenever there's a food expense, deduct the same amount from the budget
= /^expenses:food$/
(budget:food) -1
1/1 opening balances
assets:checking 1000
equity:opening balances
1/2 budget allocation ; could also do this with an automated posting on income txns
@simonmichael
simonmichael / ski.hs
Last active September 29, 2021 05:09
ski.hs - terminal game dev 2021-09-28
#!/usr/bin/env stack script --compile --resolver lts-18 --verbosity=warn
{-# OPTIONS_GHC -Wno-missing-signatures -Wno-unused-imports #-}
{-# LANGUAGE RecordWildCards #-}
-- ski.hs - Downhill Skier Driver Space Pilot !
import Control.Concurrent
import Control.Monad
-- import Data.Char
-- import Data.List
@simonmichael
simonmichael / avodonosov.journal
Last active September 8, 2021 22:38
Working out a reporting challenge from HN, part 2. See also part 1: https://gist.github.com/simonmichael/3bb42cd82b4afd437305d10ad914b9ec
; avodonosov problem, HN 2021-09-05
; part of https://gist.github.com/simonmichael/3bb42cd82b4afd437305d10ad914b9ec
; "For example
; Jan 1
; Received 1000 EUR for a contract
; The rate 1 EUR = 2 BYN
; Jan 2
; Exchanged 300 EUR to BYN
; The rate 1 EUR = 2.1 BYN
@simonmichael
simonmichael / avodonosov-example.journal
Last active September 8, 2021 22:13
Working out a reporting challenge from HN, part 1. See also part 2 (foreign exchange gains): https://gist.github.com/simonmichael/28f94ce2bd73318e4fccbfa7c9fc7e87
; avodonosov problem, from https://news.ycombinator.com/item?id=28424432
; For example
; Jan 1
; Received 1000 EUR for a contract
; The rate 1 EUR = 2 BYN
; Jan 2
; Exchanged 300 EUR to BYN
; The rate 1 EUR = 2.1 BYN
; Jan 3
; Received 2000 EUR for a contract
@simonmichael
simonmichael / 1-Makefile
Last active August 29, 2021 19:37
make rules and short symbols setup for market-prices.py (https://github.com/barrucadu/hledger-scripts#market-prices)
YEAR:=$(shell date +%Y)
PRICES=$(YEAR).prices
# Fetch latest market prices, add P records to prices file.
MARKET_PRICES=~/src/PLAINTEXTACCOUNTING/hledger-scripts/market-prices/market-prices.py <market-prices.json
.PHONY: prices prices-dry
prices-dry:
@$(MARKET_PRICES)
@simonmichael
simonmichael / Makefile
Last active August 11, 2021 16:34
elaborate cron/make rules for periodically, automatically, cleanly git-committing (hledger) files, with logs for troubleshooting
# Perform any auto-commits that are due, in the proper order.
autocommit: \
autocommit-time \
autocommit-txns \
autocommit-misc
# Auto-commit any timelog changes.
autocommit-time:
@echo `date` $@ >>$@.log
@( git commit -qm 'time (auto)' $(TIMEDOT) | grep -E '(^\[|file changed)' ) >>$@.log \
@simonmichael
simonmichael / paypaljson
Created June 22, 2021 21:21
updated scripts for downloading paypal transactions for hledger
#!/bin/bash
# Download recent transaction history from Paypal as JSON,
# and print on stdout.
#
# Requirements: a Paypal developer account, curl, jq (just for pretty-printing)
#
# brew install jq
#
# Limitations:
# - sees only the last 30 days of history