This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| /** | |
| * Split a large JSONL (NDJSON) file into chunks by line count or size. | |
| * | |
| * Features: | |
| * - Streams input line-by-line | |
| * - Writes chunk files incrementally | |
| * - Supports splitting by: | |
| * --max-lines=N | |
| * --max-bytes=N |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| /** | |
| * Stream-transform JSONL (NDJSON) from stdin to stdout with backpressure. | |
| * | |
| * Features: | |
| * - Reads JSONL from stdin | |
| * - Parses one JSON object per line | |
| * - Applies transform/filter logic | |
| * - Writes JSONL to stdout | |
| * - Respects stdout backpressure |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| /** | |
| * Stream-write JSONL (NDJSON) safely with atomic write. | |
| * | |
| * Pattern: | |
| * 1) Write to a temp file in the same directory | |
| * 2) fsync (best-effort) to reduce risk of partial writes | |
| * 3) Rename temp -> final (atomic on the same filesystem) | |
| * | |
| * Usage: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| /** | |
| * Parse a delimited file (CSV-like) line-by-line with streaming output (no deps). | |
| * | |
| * Features: | |
| * - Streams the input file (memory efficient) | |
| * - Supports a delimiter (default: comma) | |
| * - Handles quoted fields (basic CSV rules: "escaped "" quotes") | |
| * - Optional header row -> outputs objects | |
| * - Outputs JSON Lines (NDJSON) to stdout (great for pipelines) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| /** | |
| * Read a large file line-by-line (streams) in Node.js. | |
| * | |
| * Usage: | |
| * node node-read-large-file-line-by-line.js ./bigfile.txt | |
| * | |
| * Notes: | |
| * - Uses streams to avoid loading the entire file into memory. | |
| * - readline provides a clean async iterator interface. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """ | |
| Basic SQLite migrations runner (no dependencies). | |
| Pattern: | |
| - Keep a list of migrations (id, name, sql) | |
| - Store applied migrations in a table: schema_migrations | |
| - Apply missing migrations in order inside a transaction | |
| Good for: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """ | |
| Basic SQLite helper (no dependencies). | |
| Features: | |
| - Context-managed connection | |
| - Row results as dict-like objects (sqlite3.Row) | |
| - Helpers for execute / executemany / fetchone / fetchall | |
| - Optional pragmas for better defaults |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # ----------------------------------------------------------------------------- | |
| # Bash retry helper with exponential backoff + jitter | |
| # ----------------------------------------------------------------------------- | |
| # Why jitter? | |
| # - If many clients retry at the same fixed interval, they can synchronize and | |
| # cause thundering herds. Jitter spreads retries out randomly. | |
| # | |
| # Usage: | |
| # retry_jitter <attempts> <base_delay_seconds> <max_delay_seconds> <command...> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # ----------------------------------------------------------------------------- | |
| # Bash retry helper | |
| # ----------------------------------------------------------------------------- | |
| # Usage: | |
| # retry <attempts> <delay_seconds> <command...> | |
| # | |
| # Example: | |
| # retry 5 2 curl -f https://example.com | |
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| <title>Responsive Images: srcset + sizes</title> | |
| <style> | |
| /* Demo-only styling */ | |
| .container { max-width: 900px; margin: 2rem auto; padding: 0 1rem; } | |
| img { max-width: 100%; height: auto; display: block; border-radius: 12px; } |
NewerOlder