Monday, January 31, 2011

Awesome items on Amazon

I should be packing for a business trip, but instead I got sucked into looking at awesome things on Amazon:

  • Badonkadonk
  • Wolf shirt
  • Zubaz pants
  • AudioQuest cable
  • Denon cable
  • Tuscan milk
  • Uranium ore
If you don't get it then look at the prices, reviews, pictures, product descriptions, etc. Still don't get it? Go buy a wolf shirt. Other suggestions for products?

Thursday, January 27, 2011

Tired of snowstorms

I just want you to know that I am tired of snowstorms. There have been a ridiculous number this year, and the accumulation is way out of control. I took these pictures this morning. This first one is of our backyard play structure. Playset This is at a different angle and includes a better view of the fence. Fence in backyard I'll admit that the snow can be pretty on the trees. It's just that my back is starting to hurt just thinking about shoveling. Backyard The deck was shoveled as of two days ago. So all that is on there is fresh accumulation. This is the fourth time (I think) this season. Deck Here is a view of the sad trees in my front yard. Yes, that's my front yard. Front yard I went upstairs and got an alternate view of the play structure. This one includes iccicles! Backyard from second story A more boring picture of our backyard. You can see our poor snowman (or what's left of him). Backyard from second story Here is the view to the street from upstairs. It is hard to see how big the snow banks have become. The worst ones are by my other driveway, but I couldn't get a good picture of them from inside. Street view from second story Finally, here is a view of the roof and the chimney for the fireplace we don't use. Roof view to north Two bad we have already used snowpocalypse and snowmageddon this year. I have a feeling we aren't done yet. We are also worried about when this all melts.

Wednesday, January 26, 2011

Technical phone interview

Eventually I had the technical phone interview with Facebook. It went pretty well, I think, but did not result in further interviews. The interviewer was a relatively new engineer there that got a PhD doing distributed systems work.

The interviewer started out by asking me to say some more about my background. I mentioned briefly what I am currently doing and then went into more detail about my graduate work. The interviewer asked follow up questions that required me to go into more detail than I normally need to when answering this type of question. At one point the interviewer asked me to explain the unique contribution of my dissertation and I floundered a bit. Oh well.

I got asked "Why are you interested in Facebook?" I was honest here and said that basically "you guys came to me" and "Facebook is cool." I think this, more than anything else, is what deterred a future interview. If you are interviewing with a company, have some good reasons why you want to work there!

The interviewer shared a little about their background.

We also discussed hip-hop. Alright, so it is really HPPHP, High Performance PHP. It is a tool they use at Facebook to enable web designers to code in PHP and still get the performance of C++. The interviewer did some rough math on a hypothetical situation. Suppose we have 100,000 servers. Each of those servers costs $5000 for the hardware and then another $5000 for maintenance over three years. That's $1,000,000,000. HPPHP results in a 50% savings. Instead of 100,000 servers, we can get away with 50,000 servers. That's $500,000,000 in savings. Now consider if it is just 1% savings. That's still $10,000,000! One of the interviewer's points was that in academics, 1% is nothing. In the real world, it matters.

Of course, there was also a technical question. The interviewer had me go to a website which opened up a shared notepad-type interface. We could both type on this interface, although there was some lag. Once I got a strange pop-up come up because I tried to use an Emacs shortcut (fingers were on autopilot).

The interviewer listed some numbers in a sequence. My job was to figure out the next element in the sequence and then write some code that would print out the for n elements of the sequence. The sequence started at 1 and then each next number was the previous number read out loud. So 1, then 11 (one 1), then 21 (two 1s), and so on. Not too bad.

At first I tried to reason out the mathematical relationship between the numbers, but the interviewer quickly intercepted me and indicated there was not one to be found. The interviewer suggest I just code it up like I did it in my mind. So I did.
             1
            11
            21
          1211
        111221
        312211
      13112221
    1113213211
31131211131221

// Prints first n numbers in the sequence
void seq(string n)
{
    cout << 1;
    string last_number = "1";

    for( int num = 1 ; num < n ; num ++ )
    {
    
    
  // Last char
  char last_char = 'x'; 
  unsigned count = 0;
  string new_number = "";
  for( int x = 0; x < strlen(last_number) ; x++)
  {
    //character
    char c = last_number[x]; 
    if( c == last_char )
    {
        count++;
    }
    
    if(( c != last_char) ) 
    {
        if( count > 0)
        {
            new_number+=(itoa(count));
            new_number+=last_char; 
        }
        last_char = c;
        count = 1;
    } 
  }
     new_number+=(itoa(count));
     new_number+=last_char; 
  
    cout << new_number;
    last_number = new_number;
    
    //int y = atoi( c );
  }
}
The formatting is awful but the interviewer seemed satisfied with my response. Here is a version that I spent a few minutes getting to actually compile:
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <cassert>

