Red Rocks

Recursive Snippet Processing with Lift

July 22, 2010

I really like how Lift’s ’template’ engine works.  In short, you define XML tags that map to a Class and Method for execution.  For instance, a basic HTML template looks like:

<lift:MyClass.myMethod>
  <div>Hello, <my:name/>.  Welcome to my sample web app</div>
</lift:MyClass.myMethod>

This will result in the myMethod function on MyClass being called, which can then easily replace <my:name/> with a dynamic value.

The real power comes from the fact that the Lift framework will continue to (re)process the XML until all Lift tags have been resolved.  This means that a call to one snippet can produce a call to one or more snippets.

I came across an example of this on a recent project.  I wanted to produce the same HTML block for multiple snippets.  My first effort at refactoring produced something similar to this:

Using Comet with Lift to Dynamically Update Pages

July 21, 2010

Lift, a web framework written in Scala, provides easy integration with Comet, a server side HTML push model.

The Lift Demo site provides a good overview of the basic Comet usage.  A CometActor has two main parts.  The render method, which is executed when the page is first requested, generates any initial content required for the page.  The actor message method, called when the CometActor receives a message, is responsible for triggering an update on the page.

The render method is similar to the render method on any snippet.  It usually has a bind method that replaces XML tags in the template with dynamic content.  This can be visible HTML, JavaScript methods that will be used during updates, or a combination of the two.

The Comet Chat example has the following render method:

Deploying a Scala Lift Application in an OSGi Container

July 20, 2010

My current project involves building a Lift web application and deploying it in our OSGi application container.  I’ve been working with Scala on and off for a while, and I’ve always been interested in Lift.  With the release of Scala 2.8 and Lift 2.0, I decided it was time to give Lift a real try on my current project. 

The easiest way to deploy a WAR file is using Pax Web’s War Extender. This allows you to simply deploy a WAR file with an updated MANFIEST.MF file (making it an OSGi Bundle) in the same container as Pax Web. In my example I will build a WAR file as a standard OSGi Plugin and build it using Eclipse, but you could also build a normal WAR file using Maven or SBT and add the OSGi attributes to the MANIFEST.MF file and deploy it with Pax Web.

The following steps assume:

Hiking with a DSLR Camera

July 17, 2010

Update: I’ve posted an updated version of this here: Hiking with a DSLR Part 2.

I just spent a week in Rocky Mountain National Park hiking with my family. It was a great week, and it allowed me to give my new hiking setup a full workout.

My camera is a Nikon D300, and my primary hiking lens is the Nikkor 17-55 2.8.  Since I have small kids, I carry a child carrier, either a Kelty FC3 or FC1.  None of my normal carrying solutions (outlined below) worked for hiking, so I needed something different.

I came across the Cotton Carrier, which is a chest harness for the camera.  You screw a small round attachment into the bottom of your camera, and it slides into the chest harness.  It also provides a Velcro strap to immobilize the camera further, although I only use this if I need to scramble up rocks or jog.  It also provides a safety strap that I attach to where a normal camera strap would attach.

In this setup, I don’t use a camera strap at all.  Between the harness and the safety strap, the camera isn’t going anywhere, and it provides for clean access to the camera.

When I first got my carrier, it didn’t come with the safety strap, and I kept a very short camera strap on the camera to provide for a little extra safety when I had it out of the carrier.  When they added this feature they offered it for free (plus postage) which was a nice touch.

This setup worked pretty well, but it was frustrating to use the Tripod which I sometimes carry with me on hikes.  To address this, I moved to a solution where I ‘always’ used a quick-release solution.

I use Arca Swiss compatible plates and clamps.  Initially, I had a generic plate for my D300 and a Kirk QRC-2 clamp on my tripod.  This worked alright, but the plate was bulky so I always took it off the camera when I wasn’t using it, which was time consuming.

