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.)

How to use very latest Bundler in Travis

TL;DR: When Bundler has fixes in master that you need, use the specific_install Rubygems plugin to install and use Bundler directly from a git branch. Example Travis YAML configuration excerpt:

before_install:
  - gem update --system
  - gem install specific_install
  - gem specific_install https://github.com/bundler/bundler.git
Picture: taken at Cambridge U Library. This is a CC0 free stock photo. But those are nice columns surrounding and wrapping the body of the page. Also: note the shadows of the supporting lines still visible in the finished book.

I will spend the rest of this post unpacking what the above means.

In Ruby, there is a package manager called Bundler. It’s continuously developed, and like all software, can have bugs.

When a Bundler bug gets fixed, the code changes are “merged to master branch”. Then we all wait for the next release. The workarounds are about sticking to an older, non-broken version: use the -v option to choose an exact release. Example: gem install bundler -v'1.13.7'

The Rubygems system does not have a way to install gems “from a Git source URI”, but it does have a plugin system. And luckily, one of the plugins available (but not on that page) is specific_install.

allows you to install an “edge” gem straight from its github repository, or install one from an arbitrary url

In order to work around the “we all wait for the next release” step, we can install the latest and greatest using this plugin.

The plugin’s has also aliased its specific_install action to git_install. The manual claims:

This alias is shorter and is more intention-revealing
of the gem's behavior.

Source: The above Travis configuration snippet comes from a PR to the releaf project.

IndieWeb clubbery

Tonight, I made it to Homebrew Website Club hosted at inUse in Malmö. I was greeted by three kind souls, among them a proprietor of a Lego fan website with a 176 contributors – and Pelle and Emil.

The club format is the same every time: first an hour of social or at-your-computer time. Then an hour of show-and-tell explanations, demoing and showing stuff.

Emil showed us CSS and SVG techniques, some of them brilliant. SVG is a deep well to drink from. Read more at Sara Soueidan’s website.

Pelle made a very nice hands-on demo of a system of services he’s built, which involved commenting on any page using his telephone.

We had talked about Node.js a fair bit, and I showed what the private caching npm server sinopia looks like when installed. Its claim to fame is its file-based caching – don’t fetch packages from the central repository more than you need.

When I had showed that, we had used up our time, and it was time to put the crisps down and go home. How kind, to have time limit, so that people on tight schedules won’t miss stuff.

On the way out, I asked: “Pelle, do you have a exercise for me to take home?” He responded immediately: “Make your site receive or send WebMentions.”

I look forward to next time.

Aiga forward and left arrow, an example of a random SVG

Git Pre-commit hooks!

Not even once!

Run relevant code-checking tools on your code, before it is even checked in locally. Using the Ruby project Overcommit, you can set this up on your own machine in a jiffy. Or, read more about git hooks.

I took these steps:

  1. Install the overcommit gem in your active Ruby. gem i overcommit
  2. Install overcommit in your system Ruby, using this neat trick:PATH=/usr/bin:/bin:/usr/sbin:/sbin sudo gem install overcommit – This makes it available to tools like SourceTree! (On committing, it opens a bare shell, without your cool settings.)
  3. In your project directory, where you wish to begin using Overcommit to run Git hooks: overcommit --init
  4. Configure the resulting .overcommit.yml to enable/disable the checks you want run.
  5. Try committing a file which would fail a check.
  6. Profit!

PS: Here is an example .overcommit.yml:

PreCommit:
  ALL:
    problem_on_unmodified_line: warn
  CoffeeLint:
    enabled: true
  RuboCop:
    enabled: true

Looking forward to PolyConf 2015

On Wednesday, I once again journey south, to Poznan in Central Europe, to participate in the PolyConf programming conference.

Poznan Glowny

As every year, it is about getting new perspective on things, from happy and grumpy people in the field. The field of computering.

I’m lucky to see some familiar faces in the list of people going there, and I’m travelling with qerub, a good friend. (Now, by visiting his website, I saw this wonderfully Acme-hacking project: an S-expression interface to his iTunes library. It’s a year old. I feel like a bad friend for not having seen it before. And, his casing utility camel-snake-kebab has a nicely communicative README.)

Last year, some major themes that stayed with me were property-based testing, functional everything and formal verification (software proofs).

People I met were curious about things, curious about history, curious about sub-fields near their own special field of interest.

To be able to catch the ideas and whims of this three-day madness festival, I will bring a Leuchtturm note-taking book. I’m pretty excited about using it. You may see photos of it on here. Update: inspiration from Bocoups blog, which is covering CSSConf using art.

You’ll hear more from me.

Child themes and repairing them

Meta-blogging, again. It took quite a long time, and had some fits and starts, but now this blog runs on a so-called Child Theme of a freely available WordPress theme.

