Skip to content

Instantly share code, notes, and snippets.

View bjoernbuth's full-sized avatar

Bjoern Buth bjoernbuth

View GitHub Profile
"""
The most atomic way to train and run inference for 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.
@duke8585
duke8585 / main.py
Last active February 6, 2026 11:17
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.
@joedefen
joedefen / DotFileScripts.md
Last active February 28, 2025 13:59
Pattern for Handling Normal and Dirty DotFiles using Two Bare Git Repositories
@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
@MahmadSharaf
MahmadSharaf / Microsoft.PowerShell_profile.ps1
Created January 18, 2022 20:57
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
}
@adojos
adojos / git-for-win_Pacman_Install.md
Last active February 13, 2026 00:24
Git: Pacman Installation on Git For Windows #git

Git For Windows (GitBash) Pacman Installation

The 'Git for Windows' by default does not come with MSYS2 package manager called 'Pacman' and hence it is a limited version or subset of the MSYS2. Also the bash which supplied wih 'Git for Windows' is not a full version of bash hence does not provide for full Linux environment.

However you can get package manager support inside 'Git for Windows' in following ways :

  1. Install full MSYS2 and build Git for Windows yourself (Most git users don't require all packages and MSYS2)
  2. Install Git for Windows SDK (heavy & consumes around 3-5 Gb space)
  3. Use a hack to merge the MSYS2 Pacman packages with your existing Git for Windows installation
@tchen
tchen / sample.py
Last active December 20, 2024 04:33
openpyxl: dealing with merged cells
# When exporting excel spreadsheets with merged cells, only the first cell of the merged cell has a value
# This snippet allow you to take the value from the first cell for all the other cells within the merged range
# Tested with openpyxl 3.0.7 as of 2021-06-17
#
# References:
# https://stackoverflow.com/questions/39574991/how-to-detect-merged-cells-in-excel-with-openpyxl
# https://openpyxl.readthedocs.io/en/stable/api/openpyxl.worksheet.merge.html
import openpyxl
def parent_of_merged_cell(cell):
@dimo414
dimo414 / getopts.sh
Last active January 27, 2025 20:55
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 (( ... ))
@iafisher
iafisher / bookmarks_from_sql.py
Created March 9, 2019 22:54
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.