I looked into using quick release plates with my Cotton Carrier and realized all I needed was an additional clamp.  You simply screw the Cotton Carrier round attachment to the Clamp, and then you simply clamp the clamp to the camera.  This approach increases the distance from the camera to the carrier a little, but I didn’t find it to be a problem.

I also upgraded my generic plate to a Kirk plate made specifically for the D300, the Kirk PZ-122.  This plate was MUCH better than the generic plate I used before.  It is much more low profile, and has a ‘stopper’ you can put on one side to the plates can only go on and off on one side.  Additionally, it has a second screw hole, so you can attach the camera to other things that use this attachment without removing the plate.  Since I regularly use a Rapid Strap, that screws into that hole, it turned out to be a great feature.

All in all, I’m very happy with the Cotton Carrier + Kirk Plates/Clamp system in general, and for Hiking in particular.

The harness looks like it covers your entire chest, but only the bottom band (about 1 1/2 inches) is really snug against your chest.  It does get a little sweaty, but not bad considering, and nothing compared to my hiking backpack.

When I’m not hiking, I use one of the following (all of which I like for specific uses):

Java Email Server 2.0 Beta 3 Released

June 24, 2010

Java Email Server (JES) is an open source email server (SMTP/POP3) written in Java.


This release is the third Beta version of the new 2.0 development branch. This is an incremental update to Beta 2 and contains the following updates:
  • (New Feature) A recipient policy is now offered for all incoming messages originating from local domains. See the rcptPolicy.conf file for details.
  • Further relaxed the default security settings so that cleartext passwords are accepted.
  • Unlimited jurisdiction cryptography is not required by default anymore.
  • The digest-MD5 SASL mechanism is off by default now.
While the belief is that JES 2.0 Beta 3 is stable, we will continue with Beta releases in the 2.0 branch until we feel confident that the 2.0 code is stable and production safe. Please provide feedback on this release in the JES Google Group, even if it is just letting us know you are using JES without any issues.

You can download this release from the project home page.

iTunes Export 2.2.2 Released

June 2, 2010

iTunes Export exports playlists defined in your iTunes Music Library to standard .m3u, .wpl (Windows Media), .zpl (Zune), or .mpl (Centrafuse) playlists. iTunes Export also supports copying the original music files with the playlist to facilitate exporting to other devices. iTunes Export is open source and freely available for use.

The 2.2.2 release features updates and bug fixes to the console and GUI versions

For the GUI version:

Acquisitions - Palm and HP, Siri and Apple

April 28, 2010

Two interesting acquisitions were announced today, one exciting, one disappointing.

First, the exciting one.  Apple acquired Siri.  I’ve used the Siri app for the iPhone, and was very impressed.  It attempts tries to be your digital secretary, and actually does it quite well.  It abstracts you away from how it finds out information, and just presents what you want to know.  It works great for the simple cases so far, and I think over time will become very good at much more.  For Apple, who I believe is focusing on making computers into appliances, this is a great fit.  As I discussed in my post about the iPad, I believe the next evolution of the computing space is creating computing appliances, not computers.  Thinking of the iPad as a computer with a touch screen instead of a computer with a keyboard is wrong, just as thinking of a TiVo as a computer with a video capture card is wrong.  Yes, both analogies are technically correct, but they both miss the point.  Both are computing appliances, not computers, and the rules and expectations for them should be different.  I’m very excited to see what Apple will do with Siri.

And now for the disappointing one.  HP acquires Palm.  Palm was once a great company.  They nearly single handily created the PDA (Personal Digital Assistant) market, with the Palm Pilot.  The Palm Pilot dominated the market for years, until the advent of smart phones.  Then they created the smartphone market with their Treo line (technically they bought Handspring, which was formed by the same folks), and extended their domination.  I was an early adopter back in 1998 and used Palm Pilots and Treos up until last year when I switched to an iPhone 3GS.

If was very excited about Palm’s new OS, but in the end it was too little, too late.  If they had launched the WebOS/Pre a year before the iPhone came out, they may still be dominating the landscape.  And they certainly should have been able to do that.  The Palm OS was great in the 90’s, worked OK in the early ‘00’s, but was really showing its age by 2005.  They waited far to long to move to the next generation.

