Hello and welcome to my blog, which will deal with programming and other silly hobbies of mine.

This page has a feed that you can track (if you use Firefox, you may see the feed icon in the location bar)

lolcatz: Ish more coming?

by hrjhrj 03 Feb 2009 04:03


've been tripping on lolcats these last few days. I Can Has Cheezburger is the perfect way to unwind after a tiring day.

I wonder how this lolcatz movement originated. The wikipedia article doesn't pin it down; just describes it as a parody of internet grammar (or rather the lack of it).

But I have seen something similar in Terry Pratchett's novels. For example, in Moving Pictures (1990) when a bunch of animals, who happen to be on the magical hills of 'Holy-Wood' suddenly start speaking English. The entire scene is gut-aching hillarious. And the cats speak exactly like these lolcatz!


Fun With Inkscape

by hrjhrj 14 Jan 2009 17:47

A fun image done with inkscape.
Squint your eyes or stand away from the screen (or simply remove your specs, if you are myopic like me) to see the author of this blog.


tags: art fun

Winstone : A minimal servlet container

by hrjhrj 12 Jan 2009 11:32

When I am learning something new, I like to start with basic, simple tools and ideas. When learning servlets, I was quite intimidated by the size of Tomcat and Jetty containers (both the download size and the number of configuration options).

By contrast Winstone's design goal is to be simple and minimal, and it lives up to its promise. The download is about 150kb and I had configured and used it within a few seconds.

Compare that with

  • Tomcat 7Mb
  • Jetty 24Mb

Before you start using it, some caveats:

  • Given Winstone's design goals, there are some limitations in its feature list, and they are listed very diligently on its homepage.
  • The lastest release date is Jan 2008. That either means that the product has matured enough not to require updates, or that development has stalled.

tags: servlet web

Web programming in Scala: Choosing a framework

by hrjhrj 05 Jan 2009 20:31

For the last few months I have been trying to build a web site. Months? You may wonder why it's taking so long. It's nothing very fancy; just a simple input screen for a project I am working on. But the idea is to learn the techniques involved, and try to build an infrastructure that I can use for .. you know.. the super duper mega project always lurking in the pipeline.

A bit of my background. I have been a Systems Programmer (embedded systems, mostly) and my web programming skills shine at visual magnitude -20. A little bit of HTML, XML, Javascript and HTTP is fine with me, but I had a tough time staying afloat in the sea of buzzwords like JSP, JSF, Facelets, Servlets, Containers, EJBs, ORMs, ooh-my-blah-blah..

One thing I was clear about: I wanted solutions only around the language I am most comfortable with… Scala (and hence around Java). Without that restriction, the sea would have been even deeper and wider, for a newbie web developer.

Lift Web

I started by checking out [Lift Web], a framework written in Scala, and one of the oft showcased Scala applications. Lift seems to be a comprehensive framework, still in evolution (I mean the evolution of paradigms not just the code). The mailing list is very active and responsive. There have been some recent documentation efforts, but I didn't have that convenience back when I started, and so I had a tough time getting the big picture (probably because I didn't know some web basics back then). I also had a struggle with Maven (the dependency manager from Apache) which is used by the Lift guys. The problem, I think, was that Maven was being used for both dependency management and building the code. My complaints about a lack of a build tool on the scala mailing list triggered the creation of a very nifty tool: [SBT] by Mark Harrah.

Eventually, I was able to build what I wanted in Lift and it works fine. But I wished for a more light weight framework, so that I get to understand what is happening behind the scenes, and get a feeling of control.

I prowled for alternatives.

Slinky and Sweet

[Sweet] is a much simpler framework than Lift and easy to get started with. There is clear documentation available on the project's wiki. The only problem (from my point of view) is that it is based on a third party templating language (freemarker). When I mentioned this on the Sweet mailing list, it was suggested that I could build my own View class, and it was while exploring this option that the penny dropped.

I realized that this whole framework thingy is actually quite simple, once you understand Servlets and the HTTP request/response cycle. And what makes templating simple is Scala's support for XML. For example.

