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:
Monthly Archives: March 2015
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.
Reverting to Previous Versions in Git
This is a follow-up to my other post on contributing to a project on Git. Whereas the other post dealt with pulling, commiting, and pushing, this post covers reverting to a previous version.