Escape Madness

I stumpled upon something funny at work today. It might help being a fellow programmer to consider this being funny. It took some time today to come up with a solution ...

Task: Change a path in a text file during a build process using the java build tool ant.

Solution: Use a Regular Expression to scan the text file and replace the value.

This is where the madness begins: You need to escape a backslash. Probably multiple times ...

20 = 1
The path contains one backslash:

21 = 2
You need to escape the \ in the properties file, it should read:

22 = 4
If you want to print the Path in a Java String (which ant more or less uses), you need to escape each \ with \\, that becomes:


23 = 8
If you want to put that in a regular expression, you need to escape each \ with \\, which will lead to:

24 = 16
This expression should be generated by another regular expression, so each \ needs to be replaced with \\, hence:

25 = 32
Put the thing into an build.xml file for ant, you you'll end up with 32 (thirty two!!!) backslashes to have one in the end. Without escaping 1 (one) backslash with 16 backslashes (written as 32, because each one of those 16 needs to be escaped), it won't work:

<propertyregex br="" 
    input="${$jboss.dir}" regexp="\\"
<replaceregexp br="" 
        <!-- yadda, yadda, yadda -->

Now that's efficiency. Thanks a lot, java folks.

Things like that never happen to me in perl. Oh dear perl, I really love you. For a reason.

Christmas Season

First Advent

I really love Christmas Season, with all the christmas markets, the warm colors and all the joy. Last weekend the BF and I had a great time together, enjoying the holiday spirit.

Stuttgart is colorful

Yesterday at around 5pm (jebus, sun goes down early these days) we've been strolling around in the city, heading to a café for some heavy double choclate fudge cake and some coffee, we came across these shop windows and I just liked them.

Before that, the BF and I had a very nice walk in the snowy sub-suburban outskirts of Stuttgart. Or, to say it differently, in the haunted forests of nowhere. We came past some teeny-weeny ancient castles hidden in the forests, used by our former Kings as hunting seats. It was a very pleasant day together, and we had much fun in the white winter-wonder land, with all the snow on the trees. And also with the glassy trails on the way back to the city, where the warmth of the café reimbursed us for the frostbites and the starvation we had to endure in the enchanted and endless forests of our beloved former Kings.

A star is born ...

In the city they're quite busy preparing the christmas market, that will open to the public in three days. It's one of the biggest christmas markets in Germany, and it exists for about 350 years. Looking forward to having some mulled wine and sugarroasted almonds...

Consultation -- Kind of

Do you know this? Something's happening, and you know this would make a good posting, but you can't find any time to put it up, and suddenly it's forgotten?

Well, for one year now, I wanted to blog about this:

