Skip to content

Instantly share code, notes, and snippets.

View dblume's full-sized avatar

David Blume dblume

View GitHub Profile
@dblume
dblume / chart_log_delays.py
Last active February 16, 2026 01:43
Given cronjob logs, chart delays of each job run.
#!/usr/bin/env python3
# git ls-files | entr -c sh -c 'ctags -R *; ./chart_log_delays.py'
import os
import sys
from argparse import ArgumentParser
from typing import Callable
from pathlib import Path
from collections import namedtuple
import datetime
@dblume
dblume / bashrc_snippet.sh
Last active December 13, 2025 18:32
Bash functions that execute commands on your behalf should append them to the history (see line 11)
gf() {
local file
if type batcat >/dev/null 2>&1; then
file="$(git ls-files | fzf --preview 'batcat --color=always --wrap never --terminal-width $COLUMNS {}' --preview-window=right:60%)"
else
file="$(git ls-files | fzf --preview 'cat {}' --preview-window=right:60%)"
fi
if [ -n "$file" ]; then
echo ${EDITOR:-vim} "$file"
# vvvvvvvv It's more useful to have "vim [file]" in your history than just a "gf".
@dblume
dblume / search-regex.sh
Last active February 14, 2026 20:21
Shell script to test regex for identifying paths to files esp with linenumbers
#!/usr/bin/env bash
#
# This is for a tmux shortcut to search terminal output for file paths.
#
# Original Regex from https://jyn.dev/how-i-use-my-terminal/
# See this gist: https://gist.github.com/dblume/51d36f5656ecbb03012c604e4156ecd6
#
# Used here: https://github.com/dblume/dotfiles/blob/main/.tmux.conf#L40
#
# Note for macOS users: if you get no matches, the (\\>|$) at the end may be the
@dblume
dblume / cost_basis_puzzle.py
Last active October 23, 2024 04:46
Given a list of transactions, can we determine a strategy to match an actual cost basis?
#!/usr/bin/env python3
from collections import namedtuple
from dataclasses import dataclass
import csv
import datetime
from typing import Sequence, Callable
__author__ = 'David Blume'
__copyright__ = "Copyright 2024, David Blume"
__license__ = "Apache 2.0"
@dblume
dblume / cost_basis.py
Last active October 21, 2024 05:03
Determine the cost basis of a robo-traded stock from Wealthfront exported as Quicken QFX
#!/usr/bin/env python3
from argparse import ArgumentParser, RawDescriptionHelpFormatter
from collections import namedtuple
from dataclasses import dataclass
import csv
from typing import Sequence
import operator
__author__ = 'David Blume'
__copyright__ = "Copyright 2024, David Blume"
@dblume
dblume / convert_qfx_to_csv.py
Last active January 9, 2026 15:13
Convert Wealthfront's exported Quicken QFX format to CSV
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Converts Wealthfront's exported QFX to CSV.
# Thanks @egill512
# https://gist.github.com/whistler/e7c21c70d1cbb9c4b15d?permalink_comment_id=3296132#gistcomment-3296132
from csv import DictWriter
from glob import glob
import ofxparse
@dblume
dblume / logpower.sh
Last active May 12, 2024 06:39
Log to file the current state of the battery to track trends
#!/usr/bin/env bash
#
# A script I use to track the health of my FrameWork laptop battery
#
# Usage Ex.,
#
# $ logpower closing lid
#
# will write to stdout and to a file:
# 1. Timestamp
@dblume
dblume / timestamps_match_clock.py
Created February 27, 2024 21:40
Unix Timestamps whose lower digits match the clock time's digits too
#!/usr/bin/env python3
import time
# Timestamps whose lower digits are zero when the clock's are too HH:MM:SS "00:00:00"
# Eg., 1800000000 = 2027-01-15 00:00:00
million = 1_00_00_00
t = (int(time.time()) // million + 1) * million
while time.strftime("%H%M%S", time.localtime(t)) != '000000':
t += million
print(f'{t} = {time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(t))}')
@dblume
dblume / openpgp.md
Created May 27, 2023 08:29
Proof for keyoxide

openpgp4fpr:1CBD499C61C7A3A7DED3935F5E21C0D40ED9EB54

@dblume
dblume / qrcodes.sh
Created March 20, 2021 02:24
Find a QR code with as few black dots as possible.
#!/usr/bin/env bash
#
# Spoiler:
# $ ./qrcodes.sh | sort | head
# 416 http://7c.dblu.me
# 416 https://j.dblu.me
# 416 http://wc.dblu.me
# 420 http://2E.dblu.me
# 420 http://73.dblu.me
#