Blog

Ramblings on code, startups, and everything in between

This summer we have an engineering intern from Tufts University (go Jumbos) joining the team. He’ll be working on internal projects including Rotorobot and a couple of new ideas. Here’s Phil in his own words.


Could you tell us a little bit about yourself?

Sure. I’m from Haverhill, MA originally so I’d call Boston home. I’m currently attending Tufts University and pursuing a BA in both Computer Science and Cognitive Science. At Tufts, I’m also working with the linguistics department on a couple of research projects surrounding the structure of the mental lexicon.

Where can we find you outside of work and school?

I’ve been playing Rugby at Tufts for the past few years so probably on the pitch, or maybe relaxing in my hammock with a book and an IPA.

What’s been the hardest part about learning PHP and Symfony2?

The hardest parts about learning Symfony2 have been recognizing how the many components of the framework fit together, and allowing the framework to take care of some of the heavy lifting. It was a leap to go from hacking away with straight PHP to designing an application, keeping both structure and modularity in mind.

Which computer science course has helped the most in transitioning to “real world” programming?

The computer science curriculum at Tufts has definitely helped me make the transition into real world programming. In particular, the course: Comp20 – Introduction to Web Development has given me exposure to the many tools that are used in the creation of web applications.

What technology/language/framework/etc. are you excited to learn more about?

This summer I’m excited to learn more about back end programming, the SQL language in particular as well as learning Bash more in depth so I can improve my use of the shell.

So far, what’s your favorite lunch spot been?

My favorite lunch spot so far has definitely been Orinoco in Harvard Square. I will buy some of their hot sauce by the summers end.

And finally, movie quote you live by?

“Crying: Acceptable only at funerals and the Grand Canyon”

For the uninitiated, Orinoco has an authentic Venezuelan hot sauce which has been known to destroy even veteran hot sauce connoisseurs. Here’s Phil deciding to take the plunge:

Posted In: General

Tags: ,

There’s plenty of opinions about the efficacy of technical interviews and an equally large amount written on the topic. Personally, I don’t think there’s much value in putting someone in front of a whiteboard and seeing if they can regurgitate how merge sort works (I couldn’t) and there’s plenty of blog posts arguing that point. Something that I do think is valuable is trying to gauge how well someone really knows a language that they’ve listed on their resume or used in a project. And recently, with the surging popularity of Node.js and “coding boot camps” it seems like every resume we’ve seen mentions a proficiency in Javascript.

So how could you suss out someone’s knowledge of Javascript? I poked around on Quora a bit and ran across few top voted related questions: What are some good JavaScript interview questions? and What are the most important JavaScript concepts to know for a job interview?. Skimming through them know, the questions are mostly focussed on “tricks” which isn’t very useful and the list of skill is a bit underwhelming as well. Ok, so what questions can we ask?

Prototypical Inheritance

Prototype based inheritance is woven into the fabric of Javascript so I think chatting about it will reveal a lot about a candidate. You’ll get a sense if they generally “get” how object oriented programming works and then more specifically how Prototype inheritance in Javascript works.

Looking at code, a good starting point would be talking through the difference between “Duck” in the following sample:

From there, there’s the natural philosophical discussion about how Javascript doesn’t have classes but instead objects are copied from existing ones down the prototype chain. That seems to naturally lead to a discussion of how you’d accomplish something like (don’t in production):

First Class Functions and this/bind

First class functions are heavily used Javascript in idiomatic Javascript so they certainly deserve some discussion. At a high level, describing first class functions is fairly simple. Functions are treated like any other object so that they can be passed as arguments, inserted into arrays, and all the other things you’d normally be able to do with objects.

Jumping back into code. An interesting first discussion would be “How could you implement a switch statement without using ‘if’ statements or a ‘switch’ block?”

Getting a bit fancier, another task would be to implement a “filter” method similar to the one found in lodash/underscore. “filter” accepts an array of elements and a callback and returns the elements which return “true” when passed to the callback. So as an example:

The big change is in our “filter” we’re changing the semantics so that “this” is the value from the list being filtered. Watching how someone approaches and implements this will reveal how deeply they understand Javascript’s function semantics.

Async and Promises

Last up would be touching on Javascript’s model of asynchronous programming followed by a Promise implementation (q, jQuery, etc.). The difference between asynchronous code and synchronous code is large enough that it probably could fuel an interesting discussion. A couple of interesting points to touch on:

  • At a high level, what is the difference between asynchronous and synchronous code?
  • In a single threaded environment like a Javascript engine, why would an asynchronous model be beneficial?
  • Typically, why would an implementation using Promises be more flexible than just a callback?

