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

Valid XHTML YouTube Embedding

I was checking validation on my pages and found the only XHTML errors were from the suggested YouTube embedding code. A quick search revealed several XHTML valid code examples, and here is what I am using to center the frame under XHTML 1.0 Transitional (this fails 1.0 Strict validation – to make this validate under Strict, just remove align=”center”..):

<p align="center">
<object type="application/x-shockwave-flash" style="width:425px; height:350px;" data="http://www.youtube.com/v/sdUUx5FdySs">
<param name="movie" value="http://www.youtube.com/v/sdUUx5FdySs" />
</object>
</p>

Update:
I am now using div’s to solve page formatting issues..:

<div>
<object type="application/x-shockwave-flash" style="width:425px; height:350px;" data="http://www.youtube.com/v/sdUUx5FdySs">
<param name="movie" value="http://www.youtube.com/v/sdUUx5FdySs" />
</object>
</div>