Wednesday, July 30, 2008

Sliding down, Scriptaculous and jQuery

Haven't been hacking JavaScript "seriously" after a few years, I got myself back into doing it two days ago. I wanted a slide up/down effect on a panel when a button is hovered.

I first came across the Scriptaculous but I wasn't satisfied with the size of the JS files, Scriptaculous+Prototype+jQuery, as I use Thickbox as well (too bad, Lightview is not free).

I received some questions in Twitter and Facebook about "why both?", so I knew I needed a change unless I had a good reason. I then spent a bit of time in the morning to read the jQuery's documentation and found out that it's easier to get this done with it.

Here's the code comparison:

jQuery's Snip

jQuery(document).ready(function(){
jQuery("#woPageSelector").hover( function(){ jQuery("#woPageSelectorContent").slideDown(300); }, function(){ jQuery("#woPageSelectorContent").slideUp(300); } );
});


Scriptaculous' Snip

var mouseOverHandler = function(event) {
$('wpPageSelectorContent').slideDown({duration: 0.5, queue: {position: 'end', scope: 'pageSelectorsPanel', limit: 2}});
$('woPageSelector').stopObserving('mouseover', mouseOverHandler);
document.observe('mouseover', mouseOutHandler);

}

var mouseOutHandler = function(event) {
$('wpPageSelectorContent').slideUp({duration: 0.5, queue: {position: 'end', scope: 'pageSelectorsPanel', limit: 2}});
$('wpPageSelector').observe('mouseover', mouseOverHandler);
document.stopObserving('mouseover', mouseOutHandler);
}

$('wpPageSelector').observe('mouseover', mouseOverHandler);

By the way, if you really have to use Prototype and jQuery at the same time, you may want to read this page to prevent conflicts.

- yc, woohoo!

Sunday, July 27, 2008

Second Day of BarCamp Malaysia - Awesome!

The second day of BarCamp was simply.. Awesome! I talked about being a newbie wireless user yesterday and I have another newbie experience today on OpenOffice Presentation. We are newbies in certain areas of our life at every single day to learn new things, aren't we?

I started my day by attending a wireless network hacking session by the iTrain guys. A very great and rich session indeed, with a speaker who couldn't stop reminding us that he has a longer toy than us, he showed a number of tools to make wireless hacking easier. And not to forget, Linux is the best platform to launch attacks. It's a shame that the demo didn't work and the session dragged quite a while to make my slot left with 30 minutes time.

Yes, my talk on CDN fell in the same lecture room. Being a big fan of Steve Jobs' style presentation, I made my slides as clean as possible with just keywords, although I didn't deliver a smooth one like his (hopefully next time), thanks God that the decision to make the presentation short saved me from rushing given such limited time (of course, the reason wasn't to run into Ditesh's talk but to have more QnA and interactions).

Followed by it, it was Talat's talk on "Hidden Impact of Higher Mathematics on the World Wide Web". Talat and his talk reminded me of the Oxford Murders.

After having our Subway lunch, I ran into (once again) the Lecture Room 1 as Kamal and Aizat planned to run a ligthning talk session there. So, when I thought I would finish up my day all in Lecture Room 1, we got the news that the session got forked and we just merged with folks in another room.. which started with a talk on hiding porn video files.

It's so excited to see how much information people could share in that one hour time!

- yc, in and out.

Saturday, July 26, 2008

First Day of BarCamp Malaysia

Was ruined, by my own paranoia, which I will talk about it later.

Quickly run through, my camping started from Gavin Bong's "Google Android" talk. A pure technical talk on Android which got us hanging to decide whether we shall go for this toy.

The second and third talk that I attended fell in the same time in the schedule, Chee Seng "Flex and JRuby on Rails" and Yoon Kit's "The OpenMalaysiaBlog Story", attended just half of each of them. I liked how Yoon Kit's presented the stories in a mind-mapping-like diagram.

