DNB and Typing

d4b 56% Tue 09 Apr 2019 08:42:36 AM CEST
d4b 22% Tue 09 Apr 2019 08:45:01 AM CEST
d4b 67% Tue 09 Apr 2019 08:46:57 AM CEST
d4b 67% Tue 09 Apr 2019 08:48:54 AM CEST
d4b 28% Tue 09 Apr 2019 08:50:47 AM CEST
d4b 67% Tue 09 Apr 2019 08:52:42 AM CEST
d4b 00% Tue 09 Apr 2019 08:54:36 AM CEST

Though from now on they should also be available on brainscale.net

Python

Chained try/except blocks

Apparently this is the recommended way to do this, as per this answer and the official Python docs:

def __getattribute__(self, item):
    try:
        return object.__getattribute__(item)
    except AttributeError:
        pass  # fallback to dict
    try:
        return self.dict[item]
    except KeyError:
        raise AttributeError("The object doesn't have such attribute") from None

Easier to ask for forgiveness than permission. This common Python coding style assumes the existence of valid keys or attributes and catches exceptions if the assumption proves false. This clean and fast style is characterized by the presence of many try and except statements. The technique contrasts with the LBYL style common to many other languages such as C.

Get file name without extension

os.path.splitext("path_to_file")[0]

Bash adding symbols to filenames

Adding a + to all the files in the current directory, before the extension: for file in *.jpg; do mv $file $(basename $file .jpg)+.jpg; done (from here)

English

A Kludge kluge (/klʌdʒ, kluːdʒ/) is a workaround or quick-and-dirty solution that is clumsy, inelegant, inefficient, difficult to extend and hard to maintain.

vim reload file currently open

:e is one way to do it.