## Big-endianness and LTR

When I see a large number without thousandths-separators, it takes me a while to figure out the scale of the number. For example, I see 1433344557 and wonder, is it 1.4 billion, 143 million, or what?

I go slow when mentally adding commas going backwards from the last digit, because it's unnatural for me to read right to left. So I do this instead: I scan forwards (left to right), mentally checking off groups of three digits, and when I reach the end, I see how many digits were left over, and jump back to the beginning of the number and make the call.

So I go: 143, 334, 455, with one digit left over (7), jump back and say, that's 1.4 billion.

Of course, it would be a lot easier if it were just written with the commas to begin with (1,433,344,557), but I don't always have that luxury.

## The Goggles... they do something!

As I watched the Nadal-Djokovic US Open Finals yesterday, I wondered about the logo that Djokovic was wearing on his clothing. It looked like the logo of the Tata Group, but I wasn't sure. Arvind suggested that we try Google Goggles.

I found a picture of Djokovic through an images search, zoomed into it on my computer, took the photo shown here with my Android phone and then fed it to Goggles. Goggles nailed it! The first and only result I got back was Sergio Tacchini.

It was amazing, given that my photo was rather crappy, and taken off an image on my monitor. I suppose I could also have found the answer through Wikipedia, but Goggles was just so much cooler to see in action.

## Speculative parsing and chunk size

I've started doing some tests to understand how different browsers download and parse HTML and JavaScript, something I should've done a long time ago. I'll post about the things I find interesting. Here's one:

You probably know that the latest browsers perform "speculative parsing" (a.k.a. "preload scanning"). Say the UI thread is waiting for a script to download. The thread won't (can't) continue building the DOM from the rest of the page, because the script may affect the DOM. So the script must be parsed and executed first. However, there's nothing wrong in at least scanning the rest of the page quickly for resource URLs and queueing them up for download, while waiting for the script to arrive.

However, once the script has arrived, the UI thread will get busy parsing and executing it. It won't be able to look for any more resources if some more page content arrives during that time.

Consider an HTML page that's delivered in two chunks:
`<!-- chunk 1 --><script src=foo.js></script><image src=bar.jpg><!-- chunk 2 --><image src=quux.jpg>`

I was trying to demonstrate this effect in Chrome. However, even though I was sure that I was flushing the first chunk properly, Chrome didn't seem to even start downloading the first script (foo.js) until the page was done (all chunks had been received). Safari behaved the same way. After some more testing, I realized that it was because my tests were too small. These WebKit browsers do not scan the rest of the chunk unless the chunk is at least 1KB in size! Firefox doesn't have this issue. It scans the rest of the chunk no matter how small it is.

UPDATE:

A couple of my colleagues (Tony and Bryan) suggested that this was due to charset sniffing. Indeed, that was the case. When I specified the charset, the issue seemed to go away. Chrome issued the fetch requests for the script and image right away.

However, when I made the first chunk even smaller than before (but still specifying the charset in the Content-Type header), the issue came back. I.e., Chrome still waited to buffer up more chunks. I realized that this is because of content sniffing. I confirmed that once 256 bytes had been buffered, the chunks would get parsed.

Summary

For each resource, Chrome may buffer the first few bytes before parsing them. It does this to figure out the content-type, the charset (encoding) and the doctype (i.e., whether quirks or standards mode). Specifying content-type and charset explicitly helps, but for text/html resources Chrome still needs to buffer to detect the doctype, due to underlying webkit constraints. The buffering may be 256 or 1024 bytes depending on the above.

## Hiking

Another week, another first. Went for a hike yesterday, with two of my colleagues. Until now, I've done only mild stretches, such as 4 miles at Rancho San Antonio and 6 miles on flat streets. So, this 20 mile, 4000+ feet elevation gain was a drastic move. We went from Del Valle to Rose Peak, and back, in 10 hours.

It was a nice and warm day; the trail was well kept; the scenery was very pleasant (photos). At the top at Rose Peak, we could see the clouds below us. We walked the last hour in the dark, but thanks to Gurmeet's flashlight, it was not so bad.

Towards the end of the hike, I found it hard to say which I found more painful - uphill or downhill. Uphill was slow-going, heavy-breathing and groin-aching. Downhill was knees-killing. It didn't help that I had to lug around my backpack loaded with a lot of useless things, including an umbrella, extra pair of shoes and a couple of t-shirts.

