Saturday, February 20, 2010

Potatoes and Ravi Bhaiyya

I was at the neighborhood NTUC and the wifey wanted to pick up potatoes. Now, every indian knows that potatoes are a key ingredient in Indian vegetarian cuisine and every time I make a visit to the vegetable store, potatoes are in the list, along with tomatoes and onions, of course. But to my surprise, there were no potatoes, not even one, zilch. That was an absolute shocker. As it is I have been cribbing about the potatoes being super costly in this Island, but not finding one was too much for me, and my wife's culinary future, which was now in uncertain land, to take. So, we threw caution to the winds, and our loyalty to NTUC up into smoke, and decided to hunt for potatoes elsewhere.

We finally found some not-so-good-looking-but-who-cares-for-vanity-in-an-emergency potatoes at a mom and pop store nearby and my wife's heart, which had stopped functioning the moment she saw the potato counter empty at the NTUC, started chirping away nice and easy.

But, once potatoes come into limelight, I have to relate the anecdote of a certain Ravi Bhaiyya. It was the year 1995, and I was still in high school when an unfortunate demise in the family had lead my parents to head to Chennai leaving me in Delhi. But they found Ravi Bhaiyya, who was brother of Omkar Bhaiyya, who was physiotherapist or Sharma Aunty, who was wife of Sharma Uncle, who was a long time friend and senior of my dad. Ravi Bhaiyya had just moved into the capital to pursue a career in theatre and he didn't mind baby sitting me for the time my parents were gone.

My parents assured me that Ravi Bhaiyya could cook and if I helped him out, things should be smooth sailing. Well, it wouldn't have been smooth had it not been for a tiny glitch - Ravi Bhaiyya COULD NOT cook any shit without potato. Seriously. He had to cut in, boil in or mash in potatoes into EVERY single edible thing he had ever created in the insides of anything resembling a kitchen. He could cook the potatoes with anything - tomatoes, onions, eggplant, cauliflower, cabbage and diversify the potatoes with dishes like Kashmiri Aloo, Dum Aloo, Dari wale Aloo and various other incarnations, but never without it. It got so bad that the neighborhood subziwala stopped selling us potatoes in the suspicion that we were hoarding them. Only our innocent faces and smiling demeanor prevented us from getting arrested.

And for somebody who was brought up on the concept of balanced diet and green vegetables and neo shit like that, I just couldn't take the potatoes. Thankfully, Ravi Bhaiyya had a great voice and he practiced his singing every now and then and his beautiful renditions of hindi songs of 60s and 70s, which I totally digged, smoothed me out. Else, I was gonna murder the dude, by stuffing his potatoes into his throat.

From Ravi Bhaiyya's favorite song:
Teri duniya se hoke mazboor chala
main bahut door bahut door bahut door chala 
ps: Ravi Bhaiyya finally succeeded to get into mainstream theatre by the time of our last meeting, which was many years ago, but we have, unfortunately enough, lost touch with each other since. If you happened to know a dude from Bhaliya, who could sing and act well, and could not cook without packing in a few pounds of potato, tell him to read this blog and leave a comment. :-)

Wednesday, February 17, 2010

Google's Peanut Butter Manifesto moment

If it is not obvious already that Google is heading fast towards a "spread too thin" moment, aka Peanut Butter Manifesto moment, check out the following two pieces of information:


I always thoughts it was a question of "when", not "if", that Google will head into the same spiral of profit-centeredness-leading-to-loss-of-innovation that many other companies have fallen into in the past, and so it is interesting to see pertinent signs in that direction. 

Tuesday, January 12, 2010

Have you used Stanza yet?

If you haven't heard it, now now is a good time to do it. Stanza is probably the best app I have used on the iPhone yet. It's also probably the app that makes the best of the iPhone's look and feel and its connectivity to give you a wholesome experience. So, what does it do? Allow you to read books. What else does it do? Let me list it out:
  • Allows you to directly download e-books to the phone from free source e-books like Feedbooks, Project Gutenburg etc.
  • Allows you to bring in PDFs into your phone through their Desktop counterpart app, called Stanza Desktop.
  • Allows you to read both in portrait and landscape modes.
  • Allows you to read either in black-on-white or on white-or-black.
  • Allows you to change the contrast, brightness, font size to improve your reading experience.
  • Takes up full screen to increase reading space.
  • Flipping pages is super easy (tap on right for next and on left for previous page) and fast (none of that waiting business)
  • Works as expected when a call comes in while you are reading - picks up where you left off.
  • Do you like to add annotations or bookmarks as you read for future reference? You can do that too. 
