In the middle of the desert you can say anything you want
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 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
From How to use skip and xfail to deal with tests that cannot succeed — pytest documentation on dynamically skipping tests based on a condition:
@pytest.mark.skipif(sys.version_info < (3, 10), reason="requires python3.10 or higher")
def test_function():
Better than my previous approach of if xxx: pytest.skip("...")
inside the tests themselves.
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.
TIL Gitlab has
tig
/ pycharm log /. .., located at “Repository -> Graph”. Really neatI should play more with the existing interfaces of things I use often