August 24, 2010

Where have all the free dns services gone?

Filed under: Software

During the last couple of years I have been using zoneedit.com and everydns.org as free dns servers, but none of them can be used anymore to add new domains. Zoneedit even decreased the number of free domains from 5 to 2. So I was looking around for alternatives. There is freedns.afraid.org, but they have the disadvantage of other people being able to associate secondary domains to your domain. Another one is dnsexit.com, so I am trying that one out now.

August 10, 2010

Watch out with Locale.getDefault() and ssh

Filed under: Software

In one of my webapps I was using Locale.getDefault(), assuming it would take the values in /etc/sysconfig/i18n, but this turned out to work differently. When I logged in via ssh from a terminal with another locale to restart the webapp, the locale of the ssh client was used in Locale.getDefault(). This behaviour can be avoided as described in this excellent article.

July 16, 2010

sudo: sorry, you must have a tty to run sudo

Filed under: Software

when I was starting a script containing the sudo command in a cron job, I received the message ’sudo: sorry, you must have a tty to run sudo’. to avoid this message one can comment out the line ‘Defaults requiretty’ in /etc/sudoers.

January 20, 2010

Supermicro IPMI applet in Firefox/Ubuntu

Filed under: Software

I thought I could run applets in my Firefox 3.0.17 on Ubuntu, but yesterday I encountered an applet that did not run, namely the applet that is used to acces the Supermicro IPMI card (AOC-SIM1U-3B+). After removing the Icedtea plugin and adding the sun java plugin (sudo apt-get install sun-java6-plugin) the applet started working.

 

November 3, 2009

Coriolis for sailors

Filed under: Science

Last weekend we had an excellent sailing trip from Nieuwpoort to Ramsgate and back again. And as it happens on such occasions, conversation touched the subject of Coriolis forces, which is important - for sailors - to understand the deviations of air flows when they move from high to low pressure areas (deviation to the right in the Northern hemisphere, deviation to the left in the Southern hemisphere).

Often these conversations get needlessly complex.  So here is my stab at it. The Coriolis force is a pseudo force, just as the centrifugal force is a pseudo force. You only need these pseudo forces to explain things if you are an observer on Earth who is not able to imagine how things would look from a distance. I was told a sailor must be able to see his boat from a bird’s perspective, so sailor, just fly a bit higher and watch the Earth from a few thousand (nautic) miles and you can forget about Coriolis and rely on more basic physics:

1. Newtonian inertia: tendency of an object to maintain its state of uniform motion (unless acted on by an external force).

2. The velocity of an object making a rotational movement (e.g. a rock on the surface of the Earth) is the ‘rotational velocity’ times the distance to the rotational axis. This means that a rock on the equator moves faster than a rock on the Tropic of Capricorn or the Tropic of Cancer.

3. Context: air moves in a thin layer around the Earth.

So what happens to an air particle that moves from South to North in the Northern hemisphere: since it is stuck in this thin layer around Earth, it moves to an area where the Earth’s velocity is lower than the velocity of the particle, and since it wants to keep its velocity, it moves along a line that curves to the right. The same reasoning can be applied for moving from North to South and for the equivalent cases in the Southern hemisphere.

When moving from West to East in the Northern hemisphere the reasoning is as follows: the (air) particle’s speed is larger than the speed of the underlying surface of the Earth. Because of its higher tangential speed the particle has the tendency to get thrown out of its orbit and move away from the Earth’s axis, but since it is locked in this thin layer, it can only do so by deflecting to the South, thus making a curve with a deviation to the right. Again, similar reasonings can be made for East to West and for the cases on the Southern hemisphere.

So no talking about Coriolis or other pseudo forces needed to understand air movements on Earth.

 

 

October 31, 2009

A commercial

Small commercial on a product we are offering to veterinarians in an attempt to enhance its google ranking. Sorry for the noise. Software voor dierenartsen, praktijkbeheer, logiciel veterinair, application pour vétérinaires, Tierärzte, Webanwendung für Tierärzte.

 

Sonetas Sonetas

October 27, 2009

Creating a movie from pictures

Last weekend, I was trying to create a ‘Lego City Movie’ (together with my son): taking many pictures of slightly moving Lego objects. I was surprised how easy it was to create a movie from this stack of pictures. It was just down the man page of mencoder:

 Encode all *.jpg files in the current directory:
 mencoder "mf://*.jpg" -mf fps=2 -o output.avi -ovc lavc -lavcopts vcodec=mpeg4

I was lucky that in my camera the time order of the pictures is the same as the alphabetic order of the picture names. So everything was ordered as desired. Very neat …

October 23, 2009

Those without ambition

Filed under: Science

