Permanent redirection to default host in Apache

A few weeks ago at work, I needed to rename a webhost. To avoid breaking a lot of links to the old hostname, I set up permanent redirection, but ran into an infinite loop. I tried both a simple Redirect statement like this:

Redirect permanent / http://newhost/

And the same thing using mod_rewrite. I have done this many times before at home, but what was special about this case is that the web server was set up as default host. So I just added a virtual host with the old hostname. Eventually I got it to work with mod_rewrite by using a RewriteCond statement to break the loop:

<VirtualHost *:80>
ServerName oldhost

<IfModule rewrite_module>
RewriteEngine on
RewriteCond %{HTTP_HOST} oldhost
RewriteRule ^/(.*)$ http://newhost/$1 [R=permanent,L]

However, I’m still not sure why this is neccesarry, since the first rewritten URL should end at the default host which doesn’t rewrite anything.

Building Courier-Authlib 0.65.0 on CentOS 5

Today I wanted to upgrade Courier-Authlib from 0.63.0 and read this in the ChangeLog:

2010-03-06 Sam Varshavchik

* Remove the bundled libtdl library. Require the system-installed
libltdl library.

As expected, this gave me some problems with my old CentOS 5.9 release:

/bin/sh ./libtool –tag=CC –mode=link gcc -g -O2 -Wall -I.. -I./.. -export-dynamic -dlopen -dlopen -dlopen -dlopen -dlopen -o authdaemondprog authdaemond.o libltdl/ liblock/ libhmac/ md5/ sha1/ rfc822/ numlib/ -ldl
libtool: link: cannot find the library `libltdl/’ or unhandled argument `libltdl/’
make[2]: *** [authdaemondprog] Error 1
make[2]: Leaving directory `/usr/local/src/courier-authlib-0.65.0′
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/courier-authlib-0.65.0′
make: *** [all] Error 2

I fixed this by adding this line to my build script (after configure):
sed -i -e 's/^LIBLTDL = ${top_build_prefix}libltdl\/ = -lltdl/' Makefile

Update, February 15th 2013: Today I found out that in a freshly installed VMware machine with CentOS 5.9, ltdl was missing. So I needed to add the following in my pre-build script as well:
rpm -q libtool-ltdl >/dev/null
if [ $? != 0 ]; then yum -q -y install libtool-ltdl; fi
rpm -q libtool-ltdl-devel >/dev/null
if [ $? != 0 ]; then yum -q -y install libtool-ltdl-devel; fi

Update, December 7th 2015: I wanted to build 0.66.4 today, and the problem reappeared. Luckily, I found this posting which saved me some time. Updated ‘sed’ command:
sed -i -e 's/^LIBLTDL = $(top_build_prefix)libltdl\/ = -lltdl/' Makefile

The downfall of Samsung

First of all, I’m a big Samsung customer. I own two Samsung LCD TV’s, a PC monitor, a cellphone, a Blu-ray player and a hard drive. Heck, I even own a Samsung vacuum cleaner. I don’t own any Apple products. So this is not about the ongoing Samsung vs. Apple patent war or me dishing Samsung because I’m an Apple fanboy. It’s about me being a critical, but fair, customer.

In January I bought a top-of-the-line 55″ LED Smart TV – UE55D8005. This is a very nice TV, but the “Smart” also makes it a computer – a computer that needs software.

Next, in June I also bought a smartphone, Galaxy S3 – finally making the switch from my ancient HTC Desire (that became useless because of the lack of internal memory – but that’s a completely different story).

I’m relatively satisfied with both products. However, I’m not at all impressed by Samsung’s understanding of software and product life cycles. It seems that Samsung abandons software support for a specific model almost before the last item has shipped.

The TV came with a Galaxy 5″ Wi-Fi tablet. This tablet came with an app called Samsung Smart View. A nice little app to control the TV and even stream video from the TV to the tablet. However, this app is not compatible with Samsung Galaxy S3, their flagship smartphone. It’s been four months now, so why is this still not working? I contacted Samsung about this issue, but didn’t get any useful answers. I asked four times before I got confirmation that they were even aware of the issue, but their support is completely broken.

Yesterday Netflix was introduced in Denmark. So I also asked Samsung how to get the Netflix application for the TV back – I couldn’t find it anywhere, but I knew that the app exists for my model and works with the American Netflix. Their support couldn’t help me with this, but told me that the latest TV models (E models) would get an update today or tomorrow.

What’s the point of all this? Samsung simply don’t get it. Not being able to integrate a top model of their TV’s with the current top model smartphones is ridiculous. There are so many reasons why this would make sense. Just to name a few features that would be nice to have on the phone:

  • Remote control.
  • Using the phone as a keyboard.
  • Scheduling timed recordings.
  • Automatic pause/time shifting when the phone rings.

The TV also integrates with services on the net, for example YouTube. Samsung cannot just abandon the firmware once a new TV model has been released – and render “old” models useless when services change and need software upgrades. At least not if they want customers to stick. I don’t get it. Is the logic that I will buy a new TV only nine months after buying a 2.000 € TV – only to get the latest software? If this is the case, they are doomed – I’d never buy another Samsung Smart TV after experiencing a complete lack of support and upgrades once.

Then there’s the poor quality of the software. I prefer Android to iOS because of its open nature. But everything Samsung has built on top of Android sucks. Period. Just to name a few:

  • TouchWiz: Well, this is actually decent, but has some stupid bugs – like folders opening on their own. So annoying.
  • Calendar: First of all, it’s ugly. When creating new events, it always defaults to “Samsung Calendar”. Who would prefer Samsung Calendar to Google Calendar – and what is Samsung Calendar? What’s up with the up/down arrows when setting date and time – why not use a scroll wheel? And how about some nicer widgets for the calendar?
  • ChatON, Samsung Apps, S Suggest: Who cares about these things?
  • Sometimes it wants me to connect to my Samsung account, but doesn’t say why. If the wrong password is typed in, the application leaves and prompts for both username and password again. They shouldn’t release software that works like this.

To summarize, Samsung is a hardware company in a software world. They have no talent for writing software whatsoever, and they don’t even manage to support and integrate their own products. Apple and Google get this. This is why I believe Samsung will have a very hard time, once the competition is ready to take them out. Like Google killed Altavista in the late 1990’s. Like Netflix killed Blockbuster. I know I’m ready for an alternative to both Apple and Samsung.

Lossless JPEG rotation

For a long time I’ve avoided rotating JPEG pictures in portrait format from my digital cameras — due to possible quality loss. Using the EXIF information software should be able to handle this, i.e. rotate pictures on-the-fly, but unfortunately this is rarely the case.

I finally decided to investigate if it’s possible to perform rotation without quality loss. The good news is that it’s possible, but it has some limitations. I found this in a very old JPEG FAQ (question 10):

“There are a few specialized operations that can be done on a JPEG file without decompressing it, and thus without incurring the generational loss that you’d normally get from loading and re-saving the image in a regular image editor. In particular it is possible to do 90-degree rotations and flips losslessly, if the image dimensions are a multiple of the file’s block size (typically 16×16, 16×8, or 8×8 pixels for color JPEGs). This fact used to be just an academic curiosity, but it has assumed practical importance recently because many users of digital cameras would like to be able to rotate their images from landscape to portrait format without incurring loss — and practically all digicams that produce JPEG files produce images of the right dimensions for these operations to work. So software that can do lossless JPEG transforms has started to pop up. But you do need special software; rotating the image in a regular image editor won’t be lossless.”

The next obvious question is: Which software supports this? Well, I was pleased to find that one piece of software that does that is Directory Opus. Quote from the forums:

“To perform lossless rotation the dimensions of the image must be an even multiple of the DCT block size (8) multiplied by the sampling size. The standard JPEG code defaults to a 2×2 sampling size (and Opus doesn’t change this) which means an image Opus outputs would need to have even multiple dimensions of 16×16”

In other words, right-clicking in Directory Opus and selecting “Convert Image” will let you losslessly batch-rotate pictures, as long as you select “Rotate” as the only option.

Here’s a list of other applications that support lossless rotation: Lossless jpegtran applications. Beware, Photoshop is not one of them. Neither is Explorer or Paint.