Life Codecs @

Ruminations. Reflections. Refractions. Code.

Feb 23, 2009 - general personal philosophy

Blog Name Change

So I googled “lifeflow”, my God I am embarrassed – that turned up a heap of hits – could I be part of the hive mind that is the world. No, that can’t be, I attribute it to a quirk of fate :P. So here’s the new name, the tagline has “Code” added to it. In a sense the original intent of this web log has not changed, and I think figuring life out takes some encoding and decoding, and I do enjoy writing code, and and ‘codex’ is a book or manuscript – very log-y – so ‘Life Codecs’ sounds rather apropos. And googling this, as expected a lot of results turned up on audio/video codecs, but that’s okay – at least I am not some quick fix to gain enlightenment. I mean, I wish I was – like for real – but I’m not :P.

Let’s hope I don’t have to change it again.

Feb 22, 2009 - general personal software dev


I have some semblance of a website! And I finally put some code on, yeah baby! This being a bum business is kinda fun, hmm now if only I could bring in money while staying at home without methods mentioned in scammy ads. Anyway, check it out :D.

— Kamal

Feb 16, 2009 - how to software dev

WordPress’ Tag Cloud Limit

So I got sick of wordpress seemingly not updating my tag cloud – after googling – turns out the tag cloud is limited to 45 items, and the admin interface (using WordPress 2.7.1 at time of writing) has no way of updating it. If you wish to up this limit, you:

  • Navigate to /path/to/wordpress/install/wp_includes
  • Backup the file widgets.php as widgets.php.orig in case you mess up (and no I did not).
  • Edit widgets.php, around line 1867 you’ll find a function wp_widget_tag_cloud($args) which looks like so:
 * Display tag cloud widget.
 * @since 2.3.0
 * @param array $args Widget arguments.

function wp_widget_tag_cloud($args) {
        // [... snip ...]
        echo $before_widget;
        echo $before_title . $title . $after_title;
        wp_tag_cloud(); // REPLACE ME!! ME!!! (and no this comment did not exist in the source)
        echo $after_widget;
  • Replace the commented call (can you guess which one?) with:

    wp_tag_cloud(array(‘number’ => 78))

    replacing 78 with the no. of tags you want to display.

If you’re so inclined and have shell access to your install, you can instead apply this patch which sets the number to 101, my setting, and if your file is different (say due to a different version of wordpress), it probably will fail :P.

Enjoy. I’m going to tag this post, among others, with ‘tag’, bet you didn’t see that coming ;).

— Kamal

Feb 6, 2009 - software dev


The title means “Wicket is Wicked!” in German (I know, lame, still kinda funny though :P). More seriously I just finished Parts 1 and 2 of Wicket in Action. I found the book to be very well-written with one exception: the analogies to the lasagna preparation made me very hungry – I am currently fasting, ahem. Apart from that, it certainly explained the framework well enough to enable to me to write this post, so kudos to the authors and Manning. Here’s my ‘review’ (if I may be so bold) of the book/framework (note that this is based on fairly limited usage writing toy apps, so caveat emptor):

