Blog

Using SVG and CSS to create Pacman (out of pie charts)

5/23/2017

Lea Verou has a wonderful talk about various techniques we can use to create a pie chart purely in HTML/CSS. The techniques are clever and interesting, but pie charts are a little boring. So let's modify one of her ideas and create Pacman instead. ...

How to solve the Impossible Escape puzzle with almost no math

2/12/2015

You and a friend are imprisoned but have a chance for freedom. To earn it, you must walk alone into a separate room where a chess board is laid out with a coin per square randomly showing heads or tails. You are shown a particular square on the chess board, and are then allowed to touch one coin to flip it. Then you must leave without making any contact with your friend. Your friend enters the room and must pick the square which was pointed out to you. You and your friend may discuss a strategy before you enter the room. ...

How to make iterators out of Python functions without using yield

11/2/2013

The built-in iter() method in Python 2.2 and later hides a neat trick which is not well-known. Typically iter() is used to return an iterator from an iterable object: ...

How to globally customize exception stack traces in Python

10/22/2013

The Python language has some useful flexibility when it comes to exceptions. Programmers want as much relevant information as we can get when our code does something unexpected. Python's default behavior for an unhandled exception is to print a stack trace, the error type, and the error description. This is sent to sys.stderr (typically, the console), like this: ...

Is your tango embrace really too firm or too relaxed?

3/8/2013

Followers, you may be familiar with the scenario where you dance with one leader, and receive feedback that your embrace is too firm, but when you dance with another leader, the same embrace is too light. So, which is it? ...