In the middle of the desert you can say anything you want
textwrap — Text wrapping and filling — Python 3.14.7 documentation
Everything You Can Do with Python’s textwrap Module | Martin Heinz | Personal Website & Blog
TODO
Previously: 250527-1937 taskfile go-task bits
Poe the Poet. Previously I used 250527-1937 taskfile go-task bits for something similar.
Poe the Poet is a batteries included task runner that works well with poetry or with uv.
Tasks defined in pyproject.toml. Especially neat are (Python) script tasks that allow you to run any importable thingy from your code. 1
Playing with it, current pytest.ini (rel: 260827-2259 Complexipy for code complexity)
[tool.poe.tasks]
test = "pytest"
test-now = "pytest -m now --pdb"
check-complexity = "uv run complexipy src --failed --suggest-refactors --max-complexity 15"
ty = "uv run ty check src --output-format concise"
fty = "uv run ty check src --output-format concise --fix"
ruff = "uv run ruff check src"
fruff = "uv run ruff check src --fix"
fruff-unsafe = "uv run ruff check src --fix --unsafe-fixes"
black = "uv run black src --check"
fblack = "uv run black src"
(Is this better than adding usual pyproject.toml uv script endpoints? It supports using inputs from other scripts but if you end up doing that you probably may need a real scripting language) ↩︎
NestedText — Structured Data for Humans — NestedText 3.8 documentation
Like YAML but easier and less confusing. See their comparison with other formats.
Has only strings as data type, the consumer does its own validation, which makes the syntax simple. Brilliant. (Also no need to quote, or escape, or deal with the Norway problem1.)
Katheryn McDaniel:
position: president
address:
> 138 Almond Street
> Topeka, Kansas 20697
phone:
cell: 1-210-555-5297
home: 1-210-555-8470
# Katheryn prefers that we always call her on her cell phone.
email: KateMcD@aol.com
additional roles:
- board member
Previously: 211020-1304 YAML Norway issues ↩︎
Main surprise:
lowercase only minor words that are three letters or fewer in a title or heading (except the first word in a title or subtitle or the first word after a colon, em dash, or end punctuation in a heading):
- short conjunctions (e.g., “and,” “as,” “but,” “for,” “if,” “nor,” “or,” “so,” “yet”)
- articles (“a,” “an,” “the”)
- short prepositions (e.g., “as,” “at,” “by,” “for,” “in,” “of,” “off,” “on,” “per,” “to,” “up,” “via”)
My package was 156mb because my tests/ were 120mb.
Uv uses hatchling
uv build output · Issue #7938 · astral-sh/uvTL;DR add this to pyproject.toml
[tool.hatch.build.targets.sdist]
exclude = [
"tests/"
]
Before/after:
# before
-rw-r--r-- 1 sh sh 156M Jul 13 13:20 pkg-9.2.0.tar.gz
# after
-rw-r--r-- 1 sh sh 8.3M Jul 13 13:15 pkg-9.3.0.tar.gz
# yay!
How to speed up Python application startup time - DEV Community
This tells you the time for imports:
PYTHONPROFILEIMPORTTIME=True uv run my_program.py
Colors - Core concepts - Tailwind CSS
Click to copy the OKLCH value or shift+click to copy the nearest hex value.
Oh that’s cool I could use that. The only reason I found it was because https://quasar.dev/style/color-palette/#color-list didn’t give clean access to the hex values so I kept looking :)
I think I’ve read about this years ago somewhere, just thought of it
For all my (fish) CLI aliases a , is an OK prefix to use, it even supports completion.
alias ,isodate='date +%F'
No idea about any downsides yet, will play with this for a week or so.
function ,blist -d "search and show bitwarden credentials"
command bw list items --search "$argv" | jq '.[].login | [.username, .password]' -c
end
function ,bcp -d "copy password of the first matching bitwarden item"
command bw list items --search $argv | jq .[0].login.password -r | xc
echo "copied password for '$argv'"
end
# etc, I see potential here!
``
Also TIL: fish functions can have a description that will be shown when tab completing! function functionname -d 'function description'
Isn’t it beautiful?
I wanted the metadata.annotation pod-requests, viewable in node config -> YAML on the Rancher webgui.
Came up w/ this:
kubectl get node node-name -o template --template='{{ index .metadata.annotations "management.cattle.io/pod-requests" }}'
# | jq '.["nvidia.com/gpu"]'
It refused to allow me to use - and / inside the name (k get node nodename -o template --template={{.metadata.annotations.management.cattle.io/pod-requests}} didn’t work), solution from Helm templating doesn’t let me use dash in names - Stack Overflow.
Fun version w/ templates and json (there has to be a better way):
k get node nodename -o template --template='{"requests": {{ index .metadata.annotations "management.cattle.io/pod-requests" }}, "limits": {{ index .metadata.annotations "management.cattle.io/pod-requests" }}, "total": {"nvidia.com/gpu": {{ index .metadata.labels "nvidia.com/gpu.count" }} } }' | jq .
Returns:
{
"requests": {
"cpu": "19795m",
"memory": "7450Mi",
"nvidia.com/gpu": "1",
"pods": "37"
},
"limits": {
"cpu": "19795m",
"memory": "7450Mi",
"nvidia.com/gpu": "1",
"pods": "37"
},
"total": {
"nvidia.com/gpu": 1
}
}
Or even
k get node nodename -o template --template='{"requests": {{ index .metadata.annotations "management.cattle.io/pod-requests" }}, "limits": {{ index .metadata.annotations "management.cattle.io/pod-requests" }}, "total": {"nvidia.com/gpu": {{ index .metadata.labels "nvidia.com/gpu.count" }} } }' | jq '. | [.requests["nvidia.com/gpu"], .limits["nvidia.com/gpu"], .total["nvidia.com/gpu"] | tonumber]' -c
# -> [2,1,4]
I’m bored an why not. If I didn’t need this more often than once a year would do this properly but..
# k get nodes -A -o yaml > /tmp/xxx
# let $d = open /tmp/xxx.yaml
k get nodes -A -o yaml | from yaml | let $d
$d.items | get metadata | select name labels."nvidia.com/gpu.count"? annotations."management.cattle.io/pod-limits"? annotations."management.cattle.io/pod-requests"? | rename name gpucount limits requests | update limits {|| from json} | update requests {|| from json} | update limits {|$i| $i.limits."nvidia.com/gpu"?} | update requests {|$i| $i.requests."nvidia.com/gpu"?}