flickr!

I have grown tired of maintaining my gallery software locally (and lazy with uploading images..), so got myself a Pro Account and migrated all the existing images to the wonderful flickr. I will update the gallery link and tinker with blog integration – there are a few flickr widgets that might be just perfect 🙂

http://www.flickr.com/photos/pbandjelly/

aptitude love

A post to the debian-user mailing list included a nice little aptitude command to show installed packages not from the main debian apt repositories. 🙂

mshuler@ares:~$ aptitude search '~i!~Odebian'
i dynagen - Cisco 7200 Router Emulator Command Line Interface
i dynamips - Cisco 7200/3600/3725/3745/2691 Router Emulator
i w32codecs - win32 binary codecs

it wasn’t me..

My mail server is going mad.. It looks like some spammer decided to use my domain and I am currently rejecting thousands of emails to the user ‘fidpbandjellyqid’ at my domain.. Sorry, but it wasn’t me..
valid email graph
rejected email graph
update: (Thu Jun 21 18:18:27) – the mail traffic is slowly but surely tapering off, but total rejected messages in the last few days is currently at 118,796 and counting..

epoch2local

Another little tidbit.. I use this frequently to translate epoch timestamps from a Postgres database log table:

#!/usr/bin/perl
# translate epoch time to human readable local time
use strict;
use warnings;
my $epoch = $ARGV[0];
if ( $epoch ) {
print "Epoch time: ".$epoch."\n";
print "Local time: ".localtime($epoch)."\n";
} else {
print "This script takes an argument of an epoch timestamp and translates it to local time:\n\n";
print " perl epoch2local.pl 1131662204\n\n";
}

psql2csv

CSV Output from ‘psql’ – courtesy of Will R.

#!/bin/bash
FS="'|field_separator|'"
RS="'|record_separator|'"
HOST="localhost"
DB="core"
USER="core_write"
FILE=$1
psql -A -F$FS -R$RS -f$FILE -h$HOST -d$DB -U$USER \
| sed 's/"/""/g' \
| sed "s/$FS/\",\"/g" \
| sed "s/$RS/\"\n\"/g" \
| sed '1s/^\(.*\)$/"\1/' \
| grep -v "^\"([0123456789]\+ row[s]\?)$"

This script will properly escape commas, quotes, and newlines. It will also leave the headers, but remove the row counts. This is useful for generating true csv output from the command line for automated reports (without requiring python and psycopg).

Save the script (ie. psql2csv.sh), make it executable, place your query in a file (ie. query.sql), then run:

./psql2csv.sh query.sql > report.csv