Sunday, April 24, 2005

BlogPoster is born (barely!)

As you can see, the previous post is a test post from an OS X application that I am developing. Its called BlogPoster, and it will allow you to post to your weblog from your favorite mac, without actually opening the weblog service in a browser. I know, I know -- applications like these are retro, and they are a dime-a-dozen. But I am writing it to mainly hone my developing skills in Cocoa, Python, pyobjc, and to gain more familiarity with XML.

Interface Builder is an OS X application that lets you create Cocoa/Carbon based GUI applications quickly and intelligently. It also defines skeleton classes that capture the interaction between the various GUI compnents, leaving the user to flesh out the classes for functionality. It is especially suited for applications that follow the Model-View-Controller (MVC) design pattern.

Python, as you might know, is the most kick-ass scripting/object-oriented/whatever language ever. Python rocks! Objective-C is an extended C, with, as the name implies, object oriented features. pyobjc is an extension of python that allows a developer to combine the features provided by both Python and Objective-C. Since its an extension of python, the syntax of pyobjc resembles that of Python.

BlogPoster is still in its infancy - I spent 6 hours reading others' code (isn't that the best way to learn?), and 2 hours writing my own - about a 100 lines of python code. So, the only blog to which posts can be uploaded is mine :) I want to make it complete, by adding the following features (in order of priority):

  • HTML Editing
  • HTML preview
  • Image upload
  • Support for all blogging services that provide an XML-RPC based API for developers


Screenshots, and source code will be posted (via BlogPoster :) ), once the project is in a respectable state. Not too many people are mac users, leave alone being mac hackers, but people - if you are not at least one of these, you are missing out on something sweet.
test from BlogPoster
hello, world

Thursday, April 07, 2005

Yahoo! vs Google

A friend and I were comparing Google and Yahoo! He loves Yahoo! and hates Google. He loves Yahoo! because it has a comprehensive suite of web-services, and comes up with pioneering revenue-generating ideas. He hates Google because the guys there act like they are "the saviors of technology", and because they front crap like "We are in it because we love technology", while "they are actually in it for money" (which, by the way, they are making tons of).

As for me, I hate Yahoo! and love Google. For pretty much the same reasons he hates them. Let me clarify: Sure, Y! has a suite of websites, but have you used them? They are stinking piles of shit. Y! Maps has been around for ages, and its probably the clunkiest web software around. Have you seen their homepage? Even after a (much-hyped) redesign, their homepage is cluttered with ads, and with no clear focus. And let's not even get into My Yahoo!

I believe that it is important to get things working. I concede that Yahoo! does that. But then, they sit on their asses doing nothing to improve things that are working. Especially when there is trememdous potential to do so. This is the very reason Google could enter and dominate the web search market that was once Yahoo!'s domain. There is no point in being a pioneer if you don't continually strive towards improvement.

As a Mac user, another thing that greatly ticks me off about Y!'s development culture is their absolute contempt, and lack of support, for non-Windows environments. It may be true that setting teams of people to work on developing software for the Mac might not reflect in financial returns, but then, why even bother? Their website features a half-assed Y! messenger client for the Mac that doesn't even anti-alias fonts, leave alone supporting audio/video. I would actually be willing to pay them for a decent OS X client.

I don't need to sing praises about Google here, since Slashdot already does that for me. But I do believe most of that praise is warranted. Have you looked at how prolific they are? My point is that it is not beyond most tech companies to do good stuff (Yes, even Microsoft). They just need to have the right mindset.

Any way, this whole rant was finally written because of my frustration using Yahoo! messenger for the Mac. So, I am thinking of writing a third party client for Yahoo! messenger that addresses all my frustrations. Yes, I want to go all the way, and provide audio/video support. I am not brave enough to write code from scratch. But it is going to be a challenge to even reuse components. Any way, in the meanwhile, I will start migrating away from everything Yahoo!, so that if I don't get around to developing my client, I can still survive.

Apple iChat, here I come.

Tuesday, March 29, 2005

Oldboy: Wierd-ass movie

Go watch this oddball movie, if you haven't already. If for no other reason than that you get to see a live octopus eaten. Also, almost randomly, there was an allusion to the 1999 wierdo-cult hit Being John Malkovich: A character mentions his discreet "7.5" floor business, where the anonymity of clients is top-priority. If you have seen BJM, you will recall that the porthole is in an office which is on floor 7.5. I was just wondering if 7.5 is standard nomenclature for discreet businesses, or if this was a deliberate reference to the other movie.

Monday, March 28, 2005

Addendum: More Questions

Random Walk (on-site)

  • Node is an element of a linked list of integers. Define Node, and implement the function:
    Node *addToEnd( Node *list, int val ).
  • In my implementation of addToNode(), I separately handled the case when the list is NULL. I was asked to improve the implementation to merge handling both cases. Hint: Use a Node ** variable.

