RSSAmplifier

Blog

gbenson.net

gbenson.netRSS feed ↗10 posts

Latest posts

longintrepr.h

Did your pip install fail with longintrepr.h: No such file or directory? The file likely is on your system, but it sometime or another it was moved, from /usr/include/python3.xx/longintrepr.h to /usr/include/python3.xx/cpython/longintrepr.h. The proper fix is to update the package in question with the new path, but if you re installing an old version of something or Continue reading longintrepr.h

Docker images by age or size

Files by age, newest first: ls -lt Docker images by age, newest first: docker images --format "{{.CreatedAt}}\t{{.Repository}}:{{.Tag}}" sort -r Files by size, largest first: ls -lS Docker images by size, largest first: docker images --format "{{.Size}}\t{{.Repository}}:{{.Tag}}" sort -rh Why why why??!

Slow boot?

Does your Linux box take forever to boot? The command you’re looking for is systemd-analyze blame

Terminal colours

\x1B[38;5;105m and \x1B[38;5;141m are a great combo.

Python antipattern: Close in finally

Don t do this: thing = Thing() try: thing.do_stuff() finally: thing.close() Do do this: from contextlib import closing with closing(Thing()) as thing: thing.do_stuff() Why is the second better? Using contextlib.closing() ties closing the item to its creation. These baby examples are about equally easy to reason about, with only a single line in the try block, Continue reading Python antipattern:…

Too many git branches?

Do you have too many git branches on the go at once? Here is the command to list them in order of last modification: git for-each-ref --sort=-committerdate refs/heads

Python atomic counter

Do you need a thread-safe atomic counter in Python? Use itertools.count(): >>> from itertools import count >>> counter = count() >>> next(counter) 0 >>> next(counter) 1 >>> next(counter) 2 I found this in the decorator package, labelled Atomic get-and-increment provided by the GIL. So simple! So cool!

git submodule forgetting

Did you forget the -r when cloning a git repo with submodules? The command you re looking for is git submodule update --init

GitLab YAML Docker Registry client

Have you written a Docker Registry API client in GitLab CI/CD YAML? I have. # Delete candidate image from CI repository. clean-image: stage: .post except: - main variables: AUTH_API: "$CI_SERVER_URL/jwt/auth" SCOPE: "repository:$CI_PROJECT_PATH" REGISTRY_API: "https://$CI_REGISTRY/v2/$CI_PROJECT_PATH" before_script: - which jq >/dev/null (sudo apt-get update & sudo apt-get -y install jq) script: -…

sudo tee >/dev/null

Need to redirect to a file from sudo? Use sudo tee >/dev/null: $ sudo ls -l /root >/root/files.list -bash: /root/files.list: Permission denied $ sudo ls -l /root sudo tee /root/files.list >/dev/null $ sudo ls -l /root/files.list -rw-r--r-- 1 root root 94 Oct 18 09:31 /root/files.list