Paste a predefined text via a keyboard shortcut

The aim of this tip is to have a keyboard shortcut to quickly configure my favorite kubectl aliases for the CKA exam :-) Install xdotool and xsel sudo apt install xdotool xsel Add this keyboard shortcut (In Gnome: Settings > Keyboard > Customize Shortcuts > Custom Shortcut) /bin/bash -c 'echo -n "source <(kubectl completion bash) && alias k=kubectl && complete -F __start_kubectl k && alias kgp=\"kubectl get pods\"" | xsel && xdotool click 2' Source: https://askubuntu....

March 25, 2021 · 1 min · JC

Update author and email in git history

Imagine you have already made some commits in a git repo and you want to update your mail address and/or your name ? In short, you want to re-write git history with good informations. Here is a script who can do that. Put here in parent folder of git repo you want to edit: #!/bin/sh git filter-branch --env-filter ' OLD_EMAIL="incorrect-email@domain.tld" CORRECT_NAME="Your Name" CORRECT_EMAIL="good-email@domain.tld" if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ] then export GIT_COMMITTER_NAME="$CORRECT_NAME" export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL" fi if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ] then export GIT_AUTHOR_NAME="$CORRECT_NAME" export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL" fi ' --tag-name-filter cat -- --branches --tags This script will search for all commits done by incorrect-email@domain....

February 24, 2021 · 1 min · JC

Multiple ansible versions with python virtualenv

TL;DR export ANSIBLE_VERSION=x.x.x mkdir -p ~/ansible_venv cd ~/ansible_venv python3 -m venv ansible${ANSIBLE_VERSION} source ansible${ANSIBLE_VERSION}/bin/activate pip install --upgrade pip setuptools pip install ansible==${ANSIBLE_VERSION} ansible-lint netaddr pbr hvac jmespath passlib bcrypt . ~/ansible_venv/ansible${ANSIBLE_VERSION}/bin/activate Long story Install python3-venv package: sudo apt install python3-venv Create an ~/ansible_venv directory: mkdir ~/ansible_venv From ~/ansible_venv directory, create your virtual ansible environment: e.g for ansible 2.9.16: python3 -m venv ansible2.9.16 Once this environment created, activate it: source ansible2.9.16/bin/activate You will see your shell has changed, with name of virtualenv you are currently using....

February 24, 2021 · 1 min · JC

Memo Helm

helm is a kind of apt-get for kubernetes. As tiller poses a potential security threat, we will focus here on helm v3, the current stable release. With helm v2, you had to install tiller component in the kube-system namespace of your cluster, then have to add a RBAC account, as explained here. Ressources: https://helm.sh https://v3.helm.sh https://helm.sh/docs/using_helm/ https://v3.helm.sh/docs/intro/quickstart/ Installation Just download from Github Helm Releases and put the helm binary in one of your PATH’s folder....

February 14, 2021 · 1 min · JC

Backup android app, data included, no root needed, with adb

adb is the Android CLI tool with which you can interact with your android device, from your PC You must enable developer mode (tap 7 times on the build version in parameters) and install adb on your PC. Fetch application APK To get the list of your installed applications: adb shell pm list packages -f -3 If you want to fetch all apk of your installed apps: for APP in $(adb shell pm list packages -3 -f) do adb pull $( echo ${APP} | sed "s/^package://" | sed "s/base....

January 29, 2021 · 3 min · JC