Thursday, March 24, 2005

Technical interview questions

Here's a list of questions I was asked over the last two months, in the course of my job search. No solutions, nor a comment on the quality of questions, will be provided. So, don't bother asking.

Microsoft (on campus):

  • Reverse a linked list.
  • Given an array (positive and negative integers), find the contiguous subarray with the maximum sum.
  • Implement:
    void *aligned_malloc( size_t size_in_bytes, int align );
    void *aligned_free( void *ptr_returned_by_aligned_malloc );

    aligned_malloc() is like malloc(), but takes an additional argument - align. If p is the pointer returned by aligned_malloc, then, ( p % align == 0 ).
  • Find the minimum number of colors required to color a dodecahedron. Now, write an algorithm that does so.


NetApp (phone screen):

  • When would you prefer hashing as your dictionary implementation?
  • What is secondary hashing?
  • Perfect hashing/universal hashing...
  • How is the open() system call implemented in UNIX?
  • The rest, I don't remember (its all a haze).


Caliber Consulting (phone):

  • Given the function:

    void swap( char *p1, char *p2 ) {
    char *tmp;
    tmp = p1;
    p1 = p2;
    p2 = tmp;
    }

    what is the output of the following code:

    #include

    int main() {
    char *s1 = "hello";
    char *s2 = "world";
    swap( s1, s2 );
    printf( "%s, %s\n", s1, s2 );
    return 0;
    }

  • Implement strlen(), strcat()...
  • What is the complexity of strcat() ?
  • How would you change strcat(), given the following scenario:

    char src[VERYBIGNUMBER]; /* NULL initially */
    char *s1, *s2, ..., *sn;

    You need to place the strings s1, s2,..., sn into src using strcat(). Assume that src can accomodate all these strings. Note that normally, a single execution of strcat() takes O(l + m), where the lengths of the two strings are l and m. With that complexity, the above cascade of strcat()'s takes time proportional to:

    n*strlen(s1) + (n - 1) * strlen(s2) + ... + strlen(sn).

    Can you change the complexity to:

    strlen(s1) + strlen(s2) + ... + strlen(sn) ?

  • Given that you had only upto the IP stack implemented on two machines. How would you go about establishing a session between them? Note - you obviously can't just use TCP! Also, no error correction, sequencing etc. are required, so you don't *need* to use TCP.
  • With the same scenario as in the previous question, how would you implement a messaging client?
  • What are virtual functions in C++?
  • How would you implement virtual functions in a compiler?


Random Walk (pre-interview - on campus):

  • Implement the factorial function.
  • What is polymorphism?
  • What are virtual functions?
  • Talk about inner classes in Java.
  • Difference between a button and a JButton
  • 57 cents worth of money in 7 coins. How many of each do I have: 1c, 5c, 10c, 25c ?


Neuco (phone screen)

  • What are virtual functions in C++?
  • How does a typical C++ compiler implement virtual functions?
  • How would you reproduce/simulate the object system of C++ in C?
  • Given a C++ object and its method, how would you simulate with a C function, the calling of the C++ method?
  • Suppose you are given a pointer to a function that takes a double between 0 and 1, and returns a double between 0 and 1. The function is continuous, and is zero at some point(s) in the interval. Write a procedure to find those zero-points. What is the complexity of the function, as a function of (a) precision, (b) accuracy ?


Random Walk (phone interview)

  • What is the difference between the procedural and the object oriented approaches to programming?
  • Elucidate the cornerstones of OOP.
  • Suppose you had a Shape class. Its an abstract class that subclasses into concrete classes like a Point, Triangle, Square etc. How would you handle render()'ing a Shape instance...?
  • Suppose an application program wants to render birds on the screen. Different birds are to have different functionalities (Ducks can quack(), Crows can fly() etc). Suggest a good design pattern to provide these functionalities to different instances, that repsects the paradigms: cohesion and loose coupling.
  • What is the most prominent characteristic about multi-threaded programming? And why does multi-threaded prog have this characteristic?

Thursday, January 20, 2005

I'm Rick James, beee-yaatch!


I'm Rick James, beee-yaatch!, originally uploaded by shashankr.

Finally, it is here... a million thanks to Ditch for giving me this shirt as a gift.

The Flight to Goa

I went to Goa for a vacation when I was in India. A huge family, probably Assamese (I heard one of them call another Talukdar), also got on the Indian airlines flight. I immediately sensed this family would create a spectacle. It was probably their first time on a plane, and they intended to make an event out of it. Their assigned seats were scattered around the plane, and in an effort to rectify that, the head of the family (whom I will call Chief,) started asking the other passengers, loudly, to "adjust" and move to other seats. Of course, not everyone obliged; I was one of them. I was not going to give up my window seat to anyone, certainly not to obnoxious Chief. This led to louder condemnations in Assamese by other members of the family. Chief Talukdar, in fact, finally sat down two seats away from me.