As I slept pretty late last night, my brain wasn't in any good condition to absorb more knowledge, I ended up looking for my friend in a Silverlight's talk, by the Silverlight guy. I blogged about Silverlight last year by the way. The product is quite interesting, slides were pretty, but the presentation was pretty screwed as the speaker came late and more than 50% of the slides were skipped.

The fifth talk, "Mobile Future" by Henry from Nokia. This is the talk that got me (bored) to hook into the IRC to chat with the #myoss guys. What went wrong? Henry was not actually being at the wrong place but there were just too many technical guys being in the room to generate him some problems.

IRC? I then realized that I have some applications running and they were trying to authenticate with servers and some of them were using plain text authentication. If they were ever sent, they were sent to the network set up by KageSenshi. Browsing is pretty safe on this laptop, as everything is tunneled over SSH to a server, but not other applications! I was not sure at all how they worked, but I could guess that the applications would check for availability of the servers before sending authentication information.

Now, why waste time guessing if I could just run back home with a cab in 10 minutes? That's how I finished my camping today. Can't blame KageSenshi if he really got my passwords. ;-) Of course, the biggest mistake was ever telling him that it happened. That was really a stupid ~20-minute, everything uses SOCKS now at my end and I feel fitter and happier.

I'm done, first-day Barcamp journey of a newbie wireless user.

- yc

Friday, July 25, 2008

Things do Go Wrong Sometimes

Chuk Munn is a Sun Evangelist who I met last week, a comment from him in the Malaysian Java User Group lately, however, went very wrong and was found in strong disagreement by a number of us.

It's a topic on class-loading which he shared based on his past experience that "(you shall) never use a functionality from an open source project if it is available unless you absolutely have to."

I'm not sure what he was trying to sell, maybe the Java Logging API provided by the SDK versus Log4J. But certainly from me, I would rather put the blame on the container of not doing a good isolation work instead of blaming open source.

- yc

Wednesday, July 23, 2008

Ubuntu Hardy Update Freezes during "Generating locales..."

I was upgrading a Ubuntu machine at work yesterday, it froze while it set up the locales:
Setting up locales (2.7.9-4) ...
Generating locales...
en_AU.UTF-8...

(you can go for a coffee now, like, taking a shower and drive down to the town to buy it from Starbucks)

I killed dpkg and restarted the set up but it didn't help. More errors while after packages were being set up:
perl: warning: Setting locale failed.

I didn't get a good response from the #ubuntu channel but some Googling got me to bump into this forum topic. There are a number of solutions being suggested in the topic, what worked for me was by booting into the recovery mode to run the package manager again.

- yc

Tuesday, July 22, 2008

"Shutting down" the RMI Registry

This blog is a quick tip to shut down the RMI registry. Something I encountered just now while writing the tearDown() method for a test case.

When a RMI registry has already been created (via LocateRegistry.createRegistry()), re-creating it will give you an ExportException:
java.rmi.server.ExportException: internal error: ObjID already in use
at sun.rmi.transport.ObjectTable.putTarget(ObjectTable.java:169)
at sun.rmi.transport.Transport.exportObject(Transport.java:74)
at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:229)
at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:393)
at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:129)
at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:190)
at sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:92)
at sun.rmi.registry.RegistryImpl.<init>(RegistryImpl.java:78)
at java.rmi.registry.LocateRegistry.createRegistry(LocateRegistry.java:186)
at org.mule.transport.rmi.RmiMessageReceiverTestCase.registerRmi(RmiMessageReceiverTestCase.java:126)

Yes, you can't create the same registry twice, therefore you may want to dispose the previous one after every test (not actually necessary, as you could just share the same instance for all tests). An RMI registry can be disposed with the UnicastRemoteObject.unexportObject() method, by passing the Registry object to the method argument. Take note that LocateRegistry.createRegistry() and LocateRegistry.getRegistry() give you a stub to the remote object as a different object, so please use the same reference returned from the createRegistry() method.

