Right now I’m studying the discipline of shipping, in several different ways:

It’s a bit of an obsession, but I think it’s important, especially for me, since none of these things came naturally to me. Also, I think that the best time to learn about something is when you have a seemingly unhealthy obsession with it. If I’d latched onto Ruby on Rails back in 2006…

I’ve seen more than one screencast where the narrator has invited me, the viewer, to pause the screencast to try going through the steps myself. Usually, the invitation is accompanied with the author saying that I’ll learn more if I do.

Of course I’ll learn more, because I’ll spend more time watching the screencast. But will I learn more efficiently? I’m not so sure. Here’s why:

  1. It disrupts flow. The author goes from teaching me something about the topic I’m learning about to talking about something he or she isn’t necessarily an expert about.
  2. It breaks up the screencast if I don’t have a long enough block of time to watch it with breaks.
  3. It makes it take longer to view the screencast more than once. Too long, for me, anyway. I remember reading somewhere in Brain Rules that repetition works better as a memory tool if you repeat something on a different day than if you repeat it back to back. I know this, intuitively, to be true. I also remember John Medina saying that if you vary where you are when you hear something, or what medium it’s in, it works even better. That’s why it’s smart to distribute example code with screencasts.

I wish the suggestion to pause and try following the instructions would come as a little text blurb distributed with screencasts instead of narration. And if, on the second or third viewing, I decided to follow along with every little thing, I would pause more often than the video suggests. So whether I’m pausing or not pausing, I find being instructed to pause to be distracting.

By the way, Brain Rules is a great book. So is Food Rules. They’re written by different authors, and are about different topics, but both are written by experts in their fields, who are also great writers, and both are awesome.

One final point: for screencasts that aren’t immediately relevant to me, but are still interesting, watching them all the way through without trying things makes even more sense. That way I can peruse more screencasts to find the ones that are most relevant to my current interests. I can learn about more tools and domains and better decide which ones I want to work with.

  1. Limit your number of tweets per day to a certain number. Use them wisely.
  2. If you get close to the limit, start saving tweets for future days.
  3. If you want to say more online, find interesting blog posts and leave insightful comments. Comments that require work outside of composing the comment tend to be insightful.
  4. Exceptions should be exceptional.

Backstory: I’ve lost readers (sounds less narcissistic than “followers”) by tweeting too often. I’ve changed how I’ve tweeted since I read Gwen Bell’s twitter bio, which used to say that she was limiting her number of tweets to a certain number per day. Sometimes I still have been tweeting too often, though. As I started blogging more regularly, the idea to switch from tweeting to leaving comments on blogs came to me.)

I’ve known of Incanter, a powerful statistics library for Clojure, for a while now. A couple of days ago I set out to get it running nicely, and was successful. Here are the steps I took:

Installing Leiningen

I used Leiningen because I knew it made packages easy to install, and while it is described more often as a build tool than as a package manager, it has a repl command, so I can use it for experimenting with libraries, too. It was at least as convenient as I expected. I’m going to continue using it to set up repl environments.

To install it, follow these simple instructions from the leiningen repository:

  1. Download the script.
  2. Place it on your path and chmod it to be executable.
  3. Run: lein self-install.

That’s it! It uses the Java installation that comes with OS X. I installed this on Snow Leopard, but these instructions should work on Leopard as well. If you replace aquamacs-emacs-starter-kit with emacs-starter-kit, all of the instructions in this blog post should work on other platforms, with some other minor changes.

Opening a Clojure repl with access to Leiningen

To start a new Leiningen project, I went to my home directory and ran:

This creates a directory called incanterplayground with project.clj and a few other files. Only project.clj will need to be modified to get an Inanter repl environment up and running. I opened project.clj and added the repository and dependency information for Incanter:

And then, following the instructions in Leiningen’s README file, I ran lein deps and lein repl in the project directory:

I wasn’t planning on using swank or nailgun. I haven’t been using emacs, and nailgun doesn’t sound very appealing to me, mainly because when I looked at using it with JRuby a year or two ago, it came with security warnings so strong that they seemed to be telling me you don’t want to use this. When I read the above message, though, I felt like I should give one of the two a try. Before I even tried importing incanter, I started working on getting emacs and lein-swank running.

Getting the lein-swank plugin running

The lein-swank plugin is a server, and therefore doesn’t require emacs to be up and running to run. So I tackled getting lein-swank running, and I put off installing SLIME, which I didn’t know how to use, until afterward. I added a dev-dependencies line to my Leiningen project file. Here is project.clj with this added:

I then ran lein deps and lein swank:

(Note: I made this tutorial while running through these steps for the second time, so lein deps is using files that have already been downloaded. The first time you run it, lein deps will show the download and installation progress.)

This indicates that the swank server is running, and is ready to be connected to by emacs.

Getting emacs running and installing packages with ELPA

I used to use emacs, and I had installed Carbon Emacs to try out org-mode. I didn’t check to see if ELPA was already installed, but rather, ran the directions on the ELPA website. This involved taking a piece of code and evaluating it. Then I went to the ELPA package manager, selected the packages listed in the lein-swank installation instructions, and ran the install. I saw a lot of warnings go by.

When I got done, I restarted emacs, and tried running M-x slime-connect. The command, however, wasn’t installed. I searched for help, and found a post from a user who had the same problem. Someone replied to the post saying that he probably had a bad installation of ELPA. At this point I punted and decided to try aquamacs instead. After installing aquamacs, and running it, I got the idea to find an emacs profile to use that would hopefully have ELPA already working. I searched for an aquamacs emacs profile and found aquamacs-emacs-starter-kit.

