Skip to content

Instantly share code, notes, and snippets.

@hfreire
hfreire / shrink_ext3_partition.md
Last active January 19, 2019 19:03
Shrink an ext3 partition on a SD card in OSX
Unmount disk
sudo diskutil unmount /dev/disk2
Check partition status
sudo e2fsck -f /dev/disk2s3
@hfreire
hfreire / base64uuid.java
Created May 8, 2019 10:12
A Base64 UUID encoder/decoder optimised for encoding and decoding UUID hashes in only 22 characters (instead of 36)
import java.nio.ByteBuffer;
import java.util.Base64;
import java.util.UUID;
public class base64uuid {
private static final Base64.Encoder BASE64_URL_ENCODER = Base64.getUrlEncoder().withoutPadding();
public static void main(String[] args) {
try {
if (args.length < 2) {
@hfreire
hfreire / ban_unban_ip_fail2ban.md
Last active May 10, 2019 09:34
Ban/unban an IP address from Fail2ban

Ban IP address 1.1.1.1 jailed within ssh

fail2ban-client set dovecot banip 1.1.1.1

Unban IP address 1.1.1.1 jailed within ssh

fail2ban-client set dovecot unbanip 1.1.1.1
@hfreire
hfreire / brute_forcing_imap_passwords.md
Created May 10, 2019 09:39
Brute forcing IMAP passwords
nmap -p143,993 --script imap-brute localhost
@hfreire
hfreire / generate_secure_password.sh
Last active July 11, 2019 15:01
Generate a secure 32 char password with user random seed
apg -n 1 -MCLN -m 32 -s
@hfreire
hfreire / rpi-usb.sh
Last active July 24, 2019 17:39
Enable/disable power on Raspberry Pi USB ports + Ethernet
#!/bin/sh
SOC_USB=/sys/devices/platform/soc/20980000.usb
if [ ! -d $SOC_USB ];
then
SOC_USB=/sys/devices/platform/soc/3f980000.usb # Raspberry Pi 3
fi
BUSPOWER=$SOC_USB/buspower
@hfreire
hfreire / zsh_startup_load_order.txt
Created December 10, 2019 09:08
zsh startup load order
+----------------+-----------+-----------+------+
| |Interactive|Interactive|Script|
| |login |non-login | |
+----------------+-----------+-----------+------+
|/etc/zshenv | A | A | A |
+----------------+-----------+-----------+------+
|~/.zshenv | B | B | B |
+----------------+-----------+-----------+------+
|/etc/zprofile | C | | |
+----------------+-----------+-----------+------+
@hfreire
hfreire / use_zsh_from_macports_in_macos.sh
Last active December 10, 2019 10:00
Use zsh from MacPorts in MacOS
# Install latest zsh version using macports
sudo port install zsh
# Add macports zsh as an available shell interpreter
echo /opt/local/bin/zsh >> /etc/shells
# Set macports zsh as the default shell interpreter
chsh -s /opt/local/bin/zsh
# Open a new terminal window
@hfreire
hfreire / test_download_speed_in_stockholm.sh
Last active July 7, 2020 09:11
Test download speed in Stockholm
wget -O /dev/null http://hgd-speedtest-1.tele2.net/10GB.zip
# courtesy of Tele2 http://speedtest.tele2.net
@hfreire
hfreire / continue_macport_upgrade_outdated_despite_errors.md
Last active March 29, 2021 19:10
Continue macport upgrade outdated packages despite errors
sudo port -p upgrade outdated