Tuesday, December 16, 2008

Perl programmers

More good reasons to go back to Perl programming amid the economic downturn and rising unemployment.

Thursday, October 30, 2008

Everyone is fit to drive a bike now

HANOI, Vietnam — Faced with mounting public criticism, Vietnam's Health Ministry suspended a widely ridiculed plan to ban short, thin and small-chested drivers.

The ministry had recommended that people whose chests measure less than 28 inches be prohibited from driving motorbikes _ as well as those who are too short (less than 4 -foot-8) or too thin (less than 88 pounds).

When the media revealed the plan this week, it prompted disbelief and scorn among members of the public, who envisioned the police pulling over female drivers to measure their breasts.

Thursday's state-run Tuoi Tre newspaper quoted ministry official Nguyen Huy Quang as saying the proposal would be suspended.

Copyright 2008 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.

Monday, October 27, 2008

Sunday, September 28, 2008

Feeling Homesick

Reading this travel article this morning really makes me feel homesick

"Vietnam offers some of the most charming tropical scenery in the world. The mist rising from the land against the morning sky is resplendent. The lush mountains and gorges and verdant valleys and endless rivers create a colorful landscape. A coast line that stretches for hundreds of miles along the South China Sea makes it a marvel of geography."

Wonder if this is a case of 'opportunities missed are opportunities gain'.

Sunday, September 7, 2008

Oracle8 and INNER JOIN

The 'new' ANSI syntax (INNER JOIN, NATURAL JOIN, etc.) is only supported when dealing with Oracle9i and higher.

All the more reason to move to Oracle9i. Especially since Oracle did announce End of Life for 8i.

Monday, September 1, 2008

XStream and Dynamic Proxies

So I've been bragging a bit (yeah, just a bit) about XStream because I'm currently using it in my unit testing framework. I started out with the original DynamicProxyConverter and there is already a very good post on how to use it from Straun's blog. But then I soon ran into problems trying to set a super class for the resulting proxy object for the following class hierarchy:

public interface MyObjectInterface { void doSomething(); }

public class MyObjectBase { public void intialize() {} }

public class MyObjectImpl extends MyObjectBase implements MyObjectInterface {
public void doSomething() {}
}

The solution is to clone DynamicProxyConverter.java and replace the last line of code in the unmarshall() method:

return Proxy.newProxyInstance(classLoader, interfacesAsArray, handler);

With

return newProxyInstance(superClass, interfacesAsArray, handler);

Where newProxyInstance is a method which utilized javaassist package to create the proxy instance in the cloned DynamicProxyConverter:

private Object newProxyInstance(Class superClass, Class[] interfaces, InvocationHandler handler)
{
ProxyFactory factory = new ProxyFactory();

if (superClass != null) {
factory.setSuperclass(superClass);
}

factory.setInterfaces(interfaces);

Class clazz = factory.createClass();

Object proxy = clazz.getConstructor().newInstance();
((ProxyObject) proxy).setHandler((MethodHanlder) handler);

return proxy;
}

For this to work, your InvocationHandler class should also need to implement MethodHandler interface, ie.

public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args)
throws Throwable
{
if (proceed == null) {
return invoke(self, thisMethod, args);
} else {
return proceed.invoke(self, args);
}
}

Sunday, August 31, 2008

XStream Deserialization

When calling XStream.fromXML() to deserialize an object, XStream by default will use ReflectionConverter to populate the fields of the given root object instead of instantiating a new one. To force instantiation of a new object, use

XStream xstream = XStream(new PureJavaReflectionProvider());

Cheap journalism

VietNamNet (VNN) today has an article about Vietnam's National Day. At the end of the article the following was added

"The Governor of the US’s California State, Arnold Schawarzeneger, on August 28 sent a message of greetings to the Vietnamese Consul General in San Francisco, expressing his thanks for the Vietnamese community’s contributions to the state’s development."

Is Arnold losing it? What the fuck does the Vietnamese Consul General have anything to do with the Viet's contributions to the state of CA and how it's related to Vietnam's National Day celebration is out of grasp. Cheap, cheap journalism at its worst.

Remains in Vietnam could be Australian soldier

If this turns out to be true, the effort to locate the last Australian soldier missing in the Vietnam war would be completed. Well done