Monthly Archives: March 2010

Mapping Tomcat Apps to Subdomains with Apache

Suppose you have your web app hosted by Tomcat at http://localhost:8080/myapp. That’s an ugly address for end users, so you want it to be accessible as Here’s how you can do it with a little help from Apache via mod_proxy and mod_rewrite.

  1. Install Apache:
  2. apt-get install apache2
  3. Enable optional modules:
  4. a2enmod proxy
    a2enmod proxy_http
    a2enmod rewrite
  5. Configure proxy (/etc/apache2/httpd.conf):
  6. ProxyRequests Off
    <Proxy *>
      Order deny,allow
      Allow from all
  7. Configure virtual host (/etc/apache2/sites-available/somesystem):
  8. <VirtualHost *>
            RewriteEngine On
            ProxyPass / http://localhost:8080/myapp
            ProxyPassReverse / http://localhost:8080/myapp
  9. Enable virtual host:
  10. a2ensite somesystem
  11. Restart Apache:
  12. /etc/init.d/apache2 restart
  13. Enable proxy support in Tomcat (conf/server.xml):
  14. <Connector port="8080" protocol="HTTP/1.1"
                   redirectPort="8443" proxyPort="80" />
  15. Restart Tomcat

Note: It’s written for Ubuntu, but can be easily converted to other systems.

Fitt’s Law and Dual Monitors

Thanks to Jeff Atwood at Coding Horror I recently discovered the good old Fitt’s law. To make a long story short, it says that the larger the component is, the easier it is to click on it. The area near to screen edges is the most valuable, because from mouse cursor’s point of view it is infinite. See Particletree for a great visualization of this concept.

I knew that intuitively. It seems that UI creators have taken it into account for years, putting tiny title and task bars on top or bottom and all the most important icons in corners. I haven’t realized how important it is until I started using a mediocre dual head configuration. After all, computer is a part of me and I don’t see it until something goes wrong.

Consider this setup:

Monitor configuration in Ubuntu

The larger display is a desktop monitor with higher screen resolution. The smaller one is my laptop. Since I am right-handed and I use laptop keyboard, it needs to be on the left. Apparently in Ubuntu the “left” monitor is always the one that gets the desktop, with task bar, shortcuts and so on. I don’t know how other operating systems deal with it, but in Ubuntu you always need to have a rectangular desktop. It means your mouse can move to the brown area, right above what you see as the top edge of the screen.

Now using a quick launch or tray on the smaller screen is quite an ordeal. Even if the displays were of the same size, or the OS dealt with it without the “brown area”, you still would have issues with window title bar icons or scrollbars.

With Fitt’s law at least I am able to name this issue.

Why Is Science Cool?

It can be observed that not only programming, but also science, technology and engineering, are losing their popularity. Americans even consider it a national security risk.

It may be so because today is more about consumption (or taking) rather than creation (or expressing). We prefer to take everything for granted and avoid whatever seems unpleasant. Science is pretty high on the list – it requires discipline and concentration, and that seems to be too much.

What can we do? Show that science is not about books and study of no apparent purpose. Instead, show how it affects our daily life and can actually be cool. Don’t start with dull books and formulas. Show the goal and applications, fascinate, then teach and explain.

“Run, rabbit, run.
Dig that hole, forget the sun.”

I was happy to discover the TV & radio campaign which promotes maths in Poland. It hits the sweet spot. It consists of several professional short adverts which describe how mathematical concepts apply to apparently maths-free fields such as music, art, architecture, biology etc.

For instance, they tell how the quality of music is affected by theoretical intervals, or how everything in natural environment seems to follow the golden ratio. They also involve some renown professionals who describe how maths helped them in their work.

Now, if only the teachers followed. I wish they told me that before all the formulas.