- yc

Monday, July 21, 2008

A Networking Session with Sun / Java Evangelists

There was an invitation sent to MyJUG, to a networking session with the Sun / Java Evangelists last Wednesday at Monash University. The turn-up wasn't that high and I reached there pretty late too, I guess everyone was pretty stuck at work or in the jam. Thanks Chee Seng for the ride, otherwise I would have stuck 'til the event had ended.

Good to see familiar face like Colin Charles (the MySQL guy) and Loke there, and finally met up with Monica Ng (the Marketing Communication Consultant of Sun). The evangelists in list anyway, were, Matt Thompson, Reginald Hutcherson, Lee Chuk Munn, Peter Karlsson, Colin and Naveen Asrani.

Sitting alongside with the evangelists was fun. We started our technical conversation when Chee Seng introduced himself as a Flex guy. Chuk Munn and other folks started to bash Flex to promote JavaFx, something that I did not show much interest on which I might give a try now after being told that the beta release will be a very fine product.

We also touched on the performance enhancement of Java 6 SE Update 10 as well as the new Open Solaris. We all left after some folks distributed the live CD of the OS.

It would have been a greater event without the nearly 2-hour jam. Hopefully Sun will make it a weekend next time.

- yc

Catch Aflexi + CDN Talk in Barcamp Malaysia

Mentioned in my earlier blog that I will be presenting at Barcamp Malaysia this weekend (Sunday) on the topic "Content Delivery Network".

The agenda shall go like this:
  • Problems of the current state of the Internet
  • Introduction to CDN
  • Existing CDN Providers
  • Who use CDN?
  • Aflexi CDN model
I will put up the content of the slide as soon as I have completed it. Still fixing up stuff for prototype development here.

- yc

Monday, July 14, 2008

PropertyPlaceholderConfigurer.ignoreUnresolvablePlaceholders and my precious one hour

To speed up my prototyping process, I decided to use Mule to takecare of the integration of my core code with the persistence layer for me. Yes, basically I am lazy to write all the polling, updating, etc. This did not turn out good as I was stupidly assuming a startup problem a Mule issue and tried to fix it in the past 1 hour.

So what was it about?

I have a Mule configuration and also a Spring beans configuration which is used to configure datasource. PropertyPlaceholderConfigurer is also defined in the Spring configuration to read a jdbc.properties file and those properties will be filled into the datasource settings, e.g.

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>${jdbc.driverClassName}</value>
</property>
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
</bean>

Great, unit test goes easier now. Not yet.

I have this JDBC query settings in my Mule configuration:

<jdbc:connector name="jdbcConnector" dataSource-ref="dataSource" pollingFrequency="5000">
<jdbc:query key="getSurrogateById" value="SELECT * FROM surrogate WHERE surrogateId=${header:test}" />
</jdbc:connector>

Tried to start Mule, but it failed with this error:

[07-15 00:47:34] ERROR AbstractConfigurationBuilder [main]: Configuration with "org.mule.config.spring.SpringXmlConfigurationBuilder" failed.
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'jdbcConnector' defined in null: Could not resolve placeholder 'header:test'
at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:268)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:75)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:554)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:528)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:363)
at org.mule.config.spring.MuleApplicationContext.<init>(MuleApplicationContext.java:102)</init>

Changing the Mule version didn't help (something stupid that I did), until I uncommented PropertyPlaceholderConfigurer, Mule was able to start. That gave me the clue to look into the class (which I didn't have to as the stacktrace was obvious enough) to find out the ignoreUnresolvablePlaceholders property.

Bah.

- yc, finished ranting

Tuesday, July 8, 2008

Configuring CNAME to SWURL