I thought the family had settled after about five minutes, when I suddenly heard loud conversations break out all around. This family was not going to let a few rows of seats come in the way of the conversations they had going when they boarded. Children sitting ten rows away from each other were conversing. Aloud. Older men and women kept up a din across many rows. Chief is apparently a funny man, for every sentence of his brought forth guffaws from his kin spread strategically around the plane. So much for a surround sound experience.

And then, the plane took off. The entire family, from all around the plane, craned over their seats to get a better look of Bangalore falling away beneath them. As the plane rose higher, their exultations got louder, and reached a climax when the seat belt signs went off. Half of the family got up from their seats and started walking the aisles toward the other half. No longer bound by the (insignificant) constraint of having to sit rows away from each other, the conversation changed to a steady drone.

When the hapless flight attendants started serving snacks, everyone went back to their seats, and there was a thankful moment of silence: the family was going to eat. But soon afterwards, there was a lot of loud smacking of lips. I saw Chief lick his fingers to his satisfaction, and then wash his hands with water in the plate. I was completely rocked. Afterward, his brushy moustache still had crusts of food sticking on his face. When he went to sleep in no time, his moustache and the food crumbs gently waved about, as he snored.

Tuesday, December 14, 2004

That Instruction Permit

While I am at it, I still haven't gotten an instruction permit from the DMV. I must confess however, that this is out of my own inaction (wait, no. I "have been very busy"), than due to the inefficiencies of an archaic system. I hope to get it tomorrow (snicker... snicker...).

I pledged to myself to keep this thing better updated. But, as I said before - I have been too busy. Damn, I suck!

Interviewing at MS

Okay, wow... this is after a long time. A lot of water under the bridge. But before they slip out of my mind, let me post some questions I was asked in my screening interview (by phone) with someone from Microsoft. Yes, I sold out. If Microsoft offers me a job, I will take it with both hands.

Without further ado:

Why do you want to join Microsoft? I was kinda expecting this question, and I had a weak answer prepared. But still, this was the first question she threw at me; she virtually threw it at me. As I said, I was not too happy blathering my weak response. Not the start I was expecting.

What are your top three areas of expertise in software? Mmm... again, stock question, stock answer.

What programming languages do you know well? C, C++. Like an idiot, I tried to say I know Java, Scheme, ML - she brushed them all away, "We don't do those". Right. I forgot - I was decaying in graduate school.

What would you rate yourself in C/C++ on a scale of 10? Something tells me that someone's going to see my self-rating in the next round, and give me a lot of grief about it.

The next few questions were really stock, man. I mean, I had seen almost all these questions on various websites. But exactly two questions that I was asked, I hadn't seen. And when I figured out one of them, the interviewer asks me if I had seen them before. I said I hadn't, of course. But still, it made me almost think I was lying. Because I didn't tell her I had seen the others before. Anyway, its not my problem, if MS wants to ask questions over and over. And I am not going to list them, since you can find out with a simple search.

My favorite question (I hadn't seen this one): There are three switches in one room, and they control three light bulbs in another. You need to figure out which switch controls which bulb, but you can only visit the light bulb room once. I took a while to figure that one out. But I was happy when I got it.

The easiest question that I took longest to answer: This is really embarrassing I admit, but I took forever to figure this one out - There is a basket with x white balls, y black balls, z blue balls and w green balls. How many balls do you need to pick out of this basket before you are sure of having two balls of the same color? You don't want to know my first few attempts at solving this no-brainer. But finally, I saw the light: the pigeonhole principle. I profusely apologized to my interviewer for taking that long to figure it out.

Some things I did not do well:
My interviewer asked me how I keep abreast of the latest technological developments in the field. I blurted something about reading research articles and tech reports. Not very convincing.

What is your favorite software product? Since I use iTunes all the time, and I like all its features - its nice design, smart playlists, its fast startup in spite of its size, and its other hidden nuggets, that was my answer. She came back at me with this:

If you could improve iTunes, what would you do? Sadly, I didn't answer this one. I am very pissed about it, actually. If you are reading this, and you have suggestions, please let me know.

How would you test a stack? I know I am bad at testing. Sometimes I wish I had actually studied in college. All I could think of was to check for stack overflow, underflow and correct order of push/pop. She was expecting more, but I had nothing else to offer.

Anyway, I am going to Redmond sometime in January or February for the big interview. Excitingly enough, the email I got says, "... [be] ready to do a lot of C/C++ coding at your interviews. And most importantly, don't forget to test them before you say you are done". Thanks, will keep that in mind.