Jumping back into some code. A good first task would be to execute a set of asynchronous operations in series – Another interesting task would be to implement a tiny API using regular callbacks and then using a Promises library.

Anyway, just a couple of quick ideas. I’m still new to the recruiting and interviewing game so I’d love any feedback or comments!

Posted In: Javascript

Tags: ,

We’ve been doing a bit of AngularJS work (more on that later) recently and true to its reputation there’s an “Angular way” to accomplish most things. Interestingly, one area where I couldn’t find a “one true way” was how to facilitate mixins between controllers or scopes.

Quickly taking a step back, a “mixin” is a form of horizontal reuse that allows two objects to share code without necessarily sharing a common ancestor in an inheritance chain. With concrete examples, you might have a Dashboard and Billing controller which need to share formatting logic but nothing else you’d want to use mixins vs. traditional inheritance. In traditional object oriented language mixins are typically referred to as Traits.

Anyway, back to AngularJS. Let’s say we have some simple logic that we want to share between two scopes:

It’s a contrived example but the “idea” is that you want to share the “selectAnswer” and “getAnswerClass” functions between $scopes of two unrelated controllers. After doing some research, it seems like the cleanest way to do this in Angular is to create a service that contains the functions, inject that into the controller, and then use angular.extend() to add them to the $scope as needed:

And that’s pretty much all there is to it. I’m pretty new to the Angular dance so I’d love any feedback!

Posted In: Javascript

Tags: ,

As we continue to expand in 2015 we’re looking to add another developer to our team.  Currently we’re seeking a junior level engineer to join us!  A few attributes of a person that we’re looking for:

  1. 1-2 years of experience with MVC based frameworks (we use Symfony2)
  2. 1-2 years of real world experience
  3. Comfortable talking directly with clients, no account managers here!
  4. Works well in a team environment, but also self-managed.

A few of the perks:

  1. Flexible hours
  2. 100% paid health care (PPO)
  3. 401(k) with matching
  4. Company outings

For some more detailed information on the job please visit the posting.  If you are, or know, a developer who is looking for a new opportunity lets connect!

Posted In: General

Tags: ,

As promised, here’s the follow up on my previous post Javascript: Using Canvas to cut an area of an image where we looked at how to use Canvas to cut a mask out of an image. To quickly recap, in the last post we looked at how to crop a patterned mask out of an image using a HTML5 Canvas. Using this technique, you’d be able to provide an image that looks something like:

So how do you go about making a puzzle? You can see the end result at HTML5 Canvas Puzzle and the code is online at https://github.com/Setfive/setfive.github.com/tree/master/canvas_puzzle.

As it turns out generating an arbitrary puzzle programatically is reasonably complicated. The best explanation I could find on how to accomplish this is at https://www.allegro.cc/forums/thread/586750/603411#target. Conceptually, the process looks straightforward enough and you could probably manually do it on a whiteboard. Unfortunately, the issue I ran into with this approach is that drawing bezier curves and splines programmatically on a Canvas is a bit involved. I also don’t have a background in vector graphics so I was getting stuck in the weeds drawing lines.

Discounting generating the puzzle entirely on the fly, an alternative approach would be to use a fixed set of available pieces and then “fill in” a grid depending on how large the image area is. Conceptually, the idea is to construct a closed grid of pieces where some number of the pieces can be repeated and then repeat those pieces as needed to cover the target image. The templated pieces I used are in /puzzle_pieces/.

Technically, I decided to use fabric.js to facilitate Canvas interaction along with lodash.js and of course the ubituqous jQuery.

Walking through the code, the steps to build a puzzle are fairly straightforward:

  1. Load images: The first step is to load all the template images and target image so that they’re available to use on a Canvas. Since jQuery is available, one approach is to create a deferred for each image, resolve it as the image loads, and use $.when to wait for all of the images to load. See here for example.
  2. Build pieces grid: Next you’ll need to figure out how many repeated pieces you need to fill into the grid. One issue here is that since the puzzles need to fit snuggly the image dimensions of a given piece won’t be what you need to use to calculate the grid. Because of this, I ended up with a bit of goofy code for this.
  3. Create image masks: Once you have the number of pieces to create you’ll need to cut masks for each piece out of the source image and create fabric.js objects for them. See copyImageChunk.
  4. Place masks: Placing the “pieces” is also complicated because of the dimension issue above. See kludgy code.
  5. Shuffle and track movements: Finally, you just need to shuffle the positions of the images and then track their movement to report a “correct” position.

And that’s about it. One other “trick” is that you can use Window.requestAnimationFrame to avoid locking the UI when you’re creating the masked images since it’s a compute intensive task.

Anyway, as always questions and comments welcome.

Posted In: Javascript

Tags: , ,