Sheet ⁨05⁩ · ⁨Code snippets⁩Surveyed ⁨2026⁩

Code Snippets

Working code you can lift straight into a project: shell, Python, TypeScript, Terraform. Each snippet says what it does and where it bites.

Python Subprocess: Run Shell Commands Safely and Capture Output

Python Subprocess: Run Shell Commands Safely and Capture Output

Quick Tip Pass a list, never a string, and subprocess never starts a shell at all. That one habit removes an entire category of vulnerability from your automation. The Problem Every sc

Bash Argument Parsing with getopts: Build CLI Scripts with Flags and Options

Bash Argument Parsing with getopts: Build CLI Scripts with Flags and Options

Quick Tip getopts is a shell builtin that parses short flags properly, including grouped ones like -vf. Here is the full pattern, including the shift everybody forgets and the `local OPTIND

Node.js Graceful Shutdown: Handle SIGTERM in Express and Fastify

Node.js Graceful Shutdown: Handle SIGTERM in Express and Fastify

Quick Tip Node's default SIGTERM handler exits immediately, so every deploy kills your in-flight requests. Here's a shutdown handler that drains them properly, in about 80 lines. The Problem

Python Context Managers: Writing Clean Resource Handling with `with` Statements

Python Context Managers: Writing Clean Resource Handling with `with` Statements

Everyone learns with open(...) and stops. That is a shame, because the protocol behind it is two methods and it solves a whole category of bug: cleanup that does not happen on the paths you forgot a

Upload Files to AWS S3 with Pre-Signed URLs in Node.js

Upload Files to AWS S3 with Pre-Signed URLs in Node.js

Routing file uploads through your API server is the default that nobody questions, and it is usually the wrong one. The bytes travel to your compute, sit in memory or a temp file, then travel again to

Multi-Environment Secret Management with HashiCorp Vault

Multi-Environment Secret Management with HashiCorp Vault

Managing secrets safely across multiple environments with HashiCorp Vault Storing secrets in .env files, hardcoding them, or even using separate secret managers per environment creates security

AWS DynamoDB CRUD Operations in Node.js with the AWS SDK v3

AWS DynamoDB CRUD Operations in Node.js with the AWS SDK v3

Quick Tip Wrap the low-level DynamoDB client in a DynamoDBDocumentClient so you pass plain JavaScript objects in and get plain objects back, then guard your writes with ConditionExpression an

Python Dataclass Patterns: Slots, Frozen Instances, and Field Validation

Python Dataclass Patterns: Slots, Frozen Instances, and Field Validation

Quick Tip Reach for @dataclass(slots=True, frozen=True) with a post_init check and you get a small, immutable, validated value object in about five lines. The Problem The problem