Skip to content

Instantly share code, notes, and snippets.

View adept's full-sized avatar

Dmitry Astapov adept

View GitHub Profile
@adept
adept / Issue
Created October 10, 2019 20:24
hledger does not like currency conversions
# This is fine
$ hledger bal -f paypal.journal
£-100 cash
2 SHR shares
--------------------
2 SHR
£-100
# Attempt to report cost makes paypal account go blerghhh :(
$ hledger register -f transfer.journal cash
2019/01/01 Bought 1 share @ .. bank:cash £-100 £-100
2019/02/01 Bought 1 share @ .. bank:cash £-300 £-400
2019/03/01 Bought 1 share @ .. bank:cash £-300 £-700
2019/03/01 Sold my shares @ .. bank:cash £600 £-100
2019/03/01 Bough my shares b.. bank:cash £-600 £-700
$ hledger register -f transfer.journal shares
2019/01/01 Bought 1 share @ .. assets:shares 1 1
@adept
adept / sankey.sh
Created September 5, 2019 23:49
hledger to sankey.csv
#!/bin/bash
(
echo "source,target,value";
(
hledger -f 2018.journal is --cost -O csv -N --tree \
| sed -nre 's/["£]//g; /expenses,/{s/^/income,/;p}; /expenses[^,]/{s/(.+):([^:]+),/\1,\1:\2,/;p}; /income[^,]/{s/(.+):([^:]+),/\1:\2,\1,/;p};' \
| awk -vOFS=, -F, '$3>300 {print $1,$2,$3}' \
| sort -rn -t, -k3
)
) > sankey.csv
@adept
adept / index.html
Created September 5, 2019 23:47
Google Charts Sankey
<html>
<body>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div id="sankey_multiple" style="width: 1800px; height: 1200px;"></div>
<script type="text/javascript">
var raw_data = [];
@adept
adept / index.html
Created September 5, 2019 23:47
Amscharts sankey
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<body>
<!-- Styles -->
<style>
#chartdiv {
width: 100%;
height: 1000px
}
@adept
adept / index.html
Created September 5, 2019 23:46
Highcharts Sankey
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<body>
<!-- Styles -->
<style>
#container {
min-width: 300px;
max-width: 1600px;
height: 1000px;
@adept
adept / init.journal
Created March 15, 2019 20:24
Gist shows two attempts to create csv import rules for transactions in "foreign" currency with cost in "home" currency
2019-01-01 init
equity:opening balances
assets:bank $100
@adept
adept / eveneven.ctt
Last active December 21, 2017 16:33
odd+odd, even+even, even+odd
module eveneven where
Path (A : U) (a b : A) : U = PathP (<_> A) a b
data bool = true | false
data nat = zero
| suc (n : nat)
add (m : nat) : nat -> nat = split
@adept
adept / andsym.ctt
Last active December 19, 2017 16:05
And is symmetric
module andsym where
Path (A : U) (a b : A) : U = PathP (<_> A) a b
data bool = true | false
and (x:bool) : bool -> bool = split
true -> x
false -> false
{-
Lecture 1 on cubicaltt (Cubical Type Theory)
--------------------------------------------------------------------------
Anders Mörtberg
This is the first lecture in a series of hands-on lectures about
cubicaltt given at Inria Sophia Antipolis.
To try the system clone the github repository and follow the
compilation instructions at: