eat, enjoy, explore

In November 2012, I gave a seminar about technical interviews
for students in CS50.
I didn’t realize that the video was on youtube until today, and it has almost 5000
views! I’m glad I can keep a memento of me teaching!

A note about the video: I usually use the whiteboard when teaching and I
write much neater than I do in the video. However, I had to use a tablet
for video recording purposes, and it’s really hard to write on a touch screen!

After taking 18 computer science classes at Harvard (17 in CS, 1 in EE),
I was curious to see exactly how many lines of code I have written
for assignments these past four years. I was also curious what the breakdown
would be for the different programming languages I’ve learned over the years.

After looking through the archives of my computer, I calculated that I wrote
197,717 lines of code (141,008 insertions, 56,709 deletions) for my
classes in the past four years! In fact, I believe this is actually
an underestimate. In this post, I’ll talk about how
I calculated this number, and assumptions I made when calculating this
number.

This past semester, I took ES50, Harvard’s introductory course in electrical
engineering. For our final project, my group decided to make a voice-activated
drink mixer! I was in charge of the coding component of the project.

The code is available on github.
To do the speech recognition, I
used the Chrome Speech API. Once I have the transcribed text, I send
the text to a local server, which figures out the drink that was ordered,
and then sends the appropriate times to open each of the bottles.
The server sends these times to the attached Arduino, which then
sends current to the appropriate solenoid valves for the designated times.
When activated, the solenoid valves allow liquid to flow through.

At Harvard, a “Teaching Fellow” is the equivalent of
teaching assistants at most other universities.
Technically, I’m a “Course Assistant” as the title
“Teaching Fellow” is reserved for graduate students, but in
many of the classes that I’ve taught, the undergraduates have
the same (if not more) responsibilities than the graduate
students. These typically include teaching section, holding
office hours, and grading.

Over the past three years, I’ve attempted to have an impact in
all of the classes I’ve taught, and hopefully that impact will
last after I graduate. Also, I’ve learned several lessons about teaching
computer science classes, and I have advice for current
or future undergraduates considering teaching.

This semester, I have the privilege of being a teaching fellow
for Harvard’s legendary operating systems class,
and I was tasked with writing the synchronization problems for
this year’s synchprobs assignment! The goal of these problems
is to get students to think carefully about the synchronization
primitives and data structures needed to solve highly concurrent
problems, avoiding the usual problems that come with concurrency:
race conditions, deadlock, starvation, etc.

I remember how fun these problems
were last year (forming little fellowships of the ring and piazza posts,
meant to mimic creating barriers and reader-writer locks), and
I wanted to make sure the problems were just as fun this year.
I was tasked specifically to write problems to mimic the
synchronization one would use to implement waitpid()/exit()
(how would you do it?) and the synchronization needed
between address spaces and the coremap when implementing
a virtual memory system in the third assignment. Given
these specifications, I came up with
Singing Cows and Hunger Deletion Games synchprobs!

Consider the following example from my data systems class, where I initialize
a directory to act as persistent storage for my database.

storage struct

123456

structstorage{charst_dbdir[128];// name of the db directorystructfile*st_file;// pointer to metadata filestructlock*st_lock;// protect addition of columnsstructcolumnarray*st_open_cols;// array of open columns};

This semester, I’ve been writing and leading bootcamps as the
Harvard Computer Society Bootcamp Manager. In the past, HCS has
had bootcamps on various topics including python, javascript, and git. Bootcamps are typically
targetted for students just starting computer science (fresh{wo}men, sophomores).

My goal this smester was to restart the bootcamps and to revamp the curriculum. In this post, I’ll talk about:

The bootcamp curriculum I designed

The typical workflow for a bootcamp

The design decisions that went into writing these bootcamps

Some high level results (pull request numbers and summary of testimonials)

I published my first Chrome Extension: Omnibox GDrive Search!
The extension allows you to search your google drive for documents and then jump directly to them from the omnibox! See the code on github.

In the omnibox, type gd and press TAB. Now you can enter your queries and jump directly to the file from the omnibox suggestions!

To use it, you must first authorize Google Drive metadata read-only access to the extension by following these instructions (see screenshots in extension link):

Go to chrome://extensions

Find this extension, and click “Options”

Click “Authorize”, and then click “Accept” to grant the extension access. This will redirect to a blank page. Close it, and refresh the options page.

If you see “You have already authorized this extension!”, then you can now search!

By far, the most difficult part of the extension was understanding authorization with Google Drive. The extension is a bit
buggy and lags a little because the extension must renew the authorization with Google Drive every 15 minutes or so.
To get around this, the extension only requests authorization on the first use after the expiration and will
redirect the user to the options page.
Thus, if you’re using the extension for the first time in a while, it may take ~3 seconds before search results come back.

For my CS283: Computer Vision Final Project, I created an application to control Google Maps
using your hand and a webcam.

It uses the Chrome API to access the webcam, and frames are sent to a Tornado server that
runs the hand tracking pipeline, annotates the frame, and sends back the displacement
vector to update the view of the map. I am using OpenCV for it’s Haar Cascade libraries.

You can also view the paper
I wrote to describe the process I used in the pipeline. Below is a summary of the problem
statement and the stages in the pipeline.

Problem Statement

Given a poorly trained Haar Cascade Classifier (250 positive samples and 100 negative samples) to recognize hands,
this project assembles a pipeline to improve the quality of the tracking. These steps include:

Face detection and removal of faces.

Background subtraction.

Use a simplified Kalman-Filter-esque technique to estimate the bounding box of the hand. This assumes that a hand moves in a smooth manner.

Use our hand classifier to detect the largest hand within the bounding box.

Compute the optical flow of points within the bounding box using Lucas-Kanade.

Use the optical flow and the measured position of the hand to correct our Kalman-Filter estimate.

Inspired by other commmand line libraries, I decided to make my own Java flag
command line library here. It makes use
of Java’s Reflection capabilities to fill in the values of flags at runtime.
The library is fairly simple to use–it requires only declaring a static
field, and one invocation to Flags.parse in the main method of the
application. The library offers support for various wrapper types as well
as collection types.

As an example of using the library, you declare a flag using the
annotation @FlagInfo with the desired flag names and values.

MyApp.java

1234567891011121314151617181920212223

importme.kennyyu.flags.Flag;importme.kennyyu.flags.Flags;importjava.util.List;publicclassMyApp{@FlagInfo(help="maximum number of threads to use",altName="n")privatestaticfinalFlag<Integer>maxNumThreads=Flags.valueOf(3);@FlagInfo(help="use real logger",altName="r")privatestaticfinalFlag<Boolean>useRealLogger=Flags.valueOf(false);@FlagInfo(help="input list",altName="l")privatestaticfinalFlag<List<String>>inputList=Flags.valueOf(newArrayList<String>());publicstaticvoidmain(String[]args){Flags.parse(args);System.out.println(maxNumThreads.get());System.out.println(useRealLogger.get());System.out.println(inputList.get());}}

Then you provide flag values at the command line like so:

Passing flags at the command line

1

java MyApp --maxNumThreads=5 --useRealLogger -l=foo,bar,baz

All classes referenced from the main class with flags will be available as options.

In addition to learning how to use Java’s Reflection capabilities, this
was also an exercise in learning how to use Maven to build and deploy my
project. I am using a github project
as a maven server.

See the README.md in the github directory for more information on how to
use it and install the library.