As far as I am concerned, the only thing that is missing from this to completely replace Kindle/dedicated-ebook-readers is the ability to buy e-books from paid sources. But I don't care. There is a lot of free e-books available without copyright and of course I have PDFs (papers, short stories, etc) that I have to always clear up and Stanza is the way to do it.

And the icing on the cake? Its free. Yes, it really is.

Saturday, January 9, 2010

Conditional MySQL statements: Lifesaver on occasions

Have you tried building a pageview counter? Lets say you want to count the number of pageviews on a site/page on the following granularity - today, yesterday and accumulated. Now, lets assume that the Table is defined as follows:

CREATE TABLE pageviews (
     page_id varchar(100) not null,
     last_update_time int(11) not null default UNIX_TIMESTAMP(),
     today int(11) not null default 0,
     yesterday int(11) not null default 0,
     acc int(11) not null default 0
);

Now, your counter would normally apply a query like this to increment the counter:
update pageviews set today = today+1, acc = acc + 1, last_update_time = UNIX_TIMESTAMP() where page_id = 'xxx';

But when do you move the today counter to yesterday? Remember that after the stroke of midnight, today count should switch to yesterday and reset to 0. You could always write a cronjob which would do this for all the rows in the table at the stroke of midnight, but the trouble is that as the number of rows increase, the execution time of such a query increase and in the meanwhile (say between 0001hrs and 0010hrs), queries on the page counting client would either be blocked or be incorrectly executed making it an undesirable situation.

The solution to that is a conditional MySQL statement like the following:

UPDATE pageviews SET 
        yesterday = CASE WHEN last_update_time > xxx_ts THEN yesterday ELSE today END,
        today     = CASE WHEN last_update_time > xxx_ts THEN today + 1 ELSE 1     END, 
        acc = acc + 1, last_update_time = UNIX_TIMESTAMP() WHERE page_id = 'xxx';
where xxx_ts is the unix timestamp of the stroke of midnight of today. 

This is essentially crunching all that complex logic of having to worry about the switch time into the query. Remember that at the MySQL end, all the queries will be applied one after the other, and hence even if the same query is run one after the other, it will be set correctly.

Friday, December 18, 2009

Hack: archive of mails sent from phone for custom domain

I am going to try hard to keep this as simple as possible. I have the following accounts I wish to check on my phone:
  • Gmail
  • Yahoo
  • Custom domain email address (shreeni.info) with provider only supporting POP/SMTP
The second complication is this - I have been using my Gmail interface for both my gmail and the shreeni.info account, which means the inbox and the sent items are all merged, making searches much more easier.

Now, I wanted to fetch all of this on my phone retaining every aspect:
  • Check all email accounts
  • All replies should appear as coming from the account to which it was addressed to (so, gmail should not appear as the replier to shreeni.info mails)
  • I should still be able to search for all shreeni.info and gmail mails on the web interface if I wished to, which is quite often, in a merged manner (meaning not searching on two different places.)
Complications:
  • Continuing to use gmail as a proxy for shreeni.info meant that all responses from shreeni.info go as gmail.com address since the phone doesn't have an option which says "reply from same account as received", which the gmail web interface has.
  • Using shreeni.info as an independent account on the phone makes the replies look as required, but the sent messages are unsearchable since they are only on the phone and not in the gmail server as I desire.
Options:
  • BCC all mails from shreeni.info to gmail.com and use some sort of a filter to put it in. But it doesn't work for two reasons - my phone doesn't have a option of selectively BCCing. Its either for all accounts or none. Secondly, gmail doesn't have a way of specifying bcc: as a parameter to a filter, which is rather disappointing.
  • (Actual Solution): After configuring all accounts, go the shreeni.info account on the phone, go to outgoing servers and in "Alternate SMTP servers" section, you should see the Gmail SMTP server. Turn that on. In the same page, turn off the default SMTP server of the shreeni.info account.
