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; } |
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>Minimal Accessible Modal</title> | |
| <style> | |
| /* Minimal styling just to make the demo usable */ | |
| .modal-backdrop[hidden] { display: none; } | |
| .modal-backdrop { |
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
| package main | |
| import ( | |
| "bytes" | |
| "context" | |
| "encoding/json" | |
| "fmt" | |
| "io" | |
| "log" | |
| "net" |
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
| package main | |
| import ( | |
| "context" | |
| "fmt" | |
| "io" | |
| "log" | |
| "net" | |
| "net/http" | |
| "time" |
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 | |
| # ----------------------------------------------------------------------------- | |
| # Extract any archive (zip, tar.gz, tgz, tar.bz2, tar.xz, 7z, rar, etc.) | |
| # ----------------------------------------------------------------------------- | |
| # Usage: | |
| # ./bash-extract-archive.sh file.tar.gz | |
| # source this file and call: extract "file.zip" | |
| # | |
| # Requirements (depending on format): | |
| # - tar, unzip, gzip/bzip2/xz, 7z, unrar, cabextract |
NewerOlder