Skip to content

Instantly share code, notes, and snippets.

View simonmichael's full-sized avatar

Simon Michael simonmichael

View GitHub Profile
@simonmichael
simonmichael / 20221218.org
Last active December 21, 2022 18:37
Results from a run of hledger's ledger-compat test suite

Tested 2022-12-18 with hledger 1.28.99-g016b7759f-20221209, mac-aarch64

@alias

../regress/1384C1D8.test: [Failed]

Command (at line 20): hledger -f- check Expected stderr:

Got stderr: hledger: Error: -:1:1:

@simonmichael
simonmichael / hledger-lib.ghctimes.org
Last active March 25, 2022 22:10
GHC 9.0.2 -ddump-timings output for hledger-lib on a macbook air m1, showing the stack command and some emacs viewing tricks

stack build hledger-lib –force-dirty –ghc-options=’-fforce-recomp -ddump-timings’ -*- mode:org; eval:(hi-lock-mode 1); -*-

Hi-lock: ((“alloc=\w+” (0 ‘hi-blue-b t))) Hi-lock: ((“time=\w\w\w.*” (0 ‘hi-red-b))) Hi-lock: ((“time=\w\w\w\w.*” (0 ‘highlight))) Hi-lock: end

hledger-lib-1.25.99: unregistering (–force-dirty specified) hledger-lib> configure (lib) Configuring hledger-lib-1.25.99…

initializing unit database:

@simonmichael
simonmichael / SM's Haskell Survival Guide.md
Last active March 5, 2022 03:26
SM's Haskell Survival Guide (draft)

SM's Haskell Survival Guide

Somewhat-repeatable recipes for getting a reliable haskell build toolchain installed as of 2022Q1. You might need to make adjustments, eg on Windows, but hopefully not too many.

Set up with ghcup

Current most popular method. Best way to get native arm tools on mac m1. You can use it to install the compiler ghc, build tools cabal and/or stack, and IDE/editor language server hls (under $HOME/.ghcup). Actively maintained.

  • install latest ghcup (manages haskell core tools)
@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 / 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 / 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
@simonmichael
simonmichael / paypalcsv
Last active June 16, 2021 04:03
paypalcsv - download transactions CSV from Paypal's API
#!/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=