// This surrounds the given node with a standard template code.
def surroundWithStd (node:scala.xml.Node, title:String) = {
       <head> <title>{title}</title> </head>
       <body bgcolor="#c0c0ff">

// Sample usage
private def userAdd = {
    surroundWithStd (
         <h1>User addition</h1>
         <form method="post">
           <label for="nameField">Name</label>
           <input type="text" name="nameField" />
           <input type="submit" value="Add" />
       "user addition"

This should be faster than Lift's templating+snippet support (since the parsing of XML literals in Lift's case would have to be done at run-time) and more importantly doesn't require you to know anything more than Scala.

Ofcourse, you could do away with the XML support and use Strings directly (like the examples given in Servlet tutorials), but with XML you get static checking for XML syntax by the Scala compiler! The disadvantage is that it is bit slower (About 4x slower on a simple benchmark that I wrote).

This kind of down-to-basics approach is also being taken by the [Slinky] framework. But that is still a nascent project and heavily depends on the scalaz package, which is a little too academic and under-documented for me.

Rolling my own framework

Not finding anything that readily matched my needs, I just sub-classed javax.servlet.http.HttpServlet and went from there. It was totally straight forward; about 100 lines of code for the "framework" which includes "get" and "post" handlers, extraction of parameters and session data, along with a way to handle URLs with regex pattern matching.

You get the full advantage of a general purpose language at your disposal for the view layer. But that could also be a disadvantage for large projects, because the flexibility could snow-ball into complexity.

For smaller projects, it is a boon, because the number of people who would contribute to the project would be smaller and hence the problem is more managed. Also, it is quite easy to slap-on a file-based view layer with limited inline scripting (something like JSP or Lift's templates) on top of this basic layer when the project grows.


It is a good learning exercise to cook stuff on your own. And I am now more aware of the relative strengths of the currently available alternatives. In the future if my needs grow, I will be comfortable in upgrading my framework, or tailoring others to my needs.

tags: lift scala servlet web

why I hate java lib

by hrjhrj 25 Dec 2008 15:06

It takes so many lines of cruft to load a simple image.

import java.awt.*

Image image = Toolkit.getDefaultToolkit().getImage(args[0]);
MediaTracker mediaTracker = new MediaTracker(new Container());
mediaTracker.addImage(image, 0);

…. when it could be as simple as

Image image = SomeClass.getImage(args[0])

I think, it's not a language problem. It is just the obsession with object oriented-ness!


alternate DNS servers to the rescue

by hrjhrj 21 Dec 2008 19:27

For those burned by the latest internet carrier outage, try adding an alternate DNS server to your resolv.conf (or its equivalent in other operating systems). This will solve problems faced by some ISP's DNS servers.

For example, OpenDNS provides a great free service. Their servers are: and

If you are using DHCP to populate resolv.conf, remember to update the dhclient.conf file. For example,

prepend domain-name-servers;

Add this to the dhclient.conf file of the network interface you are using. For example, for eth0, the file will be /etc/dhclient-eth0.conf

While you are at it, consider running a local DNS caching server on your machine. This will result in a quicker network access for you, and also reduce the load on the public DNS servers. For example, dns-masq is a great and easy to use DNS caching server.

To make sure your local DNS server is used, add another line to dhclient.conf as follows:

prepend domain-name-servers;
prepend domain-name-servers;


What a feeling

by hrjhrj 16 Dec 2008 14:21

As I saw this photo, a song played in my mind.

What a feeling.
Bein's believin'.
I can have it all,
now I'm dancing for my life.
Take your passion
And make it happen.
Pictures come alive,
you can dance right through your life.

(Irene Cara - What A Feeling )


Moon, Venus, Geminids, Fireball - Observation report

by hrjhrj 15 Dec 2008 14:47

Building the mount

After the successful "first light" through the telescope, I spent last week in frantically building the mount. It was an interesting exercise to calculate the height of the mount and then to purchase the plywood of the right thickness and size. I had to make so many iterations while drilling, fixing, aligning the wooden pieces that it's a big surprise that I did not suffer a major emotional breakdown.But, it has all paid off. The mount is functional, though, I admit, it is a bit rough to operate and intensely fugly to look at. It can only be operated by me, but hey, even the world's best observatories have a dedicated operator ;)

Dec 14th

With the telescope mostly functional I called up my ex-colleagues from Vayavya for a quick observation session. I called them up at 10.30pm and PS, Madhu and Gobi turned up instantaneously. The full moon would have been the bane of a regular observation session, but since my mirror is not coated yet, it was the only object I could aspire to, and it didn't fail us.

We took our turns admiring the moon, the telescope and the mount, in that order, and since all of them were first time observers, I got to give them a lot of golis (facts based on a fast lapsing memory).

We enjoyed looking at the Geminids which were quite frequent, even with the Moon sitting squarely inside Gemini.

At some point, I brought out my 10x50 binoculars, and we had a peek at the Orion Nebula. All else was hopelessly lost in the Moon + street light haze.

They left at around 12.30am, and it was then that an idea struck me; could I actually try some photography? All I had was a 3.2 megapixel mobile camera and a slow, uncoated mirror. But the results weren't all that bad:

Dec 15th

The next day evening I tried pointing the scope at Jupiter, and I had a rude shock. All I could see was an extremely distorted shape without any hint of any moons, and I spent quite some time in rechecking the focus and alignment. I was almost beginning to feel disheartened with the quality of the mirror, when I suddenly realized that I had been mistaking Venus for Jupiter. I quickly cross checked with KStars, and confirmed it. And then, it all made sense. I was looking at a very bright and crescent face of Venus and it looked great! (The real jupiter was almost setting on the horizon)

As if to share my cheer, a bright fireball appeared directly overhead and was visible for about 3-4 seconds.

All in all, these were great observation sessions! I can hardly wait to get the mirror coated and begin some serious observations.

tags: observation telescope

Wikipedia contributor : inductiveLoad

by hrjhrj 14 Dec 2008 16:26

It's amazing how much of their time people devote to contributing to open-source software and information.

I happened to see this superbly done map of our stellar neighbourhood, by inductiveLoad. It's a novel way to accurately represent 3d space. (novel to me, for sure)

Browsing over to his wikipedia profile, shows the immense amount of effort he has put in to this cause.


First Light

by hrjhrj 28 Nov 2008 09:11


Saw the first sight through my telescope, and it was brilliant!

I was able to get a working assembly of my scope late yesterday evening. But the weather yesterday was too bad and I couldn't see a thing.

This morning I got up early and did a quick test. At first I couldn't see a thing, but then realized that the collimation was really bad. After some quick adjustments I was able to get a decently good collimation, and then I pointed the scope around the neighbourhood, and boy! I was stunned by the quality of the result.

I could see a thin wire in the field of view, and it took me some moments to realise that this was an object in somebody's balcony in a far-away apartment!

Boy! Two years of grinding, polishing, planning, gashing, more planning, trips to SP road (in Bangalore), crying, planning, buying, sawing, phone-calls, visits to hardware stores, waiting, waiting…

And at last… the first view! I am feeling really triumphant today.

A lot of people to remember who helped me along the way, directly / indirectly:

  • Pavan. We started the grinding together
  • Vinay, who lended me some Red Rouge
  • Hemanth, for lending me a Sam Brown and a Robert something
  • Pratap, for the discussions on the mirror cell
  • Brahma, many more discussions on the mirror cell. We almost made one, but then I decided to buy this off the shelf.
  • ATM Group India (yahoo group)
  • ATM Orkut community
  • and finally BAS (for the inspiration)

Some details about the current configuration
8.5" diameter, uncoated mirror
72" focal length
25mm Ramsden eye piece, which gives me about 72x zoom
Badly collimated, precariously attached elliptical mirror.

tags: telescope