Jump to Errors in Ruby Koans with VIM

I attended a Ruby Koans hack night the other day. Since I already know most of Ruby, I decided to see if I could get VIM’s make quickfix support running on the koans – the program prints a file and line, so at best it will just work and at worst I’ll have to get into writing an output parser.

Quickfix Mode

Quickfix mode (:help quickfix) is a feature of VIM designed for grabbing compiler output and stepping through the errors and warnings. VIM parses it into a list of file, line, message. It can jump you to the file in question, and has facilities to step back and forth through the list. Quickfix mode is also used by vimgrep and the Ack plugin to allow you to step through search results – which is where I spend no small part of my time.

WIth the ack plugin:

:Ack mystery_method

The plugin auto-opens the quickfix window. You can use :copen to do it yourself. Once you’ve got a list of search results (visible or hidden), you can step through the list with :cn[next] and :cp[revious]. I do this so much that I bound C-n to :cn

nnoremap <leader>a :Ack 
nnoremap <C-n> :cn<cr>

Make

The :make command runs the make program, make by default, and puts you into quickfix if there is anything that looks like a file-line pair. The make program is defined by the vim setting makeprg. I don’t do the koans very often, so I just set it at runtime.

" wrong
:set makeprg=rake

Unfortunately, this simple version doesn’t quite work. The koans helpfully provide text coloring, which is great for terminal use, but VIM sucks the control codes into the filename and gets confused when it can’t find the file. I initially hacked the rakefile to remove the offending codes, but with a moment’s reflection I realized that the koans might just have an option to deal with this. A little code inspection turned up the NO_COLOR environment variable.

There is just one more complication: you need a space between an env variable and the command, but spaces separate settings passed to the :set command. So, we’ll have to escape the spaces.

" right
:set makeprg=NO_COLOR=true\ rake

Now just :make and VIM should jump you straight to the first line that needs your attention. The koans only report one error at a time, so you’ll need to :make after every change – this might be a good time for a runtime keybinding.

Comments Off

Intro to Ruby at Elgin Technology Center

Ruby is a dynamic, object-oriented programming language with lots of cool stuff. It has attracted a community of creative, fun-loving, passionate people, who have generated a great quantity of conferences, videos, web sites, tools, companies, and hot job market to boot.

Comments Off

Paths, Properties, Paint: HTML5 Canvas and the Pervasive Pixel Painting Protocol at Fox Valley Computing Professionals

Sometimes, stacking divs and fiddling with CSS just doesn’t cut it. The canvas tag gives us an escape hatch – an infamous blank rectangle. Unlike applets and Flash, canvas is orchestrated by the same javascript you already use to run your web site. Canvas is a strange beast however; while it gives us a “blank canvas” perfect for painting and blending effects, the API is largely vector based, which makes it easy to do shapes and outlines that can be smoothly transformed.

We’ll take a deep dive into the way canvas “thinks” – the drawing model that you’ll need to bend it to your will. This same drawing model reappears in a number of other systems. Along the way we’ll also take a short peek into computing history to see how this hybrid vector/raster model came about.

Comments Off

Prototypal Objects at Chicago Javascript

A short into to Javascript objects and prototypes.

Javascript objects are basically maps from strings to values, witha few extras, like dot indexing and prototypes. Prototypes are a way of relating objects so that one, the prototype, can provide default values for another. I find prototypes are simpler and more supple object model, though it may not be as familiar to those experience in class based systems.

Comments Off

Paths, Properties, Paint: HTML5 Canvas and the Pervasive Pixel Painting Protocol at Chicago Web Conf

Sometimes, stacking divs and fiddling with CSS just doesn’t cut it. The canvas tag gives us an escape hatch – an infamous blank rectangle. Unlike applets and Flash, canvas is orchestrated by the same javascript you already use to run your web site. Canvas is a strange beast however; while it gives us a “blank canvas” perfect for painting and blending effects, the API is largely vector based, which makes it easy to do shapes and outlines that can be smoothly transformed.

We’ll take a (brief) peek at how this bizarre combination came about, and then dive into the way canvas “thinks” – the drawing model that you’ll need to bend it to your will.

One comment so far, add another

Paths, Properties, Paint: HTML5 Canvas and the Pervasive Pixel Painting Protocol at Elgin Technology Center