Those who state that some areas/fields can NEVER be the subject of science are without ambition, which is not too terrible in itself, but what is worse: they condemn the ambition of others to increase knowledge.

October 21, 2009

Combining Tomcat & Drupal

Filed under: Software

 

Most of my applications are Tomcat (java) applications, but recently I started creating small apps in Drupal (php). Since I have only 1 server to run both types of apps, I had to find a way to combine them. The traditional approach would be to enable AJP and have Apache Httpd forward requests to Tomcat. However I decided to take another appproach since:

  1. my Tomcat apps are the most valuable and I read that the AJP connector has a performance cost.
  2. I was not able to find a clear howto on combining Tomcat 5.5 and Apache Httpd 2.2
  3. I still had a spare IP address

So I decided to configure a second IP address on the eth0 interface. To have this permanent just copy /etc/sysconfig/network-scripts/ifcfg-eth0 to /etc/sysconfig/network-scripts/ifcfg-eth0:0 and edit the DEVICE and IP address in the latter (and restart the network, ‘/etc/init.d/network restart’). Note that I disabled /etc/init.d/NetworkManager and use /etc/init.d/network (on fedora 11) instead, I had the impression that NetworkManager did not pick up eth0:0, but I did not further investigate.

Then I added a rule to iptables to redirect packets for the second address to the Apache Httpd server (which was configured to listen on port 8080).

 iptables -t nat -A PREROUTING -p tcp -d secondIP/32 –dport 80 -j REDIRECT –to-port 8080

To make this iptables config permanent just do ‘/etc/init.d/iptables save’.

In DNS I configure the domains using Tomcat to the first IP address and the domains using Drupal to the second address.

 

October 13, 2009

The mysql/jdbc 8 hour problem

Filed under: Software

This subject has been discussed a zillion times on the web (not always very constructive) and it has been bothering me for many years as well. So let me be person zillion+1 to write a blog entry on it.

Let me first describe my setup: Tomcat 5.5, MySQL  Ver 14.12 Distrib 5.0.51a, for debian-linux-gnu (x86_64) , mysql-connector-java-3.0.17-ga, c3p0 0.8.5.2, hibernate 3.2. In my application I access the database both via hibernate and via tomcat container managed authentication.

In mysql the configuration parameter wait_timeout defaults to 28800 seconds (= 8 hours), typically resulting - if no precautions are taken - in an sql exception after a night of inactivity on the webapp. What can be done about this:

  1. increase this timeout value in my.cnf (make sure to change it in the mysqld section), but this is a workaround and not a real solution.
  2. use the connection testing mechanisms provided by e.g. the c3p0 pooling lib.

A good description of this connection testing is provided here . The most robust mechanism is testing the connection before you want to use it (testConnectionOnCheckout), so let’s focus on this approach for the remainder of this article.

What we need to figure out now is how we configure c3p0 pools with the testConnectionOnCheckout mechanism in hibernate and in container-based authentication (because these are the 2 ways we access the database)

For hibernate I used following fragment in the hibernate config file

<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.max_size">4</property>
<property name="hibernate.c3p0.min_size">2</property>
<property name="hibernate.c3p0.timeout">200</property>
<property name="hibernate.c3p0.max_statements">0</property>             
<property name="hibernate.c3p0.acquire_increment">1</property> 

AFAIK the explicit mentioning of connection.provider_class is only needed for hibernate 3.3 and higher.

I also added following c3p0.properties file on the class path:

c3p0.testConnectionOnCheckout=true
c3p0.preferredTestQuery = SELECT 1
c3p0.checkoutTimeout = 10000 

For the container-based authentication I added following DataSource and Realm in the context of server.xml

<Resource name="jdbc/myAppDs" auth="Container" type="com.mchange.v2.c3p0.ComboPooledDataSource"
     driverClass="com.mysql.jdbc.Driver"
     factory="org.apache.naming.factory.BeanFactory"
     jdbcUrl="jdbc:mysql://localhost/myAppt"
     user="aUser"
     password="aPassword"
     minPoolSize="5"
     maxPoolSize="15"
     maxIdleTime="200"
     acquireIncrement="3"/>
<Realm className="org.apache.catalina.realm.DataSourceRealm"
     debug="99"
     dataSourceName="myAppDs"
     localDataSource="true"
     digest="md5"
     userTable="userPswd"
     userNameCol="username"
     userCredCol="password"
     userRoleTable="userRole"
     roleNameCol="role" />

The resource also needs to be specified in the corresponding web.xml

<resource-ref>
<res-ref-name>jdbc/myAppDs</res-ref-name>
<res-type>com.mchange.v2.c3p0.ComboPooledDataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref> 

So, that’s how I am avoiding the daily sql exceptions …

Get free blog up and running in minutes with Blogsome
Theme based on a design by Jay of onefinejay.com