What Happened to Disk Utility?

In the Bad Old Days™ of consumer computing, there were external hard drives for sale that were “made for Mac.” Of course, that didn’t actually mean anything– a hard drive is a hard drive. Macs don’t have some kind of voodoo magic that requires you to buy drives just for them. The only difference between these and any other drive on the shelf was that 1) it came pre-formatted as HFS+, the default file system of OS X and 2) the makers of the drives charged anywhere from $10-50 more for the “Mac” model. Other than that, the hardware itself was identical. What this meant was that the smart move was to just buy the normal drive and re-format it yourself. The manufacturers just used the “for Mac” label to extract some extra money out of people who didn’t know any better.

For the past few years, I haven’t bought a drive like this; I used an external enclosure and just bought bare drives. When one filled up, I’d buy another bare drive. This is a backup strategy for really cheap people, and it works fine. External 3.5” enclosures, though, are mostly terrible. They require their own power, they’re ugly, and replacing the drives is a pain. When it came time to replace the drive most recently, I decided to get a “real” external hard drive.

It was more than a little suprising to find out that The Old Way of selling external drives is alive and well. Here’s one example of many: two of the exact same Western Digital 1TB drive, the Mac version with a price $15 higher.

Of course I assume I won’t be fooled by this, that I am A Smart Person™, and I’ll just get the cheaper drive and format it myself.

Bad move.

It wasn’t until the drive made it to me that I plugged it in and opened the Disk Utility, which apparently got a complete rewrite for Mac OS 10.11.

This is a complete mess.
This is a complete mess.

A few of the problems I encountered while trying to format this drive as HFS+, which (as expected) arrived formatted as NTFS:

I also attempted to make this work without the new Disk Utility GUI, just by using the Terminal diskutil (Disk Utility.app is just an interface for this), but didn’t have any better luck. The disk has been returned and a “for Mac” version is on the way. Turned out, I wasted way more than $15 worth of my time trying to be A Smart Person™ on this one.

I still don’t know what exactly the problem is, but if the drive was a lemon, Disk Utility gave me no affordances to be able to tell. It is so bad that attempting to use the new Disk Utility on a known-good drive and on a broken one are completely indistinguishable.

Some Books I Read this Year

In no particular order.

Liu, Murakami, Fleming

The Three-Body Problem

As hyped as this was, it was probably impossible for it not to end up on my reading list this year. There’s enough technical detail that it borders on hard sci-fi but not so much that you’re completely bogged down in it1. Recommended if you’re a fan of general science fiction; it isn’t too fantastic (no spaceships or lasers).

The Wind-up Bird Chronicle

If you’ve read Murakami, you know what to expect from this. I, on the other hand, had never read Murakami before I picked this one up. It’s completely perfect and completely bonkers in that way that only Murakami can write. I could not for the life of me tell you what exactly this book is about, and somehow I couldn’t put it down.

The Man with the Golden Gun

It’s one of Fleming’s original Bond novels. No other description necessary. If at no point during the summer you have ever grabbed a Bond book and read it by the pool, do yourself a favor.

Rothfuss, O'Malley, Cline

The Name of the Wind

Of all the books in this post, this one is the biggest question mark after having finished it. The writing is undeniably good, but the material isn’t up my alley. It’s a sort of Lord of the Rings meets Harry Potter fantasy story but it somehow leans too old to be Harry Potter and too young to be Lord of the Rings. While I was reading it I kept asking myself who exactly the intended audience is. Word of advice: this is the first in a trilogy, and it ends in a cliffhanger, so if you don’t like this style enough to commit to all 3 books, you might be disappointed. I doubt I will read the other two.

The Rook

Another good summer/poolside read. Just good old fashioned fantasy/sci-fi. Don’t think too hard about it, just enjoy it.

Ready Player One

Never let it be said that Ernest Cline does not know exactly what his millennial audience wants. This book is as low as low-brow literature gets but goodness is it addictive. It may be a meme by now but I have nothing bad to say about it. Besides, it’s a quick enough read that even if it had been terrible, I couldn’t have lost much time on it. Recommend.

  1. If you want to be pedantic, the problem described in the book is #actually a four-body problem.

OCR With Tesseract and Ruby on El Capitan

I recently had a need to extract some text from a photo taken with my phone. Some quick research on this mostly arrived at recommendations for the tesseract library. Tesseract is a C (and C++) program, but because of the way some other pieces of this project work, I wanted Ruby bindings for it.

Good news: there is a tesseract ruby gem.

Bad news: If you use the default tesseract on Homebrew and the default tesseract-ocr gem, you get a crashing error when trying to include it in the script. It looks something like

/Users/micah/.rvm/gems/ruby-2.1.2/gems/ffi-inline- `compile': compile error:

The problem is that the version of tesseract that Homebrew currently installs (since 21 August 2015) is 3.04, which is not compatible with the Ruby side of things in the current gem. This new Tesseract has a ProcessPages function which formerly stored its value in a STRING*, but in 3.04 was changed to instead put the result in a new class called TessRenderResult. Ruby is still expecting process_page to store its value in a STRING*, but this isn’t happening. According to one Github Issue on the ruby-tesseract-ocr project, there may never be a version of this gem that works with both pre- and post-3.04 versions of tesseract.

Fortunately, there is a relatively painless fix for this, but I had to spend all morning reading Github issues before I found the one that has the fix to get there. Maybe this will save someone else some time.

Homebrew has support for installing a previous version of a formula. In our case, we want Tesseract 3.02. Make sure you’ve done a brew update && brew upgrade, then do the following:

If you’ve already installed Tesseract 3.04, uninstall it with brew uninstall tesseract.

Tap the homebrew-versions keg with brew tap homebrew/versions.

We can now install past versions of formulae by URL. The most recent non-breaking Tesseract is at this URL (links to the raw file). To install it, just brew install that URL:

brew install https://raw.githubusercontent.com/Homebrew/homebrew/be42e223cb58d9d7f94215a7607a8aa9a0b594b2/Library/Formula/tesseract.rb

You may also need to gem uninstall tesseract-ocr and reinstall it, but after that, the gem worked for me exactly as the documentation describes:

require 'tesseract'

e = Tesseract::Engine.new {|e|
  e.language  = :eng
  e.blacklist = '|'

e.text_for('test/first.png').strip # => 'ABC'

"Open in TextMate" Toolbar Item for El Capitan

Surprisingly, there doesn’t seem to be an easy way to do this floating around for the current versions of TextMate and OS X. Here’s an up-to-date method on how to get a Finder toolbar button that opens the current Finder directory (only the directory, this won’t work on files) in TextMate. It looks like this:

A Finder toolbar item for "Open in Textmate"

It’s a tiny AppleScript saved as an .app bundle. The script is:

tell application "Finder" to set currentDir to (target of front Finder window) as text
do shell script "/Applications/TextMate.app/Contents/Resources/mate " & (quoted form of POSIX path of currentDir)

Save this as “Open in Textmate” and make sure in this window, the File Format is set to Application. It can’t be run from the Finder toolbar if you don’t save it this way. Put it somewhere you’ll always have it like iCloud Drive or Dropbox, that way you can add it to more Macs later if necessary.

After saving, navigate to wherever you put it, hold down the ⌘ key and drag it into the Finder’s toolbar. You’ll probably also want to give it an icon- I spent 45 seconds on Google and decided on this one