TheGuy and I had spent a beautiful afternoon at the bank of Manhattan. (Not the thing with the green papers, the one near the Hudson, I guess it's also called river park). When we were back at his building (but he has moved a few weeks ago, so by the time I'm writing this, it's his former building) and walked to the elevator, a small old woman with huge luggage was talking to the doorman. She was coming back from a trip. It was a warm and sunny day, and TheGuy was bare-chested, showing off his abs and pecs. When the elevator came, the old Lady joined us in the elevator, and they were joking. I realized they know each other. No wonder, he told me she's his next door neighbor.

But somehow she was very familiar to me as well, but I didn't understand why. She was making jokes about TheGuy's bare chest, that this would be too sexy, and that I'm lucky for having this handsome guy. Not exactly what I had expected from an old Lady. I thought old ladies are prude. TheGuy told her I'm from Germany, and then she perfectly spoke German to me. We helped her carry her luggage to her apartment and talked for a little while.

Back at TheGuy's apartment, he asked, "Do you know her?". I said, "Not really, but she is very nice and amazing, and in a weird way she was familiar to me". He said, "Well, she's quite famous. She's Dr. Ruth."

I'm very proud and pleased I met this remarkable and wonderful woman, and had the chance to visit her at home and have a little chat with her.

Literature: The Visit

One of the best-known contemporary literary critic in German TV and radio has exactly the same name as I have (which is not a very common name like Matthew Smith or something like that). He grew up in my town as well. We get confused a lot. If you enter my our name, our city, and "radio" or "media", you'll find his entries pretty much mixed up with mine, since I do a radio show about culture (by the way, the next show is all about books) and publish many articles in our magazine.

It happens quite regularly that I get manuscripts from young authors by mail. "I know you're a very busy man, but could you please read my manuscript and tell me what you think" -- "Uhm, I'm not the one you think I am, we just have the same name." -- "Could you please read it anyway???"

"Are you the real XXX?"-- "I am a real XXX, but probably not the one you're thinking of."

"I stayed up all night because I saw that you'll be on [generic late night show], but it wasn't really you..."

To live up to expectations, I want to write about an excellent book by the Swiss author Friedrich Dürrenmatt: "Der Besuch der alten Dame" In English: The Visit. (see article in Wikipedia)

I had to read it in school when I was about 15 years old. I read the entire book in one evening, because I couldn't stop. It deals with the themes of punishment, greed, revenge, and moral strength in a very interesting and yet entertaining way.

I've almost forgotten how brilliant this book is. But currently I'm sick, I cought a flu, and by pure accident I saw it on TV today. I need to read it again, and you might want to read it as well. (hint)

Layman's Guide to Acceptable HDR Images (batteries not included)

Since I got some e-mails and instant messages about my HDR images, I've decided to write a short tutorial for absolute Newbies. Anyway, seems like there are some readers of my blog...

Warning: HDR is harmfully addictive!

First Step: Software
Get yourself a HDR Software. There are many different programs out there in the wild. But since I use and adore Linux, I was limited in my choices somehow. I use Qtpfsgui, which is freely available for Windows, Mac and of course Linux. The results of my first few attempts were quite disappointing. But now I know the reason:
I didn't have this handy guide ... ;-)

Second Step: Source Images
Maybe even more important than a decent software are good pictures to start with.

Don't: In most tutorials, you can read that you need to take 3 to 7 pictures, i.e. one correctly exposed, one (to three) underexposed, and one (to three) overexposed. Some cameras can do that automatically ("exposure bracketing") . But, in fact, you need a tripod, and even then, people or things do move a little bit, which forces you to stitch your images (if you ever need to do it, use hugin).

Do: I'm using just a single image. The secret is, you need to take a RAW image. Most digital cameras can write RAW images. Usually the camera processes the data from the image sensor and saves a jpg. In this step, the camera applies white balance, some sharpening algorithms, exposure corrections and all that stuff. In a RAW file, you have the "real" data, without any corrections. The advantage of a RAW image over another format is, that it contains more color depth and more dynamic range. And aren't HDR (high dynamic range) pictures all about dynamic range?!

So, my advice: Set your camera to save the images as RAW and use just a single RAW image.

Let's use this picture for our little workshop. As you can see, it's a bad image. Almost no details in the dark parts. But I underexposed it like that on purpose. I wanted to capture the structure of the clouds. The software is quite good in correcting underexposed parts (like the buildings), but an overexposed sky would lose it's structure and would be a plain white area. Not exactly what we want, am I right?

Step 3: Setting up your Software
Before you start, change one setting in Qtpfsgui. This will save you a lot of time and frustration. Go to the options and add a -w (or -a) to the raw convertion parameters. Without that, your images will have a mean color cast.

Step 4: Create the HDR (finally)
Click on "New Hdr..."

Then, click on "Load Images", and select your RAW image. Remember, most people use three to seven images here, but we only use one, our RAW image. Efficient, huh?

Just click on "Next >", and then "Finish". The default settings should be good enough for us. After a little while, we can see our new HDR image (see picture below). But that's not what we expected, right? Usually you use tonemapping on your HDR to get the images you probably know as HDR...

Step 5: Tonemapping
Click on "Tonemap the HDR" on the gui, which brings up our tonemapping window. Here you can use different Tonemapping algorithms (where I prefer "Fattal" most of the time).
Select the Tab labeled "Fattal", and press "Apply".

With the default settings(!), you should end up with an image like that:

I usually play a bit with the sliders, you will learn quite fast what each one does, and how you need to push them, to get the results you want. Use a small image for this process, because it's generated much faster than a big one.

When everything is adjusted for a breathtaking image, switch to a higher resolution and generate the image.

Step 6: Save and say "Wow!"
If you have an image that fits your taste, use "Save as..." to save the tonemapped image. Now is the right time to be proud of your work. Show it to friends and impress them.

Step 7: Show me your art
If you created a HDR following this guide, I would highly appreciate your feedback, and also a link to your image. Show me your baby. ;-)