< October 2006 >
1 2 3 4 5 6 7
8 91011121314
Mon, 30 Oct 2006:

Last thursday night, the last Karanavar of my family joined his ancestors. He was a teacher by profession and a painter by persuasion - a professor of zoology and a painter of landscapes. Even after retiring, he was one of the founders of the ICS entrance coaching centre in Cochin and continued teaching. I've never sat in one of his classes, but he was a teacher to me and much more.

As a young boy, I used to gravitate towards his house. The first and primary reason was that there was a fridge (where fridges and grandparents meet, there is a likelihood of icecream). But what kept me hanging around was his VCR (also the first one in the neighbourhood). Eventually having run out of Mickey Mouse cartoons to watch, I would end up watching his collections of nature documentaries. I used to while away entire afternoons, watching some of the best documentaries BBC has ever produced. If I've acquired some sense of admiration for nature, it starts from those happy days in the eighties.

And then there was his workshop. He used to play around with electronics (when he was 60+) and one of the first things I saw built was a water level detector for the water tank. Eventually, every house around wanted one of these - encased in old transistor case, hooked up to its speakers to wail out when the water got too full in the tank (while pumping it). For the first time in my life, technology was cool.

Some of his work

He was a stickler to healthy living, a strict schedule and regular exercise. Sunrise would find him in the temple, even though he wasn't a blind believer in God. He was an epitome of health, having never suffered from diabetes or blood pressure disorders, which were common in his contemporaries. But then cancer struck its blow. He survived the first onslaught, went under the knife and managed to fight it without chemotherapy. It was not be, here was a secondary, that too in his vertebra.

But he still had his legendary nerves of steel. When I visited him a week back, pressure on his spinal cord had cost him use of both his legs. But as I was talking to him, he launched himself into a lecture about the human anatomy and how the hip bears the load of the whole body. What took me by surprise was the obvious conclusion - he will never be able to sit upright, not even in a wheel chair. I haven't met too many who could talk so lightly of their own fate.

No matter how many times it happens, it never gets any easier to lose someone. But eventually, you've got to reconcile yourself to carrying a little bit of them inside yourself.

And then, as I helped my uncles lift him to his funeral pyre, the thought came unbidden - Goodbye ... for now.

The Way of the warrior is resolute acceptance of death.
                -- Miyamoto Musashi

posted at: 19:08 | path: /me | permalink | Tags: , ,

Fri, 27 Oct 2006:

Once upon a time, in the cold December of 2004, there was a blog post. I read it, thought about it a lot and eventually made a decision.

All that's now history - friday was swaroop's last day at Yahoo! bangalore.

With that, it looks like I know more ex-Yahoos than those in office ... [-).

A good compromise leaves everyone mad.
                  -- Calvin

posted at: 01:52 | path: /yblr | permalink | Tags: , ,

Wed, 25 Oct 2006:

Weak symbols are a poor man's version of linker land polymorphism. A weak symbol can be overriden by a strong symbol when a linker loads an executable or shared object. But in the absence of a strong sym, the weak version is used without any errors. And that's how it has worked for a long long time in ELF binary land.

But then dlopen() went and changed the rules. When you load a shared library with RTLD_GLOBAL, the symbols became available to all the other shared objects. And the libc rtld.c had the runtime magic required to make this happen (and the unloading was even harder).

Then one fine day, Weak Symbols were empowered. In dynamic shared objects (DSO), there was no difference between weak and strong. It has been so since the glibc-2.1.91 release.

Now let me backtrack to my original problem. Once upon a time, there was a php extension which used an apache function, ap_table_set() to be precise. But for the same php extension to be loadable (though not necessarily useful) inside a php command line executable - the external symbol had to be resolved. That's where a weak symbol proves itself invaluable - a libapstubs.a could be created with a weak ap_table_set, so that as long as the extension is run outside apache, the stub function will get called.

But it wasn't working on linux (works on FreeBSD). And except for the extension, we weren't able to write a single test case which would show the problem. And then I ran into a neat little env variable - LD_DYNAMIC_WEAK. Just set it to 1 and the rtld relegates the weak symbols back into the shadows of the strong ones. But that raised a few other problems elsewhere and I personally was lost.

But now I know where exactly this went wrong. Php was using a glibc dl flag called RTLD_DEEPBIND (introduced in zend.h,1.270). This seems to be a glibc feature and the flag bit is ignored by the FreeBSD libc - which was running the php module happily. As you can read in that mail, it looks up the local shared object before it starts looking in the global scope. Since libapstubs was a static .a object, the local scope of the ext .so did contain the dummy ap_table_set() and since glibc rltd was ignoring the weak flags, that function was called instead of the real apache one.

