fixing stale jdbc dbcp connections with testOnBorrow and validationQuery

May 3, 2007 - 10:41am
I've recently had problems with a webapp running in tomcat trying to use a stale jdbc connection via the apache commons database connection pools library (dbcp). I fixed this problem by adding a validation query to the configuration in the webapp's context.xml file. The documentation for dbcp options is here: http://jakarta.apache.org/commons/dbcp/configuration.html The change involves adding...

a href usage

January 26, 2007 - 12:56pm
The link html tag Basic usage <a href="http://www.crumpeta.com">tech hints</a> Link titles The text in the link title will appear when the mouse is placed on top of the link. link title example link <a href="http://www.crumpeta.com" title="Tech hints and notes">tech hints</a> Page loading options open up page in the entire window Use this link option to bust...

Including data in a perl script

November 17, 2006 - 2:42pm
Sometimes you want to include data in a perl script and not want to include the data within the code itself. With perl, you can do this by using the __END__ label and reading the data in via the DATA filehandle. For example: #!/usr/bin/perl while ($line = <DATA>) { chomp $line; push (@whoishere, $line); } for ($i = 0; $i <= $#whoishere; $i++) { print "$whoishere[$i] is at...

Creating DSA key for remote SSH login

November 16, 2006 - 6:57pm
This is a simple and bare bones way to create a dsa key to connect from one server to another via ssh without using passwords. In plain english: How to connect from your unix (most likely mac os x) computer to your server without typing in a password. Say you want to connect from your computer, mason, to a remote server, dixon, running ssh. In your home directory in mason, you need to create a...

starting and stopping services with daemontools svc command

October 12, 2006 - 5:27pm
How to start a service with deamontools' svc command. I am assuming that the usual /service directory exists and all commands below are issued there! To start up qmail-smtpd for example: $cd /service $svc -u qmail-smtpd To check the service was brought up sucessfuly issue: $svstat qmail-smtpd qmail-smtpd: up (pid 1073) 6568 seconds To stop a service, issue: $svc -d qmail-smtpd check if it...

Fixing delete and backspace mappings in a terminal

October 6, 2006 - 4:34pm
There are a lot of solutions for this problem. But for me, the first thing to try is to change the terminal type in bash. If you get the following and you are using bash: $env | grep TERM TERM=xterm-color Try changing the .bashrc file by adding the following line: TERM=xterm Log out of the terminal session and log back in to use the new terminal type. Your delete key should now work properly....

Adding cookie information to apache log files

October 6, 2006 - 11:41am
The typical apache combined log format configuration is : LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined But by appending a simple element, %{Cookie}i, one can record cookie information into the logfile: LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{Cookie}i\"" combined-cookie ${Cookie}i will insert the contents of the HTTP...

Perl regex one liner howto

September 1, 2006 - 5:43pm
$perl -p -i -e 's/goonies/gremlins/g' monsters.txt The -p indicates that the substitution be done for every line in monsters.txt. The -i causes changes to be written in place. The -e indicates that the stuff in between '' is the program to execute.

Using mysqldump to create a csv file

August 30, 2006 - 4:10pm
$mysqldump -u user -p --fields-terminated-by=',' --tab=/tmp mydatabase mytable The above command will create 2 files in /tmp. mytable.sql and mytable.txt. The sql file will contain the table creation schema and the txt file will contain the records of the mytable table with fields delimited by a comma. Keep in mind that the --tab option will only work if the mysql client and the mysql server are...

Old Greenwich, CT 06870 - (914) 275 5520