Now, all messages out of this account will be routed through the gmail smtp server and hence will appear on the web interface as if you sent it from there. Search works is as is. The only minor complication is for messages coming into gmail through the shreeni.info account which might be read twice, once directly and once through gmail when it fetches the same emails. For that, I just marked them as "skip inbox" and hence I read them only once.

I know it is a complicated situation and I know I am finicky about some things which others may not care, but I have a hunch more people will be trying to solve the same problem and hence this post.

Wednesday, December 16, 2009

The assumptions of new beginnings

pre-note: I am sorry for posting this almost a month late, but its an essay and hence its probably acceptable. Apologies anyhow.

When I visited Jakarta for the Yahoo Open Hack Day 2009 late last month, apart from presenting the talk on YQL, I was also in the judging panel. One of the things that very quickly struck me was the point from which all the bloggers started. This is an important thing to observe.

Starting on social networks or using their power is so 2008 at this point of time. The first thing in vogue is to use the power of GPS and build solid location aware utility services. The second things in vogue is that of using twitter and other streams of micro blogging.

Thirdly, even in countries like Indonesia (and much like India and China) where the mobile penetration is not not very high and is mostly lower end Internet connectivity for whatever penetration there is, the focus on building mobile aware apps is huge. This ties in, of course, with the first item which is to build GPS and location aware products, but you could build powerful apps that just depend on you being mobile, if nothing else.

Over the next few months, the battle for attention in the tech space is now for apps built on these paradigms - mobile, location-aware and stream-aware. What is encouraging, clearly, is that its not the hackers in the silicon valley who are thinking along these lines, but hackers in Jakarta, Indonesia which is the epitome of a developing country who are jumping on the new age paradigms.

Wednesday, December 9, 2009

A contradiction to Joel's thoughts on micromanagent

Do you read Joel Spolsky, either at joelonsoftware.com or on inc.com? If not and if you happen to be related to a technology company, you must subscribe to his writings now and probably read the archive. He presents well thought out essays on building high quality technology products, high performing technology building teams and so on. I have been reading him for a few years now and have generally liked what I read.

But lately, I have been having a major contradiction with what he says and this post is about that. He talks about why micromanagement is a bad idea and that he would never micromanage since he always hires the best talent available. So far so good. Till the point that he wants to build a team of a few dozen people, you will never end up with talent which is anything less than the best. Even then you need to be in a position where you can control the business requirements such that you are willing to wait for talent before you expand on your product offerings. For Joel, that's always possible, since he owns his company, and hence has a control over who gets hired and hence he has a strong tight fist control over all the positive cycle he wishes to generate.

Once you get out of that comfort circle, that of having control over the timelines as well as the size of the company, you are in hard luck. Once you have time pressures (and some will argue that they can always control it, but I don't agree) you sometimes need to build a team in a short span and hence you are always constrained by the talent pool available at THAT POINT of time. So, you might always end up hiring somebody who is say only 95% of your worst previous talent. So, you see that the lowest talent point of yours is already going down.

Now, similarly, if you wish to expand your product offerings, you need to hire a LOT of people, some of whom will always slip through despite being not the best. They may not be less smart, but may have a lazy attitude, or may have a indisciplined work culture (those people who won't check in code in time, or break the build, or not write documentation, or introduce the first shitty code since nobody was looking around) and thats the beginning of the slide. Now, if you don't have shareholders to respond to, you can stick with only a narrow product offering and get away with it, as Joel has. But no public listed company is in a position to totally neglect their expansion of product offerings only for the express desire of keeping only the 100% best talent.

I am not saying that hiring the best talent is not possible or should not be the endeavor of any manager/owner. All I am saying is that as an engineer or a manager of a few years experience in the industry, you are quite often to find yourself in the company of less than 100% talented people every now and then for reasons you can't always control. You can always chose to start up your own company with these principles as your primary motive, as Joel has done, but not everybody is going to be in a position to do that. If everybody in fact did that, then all companies would be just 2 or 3 or 4 member companies working on fairly trivial products.

My point is that once you talk about building large wealth creating organizations like the Yahoos, Googles, Microsofts, IBMs etc, you will definitely end up in a position where you will end up with less than 100% perfect talent and from there on, you need to bring on the best management, and possibly micromanagement, skills to the table to make it all work.

ps: Feel free to critique what I have written here, since I am still philosophizing on this idea. :-)