/ LIVING

Code Snippets

This is a living list of code snippets and commands that have been useful to me.

Python

Convert between CSV and JSON

https://books.agiliq.com/projects/tweetable-python/en/latest/file-conversion.html#csv-to-json

Shell

Generate list of all file extensions in a directory

find . -type f | awk -F. '{print $NF}' | sort | uniq | awk 'BEGIN { ORS=" "; print "[" }; {printf "'.%s',", $1}; END { print "]" }' && echo

Get width/height of all images in directory

find . -type f -exec sips -g pixelHeight -g pixelWidth {} \;

Spoof your MAC address

# see your current mac address
ifconfig <network interface, such as en1> | grep ether
# see other mac addresses on the network
arp -a
# set your mac address
sudo ifconfig <network interface> ether <new mac address>