Tag Archives: OS X

Two Quick Nim Scripts

Today I Googled something like “julia lang compiled” for the umpteenth time in several months, and then I remembered that Nimrod existed, except it’s Nim these days, and it might make it to version 1.0 any week now. I decided to look around a bit, and I discovered that the documentation seems to have improved, and the language has gotten more fleshed out. I decided to try two small things I’ve been doing a lot of lately, SSH-ing and HTTP-getting and posting, and see what they look like in Nim.

Continue reading Two Quick Nim Scripts

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.

Continue reading Visualizing Networks with Graphviz

Using Optional Values in Swift

Optional Values

Swift has a nil keyword that is sort of like the None keyword in Python; however, regular variables and constants cannot be nil. In order for a variable to be nil, it must be initialized as an optional. (Constants cannot be nil or optional.) An optional is decalred by appending a question mark the variable type. For example, the two statements below are equivalent.

Continue reading Using Optional Values in Swift

Installing Canvas for Node on OSX

I’d like to work with Processing.js, but I had trouble installing the canvas dependency. This should be as easy as,

$ npm install canvas

But there’s a thingy that doesn’t work in Homebrew. I found the answer in this thread on their GitHub. On OSX you have to call this command before you can install canvas:

$ export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig

Then we can install canvas and processing using npm like we’d expect.

Creating a Flowchart with TikZ and LaTeX

In this post I’ll discuss how to make simple flowcharts in LaTeX using TikZ. Probably the best collection of TikZ examples can be found at TeXample.net, but there are other helpful examples like these two PDFs, here and here. In case you’re wondering, TikZ is a recursive acronym “TikZ ist kein Zeichenprogramm,” a reminder (in German) that it is not an interactive drawing program.

Continue reading Creating a Flowchart with TikZ and LaTeX