Wednesday, January 26, 2011

Ebooks from top StackOverflow answers

Have you tried StackOverflow, if you are a developer its probably one of the best resource for asking questions.
Its a great site, what is even greater is that someone converted the best answers into an Ebook format.

Great for bring around, the link is here Whats nice is that it is broken up nicely into the different subject like ajax, python, c#.

Tuesday, January 25, 2011

Posting data with Node.js

Recently i needed to post data using node.js, I was not trying to post a long string of data but rather parameters from a form. But the Node.js help page isn't too helpful, it just say use request.write() to write data to the stream

  This is the first interation i got.


var http=require('http'); var post=http.createClient(80,'localhost'); var request=post.request('POST',/test.php'.{'host':'localhost'}); request.write('test=10'); request.end(); request.on('response',function(response){ response.setEncoding('utf8'); reponse.on('data',function(chunk){ console.log(chunk); } });
test.php is a simple php script that prints out the parameter value.

  I got nothing... nothing was printed out. What was wrong?

  Using curl and Fiddler, i did a little investigating about what went wrong, what was missing was the Content-Length and the Content-Type which needs to be application/x-www-form-urlencoded.

  Adding these 2 parameters to the script

var http=require('http'); var post=http.createClient(80,'localhost'); var request=post.request('POST',/test.php'.{'host':'localhost','Content-Length':'7','Content-Type':'application/x-www-form-urlencoded'}); request.write('test=10'); request.end(); request.on('response',function(response){ response.setEncoding('utf8'); reponse.on('data',function(chunk){ console.log(chunk); } });
And yeah ! It works !

Tuesday, January 11, 2011

JRex, Embedding Gecko (Firefox) in eclipse

Jrex is a Java component that embeds Mozila Gecko in your application. The project has been dead for some time since 2008 from what the page. So the version of Gecko may not be the latest but should be good enough for whatever you would like to try out.

 However looking at the code from Vijay (
), i got it working and it seems to work fine, but Vijay dosen't really go into how to setup the project like where to download the jars and where to put the dll and so on, and I did have some hard time trying to find out where to find the jars.

1. At first i took apart the jnlp file on to find out what are the dependencies, but after looking around the mozdev site, i finally found the downloads for the jars, source and docs in here (

 2. But it dosen't include the jrex_gre files that are in the jnlp, those you can get them here ( Look for the jrex_gre.jar

 Setting up your eclipse.
Put the jrex.dll in your eclipse directory, if not you will get a UnsatisfiedLinkError when you try to run the view. Put the jrex.jar in your lib folder of your project.

 Unzip the jrex_gre.jar contents to a nice location you can remember.  You will see in Vijay's code a place that you will need to supply the path to the file in org/mozilla/jrex/jrex_gre files.

 That should fill up the missing pieces in Vijay's writeup.

I will try to package the source code into github at some later time.
&n bsp;

Thursday, January 6, 2011

Fedora 14 - Using the DVD as a software repository

Installed Fedora today at office in order to try out some web acceleration stuff lile squid and varnish. I used the DVD iso version, so that i can have most of the essential software already.

  When i rebooted i found that the dvd is not recongnised as a software repository, because there is no entry in /etc/yum.repos.d/.

No biggie, just mount the dvd, in the root of the dvd there is a file media.repo, jus copy the file to /etc/yum.repos.d/ as packagekit-media.repo and you are all set, your dvd becomes a software repository.

Wednesday, January 5, 2011

Resolutions 2011

My resolutions for 2011.

For the personal geek in me (Probably have little to do with work)

I declare this to be the year of functional programming for me!

Common Lisp 
Begin by first completing Practical Common Lisp and Land of Lisp, and the little pet project that i do when i have free time, the idea of closures and high order functions really appeal to me.

Another Functional Language that I hopefully have time for this year. Invented by Ericsson for using in telephony applications, it has some interesting properties like fault tolerant and hot swapping. Since it's designed for telephony (which has something like 9 9's of availability) you can actually swap in code while the system is running which i think its pretty cool.

Hadoop/Map Reduce
Always heard about MapReduce and Hadoop, I shall attempt to read google's paper on it and hopefully setup a working instance.

NoSQL is getting big nowadays with Twitter and Facebook all moving/developing part of their infrastructure on top of NoSQL type of storage.
Learn at least one implementation and see how it can be worked into a project.

For the bookworm in me
Read The Elements of Style, one of the great books on the writing for the English language. Time to get better at my writing, better written communication is essential as you go along ur working life.

Read more "management" style books especially in the realm of making people happy at work, I am quite interested in how great organizations retain their people and keep them happy.
So far i have FISH! tales, Why work sucks from the library here with me.

For the not so fit me
Finish taking my IPPT before June and pass it.
Run at least once a week at least 2.4km.
Attempt to run a half marathon by then end of the year. (Haha this will the hardest one in my list)

For the bad habits in me
Second guessing or interrupting people midway
I don't know if people noticed but i do have a bad habit of either completing other people's sentence or second guessing what they will say. I will let others finish what they want to say before I start, I will try to follow the rule of One Conversation at a time.

I have a habit of procrastinating, enuff said.

For the father and husband in me
Hopefully I will have time to go for a vacation, hopefully it will be the first time that I am bringing Chloe overseas.

Better Father/husband
Its quite hard trying to be specific as to what makes a better father, could be a variety of factors but i sorta like this one that I got from FISH! Tales book, "Love for child. is simply being there".

Lets look back again in 2012.