Author Archive

Deploying a Subversion branch with Capistrano

Wednesday, January 30th, 2008

Capistrano is a tool for automating tasks via SSH on remote servers. It has many uses, I (and many others) use it to deploy their (rails) applications. The best I can tell there is no built in way to deploy a branch from your source code control system. There are a couple ways of accomplishing this. I chose passing in the branch as a parameter to the Capistrano command:

cap --set-before branch=testbranch  deploy

(more…)

Handling Session Timeouts (and other errors) using Ajax

Friday, January 11th, 2008

Ajax can bring a much more responsive and intuitive feel to web applications. However, many times developers overlook error cases when using Ajax. What if the request fails? In one particular case a user’s session may have timed out before they made an Ajax call. This post describes one such way of handling this in a somewhat friendly way.
(more…)

Sending UTF-8 email with Oracle

Wednesday, April 18th, 2007

I have seen several examples of sending email using oracle with non-ascii characters floating around the Internet, but few seem to tackle sending these ’special’ characters in both the subject and the body. Many also take a shortcut and use 8bit transfer encoding for the body. I am 99.9% sure that this will work on today’s mail servers, but basic SMTP only really needs to support 3 transfer encodings - 7bit ascii, base64, and quoted-printable.

(more…)

Mongrel vs. WEBrick

Tuesday, April 3rd, 2007

We had the need to hook up a simple ruby web process (non-rails) to our production apache server. As Leslie Hensley pointed out, fcgi and scgi are on the way out, and mongrel + mod_proxy_balancer is the new way to go. We use mongrel extensively in our rails deploys, but always just used WEBrick to do simple serving. To make a long story short, we had to ask ourselves….is mongrel that much better (and in this case better == faster) than WEBrick?

(more…)

Tomcat + UTF8 + HTTP Get

Monday, March 19th, 2007

By default tomcat doesn’t UTF-8 encode get parameters like it does post parameters. This doesn’t seem to be the case with other application servers. So before you get yourself into trouble with your internationalized web application, make sure you make this change.

Scary apache errors moving from prefork to worker

Wednesday, March 7th, 2007

We were helping a client push more data through their apache/tomcat web application running on a Solaris box and decided to switch from the process (prefork) to the threaded(worker) processing model. When we fired up the new apache we started getting errors like these:

[emerg] (45)Deadlock situation detected/avoided: apr_proc_mutex_lock failed. Attempting to shutdown process gracefully.

Not good. After a little digging we found that the default AcceptMutex switched from pthread to fcntl between apache 2.0.49 and 2.0.52.

Adding:

AcceptMutex pthread

to httpd.conf cleared up the errors and we’ve had smooth sailing ever since.

Building a better world with Google Spreadsheets

Wednesday, December 6th, 2006

I was tickled when I ran across the GoogleLookup and GoogleFinance functions in Google Spreadsheets. I was very tickled when I found there was a REST API for interacting with the spreadsheets.

So not only can you lookup the current volume of Google stock in a spreadsheet (=GoogleFinance(”GOOG”, “volume”)) or find out Roger Clemens’s ERA (=GoogleLookup(”Roger Clemens”,”earned run average”)) you can access those values real time using an open API. I cobbled together a quick ruby program that can retrieve values from a private or public (published) Google spreadsheet.

(more…)

IE7 adds native XMLHTTPRequest object

Thursday, October 26th, 2006

The recently released IE7 supports a native XMLHTTPRequest object. On the surface this can be considered a good thing and should be commended. However, to the people that erroneously (in hindsight) assumed that…

window.XMLHttpRequest == ! (not) IE

…they are in for some strange behavior (here, here, here, and here for example).

The problem occurs when the code is optimized for non-IE browsers and does not recreate the XMLHTTPRequest object on each event. Back when “window.XMLHttpRequest == !IE” was true, this code worked as expected: IE browsers created a new XMLHttpRequest object on each event and non-IE browsers reused the same XMLHttpRequest object. Now IE7 will correctly process the first event but then fails on the second (and subsequent) requests because you still can’t reuse XMLHttpRequest objects.

We chose to just remove the optimization all together and recreate the object on each event for all browsers. Others may wish to come up with some other check that will allow them to keep it.

Accessing oracle with sqlplus and no tnsnames

Friday, July 28th, 2006

If you want to access a database without it being in your tnsnames.ora file, you can use a ‘URL’ at the command line:

sqlplus login/pwd@//hostname:1521/sidname

This should work with versions 9 and above. Let me know if other versions work.

Using axis with https and a self signed certificate

Saturday, April 8th, 2006

While developing a webservice based application we ran across some issues using a self signed certificate. After running our wsdl2java ant task we got the following error using Java 1.4:

sun.security.validator.ValidatorException: No trusted certificate found

Using Java 1.5 the error looks like this:

sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification path to requested targ

Fair enough. Java is telling us we need to import our self signed certificate into java:

/usr/local/java5/bin/keytool -import -alias mycert \\\\
  -file server.crt -keystore /usr/local/java5/jre/lib/security/cacerts
Enter keystore password:  changeit
... CERTIFICATE DUMP ...
Trust this certificate? [no]:  yes
Certificate was added to keystore

Running our ant task again:

java.io.IOException: HTTPS hostname wrong:  should be <localhost>
  at sun.net.www.protocol.https.HttpsClient.checkURLSpoofing(HttpsClient.java:490)
  at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:415)
...LONG STACK TRACE TRUNCATED....

(more…)