wtf nth

Mar 28

Finding Technical Partners in College

Someone recently asked me how they could find technical people to work with at Cornell. I decided to post my response so others could benefit from it as well, as I suspect it’s more broadly applicable.

Timing is important. At the beginning of the semester, everything seems happy, and people are full of energy. People may still be looking to fill gaps in their schedules. If they want to get independent study credit for working on your project, they need to apply earlier in the semester. (Ideally, you’d talk to people right before the semester begins, while the pre-prelim idealism is at its peak.)

Towards the end of the semester, the advanced CS courses are slugging one brutal problem after another at students, and some people will be bordering on burnout. Getting them to take on new responsibilities then will be harder.

Some people look for side projects over summer or winter breaks. It may be easier for you to recruit people to work then as opposed to during a semester.

Most pitches tend to be underwhelming on the details. When someone writes something like this:

“Hi! I’m a business major looking for someone to help me program a site for my new startup. It’s a social networking site with Facebook like features, geared towards college students. I’m hoping to get the initial prototype done in a few weeks. If it works out, there is a potential for a longer term partnership.”

What hacker-types read is:

“Hi! I’m a business major who learned about programming by watching The Social Network. I want to pay you in dirt to clone Facebook for me, and I expect it to be done in an inhumanely short period of time. There’s nothing particularly inventive or original about my idea, so when no one is interested in the finished product, I will abandon it, making the entire exercise a complete waste of your time.”

To make a good pitch, be sure to include:

Just working with coders can be tough for one who lacks a technical background. For instance, it’s hard to tell if the coders are incompetent/lazy or the task you’ve given them is really tough.

If you want to understand how techies think, I highly recommend reading Hacker News. This deck offers a useful perspective on finding technical people as well.

[Cornell specific: Make your pitch on the ACSU or ISSA listservs, or in person at their meetings, or at classes like CS 2110 and 3110, and INFO 2300 and 3300. The TA staffs of those courses will be of generally high quality, as well. You may also wish to seek out company student reps; they tend to know people]

Jan 18

GeoCoordinateWatcher.Position has NaN values

I was trying to get the current position of the Windows Phone:

        new GeoCoordinateWatcher(GeoPositionAccuracy.High).Position;

Position’s fields are almost entirely NaN. To remedy this, call Start() first:

        GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
        watcher.Start();
        GeoPosition<GeoCoordinate> geoPos = watcher.Position;

Then your values will be as expected.

Jan 07

On Campus Recruiting (at Cornell)

In an earlier post, I wrote about how to hire college kids once you get to the on-site stage and make an offer. In this post, I’ll discuss the beginning of the process. My perspective on this comes from watching companies recruit myself and other tech students at Cornell since Fall 2008. (I’m not sure how much of this is generalizable to other schools.)

Career Fairs

At Cornell, the process is often initiated through career fairs. There is one tech career fair each semester. Additionally, this year Cornell sent two bus-loads of tech students to NYC for NextJump’s SA500 career fair for east coast companies, hosted at the stock exchange. There will also be a startup career fair in Ithaca in February.

These career fairs are crucial - students typically go in to them and talk to the big names they’ve already heard of (Microsoft, Apple, Amazon, Facebook, etc), but will also wander about and talk to previously-unknown startups that have a cool looking booth / demo / swag. Even if they don’t end up applying to all these companies, students feel that this is a good way to get a sense of what’s out there. If your company doesn’t directly target mindshare of tech-oriented college students, like OPower or Akamai, it may be necessary to more aggressively get your name out there than a consumer-oriented startup, like Yelp or Instagram.

Students take time out of their busy schedules, often skipping class, to come to career fairs. Big names like Google or Facebook will be sought out by students, but smaller companies that students may not have heard of will need to work harder to get people to visit their booth. When a student is just floating between booths, they decision of which to visit will be fairly superficial, based on an immediate gut reaction rather than any rational analysis of your company. A good-looking booth filled with awesome swag and attractive/intelligent looking people can really help here.

Shot Glasses and T-shirts: What to Have in Your Booth