I'm perfectly aware that RTLD_DEEPBIND can save a large amount of lookup time for shared objects built with -fPIC, because of the PLT (we've met before). But if you are trying to use it to load random binaries (like extension modules), here's a gotcha you need to remember.

Now to get back to doing some real work :)

A wise person makes his own decisions, a weak one obeys public opinion.

posted at: 17:12 | path: /php | permalink | Tags: , ,

Sat, 21 Oct 2006:

A Buffet Intellectual is a less disparaging term than the more cynical pseudo intellectual, which has seen far more use than required. The term does not make any kicks about the actual intellectual's ability, but in the dilettante attitude of the individual. The random samplings of life that such a person goes through leaves him (or her) a veritable gold mine of random conversations but very little to seek them out for.

To identify a buffet intellectual is very easy - just start talking about something in the abstract and watch the classical allusions roll by. But the easiest way is, of course, to peek into the bookshelf. In the midst of all the professional books, you'll find books about Evolution and Dinosaurs. Or half a shelf of books about Quantum Physics and the Universe. Look more closely and you'll even find books about Economics and Social orders. Heck, you may even find a couple of books about Human Psychology.

A nibble here, a nibble there and not a mouthful anywhere. Such intellectual butterflys are curiousities who rarely achieve anything by such half-hearted dabbling. What is needed is focus and perseverance - not two days' worth of everything.

Curiosity killed the cat.

posted at: 16:04 | path: /me | permalink | Tags: ,

Wed, 18 Oct 2006:

