Open in nbviewer Bookmarklet

Last week I made a Chrome extension that opens your current page in nbviewer. This isn’t ideal, though, since it is limited to people who use Chrome. Today I learned about bookmarklets, which are little bits of JavaScript that live in browser bookmarks (thanks Ethan). The Chrome extension is just a little bit of JS so it was easy to adapt into a bookmarklet. To use this bookmarklet just make a new bookmark (call it whatever you want) and copy this code into the URL field. Once you have the bookmark just click on it while you are on any page that can be loaded by nbviewer.

Open in nbviewer Chrome Extension

I got tired of pasting URLs into nbviewer so I made a Chrome extension that will try to load your current page via nbviewer.

For example, if you are at you can click the “Open in nbviewer” extension button and it will load in a new tab. It also works for URLs ending in .ipynb.

You can download the extension from the Chrome Web Store and see the code on GitHub.

I took the extension icon from the nbviewer favicon, so thanks to them for that! Thanks also for making something as awesome as nbviewer, it’s getting so I couldn’t live without it!

Teaching with the IPython Notebook

For a few months now I’ve been using the IPython Notebook as my primary teaching tool for Python topics. Within Software Carpentry we’re also switching over to using the Notebook for both in-person bootcamps and our online repository of material. Ethan White and I put together a post on this topic on the Software Carpentry blog and now Titus Brown has blogged with his own thoughts. We’ve put in a PyCon proposal for a panel on this topic in 2013.

The IPython developers have to be given a huge amount of credit for putting together the Notebook and the rest of IPython. The Notebook especially is quite a feat: a top notch research/engineering/teaching tool all in one. And they aren’t resting on their laurels, they have a ton of ideas in mind for the Notebook in the future, including a slide-show mode. I’m definitely looking forward to seeing what they’ve got!

As with many open source projects, the IPython developers struggle to find the time and funding to write their software. If any open source project is helping with your job or your research you can easily help by citing the software in your papers and in public on social media or blogs. This gives the developers more ammunition the next time they’re writing grants, so please make your support known!

Job Search

That’s right I’m looking for a new job! I’m being picky though. I’ve already got an awesome job in scientific Python that’s not in California, so I’m looking for a position that is in California. I’ve already got a couple of good leads at San Francisco tech startups (wish me luck!), but if anyone knows of other positions using Python, especially supporting scientific work with Python, I’d appreciate a pointer! Thanks!

A little about me:

See more in my resume and look me up on GitHub, Google+, Twitter, and Alpha. Email me at jiffyclub .at. gmail .dot. com.


This week I was in a job interview and one of my interview questions turned into a pretty interesting puzzle. I was asked the following question:

Assume a character encoding a = 1, b = 2, c = 3, … , z = 26. Given a string of numbers (e.g. '123456'), figure out how many different ways that string could be decoded.

I didn’t arrive a complete solution in the few minutes I had during the interview but I kept thinking about it afterwards because I couldn’t shake the feeling there was really a math problem here, not just a programming problem.

The difficult part of this challenge is figuring out how many decodings there are when there are overlapping possible groupings of numbers. For example, the string '111' can be decoded as ['1', '1', '1']['11', '1'], or ['1', '11']. I never figured out a formula for calculating the number of decodings but by manually figuring out the number of decodings for the strings '1''11''111''1111''11111''111111', etc. I noticed that the number of decodings follow the Fibonacci sequence starting with 1, 2, 3, 5, 8…! Unfortunately I don’t have a good explanation for why that is the case. (Though it makes gut level sense in the way the Fibonacci sequence is a sum of everything that has come before.) Please leave a comment if you can explain this!

So, my strategy for solving this problem follows these basic steps:

  1. Break the given string down into substrings such that each substring is one digit, '10' or '20', or cannot be broken down further because it has an unknown number of possible decodings. These substrings can be considered independently for the purposes of this problem.
    • For example, '956' becomes ['9', '5', '6'] and '121956' becomes ['1219', '5', '6'].
  2. For each substring figure out the number of decodings. For single digits, '10', and '20' this is just 1. For other substrings this is the Nth value in the Fibonacci series 1, 2, 3, 5, 8… where N is the length of the substring.
  3. Multiply together all of the number of decodings for the individual substrings to get the number of of decodings for the original string of numbers.

You can see my code for this solution here: (raw notebook).