Skip to content

Instantly share code, notes, and snippets.

View arnauldvm's full-sized avatar

Arnauld Van Muysewinkel arnauldvm

View GitHub Profile
@arnauldvm
arnauldvm / .gitconfig
Last active March 25, 2025 12:02
Git sync all local tracking branches with remotes
[alias]
tracking = "!f() { git for-each-ref --format '%(refname:short):%(upstream:short)' 'refs/heads' | egrep -v ':$'; }; f"
is-clean-workdir = "!f() { git diff --stat --exit-code || { echo \"Workdir dirty\"; exit 1; }; }; f"
is-clean-index = "!f() { git diff --stat --cached --exit-code || { echo \"Index dirty\"; exit 2; }; }; f"
is-clean = "!f() { git is-clean-workdir && git is-clean-index; }; f"
co-merge = "!f() { local=\"$1\"; remote=\"$2\"; git checkout \"$local\"; git merge --ff-only \"$remote\"; }; f"
current-branch = rev-parse --abbrev-ref HEAD
sync = "!f() { git is-clean || { echo Aborting sync.; exit 1; }; current=$(git current-branch); git fetch --all; git tracking | while IFS=: read local remote; do echo \"Merging $local with $remote\"; git co-merge \"$local\" \"$remote\"; done 3>&1 1>&2 2>&3 | egrep -i --color 'fatal|$' 3>&1 1>&2 2>&3; git checkout \"$current\"; }; f"
@arnauldvm
arnauldvm / .bash
Created June 5, 2021 22:16
Generate booklet page numbers
(n=16; for i in $(seq 1 2 $((n/2)) ); do echo -n "$((n-i+1)),$i,$((i+1)),$((n-i)),"; done | sed 's/,$/\n/')
@arnauldvm
arnauldvm / .sh
Created January 9, 2020 08:08
Upgrade all Python packages with pip
# https://stackoverflow.com/questions/2720014/how-to-upgrade-all-python-packages-with-pip
pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
@arnauldvm
arnauldvm / .md
Created November 5, 2019 09:34
How to keep environment variables when using sudo
@arnauldvm
arnauldvm / .md
Last active November 5, 2019 09:32
Trusting additional CAs in Fedora / RHEL / CentOS

https://www.happyassassin.net/2015/01/14/trusting-additional-cas-in-fedora-rhel-centos-dont-append-to-etcpkitlscertsca-bundle-crt-or-etcpkitlscert-pem/

On Fedora since 19, RHEL / CentOS 7, and RHEL / CentOS 6 since this update, the Shared System Certificates feature is available. With that system, the correct method is to place the certificate to be trusted (in PEM format) in /etc/pki/ca-trust/source/anchors/ and run sudo update-ca-trust. (If the certificate is in OpenSSL’s extended BEGIN TRUSTED CERTIFICATE format, place it in /etc/pki/ca-trust/source).

@arnauldvm
arnauldvm / git-commit-style.md
Last active April 10, 2019 06:53
git style guide

Remember:

| {type}({scope}): {subject} | | {body} (optional) |

{type}:

  • feat (new feature for the user, not a new feature for build script)
  • fix (bug fix for the user, not a fix to a build script)
  • docs (changes to the documentation only)
@arnauldvm
arnauldvm / sym-encrypt.sh
Last active March 13, 2019 15:41
Symmetric encryption using openssl
openssl rand 16 | base64 > temp_key
echo "Data to be encrypted" | openssl aes-256-cbc -pass file:temp_key > data.encrypted
# Send the file "data.encrypted"
# Send the temp_key (if possible, encrypted with the public key of the recipient)
# Recipient side:
openssl aes-256-cbc -d -in data.encrypted -pass file:temp_key
# See also: https://bjornjohansen.no/encrypt-file-using-ssh-key
@arnauldvm
arnauldvm / listfonts.puml
Last active March 13, 2019 15:40
Plantuml fonts
@startuml
listfonts
@enduml
@arnauldvm
arnauldvm / comment.md
Last active March 13, 2019 15:39
Pseudo comment in markdown
[//]: # (This may be the most platform independent comment)

See also

@arnauldvm
arnauldvm / dest_if.sh
Last active March 13, 2019 15:38
Determine network interface used for a given destination
$ ip route get 10.32.213.84
10.32.213.84 via 10.0.239.1 dev bond1.509 src 10.0.239.163
cache mtu 1500 advmss 1460 hoplimit 64