Skip to content

Instantly share code, notes, and snippets.

DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
@arobb
arobb / sierra-virtualbox-install.md
Last active November 24, 2020 13:15
Install macOS Sierra in VirtualBox on macOS host

Step 1 (Creating a bootable macOS Sierra ISO for VirtualBox):

  1. hdiutil attach /Applications/Install\ macOS\ Sierra\ Public\ Beta.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
  2. hdiutil create -o /tmp/Sierra.cdr -size 7316m -layout SPUD -fs HFS+J
  3. hdiutil attach /tmp/Sierra.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/install_build
  4. asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
  5. rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
  6. cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
  7. cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist
re.findall(r'((?:[0-9a-f-A-F.:]+)(?:[.:]+)(?:[0-9a-f-A-F.:]+))', 'f 2001:0db8:85a3:0000:0000:8a2e:0370:7334 1.1.1.1 ::1 234.34.55.3 fed')
https://superuser.com/questions/792427/creating-a-large-file-of-random-bytes-quickly
Slight modification to watch progress
dd if=<(openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt < /dev/zero) \
bs=1M count=7000 iflag=fullblock \
| pv -pterb > random-7G.txt
# https://apple.stackexchange.com/a/70189
sudo port install bash
Add /opt/local/bin/bash to /etc/shells
chsh -s /opt/local/bin/bash
Open a new tab and check echo $BASH_VERSION
@arobb
arobb / random-text-mac-and-linux.sh
Last active February 23, 2021 14:45
Generate random text
# Bash for macOS and Linux
LC_CTYPE=C tr -cd '[:alnum:]' < /dev/urandom | fold -w30 | head -n1
# Python
import binascii, os
length=10
binascii.b2a_hex(os.urandom(length)).decode('utf-8')[0:length]
#
# Determine which OS we are in
#
platform='unknown'
unamestr=$(uname)
case $unamestr in
Darwin)
platform='mac'
;;
@arobb
arobb / raspbian-build-config.txt
Last active January 17, 2019 07:08
Setting up Debian to build Raspbian images
# Done on Debian Stretch
# Configure local user as 'pi'
# Source for build process: https://github.com/RPi-Distro/pi-gen/blob/master/README.md
# Install sudo
# /etc/sudoers.d/010-pi
pi ALL=(ALL) ALL
# Dependencies
@arobb
arobb / tar-and-encrypt
Created November 26, 2019 00:32
Quick tar and encrypt
# Include files that have been symlinked
tar -czf backup.tar.gz --dereference ./backup
gpg --armor --output backup.tar.gz.gpg --symmetric --cipher-algo AES256 backup.tar.gz
# Decrypt for a bunch of files
read -s -p "Enter Password: " pw
echo -ne "\033[0K\r"
echo "$pw" | gpg --batch --passphrase-fd 0 --output backup.tar.gz --decrypt backup.tar.gz.gpg