Automate finding misspellings in source code

Typos and misspellings in code can be difficult.

Finding them and keeping them out takes vigilance. Lots of mental energy wasted.

The misspellings tool written in Python can be installed using pip install misspellings.

This tool looks for commonly misspelled words in source code. It has a built-in list of common spelling mistakes.

Example: List all Ruby files and pass each of them to the misspellings tool, with the -f option (file list) set to - for standard input.

$ find . -name '*.rb' | misspellings -f -
./lib/celluloid/exceptions.rb:12: occured -> "occurred"
./spec/celluloid/calls_spec.rb:12: wasnt -> "wasn't"
./spec/shared/actor_examples.rb:950: slighly -> "slightly"
./spec/support/configure_rspec.rb:44: occured -> "occurred"

(As a courtesy, I edited those misspellings in the Celluloid project. It wouldn’t do to let it be made an example of and then not fixing it.)

IoPython, raw but cool

I nosed around in Io’s “addons” folder, which you also can pull from the Git repository, see the Io homepage.

Update: of course, this was reported when it was fresh, with nice examples, too: pinupgeek’s blog is full of Io goodness. (Thanks, trevor!)

While nosing, I met the Python module, which lets you run Python functions in Io. It was written last year, the copyright statement shows:

  docCopyright("Aslak Gronflaten", 2006)

IoPython lacks tests, real documentation, and such, and it does not do memory management:

* Convert an Io object to PyObject.
* At the moment, we can't pass in any objects, just those that can be translated,
* until I build a python wrapper around an io object, reverse of what I did here.
* TODO: Memory management!!!

Does not seem impossible.

But I get a nice vibe from these lines:

  # Import a module
  sys := Python import("sys")
  "Which version of python are we running?" println
  sys version println
  "System path is returned as a list" println
  sys path foreach(p, p println)
  "Load the string module" println
  string := Python import("string")
  "Split a string" println
  str := "Brave brave Sir Robin"
  str println
  string split(str) println
  "Load a C module (.so)" println
  t := Python import("time")
  writeln("Current time is: ", t time)
  "Another way to invoke a method" println
  str = "UPPERlower"
  write(str, " --> ")
  string invoke("swapcase", str) println

Io could improve its library situation, if IoPython were less raw. Things will improve with time. In the meantime, I’m gonna learn more Io.

RuPy 2007, European hacker meetup

Dear hackers: %w(Ruby Python).each {|lang| lang.discuss }

Thanks for a great weekend. “I’ll see you on the Internets” has never rung
more true than when I and Tomek and Krzysztof hurried out to a waiting taxi
(driven by a talkative bard-type, who talked “about nothing” with many words).

Now: go empty your camera, upload them somewhere, and tag the photos
rupy and rupy2007.

For those of you who just joined this narrative, I have just been to Poland,
to a technical conference. This was my second-ever visit to Poland.

The people I met were passionate, different, full of integrity, imaginative,
at play, and hospitable. The organizers and the attendees were excellent at
keeping a good, nice atmosphere. When something broke, or was postponed, the
moment was used to tell jokes, make friends, and have good times. Not a bad
word, ever. The way I want it to work, don’t change a thing.

As previously advertised on this braggy weblog, I was invited to speak at the
conference. This honour landed me my own room in a central hotel, where me and
the other speakers stayed.

Saturday morning me and Tomek went to the breakfast hall, which we managed to
find, even though the hotel was quite labyrinthine. We’d just sat down, when a
guy introduces himself like this: “I’m Adam, and the bus to the conference
leaves in 9 minutes.”

A yellow shortbus took us to Adam Mickiewicz university, a polytechnical
college on the outskirts of Poznan. I was in an expansive mood, and blabbered
on about Norse mythology being very hippy-like: Loki’s transformation to a
female horse, so he could give birth to Hel, goddess of hell, half babe, half
zombie. Among those that had to listen to this were Chris Arndt (Turbogears
speaker, from Germany) and Cloves X. Jr. (Rails freelancer, and author, from
Brazil-Canada-Dubai). Hands were shaken. Chris told us a bit about how his
local programming group’s shifted meeting format: no long presentations,
lightning-talks only, with follow-up discussions.

Krzysztof, a Warsaw friend of Tomek’s, was to do a talk about the Radiant CMS.
Program items were shuffled around a bit. Very agile, responding to change —
this let as many attendees as possible hear them. A side-effect was that we
wondered when our talks were scheduled. I got lucky, and my talk would wrap up
the first day’s Ruby track.

The rest of this rambling post will detail the talks, but I’d like to add that
the talks were only the starting point for the audience participation, in many
cases at least. You should go to conferences to interact, to do what’s
impossible online, and to learn from the audience if you speak. And the people
were just great: if you were there, and you talked to me, I probably lost your
email address (but hey, we use the Web for all those notes anyway), but I’d
love to be internet-pen-pals with all of you.

Chris A’s TurboGears talk showed step-by-step how to make “yet another
bookmark web app”, and this was good stuff. He took the time to detail how the
conventions-driven way of routing URLs with CherryPy. CherryPy is the
controller in the MVC of TurboGears. (Someone bitterly said: “CherryPy’s URL
dispatching sucks”, but at least I understood more about this. Thanks, Ola E
in Malmö for carefully explaining CherryPy to me.)

Python in embedded devices: This was the talk that my electrician would’ve
wanted to hear. The talk detailed what it was like to work with Python-enabled
hardware, that term meaning either “a small computer with flash memory instead
of a harddrive”, or “a little telephone-like unit the size of a matchstick
box” (from Telit). Inspiring to hear about off-the-shelf devices that you can
program. The term “home automation” stuck with me, a little like “family
atomics.” The downside to the Telit phone device was: their hardware Python
interpreter was at version (or something). “Audience: What are you
using it for? Speaker: I am not allowed to say.” NDAs, man.

PyPy (Python reimplemented in Python): “RPython stands for restricted Python,
and we’ve made it run up to 60 times as fast as CPython.” Full-on mad
professor style, the PyPy project has gone through an EU innovation
high-technology grant. They used the money on sprints with TDD and
pair-programming. One of the two speakers was unable to get to the conference,
but his colleague was ace.

An action-packed demo-filled talk, which among other things featured a
multi-player Bubble Bobble clone in JavaScript. And experimental Python
interpreters of all kinds. The idea is that by adding some new features to a
PyPy Python implementation (“can be done in 2 weeks”) they can optimize,
feature-add, or just experiment. Transparent proxies were an interesting style
of distributed computing, which almost removed the remote/local distinction.
The talk my head spinning with possibility, but Tomasz W. took me down to
Earth when he noted the RPython probably removed the dynamic stuff. “Otherwise
it would be too hard to generate C from it.” I’ll try and see what trade-offs
RPython does.

RLisp (Ruby-with-Lisp): Tomasz W. was very gracious, and let us early leavers
have a training run of his staggeringly geeky RLisp talk. The
implementer-inventor of this Lisp-with-Ruby, or Ruby-with-macros was a decent
presenter, and his material was very interesting. Tomasz writes a weblog, and a version of
RLisp is released, so you can go play with it. His audience was Ruby/Python
folks, so he kept the concept-count low, and explained things clearly. A warm,
nice person, and good at explaining his mindblowing ideas.

Presentation by delegation, Tomek called the second half of my talk. It was
meant to be a beginner’s introduction to making and serving Rubygems at home.
A step-by-step guide. I have to do a Companion Website for that, my material
needed meaty examples. And if I have a website for it, I won’t run out of
space. (Note to self: use the webgen gem for that.)

OK, all in all, this was a conference to remember, to keep friends from, and
to come back to.