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
| import re | |
| class WhitespaceRemover: | |
| """Remove whitespace from text using different strategies. | |
| All methods remove *Unicode whitespace* (not just ASCII spaces). | |
| Choose a method based on readability, performance, and workload size. | |
| """ |
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
| # Set up the prompt | |
| # 1. This MUST be here for the $(...) or ${...} to work | |
| setopt PROMPT_SUBST | |
| # 2. Tell the venv script not to mess with the prompt | |
| export VIRTUAL_ENV_DISABLE_PROMPT=1 | |
| # 3. The prompt string (no spaces inside the parentheses) | |
| PROMPT='${VIRTUAL_ENV:+(${VIRTUAL_ENV:t}) }%m:%1~ %# ' |
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
| """ | |
| datetime_util.py | |
| Utility helpers for working with timezone-aware datetimes. | |
| This module provides: | |
| - Predefined, commonly used timezone constants (UTC, JST, ET, etc.) | |
| - Convenience functions for getting the current time in specific regions | |
| - Safe conversion utilities that enforce timezone awareness | |
| - ISO 8601 serialization and parsing helpers |
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
| def parse_number(x: int | float | str | None): | |
| """Parse a numeric string into int or float. | |
| Return None for empty or common null markers; leave non-string inputs unchanged. | |
| """ | |
| if not isinstance(x, str): | |
| return x | |
| s = x.strip().replace(",", "") |
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
| # 1. Configures unpacked packages | |
| # 2. Fixes broken dependencies | |
| # 3. Removes unused packages | |
| # 4. Clears out the local repository of retrieved package files | |
| repair-clean: ## | |
| @sudo dpkg --configure -a && \ | |
| sudo apt install -f && \ | |
| sudo apt autoremove -y && \ | |
| sudo apt autoclean |
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
| # --- Configuration --- | |
| SOURCE_DIR := /path/to/src/ | |
| DEST_HOST := host_name_in_ssh_config | |
| DEST_PATH := /path/to/dest | |
| # --- Flags --- | |
| # -a: Archive (preserve permissions/times) | |
| # -v: Verbose (see what's happening) | |
| # -z: Compress (faster over network) | |
| # -R: Relative (ensures directory structure is preserved)/Don't use -> redundant in this context |
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
| # --- Configuration Constants --- | |
| DB_HOST ?= mysql.example.com | |
| DB_NAME ?= dbname | |
| DB_USER ?= dbuser | |
| BACKUP_DIR ?= ./backups | |
| DATE := $(shell date +%Y-%m-%d_%H-%M-%S) | |
| # Restore settings | |
| # Usage: make restore RESTORE_FILE=./backups/xxx.sql.gz | |
| RESTORE_FILE ?= |
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
| def strip_df(df): | |
| """Strip leading and trailing whitespace from DataFrame string cells, leaving other types unchanged.""" | |
| return df.map(lambda s: s.strip() if isinstance(s, str) else s) |
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
| Column | Type | Meaning | Rules | |
|---|---|---|---|---|
| entity | string | Thing being measured | Stable label, not human prose | |
| variable | string | What is measured | Atomic, no units | |
| value | numeric | Measured value | Float/decimal only | |
| unit | string | Measurement unit | %, g/100g, mg/L, etc. | |
| basis | string | Unit basis | w/w, w/v, dry, as_is | |
| method | string | Measurement method | Optional | |
| source | string | Source name | File/site/report | |
| source_id | string | Stable source key | URL, DOI, hash | |
| observed_at | string/date | When observed | ISO-8601 |
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 | |
| set -euo pipefail | |
| # mdtable2csv: Convert Markdown tables to CSV. | |
| # Handles alignment rows, trims cells, escapes CSV safely, and respects escaped pipes (\|). | |
| mdtable2csv() { | |
| local in out | |
| if [[ $# -lt 1 || $# -gt 2 ]]; then |
NewerOlder