Malmö Coders’ Book Club

Quick report on Malmö coders’ book club: This was the initial sitting, and we were 7 people around the table. One academic, two leads, and four software engineers. We spoke English, since we were an international crowd.

At least three physical notebooks full of written notes were out, and the conversation was started based on questions people had during their reading. The conversations were personal, kind, and focused. It brings more perspective, to have people of different backgrounds, of different roles.

This was one of the peer groups I’d been looking for. 5 out of 5 thumbs.

PS: We had been reading Michael Feathers’ Working Effectively With Legacy Code. 

JRuby to support \K escape sequence in 9.1.15.0

Allow me to celebrate the JRuby team (and nearby efforts) in that the next patch release of it will include \K as a regular expression special character.

This GitHub Issue was just closed with a resolution in the Joni library: https://github.com/jruby/jruby/issues/4871

Its support is in a little select company, randomly listed at StackOverflow, which has such google-juice that it felt worth it to shout about JRuby on there.

I’ll repeat the example from the GitHub Issue:

$ irb
2.3.1 :001 > 'street'.match( /s\Kt/)
 => #<MatchData "t"> 

Travel report: MirageOS hack retreat in Marrakesh 2017

I am just back from a week off in Marrakesh.

Together with a hearty group of people from many places, I wrote and documented software in the heart of the medina. We also ascended the snow-covered mountain in the picture above.

A group around the ambitious MirageOS project gathered to enjoy community around the programming language OCaml.

The week was spent in an artsy hostel with a roof terrace and a cool riad. The sun baked during the day, the moon chilled the nights.

The week was a so-called hack retreat, with goals of making the MirageOS ecology of software better in some way. Some people brought their own agendas of what to make, and others, like me, found them when in place.

Most of this time was spent squinting at some screen or other: learning, listening, exploring. At work and in my spare time, I program Ruby in a Web setting, whereas here it was a systems programming language, in a system setting. But, I’m a dabbler at heart, and trying to keep a beginner’s mind.

Learning OCaml can be a hard slog, even if you know a few programming languages. Many alien concepts, and at times not much of a railing to hold on to. Many possibilities to describe things better for the new-comer. I was helped along by helpful and knowledgeable people. Sometimes, I could make a mental breakthrough by plowing through domain-specific jargon, translating it to something familiar. But more often it was by being near someone who was at the same place I was, the foreigner, the outsider, and we could quickly learn new things together.

I found a great collaborator in Matt, an English chap who had taken on an issue in the mirage-tcpip library. “There’s no need to use floating-point arithmetic here, we can change that to Int64 calculations on 64-bit integers instead.” I got to join him on this quest. To make the change, we read the section of the RFC over and over, made calculations on paper, authored unit tests (that became integration-like). And we fixed our mistakes in calculations on paper. At the end of the day, we had a Pull Request for the project, and were able to get some feedback. It felt great. And it was great. It even got merged.

Later, I collaborated on some package management issues in a SOCKS4 proxy library, which was improving a lot during the event.

The days were much the same: get up, clean up, have breakfast, continue programming, complain about slow the Internet. Suddenly: lunch, followed by some more programming, and then it was suddenly dinner.

At some points, the inviting organizer of the event made a “call” for talks, like: “Hey Spiros, I heard you would like to give a presentation of your parsing system Angstrom. Say at six o’clock?” Graciously, the speaker would then concede that this was a good time to present their work.

One of the talks was about solo5.  That is a “unikernel monitor”, a very thin thing to wrap the running of a unikernel. As a companion explainer, the presenter took care to link to this 5-page PDF of Williams and Koller’s conference paper from HotCloud16 (“Unikernel Monitors: Extending Minimalism Outside of the Box”). Check it out if minimalist systems is your thing.

We made a few outings, climbing the Atlas mountains and visiting a herbalist. But mostly we kept to the retreat itself.

Here is a short list of software projects I engaged with, however little:

Rating 10/10, A-plus, would learn to program OCaml with these people again.

Here is some Twitter extracts:

 

 

 

 

 

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.

Cinemateket: a personal failure to build habit

The new slimmer Cinemateket. It never really came together, my going there out of habit. Habit-forming failure, if you will.

Now that they’ve scaled it all back to a trickle of must-see films from the nowadays-much-smaller showable-as-analog past, it’s lost much of its previous smorgasbord charm for me. Choosing not to view a certain film isn’t so very charming when it’s the only film.

In unrelated habit-building: My quest to see all of Star Trek: The Next Generation, with the redoubtable Sir Patrick Stewart intoning the Federation‘s credo about not meddling where one should not meddle, continues. if a little abated. I’ve noted a tendency to fall asleep at the tail end of the story, in the late act II. Note to self: perhaps one episode is enough for a night.

Recently, I have met several trekkies, whereas before I seldom met anyone who professed to know the slightest thing about the Star Trek franchise.  Of these enthusiasts, one is a lawyer, one a nurse who speaks Chinese, and one works with computer gaming industry issues. All of them highly knowledgeable on matters Trek.

Onward, into the year. Habits will form. I’m sure of it.

 

Here, a random Star Trek TNG piece of gossip: That replacement doctor – Dr. Pulaski – won’t come back in later episodes, because of the following, passively-worded reason:

