Skip to content

Instantly share code, notes, and snippets.

@cjlyth
cjlyth / .profile
Created October 22, 2013 23:19
NVM load script, include this in .profile instead of the one they package
hash nvm 2>/dev/null
if [ "$?" == "1" ]; then
if [ -f "$HOME/.nvm/nvm.sh" ]; then
. $HOME/.nvm/nvm.sh
if [ -f "$HOME/.nvm/bash_completion" ]; then
. $HOME/.nvm/bash_completion
fi
fi
fi
@cjlyth
cjlyth / json.awk
Created October 18, 2013 22:58
gawk script to flatten and read a javascript object, built for a small use case that involved reading a node.js package.json
#!/usr/bin/gawk -f
BEGIN {
RS="(\"*[[:alnum:]*]\"[ \t]*:[ \t]*)?\"*[ \t]*(,|{)+[ \t]*|\n[ \t]+\"|(\"[[:alnum:]*]\"[ \t]*:[ \t]*)?{|\"+[\n]+";
FS="\"[ \t]*:[ \t]*|\"?[ \t]*:[ \t]*\"";
column_format ="| %-39s";
cols = 0; rows = 0;