Skip to content

Instantly share code, notes, and snippets.

View luizberti's full-sized avatar

Luiz Berti luizberti

View GitHub Profile
@luizberti
luizberti / colortest.sh
Last active December 7, 2016 21:23
🎨 Tests terminal color output
#!/usr/bin/env bash
echo -e "\033[0mNC (No color)"
echo -e "\033[1;37mWHITE\t\033[0;30mBLACK"
echo -e "\033[0;34mBLUE\t\033[1;34mLIGHT_BLUE"
echo -e "\033[0;32mGREEN\t\033[1;32mLIGHT_GREEN"
echo -e "\033[0;36mCYAN\t\033[1;36mLIGHT_CYAN"
echo -e "\033[0;31mRED\t\033[1;31mLIGHT_RED"
echo -e "\033[0;35mPURPLE\t\033[1;35mLIGHT_PURPLE"
@luizberti
luizberti / tinyotp.py
Created January 19, 2017 06:02
⌛ Tiny RFC4226 HOTP and TOTP implementation (CC0 Licensed)
"""
https://tools.ietf.org/rfc/rfc4226.txt <= this is implemented
https://tools.ietf.org/rfc/rfc6238.txt <= this is not (yet)
"""
from base64 import b32decode
from hashlib import sha1
from hmac import new
from time import time
@luizberti
luizberti / useful.sh
Last active November 20, 2020 16:50
My stash of useful and perhaps over-engineered POSIX tricks
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
if [ "$EUID" = 0 ]; then echo "DO NOT RUN THIS AS ROOT!" >&2 && exit 1; fi
# GLOBAL PARAMETERS
user='luizberti' # sometimes used when $USER would yield incorrect results
@luizberti
luizberti / wireguard.sh
Last active March 4, 2021 13:45
Wireguard setup tested on Ubuntu 20.04
#!/usr/bin/env bash
set -o errexit
set -o pipefail
command -v ufw &> /dev/null || { echo you need to install ufw; exit 1; }
command -v wg &> /dev/null || { echo you need to install wg; exit 1; }
command -v wg-quick &> /dev/null || { echo you need to install wg-quick; exit 1; }
command -v systemctl &> /dev/null || { echo you need systemd to use $0; exit 1; }
modprobe wireguard # checks if kernel module is present
@luizberti
luizberti / nixos-installer.fish
Last active March 15, 2023 21:11
A custom NixOS install script
# ==============
# DISK SELECTION
# ==============
set --local devices (lsblk --list --nodeps --noheadings --output=name,type | awk '$2 == "disk" {print $1}')
if not set -q disk
echo 'DISK DEVICES AVALIABLE:' $devices
read --local --prompt-str='Which device to install on? ' disk
end