I don’t see how being acquired by HP will change their position.  iPhone and Android are locked arm-in-arm for the smartphone market.  iPhone owns the proprietary walled garden space, and Android is the open, extensible choice.  Microsoft and RIM are still hanging around, mostly in the corporate market.  There just isn’t room for Palm.

HP is not an innovative company today, and is more known for their existing relationships and sales channels than engineering.  While I don’t believe any company could have really saved Palm, an acquisition by HTC or another up and comer in the space would have been interesting.

Why Can't Google and Apple just Get Along?

April 13, 2010

Google and Apple are at war.  Google entered Apple’s ‘home turf’ with Android, and Apple is entering Google’s ‘home turf’ with iAd.  There is no question that the war is on.

In most situations, competition is a great thing.  It drives companies to innovate and produce better products and services.  While that will certainly happen with their respective mobile operating systems in this situation, I believe these are two companies that would be much stronger working together.

Google and Apple are good at very different things.  Gruber nails it when he says:

Flash Builder 4 Reference Card

March 22, 2010

I recently published a Reference Card with DZone: Getting Started with Flash Builder 4.  The Reference Card covers the new features of Flash Builder 4 and includes a basic overview of Flex application development.  Check it out!

I enjoyed working with DZone to publish this card, and the editorial process was great.  I hope you find it useful.  Let me know what you think!

Google Is Great, When It Works

March 21, 2010

I’m a big fan of Google.

While I’ve written my own email server, I’ve adopted Google Apps for nearly all of the domains I manage.  Gmail is a great tool, and has freed me from the tendency to over-organize my mail.  I can now find things easier and quicker than I ever did using Outlook or Thunderbird simply using minimal tagging and the built in search functionality.

I’ve used Google Search, Google Apps (Mail, Calender), Google Reader, Blogger, Google Docs,  Google Code, Google Web Toolkit (GWT), and the Google App Engine.  Great stuff.

If it works.

However, if something goes wrong, it can be difficult to find the answer.  Your best bet is to Google for the solution of course.  Hopefully someone has encountered the issue before and can point you in the right direction.  If not…

I recently migrated my Blogger setup (for this blog) from FTP publishing to a Custom Domain hosted by Google.  The transition went fairly smoothly (as I documented here), and while I was a bit annoyed I had to change my setup, it was fairly painless and hey, the price is right.

But I ran into an issue with my RSS (Atom) feed.  I’ve been using Feedburner for quite a while to track the number of subscribers.  When I used FTP publishing I simply edited the template to point to my Feedburner feed.  However, now that I switched to hosted mode, I can’t edit the template the same way.  So most new subscribers are using the base Google feed, not the Feedburner feed. 

Google does offer an option to handle this, ‘Post Feed Redirect URL’, with the description: “If you have burned your post feed with FeedBurner, or used another service to process your feed, enter the full feed URL here. Blogger will redirect all post feed traffic to this address. Leave this blank for no redirection.” Of course, when I enter my Feedburner feed in this URL, I get the error: ‘This URL would break your feed, resulting in a redirect loop. Leave the field blank to serve your feed normally.’  Based on all the reading I’ve done, my setup appears to be correct and this should work.  Faced with limited support options, I posted a question to Google’s help forums.  I got a response that appears to suggest that something internally needs to be reset, but no help from any Google resources.  So, I guess I’m stuck.

Or course, you can point out that I’m getting what I pay for, which is true.  Blogger is a free service, and I’m not entitled to any specific level of support.  But that doesn’t make the situation any less frustrating.

At least this issue is minor.  In the end, it doesn’t really matter.  But suppose I had in issue with Gmail.  What would I do then?  Well, I guess the answer would be upgrade to a Pro account, and then demand support, but that is only because I’m using Google Apps instead a plain Gmail account.

The risk of free…