Friday, November 06, 2009

It took me an hour to write this line of code

String valueAsHTML = getContext().renderTemplate("/newsletter/newsletterPreview.htm", model);


It's a very cool line of code, but a whole hour? In software development, at least half of development is what you know. Since I didn't know how to use Apache Click to render HTML into a string, I had to spend some time looking for it. Now I can send my Apache Click page through email!

It is a cool line of code, thanks to: Malcom Egar-2 at Nabble.

1 Comments:

Blogger mike_s said...

This one took me a long time -

#!/bin/bash
#this finds dirs with 1 file in them, and outputs them quoted
#handles spaces in directory names, and
#some special chars (, and '). $1 is root of tree to search

find -L $1 -type 'f' -printf '%h\n' | sort | uniq -c | grep ^' '*'1 ' |\
sed -e 's/[ ]*1[ ]//' -e 's/^/\"/' -e 's/$/\"/'

I hate dealing with multiple levels of delimiters and escapes.

3:37 PM  

Post a Comment

<< Home