I’m not sure what this is, but I had this amazing dish in one of the most depressing shopping malls on planet Earth, near Cupertino, CA, and then again at a great pho place in Mountain View. (Correction: it’s called bun, and I’m ignorant.) The basic idea is lettuce, mint, rice noodles, and something savory, like a chopped egg roll, shaved pork, or chicken or something.
Introduction to Graph Tool
I started reading about network statistics this morning and I wanted to experiment with the available Python tools. It looks like the state of the art is graph-tool. I had a little trouble installing the software on my Mac, but there is an evolving guide to this process here.
Book Mode in Vim
Sometimes you have a lot of code, and your screen isn’t tall enough. I found this blog post that shows you how to set up Vim in a sort of “book-mode” where you have two or more panes that scroll synchronously so that you can see two or more pages of code at once.
Poisson Disk Sampling
I’ve borrowed (stolen) code from this iPython Notebook hosted on GitHub from the PyData NYC 2014 conference. I didn’t like the local
call in the original code, so I made it object oriented. (Full disclosure: I’d never seen the local
keyword before, so I stuck with the devil I knew.) I also wanted syntax reminiscent of scipy.stats
, so I added a .rvs()
method from extracting a sample from the Poisson disk object.
Generating Sub-random Numbers
Sub-random numbers sort of look random, but they aren’t and they usually provide better coverage over an interval which is sometimes more important than having truly random data. For example, you wouldn’t use sub-random numbers for encryption, but they’d be great for performing Monte Carlo calculations. You can read more about them on the Wikipedia page for low discrepancy sequences.
Modeling Elevator Usage Pt. I
I was reading a book on modeling and the first problem in the first chapter asked the reader to model the use of an elevator during the morning rush at an office. There was the implicit assumption that employees would only be going up, and that there wouldn’t be any intra-level travel. I though this problem was interesting, so I thought I’d start to model this with Python. (I turned out that it was a rabbit hole.) I think that this is interesting for two reasons, you can model the wait-time for a very common situation, this can be abstracted to a more general constrained resource problem. This is my first whack:
Simple Interactive SVG Application with Flask and Jinja
In this post I’ll provide a simple example of serving a page with Flask and feeding SVG instructions into a Jinja template through an HTML form.
Continue reading Simple Interactive SVG Application with Flask and Jinja
Making and Changing into a Directory
This function, added to your shell profile, will allow you to create directories and cd into them in one fell swoop, without you having to type mkdir
, and then cd
ALL DAY. After looking around online, I like the name mkcd
for this utility, because md
makes me think of markdown.
For some reason, I couldn’t get this to work as a one-liner in my .zshrc
file, but the listing below worked fine.
function mkcd () { mkdir -p $1 cd $1 }
Note that the -p
flag allows you to create a directory several directories deep at one go, without having to descend into them one at a time.
Visualizing Networks with Graphviz
In this post I’ll look at building graphs in Python using the graphviz
module. This assumes that you’ve installed graphviz itself, which is easy enough on a Mac using homebrew. (Simply run: brew install graphviz
.) I had two requirements for my graphs: I needed them to be directed, and I wanted to use the edge thickness to illustrate the strength of a connection. The first part was dead simple, but the second part required a little hunting.
Measuring the Terminal
I found this site with a lot of neat terminal tricks, like making text bold, changing colors, and adding a progress bar. I use the recipe for measuring the width of the terminal a good bit, so I’ll reproduce that here.