Recent writings

Returning values from a shell function

Understand how return values work in Bash functions. Learn exit codes, status evaluation patterns, and proper boolean returns with true/false commands.

Verifying webhook origin via payload hash signing

Secure webhooks by verifying payload authenticity using HMAC hash signatures with shared secrets, preventing man-in-the-middle attacks.

Recipes from Python SQLite docs

Practical SQLite recipes for Python: execute statements, batch operations, transactions, row factories, and context managers with sqlite3.

Prefer urlsplit over urlparse to destructure URLs

Use Python's urlsplit instead of urlparse for faster URL parsing by skipping the rarely-needed params component in URL decomposition.

Pick random values from an array in SQL(ite)

Emulate Python's random.choice in SQLite using JSON arrays and the random() function. Populate tables with realistic test data efficiently.

ExitStack in Python

Master Python's ExitStack for managing multiple context managers, conditional callbacks, request rollbacks, and avoiding nested with statements.

Compose multiple levels of fixtures in pytest

Combine session and function-scoped pytest fixtures to avoid expensive test setup while maintaining test isolation and preventing state coupling.

Patch where the object is used

Master Python mocking: patch objects at their import location, not where they're defined, to avoid common unittest.mock pitfalls.

Partially assert callable arguments with 'unittest.mock.ANY'

Assert specific mock call arguments while ignoring others using unittest.mock.ANY for flexible test assertions without brittle checks.

When to use 'git pull --rebase'

Fix divergent branch errors with git pull --rebase. Learn when to rebase local commits on top of remote changes for cleaner Git history.

Apply constraints with 'assert' in Python

Use Python assert statements to apply runtime constraints more succinctly than raising ValueError. Learn the trade-offs and best practices.

Automerge Dependabot PRs on GitHub

Automatically merge Dependabot pull requests using GitHub Actions. Configure branch protection and status checks for safe automated dependency updates.

Stream process a CSV file in Python

Process large CSV files without OOM errors by streaming content line-by-line with HTTPX and concurrent.futures for parallel processing.

Bulk operations in Django with process pool

Speed up Django bulk operations with ProcessPoolExecutor while preserving signals and hooks that bulk_create/bulk_update bypass.

Read a CSV file from s3 without saving it to the disk

Download and process S3 CSV files in memory using boto3 and tempfile.NamedTemporaryFile without cluttering disk with temporary files.