I walk in monologue through Berkeley's Hills Feet pressing into sidewalk firmly I eat the pensive mood solitude brings And bite into the juiciness of self-reflection I write, first time in years, free verse impromptu Taking few dozen steps between each pair of lines I yearn, on tip-toes stretching high, to be expressive A mode of being longtime self-denied I'm walking home - from job I'll soon be leaving To find myself believing once again That which I do defines me not and feeling That which I am is good. enough. a lot.
- read more
I am starting to look for a job in the San Francisco Bay Area.
Since many recruiters ask for and presumably look at GitHub profiles, I decided to give mine a little facelift:
In case you aren't familiar, that banner was motivated by Joel Spolsky's Smart and Gets Things Done, which is a book about hiring good developers . So I decided to tweet it out, mentioning @spolsky and he favorited it!
Yesterday, I decided to tweet out an image that's at the top of my resume as a standalone tweet- mentioning Joel Spolsky again, and he liked it well enough to retweet it to his 90 thousand followers, so it's been getting plenty of love.
Perhaps unsurprisingly, the only person to contact me as a result of this so far is a reporter from Business Insider :
My editor would like to post it on our site as an example of a creative way to format a resume... I'm wondering if we can get your permission to do this?
So that's what prompted this post: I simply added my name and a Creative Commons Attribution Licence (CC-BY) to the two images, and then sent my permission along.
Outside of that, no prospective employers have gotten in touch. But like I always say: you can't win the lottery if you don't buy a ticket. And since I also enjoy mixing metaphors, I'll just keep on fishing!read more
Greg Wilson asked on the IPython mailing list:
Subject: easiest way to insert a literal tab character in a code cell? Greg Wilson, on 2014-04-03 18:37, wrote: > Hi, > I'd like to put literal tab characters in cells, but of course tab means > "indent" to the editor. What's the easiest way to do this? > Thanks, > Greg > p.s. because I'm going to write Makefiles in the notebook...
The easiest way to do this is to just get a tab character somewhere that you can copy, and then paste it in.In :
# I copy pasted the output of the cell above here
An alternative solution is to make a string with tabs and insert it into another cell, using IPython machinery.In :
ip = get_ipython()In :
ip.set_next_input("\tMakefiles are awesome")In :
Makefiles are awesome
If you have a file on disk or on the web, you can also just use the
%loadmagic to do this.In :
%load /home/pi/file_with_tabsIn :
default: cat /etc/issue whoami
Such files can be written with the
%%writefilecell magic... but of course you need to have inserted tabs there in some manner.In :
%%writefile ~/file_with_tabs default: cat /etc/issue whoami
Overwriting /home/pi/file_with_tabsIn :
!make -f /home/pi/file_with_tabs
cat /etc/issue Debian GNU/Linux jessie/sid \n \l whoami pi
We can set up CodeMirror to insert tabs instead of spaces.In :
The reason we attach
IPythonis because when we use the
I covered how to add functions like this to the
custom.jsfile in your profile in my post about disabling blinking in the notebook. That way these little functions are available in every notebook, without you having to insert a cell defining them.
Now we've got code that allows us to apply the change to all current and future cells. We leave it as an exercise for the interested reader to modify that code and make a little button in the toolbar, to toggle it on a per-cell basis.
You can get to the code mirror instance via
This post was written as an IPython Notebook. You can view it on nbviewer, or download it.read more
the boldly indiscriminate python interpreter
"...because you shouldn't have to choose."
Two interpreters, both alike in dignity,
In fair Pythona, where we lay our scene,
From ancient grudge break to new mutiny,
Where civil code makes git commits unclean.
From forth the fatal loins of these two foes
A newer kind of stranger's given life;
Whose misadventured piteous overthrows
Doth with its birth bury its parents' strife.
I'm a fancy terminal-based interface to the Python interpreter. I give you
inline syntax highlighting and auto-completion prompts as you type, and I'll
even automatically show you a little tooltip with a docstring and parameter
list as soon as you hit
(to make the function call, so you always know
what you're doing! I'm svelte and proud of it - I don't try to do all of the
ipythondoes with the shell and the web, but the cool kids
love my rewind feature for demos. I strive to make interactive python coding
I'm an awesome suite of interactive computing ideas that work together.
For millennia, I've given you tab-completion and object introspection via
help(obj)in Python. I also have sweet shell features,
special magic commands (
%matplotlib, etc.) and a
history mechanism for both input (command history) and output (results
More recently, I've decoupled the REPL into clients and kernels, allowing
them to run on independent of each other. One popular client is the
IPython Notebook which allows you to write code and prose using a web
browser, sending code to the kernel for execution and getting rich media
results back inline. The decoupling of clients and kernels also allows
multiple clients to interact with the same kernel, so you can hook-up to
that same running kernel from the terminal. The terminal workflow makes
more sense for some things, but my user interface there isn't as polished
By your powers combined... I am
The Power is Yours!
pip install bipython easy_install bipython
bipythonrequires ipython, pyzmq, bpython, and urwid.
For now, you'll need to have a running ipython kernel before running
bipython. You can do this by either opening a notebook or running
ipython console. It won't always be like this, I'll fix it as soon as I can, but it'll be sooner with your help over ivanov/bipython.
After that, just run
bipythonand enjoy the ride.
Here's a walkthrough of ipython, bpython, and bipython:
The screencast is 20 minutes long, but here I'll play it back double speed. There's no sound, and you can pause at any time and select / copy portion of the text as you like. Changing the browser font size in the usual way works, too. (click here if the embed didn't work)read more
Summary: I describe stem plots, how to read them, and how to make them in Python, using 140 characters.
My friend @JarrodMillman, whose office is across the hall, is teaching a computational statistics course that involves a fair amount programming. He's been grading these homeworks semi-automatically - with python scripts that pull the students' latest changes from GitHub, run some tests, spit out the grade to a JSON file for the student, checks it in and updates a master JSON file that's only accessible to Jarrod. It's been fun periodically tagging along and watching his suite of little programs develop. He came in the other day and said "Do you know of any stem plot implementation in python? I found a few, and I'm using one that's ok, but it looks too complicated."
For those unfamiliar - a stem plot, or stem-and-leaf plot is a more detailed kind of histogram. On the left you have the stem, which is a prefix to all entries on the right. To the right of the stem, each entry takes up one space just like a bar chart, but still retains information about its actual value.
So a stem plot of the numbers 31, 41, 59, 26, 53, 58 looks like this:
2|6 3|1 4|1 5|389
That last line is hard to parse for the un-initiated. There are three entries to the right of the 50 stem, and these three entries
9is how the numbers
59are concisely represented in a stem plot
As an instructor, you can quickly get a sense of the distribution of grades, without fearing the binning artifact caused by standard histograms. A stem-plot can reveal subtle patterns in the data that are easy to missed with usual grading histograms that have a binwidth of 10. Take this distribution, for example:
70:XXXXXXX 80:XXXXXXXXXXX 90:XXXXXXX
Below are two stem plots which have the same profile as the above, but tell a different story:
7|7888999 8|01123477899 9|3467888
Above is a class that has a rather typical grade distribution that sort of clumps together. But a histogram of the same shape might come from data like this:
7|0000223 8|78888999999 9|0255589
This is a class with 7 students clearly struggling compared to the rest.
So here's the code for making a stem plot in Python using NumPy.
stem()expects an array or list of integers, and prints all stems that span the range of the data provided.
from __future__ import print_function import numpy as np def stem(d): "A stem-and-leaf plot that fits in a tweet by @ivanov" l,t=np.sort(d),10 O=range(l-l%t,l[-1]+11,t) I=np.searchsorted(l,O) for e,a,f in zip(I,I[1:],O): print('%3d|'%(f/t),*(l[e:a]-f),sep='')
Yes, it isn't pretty, a fair amount of code golfing went into making this work. It is a good example for the kind of code you should not write, especially since I had a little bit of fun with the variable names using characters that look similar to others, especially in sans-serif typefaces (
lI10O). Nevertheless, it's kind of fun to fit much functionality into 140 characters.
Here's my original tweet: @ivanov/status/443980372192137216
You can test it by running it on some generated data:
>>> data = np.random.poisson(355, 113) >>> data array([367, 334, 317, 351, 375, 372, 350, 352, 350, 344, 359, 355, 358, 389, 335, 361, 363, 343, 340, 337, 378, 336, 382, 344, 359, 366, 368, 327, 364, 365, 347, 328, 331, 358, 370, 346, 325, 332, 387, 355, 359, 342, 353, 367, 389, 390, 337, 364, 346, 346, 346, 365, 330, 363, 370, 388, 380, 332, 369, 347, 370, 366, 372, 310, 348, 355, 408, 349, 326, 334, 355, 329, 363, 337, 330, 355, 367, 333, 298, 387, 342, 337, 362, 337, 378, 326, 349, 357, 338, 349, 366, 339, 362, 371, 357, 358, 316, 336, 374, 336, 354, 374, 366, 352, 374, 339, 336, 354, 338, 348, 366, 370, 333]) >>> stem(data) 29|8 30| 31|067 32|566789 33|00122334456666777778899 34|02234466667788999 35|001223445555577888999 36|12233344556666677789 37|0000122444588 38|0277899 39|0 40|8
If you prefer to have spaces between entries, take out the
sep=''from the last line.
>>> stem(data) 29| 8 30| 31| 0 6 7 32| 5 6 6 7 8 9 33| 0 0 1 2 2 3 3 4 4 5 6 6 6 6 7 7 7 7 7 8 8 9 9 34| 0 2 2 3 4 4 6 6 6 6 7 7 8 8 9 9 9 35| 0 0 1 2 2 3 4 4 5 5 5 5 5 7 7 8 8 8 9 9 9 36| 1 2 2 3 3 3 4 4 5 5 6 6 6 6 6 7 7 7 8 9 37| 0 0 0 0 1 2 2 4 4 4 5 8 8 38| 0 2 7 7 8 9 9 39| 0 40| 8
To skip over empty stems, add
e!=a andin front of
>>> stem(data) 29| 8 31| 0 6 7 32| 5 6 6 7 8 9 33| 0 0 1 2 2 3 3 4 4 5 6 6 6 6 7 7 7 7 7 8 8 9 9 34| 0 2 2 3 4 4 6 6 6 6 7 7 8 8 9 9 9 35| 0 0 1 2 2 3 4 4 5 5 5 5 5 7 7 8 8 8 9 9 9 36| 1 2 2 3 3 3 4 4 5 5 6 6 6 6 6 7 7 7 8 9 37| 0 0 0 0 1 2 2 4 4 4 5 8 8 38| 0 2 7 7 8 9 9 39| 0 40| 8
Thanks for reading.
The cursor is meant to tell the user the current location.
The human visual system has a pre-cortical lag of roughly 50-90 ms (read more about P1).
That's how long it takes from something changing on the screen to cause an avalanche of photons to barrel towards your eyeball, be phototransduced and processed by several stages of cells in the retina, finally causing retinal ganglion cells to fire an action potential down their axons through the optic nerve, make its way to a processing relay station called the LGN, with those cells firing action potential down their axons, with those spikes finally ending up in the primary visual cortex.
By ~150 ms, our brains have processed the visual input enough to perform a non- trivial ammount of object recognition.
The default blink rate for CodeMirror is 530ms.
That's as slow as molasses in January!
Say that I've been distracted and looked away from the screen. When I look back at the scree, half of the time it will take 3 times longer for me to get the information that I want ("where's my cursor") than if that cursor was clearly visible at all times. Now it's not always that bad, because sometimes my gaze will land on the screen and even though the cursor isn't visible, it appears in a few milliseconds, and so it takes just as long as if the cursor was there the whole time. But if I happen to be particularly unlucky (there's a reason I don't gamble), it can take 6 times longer.
Try it out
Make the change stick
IPython has a notion of profiles to allow for different kinds of configurations. If this is news to you, you've probably just been using the
defaultprofile and not known it. In the shell, run the
ipython profile createcommand to be sure (don't worry, if you alreay have a profile, this won't overwrite it). Now
ipython locate profilewill tell you the directory which contains all of the configuration for the
!ipython profile createIn :
!ipython locate profile
x = !ipython locate profileIn :
db/ history.sqlite history.sqlite-journal ipython_config.py ipython_nbconvert_config.py ipython_notebook_config.py log/ pid/ security/ startup/ static/
There's a lot of stuff there, but we just need to add our one line to the end of the file in
custom.css custom.jsIn :
!echo "codemirror.defaults.cursorblinkrate=0" >> custom.js
"I want it all and I want it now!"
You say you don't want to save your current notebook and reload it to get the updated CodeMirror settings? You just want all cells in the current notebook to change their behavior? Well, OK, Freddie:In :
I hope you enjoyed this little IPython customization detour. If you want more information about how to get rid of blinking in other programs you use every day, here is an invaluable resource on that matter.
Remember, blinking in user interfaces is bad, but blinking in vision is very important.read more
I'll be in Austin, TX for SciPy next week, and I'll be giving an updated talk about tools for reproducible research.
What follows is the abstract of a talk that I really wanted to give and submitted to the general track which did not get in. I care deeply about this topic, and I'm hoping to have conversations with others about it. The talk was deferred to a poster, so if you don't bump into me at other times, seek me out during the poster session (mine's poster #15, 10:35 AM - 11:35 AM on June 27th). This post is intended as a pre-conference warm up to that.
Navigating the Scientific Python Communities - the missing guide.
The awful truth: our newcomers have a deluge of options to wade through as they begin their journey. What tools are available, how do I install them, how do I make them work together -- all hard questions facing a budding scipythonista.
On developer-friendly platforms, the popular approach is to just install numpy, scipy, matplotlib, and ipython using package management facilities provided by the operating system. On Mac OS X and Windows, the least painful, bootstrapping approach is to use a Python distribution like Python(X,Y), EPD, Anaconda, or Sage.
Both of these paths obscure a reality which must be stated explicitly: the development of packages is fundamentally decentralized. The scientific python ecosystem consists of a loose but thriving confederation of projects and communities.
The chaos of installation options and lack of centralization around a canonical solution, which on the surface appears to be a point of weakness that is detrimental to community growth, is a symptom of one of its greatest strengths. Namely, what we have is a direct democracy for user-developers. They vote with their feet: filing bug reports, testing pre-release versions, participating in mailing lists, writing and reviewing pull requests, and advertising the tools they use in talks, papers, and conversations at conferences.
I will discuss why this is the case, why this is a good thing, and how we can embrace it. The talk will present the ethos and expectations of an effective newcomer, as well as resources and strategies for incremental progress toward becoming a master scipythonista.read more
So, following up on my transition to pelican, here's a little help for navigating a pelican site. If you've ever wondered why sometimes there's a highlighted menu item at the top, and other times there isn't, read on.
With Pelican, every post belongs to exactly one category - that category is
'misc'if one is not provided (and you can override that named by setting
DEFAULT_CATEGORY = 'somethingelse'in your
pelicanconf.pyfile). Alternatively, if the post is in a subdirectory, it's category becomes the subdirectory name. So if you have a situation like this:
lady-rainicornpost will be filed under the category of
unicorns. You can explicitly override this category-from-subdirectory behavior, by specifying the category in the header of the file, like so:
title: All about Lady Rainicorn slug: lady-rainicorn category: adventure-time
Categories are where a lot of the pelican themes get the top navigation bar, which is referred to as the menu in Pelican. You'll notice that this post is filed under
technology. If you're viewing this on the main page, that won't be highlighted, but if you click on the title of this post, you'll see that
technologywill become highlighted. Same deal if you just click on
technology, which will get you a listing of the latest post in that category, and a pagination of all previous ones.
The menu items need not be limited to categories, however. With the popular
notmyideatemplate (which is what I've customized for my journal here), if you create any pages (by putting the file in a
content/pages/directory), then the title of that page will appear in front of all of the categories in the menu. These pages don't show up in RSS feeds, though.
Additionally, you can specify other
pelicanconf.py, which will go in front of all pages and categories.
MENUITEMSis a list of tuples, each tuple should be composed of a link name, and a url. This is how I link to the listing of all of my blog posts:
MENUITEMS = [('all', '/blog/archives.html')]
Finally, you can have zero or more tags attached to a post. Tags, by default, do not get a feed generated for them. To enable a tag feed, you'll have to set a line like this in your
TAG_FEED_ATOM = "feeds/tag_%s.atom.xml"
notmyideatemplate only contains logic for highlighting the active category. This is why, if you click on 'All' at the top of mine, it doesn't stay highlighted when you're on that page.
On the other hand, if you click at
cyclingat the menu bar, it will stay highlighted, and you will see a listing of the articles in that category. But if you click on the
cyclingtag in one of those posts - the menu item will not be highlighted, and you will see some more articles - in particular, right now my review of Just Ride will also be listed, but it lives in the category of
books, because that's where I'm keeping book reviews.
So there you have it - now you know the differences between categories, tags, pages, and menu items, as far as Pelican is concerned. For me, the bottom line is that I'll probably stick to just using categories, and will try to use tags sparingly. In my transition from WordPress, I cleaned up and removed a whole bunch of tags (since they were either redundant (the same tags kept appearing together), or were too specific (most tags were only used for one post).read more
Well, it's happened again, I've jumped (back) on the static blog engine bandwagon. Early versions of my site were generated literally using
gcc, and a
Makefile...). Back then I was transitioning away from using livejournal, and decided to use WordPress so I wouldn't have to roll my own RSS feed generator.
I tolerated WP for a while - and the frequency of my posts was so low, that it wasn't much of an issue.
Except for the security upgrades. I logged into the
wp-adminconsole way more times than I cared to just to press the little "upgrade" box. The reason is that wordpress keeps everything in a database that gets queried every time someone hits the site. I was never comfortable with the fact, because content can be lost in case of database corruption during either an upgrade or a security breech. Also, my content just isn't that dynamic. The WP-cache stuff just seemed overkill, since I don't get that many visitors.
But lately, I've found myself wanting to write more, to post more, but also shying away from it because I hate dealing with the WordPress editor. And I also hate being uncertain about whether any of it will survive the next upgrade, or the next security hole, whichever I happen to stub my toe on first.
And the thing is, I really like to use version control for everything I do. I liked my blog posts to be just text files I can check into version control. I also like typing "make" to generate the blog, and now I get to!
For added fun, I'm hoping that writing my posts in markdown will make it easier to coordinate my gopher presence, since it's pretty close.
For posterity, I'm capturing what the first version of my Pelican-based blog looked like. I did the same thing when I moved to WordPress.
I ran into some confusing things about transitioning to Pelican, so I thought I'd note them here, for the benefit of others.
Unadulturated code blocks
I like to use indentation as a proxy for the venerable
<tt>tag - which uses a monospace font.
If you just want to use an indentation, but do not want the indented text parsed as a programming language, put a
:::textat the top of that block. Here's what I mean. Take this Oscar Wilde quote, where I've inserted a line break for drammatic effect, for example:
A gentleman is one who never hurts anyone's feelings unintentionally.
Now, you see that ugly red box around the apostrophe? Well, That's because all I did was indent the two lines. If I just put a
:::textabove the quote, indented to the same level,
:::text A gentleman is one who never hurts anyone's feelings unintentionally.
the result will render like this.
A gentleman is one who never hurts anyone's feelings unintentionally.
As the pelican documentation specifies, this is also the way you can also specify the specific programming language you want, so
:::pythonwould be one way to not make pygments guess. You can get a list of all supported languages here, just use one of the
short namesfor your language of choice.
And you should really do this, even if you aren't bothered by the red marks, because the code highlighting plugin goes in and tokenizes all of those words and surrounds them in
<span>tags. Here's the HTML generated for the first version:
<div class="codehilite"><pre><span class="n">A</span> <span class="n">gentleman</span> <span class="n">is</span> <span class="n">one</span> <span class="n">who</span> <span class="n">never</span> <span class="n">hurts</span> <span class="n">anyone</span><span class="err">'</span><span class="n">s</span> <span class="n">feelings</span> <span class="n">unintentionally</span><span class="p">.</span> </pre></div>
and here's the version generated when you add the
:::textline at the top:
<div class="codehilite"><pre>A gentleman is one who never hurts anyone's feelings unintentionally. </pre></div>
At some point, having a dialogue with myself, I wrote in here "or should I not use pelican and use nicola instead?"
Ok, tried it - nikola takes too long to startup -
nikola --help real 0m1.202s user 0m0.876s sys 0m0.300s pelican --help real 0m0.639s user 0m0.496s sys 0m0.132s
I'm sure it's a fine static blogging engine - and Damian Avila's already written IPython Notebook converters for it, but it just feels like it tries to do too many things. Constraints are good. I'll stick with Pelican for now. (Though I did use the nikola wordpress import tool to grab the
wp-uploadimages from my WordPress blog)
another set of instructions I consulted: Kevin Deldycke's WordPress to Pelican, which is how I did get my articles out using
exitwpwhich I patched slightly, so files got saved as .md, and preserve other format properties.
also known as: not breaking the web
I wanted to preserve rss feeds, and also not break old WordPress style /YYYY/MM/DD urls - the Nikola wp-import script had created a url remapping scheme in a file called
I don't have that many posts, so I just added them in by hand:
Options +FollowSymLinks RewriteEngine on RedirectMatch 301 /blog/feed/ /blog/feeds/all.atom.xml RedirectMatch 301 /blog/2006/10/18/todd-chritien-greens-choice-voting/ /blog/todd-chritien-greens-choice-voting.html RedirectMatch 301 /blog/2007/01/04/changelogs-with-dates-gui-goodness/ /blog/changelogs-with-dates-gui-goodness.html ...
Enabling table of contents for posts
If you want to include a table of contents within a post using
[TOC], you must enabled the markdown
tocprocessor with a line like this is your
MD_EXTENSIONS = [ 'toc', 'codehilite','extra']
Categories and tags
Ok, so this was never clear to me in wordpress, either - but what's the difference between a tag and a category? is it the case that a post can only belong to one category, whereas it can have any number of tags?
I think I used categories as tags on wordpress. Looks like all posts on Pelican can have at most one category. Turns out this little aside was long enough to turn into its own post, so if you're interested, pelican tags-vs-categories has got you covered.
That's it for now
Thanks to Preston Holmes (@ptone) for encouraging me to transition away from WordPress, and pointing me to this post by Gabe Weatherhead (@MacDrifter) for how to do that. It should be said that the pelican documentation itself is very good for getting you going. Additionally, I consulted this post by Steve George which has a good description to get you started, and also covers a bunch of little gotchas, and lots of pointers. Also, thanks to Jake Vanderplas (@jakevdp) for his writeup on transitioning to Pelican, which I will consult later for incorporating IPython notebooks into my markdown posts, in the future. This is good enough for now. LTS.read more
Page 1 / 4 »