since upgrading to macOS Sierra

Of course I need to re-install Command Line Developer Tools without XCode, same after every upgrade.

Robs-MBP:themadkatter rl$ git pull orgin master
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Robs-MBP:themadkatter rl$ xcode-select --install
xcode-select: note: install requested for command line developer tools

Itty Bitty City

Found this rather nice Ardunio kit, which integrates nicely with LEGO compatible components.

Hooking into ActiveRecord logging

Quick and dirty hook to log long SQL queries and their caller.

ActiveSupport::Notifications.subscribe 'sql.active_record' do |name, start, finish, id, payload|
  time = (finish - start) * 1000
  if payload[:sql] && time > 500
    time = (time * 1000).to_i / 1000.0
    c = { |l| l =~ /something_(core|music|artists)/ }[0]
    logger ='log', 'active_record_slow_queries.log'))"(#{time}s) #{payload[:sql]} - #{c}")

Ruby WTF #1

Answers on a postcard.

2.2.0 :004 > %w( dave )
=> ["dave"] 
2.2.0 :005 > %w) dave )
=> ["dave"]

I'm so dizzy

Playing with generating SVGs manually, we’ll with a txt file of the image and HAML and Ruby but still…

It’s only appropriate really to link to YolkFolk at this point.

Comparing plain old Ruby objects

Try Google-ing for <=> it not very helpful. It’s the spaceship method, I can never remember that. So in my case I had a custom classes representing a remote resource and I needed to compare if these objects were similar based on their id. If you compare object == other_object, they won’t be the same because they are different objects in memory. You could write…

class Tentacle
  def ==(other) ==

..but what about >, >=, <, <=, !=, etc. Comparable covers all of this.

class Tentacle
  include Comparable
  def <=>(other) <=>

…but what if the object you’re comparing against is an instance of another class?

class Tentacle
  def <=>(other)
    return nil unless other.is_a?(self.class) <=>

And that was the day that was.

Test expiry of a PEM Certificate

Want to test the expiry of PEM Certificate?

Robs-iMac:something roblacey$ openssl x509 -enddate -noout -in config/certificates/ios/production.pem
notAfter=Apr 21 16:55:18 2017 GMT


RangeError (2918996727 is out of range for ActiveModel::Type::Integer with limit 4):

If you’re attempting to store an IP as an Integer in MySQL, you’ll find that an Integer just isn’t enough. I hadn’t noticed for a few days and came home to a log file full of

RangeError (2918996727 is out of range for ActiveModel::Type::Integer with limit 4):

Easily fixed.

Database changed
MariaDB [robl]> ALTER TABLE fossa_logs MODIFY ip bigint(20) NULL;
Query OK, 209 rows affected (0.03 sec)             
Records: 209  Duplicates: 0  Warnings: 0

Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT

Comparison of a UTF-8 string and an ASCII-8BIT string fails.

2.2.2 :031 > "∞".force_encoding('UTF-8').include?("∞".force_encoding('ASCII-8BIT'))
Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT
	from (irb):31:in `include?'
	from (irb):31
	from /Users/roblacey/.rvm/gems/ruby-2.2.2@upgrade-ruby2/gems/railties-3.2.22/lib/rails/commands/console.rb:47:in `start'
	from /Users/roblacey/.rvm/gems/ruby-2.2.2@upgrade-ruby2/gems/railties-3.2.22/lib/rails/commands/console.rb:8:in `start'
	from /Users/roblacey/.rvm/gems/ruby-2.2.2@upgrade-ruby2/gems/railties-3.2.22/lib/rails/commands.rb:41:in `<top (required)>'
	from script/rails:6:in `require'
	from script/rails:6:in `<main>'

Docker innit...

##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/

docker is configured to use the default machine with IP
For help getting started, check out the docs at

Robs-MBP:pledge_core rl$ docker run hello-world
Unable to find image 'hello-world:latest' locally
Pulling repository

03f4658f8b78: Pull complete 
a3ed95caeb02: Pull complete 
Digest: sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca36966a7
Status: Downloaded newer image for hello-world:latest

Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:

For more examples and ideas, visit:

Just testing what’s now running.

Robs-MBP:pledge_core rl$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORS
default   *        virtualbox   Running   tcp://           v1.10.1