Code Snippets

Category: Utilities

Date Arithmetic in Bash

GNU date supports relative expressions — yesterday, +7 days, etc.

Author: chris

Debounce Function in JS

Classic debounce — delay invoking fn until X ms after the last call.

Author: chris

Parse and Stringify JSON

Safely round-trip JSON with JSON.parse and JSON.stringify.

Author: chris

Async/Await with Try/Catch

Wrap awaitable calls in try/catch for ergonomic error handling.

Author: chris

Composer Autoload Bootstrap

Minimal entry-point that boots Composer’s autoloader.

Author: chris

JSON Encode and Decode in PHP

Round-trip JSON with JSON_THROW_ON_ERROR for safe decoding.

Author: chris

Wrap and Unwrap Errors in Go

Wrap errors with fmt.Errorf %w and inspect with errors.Is / As.

Author: chris

JSON Marshal and Unmarshal in Go

Encode and decode structs with the encoding/json stdlib.

Author: chris

Error Handling with anyhow

Use anyhow::Result and the `?` operator for ergonomic errors.

Author: chris