Sometimes, stacking divs and fiddling with CSS just doesn’t cut it. The canvas tag gives us an escape hatch – an infamous blank rectangle. Unlike applets and Flash, canvas is orchestrated by the same javascript you already use to run your web site. Canvas is a strange beast however; while it gives us a “blank canvas” perfect for painting and blending effects, the API is largely vector based, which makes it easy to do shapes and outlines that can be smoothly transformed.

We’ll take a (brief) peek at how this bizarre combination came about, and then dive into the way canvas “thinks” – the drawing model that you’ll need to bend it to your will.

Comments Off

Android

I got an Android a few months ago for some mobile web app testing. (I then proceeded to focus my attention to wrestling dragons for said web app, which didn’t leave much time for blogging.)

I really hope they they’ve worked on user experience, because my onboarding experience was absolutely awful – it was several hours before I was able to successful type the username and password to my google account, and the phone refuses to do anything until you’ve set up a google account. I had more trouble setting up other apps and services, and in some cases ended up sending passwords to myself, because I was really just that sick of typing in the same sequences over and over on a crummy touch keyboard.

The Swype keyboard is fairly nice for normal text. Even so I don’t relish typing a mobile screen, so I mainly end up entering login information, where alternate keyboards aren’t much help.

I didn’t get the latest-greatest model (which changes weekly anyway), both because I don’t have steady income, and because I wanted to see what a typical user experience would be like. I got a T-Mobile LG Optimus-T, which comes with Android 2.2.2. I’ve since unlocked the phone, but from what I can tell, I wouldn’t be able to take much farther in the Android versions because the hardware requirements increase with each release.

It still runs my geolocation-based web app, so I can use it “in context”, which was the whole point of the exercise. It’s also able to run Disk Clock fairly well, although the app-switching use case is making me reconsider the startup animations even further. (The fact that it’s running Disk Clock at all hints at some other stuff I need to get around to publishing.)

I also realized I should probably have a case for carrying it around. I got a soft case – it seemed (quite unscientifically) that a hard case would just transmit any shock through to the phone. I assumed it would have cut-outs for the buttons, but in fact there are specially designed extrusions, with a peak to push the button an a thin area around to allow it to move.

The new device also pushed my “charging station” over the edge. I don’t know how tolerant the devices are of slightly off input-power, so I’ve kept around each power supply. I pulled out the twist-ties to keep the cables straight – a technique I’d been using the keep the computer and power iPad cables sorted out.

Comments Off

On the Inception of the Ruby Object System, at Chicago Software Craftsmanship

Class, superclass, metaclass, singleton class, eigenclass, class <<self, class Class, Class.new. We all know that Ruby is an object oriented language, and specifically it is a class based language. One of the strengths of Ruby is that it can be extremely usable without having to really understand what’s going on behind the scenes. Drift from the happy path, however, and you can find yourself wandering in a dream-world of class<<self or trying to grok the difference between ‘include’ and ‘extend’. This talk will try to explain why we have classes and metaclasses, and how it all hangs together (and a bit about the movie Inception, to keep things from getting too boring.)

Comments Off

On the Inception of the Ruby Object System, at Chicago Code Camp

Class, superclass, metaclass, singleton class, eigenclass, class <<self, class Class, Class.new. We all know that Ruby is an object oriented language, and specifically it is a class based language. One of the strengths of Ruby is that it can be extremely usable without having to really understand what’s going on behind the scenes. Drift from the happy path, however, and you can find yourself wandering in a dream-world of class<<self or trying to grok the difference between ‘include’ and ‘extend’. This talk will try to explain why we have classes and metaclasses, and how it all hangs together (and a bit about the movie Inception, to keep things from getting too boring.)

Comments Off

On the Inception of the Ruby Object System, at ChicagoRuby

Class, superclass, metaclass, singleton class, eigenclass, class <<self, class Class, Class.new. We all know that Ruby is an object oriented language, and specifically it is a class based language. One of the strengths of Ruby is that it can be extremely usable without having to really understand what’s going on behind the scenes. Drift from the happy path, however, and you can find yourself wandering in a dream-world of class<<self or trying to grok the difference between ‘include’ and ‘extend’. This talk will try to explain why we have classes and metaclasses, and how it all hangs together (and a bit about the movie Inception, to keep things from getting too boring.)

Comments Off