Skip to content

Instantly share code, notes, and snippets.


Simon Michael simonmichael

View GitHub Profile
simonmichael / 1-example
Last active Sep 20, 2020
finance scripts in a robust shake file
View 1-example
~/notes$ ./do.hs
Linking do ...
~/notes$ ./do
./do.hs install deps & (re)compile this script
./do [help] show this help
./do time show time status
./do money show money status
./do lassets show liquid assets
./do incexp show monthly income & expenses
simonmichael / pricing.ledger
Created May 14, 2019
Testing ledger cost/price syntax, lots, revaluation, capital gains
View pricing.ledger
; Test ledger cost/price syntax, lots, revaluation, capital gains
P 2019-01-01 ETC 11 EUR
P 2019-02-01 ETC 12 EUR
; Fluctuating cost/price
; @, @@
; { }, {{ }}
; "functionally.. no difference"
simonmichael / accounts.txt
Last active Sep 12, 2020
a sample *ledger chart of accounts (first 3 levels): combined personal & business, eg for a freelancer
View accounts.txt
accounts receivable
accounts receivable
simonmichael / init.el
Last active Sep 12, 2020
emacs: simple window splitting policy
View init.el
;; Try to ensure sensible window splitting, independent of frame and font size.
;; Things I don't want:
;; - excessive horizontal splitting (generally I prefer no more than 2 windows across)
;; - horizontal splitting when frame is tall and narrow (causing eg useless narrow man page formatting)
;; So, aim for a simple policy: popup windows shall be half width in a wide frame,
;; half height in a tall frame.
;; Emacs' window splitting behaviour is complex and must be read carefully.
;; In particular, note: it checks split-window-height first, and if that permits it to
;; split vertically, it does that and split-window-horizontally is ignored.
simonmichael / gist:1185421
Created Sep 1, 2011
ghc-pkg-clean, ghc-pkg-reset
View gist:1185421
# unregister broken GHC packages. Run this a few times to resolve dependency rot in installed packages.
# ghc-pkg-clean -f cabal/dev/packages*.conf also works.
function ghc-pkg-clean() {
for p in `ghc-pkg check $* 2>&1 | grep problems | awk '{print $6}' | sed -e 's/:$//'`
echo unregistering $p; ghc-pkg $* unregister $p
# remove all installed GHC/cabal packages, leaving ~/.cabal binaries and docs in place.
simonmichael / 10000x10000x10.journal
Created Jul 1, 2020
10,000-transaction journal file
View 10000x10000x10.journal
This file has been truncated, but you can view the full file.
2000-01-01 transaction 1
1 1 A
1:2 -1 A
2000-01-02 transaction 2
1:2:3 2 A
1:2:3:4 -2 A
2000-01-03 transaction 3
simonmichael / Makefile
Last active Mar 26, 2020
cron job to autocommit journal & related files
View Makefile
# cron
# install ./crontab as the active crontab
@crontab ./crontab
# overwrite ./crontab with the active crontab
@crontab -l >./crontab
simonmichael /
Last active Jan 28, 2020
draft of new close doc

close, equity
Adds a "closing balances" transaction to the main journal file, that brings selected account balances to zero. Also (by default), adds the inverse "opening balances" transaction to a new journal file (creating it if necessary), restoring those account balances as they were in the old journal.

This can be used to bring asset/liability balances forward into a new journal file, or to close out revenues/expenses to retained earnings at the end of an accounting period. More on this below.

simonmichael / average-cashflow.hs
Created Nov 29, 2012
hledger scripting exercise
View average-cashflow.hs
#!/usr/bin/env runhaskell
Print monthly average cashflow by account.
$ average-cashflow.hs YEAR [JOURNALFILE]
module Main where
simonmichael /
Created May 3, 2014
a prototype squeak port of Ledger, 2007
prototype ledger file parser in squeak
Simon Michael
test scripts:
s1 := LedgerParserTests sample1 readStream
2007/10/7 the fairmont sonoma mission inn & spa
expenses:food:dining $11
You can’t perform that action at this time.