Skip to content

Instantly share code, notes, and snippets.

View arnauldvm's full-sized avatar

Arnauld Van Muysewinkel arnauldvm

View GitHub Profile
@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 / 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 / pre-commit
Last active October 7, 2018 20:56
Git pre-commit hook for python code
#!/bin/sh
# requires py_compile and pycodestyle Python module
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
@arnauldvm
arnauldvm / pre-commit
Created September 13, 2018 09:04
Git pre-commit hook for python code
#!/bin/sh
# requires py_compile and pycodestyle Python module
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
@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

from os import path
import inspect
scriptdir = path.dirname(inspect.getfile(inspect.currentframe()))