Joining Facebook

For those who don’t follow my company blog:

GazeHawk Team Joins Facebook

I start at Facebook Monday.  As always I’m hoping I have the chance to blog more actively, though we’ll see how realistic that is.

To go along with the new job, I’ve moved my blog over from to, and made it look a little more professional. will be used to host my pet projects as they pop up.  Feedback/suggestions on the redesign are certainly welcome!

How to Catch a Cheater

Update: I wanted to explicitly mention that these homeworks were basically puzzles, which is why Googling was off-limits.

Update 2: Thanks gzak for remembering the actual name of the problem. It’s “Finkleberg’s 101 Game” and a copy of the actual homework is here.

There’s a story making its way around the web about a professor catching 1/3 of his class cheating and the fallout from it (everyone retakes the midterm, people who admit to cheating have to take an ethics course). It reminded me of something one of my professors at Carnegie Mellon did in one of my Freshman year CS classes. This is a from-memory recount of it, exact details are probably slightly off.

For context:

  • The early homeworks in this class were basically puzzles, where if you’ve seen the style of problem before you more or less knew the answer. The goal was to expose us to these types of problems and teach us how to think them through properly.
  • We were explicitly told that searching online for answers to homeworks was forbidden.
  • One of our last homework’s problems began with something like “Commonly referred to as The Glorblar Problem, …” (I don’t remember the actual word he used, it seemed completely plausible)

We get to class one day and wait for the professor to start speaking. Today he just starts running through slides silently:

  1. “As many of you know, one of my hobbies is catching cheaters”
  2. A picture of the last homework with the phrase “The Glorblar Problem” circled
  3. A screenshot of Google with “The Glorblar Problem” in the search box
  4. A screenshot of the Google results, with the domain of the first result (which had the problem and correct solution) circled
  5. The whois result for that domain, with the professor’s name circled (you can hear a collective gulp as half the room realized what was coming next)
  6. The apache logs from the webserver, along with blurred-out reverse IP lookups for the entries

Then he started speaking. He told us he had access to the login records from the school’s public machines as well. Anyone who Googled the result should confess and take a 0 for the homework, otherwise he would report them to the dean and they’d fail his mandatory class.

A ton of students confessed. A lot of them were sent the link from a friend and many claimed not to have used it, but nobody could deny that they were caught cheating by the letter of the law.

The moral of the story is don’t fuck with Luis von Ahn, he will wreck you (no, I wasn’t one of the students who cheated, but that was one of the more impressive hacks I’d seen during college).

tl;dr – My professor made a honeypot for cheaters by planting a Google bombed phrase in his homework.

Force a Canvas Refresh

When playing around with some canvas stuff I found an interesting bug in Chrome. Basically when you have a putImageData call inside of a setInterval loop, canvas does not refresh properly.

There’s a pretty simple hack to fix this: force the canvas to refresh every time you call putImageData. But how do you do this? There is no redraw function, nor any obvious way to force a refresh.

The trick is making a change to some property of the canvas element. Doing this in a way that forces a refresh every frame but won’t actually change anything for the user is not as obvious as you’d think.

Opacity isn’t actually visible with a sufficiently small delta, so it’s a good candidate. We just switch back and forth between two different opacities.

this.ctx.putImageData(img, x, y);
this.rebuild_chrome_hack = !this.rebuild_chrome_hack;
$('#canvas').css('background-color', this.rebuild_chrome_hack ? 1 : 0.999);

The Worst Paragraph Ever Written

Context: There’s an organization that sponsors Shabbat dinners. It’s really awesome: they basically pay you to feed your friends. That being said, they need a copywriter. Here’s a paragraph in the email they sent confirming my sponsored dinner:

As of Monday, July 19th, the new NEXT Shabbat program will begin providing new NEXT Shabbat’s with up to $14 per guest (maximum of 16 guests) for the first three meals a host registers after that date. After those three meals, hosts will receive up to $10 dollars per guest. As a returning NEXT Shabbat host, your meal-payment will be based on the number of meals you’ve held already. However, since you have a meal scheduled to take place between July 19th and August 19th, you will still receive $18 per-guest for that meal. Following that meal, if you’ve already held at least three meals, any meal registered after July 19th will only be eligible for a payment of $10 per guest. By joining with us as we make these changes to the program you will give many more people the opportunity to host and will enable thousands to participate in home-based Shabbat meals for the first time. If you’ve held less than three meals, any meal registered after July 19th will be eligible for a payment of up to $14 through your third meal. You can also see how many meals you have already hosted.

As always apologies for the lack of updates: I promise there’s a short (but major) update coming very soon, followed by more frequent posting (there’s a reason I’ve been so quiet lately).