The trick is that I get to fiddle with small necessary things (like repairing the missing link to jQuery and some Twitter-needed meta tag) in files that are not updated and outdated when the theme gets an update.


.
|-- functions.php
|-- screenshot.png
`-- style.css

Something like that is enough. The automatically-included functions.php file makes it easy to do things the WordPress way, using their hooks-and-actions concept.

All this, and I really only wanted to install Known, the Indieweb blogging engine that supports webmentions.

Install ruby-2.0.0-p195 using rbenv, ruby-build and pkg-config

Ruby, Rails, news of new versions. Your computer’s Homebrew and ruby-build installation does not work. Something’s borked. It worked on the other people’s Debian machines. Your Homebrew system gave you… output. Some obscure error about openssl?

You search. You whine. You arrive here. Breathe.

Requirements: rbenv, ruby-build, a Ruby 2.0.0-p195 refuses to install on account of missing header files for openssl, since the Apple-bundled version is outdated.

TL;DR:

Add this at the end of your shell startup file (such as ~/.bash_profile or ~/.zshrc). Then run the installation again.

export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig:/usr/local/lib/pkgconfig

Learn how!

In order to share more of the fact-finding process, here is some narrative. All credit is due to Stuge. He told me to read, it would work. Thanks! He was right, too. It did work.

First of all, pkg-config is a neat little program. It’s the hero of this narrative. Does all the heavy archiving, noting things down, so you don’t have to.


pkg-config --debug

This lists everything that pkg-config knows about header file locations, libraries, compilation configuration settings about the libs on your system.

Begin by ensuring there is a PKG_CONFIG_PATH on your system, that points to where the currently-symlinked Homebrew packages are. Add this to your shell startup:

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

Well, this is half-way, pkgconfig can now find most of its .pc files.

The specific complaint was about openssl. Let’s go to its folder, using brew:


$ cd `brew --prefix openssl`

Now, are there any pkg-config files around? Use find:


$ find . -name '*.pc'
./lib/pkgconfig/libcrypto.pc
./lib/pkgconfig/libssl.pc
./lib/pkgconfig/openssl.pc

Ah-hah!


$ cd lib/pkgconfig
$ pwd
/usr/local/opt/openssl/lib/pkgconfig

This is the path where our pkg-config descriptions sit. Pre-pend it to its path!


export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig:/usr/local/lib/pkgconfig

Thusly, the desired result:


$ ruby-build 2.0.0-p195 ~/.rbenv/versions/2.0.0-p195
Downloading ruby-2.0.0-p195.tar.gz...
-> http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p195.tar.gz
Installing ruby-2.0.0-p195...
Installed ruby-2.0.0-p195 to /Users/olle/.rbenv/versions/2.0.0-p195

The end.

Addendum for web-crawling robots

(The obscure error mentioned at the start included here for searchability.)


rbenv install 2.0.0-p0
Downloading ruby-2.0.0-p0.tar.gz...
-> http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz
Installing ruby-2.0.0-p0...

BUILD FAILED
Inspect or clean up the working tree at /tmp/ruby-build.20130506102349.2564
Results logged to /tmp/ruby-build.20130506102349.2564.log
Last 10 log lines:
installing default gems: /home/shivin/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0 (build_info, cache, doc, gems, specifications)
bigdecimal 1.2.0
io-console 0.4.2
json 1.7.7
minitest 4.3.2
psych 2.0.0
rake 0.9.6
rdoc 4.0.0
test-unit 2.0.0.0
The Ruby openssl extension was not compiled. Missing the OpenSSL lib?

Kod100: Document a very old project

#kod100 is a thing. In Sweden. “Do FOSS stuff for a hundred consecutive days.” Keeping a log of it is optional. So, I’m dusting off WordPress. And trying.

Things experienced in this session:

Use the wp-cli command-line tool to manage WordPress. Until it’s completely package-stable, use it from the Git repository. Fine instructions at their homepage.

And, for ergonomy, I added syntax highlighting in less.

Also began the actual project, by using git-svn to pull a repo copy onto GitHub. The shared Subversion repository for all PHP extensions has quite a few revisions. Too many! A pull from the top will be more effective, I guess.

Goal of project: add some documentation to one of the oldest still-living PHP extensions: stats. Most of it is just hard to understand, since I’m no math head.

the freedom of the copy party

In The working class of computer art GOTO80 talks about demoscene parties:

What is the point? Well, I really like the freedom of the copy party. Think of it as a hackerspace disco with lots of man-beer and old music. There’s no money and no bullshit. You don’t have to network with the right people and explain your work on their terms. It’s an odd soup of CEOs, graffiti writers, headmasters, schizophrenics and academics that is hard to find elsewhere. Some people are just quiet and make music, others are fixing some hardware while the Finnish BBS-d00d is puking in the closet. Then they all crash on the floor, covered in data noise. It’s like being 16 again all over, except for the SD-cards.

Hackerspace disco!