## It was my first time. And it was awesome!

Watched an NBA game with my coworkers on Monday. My first time watching one. It was amazing.

I'm not a basketball fan, so I didn't know anything about the teams (Golden State Warriors vs Dallas Mavericks). I kinda assumed that they were some random teams, so I thought it'd be like a random little league game, with a few die-hard fans thrown in.

Whoa, was I wrong.

The thing that struck me the most was the professionalism of the whole thing. The stadium (Oracle Arena) was in full swing. Lights, ads, real-time TV display, awesome camera work in replays, slow mo and angles, popcorn vendors, etc. Every timeout, every gap between the quarters, the NBA had something going on - trampoline stunts, 3rd grade kids playing, pizza give-aways, t-shirt guns, lucky draws, guess-the-song contests, and uh, the cheerleaders. Having played a minor logistics role back in my school days, I appreciated the co-ordination and practice needed to pull off such a smooth operation.

The game itself was not as much fun. The Warriors led for the most part, though both teams were playing very fast and loose. Eventually, the Mavericks tightened up their game, and won handily. Apart from the 3rd grade kids playing full-on basketball, the most fun I had was listening to a couple of vociferous Warriors supporters nearby. "Are you blind, referee??!! Come on man! The guy was sliding on his ass! Dirk No-game-zki!" and so on.

I can only imagine what it would have been like if the Lakers and Kobe were playing...

## Perseverance

"First they ignore you, then they laugh at you, then they fight you, then you win."

— Mohandas Gandhi.

## Scientific truth

"I resolved to decline future invitations from debating societies that encourage insincere advocacy on issues where scientific truth is at stake."

— Richard Dawkins, Preface to The Blind Watchmaker, 1986.

## Liberty and security

"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety."

— Benjamin Franklin, Historical Review of Pennsylvania, 1759.

## Pursue a dream

"When a big company lays you off, they often give you a year's salary to 'go pursue a dream.' If you're stupid, you panic and get another job. If you're smart, you take the money and use the time to figure out what you want to do next."

— Guru Profile, http://www.guru.com/channel/tech/portrait/P66.jhtml, Aug 1999.

## Not run but proven

"Beware of bugs in the above code; I have only proved it correct, not tried it."

— Donald Knuth, Notes on the van Emde Boas construction of priority deques: An instructive use of recursion, Mar 1977.

## Not wrong but illegal

"I don't call this copying piracy, because that is a propaganda word. I don't think it is wrong to copy and share information. Governments can pass laws against it, but that does not make it wrong, just illegal."

— Richard Stallman, Interview with RMS by Hiroo Yamagata, Aug 1997.

## Then they came for me ...

"When Hitler attacked the Jews I was not a Jew, therefore I was not concerned. And when Hitler attacked the Catholics, I was not a Catholic, and therefore, I was not concerned. And when Hitler attacked the unions and the industrialists, I was not a member of the unions and I was not concerned. Then Hitler attacked me and the Protestant church -- and there was nobody left to be concerned."

— Martin Niemöller, Congressional Record, Oct 1968.

## Make a bonfire of your reputations

I used to have a collection of quotes I really liked on my old site. This one is my most favourite, and it's lifted from Michael Crawford's site:

"I give you this one rule of conduct. Do what you will, but speak out always. Be shunned, be hated, be ridiculed, be scared, be in doubt, but don't be gagged. The time of trial is always. Now is the appointed time."

— John Chapman, Commencement Address to the Graduating Class of Hobart College, 1900.