Maurice Hurley, head writer and showrunner, did not like working with McFadden, and McFadden was fired at the end of the season 1. Diana Muldaur joined the production as the Enterprise’s new chief medical officer, Dr. Katherine Pulaski, for season 2.

Series creator Gene Roddenberry admitted that the Dr. Pulaski character did not develop a chemistry with the other characters, so McFadden was approached to return as Dr. Crusher for the third season. At first, she was hesitant, but after a phone call from co-star Patrick Stewart, McFadden was persuaded to return to the role, which she subsequently continued to play through the remainder of the series.

Source: the Gates McFadden wikipedia entry

 

Export data from MongoDB 3.0 and import it into MongoDB 2.6

I just had the dream meeting with a dockerized app. This is a use-case for containerization.

I had to use MongoDB 3.0 to export some data and place it in a 2.6. Ouch: The 2.6 can’t connect to the 3.0.

A genius sat down at the exact moment of my complaining. “Just use Docker.”

So – to get and run the 3.0 Docker image of MongoDB – started with a bash shell:

docker run -ti --rm -v /Users/olle/slask/portal-test:/backup mongo:3.0 /bin/bash

(Related: this works because of the last line in its ENTRYPOINT script: entrypoint.sh (see 3.0/docker-entrypoint.sh))

When that pulls down and starts the shell, things are automated, and we land in a shell.

There, we can do the 3.0 invocation of mongodump:

mongodump -h ds012345-a0.mongolab.com:12345 -d portal-test -u portal-user -p secret -o /backup/portal-test

This gave me a dump folder at:

/Users/olle/slask/portal-test/portal-test/portal-test

I had been too generous with the wrapping folders. No biggie.

Then, the local 2.6 invocation:

mongorestore -d portal-test /Users/olle/slask/portal-test/portal-test/portal-test

Bam.

A disciplined method to fix Rubocop TODOs

Here, a listicle of advice you never asked for!

A method to locate and fix linting errors in Rubocop one at a time:

  • choose a “cop” from the .rubocop_todo.yml file
  • remove the line which includes the .rubocop_todo.yml
  • rubocop --only Lint/IneffectiveAccessModifier
  • fix issues and test fixes with the --only invocation
  • rubocop --auto-gen-config to regenerate the .rubocop_todo.yml file
  • git checkout .rubocop.yml to add back include line
  • commit this change with the name of the “cop” used

I really really tried to use it at FakeFS.

Game prep

See, this list of game preparation is soon a year old:

  • Buy skulls as game chits.
  • Invite players and nag them to confirm attendance.
  • Read the text of the scenario to play.
  • Try out the conflict system. Practice run.
  • Realize the rules are many but smart.
  • List game activities.
  • Figure out snacks and food.

 

Hold Elasticsearch back on 2.4 for Chewy on macOS

So, Elasticsearch 5.0.0 is out.

I’m using Chewy, a Ruby DSL gem that’s quite good. It’s not quite there yet with the deprecated Query APIs, (see Release Notes), so to keep using it you need to hold back to the Elasticsearch 2.4 series which is the last stable release. (Question about this, answered in the issue tracker.)

Smoky mountain top
Every upgrade is a damn climb. Yesterday was a good day. It was until 15:00 before I came upon package management issues.

Here are a couple of Homebrew invocations to stay on 2.4, with full data-loss, since the index version has been upgraded.

curl localhost:9200

The output for 5.0.0 is:

{
  "name" : "61mKC-n",
  "cluster_name" : "elasticsearch_olle",
  "cluster_uuid" : "EtOE3oHxQRSur5_qhRr-TQ",
  "version" : {
    "number" : "5.0.0",
    "build_hash" : "253032b",
    "build_date" : "2016-10-26T04:37:51.531Z",
    "build_snapshot" : false,
    "lucene_version" : "6.2.0"
  },
  "tagline" : "You Know, for Search"
}

This is the version 5.0.0 that we can’t use with Chewy.

brew services status elasticsearch

If you don’t have one of those services running, you can skip a few steps.

brew services stop elasticsearch
brew unlink elasticsearch 

Now, with a clean slate, we can ask Homebrew to install a specific version (actually, a release series, “2.4”):

brew tap homebrew/versions
brew install elasticsearch24 
brew services start elasticsearch24

If you now run curl localhost:9200 you’ll may perhaps not see JSON ouput: if your index has been running on the 5.0.0, its lucene_index version would’ve been bumped, so that 2.4 can no longer read it.

The data files used by your Elasticsearch resides in /usr/local/var/elasticsearch. My node was called elasticsearch_olle and I decided to move all of its data out to a non-important folder on my harddrive:

mv /usr/local/var/elasticsearch/elasticsearch_olle ~/slask

After that, I could

brew services restart elasticsearch24

and then curl localhost:9200, to see the following 2.4 output:

{
  "name" : "Miss America",
  "cluster_name" : "elasticsearch_olle",
  "cluster_uuid" : "ym_Ovns4RHWqh-ZRcHWxcw",
  "version" : {
    "number" : "2.4.1",
    "build_hash" : "c67dc32e24162035d18d6fe1e952c4cbcbe79d16",
    "build_timestamp" : "2016-09-27T18:57:55Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.2"
  },
  "tagline" : "You Know, for Search"
}

“Winning.”

Photo credit: Kamil Szybalski