Skip to content

Instantly share code, notes, and snippets.

View bjoernbuth's full-sized avatar

Bjoern Buth bjoernbuth

View GitHub Profile
@bjoernbuth
bjoernbuth / microgpt.py
Created February 12, 2026 12:23 — forked from karpathy/microgpt.py
microgpt
"""
The most atomic way to train and inference a GPT in pure, dependency-free Python.
This file is the complete algorithm.
Everything else is just efficiency.
@karpathy
"""
import os # os.path.exists
import math # math.log, math.exp
@bjoernbuth
bjoernbuth / main.py
Created February 6, 2026 11:17 — forked from duke8585/main.py
FIFO with python
import dis
from typing import assert_type
from zoneinfo import available_timezones
import pandas as pd
from collections import deque
def prepare_trade_republic_transactions(file_path):
"""
Prepares and filters transaction data from a custom Trade Republic CSV file via pyTR package.
@bjoernbuth
bjoernbuth / nbstripout
Created March 12, 2025 18:41 — forked from minrk/nbstripout
git pre-commit hook for stripping output from IPython notebooks
#!/usr/bin/env python
"""strip outputs from an IPython Notebook
Opens a notebook, strips its output, and writes the outputless version to the original file.
Useful mainly as a git filter or pre-commit hook for users who don't want to track output in VCS.
This does mostly the same thing as the `Clear All Output` command in the notebook UI.
LICENSE: Public Domain
@bjoernbuth
bjoernbuth / colorlog.py
Last active February 5, 2025 07:23 — forked from hosackm/colorlog.py
Colored logger module using Colorama
import logging
from colorama import init, Fore, Back
init(autoreset=True)
class ColorFormatter(logging.Formatter):
# Change this dictionary to suit your coloring needs!
COLORS = {
"WARNING": Fore.RED,
@bjoernbuth
bjoernbuth / getopts.sh
Created January 27, 2025 20:55 — forked from dimo414/getopts.sh
getopts function helper
#!/bin/bash
#
# Helper utility to simplify using Bash's getopts utility, and make it usable with functions.
#
# Example usage:
# foo() {
# local _usage=... # optional usage string
# eval "$(parse_opts 'ab:f:v')" # provide a standard getopts optstring
# echo "f is $f" # opts are now local variables
# if (( a )); then # check boolean flags with (( ... ))
@bjoernbuth
bjoernbuth / bookmarks_from_sql.py
Created January 11, 2025 00:07 — forked from iafisher/bookmarks_from_sql.py
Programmatically access your Firefox bookmarks
"""
A script to automatically export bookmarks from Firefox's SQLite database.
There does not seem to be a programmatic way to get Firefox to export its bookmarks in
the conventional HTML format. However, you can access the bookmark information directly
in Firefox's internal database, which is what this script does.
Always be careful when working with the internal database! If you delete data, you will
likely not be able to recover it.
@bjoernbuth
bjoernbuth / Microsoft.PowerShell_profile.ps1
Created December 25, 2024 21:43 — forked from MahmadSharaf/Microsoft.PowerShell_profile.ps1
Python Virtual Environment Wrapper for PowerShell
# Adding this script to PS profile allows quick actions for Python venv library.
# Create a variable where virtual environments are located
$VENV_HOME="$HOME\.virtualenvs\"
# A function to list all available virtual environments
function Get-Venvs{
Get-ChildItem -Path $VENV_HOME -Name
}
@bjoernbuth
bjoernbuth / venv_wrapper
Created September 15, 2023 18:17 — forked from dbtek/venv_wrapper
Python 3 venv wrapper. Manages all virtual environments under ~/.venv/ .
# include following in .bashrc / .bash_profile / .zshrc
# usage
# $ mkvenv myvirtualenv # creates venv under ~/.venv/
# $ venv myvirtualenv # activates venv
# $ deactivate # deactivates venv
# $ rmvenv myvirtualenv # removes venv
export VENV_HOME="$HOME/.venv"
[[ -d $VENV_HOME ]] || mkdir $VENV_HOME
@bjoernbuth
bjoernbuth / jmn-url-get-title.el
Created September 12, 2023 19:36 — forked from jmn/jmn-url-get-title.el
How to make org-mode org-insert-link (C-c C-l) automatically fill in the description from a webpage
;; How to make org-mode org-insert-link (C-c C-l) automatically fill in the description from a webpage:
(defun jmn/url-get-title (url &optional descr)
"Takes a URL and returns the value of the <title> HTML tag,
Thanks to https://frozenlock.org/tag/url-retrieve/ for documenting url-retrieve"
(let ((buffer (url-retrieve-synchronously url))
(title nil))
(save-excursion
(set-buffer buffer)
(goto-char (point-min))
@bjoernbuth
bjoernbuth / .pylintrc
Created September 12, 2023 19:20 — forked from xen/.pylintrc
[MASTER]
# Specify a configuration file.
#rcfile=
# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
# Profiled execution.