TextWrangler Text Filter collection
Location ~/Library/Application Support/TextWrangler/Text Filters
Tidy HTML.sh
#!/bin/sh # run "tidy" on the file given as 1st (and only) parameter. # /usr/bin/tidy -utf8 -asxhtml -indent -wrap 100 -quiet 2> /dev/null
Tidy XML.sh
#!/bin/sh XMLLINT_INDENT=$" " xmllint --format --encode utf-8 -
Tidy JSON.py
#!/usr/bin/python import fileinput import json print json.dumps( json.loads(''.join([line.strip() for line in fileinput.input()])), sort_keys=True, indent=2)
Compact JSON.py
#!/usr/bin/python import fileinput import json if __name__ == "__main__": text = '' for line in fileinput.input(): text = text + ' ' + line.strip() jsonObj = json.loads(text) print json.dumps(jsonObj, sort_keys=False, separators=(',',':'))py
YARN Acls.sh
#!/bin/sh # gawk '{match($0,"([a-zA-Z]+).acl_submit_applications=(.*)",a); if(a[1] != "") print a[1] "\t" a[2] }' # awk -F: '/user1|user2|zeppelin/{print $1 "\t" $5}' /etc/passwd gawk '{ match($0,"([a-zA-Z]+).acl_submit_applications=(.*)",a); if(a[1] != "" && a[2] ~ "[^ ]*") { str = a[2] gsub(/ ,/, "", str) gsub(/,/, "|", str) str_grep = "grep -E \"" str "\" /etc/passwd" str_awk = "awk -F: '\''/" str "/{print $1 \"\\t\" $5}'\'' /etc/passwd" #Bad code below if (str == " ") { str_grep = ""; str_awk = ""} print a[1] "\t" a[2] "\t" str_grep "\t" str_awk } }'