Parse JSON on the CLI
Simple one-liner to parse JSON on the command line: 1 cat fileof.json | python -mjson.tool
View ArticlePostgreSQL CSV output from the CLI
Get CSV output from a postgreSQL database directly from the CLI: 1 psql -A -F ',' -t -c 'select * from tablename;' You can then, clearly, redirect the output as desired.
View ArticlePipe filenames to tar
Simple oneliner that demonstrates the principle of how to specify the files you wish tar to archive (or extract) by piping to it: cat filenames.txt | tar cvzf ~/try.tgz -T -
View Articlegpg-agent pinentry
Sometimes, the default setting of the gpg-agent is to use the gtk version of the pinentry program, however this may not be desirable on headless servers. It is possible to alter this behaviour by...
View Articleopen_basedir restriction in effect
PHP threw up this error today PHP Warning: Unknown: open_basedir restriction in effect. File(/foo/index.php) is not within the allowed path(s): (/bar/:/tmp/:/usr/share/pear/) Seems open_basedir is set...
View Articlegpg quick guide
GENERATE KEY PAIR Generate personal key pair (private and public) gpg --gen-key You will be prompted for a password for private key LISTING / VIEWING KEYS IN KEYRING List public keys in your gpg...
View Articleroundcube doesn’t display dates
Roundcube has a known issue where date fields are blank. Apparently it requires a timezone directive set, in /etc/php.ini add/edit this line: date.timezone = "US/Hawaii" You can change “US/Hawaii” with...
View Articlerecursion power of
A book I was reading suggested I write a recursive function that calculated a power of a number. Here’s my attempt – comments and suggestions welcome: double powerup( double num, double powr) { if (...
View Articleudev interface naming
Following a hardware failure on a Ubuntu box, it seems that simply swapping the disk to a similar hardware system is not as easy as I had thought. It would appear that udev attempts to keep a permanant...
View Articleimplementing my own strdup
While chatting on IRC last night I entered conversation about strdup(), a C function I had never used or encountered. I was then challenged to write my own. Checking the man page had me thinking about...
View Article