Everyone needs a project in life (a la the philosophers in Sophie's World), hopefully something big and ambitious. What's yours?

I know mine. I started on it about 6 years ago, pursued it on-and-off for about 2 years, and then ignored it completely for the next 4 years, as I moved jobs. Now, I am on the threshold of moving into a new role, and I am filled with a determination to get back to my life's goal. One of these days, I will have done enough work on it to perhaps even submit it for a Ph.D. thesis.

When it's done, it will have a deep impact on traditional software engineering.

## Inertia

I am trying to understand the nature of inertia. I don't have it nailed, but I think I'm making progress.

Today, I set out to do some work in the morning, which I finished by noon. It was an okay piece of work (nothing great, just a side-by-side evaluation). Still, I knew I wasn't going to do anything as good for the rest of the day. I had some other stuff to do - emails and facebook messages to respond to, expense reports to file, etc. But, they all seemed so much lesser (in worth or excitement) by comparison. It was going to be downhill for the rest of the day.

That made me very lethargic. I just lazed around, to the point of falling asleep. I tried watching a movie, but even that wasn't very exciting. I told myself "Okay, tomorrow, I'm going to wake up early, exercise, and finish all these items on the to-do list right away." I was just procrastinating.

After several hours, I forced myself to get back onto facebook, and voila, I was having fun again. Perhaps it was the social nature of the task. Or perhaps I had just gotten past the activation energy point. In any case, I understand a little bit more about myself now, and how to get myself off my butt. I need to nail it, to get those sadhabhishekam videos done.

I think we all feel a little relish at others' misfortunes now and then, especially when they are people we don't particularly like.

It's hard to avoid that feeling. That private thrill of "Serves him right!". Despite that I am more secure in my life than most, it happens to me too. Recently, I witnessed a negative comment about somebody's code that made me feel a little smug.

Ask yourself: The last time you said "I am happy for you", were you really so? Or, was it because it was the right thing to say?

As with most failings, I think just recognizing that we are prone to them is winning half the battle. To go further, we should remember the instances when we succumbed and consciously try to overcome them.

## Power and discretion

You know the old maxim: Power corrupts. Absolute power corrupts absolutely. I have noticed that the second part is not as emphatically true as the first.

Recently, I was walking out of my office building when a security guard stopped me. I was headed towards an exit which was not "officially" opened. Never mind that it was fully built and functional, that I and others had already used it a few times before, that it was in fact going to be officially opened the next day, that there was nothing blocking the exit save for a tiny string, that it was the shortest route out or that there was no physical, logical or spiritual harm in letting people walk out that exit.

He felt bound to enforce an arbitrary rule. He made me walk around to the official exit (which was anyway right next to the one I wanted).

Just a few days before that, the security guards and their manager at a food court tried to stop me putting tables together. In this food court, all the movable tables and chairs are arranged so that they seat four persons each. We were a larger group, so I pulled two tables and their chairs together. We were about to eat when these chaps showed up and demanded that we separate the tables. No amount of logical reasoning could disabuse them of the notion that the food court's rule about not joining tables was sacrosanct. I pleaded to let us eat in peace, and after we were done, to have their way. Ultimately, they relented.

In general, I find that the guys in smaller positions of authority (security guards, middle managers, constables, clerks in government offices, etc) tend to wield their power absolutely. They don't use their discretion. Their standard defense is that those are the rules, that they didn't make the rules, and that they will get flak from their higher-ups otherwise. To some extent, that defense is valid, but I see it used even when it's okay to bend the rules sometimes.

I have seen this a lot in Singapore. Few people feel empowered to use their discretion. In fact, there are many who relish being stubborn about the rules. Sadists.

On the contrary, the people in higher positions of authority tend to be more flexible. The CEO of my company has his eye on the big picture, on the things that really matter. He is less likely to say "No" to a little extravagant spending, for example, than the immediate manager who approves the expenses. The CEO doesn't want to waste his time bickering about little rules.

As a manager with a little power myself, I am acutely aware of my responsibility to not fall into this trap. I try to consciously think about these things when I invoke a "rule".

Foolish consistency is the hobgoblin of little minds.

## Expertise and effort

A great myth is that experts don't need to put in as much effort (as mere mortals) to achieve something. Notwithstanding that experts usually got to their level having put in a lot of effort to begin with, they have to continue to work hard at maintaining their expertise (except where said expertise may be innate and not just apparent).

Okay, that was very opaque. Let me explain. Let's take an expert doctor, for example. He's able to diagnose illnesses accurately. We are amazed by his skill. How could he guess correctly that the child was not using her arm because of a specific injury called the Nursemaid Elbow? How did he know just by looking at her?

This sort of expertise is apparent expertise (as opposed to innate expertise, which is skill that one is born with). A lot of skill and knowledge is acquired over time. We may have an aptitude for certain skills, but we still have to work hard at acquiring them. The doctor didn't get to where he is today without a lot of study and hard work.

Moreover, the doctor has to stay on his toes. He has to keep up with changes in the field of medicine. He has to learn from his experiences every day. He has to put in a lot of effort to keep up the appearance of his expertise.

Another problem we don't realize often is that expertise in one area doesn't usually translate to expertise, or even just competence, in another. For example, you may be an expert in a field, but it doesn't mean you can explain it well to your students.

I gave a talk today about an internal system. It seemed to have been received well, but I was disappointed. I thought it was haphazard and lacked coherence. I've yet to see anyone criticize a technical talk, so I don't place too much faith in the seemingly positive reception. I know the talk was bad. The problem is that though I am a reasonably good speaker, have no stage fright and am very comfortable giving talks (having been a lecturer before), lack of preparation hurt. There's no getting around putting in the effort to prepare a talk.

Similarly, no matter how good you think you are, how experienced you may be, you have to make the effort to prepare. You have to plan your interview questions beforehand. You have to think ahead of a detailed work plan for you intern. Otherwise, the outcome will usually be suboptimal.

## B+

Following on from my previous post, if you are able to focus on what matters, go one step further towards becoming a better person: Adopt my blood group as your motto. Be positive.

Learn to listen. Don't dismiss people or ideas outright, no matter how wacky they may be. If your colleague's argument seems to be full of crap, look deeper. Look for the gem in their argument.

If somebody criticizes something you feel passionate about, try to understand what it is that caused them to feel that way. People freely use extreme words such as "never" and "always" without really meaning to. Perhaps your colleague is overgeneralizing, extrapolating to situations that make the argument obviously bogus. If so, ignore those generalizations. See if the argument is applicable in some context, any context. Find that positive thing.

## How does it matter?

I have said before how we have a tendency to disagree. This is especially true in a corporate setting where we feel a need to assert our superiority in intelligence, knowledge and other skills. It is even more true at the current company I work for, which is filled with big egos.

My advice to you is to focus on what matters. Even if your colleague hasn't expressed himself well, even if he hasn't highlighted the important things, concentrate on the core of the idea or argument. Resist the temptation to tear the rest of the idea down. Ask yourself if the thing you are bringing down really matters to the point being made. If it doesn't, ignore it.

This is similar to the concept of "constructive criticism," but not quite. Constructive criticism is a good idea, but it has been overexposed. At the workplace, I cringe when a pacifist uses this sword to silence a vocal, unpopular, detractor. It's worth understanding the difference. The pacifist insists that you should not criticize unless you have a solution to offer to the problem. That's too onerous a requirement. I think you'll agree that many times, we can easily see what's wrong, even though we may not know how to fix it.

My point with "How does it matter?" is different. Feel free to criticize, without offering any constructive solutions, but do focus on what really matters. A common scenario is when dealing with analogies. Few analogies are perfect. Instead of pointing out how your colleague's analogy is flawed, because of this-and-that, try to understand the essence of the analogy and see whether you agree with it. If possible, ignore the analogy completely, as it's only supposed to be an aid in understanding the argument, and not the argument itself.

## Harry Potter and the Hallows

I picked up the new Harry Potter book and got through 2 pages before I barfed. By page 10, I was asleep. Rowling's style is crap. I remember feeling this way when I read The God of Small Things. The first page of that book is filled with grandiloquence - the sort of inconsequential, flowery prose that got me an "F for style" in school.

Rowling's style is not as bad, but her abuse of adjectives irks me. She has an obsession to adorn every noun with an adjective. Stephen King has similarly criticized her overuse of adverbs. Here's the evidence (choice excerpts from the first two pages):

The lane was bordered on the left by wild, low-growing brambles, on the right by a high, neatly manicured hedge.

"Thought I might be late," said Yaxley, his blunt features sliding in and out of sight as the branches of overhanging trees broke the moonlight.

They turned right, into a wide driveway that led off the lane. The high hedge curved with them, running off into the distance beyond the pair of impressive wrought-iron gates barring the men's way.

A handome manor house grew out of the darkness at the end of the straight drive, lights glinting in the diamond-paned downstairs windows. Somewhere in the dark garden beyond the hedge a fountain was playing.

The hallway was large, dimly lit, and sumptuously decorated, with a magnificent carpet covering most of the stone floor. The eyes of the pale-faced portraits on the walls followed Snape and Yaxley as they strode past. The two men halted at a heavy wooden door leading into the next room, hesitated for the space of a heartbeat, then Snape turned the bronze handle.

The drawing room was full of silent people, sitting at a long and ornate table. The room's usual furniture had been pushed carelessly up against the walls. Illumination came from a roaring fire beneath a handsome marble mantelpiece surmounted by a gilded mirror.

Really! Do we care that the floor was made of stone or the handle of bronze? "Roaring fire," "handsome marble mantelpiece" and "gilded mirror"? Argh. I know I'll still finish the book. It's magic, you know.

## Prudence is the better part of valour

One of the hardest things in life is knowing when to shut up.

I am not talking about putting foot in the mouth, blurting out secrets, being obnoxiously garrulous, etc. I am talking about other situations where our instinct is to say something, but the world would be a better place if we restrained that impulse. Here are some examples:

You are head over heels in love. You can't contain your enthusiasm. You want to keep professing your love for your significant other. You know what? Sometimes, you should just put a lid on it. It is good advice, as is most other "don't overdo it" advice. Withholding a little can make the relationship last longer. Keep him/her running.

You are incredibly smart. Any time any topic comes up, you have the definitive answer or a very strong opinion. You solve everyone's problems, even when the question is not directed to you. Stop doing that! People hate know-it-alls.

You are completely truthful. You tell your spouse or your best friend everything. This thing on your mind bothers you, though. It is a little too personal. Be discreet. Convince yourself that it's insignificant. You share all the important things. Those that matter, anyway. As someone said, knowledge changes things. Your friend may be affected irreversibly by that knowledge. The very fact that they have a certain knowledge changes the world.

Your kid believes in Santa Claus. Your coworker wouldn't understand why you were told he's about to be fired but he wasn't. Your dad doesn't know that everyone can see past his innocent bullshit. And so on. Use your discretion.

Here's a short history of my domain:

When I got sreeram.org in 2000, I hosted it on Srikant's machine. He was employed at the National University of Singapore (NUS) and had his own static IP and a Debian box. I preferred OpenBSD. I put my own machine next to his, and connected the two through a crossed-cable. My machine used to make a lot of noise, which bothered Srikant. So, I hid it inside a cabinet. However, I didn't have enough cooling, and eventually the box fried.

Soon, I joined NUS myself. I took care of the systems and network at the Medical Computing Laboratory, so I was able to move my site there. The School of Computing didn't allow incoming connections. Ordinarily, it would have been impossible to host my website there. However, we had a static IP for the lab where we hosted the lab's website, so I was able to use that for my site as well. The school's security policies regularly inhibited my site from working. While I worked around most of them, eventually I gave up and looked for a better home.

Kartik agreed to host the site on his cable-modem connection. He installed OpenBSD on a spare PC, and I administered it remotely. This worked well for a while, including after I left NUS. However, one day that box failed and my site went dormant. For the next three years, it dropped off the web.

I have now brought it back. Instead of insisting on free hosting and OpenBSD, I've now resorted to Google. Google provides free hosting for web, email, blogs and a suite of other applications (calendar, chat, docs and spreadsheets) through its Google Apps For Your Domain (GAFYD) service. This, along with the goodies it comes with (online administration, backup, failover, great bandwidth, etc), is as good as it gets for hosting your domain for free.

A technical issue: With GAFYD, it's not possible to use the root domain for your website. You have to use a subdomain, typically "www". You can't use a CNAME for the root record, and just specifying the IP address of the www site doesn't work. Luckily for me, my domain registrar provides free web forwarding, so I have redirected the root domain to the www site, so http://sreeram.org/ works.

## No, but ...

Often in discussions, we have a tendency to start a response with "No, but ..." This happens even if the response is only tangentially related to the point the previous person made. It happens in both heated discussions and informal social chatting. It is usually unnecessary. Listen closely the next time you are in a group (or even with just one other person).

Why do we do this? Kartik suggests that it's because of a subconscious need to have the last word. Agreeing with somebody doesn't feel like you had the last word. You feel that the person who proposed the thing you agree with had it. Hence the need to assert the last word by disagreeing and putting forth your point of view.

I agree that this plays into it. However (heh :) "No, but ..."), I think a deeper cause is that we don't really care for what other people have to say. We care more about having our say. We love to hear our own voices. The "No, but ..." really says, "Yeah, whatever. Now, listen to me. I think ..."

I am reminded of an exhortation my dad had scribbled on the inside of an encyclopaedia: "Speak because you have something to say. Not because you have to say something."