using namespace std;

// Prints first n numbers in the sequence
void seq(int n)
{
  if(n < 1) return;
  cout << 1 << endl;
  string last_number = "1";
  
  for( int num = 1 ; num < n ; num ++ )
  {
    // Last char
    char last_char = 'x'; 
    unsigned count = 0;
    string new_number = "";
    for( int x = 0; x < last_number.length() ; x++)
    {
      //character
      char c = last_number[x]; 
      if( c == last_char )
      {
        count++;
      }
      if(( c != last_char) ) 
      {
        if( count > 0)
        {
          ostringstream tmp;
          tmp << count;
          new_number+= tmp.str();
          new_number+=last_char; 
        }
        last_char = c;
        count = 1;
      } 
  }
    ostringstream tmp;
    tmp << count;
    new_number+= tmp.str();
    new_number+=last_char; 
    
    cout << new_number << endl;
    last_number = new_number;
  }
}

main(int argc, char** argv)
{
  assert(argc==2);
  seq(atoi(argv[1]));
} 
That compiles with g++ in cygwin and it appears to work correctly. I noticed a few mistakes in making the version that actually compiles and did things a bit differently in some places. Might be one of the reasons they didn't want another interview.

As I have written this up I recall the problem was posed as a basis case and an inductive case. That seems to indicate that a recursive function could also solve it. That would have been clever. Might have been what the interviewer hoping to see.

After writing the code the interviewer had to leave for another meeting. I got to ask one question, so I asked what Facebook was doing to maintain its culture as it became larger. He gave a semi-generic answer, which is about all I should have expected. Then that was all.

A few days later I emailed the recruiter to follow up, and the recruiter let me know they would not be pursuing further interviews with me at this time. It was actually a relief to not have to decide between a sweet job and our #1 location.

Monday, January 24, 2011

Facebook technical phone interview prep

After my initial Facebook interview the recruiter told me they wanted to have a technical phone interview with me. The recruiter then passed me on to somebody else who arranged the interview. Meanwhile, the recruiter sent me some tips on how to prepare.
Please research any recent news about Facebook for talking points and more information about the company. You may be asked questions as to what your favorite features of the site are, and how you might improve those features. It will be helpful to take some time to think about this beforehand.

Be prepared for technical questions involving coding or algorithms in your best language, design patterns, and more specific questions to your background. It may also help to review core CS concepts (data structures, binary trees, link lists, object oriented analysis/design) as well as subjects pertaining to the scale of our environment. Please be near a computer with internet access as you will be coding over a web application.

It will help to look at the puzzles on our careers page for some ideas on the types of problems they will potentially ask. For coding questions, you will be asked to produce clean, efficient code in a reasonable amount of time. You have 45 minutes on the call. If the interviewer gives you hints to improve your code, take them and run with them. It is good to adjust and work through the problems with the interviewer to show your thought process and problem solving ability.
Simple and straightforward enough. The recruiter also sent me a bunch of links to review. I had heard most of the news through TWiT and TWiG, but the list still provided a nice review.
In preparation I also set up Chrome to have bookmarks ready while I interviewed. That ended up not mattering much, but I will tell that story later.

Friday, January 21, 2011

Facebook phone interview

I recently had a preliminary phone interview with Facebook. The recruiter contacted me out of the blue saying they were looking for "rockstars." I almost marked it as spam, but then actually read it. Facebook is the kind of company that I can't at least consider should they choose to pursue me. Plus it is good to try and sharpen the saw every once in a while.