I fully read and tried out examples in parts 1 and 2. I love the framework, it truly brings an OO component-driven model to web programming. As the authors aptly pointed out, Wicket solves the impedance mismatch problem between the stateless nature of HTTP and stateful object model, and Wicket solves it well! The impedance mismatch issue is analogous to the one we have between OOP and RDBMSes which of course ORM solutions like Hibernate solve. Some pros and cons:


  • Familiar OO UI programming model, especially for people who’ve written thick client apps in toolkits like Java Swing.
  • Encourages typesafe – almost transparent – state maintenance using objects rather than direct manipulation of the Servlet HttpSession.
  • Excellent abstractions make learning logical and intuitive, for example a Page represents a top-level container, similar to a Frame object, to which you can add child components.
  • Minimal configuration gets you started. Pretty much just web.xml to configure your wicket app, the other plumbing can be done using Maven 2, definitely check out the bonus chapter 15 online very early on to configure your IDE so you can play with the examples.
  • Makes wizard creation – a fairly common and very tedious task in web programming, God the pain… – a breeze, not because it has specialised classes or declarative ways of doing it, but because state maintenance is easy, passing one page instance to the next page instance is straightforward ( page1 = this; … setResponsePage(new Page2(page1, …)).
  • Previewability – allows HTML pages to be viewed with dummy data that will be removed at runtime. The authors admit however, if a page has a lot of components, it makes it more tedious to preview.
  • A lot of thought has gone into packaging new components, complete with their own resources such as CSS files, images, and Javascript. This extensibility does allow a lot of reuse of components easily, very much in line with OO principles.
  • I did not mess with this a lot – but Wicket seems to have decent Ajax support, including transparent fallback to non-Ajax behaviour if it is disabled on the browser. The authors point out that Wicket takes the view that Ajax is optional, and assuming you use the correct Ajax+Fallback component, no code changes are needed to accomodate both Ajax and non-Ajax behaviour. Chapter 10 of the book which I hardly read (part 3) goes in more depth about using Ajax.
  • Due to the stateful nature – makes checkbox and multi-selection handling a breeze, woohoo!!
  • A lot of built-in validators for common validations – having said that, these days I tend to prefer having validations (== business rules) done via my models, so this doesn’t buy me a lot – in fact it would make me put business rules in the web tier. Ideally we could annotate models and use some form of code generation (I hear screeches of pain…) for both the models and the client side for better responsiveness, of course some validations just can’t be done on the client side, so still thinking on this.


  • There’s a lot of reliance on Java object serialization – to achieve transparent state maintenance, Wicket serializes the manipulated markup and code at the end of each request. This means any models you have used in the session must also be serializable. The good news is the authors spend time talking about this, and ways to get around it, using detachable models (I’d rather call them model wrappers for they wrap your actual model object) for example. This is also something to take note of when considering performance issues.
  • For people used to request-response based frameworks like Struts, the programming model will take a little bit of getting around – although I got around it pretty quickly, it seriously is way easier and more logical, especially to back-end programmers. As with any framework, there are new concepts to pick up here and there.
  • To bind models to web forms, strings are used in the form of property expressions (e.g. foo.getAddress().getStreet() -> “foo.address.street”), this obviously will not be picked up when your models get refactored. Hopefully smarter or Wicket-aware IDE plugins will help in this area. This plague is common to many frameworks… (e.g. in Hibernate: HQL and even when using the Criteria API).
  • In spite of adherence to the DRY principle, it does not generate HTML for you, and markup (which are tagged with “wicket:id” attributes referenced in the code) and code must remain in synch or Wicket will throw an error when accessing that page. This is good and bad, the nice bit is it does allow web designers to maintain the look and feel for you. Wicket IDs, Code Hierarchy, and Markup Hierarchy synchronisation is another place where Wicket-aware IDE plugins would be useful.

I only skimmed through Part 4, but it definitely has a lot of useful advice on integrating Wicket with with other toolkits and middleware such as Spring and Hibernate, and on internationalization (i18n) and localization (l10n) (still trying to figure what the latter’s scope is exactly…), something that’s missing in many books – while it’s not strictly necessary thoeretically, practically no framework works in isolation these days except perhaps if you get full-stack frameworks like Grails or JBoss Seam that Ruby on Rails popularised; dunno, I still kinda like cherry picking my parts, but I haven’t explored these so I may change my mind.

Hmm, I wonder how it compares to GWT – something else to try out when I have time, for now, time to check out EJB 3.

— Kamal

Feb 2, 2009 - general gripe personal

Bad Hairday!

Ya know, like many geek-types, I am not one who is too concerned with how I look, at times I look a little messy, but clean, not dirty or icky – to me that is sufficient. Fortunately (for it is overall fortunate), hair grows and there are times when I need to cut it. I kept long hair for a couple of years – looked very hacker-ish, but alas, it was a maintenance nightmare. So anyway – I do not have a regular salon that I go to, and am not one to spend any more than 30 dollars per haircut, even that is excessive! Unfortunately, it seems that in Melbourne, there’s no such thing as a “decent” haircut unless (I assume here, for I have not done it) you shell out some absurd amount. So today, despite my inner voice telling me to do it tomorrow (no kidding!), I decided I needed to get a haircut. I went into the city, looked at a few places on Elizabeth St., went to Melbourne Central basement – there was a place I had intended to try out but they were closing already. Went into China town, entered a place… and for a simple male cut in this standard-ish looking place in an arcade, they were charging 63 dollars! Can you believe that?! Like, what magical I-Ching hexagram was consulted to get that number?! So I stood there, raised an eyebrow, then declined and left. I ventured back to Elizabeth Street to this decent looking salon (by no means a 2-seater barber shop, though I reckon I’ll try that next time… couldn’t be worse). I was asked to wait 15-20 minutes, and then it was my turn…

The lady (in her early 20s) asks what kind of cut I’d like, I said I wanted it short, and “square at the back” – the latter phrase is something I picked up way back when I moved here, to say I want a clean angular lining at the back, as opposed to curvy one I suppose. Firstly, I asked for a haircut and I came to a salon, so what’s with these people asking me what number I am!? Like how the heck am I supposed to know what clipper I want to use, isn’t that why I’m there!? Okay, so maybe there are people who know their hair and the tooling for it well, I am not one of those lucky folk. So anyway, I tell the lady I have no clue, she says she’ll try a number 4 (she was Chinese, I am told the character for “4” in Chinese is similar/the same to the character for death!). I’m like yeah whatever. And BANG, she runs the thing like a bloody lawnmower on grass. I mean I asked for “short“… not “let the outline of my head be visible to all who will see“! She moved it so fast that by the time I told her that I didn’t want it that short, she replies in her accent, “this is no. 4 – must be same len’ everywhere, if start, cannot stop”… what the bleep!? I realised then there was nothing I could do about it, it was way too late.

Now if it was just that, perhaps I could let go and move on (actually I have done that already, I’ll just feel better once I have this all in writing!), she also had no sense of symmetry… when she was placing the mirror at the back of my hair, I had to point out a couple of things – it wasn’t “square at the back” damn it!, and in one case, she just could not see what was wrong… so I literally just went “nevermind”, because I was afraid she’d ruin it further :(. Folks, if you have no sense of symmetry – please, don’t consider hairdressing, or software engineering, become an abstract artist or something, you know. So yeah, I have had a bad hairday – this must be the worst to date, once it grows I shall be able to get it cut again (I don’t where, but I do know where NOT!). Oh and worst of all… she did not use scissors… the biggest no-no in my book1. I asked for a haircut, not a clipper cut (a concept I have only heard of here…)!

Now some upsides – yes there are upsides, hard to believe: despite the cost advertised – 30 dollars – I was charged 15 – I so would have left some diplomatically caustic (is that even possible, or is it an oxymoron?) words for her to ponder otherwise. It appears she thought I wanted a clipper cut (but I said I wanted a HAIRCUT, H-A-I-R-C-U-T!!) – boy I must look like a starving student (that’s another upside, I must look young and fresh)… I suppose I hadn’t had any food yet at the time. The final upside I guess the lack of hair will keep my head cool during the summer. Meh.


1 Kamal’s Book of Life Skills, by yours truly, Chapter 33, p22, verse 11: “Profess’d as a hairdresser, ask’d for a haircut, clippers come and clippers go, but thou shalt use scissors without fail, else, a pox o’ thee, curses, boils, and sores spattereth across thy body, Heretic O’ A Hairdresser, Liar, Cheat, Heathen and Most Unholy Scum.”