Skip to content

Instantly share code, notes, and snippets.

@hfreire
hfreire / upload_download_to_from_aws_glacier_using_aws.sh
Last active Sep 2, 2021
Upload/download to/from AWS Glacier using aws-cli
View upload_download_to_from_aws_glacier_using_aws.sh
# create a vault
aws glacier create-vault --account-id - --vault-name my-vault-name
# check that the vault was created successfully
aws glacier describe-vault --account-id - --vault-name my-vault-name
# upload a file to the vault
aws glacier upload-archive --vault-name my-vault-name --account-id - --archive-description "my-archive-description" --body my-text-file.txt
# request an inventory of the vault
@hfreire
hfreire / qemu_osx_rpi_raspbian_jessie.sh
Last active Jul 16, 2021
How to emulate a Raspberry Pi (Raspbian Jessie) on Mac OSX (El Capitan)
View qemu_osx_rpi_raspbian_jessie.sh
# Install QEMU OSX port with ARM support
sudo port install qemu +target_arm
export QEMU=$(which qemu-system-arm)
# Dowload kernel and export location
curl -OL \
https://github.com/dhruvvyas90/qemu-rpi-kernel/blob/master/kernel-qemu-4.1.7-jessie
export RPI_KERNEL=./kernel-qemu-4.1.7-jessie
# Download filesystem and export location
@hfreire
hfreire / continue_macport_upgrade_outdated_despite_errors.md
Last active Mar 29, 2021
Continue macport upgrade outdated packages despite errors
@hfreire
hfreire / test_download_speed_in_stockholm.sh
Last active Jul 7, 2020
Test download speed in Stockholm
View test_download_speed_in_stockholm.sh
wget -O /dev/null http://hgd-speedtest-1.tele2.net/10GB.zip
# courtesy of Tele2 http://speedtest.tele2.net
@hfreire
hfreire / use_zsh_from_macports_in_macos.sh
Last active Dec 10, 2019
Use zsh from MacPorts in MacOS
View use_zsh_from_macports_in_macos.sh
# 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
View zsh_startup_load_order.txt
+----------------+-----------+-----------+------+
| |Interactive|Interactive|Script|
| |login |non-login | |
+----------------+-----------+-----------+------+
|/etc/zshenv | A | A | A |
+----------------+-----------+-----------+------+
|~/.zshenv | B | B | B |
+----------------+-----------+-----------+------+
|/etc/zprofile | C | | |
+----------------+-----------+-----------+------+
@hfreire
hfreire / bash_startup_load_order.txt
Last active Dec 10, 2019
bash startup load order
View bash_startup_load_order.txt
If you have ever put something in a file like .bashrc and had it not work, or are
confused by why there are so many different files — .bashrc, .bash_profile, .bash_login,
.profile etc. — and what they do, this is for you.
The issue is that Bash sources from a different file based on what kind of shell it thinks
it is in. For an “interactive non-login shell”, it reads .bashrc, but for an “interactive
login shell” it reads from the first of .bash_profile, .bash_login and .profile (only).
There is no sane reason why this should be so; it’s just historical. Follows in more detail.
For Bash, they work as follows. Read down the appropriate column. Executes A, then B, then C,
etc. The B1, B2, B3 means it executes only the first of those files found.
@hfreire
hfreire / rpi-usb.sh
Last active Jul 24, 2019
Enable/disable power on Raspberry Pi USB ports + Ethernet
View rpi-usb.sh
#!/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 / generate_secure_password.sh
Last active Jul 11, 2019
Generate a secure 32 char password with user random seed
View generate_secure_password.sh
apg -n 1 -MCLN -m 32 -s
@hfreire
hfreire / brute_forcing_imap_passwords.md
Created May 10, 2019
Brute forcing IMAP passwords
View brute_forcing_imap_passwords.md
nmap -p143,993 --script imap-brute localhost