Skip to content

Instantly share code, notes, and snippets.

View AlexElvers's full-sized avatar

Alexander Elvers AlexElvers

  • Berlin
View GitHub Profile
AlexElvers /
Created March 22, 2018 12:45
Interactive shutdown popup in GNOME when pressing the power button
# Replaces /etc/acpi/
case "$1" in
case "$2" in
logger 'PowerButton pressed'
gnome_users=$(pgrep gnome-session | xargs ps -o %u -p | sed 1d)
while read -r user; do
AlexElvers /
Created November 25, 2016 00:43
Make the top left pixel slightly transparent so that Twitter does not convert it into ugly JPEG
twittersafepng() {
convert "$1" -alpha on -fill '#000000fe' -draw 'matte 0,0 point' "$outfile"
echo "written to $outfile"
AlexElvers /
Created September 6, 2016 16:09
Create doveadm password hashes in Python
This function encodes the password similar to `doveadm pw -p PASSWORD -r ROUNDS -s SCHEME`, e.g.
import crypt
def encode_password(password: str, rounds: int = None, scheme: str = None) -> str:
Encode password with random salt.
AlexElvers /
Last active July 26, 2019 20:47
Search and activate virtualenv in current directory or parent directories
activate() {
local path_="$PWD"
while [[ "$path_" != "/" ]]; do
if [[ -e "$path_/Pipfile" ]]; then
echo "Pipfile found in $path_"
pipenv shell
return 0
elif [[ -e "$path_/env/bin/activate" ]]; then
echo "virtual env found in $path_"
source "$path_/env/bin/activate"

Keybase proof

I hereby claim:

  • I am alexelvers on github.
  • I am aelvers ( on keybase.
  • I have a public key whose fingerprint is 29C9 1451 2D0B 7FEB D63E 43B7 7DB1 096F FD76 DBBA

To claim this, I am signing this object: