The Advisory Boar

By Abhijit Menon-Sen <>

Virtual hosting with Ejabberd


I have been running Ejabberd from the default Debian packages on for some time now, with just enough bells and whistles to serve my own rather modest needs. Recently, some friends asked me if I would serve Jabber for their domains too, and I was pleased to find that relatively easy to do.

Let's suppose I want to serve The first step is to add to the list of hostnames in ejabberd.cfg:

{hosts, ["", ""]}

Next, I have to restart Ejabberd to make it accept the new hostname.

Then I use ejabberdctl to register the new JID, while soothing irate users whose connection to the server was dropped during the previous step, and wishing that the server could just accept arbitrary hostnames in JIDs and do the necessary magic internally without needing to be restarted.

ejabberdctl register foo somepassword

Now the new user should be able to login to the server using their favourite Jabber client.

Finally, the following SRV records must be added to the zone in order to delegate XMPP/Jabber service to my server.      SRV 0 0 5222 SRV 0 0 5222 SRV 0 0 5269

Once the world can see these records, anyone trying to contact someone at will talk to my server (that is, unless it is an unpatched Net::XMPP client).

Halving a slice of pie


A few days ago, I bought a slice of Date and Apple Pie from Eatopia.

(Eatopia is a food court at the India Habitat Centre in New Delhi. It is noisy and crowded, but used to have a pretty good bakery. I haven't been there for some years, but Hassath and I happened to be in its vicinity, so we stopped in to pick up a sandwich, a croissant, and a slice of the pie that was once a particular favourite of my father's and mine.)

Hassath was going to eat the sandwich; the croissant was mine. The sandwich was larger, so I finished my croissant first, and was reaching for the pie when a thought struck me: where exactly should I bite it to get no more or less than my fair share?

The slice was too wide to fit in my mouth sideways, so I couldn't try to bite it in half lengthwise (precious crumbs!). I would have to approach this resource-sharing problem pointy-end first, and bite very carefully.

Thinking quickly, I simplified the pie slice to a circular section (assuming that it had uniform thickness, and giving up on the crusty outer edge). It was an eighth of the pie, so its area was πr²/8, and the angle at the vertex was π/4 radians. My fair share (ignoring, in the interests of simplicity, the fact that I clearly deserve a larger piece for forgoing the crust) would thus be an isosceles triangle with half that area; and its height is what I needed to determine.

The area of an isosceles triangle with height l and base d is l×d/2. We know that is equal to half of πr²/8; and we can also express d as 2l×tan(&pi/8), π/8 being half of the central angle. Thus 2l²×tan(π/8) equals πr²/8, and so l is the square root of πr²/(16×tan(π/8)); in other words, l is r times some constant, which suits us fine.

tan(π/8) gave me a bit of pause, before I remembered that π/4 was a more tractable angle, and tan(θ) equals sin(2θ)/1+cos(2θ). sin(π/4) and cos(π/4) are both equal to 1/√2, so the required tangent is √2−1 ≅ 0.4142. Losing patience, I simplified progressively: 0.4 times 16 is 6.4, which is about twice π, so l ≅ r/√2 ≅ 0.7r. I stuffed the pie into my mouth and bit off a piece that looked about right.

So much for applied math. The pie was awful.

(After I'd finished eating, I realised—looking at the remaining piece—that I had incorrectly assumed that my bite mark would be a straight line. If, instead, I had incorrectly assumed that it would be a section of a circle concentric to the outer edge, I could have saved myself some trigonometry and the answer would have been exactly r/√2. But the pie wouldn't have tasted any better for it.)

The Hour of the Furnaces


What does this mean?, asked Hassath, pointing to «La Hora de los Hornos» in an article about documentary films.

The hour of the… something.


And just like that, a flood of memories swept me twenty years back in time to the Argentinian pampas, which I had experienced time and again through Gerald Durrell's marvellous writings. I remembered the story of a tough gaucho moved to tears as he recounted how he—in a moment of uncharacteristic sentimentality—rescued a small bird whose leg was stuck in the wet clay with which it was building its nest. The bird, once freed, perched a few feet away and poured its heart out in song, as if to thank the enraptured cowboy.

The bird's name, Hornero, was what triggered a memory so vivid that, just for an instant, I could almost smell the clay and feel a dry, dusty wind stinging my cheek. Horneros, named for the resemblance of their round clay nest to a horno, an old wood-fired oven. Ovenbirds.

Furnaces. That's it. The Hour of the Furnaces.

The Hour of the Furnaces is a 1968 documentary by Fernando Solanas and Octavio Getino about the struggle against neo-colonialism in Argentina. The title quotes Che Guevara who, in turn, was quoting the nineteenth-century Cuban revolutionary leader and poet José Marti: "Now is the time of the furnaces, and only light should be seen." The film is in three parts, and is 260 minutes long. Hassath, who has seen it, recommends it highly.

My treasured collection of Gerald Durrell's books is long gone, given away over the years; and now, I have a film to watch that will teach me very different things about Argentina. But it will also always remind me of a small brown bird celebrating its freedom with a song.

Second thoughts about the Simvalley PICO RX-80


After a few weeks of using the phone, I'm less thrilled than I was at first.

To begin with, the battery life is nowhere near the claimed 90 minutes of talk time and 100 hours of standby (which would have worked well for me, since I don't make many calls). A full battery lasts almost 48 hours with minimal use (messages only), but using the phone, even if it's mostly for messages, always drains the battery in less than a day. The display flickers occasionally, which may or may not be related.

The audio quality sounds fine to me, except that what I hear is mostly complaints about excessive feedback (i.e., callers hear their own voice after a delay). I don't know why it happens, but it's unpleasant.

When sending messages (which I do more often than making phone calls), it's annoying to always have to switch from the default German input mode, and the lack of a sensible English dictionary also rankles. In practice, I'm forced to type in "triple-click" mode most of the time. The keyboard, though very nice to use, is a trifle too noisy for my taste (enough to make people nearby look up).

Aside: the phone does seem faster at sending messages than any other I've used, but I can't imagine why or how that might be, and I'm not certain that it isn't an interface effect. It's also nice that you can cancel the sending—if you can hit the red button quickly enough.

One bug that does nothing more than amuse me: if you select "unlock" when the keypad is locked, it says «Press '#' \nkey» (i.e., the two literal characters \n, not a linefeed).

All told, the problems outweigh the advantages of having an extremely small phone. I'll try to get my old Nokia's screen replaced, and keep the RX-80 as a backup.

On applying for a US visa from Delhi


Speaking of renewing passports and the horrors of international travel, 1999 was also the last time I applied for a US visa (and, I hope, the last time I'll ever need to).

On that occasion, I queued up at dawn (behind a hundred-odd people!) and was denied a visa many hours later because I didn't have "strong enough ties" to my country. When I needed to travel to Europe some years later, most embassies took one look at the US "application received" stamp in my passport and matched it with one of their own ("application received" sounds innocuous, but it might as well say "VISA FAIL"). It took a long time to get that sorted out.

Things have changed a lot since then. Hassath, who wanted to attend the Grace Hopper Conference this year, investigated the process. A few years ago, the embassy outsourced the initial paperwork, which is now done online. The dawn queue is also gone: the web site displays an appointment schedule, and you can book a convenient free slot and turn up at the embassy at that time. But one of the biggest changes is in the handling of the application fee.

When I applied, the non-refundable visa application fee was some INR1200 (about USD25). Now the fee is USD131 at the "consular exchange rate" of INR50/USD (which conveniently favours the USD by about INR3/USD), which makes it INR6550. That is a substantial portion (>70%) of a month's rent for us. If money is important to you, as casually puts it, you will be happy to learn that

Nonimmigrant visa fees are based on "reciprocity," (what another country charges a United States citizen for a similar-type of visa). The United States strives to eliminate visa issuance fees whenever possible; […but…] you need to understand the distinction between a visa "issuance" fee and a visa "application" fee. Most non-diplomatic and non-official visas issued by United States consular officers abroad require a visa "application" (machine-readable visa - MRV) fee that recovers for the United States the costs associated with manufacturing, processing, and printing the visa. The current visa "application" fee is $131.00.

I had to pay the fee by demand draft at the embassy, but now one has to pay it (plus the INR374 service charge for VFS, the company that handles the online application process) at any of about a dozen select branches of the HDFC bank and obtain a receipt before you can book an appointment online. If you find that no appointments are available before you travel, you lose the money. If you misplace the receipt, you lose the money. If you manage to apply and are denied a visa, you lose the money (but perhaps the distinction between "issuance" and "application" fees will be a source of comfort, if money is important to you).

You still need to produce scads of personal and financial information (for example, tax returns and bank statements for the past few years), of course, but much more thought has been put into the rules for the visa photo. "Passport-sized" used to be a sufficient description, but now there is a special size (larger than anyone else asks for), and a number of rules to spell out what is expected of the background, foreground, clothing, and direction of the applicant's gaze. Everyone is fingerprinted these days, so you are also instructed to arrive for your appointment with clean hands.

For people who are refused a visa, the embassy now has this helpful page that begins with the heart-wrenching tale of Sanjay and Anil—friends who will not see each other because one could not obtain a visa to visit the US. It has soothing answers to a number of questions the distressed applicant may have.

Q. Why is there a visa requirement?
A. The U.S. is an open society. […]
Our immigration law requires consular officers to view every visa applicant as an intending immigrant until the applicant proves otherwise.

Ten years ago, the Consular Officer helpfully told me at the end of my visa interview that I would have to wait three days before I could apply again, but I have somehow contained my enthusiasm to reapply ever since. Based on the current application process, I think I can hold out a while longer.

Renewing my passport


Ten years ago, I renewed the passport I got before I visited my father at Cambridge when I was eight years old. I remember standing in a queue for four hours before finally being told that I was in the wrong place. I switched queues, but the second counter closed before I reached it, and I had to go back and queue up again the next day.

That passport expired earlier this year, and I dreaded every aspect of applying for renewal. But, thanks to a Hassath who also needed to renew her passport, I finally got around to filling in the forms and going to the Regional Passport Office behind the Hyatt Regency hotel in RK Puram. (We filled in our forms together, but it later turned out that Hassath needed a different form and had to join a different queue, while I was in the bog-standard general category for renewal.)

One major difference today is that you have to queue up outside to get a "token number" stamped on your application form by a counter at the rear of the building. The applications are then processed by counters inside the office in token sequence, and the current token at each counter is displayed on electronic displays both inside and outside the building. This helps to reduce queueing time, since the first counter only needs to stamp a number on the form, and people don't need to go inside until their timetoken is nigh.

I arrived about an hour before the token counter opened at 0930. There were some twenty people in line before me. I got my token (#17) by 1000, then joined a very long queue of people waiting on the sidewalk to get inside the office when it opened at 1030. This queue (which was the only one in 1999) also drained very rapidly, because everyone just piled in when the gates opened (the guard needing to check only for a stamped form before letting people in).

While waiting inside, I realised that a lot of people don't understand the token system. For one thing, the display boards are not cleared at the beginning of the day, so they display some confusingly large numbers (451) from the day before… but also some small numbers (35) which are harder to distinguish from current numbers. Besides, parts of each display don't work, and there are still always some people who try to submit their application out of sequence. I overheard someone saying You have to watch the display. Any number could come up at any moment, and you have to rush to the counter when yours does. (translating from Hindi).

The confusion helped me: several people missed their turn at a counter, and #17 came up much sooner than I had expected. It took only a few more minutes to submit my application, have the old passport cancelled (and returned), and pay for the renewal. I got a receipt that says I can send an SMS (but only during business hours!) with "PPT file-number" to 57272 to track the status of my application.

The application form for renewal was also quite easy to fill in (though a separate "personal particulars" form must be filled in duplicate), and one needs to produce only a few documents to support it (in my case, my PAN card, a phone bill, and my old passport). While waiting in line at the passport office, I was pleasantly surprised to learn that it's even possible to apply online: you fill in the form, get a custom-generated PDF, and can submit it—without a token—at a separate counter.

Now I have to wait for the police enquiry (to verify my address and the "I'm not a criminal" check-boxes I ticked on the form). Let's see how long that takes.

Update (2009-11-04): I received my passport today, but the story continues.

Updating last-modified dates with a git hook


I wrote a git post-commit hook that looks at certain files in my repository whenever I change them, edits them a bit if it wants to, and commits any changes it made. The changes it makes are not very interesting, but such a hook could, for example, be used to maintain "Last modified: ..." lines in static HTML files as shown below.

Let's say we want to update all foo/*.html files that contain something like the following line:

<div class=lastmod>Last modified: ...</div>

The idea is simple: use git diff --name-only HEAD^ HEAD to get a list of the files that were changed by the last commit, pick the ones we're interested in, edit them using sed, and commit any changes we make.

Read more…

What is Nehru Place?


A few people have asked me about Nehru Place, which always features prominently in my adventures with hardware. There's a Wikipedia entry, but—although it makes a feeble effort—it's much too dry to communicate the flavour of a place where you can find, next to an "authorised HP distributor", a chap with syringes full of coloured ink who will refill your printer cartridges for a small fee.

Nehru Place is a large commercial area in South Delhi. The core of the marketplace is spread across a number of four-storeyed buildings about thirty years old, but businesses have expanded outwards into newer and taller buildings. A number of companies have offices here, but the area is best known for being India's largest (or so I hear) marketplace for computer hardware.

There is a tremendous variety of shops. Swanky laptop showrooms with mood lighting rub shoulders with stores selling second-hand hardware, stationery shops, food stalls, people selling cheap T-shirts off the pavement, high-quality printing shops, and shops of varying size that sell all kinds of components, optionally assembling them into computers on the spot. Space is at a premium, so hardware is stacked ceiling-high everywhere. The larger stores usually keep the bulk of their inventory in some basement or somewhere on the seventh floor of a building you didn't know existed, and will order it for you on demand.

If they don't have something you want, they'll find someone who does, because everyone is connected through an internal telephone network, and shops have gophers who are regularly dispatched to pick up or deliver some item to each other. Everyone has a pocket calculator to quickly add their cut to the price they get on the phone without your seeing the numbers… and the prices for a component can vary widely, depending on where you ask, and how much effort you're willing to put into surveying the options. Visiting the market without a clear idea of what you want (and a checklist to keep track of all the prices) is just asking for trouble.

Nehru Place has also changed a lot in the past ten years. I remember a time when there was someone offering to sell me porn at every corner, but these days it's only pirated CDs ("software! games! movies!"). There are many more women buying hardware than there used to be even a few years ago, and more foreign tourists looking for cheap hardware. The older buildings are still fire-safety nightmares with exposed cabling and dilapidated elevators, but the newer ones are all shiny glass and steel with central airconditioning and CCTV surveillance.

There was once even a token effort towards access for disabled people, but it was restricted to building ramps beside the stairs in the central courtyard. (While this was happening, Rai and I almost stumbled into the first attempt: a sixty-degree slope with a deep open pit at its foot; we can't find the photographs we took, but that pit just about sums up the whole effort.)

Nehru Place also features an Udipi restaurant (among many other shops that sell a variety of fast foods) that serves the most excellent kachoris I have ever eaten.

Celebrity security ordeals


I'm tired of hearing people getting worked up about the "demeaning and humiliating" treatment that some celebrity or the other occasionally suffers at the hands of airport (or other) security personnel, because they usually demand more respect for important people, or fewer complaints from them.

Two recent examples: former Indian president A.P.J. Abdul Kalam being frisked before boarding a Continental Airlines flight bound for Newark despite his VVIP status exempting him from security checks, which provoked outrage and demands to ban the airlines in Parliament; and actor Shah Rukh Khan being detained for a couple of hours on arrival at Newark airport, which at first made him not want to "set foot on US soil again", but which he later said was "nothing" compared to what Kalam had faced.

Some people have written in to newspapers saying that celebrities should be treated like everyone else and that they shouldn't object to security procedures. I agree with the first part, but I vehemently disagree that security procedures should be accepted by all as a fait accompli. Nobody should be subjected to the humiliating and farcical "security theater" that international travel has devolved into these days.

Until then, however, perhaps it would be best if celebrities were treated especially poorly at airports, considering how much more media attention their complaints attract.

As an aside, I liked this letter to the Editor of The Hindu from J. Victor Rajasekaran of Chennai.

The Newark incident was undoubtedly a matter of humiliation for SRK and a rude shock for lakhs of Indians. The Americans and other westerners are clearly racial [sic].
How prejudiced the westerners are! They should learn a lesson or two from us. Look at the way we treat our fellow citizens. Look, for instance, at the case of the Dalit youth who was beaten up on Thursday in Tamil Nadu by caste Hindus for riding a bicycle. Let us feel proud to be Indians.

Fighting the fixers: thermal paste edition


While cleaning accumulated dust out of Hassath's Athlon64 heatsink the other day (to silence an overheating alarm), I accidentally lifted the heatsink off the CPU and broke the layer of thermal paste. After that, of course, the machine refused to boot at all, emitting a loud siren-like wail at startup.

I didn't have any thermal paste handy, so it was off to Nehru Place yet again. I decided to look for someone who would remove the heatsink and apply the paste for me, because I'd never worked with a spring-clipped heatsink before (I thought it was just a matter of applying more force to remove it than I had, but I wasn't sure).

The "customer-facing" parts of Nehru Place are often quite clueless. The people who know how to fix things live in cramped little cubicles inside the seediest buildings and basements. The showrooms send computers (not customers!) down to them, and they fix them and send them back upstairs to feel the sunlight once again. I could probably have left the computer with any shop, told them it doesn't work, and asked them to get it fixed. But I was in a hurry and I knew exactly what I wanted, which always makes things more difficult.

Unfortunately, I don't know any competent fixers; but I do know someone who's good at finding hardware, and I know his shop (also in a basement) does assemble and fix machines. I started there, but my clueful friend wasn't around. I introduced myself to his minions (there were two of them, let's call them Sixteen and Twenty-five) and explained that my CPU was overheating, and needed some thermal paste reapplied.

Read more…