I just received a tweet about how did I configure www.yclian.com to point to yclian.swurl.com, something that I actually was stuck in a while. Here is a short blog about it.
  1. Configure your DNS CNAME
    Create a new CNAME, e.g. www, and point it to your SWURL's host, e.g. yclian.swurl.com.
  2. Configure your SWURL
    Go to SWURL > Settings and add set the CNAME http:// field to your new domain alias, e.g. www.yclian.com.
Clear enough? I actually found it from this conversation.

- yc

Monday, July 7, 2008

How Generic Shall it Be?

I have been writing the protocol API using Java 1.5 these days. There are some tempting features to use, but I'm not sure how evil they will be.

For instance, I use annotations to reflect clauses mentioned in the technical specifications:
@TechnicalRecommendations("1.2.1.3")
@PublishEvent(events={"UserNotification.EventType.ACCOUNT_CREATING", "UserNotification.EventType.ACCOUNT_CREATED"})
public void createUser(User caller, User targetUser) throws PermissionException;


I also use the generic feature:
public interface User<P extends Profile<?> extends Entity
public interface Profile<U extends User<?>> extends Entity


That sounds a bit funny hey. I haven't yet found a good guide on how you should use generic smartly. Comments?

- yc

Sunday, July 6, 2008

Blog Ads == Sign of Immaturity

Feel free to disagree.

I have never been a fan of putting blog ads in my blog, as you can see as well, I apply a plain and simple layout. This is due to one very fundamental belief that Web 2.0 is data driven.

I once stood up in a public forum to point out that, people should be utilizing tools to efficiently obtain information/data/feeds, web browser is just an option. One reason to go against using web browser to visit a blog or news site is the unnecessary download of images, JavaScript, stylesheets, etc.

This belief has turned to an even-firm conviction as I started to use Swurl last week.

It has been so many years, and it looks like people still need more time to adopt Web 2.0 in the "right" way. What about the ads companies? Maybe they have to find ways to inject ads into content when web/HTML presentation is abandoned.

By the way, I made some DNS configurations, you can now reach me at yclian.com.

My blog address is now:
My Swurl page is at:
My (new) OpenID is at:

- yc

Friday, July 4, 2008

Welcome to Aflexi

Hi guys,

I did not touch on this in my status update a few weeks back. Anyway, here it is, I have left CustomWare Asia Pacific, a company that I first joined after my undergraduate study and which certainly had shaped my career pretty well -- worked on Atlassian and MuleSource products.

I am now starting a new business with my friends, a company called Aflexi, with a goal to transform the current state of the Internet to a better one, with CDN (Content Delivery Network). I am holding the position of V.P. of Engineering and.. we're still working on the website, feel free to follow our Twitter here. Catch me in the BarCamp Malaysia (first and ever) as well, there will be a session that I will be presenting CDN to the folks.

Anyway, it is the birthday of Rob (founder/CEO of CustomWare) today, so.. happy birthday mate.

- yc

Wednesday, July 2, 2008

How opportunity is given to your team members? If you are given this common scenario.

Firstly, I am not facing such a problem now. The situation came into my mind and I was thinking about what would be the best solution(s), if it happens one day that I have to make such decision.

I scrolled over my long list of MSN buddies, but I couldn't find the right people being in the right companies (true that, there's no perfect company and each company has its own culture) to answer my question. If there's any books that you can recommend, do let me know too.

Here comes the question. Say, if you are a team leader who is running a small team and there is an opportunity which can only be given to only one team member. An opportunity could be, a chance to move to another project, or to lead a new sub-project in a team.

Very common problem right? But I would like to know how differently people will handle this. Generally, the leader will short-list the potential ones from the team and make internal discussions with the superior and/or the candidates; or, instead of short-listing the guys, you make this information completely transparent to the team and let those who are interested to come back to you.

I gave two suggestions above, but each comes with its own set problems. The first one could possibly kill the opportunities of others, the second one could generate more competition in the team, so..

What will YOU do and suggest? And, what organization you are in? An open one? You may want to tell me how often do you share information with the team.

- yc