I downloaded it to my github directory, rather than to my Emacs preferences directory.

I then added these three lines to the end of ~/Library/Preferences/Aquamacs Emacs/Preferences.el (which just had comments in it):

After this, I restarted Aquamacs, saw a ton of warnings fly by, waited it for it to finish what it was doing, and restarted Aquamacs again. I saw more warnings fly by, and restarted Aquamacs again. I may have restarted Aquamacs a third time before it stopped showing a lot of warnings. It takes a little time for aquamacs-emacs-starter-kit to work its magic.

Then I installed the required packages by typing M-x package-list-packages, selecting the packages that I needed or wanted that weren’t already installed, and typing x to install them. I made sure that clojure, clojure-test, paredit, slime, slime-repl, and swank-clojure were selected before hitting x. After pressing x, I waited while some warnings flew by, and restarted Aquamacs again. Then I tried typing M-x slime and then pressing tab to see what the autocompletion showed. There were a bunch of results, so I felt confident that I had successfully installed SLIME. Indeed I had.

Running SLIME

Finally, I ran SLIME. I still had lein-swank running from a previous step, so I typed M-x slime-connect and chose the default host and port. After a second or two, I saw a silly message indicating that it worked.

I poked around the commands, first using tab completion on M-x, and then looking at the the keyboard bindings in the project.clj buffer with C-h b. I opened a new file with C-x C-f playground.clj, and started evaluating expressions in there. You need to be in a window that’s in the slime mode; the *scratch* buffer will evaluate with emacs lisp if you type C-x C-e in it.

Here’s an example session:

If you go to the end of the first line and type C-x C-e, SLIME should print out #’user/x in the status line. If it works, you know it’s evaluating Clojure and not emacs lisp. Go to the end of the second line and type C-x C-e, and then to the end of the last line and type C-x C-e. It prints out 6. This way I know that it’s running them in the same Clojure session. Pretty cool, huh?

Printing out a graph with Incanter

I found this introductory incanter code, pasted it into playground.clj, and started evaluating it.

After I ran C-x C-e on the first line, a new dock icon with a Java logo appeared. I switched back to Aquamacs, went to the end of the second line, and typed C-x C-e again. Three lines showed up in the emacs status bar, describing an object that was returned. I clicked the new dock icon, and voila! A graph showed up.

What now?

Now that I have a nice Emacs, Clojure, and Incanter setup, there are so many different directions I could go. I have something in mind, but I don’t want to reveal it, because in my mind I might feel like I’m done and lose my motivation to do it. If you need ideas, though, one thing you could do is go to the Data Sorcery blog and start trying the examples there.

There are only two hard things in Computer Science: cache invalidation and naming things.

— Phil Carlton

I find that I spend an awful lot of time naming things. More than that, it’s a distraction. I also spend a lot of time organizing directories, and a lot of time trying to recall where I’ve put things.

Cluttered Office

GitHub has made it a lot easier for me to find code online. In fact, it’s so easy that sometimes I just download another copy of a repository rather than search my home directory for one.

As of yesterday, though, the madness is over, because I decided to replicate github’s organization on my own computer. Here are the first two levels of my new, and currently modest, ~/github directory:

As I get more repos downloaded, I think my new organization style will only make more sense. And if I also need a github repo somewhere else, I can symlink it. Also, ~/src is symlinked to ~/github/benatkin.

The idea came when I realized I didn’t have all of my GitHub repos in one place. As you can tell by the tree, I still don’t. Also, I’m putting stuff in my GitHub directory that I may add to GitHub later. If something stays there longer than a week and  I don’t put it on GitHub, though, I’ll move it to the archive.

This new directory structure also has the nice side effect that I won’t need to delete repositories just because I need stuff to be easier to find.  It shouldn’t take long for the number at the end of the tree output to go over 100, and in a while, the number could be in the thousands. I’ll think of it as a partial mirror.

If you do any native iPhone development, check out ASIHttpRequest. You’ll be glad you did. I tried a couple of frameworks, Objective Resource and HttpRiot before using this library. I found that using a library for making HTTP requests feels much more natural to me than using a framework. ASIHttpRequest reminds me of jQuery’s ajax() function.

Perhaps when I’m working with a large number of models I’ll want something like Objective Resource or HttpRiot. If I do, I’ll consider changing one of them to be an interface to ASIHttpRequest, which builds upon lower-level APIs to be more powerful than NSUrlRequest.

At this month’s BoulderRuby meeting, Randall Thomas gave a talk. During his talk, he told us about R, a statistical programming language. I’d heard of it in passing, but hadn’t tried it. After seeing how cool maps could be generated with very little code, I decided to try it out.

I went to the download page and grabbed the latest binary package for OS X. It comes as a .pkg file. I opened it, and the installation process started. Unfortunately, near the end of the installation, it hung, on the Preparing R 2.10.1 for Mac OS X 10.5 or higher (Leopard build)… step. I switched to another application, and ten minutes later, it was still stuck.

I tried googling specifically for the R installer hanging, but didn’t find anything. I started searching for OS X package installer hanging instead. Finally, I saw a bug report about git-osx-installer hanging under similar circumstances, to which Seth Milliken replied saying that it’s caused by iPhone Simulator.

I was running iPhone Simulator, so I tried killing it, and the installer immediately stopped hanging and told me that installation failed. I ran the installer again and it worked.