Flockr generates digraphs out of your flickr contacts. This is what has triggered me to go off the straight & narrow path of low level programming into hacks with Graph networks and x-mixed-replace. Anyway, what is done is done - take a look at a canned demo if you are on Firefox 1.5 and above (can't host cgi scripts).

The really hard part of the above code comes out of the simple fact that HTML Canvas is totally pixel based. You cannot attach an event to a small circle drawn as lines & figures. The code inside graph.js has a class called NodeHandler which sort of implements event masks and handlers for a node I've drawn on canvas. The code uses a hashed bucket to determine which all nodes it needs to iterate over, rather than loop over every node in the graph for every mouse move - harsh lessons learnt from dotgnu's winforms. It works better than I'd expected of Javascript and certainly seems snappy enough.

Now, I'm off hacks for a while ... time to vent some energy on real code.

An empty canvas has more potential for greatness than any painting.

posted at: 11:12 | path: /hacks | permalink | Tags: , ,

The LCA submissions have been rated, reviewed and the letters sent out. And it shouldn't come as a very big surprise that my talk hasn't been selected - here's to all those who said "Yeah right, save your talks for real conferences". I can't honestly say that I'm not disappointed, mainly because there is no point in talking about libjit in 2008 - it would have crossed over the bump into old & busted. And I'm definitely not going to submit a talk to conference which I haven't attended - I'm too fragile to go through an audience mismatch again.

But on the other hand, it is a testament to the quality of conference. if my talks aren't good enough, that sure is a conference which I shouldn't miss - which brings me to the real reason why I'm depressed right now.

My LCA 2006 trip in total cost around 1.4 Lakhs (~3200 USD) - of which dotgnu chipped in 1700 USD, Yahoo! chipped in 600 USD and I pulled the rest of the ~1000 USD. But this year, I see no reason for DotGNU to pay anything, because most of my efforts have gone into APC rather than the usual creative energy vented out on dotgnu. Since I have switched teams & manager, I think Yahoo! will wash hands clean, especially after what happened to spo0nman.

Since I'm not getting a raise this year, despite complaints, I don't think I can build a slush fund to fulfil the extra ~2000 USD (7 months' savings) - but even for the 1000 USD part, I'll probably have to give up a few luxuries. There's a bit of me that says I should be more optimistic, but deep inside me I know why I'm not.

Disappointment leaves a scar which ultimate fulfillment never entirely removes.
                      -- Thomas Hardy

posted at: 08:42 | path: /conferences | permalink | Tags: , ,

Tue, 17 Oct 2006:

For the entire weekend and a bit of Monday, I've been tweaking my di-graphs to represent flickr entries and in general, that has produced some amazing results. For example, I have 700+ people in a Contact of a Contact relationship and nearly 13,000 people in the next level of connectivity. But in particular, I was analyzing for cliques in the graph - a completely connected subgraph in which every node is connected to every other. For example, me, spo0nman, premshree and teemus was the first clique the system identified (*duh!*).

Initially, I had dug my trusty Sedgewick to lookup graph algorithms and quickly lost myself in boost::graph land. STL is not something I enjoy doing - this was getting more and more about my lack of const somewhere rather than real algorithms. And then I ran into NetworkX in python.

NetworkX is an amazingly library - very efficient and very well written. The library uses raw python structures as input and output and is not wrapped over with classes or anything else like that. The real reasons for this came up as I started using python properly rather than rewrite my C++ code in python syntax. When I was done, I was much more than impressed with the language than the library itself. Here are a few snippets of code which any C programmer should read twice :)

def fill_nodes(graph, id, contacts):
    nodes = [v.id for v in contacts]
    edges = [(id, v.id) for v in contacts]

def color_node(graph):
    global cmap
    node_colours = map(
                lambda x: cmap[graph.degree(x) % cmap.length], 

Or one of the more difficult operations, deleting unwanted nodes from a graph.

# trim stray nodes
def one_way_ride(graph):
    deleted_nodes = filter(
                 lambda x: graph.degree(x) == 1,
    deleted_edges = filter(
                 lambda x: graph.degree(x[0]) == 1 or
                 graph.degree(x[1]) == 1, 

The sheer fluidity of the lambda forms are amazing and I'm getting a hang of this style of thinking. And because I was doing it in python, it was relatively easy to create a cache for the ws requests with cPickle. Anyway, after fetching all the data and all this computation, I managed to layout the graph and represent it interactively, in the process forgetting about clique analysis, but that's a whole different blog entry anyway.

The worst cliques are those which consist of one man.
                -- G. B. Shaw

posted at: 07:44 | path: /hacks | permalink | Tags: , ,

Mon, 16 Oct 2006:

I've been playing around with some stuff over the weekend, which eventhough runs in a browser, needs continous updates of data while maintaining state. So I tried to a socket-hungry version of server push which has been called COMET. Now, this technique has come into my notice because of a hack which bluesmoon did, except I had to reinvent for python what CGI.pm did for bluesmoon by default.

But first, I mixed over a couple of the client side bits. Instead of relying on XHR requests, which are all bound & gagged by the security model, I switched to a simpler cross-domain IFRAME. But what's really cool here is that I use a single request to push all my data through, in stages, maintaining state. So here's a bit of code, with technical monstrosity hidden away.


import sys,time

from comet import MixedReplaceResponse

content = "<html><body><h1>Entry %d</h1></body></html>";

req = new MixedReplaceResponse()

for i in range(0,10):
	req.write(content % i)


The MixedReplaceResponse is a small python class which you can download - comet.py. But the true beauty of this comes into picture only when you put some scripting code in what you send. For example here's a snippet from my iframe cgi code.

wrapper = """
   <html><body> <script>  if(window.parent) {
	} </script></body></html>

script = ("window.parent.updateView(%s);" % json.write(data))

req.write(wrapper % script)

As you can clearly see, this is only a minor modification of the json requests which I'd been playing with. But underneath the hood, on the server side, this is a totally different beast, totally socket hungry and does not scale in the apache cgi model. Interesting experiment nonetheless.

Now, if only I could actually host a cgi somewhere ...

To see a need and wait to be asked, is to already refuse.

posted at: 09:12 | path: /hacks | permalink | Tags: , ,

The first shortlist of talks for FOSS.in/2006 is out. Let me be the first to say that there are a couple of surprises there. First and very surprising one would be a talk by none other than spo0nman himself. Second was botsie talking about Gentoo - not about XFCE. Yet another, sort of surprise, with bluesmoon about libyahoo2 - I suppose he can indeed talk about it, though not commit stuff ?

And then, a few names were obvious by their absence. I don't see a talk by KingDiamond or BigBeard - And kryptic too is missing, which was probably not as much of a surprise (*click* *click*).

The talks list seems a bit biased towards the kernel/library/OS land and a little left of the eyecandy section, but I'm sure that is probably not a real problem. Just make sure one of the computers around is running Beryl with the keyboard on a recorded cycle with xsendkey.

I like the word "indolence", makes my laziness seem classy.
            -- Bern Williams

posted at: 01:53 | path: /conferences | permalink | Tags: ,

Sat, 14 Oct 2006:

After climber over enough mountains, I'm now planning to take a dip & see some corals. Current plan involves a week in Lakshadweep in mid/early November - seems to be a good time to visit, the sunshine shouldn't be too hot and the weather mild. I am planning a single week trip with the weekends to take the slack of the trip. December is actually when the circuit gets really really expensive - which puts this in a nice bracket.

The current budget is about 15-17k INR (which should basically take care of November's paycheck). Current plan is to take a helicopter one-way from Lakshadweep and the other way on the boat - as far as possible on the budget. Current plans involve taking the MV Tipu Sultan which plies between Cochin and the islands (3,400 INR). The helicopter ride is a lot more expensive and costs (7,400 INR).

The only airport in Lakshadweep is on the Agatti island, which is a pretty awesome coral formation. Here's how it looks from Google Earth at maximum magnification - the straight dark strip is the airport. But as far as I can understand, there is only room for one hotel on the island - the Agatti Island Beach Resort which looks to be more than slightly on the expensive side.

After the point-to-point travel, there's a maximum 6,000 INR to do the sightseeing + stay in the islands. So that obviously rules out the expensive hotels (2000+) for more than a single night.

Totally I have 5 islands to hit: Agatti, Kadmat, Bangaram, Minicoy and Kavaratti. Three of them come up in the standard "Coral Reef" tour package and now I've got to find out how to visit the other two (one of them is uninhabited wilderness).

So far the trip plan is not totally set in stone - I'm still debating the possibility of taking a tour package instead of planning out my own trip. Either way, I want that helicopter trip over to Agatti, if not from Cochin, then from somewhere else.

So, if anybody's interested in pooling along with me, please let me know. A group of 4 will be ideal to get at least a few discounts along the way (heh, did I mention that people speak Malayalam in Lakshadweep ?).

And if someone had any advice, that'd be even more than welcome. Leave a comment here, I'll be watching.

A good traveler has no fixed plans, and is not intent on arriving.
                -- Lao Tzu

posted at: 05:55 | path: /misc | permalink | Tags: ,

Fri, 13 Oct 2006:

I was battling with some code that used instanceof() in python. I don't where that's a built-in (I suspect jython), but it doesn't work on my python 2.4.3. While I was wondering about this problem, I tried something outlandish and it worked. But before I actually explain what I did, take a closer look at this module (x.py).

def identity(h):
    return h

def coolfunc(p):
    return identity(p)

That was pretty standard code, right ? Now, to use/abuse this module in y.py.

import x

print x.coolfunc("Hello World !")

x.identity = lambda x : 42;

print x.coolfunc("What is 21 + 21 ?")

As you can probably guess, I can override (uhh.., pollute) x.identity with my own functions, which opens up a solution to my original problem. Pretty simple, now that I think of it.

othermodule.instanceof = lambda x,y : type(x) == y

I hope this has made your friday a little bit more surreal :)

Talent to endure stems from the ignorance of alternatives.

posted at: 10:42 | path: /hacks | permalink | Tags: ,

Found this in one of the mailing lists - but this is total fnuk. Please feel free to click on any of the following links - yahoo shit and google shit. Please take a look at your title bar of your browser to understand the true beauty of bi-directional font-rendering :)

I'm sure xoferiF wouldn't violate any trademarks by the Mozilla foundation.

Drawing on my fine command of language, I said nothing.

posted at: 05:30 | path: /fun | permalink | Tags: , ,

I remember the last one very vividly.

No amount of careful planning will ever replace dumb luck.

posted at: 04:20 | path: /fun | permalink | Tags: ,

Thu, 12 Oct 2006:

I finally got my camera repaired. It cost a whopping 6,800 INR to replace the cracked LCD and backlight-panel - I could've bought a brand new camera for a little more, but I liked to get back my original camera. Some of the pictures I've taken with it while it was broken were good, but I saw the difference when I had the full LCD screen and all the visual controls set. Here's a sampler from my train ride on monday.

Amazing photographs and some of my best pictures of Kerala so far. The weather is more to credit than my camera though - a calm, quiet morning after a stormy night, blue skies and all.

There is one advantage to having nothing, it never needs repair.
                                -- Frank A. Clark

posted at: 00:34 | path: /hardware | permalink | Tags: ,

Wed, 11 Oct 2006:

Last year, Atul had coined a phrase, "The Guru Shishya Syndrome", in a mail to the list. The year has passed us by and now in one of the recent posts, he has had to re-hash it, only with a little bit more sting in its tail (Crikey !). And I say that probably because it touches a few raw nerves - something which was probably more my fault than Atul's. But just so that you know what I'm talking about, let me re-quote that entry with my inherent biases and emphasis added.

For example, if you are involved in a FOSS project and have solved
a problem in that area that helped the project improve its performance,

stop believing that your contribution was too small to talk about, 
stop believing that your "overlords" in the headoffice in the USA
are the only ones who can think. 

I don't have a talk proposal for FOSS.in/2006. I had been vacillating about giving a podium talk for a while - I'd rather talk with a 10-15 member group than "to" 45. But eventually, I didn't have to make the decision. On Sunday as the deadline approached, I was sitting at a close relative's bedside, in Cochin hospital. But even without that twist of fate, I wouldn't have been talking about APC or giving a generic dotgnu talk. But before I go into the reasons for such unreasonable behavior, let me digress into some other territory.

'Jool Noret' effect: To give you some context, this is a character from one my favourite fantasy books - Dune. An excellent fighter who spent a life time achieving perfection with melee weapons. But what sticks in your mind, while you read about this character, lost in all that drama, is his philosophy - "I have so much left to learn, to start teaching".

And as I've previously blogged about, shining a light into the darkness of your ignorance only serves to highlight the shadows cast. In essence, what makes me good (IMHO) is what prevents me from stopping the journey to evangelize or pick laurels.

And even if I had actually gotten time on saturday or sunday - I wouldn't have submitted an APC: Maximizing Throughputness talk, I would've talked about something new, fresh & risky - something like Scripting your Application or probably about using lua or python to script your events and build plugins in (like this). Last year, I did a talk on Firefox: Plug it in - and I'd never written a single firefox extension till the talk schedule was out. But that was a good talk, because I understood and tackled a lot of the problems a newbie faces while writing their first extension. Compared to that, my contributor talk on dotgnu had a definite So On & So Forth feel to it.

I can't afford to experiment with topics or technology at say, LCA (here's why). For my LCA talk proposal, I'm actually planning to write a minimal basic-block JIT for PHP to show off libjit, but that's not quite pushing the boundaries for my personal knowledge - it is more of use than explore. FOSS.in, on the other hand, is as close to a home ground as it gets. That gives me a bit more confidence to do something which I'm not already an expert in. Rather than rehash what I already know, I'd like to pick up something new and run with it.

I'm quite aware that this is completely at cross-purposes with what a conference organizer would obviously want. Rather than have me skim the surface of a new topic, they'd want me to go deep and technical in something I'm really good at. But that sort of expert speak works only with a lot of audience involvement which just does not happen in a group of 50+ (hardly even in groups of 20). Bouncing ideas off others requires that you shouldn't need to wait for someone to shut up before you speak.

So all in all, I'd rather do a BoF with 20-odd people and end up with a new idea, than go the Attention Class! route that the podium talks force me to. If I didn't submit a talk, it had nothing to do with any bigshot from the US headoffice, but with fate keeping me offline on the weekend.

I didn't decide. It was decided for me.

If you understand what you're doing, you're not learning anything.
                -- A. L.

posted at: 11:11 | path: /rants | permalink | Tags: , ,

Sat, 07 Oct 2006:

One of the first cool things I saw in flickr was notes. They're those small boxes which you can drag across a picture to mark off a region or add some more context to something. When I recently started linking in flickr photos to my blog, these were some things I missed. Without a small box saying "That thin line is the road", a few of the more impressive photographs I'd got were quite ordinary landscapes.

While looking at the new flickr apis - especially the JSON apis, something clicked somewhere. Finally, there seemed to be a very nice way to do cross-domain requests from my blog (or literally any web-page) to flickr to read notes, tags and other information. Minimilastically, this is what my code does :

function myMethod(data) 

var photos_get_info = "http://api.flickr.com/services/rest/?"
        + "method=flickr.photos.getInfo&api_key="+api_key
        + "&format=json&jsoncallback=myMethod"
        + "&photo_id=" + photo_id + "&secret="+secret;

/* cross-domain request */
(function(url) {
	var _s = document.createElement("script");
	_s.src = url;

The photo_id and secret are the two parts in a flickr image url, the first part is the id and the second the secret. Provided you've given valid data there, flickr will respond to your data load with something like the following data.

myMethod({"photo" : .... , "stat" : "ok" });

Which when interpreted by the browser, magically seems to call your callback myMethod. Isn't that beautiful or what ? Of course, this workaround is not necessarily new information for me - but pretty damn convenient. Either way, once you've got the cross-domain data, it is only a few steps away from taking that data and displaying it.

Take a closer look at the ugly javascript if you want, or just look at the pretty pictures or funny pictures or even your own pictures.

Actually, more than being able to embed notes in my blog, this has brought along an unexpected advantage. With this script, the flickr notes are scaled according to the picture, so that you can have notes for a large or original size picture. Maybe I should make this a GM script so that I can do the same in flickr's zoom.gne pages.

Either way, the fun ends here.

It's difficult to see the picture when you are inside the frame.

posted at: 04:20 | path: /hacks | permalink | Tags: , , ,