Friday, 30 May 2014 at 2:22 pm

I recently started using Ipython notebook and it has quickly become essential to my workflow. However, when discussing the data informally with colleagues, I wanted the code cells to be hidden as to not distract from the figures.

The newest IPython notebook version do not allow executing javascript in markdown cells anymore, so adding a new markdown cell with the following javascript code will not work anymore to hide your code cells:

$('div.input').hide()

I also didn't want to resort to adding an ugly extra markdown cell, so I went into the IPython jinja template and added a new menu item under "view" for toggling the code cells. 

The IPython notebook template on my OSX laptop was located at:

/Library/Python/2.7/site-packages/IPython/html/templates/notebook.html

I added a new javascript toggle function in the script tag. Where it used to be:

<script type="text/javascript">
// MathJax disabled, set as null to distingish from *missing* MathJax,
// where it will be undefined, and should prompt a dialog later.
window.mathjax_url = "{{mathjax_url}}";
</script> 

I changed it to: (added code in red)

<script type="text/javascript">
// MathJax disabled, set as null to distingish from *missing* MathJax,
// where it will be undefined, and should prompt a dialog later.
window.mathjax_url = "{{mathjax_url}}";

code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}
code_show = !code_show
}
</script>

Then under the view menu:

<ul id="view_menu" class="dropdown-menu">
<li id="toggle_header"....
....
..
</ul>

I added a new menu item:

<li id="toggle_toolbar"
title="Show/Hide code cells">
<a href="javascript:code_toggle()">Toggle Code Cells</a></li>

Save the notebook.html file and restart your ipython notebook. You should now have a new third menu item under "view" that'll allow you to toggle the code cells.

This is a pretty dirty hack though and it might conflict with future updates. So please make a backup version of the notebook.html before you modify it.




  Wednesday, 07 May 2014 at 2:17 pm

It's over. This was the thought that went through my head as I walked out of hacker school's front door around midnight. Having had a few drinks in the preceeding couple of hours as part of the end-of-term party, my steps were heavier than normal.

What is it?

Hacker school is a three months programmer's retreat where a group of like-minded and motivated people are gathered in a room to learn as much as they can about programming. This is not unique. Organized workshops and retreats exist for many professions and careers. However, what makes hacker school different from others is its singular devotion to learning and community. The more cynical among you might question the organizers' sincerity, as there are obvious secondary motivations in the form of recruitment fees for the organizers and landing a job in the tech industry for the attendees. Take it as you will, I did not find these practical motivations to be obstructive during my stay.




-



Search

Categories


Archive