Skip to content

Instantly share code, notes, and snippets.

Avatar

Simon Michael simonmichael

View GitHub Profile
@simonmichael
simonmichael / avodonosov.journal
Last active Sep 8, 2021
Working out a reporting challenge from HN, part 2. See also part 1: https://gist.github.com/simonmichael/3bb42cd82b4afd437305d10ad914b9ec
View avodonosov.journal
; 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 Sep 8, 2021
Working out a reporting challenge from HN, part 1. See also part 2 (foreign exchange gains): https://gist.github.com/simonmichael/28f94ce2bd73318e4fccbfa7c9fc7e87
View avodonosov-example.journal
; 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 / Makefile
Last active Aug 11, 2021
elaborate cron/make rules for periodically, automatically, cleanly git-committing (hledger) files, with logs for troubleshooting
View Makefile
# 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 Jun 22, 2021
updated scripts for downloading paypal transactions for hledger
View paypaljson
#!/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
@simonmichael
simonmichael / paypalcsv
Last active Jun 16, 2021
paypalcsv - download transactions CSV from Paypal's API
View paypalcsv
#!/bin/bash
# Download last 30 days of transaction history from Paypal as CSV.
# brew install jsonpp jq
# npm install -g json2csv
# credentials from an API app created in https://developer.paypal.com
CLIENT_ID=
SECRET=
@simonmichael
simonmichael / Caddyfile
Last active Apr 27, 2021
caddy 2 configs, WIP
View Caddyfile
# https://caddyserver.com/docs/caddyfile/options
{
email webmaster@joyful.com
}
# import everything in this directory beginning with a lowercase letter (not this file, dot files, or autosave files)
# import [a-z]*
# can't do it with caddy 2 ?
#import *
import hledger.org
@simonmichael
simonmichael / Balance.md
Last active Mar 5, 2021
draft of balance report types doc
View Balance.md

For https://github.com/simonmichael/hledger/pull/1496

Balance report types

For more flexible reporting, there are three important option groups:

hledger balance [CALCULATIONTYPE] [ACCUMULATIONTYPE] [VALUATIONTYPE] ...

The first two are the most important: calculation type selects the basic calculation to perform for each table cell, while

@simonmichael
simonmichael / buy-and-sell-btc-adjusting-basis-on-both.journal
Last active Mar 3, 2021
hledger entries for adjusting cost basis of investments
View buy-and-sell-btc-adjusting-basis-on-both.journal
comment
Journal entries describing a stock or cryptocurrency purchase and
sale, with cost basis adjustments to account for fees. In this
example, even though selling at a higher price, the high fees
turn the gain into a loss.
This is just one way to record these; I have tried to split
out the parts for clarity. Opening and closing transactions
and some reports have been added to show the results and
@simonmichael
simonmichael / symlinkghc
Last active Mar 1, 2021
symlinkghc - Symbolically link the ghc tools provided by the global stack resolver into PATH
View symlinkghc
#!/bin/sh
# Usage: symlinkghc
# Symbolically link the ghc tools provided by the global stack resolver
# (ghc ghci runghc runhaskell ghc-pkg haddock hp2ps hpc hsc2hs,
# ~/.stack/global-project/stack.yaml)
# into ~/.local/bin, so that they are always available at the command
# line for quick experiments. ~/.local/bin should be in your PATH.
# Similarly named executables/links in that directory will be overwritten.
# GHC will be downloaded if needed, eg if you just updated the global stack resolver.
# Caveat: these will see only the ghc package db by default, not new packages you have installed.
@simonmichael
simonmichael / .emacs
Last active Jun 20, 2021
Emacs org-capture template for hledger/ledger/PTA transactions
View .emacs
(setq org-capture-templates '(
;...
("t" "h/ledger transaction" plain
(file "~/finance/2020.journal")
"%(org-read-date) %^{Description}
%^{Category|expenses:food:groceries|expenses:food:dining|expenses:transport:gasoline|expenses:home|expenses:medical|expenses:entertainment|revenues:consulting|revenues:misc} %^{Amount}
%^{Asset/liability account|assets:cash|assets:bank:checking|liabilities:bank:credit card}"
:empty-lines 1)
))