Students will circulate throughout the career fair, greeting one another. (Don’t ambush students who are just milling around and talk at them for 40 minutes without giving them a chance to break away.) As a student, many other students I encounter fall in to the “we see each other in class but don’t otherwise really hang out” category. For these encounters, talking about which companies have the best swag is a great conversation starter. As a recruiter, whatever swag you make visible to students walking by will be broadcast peer-to-peer throughout the rest of the crowd. If your swag is great, you can cause people to seek you out, the same way they seek out the respected tech giants. (At SA500, ZocDoc quickly drew attention to itself by handing out $100 to anyone who could answer their interview questions. People were going to try it even if they didn’t think they’d be interested in ZocDoc, which gave the CEO a chance to make his pitch. In terms of eye-catching swag, a row of $20s works quite well.)

What constitutes “great swag” is a matter of taste, and largely depends on what image you want to portray for your startup. My personal favorite swag is a brushed green glass shot glass from Palantir. Pong balls are also a classic. (Better to stay away from drug paraphnelia - ha.) Many startups advertise themselves as a laid-back alternative to the drab, stuffy business world. Cornell is all about “work hard, play hard”, and if your startup can provide both, it will appeal to students. T-Shirts are also essential. At the Fall 2011 career fair, Dropbox spammed t-shirts to anyone who walked up, and since then you can’t walk across the engineering quad without seeing someone wearing one. This is a great way to get your name in front of students who may not otherwise have heard of you.

In addition to swag, it helps to prepare a small printed card that advertises working at your company. Students can read this while they are waiting in line to talk to you, thus saving you from having to repeat “we are based in Seattle, WA” a million times, and they can bring the cards home with them, to jog their memory after the career fair. A long day of talking to employers can make them all blur together, but having some specific written points about each one can help keep things straight. This card answer the following questions:

If a student has never heard of your company but is intrigued by your awesome swag, the first question on their mind will likely be “what exactly do you do?” Having a demo really helps here. Even if your app’s value only becomes apparent after the user has been using it for a while, like Trello, log in to the app with a fake user so students can play around with it.

Bring Alums

Bring alums of the school you’re visiting from your company to staff the booth. Younger alums may still have personal connections to the students. If a student sees, “Hey, that girl at the Moat booth was my great TA for CS 2110”, he’ll be more likely to go up and talk to her, and to think highly of the company in question. Having booth staffers be alums of the school you’re visiting gives them an instant common ground with candidates.

Finding Interesting Candidates Amongst Career Fair Contacts

If you’re recruiting coders, don’t be afraid to ask technical questions right during the initial contact at the booth. It shows that you are serious about getting the best people. I would structure it something like this:

Talk to the candidate for a few minutes to get a general sense of who they are.

Can they solve FizzBuzz in less than two minutes? If yes, continue, else thank them for their time and discard their resume.

Can they solve a more difficult question (should take around 10 minutes)? If yes, put them on the “special list”, else throw their resumes in the heap.

At the end of the day, take the top 10 candidates from the special list, and invite them out to dinner. (Your alum co-workers should be able to recommend somewhere good to eat. The choice of where to eat will also contribute to the image your company gives.) Use the time at dinner to get to know them better, and to give them a chance to learn more about your company. It should be fun and relaxed - don’t ask them any interview-style questions, but it’s fine to casually discuss the technical details of the students’ latest projects.

At this point, it’s up to however you structure your process, but as long as you’re on campus, I’d recommend staying a few extra days and doing on-campus interviews with as many promising-looking candidates as possible. At Cornell, the Campus Career Services office provides interview rooms for visiting companies. I personally find in-person interviews to be much more pleasant than phone screens, and going to NYC or further for a first-round onsite is a pain, unless I’m incredibly enthusiastic about the company.

Other Campus Events

Big name companies often have events like tech talks / info sessions, ice cream socials, or trivia nights. In Fall 2011, a bunch of companies set up video game stations in Duffield for a more informal way to interact with students. Tech talks are a great way to show off your engineering accomplishments, and give students a sense of your company’s software development philosophy. However, Cornell students are typically extremely pressed for time, so if your brand isn’t as well known, it may be tough to attract a big enough crowd to fill an auditorium. It’s hard to go too far wrong with anything that involves giving away free food that tastes good. (People joke that career fair week is the “ACSU meal plan”.)

