Linux Snippets

These are not only linux snippets but also bash snippets and snippets using tools that run under Linux, *nix or sometimes even MacOSX, I should reorder this article someday ;) Settings for more reliable bash scripts set -euo pipefail this gives us …​ -e: exit script if a single command fails -u: exit script if an unset variable is used -o pipefail: return value of a pipeline is the status of the last command to exit with a non-zero status, or zero if no command exited with a non-zero status ...

March 1, 2010 · 15 min · 3006 words · Micha Kops

Python Snippets

Virtual Environments Create and activate a venv python -m venv /path/to/new-env (1) source /path/to/new-env/bin/activate (2) 1 Creates a new virtual environment 2 Activate the new virtual environment Deactivate venv deactivate Save used dependencies to a file pip freeze > dependencies.txt Install dependencies from file pip install -r dependencies.txt Storing and fetching Credentials from the System Keyring I am using jaraco/keyring here: pip install keyring import keyring keyring.set_password("system", "db.sample.password", "xoxo") print(keyring.get_password("system", "db.sample.password")) ...

March 1, 2010 · 1 min · 100 words · Micha Kops