Haskell and the Towers of Hanoi

I’ve been interested in Haskell for a couple of months now, but teaching at Portland Code School has been keeping me busy enough that I haven’t had the time to give it more than a cursory glance. Over the week of Labor Day, we gave the students some extra time off, so I took that time as a chance to finally delve into it some more and start going through the exercises and materials from a well-reviewed course from UPenn that I found. One of the earlier exercises is to solve the Towers of Hanoi in Haskell. Before I get into my solution, though:

What is Haskell?

It’s a strongly-typed, lazy, purely functional programming language. The syntax of Haskell is like nothing I’ve ever worked with before, Continue reading

Super Simple Sinatra & Slim Site

With Portland Code School all wrapped up (or at least mostly–I was asked to TA for the current class, so I’ve been doing that a couple of nights a week), I decided it was time to knock the rust off my Ruby and apply some of the JavaScript stuff I learned to Ruby. To that end, I’ve started building an online version of RoboRally, a favorite old board game of mine (Here’s the GitHub repo). Most of what I’ve been doing so far is working out some game logic, but it seemed like it was about time to start working on the web interface side of things. The obvious choice for a Ruby web framework is Rails, so of course I decided to use Sinatra instead. In addition to sheer perversity, since Sinatra is more lightweight, it seemed like a better choice for really learning the ins and outs of how all this stuff goes together. For templating, I’ve gone with Slim.

There are a bunch of tutorials on Sinatra and Slim around, but I didn’t find too much about using them and a Ruby app all at once, so I did a lot of experimenting to see what would work. Now that I’ve got that more or less squared away, it seems like a good time to pass that info along.
Continue reading

Vim splits and tabs

I was doing some coding down at Portland Code School recently, and a classmate wandered by and paused when he saw my screen. “Is that Vim?” he asked. “What plugins are you using to make it look like that?” The screen he was looking at was much like this one:

vim-vsThis is actually all plain vanilla Vim–I’ve got a couple of plugins that add a little functionality (tpope’s Surround, Unimpaired, and Repeat are about it)–but nothing that changes the display of Vim at all. I’ve thought about picking up NerdTree because I’ve heard about it a lot, but I’m still feeling like a new-enough Vim convert that I don’t want to start using anything too far from the basic functionality of Vim, just because there’s so much to learn in the basic program that so many people don’t know about–which brings us back to my classmate and his question about my screen setup.

Continue reading

The basics of Backbone.js

I’ve been learning my way around Backbone quite a bit lately. It’s definitely a powerful library that can do some pretty cool things—enable you to change the layout of the page without having to make a server call, for example. Like most cool and powerful libraries, though, it can be difficult to wrap your head around. Backbone makes use of three central concepts: Models, Collections, and Views. One mistake I made when first getting into Backbone was thinking of these as analogous to list items, the list itself, and different layouts for the list. That’s not exactly right though—we’ll go into why not and what these things do after the jump.

Continue reading

Overview of a full-stack javaScript site, part 2

Yesterday I detailed the code we’ll be using on our Portland Code School group project to interact with the server and the database. Today we’ll look at the libraries we’ll be using on the client side to make everything work smoothly. Client-side code is becoming more and more important as sites try to improve load times and minimize the work that the server has to do, so this is definitely great stuff to learn about.
Continue reading

Overview of a full-stack Javascript site, part 1

So, capstone projects have started at Portland Code School. Our task is to figure out a web app we want to build, and then to build it. We have to include client-side, server-side, and database code—the whole nine yards. We’ve got a pretty good idea of what we’ll be building in my group, but it’s not time for spoilers just yet. Instead, I’ll be talking about the basics of a full-stack JavaScript site and going over the bits and pieces that we use and how they tie together. This is, of course, at least half for my benefit—it’s like talking out loud about a problem. So if you spot any glaring errors or misconceptions, do me a favor and point them out!
Continue reading

Vim generating invisible extra lines?

I’ve had a strange problem crop up a few times recently when working on a couple of projects—Node projects each time, but I don’t know if that’s particularly relevant. Occasionally I’ll run jshint on file or just try to run it with node, and I’ll get an error like the following:

Continue reading


I got really excited the other day when I stumbled across the Pentadactyl extension for Firefox. It tries to do exactly the sort of thing I’d love to see done: it brings Vim-style movement to the Internet. It’s a very well-done extension—it does its job very well indeed. The problem is, the job is a really hard one, and may just not be doable at all. Basic navigation is fine; you can and up and down pages, and across tabs, and even or to highlight all the links on a page and add shortcut numbers to make it easy to follow links.
Continue reading

On Mouseless Computing

Well, I’ve been continuing to delve into Vim (and JavaScript too, of course). An interesting side effect of using Vim a lot is that I’ve started getting annoyed when I have to actually use the mouse or trackpad or whatever. On the laptop running Mint, I can usually go for a fairly long stretch of time without needing to do anything with the trackpad, but on my Windows 7 desktop—well, things are different there.
Continue reading