Side note: for some reason, even big companies with plenty of money insist on buying shitty pizza from Domino’s for their tech talks. Why? Does anyone really enjoy it?

Bigger companies often have student ambassador programs, where they pay on-campus students a nominal fee to represent them and organize events year-round. I’ve never done this, but some people enjoy it.

Facebook recently started doing on-campus hackathons. They bring a bunch of engineers, who help students complete projects in 24 hours, then award prizes to the winners. This is a great way for students to form personal relationships with employees, and it gives employees a way to see students’ thought process first-hand. For Facebook, it also allows them to showcase their “hacker culture”.

Really, as long as your company lets its culture shine through, everything should be fine. Unless you use MUMPS. ha.

Dec 29

Advice on hiring smart college kids

I recently finished interviewing for a full time position at 5 different companies: one tech giant, a mid-sized company, and three startups. Some of the startups are still trying to optimize their process for hiring college kids. To that end, here are some of my thoughts as an applicant in the process.

Most people want to work with the smartest co-workers possible. I have been burned several times by group projects with bad people, so I am very interested in not repeating those experiences in the workplace. Thus, I am more interested in a job I perceive as being harder to get. One company that gave me an offer was enthusiastic about me during interviews to the point of being off-putting. At another company, the hardest technical question I got was fizz buzz. This made me a bit skeptical about the quality of the company’s engineering if anyone who can answer fizz buzz can get a job.

Another company asked me “how much do we need to pay you to convince you to work here?” at the end of the day of interviews. I’d say even that borders on coming on a bit too strong.

However, this doesn’t mean it’s a good idea to neglect candidates. After an offer is extended, there may continue to be back-and-forth for the candidate to get more information about the company. Special treatment here, like letting the candidate speak to founders and investors, can suggest to the candidate that the company will continue to deeply care about her after she accepts the offer. Conversely, if the recruiter seems disorganized and can’t even tell you the vesting schedule for your equity during a phone call to discuss offer details, it reflects poorly on the entire firm.

Choosing first job out of college can be quite stressful - the search space is much larger than at earlier points in the candidate’s life, and some people may fear that their next step will make or break their career. To help with this, consider connecting a candidate you’ve made an offer to with new grads at your company. (Ideally, it would be someone from the same program as the candidate.)

Dec 20

Lessons Learned from Corpionage

This semester, I worked on Corpionage, a Facebook game for people who like to mess with their friends. I thought it turned out pretty well, but there are a few key take-aways.

Our general architecture:

Server, UI, and Engine

The server is Google App Engine, the UI is GWT, and the Engine is PlayN. (More detail)

  1. Automated testing is non-negotiable. In the last few weeks of the project, a bug fix was just trading a bug we knew about for one or more that we didn’t. We had automated testing for the backend, and it was the most stable part of our codebase.

  2. Tools add potential for error. Maven and GWT gave us many issues. A great deal of engineering time was wasted trying to fix dev environments. We ended up dropping maven, which drastically increased engineering time available to actually write code.

  3. People over-estimate their own skill. Bad coders produce negative work and drag down the team’s morale. If possible, make repo write privileges predicated on some level of code quality.

  4. Events are pretty nice. Our engine, UI, and server communicate with each other largely through events. Particularly in a game where you can have many things happening that different parts of the code are interested in, it’s really great to just publish an event that anyone can consume.

Our events were identified by a string key. This allowed us to avoid making a new class for each distinct event:

public class PositionEvent extends LevelEvent {

  // ...

  private int x;
  private int y;
  private Direction direction;

  public PositionEvent(String key, int x, int y, Direction direction, int levelIndex,
      long owningPlayerId) {
    super(key, levelIndex, owningPlayerId);
    // ...
  }

  // ...
}

To fire an event:

      PositionEvent showInvader =
          new PositionEvent(DefendController.SHOW_INVADER, x,
              y, direction, levelIndex, currentPlayerId)
      GameHost.getInstance().dispatchEvent(showInvader);

DefendController.SHOW_INVADER is the key that identifies this specific event. There are other keys that also use PositionEvent, which save us the pain of making a bunch of empty classes:

