Sunset Pictures From A Beach Walk

About 3 miles from our home in Mattapoisett is this great piece of land donated by Paul Munn, now called the Munn Preserve. Chris and Sara introduced us to it a couple months back as a great place to take the dog and it is. Jazz (our labrador retriever) goes bananas when we turn onto the road that leads to the beach. Sometimes I think I enjoy it more than she does though. I took a couple pictures of the walk 2 weekends ago; it was near freezing, but the sun was setting just as we got to the beach (there’s about a 1/2 mile walk through the woods to get to the beach), which, with the sunset, painted pictures of the most amazing color:
reserve_land_branch_at_sunset.jpg

brandt_island_sunset2.jpg
It must have gotten really cold one night because there were these huge chunks of ice that washed up on shore; the only way I couldl describe them to Karen was ‘scalloped potatoes’:
ice_flow.jpg
And then there was this sunset:
brandt_island_sunset.jpg
which, if I had to choose a favorite color… well I’d pick all of them. All of these pictures made possible by Jazz, who won’t sit still long enough to get a picture of her:
shaking_jazz.jpg
You can view the entire set (good and bad) here.

Tomcat 5.0.x bug with dollar sign (and non ASCII characters)

Hoping to bring this to the top of the queue for anyone else that runs into this: if you put configuration information into your Tomcat conf\server.xml file and said configuration contains a dollar sign ‘$’, according to bugzilla [1,2], the dollar sign is interpreted and thus doesn’t show up unless you double up on it. So if you have a environment entry like this:

<Environment name="ftp.password" type="java.lang.String" value="amsdk$k23"/>

you’ll need to change it to this:

<Environment name="ftp.password" type="java.lang.String" value="amsdk$$k23"/>

to make it work with Tomcat 5.0.x (same thing applies to JNDI entries in server.xml). According to this comment, this issue probably will not be fixed because Tomcat 5.0.x is in maintenance and not in active development. Supposedly this behavior will be fixed in version 5.5.7.

An observation: if you’re running a business selling software, make the bug list open the public. There’s nothing better than being able to find a solution without having to spend an hour on the phone with a technical support person who is doing nothing more than searching the private bug list.

Tabbing Through Tabs

My boss asked me today if it was possible to tab through the tabs of a Firefox window (the only drawback to tabbed browsing is that you lose ALT-TAB). Turns out you can use CTRL-PAGEDOWN and CTRL-PAGEUP to tab through multiple tabs in a Firefox window, Which is nice. Some of the other ones I use without even realizing they’ve become part of my vocabulary are:

CTRL-T — open a new tab
CTRL-D — bring focus to the URL
CTRL-R — reload the current page
CTRL-F12 — bring focus to the google toolbar search box

There’s a nice list of keyboard shortcuts here.

I think you should have to memorize at least 12 keyboard shortcuts before you’re even allowed to use a computer. It kills me when someone uses a mouse to do something you can do in less than a second with the keyboard. Maybe someone can write a Pragmatic Keyboarding book or a Keyboarding Hacks books.

Retrieving an RSS feed protected by Basic Authentication using ROME

Today I worked on a feature in a Struts web application where I needed to retrieve an RSS feed that is protected by Basic Authentication and then display the the results of the feed in a web page. I’ve heard alot about ROME in the past couple weeks, so I decided to try it out. It quickly passed the 10 minute test (downloaded rome-0.5.jar, downloaded jdom.jar, used the sample code from the tutorial on the wiki); I was able to retrieve, parse and display the results of my own feed in no time:

String feed = "http://cephas.net/blog/index.rdf";
URL feedUrl = new URL(feed);
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(feedUrl));
System.out.println(feed);

Easy. But that wasn’t my problem. I needed to be able to set the Basic Authentication header which is usually done like this:

String feed = "http://yoursite.com/index.rdf";
URL feedUrl = new URL(feed)
HttpURLConnection httpcon = (HttpURLConnection)feedUrl.openConnection();
String encoding = new sun.misc.BASE64Encoder().
  encode("username:password".getBytes());
httpcon.setRequestProperty ("Authorization", "Basic " + encoding);
httpcon.connect();
.. // do stuff
httpcon.disconnect();

Turns out that the designers of the ROME library were pretty smart. In addition to including the XmlReader(URL url) constructor, they also included a XmlReader(URLConnection connection) constructor, which allows you to combine the two blocks of code I wrote above to make this:

String feed = "http://yoursite.com/index.rdf";
URL feedUrl = new URL(feed)
HttpURLConnection httpcon = (HttpURLConnection)feedUrl.openConnection();
String encoding = new sun.misc.BASE64Encoder().
  encode("username:password".getBytes());
httpcon.setRequestProperty ("Authorization", "Basic " + encoding);
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(httpcon));

Add this code to your Struts action, put the resulting SyndFeed in the request scope (request.setAttribute("feed", feed);) and then in the JSP:

<c:forEach var="entry" items="${feed.entries}">
  <strong>${entry.title}</strong><br />
  ${entry.description.value}<br />
  <fmt:formatDate value="${entry.publishedDate}" type="both" pattern="MMMM dd, yyyy" />
  by ${entry.author} | <a href="${entry.link}">link</a>
</c:forEach>

So there you have it. I hope that makes it easier for someone else!