Skip to content

Instantly share code, notes, and snippets.

View simonmichael's full-sized avatar

Simon Michael simonmichael

View GitHub Profile
@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 / a.hs
Last active March 1, 2019 22:51
strange non-exhaustive error with GHC 7
addOrAssignAmountAndCheckAssertionB :: Posting -> Balancing s Posting
addOrAssignAmountAndCheckAssertionB p@Posting{paccount=acc, pamount=amt, pbalanceassertion=mba} -- line 730
| hasAmount p = do
newbal <- addAmountB acc amt
whenM (R.reader bsAssrt) $ checkBalanceAssertionB p newbal
return p
| Nothing <- mba = return p
| Just BalanceAssertion{baamount,batotal} <- mba = do
(diff,newbal) <- case batotal of
True -> do
@simonmichael
simonmichael / a.journal
Created February 25, 2019 22:10
hledger: applying transaction modifier rules selectively with tags
; transaction modifier (auto postings) rule
; Txns after 2019/1/1 with a (unbalanced) revenues posting,
; and which don't have the modified: tag, like this:
;
;2019/2/1 (cwYYYYMM) client cw | payment
; (JS:revenues:cw) $-1000
;
; will have some standard postings added. This can be used for forecasting.
;
= date:2019- JS:revenues:cw not:tag:modified
@simonmichael
simonmichael / a.txt
Created January 31, 2019 16:45
hledger commands list 20190131
$ hledger
-------------------------------------------------------------------------------
hledger 1.12.99
Usage: hledger COMMAND [OPTIONS] [-- ADDONCMDOPTIONS]
Commands (+ addons found in $PATH):
Data entry (these commands modify the journal file):
add add transactions using guided prompts
+iadd add transactions using curses ui
case () of
_ | changes==movedown -> printf "%d,%dv " x y
_ | changes==moveleft -> printf "<%d,%d " x y
_ | changes==moveright -> printf "%d,%d> " x y
_ -> printf "%d,%d. " x y
@simonmichael
simonmichael / a.hs
Created December 10, 2018 12:36
parsing with scanf
parsePoints s = s
& lines
& map (SC.scanf [SC.fmt|position=<%d, %d> velocity=<%d, %d>|])
& catMaybes
& map (SC.printf [SC.fmt|((%d,%d), (%d,%d))|])
& map read :: [Point]
@simonmichael
simonmichael / wellsfargo.hs
Last active January 19, 2019 17:42
A WIP Wells Fargo bank scraper in haskell that I couldn't get working reliably (2016). If you do, please let me know!
#!/usr/bin/env stack
{- stack exec
--verbosity info
--package webdriver
-- ghc
-}
--package data-default
-- stack exec ghci wellsfargo
-- stack exec ghc wellsfargohs
--
@simonmichael
simonmichael / Makefile.linux
Last active November 5, 2018 20:26
darcs record speed test scripts
# Makefile.linux
# The mac makefile is more up to date.
TIME=/usr/bin/time -f%E
DARCS=darcs
test:
for N in \
100 200 300 400 500 600 700 800 900 \
1000 2000 3000 4000 5000 6000 7000 8000 9000 \
@simonmichael
simonmichael / 1 event log
Created October 28, 2018 17:17
intellij-haskell beta 30 errors on restarting REPLS
10:08 AM Restarting Haskell project
10:09 AM [global-stack-repl] Stack REPL will be started with command: /Users/simon/.local/bin/stack repl --with-ghc intero --no-load --no-build --ghci-options -ghci-script=/Users/simon/Library/Caches/com.github.rikvdkleij.intellij-haskell/repl.ghci --silent --ghc-options -v1 --no-package-hiding --test --bench
10:09 AM [global-stack-repl] Stack REPL is started
10:09 AM [global-stack-repl] Command :q took + 7 ms
10:09 AM [global-stack-repl] stdout: Leaving GHCi.