public class ShowInvader extends PositionEvent { }
public class CameraCaught extends PositionEvent { }
public class WorkerCaught extends PositionEvent { }

Then, to register for an event, you’d do:

dispatcher.addEventListener(this, SHOW_INVADER);

@Override
public void eventRecieved(GameEvent event) {
    // cast event to PositionEvent and handle appropriately
}

One possible source of error is that it’s possible that an event other than PositionEvent will be created with key SHOW_INVADER, and code that depends on this for casting will crash.

Another issue is that if you don’t want to make a new anonymous inner class for each event type, you frequently end up with handlers something like this:

  @Override
  public void onEvent(GameEvent event) {
    PlayerDataEntity player = PlayerDataEntityUtils.get().getCurrentPlayer();
    if (event.getKey().equals(BuildResponseEvent.BUILD_RESPONSE)) {
      handleBuildResponse(event, player);

    } else if (event.getKey().equals(DeleteResponseEvent.DELETE_RESPONSE)) {
      handleDeleteResponse(event, player);

    } else if (event.getKey().equals(HarvestDeskEvent.HARVEST_DESK)) {
      handleHarvestDesk(event);

    } else if (event.getKey().equals(PlayerEntity.FILE_STOLEN)) {
      handleFileStolen(event);
    }
  }

Anonymous inner classes are a bit bulky, but are an unfortunate necessity because Java doesn’t allow functions as first class members of the language.

Corpionage was a lot of fun to make, but there were definitely many “learning experiences” along the way.

Dec 19

Weka’s API is Cumbersome

I’ve only used Weka a bit, and it appears to be an impressive machine learning toolkit. However, its API is quite a pain to deal with.

Consider the following code that I wrote, which translates from one representation of an example to Instance, used by Weka:

public static Instance getInstance(WeatherLabeledFeatureVector featureVector, Instances instances) {
  Instance inst = new DenseInstance(instances.numAttributes());
  for (int i = 0; i < instances.numAttributes() - 1; i++) {
    inst.setValue(instances.attribute(i), featureVector.getValueAt(i));
  }

  // what is the purpose of this?
  // If you try to setClassValue() without setting a DataSet, it crashes.
  // Why does the Instance need to know what Instances it's part of? -nth
  inst.setDataset(instances);

  inst.setClassValue(featureVector.getLabelForWeka());
  return inst;
}

(All other code in this post comes from Weka.)

It seems that setting the class value of an instance should be a fairly simple operation. However, if you do this without calling setDataset(), it crashes. Why does the instance need to know about the data set it’s part of? What if it’s part of several data sets? What if I don’t want to specify the data set at this point in the code?

The constructor for Instances requires an ArrayList:

public Instances(/*@non_null@*/String name, 
       /*@non_null@*/ArrayList<Attribute> attInfo, int capacity) {
    // ...  
    HashSet<String> names = new HashSet<String>();
            // ...
}

That’s a pain. It’s almost always better to code to interfaces instead of implementations. What if I had a different List implementation I wanted to use? I would be out of luck. Moreover, that HashSet line could be rewritten as:

Set<String> names = Sets.newHashSet();

I know that would introduce a dependency on Guava, but Guava is so fantastically useful that it seems worth it.

Code that looks like this is repeated throughout:

if (instance.classAttribute().isNominal()) {
handleNominal(instance.classAttribute());
} else if (instance.classAttribute().isString()) {
handleString(instance.classAttribute());
}

Perhaps this design could be simplified through use of inheritance and overloading:

handle(instance.classAttribute());

    // ...

public void handle(NominalAttribute attr) { }
public void handle(StringAttribute attr) { }

Using a bunch of ints instead of enums reduces type safety and readability:

/** combination rule: Average of Probabilities */
public static final int AVERAGE_RULE = 1;
/** combination rule: Product of Probabilities (only nominal classes) */
public static final int PRODUCT_RULE = 2;
/** combination rule: Majority Voting (only nominal classes) */
public static final int MAJORITY_VOTING_RULE = 3;
/** combination rule: Minimum Probability */
public static final int MIN_RULE = 4;
/** combination rule: Maximum Probability */
public static final int MAX_RULE = 5;
/** combination rule: Median Probability (only numeric class) */
public static final int MEDIAN_RULE = 6;

