Skip to content

Instantly share code, notes, and snippets.

@kljohann
kljohann / vundle-to-mr.vim
Created July 22, 2013 18:54
`:source %` this to print out all your [vundle](https://github.com/gmarik/vundle) bundles converted to [myrepos](http://myrepos.branchable.com/) format.
try
unlet s:mrconfig
"unlet s:bpath
catch /No such/
endtry
let s:mrconfig = []
for bundle in g:bundles
let s:bpath = bundle.path()
if $HOME != ''
let s:bpath = substitute(s:bpath, '^\V'.$HOME, '$HOME', '')
@kljohann
kljohann / after_ftplugin_ledger.vim
Created July 22, 2013 18:58
Join transactions in a ledger file. All transaction metadata will be transferred to the first transaction. Postings of other transactions will be lost. I use this to reconcile auto-generated (by converting from CSV) postings.
function! LedgerJoinTransactions(begin, end)
let xacts = ledger#transactions(a:begin, a:end)
if len(xacts) < 2
return
endif
let target = remove(xacts, 0)
call reverse(xacts)
" safe view / position
@kljohann
kljohann / split_transactions.py
Last active June 10, 2022 22:44
split transactions by posting date (beancount)
__author__ = "Johann Klähn <[email protected]>"
import collections
import math
import itertools
import datetime
from beancount.core import data
from beancount.core.interpolate import balance_incomplete_postings
[core]
excludesfile = ~/.gitignore
whitespace = trailing-space,space-before-tab
[color]
ui = auto
[push]
default = upstream
Xcursor.theme: neutral
! See also fonts.conf
! https://wiki.archlinux.org/index.php/Font_Configuration
! http://www.lagom.nl/lcd-test/subpixel.php
Xft.hinting: true
Xft.hintstyle: hintfull
Xft.lcdfilter: lcddefault
Xft.rgba: rgb
include "/usr/share/X11/locale/en_US.UTF-8/Compose"
include "/home/jk/.XCompose.base"
include "/home/jk/.XCompose.math"
<Multi_key> <ISO_Level5_Shift> <elementof> <elementof> : "∋" U220B
<Multi_key> <slash> <ISO_Level5_Shift> <elementof> <elementof> : "∌" U220C
<Multi_key> <slash> <ISO_Level5_Shift> <elementof> <space> : "∉" U2209
<Multi_key> <slash> <ISO_Level5_Shift> <U2203> : "∄" U2204
<Multi_key> <ISO_Level5_Shift> <integral> <o> : "∮" U222E
<Multi_key> <o> <ISO_Level5_Shift> <integral> : "∮" U222E
#!/bin/zsh
setopt local_options err_exit warn_create_global
this_cmd=$0:t
usage () {
echo -e "Usage: $this_cmd [OPTION]... [NAME] [--] [COMMANDS]...\n" 1>&2
cat 1>&2 <<END
Arguments:
NAME Name of the (parent) session to attach to.
cmake -GNinja .. -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DLLVM_USE_LINKER=gold -DBUILD_SHARED_LIBS=ON -DLLVM_USE_SPLIT_DWARF=ON -DLLVM_OPTIMIZED_TABLEGEN=ON -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_PARALLEL_LINK_JOBS=2 -DLLVM_USE_SPLIT_DWARF=ON -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_INSTALL_PREFIX=$HOME/llvm -DCMAKE_BUILD_TYPE=Debug
@kljohann
kljohann / eg.zsh
Created July 29, 2018 10:20
eg.zsh
eg () {
(( $+1 )) || {
cat >&2 <<END
Usage: $0 [<args>...] [<expr>]
args: Arguments to pass to man.
expr: Command line argument to search for.
Defaults to jump to the "EXAMPLE" section.
Examples:
#!/usr/bin/python3
from pathlib import Path
import shlex
import subprocess
import sys
OPERATIONS = (
("merge", "MERGE_HEAD"),