Skip to content

Instantly share code, notes, and snippets.

@dardo82
Created August 24, 2014 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dardo82/fd9203d24eeee60203ff to your computer and use it in GitHub Desktop.
Save dardo82/fd9203d24eeee60203ff to your computer and use it in GitHub Desktop.
Dynamic UTI encoder and decoder
DU="dyn-uti"; DUC="$DU-conv"; ZB="zbase32"; ZBP="$ZB.py"; mkdir -p $DUC; cd $DUC; pip install $ZB; cp `pip show $ZB | grep / | cut -d: -f2`/$ZB/$ZBP .
sed -i '' '/^mnet32/s/^/uti_alphabet = "abcdefghkmnpqrstuvwxyz0123456789" # Mac OSX Dynamic UTI\'$'\n/' $ZBP; sed -i '' '/^chars/s/mnet32/uti/' $ZBP
DUE="$DU-enc.sh"; DUD="$DU-dec.sh"; echo "python -c \"import $ZB; print $ZB.b2a('\$1')\"" > $DUE; echo "python -c \"import $ZB; print $ZB.a2b('\$1')\"" > $DUD
chmod a+x $DUE $DUD; echo "Usage:\\ncd $DUC\\n./$DUE '?0=7:3=text/X-frob:1=frob'\\n./$DUD 'h62d4r34gq81k3p2su1zuppgsm10esvvhzxhe55c'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment