Get Directory of Bash Script Being Executed
I needed a quick way to get the directory of the current bash script being executed and a little googling led me to this elegant little bit: # Absolute path to this script. /home/user/bin/foo.sh SCRIPT=$(readlink -f $0) # Absolute path this script is in. /home/user/bin SCRIPTPATH=`dirname $SCRIPT` via fritzthomas
Intersect Two Lists in Python
Very often I find myself combining lists, removing duplicates, or looking for differences or intersects of sets. I have no idea how I have never discovered how useful the set type in python is. Here is a really simple way to find the intersect of two lists/sets: >>> b1 = [1,2,3,4,5,9,11,15] >>> b2 = [4,5,6,7,8] [...]
