Skip to content

Instantly share code, notes, and snippets.

View brandonhimpfen's full-sized avatar
:octocat:

Brandon Himpfen brandonhimpfen

:octocat:
View GitHub Profile
@brandonhimpfen
brandonhimpfen / python-progress-bar-no-deps.py
Created January 13, 2026 22:33
A tiny, dependency-free Python progress bar for loops and iterables (supports known totals, unknown totals, and ETA).
#!/usr/bin/env python3
"""
Dependency-free progress bar for Python.
Features:
- Works with a known total OR unknown total.
- Prints ETA when total is known.
- Throttles updates to avoid spamming stdout.
- Safe for long-running loops; finalizes cleanly.
@brandonhimpfen
brandonhimpfen / sql-pagination-patterns.md
Created January 9, 2026 15:46
SQL pagination patterns: LIMIT/OFFSET vs keyset (seek) pagination, with copy-paste queries, indexing tips, and examples for Postgres/MySQL.

SQL Pagination Patterns

Use OFFSET for small datasets and random-access pages. Use keyset/seek for deep paging and stability.

-- SQL Pagination Patterns
-- LIMIT/OFFSET vs Keyset (Seek) Pagination
--
-- OFFSET pagination is simple but can get slow on deep pages and can produce
-- duplicates/missing rows if data changes between requests.
@brandonhimpfen
brandonhimpfen / go-read-file-line-by-line.go
Created January 6, 2026 19:37
Read a file line-by-line in Go using bufio.Scanner (with basic error handling and flags for long lines).
package main
import (
"bufio"
"fmt"
"log"
"os"
)
// Read a file line-by-line using bufio.Scanner.
@brandonhimpfen
brandonhimpfen / js-debounce.js
Created January 2, 2026 08:58
A simple, dependency-free JavaScript debounce utility for limiting how often a function executes.
/**
* debounce(fn, wait)
*
* Delays invoking `fn` until after `wait` milliseconds have elapsed
* since the last time the debounced function was called.
*
* Common use cases:
* - Resize events
* - Scroll handlers
* - Input / search fields
@brandonhimpfen
brandonhimpfen / bash-strict-mode.sh
Created December 30, 2025 15:09
Bash strict mode starter template using set -Eeuo pipefail, with safe defaults, error handling, and argument parsing.
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Bash Strict Mode Starter Template
# -----------------------------------------------------------------------------
# -e : Exit immediately if a command exits with a non-zero status
# -u : Treat unset variables as an error
# -o pipefail : Fail a pipeline if any command fails
# -E : ERR traps are inherited by shell functions
# -----------------------------------------------------------------------------