Python

Skipping the first part of an iterable in Python

Skip elements in iterables until a condition is met using itertools.dropwhile for efficient lazy evaluation that works with generators.

Pausing and resuming a socket server in Python

Build a pausable socket server with Python's socketserver module using threading for intermittent request handling and background tasks.

Debugging a containerized Django application in Jupyter Notebook

Connect Jupyter Notebook to Dockerized Django apps using ipykernel and django-extensions for interactive debugging and data exploration.

Manipulating text with query expressions in Django

Use Django query expressions like Replace, Upper, Lower, Concat, and Substr for efficient database-level text manipulation without fetching data.

Using tqdm with concurrent.fututes in Python

Display progress bars for concurrent Python tasks using tqdm with ThreadPoolExecutor and as_completed for real-time execution monitoring.

Faster bulk_update in Django

Accelerate Django bulk_update operations by 4x using multiprocessing to parallelize database writes across chunked record batches.

Installing Python on macOS with asdf

Manage multiple Python versions on macOS using asdf, a unified version manager replacing pyenv, nvm, and language-specific tools.

Save models with update_fields for better performance in Django

Optimize Django model saves with update_fields parameter to generate leaner SQL queries and improve performance in tight update loops.

Python logging quirks in AWS Lambda environment

Configure Python logging for AWS Lambda's pre-configured handlers while maintaining compatibility with local development environments.

Dissecting an outage caused by eager-loading file content

Learn from a production outage caused by loading large CSV files into memory. Stream process files to prevent OOM errors and crashes.

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.

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.