Skip to content

Instantly share code, notes, and snippets.

Avatar

Luiz Berti luizberti

View GitHub Profile
@luizberti
luizberti / nixos-installer.fish
Last active Jul 18, 2021
A custom NixOS install script
View nixos-installer.fish
# ==============
# 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
@luizberti
luizberti / useful.sh
Last active Nov 20, 2020
My stash of useful and perhaps over-engineered POSIX tricks
View useful.sh
#!/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 Mar 4, 2021
Wireguard setup tested on Ubuntu 20.04
View wireguard.sh
#!/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 / tinyotp.py
Created Jan 19, 2017
Tiny RFC4226 HOTP and TOTP implementation (CC0 Licensed)
View tinyotp.py
"""
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 / colortest.sh
Last active Dec 7, 2016
🎨 Tests terminal color output
View colortest.sh
#!/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"