Here are the questions I was asked and some of the answers I gave:
  1. This position is in Palo Alto. Are you willing to relocate?
    Probably. I was being honest here. I think I would be more willing to consider moving than my wife, but working for Facebook is a singularly unique opportunity.
  2. Can you tell me a little bit about the work you are doing right now?
    Blah blah blah. I probably rambled a bit too much here. Oh well. I was out of practice and forgot the preparation that good interviewing requires.
  3. Do you use Facebook?
    Yes. I then told the interviewer that I landed my current job through networking on Facebook. The interviewer asked me to explain that, so I did (probably rambling too much again).
  4. How familiar are you with the technologies we use here at Facebook? Do you follow
    Not very. I know the features Facebook puts out, but not the underlying technologies.
  5. How comfortable are you with technical phone interviews?
    It's hit or miss. I'm out of practice. My actual answer was much more verbose. The straight answer is "I normally stink and do horribly at any technical interview," but that doesn't seem like a good thing to say. Plus, I do occasionally do well.
  6. How many guesses would it take you to find a number between 1 and 1000 if I tell you "high" or "low" after each guess?
    10. I figured they were getting at a binary search, which is O(log n).
  7. What is the run time complexity of inserting into a heap?
    I have no idea. I'll guess n*log(n). I could have tried to figure this out, but I was having a brain fart and decided it was pointless to try and brazen it out. The actual answer is O(log n). Okay, okay. Really it depends on the implementation.
  8. How many direct children can a node have in a binary tree?
    0, 1, or 2.
The interviewer then told me she would pass on my answers and my resume to a hiring manager and that I would hear back in the next few days. The next morning she emailed me to set up a 45 minute technical interview.

Trying to get a job at Facebook? You do have an up-to-date profile on Facebook, right? After that, I would start by poking around at their careers site. I noticed they have a intriguing puzzles section that it probably wouldn't hurt to solve. Facebook has several recruiters on LinkedIn, so just do a search for "facebook recruiter" to get some contact information for a real person.

Wednesday, January 19, 2011

$20 Amazon gift card for $10

If you have been living under the internet equivalent of a rock, maybe you have not heard. Hopefully you read this before 8:00 eastern time on Thursday, January 20th. Acting on it can get you a free, quick, and easy $10. LivingSocial has a deal today where you can buy a $20 Amazon gift card for $10. I had to look around a bit for it. My default city was Lowell, but I could not find the deal there. I had to look at Boston deals.

Amazon is an investor in the company, which is how I think they are pulling this off. There have been 1,211,962 gift cards ordered so far. Do the math: that's 12 million dollars of free Amazon credit. And there is still eight hours left! Go get your piece of the pie.

Wednesday, January 5, 2011

Lazy post

I'm tired and still have a bunch of things to do before I go to bed, so this is what you get today:

Monday, January 3, 2011

MATLAB tutorial

I have mentioned before that many of the folks at my office use MATLAB. Since my office has historically been an "algorithms" shop, most of the ideas are prototyped in MATLAB before a software engineer (such as myself) implements them in a traditional programming language. I have picked up some MATLAB, but still felt I needed a better grasp on the tool. So I plunged into the help and online tutorials. Here are some nuggets I have learned in addition to my original MATLAB post:
  • MathWorks provides a good collection of MATLAB tutorials on their website. This includes links to other people's guides and their own audiovisual walkthroughs.
  • I liked a linked MATLAB walkthrough from MIT. It is fairly concise and covers most of what you need to get going, except for cell arrays (which is what I really wanted to learn better). The different entries in the table of contents link to a single webpage.
  • The main confusion I have with MATLAB is with the array notations. As a C programmer I have a certain way of looking at arrays, but someone brought up in the MATLAB universe doesn't even use the same vocabulary to describe things. Hence the difficulty. Here are some notes:
    • : (colon) - indicates a range, typically a domain
    • [] (brackets) - define a matrix or vector
    • ; (semicolon) - new row for matrix defined in brackets
    • () (parentheses) - indexes to a vector or matrix
    • , (comma) - indexing into next dimension of a matrix
    • .() (dot) - access named fields of a structure
    • {} (braces) - similar to bracket and parentheses, only internal structure is preserved
    Typing doc paren or help paren will bring up MATLAB's description of these operators.
  • Speaking of doc and help, they both are similar to the linux command man. doc opens up the help browser, whereas help prints out information at the prompt.
  • I would suggest using help and doc on a number of useful commands: path (where MATLAB looks for things, plot (make the fun graphs for which MATLAB is known), clear (disassociate a variable), and nargin (number of arguments to a function).
  • The Programming Roadmap on the MathWorks site talks about advanced function features. Use help/doc on varagin, varargout, and funfun. MATLAB can even have anonymous functions using @, but I doubt the scientists and work want me using λ functions.
  • Need/want to play with MATLAB but do not want to fork over private funds for a license? Try Octave!
I now feel much more confident in my MATLAB skills, or at least my knowledge of MATLAB resources. Hopefully I can put them to good use when given the opportunity.