(Although the comments for what each rule mean are admirable.)

What is this, C? Why split variable declaration and assignments?

public Enumeration listOptions() {
  Enumeration   enm;
  Vector        result;

  result = new Vector();

  enm = super.listOptions();
  // …
}

Ternary conditions are great:

if (dist[index] == 0)
  result = Utils.missingValue();
else
  result = index;

Becomes:

result = dist[index] ==  0 ? Utils.missingValue() : index;

Also, I generally tend to always put brackets in control flow statements, so there’s no risk of adding another line accidentally:

 if (dist[index] == 0)
   result = Utils.missingValue();
 else
   result = index;
   foo = bar;

Throwing Exception is never a good idea. If you catch Exception, you may catch all sorts of issues that aren’t expected:

/**
* ...
*
* @param forPredictionsPrinting varargs parameter that, if supplied, is
* expected to hold a weka.classifiers.evaluation.output.prediction.AbstractOutput
* object
* ...
* @throws Exception if model could not be evaluated
* successfully
*/
public double[] evaluateModel(Classifier classifier,
                           Instances data,
                           Object... forPredictionsPrinting) throws Exception { /* … */ }

This interface also takes arguments of type Object, but specifies that they must be of a specific type. The whole point of Java’s static typing is that constraints like that can be encoded at compile time instead of run time.

Finally, classes fail to use get*() as a naming convention for getters, which makes it harder to learn the API. If you’re working with Google code, and you’re not quite sure how to get what you’re looking for, if you type obj.get in your IDE, you can be confident that the autocomplete will show you all the getters.

Weka is a great way to quickly drop in some machine learning for a project. But coding to it is a bit of a pain that could easily be cleaned up through adherence to best practices for clean code.

Dec 14

I Wish Java Had Good Generics

Do you see the problem with this code?

// map from url as a string to content for that url
// apparently URL.equals() is bad:
// http://javaantipatterns.wordpress.com/2007/11/24/comparing-urls-with-urlequals/
private static Map<String, String> urlCache = Maps.newHashMap();

private static String getURLContent(URL url) throws IOException {
  if (urlCache.containsKey(url.toString())) {
    return urlCache.get(url);
  }
  // ...
}

I wish it wouldn’t even compile.

(Problem: using url instead of url.toString() in get())

Oct 20

GWT DeferredBinding fails at runtime

I had a UiBinder component for whom deferred binding in compilation went fine, but failed in runtime. Turns out the constructor was throwing an exception at runtime. Fixing the exception also fixed the runtime failure.

NullPointerException when initializing GWT’s UiBinder widget

I have a simple Composite that uses UiBinder. GWT was crashing on the following line:

public StartView() {
    initWidget(uiBinder.createAndBindUi(this)); // NullPointerException
}

StartView.ui.xml:

<g:VerticalPanel>
    <g:HorizontalPanel>
        <comp:FloorPicker />
        <g:HTMLPanel ui:field="gamePanel" />
        <comp:BuildMenu />
    </g:HorizontalPanel>
    <comp:FriendsPlaying />
</g:VerticalPanel>

The composites in comp were ones I had defined myself. They were simply empty composites:

public class FriendsPlaying extends Composite { }

Apparently GWT doesn’t like this. Solution: fill them out with the UiBinder boilerplate, and everything will work fine.

Sep 05

You CAN change the referrer header on WP7

There are a few threads complaining that you can’t set the referrer header on an HTTP request from Silverlight in WP7:

HttpWebRequest and Referer field on a WP Silverlight App

Odd behavior with the Image control and the HTTP Referer Header

httpwebrequest and referer header

However, it’s currently possible relatively easily:

WebClient webClient = new WebClient();
webClient.Headers[HttpRequestHeader.Referer] = "http://foo.com";

If your calls to a web service are failing on the WP7 and not in a browser, this may be the cause. Silverlight on the phone automatically sets the referrer to be the installation on the phone:

Referer: file:///Applications/Install/ ... /Install/

Some web services consider this to be an ill-formed request.