Code Snippets

Here you'll find some snippets and one-liners that I find handy.

Rsync Commands

# Generic copy/sync/backup 
rsync -aAhHEXP /path/to/in/ /path/to/out/
# Copy/Sync/Backup With FAT(32) Destination
rsync -PAah --modify-window=1 /path/to/in/ /path/to/fat32/out/

Nifty Pacman Oneliners [Arch-Specific]

## Listing Packages
# List All Installed Packages
pacman -Qq | sort
# List Explicitly Installed Packages
pacman -Qeq | sort
# List Packages Installed As Dependencies
pacman -Qdq | sort
# List Packages Not in "essential" groups
comm -23 <(One of The Above Commands) <(pacman -Qgq base base-devel multilib-devel | sort)
# List All Packages Not In Repos (AUR or Local/Custom)
pacman -Qmq | sort

## (Re-)Installing Packages
# Reinstall every installed package that is in the repos
comm -23 <(pacman -Qeq | sort) <(pacman -Qmq | sort) | pacman -S -

## Package Cleanup
# Remove all Orphans and their Dependencies
pacman -Rs $(pacman -Qtdq)

## Mirrors
# Generate Up-To-Date Mirror List (reflector package from [community] is required)
sudo reflector -n 10 -l 10 -f 10 -c "United States" --sort rate --save /etc/pacman.d/mirrorlist && sudo pacman -Syy && sudo chmod 655 /etc/pacman.d/mirrorlist

Python Script To Decode URL-Encoded Bittorrent Infohashes

Usage: ./ <Encoded Infohash>
from urllib import unquote
import string 
from sys import argv

test = argv[1]
ihash = unquote(test).encode('hex')
print ihash