In the middle of the desert you can say anything you want
Stumbled upon zyedidia/micro: A modern and intuitive terminal-based text editor. Simple text editor that wants to be the successor of nano, CLI-based. The static .tar.gz contains an executable that can be directly run. Played with it for 30 seconds and it’s really neat**.
(Need something like vim for someone who doesn’t like vim, but wants to edit files on servers in an easy way in case nano isn’t installed and no sudo rights.)
There are online resources:
SO thread1 version:
diff <(jq --sort-keys . A.json) <(jq --sort-keys . B.json)
Wrapped it into a function in my .zshrc
:
jdiff() {
diff <(jq --sort-keys . "$1") <(jq --sort-keys . "$2")
}
vimdiff
is a thing and does this by default!
Otherwise2 diff has the parameters -y
, and --suppress-common-lines
is useful.
This led to jdiff
’s brother jdiffy
:
jdiffy() {
diff -y --suppress-common-lines <(jq --sort-keys . "$1") <(jq --sort-keys . "$2")
}
git diff --no-index
allows to use git diff without the thing needing to be inside a repo. Used it heavily previously for some of its fancier functions. Say hi to gdiff
:
gdiff() {
git diff --no-index "$1" "$2"
}
Rancher
Two ways to run stuff
kubectl
Via yaml:
- name: podname
image: "docker/image"
command:
- /bin/sh
- -c
- while true; do echo $(date) >> /tmp/out; sleep 1; done
Kubernetes Workloads and Pods | Rancher Manager
Assigning Pods to Nodes | Kubernetes:
nodeName
is a simple direct way
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx
nodeName: kube-01
TIL - when looking how to clean printer heads - that some printers can do it automatically! Can be started both through the OS GUI or the printer itself (if it has buttons and stuff).
Wikihow (lol) as the first result in Google gave me enough to learn about automatic cleaning being a thing: How to Clean Print Heads: Clogged & Dried Up Print Heads; How to Clean a Printhead for Better Ink Efficiency < Tech Takes - HP.com Singapore +
Seen first in [[garden/it/230228-1835 Python Callable Protocols for complex Callable typing]].
pass
)If you need to add typing to a complex Callable, with, say, parameter names etc., there are Callback Protocols.
# NB "self" is included!
class Combiner(Protocol):
def __call__(self, *vals: bytes, maxlen: Optional[int] = None) -> list[bytes]: ...
def batch_proc(data: Iterable[bytes], cb_results: Combiner) -> bytes:
for item in data:
Python 3.7 needs typing_extensions
, 3.8+ support it natively.
See also: python typing signature (typing.Callable) for function with kwargs - Stack Overflow
Was doing a graph-like stucture to easily explain a really complex decision tree that’s not really a tree, but I was really looking for an existing thing: A state machine!
And it’s even an existing programming pattern: StateMachine — Python 3 Patterns, Recipes and Idioms
The book I didn’t know I needed!
Anyway, existing implementations:
I really like how feature-complete and documented transitions
is - callbacks etc.
git diff [--options] <commit> <commit> [--] [<path>...]
For example, for ‘between now and 2 commits back’:
$ git diff HEAD^^ HEAD main.c
$ git diff HEAD~2 HEAD -- main.c
Paths need to be relative to the root of the repo.
Another option (can do different files) is:
git diff <revision_1>:<file_1> <revision_2>:<file_2>
Source: git - How do I diff the same file between two different commits on the same branch? - Stack Overflow
(Bonus: the --
makes it work for files with weird names like -p
, good for scripts but rarely needed in practice).
Previously: 230221-1406 Gitlab has a git graph and comparisons
Adventures in cross-platform programming: I used fnmatch to basically simulate globs in a place where regexes were overkill, but not for filenames.
On windows, paths are case insensitive and therefore fnmatch is case insensitive too, leading to unexpected behaviour.
fnmatchcase() is case-sensitive regardless of OS.