I wrote a brute-force solver in Ruby for the combination-lock puzzle

I wrote a brute-force solver for the “Can you crack the lock code?” / “Can you open the lock using these clues?” puzzle.  Apparently there are a few slightly different versions:

On Puzzlebrain.com, rule 5 contains 7-8-0.

On Puzzlersworld.com, rule 5 contains 8-7-0.

In the one I saw (in a friend’s Facebook post), Rule 5 contains 3-8-0.

The puzzle states that for a 3-digit combination lock, where each
digit is a value between 0 and 9, the following clues are known
about certain combinations:

6-8-2 “One digit is right and in its place”
6-1-4 “One digit is right but in the wrong place”
2-0-6 “Two digits are right, but both are in the wrong place”
7-3-8 “All digits are wrong”
3-8-0 “One digit is right but in the wrong place”

It has been years since I last wrote Ruby code professionally, but I
really enjoyed using it, so I decided to dust off my rusty Ruby
skills today and write a concicse, fairly idiomatic program to
brute-force a solution to this puzzle.

Here it is: https://github.com/JamieFlournoy/Lock-Puzzle-Solver/blob/master/lockpuzzle.rb (There are instructions in the top of the code for how to run it on your computer or in a browser-based Ruby interpreter.)

If you’re curious about the different versions of rule 5, you can edit the code to try those different variations. In fact, why not try commenting out the code where it tests rule 5, to see what the results are when rule 5 doesn’t apply at all? ;)

OTP codes from Mac not working due to Mac clock running fast

I’m a fan of Time-based One-time Password, aka TOTP, as a means of Two-factor authentication. I’m also a fan of the 1password password manager, which I have set up to sync between my various devices: a laptop Mac, an Android phone, and an iPad. A nice feature of 1password is that it will act as an OTP authenticator, if you store the TOTP secret (either copy-pasted as text, or scanned as a QR code that decodes to a URL containing the same text) alongside your password info. So if I’m lying in bed with only my iPad nearby and I need an OTP code to log into something, I don’t have to get up and grab my phone to get it from Google Authenticator. (I do also have the OTPs in Google Authenticator though.) More importantly, this means that none of my devices is a single point of failure; if my phone is stolen or dies, I can still get into stuff because I have the secrets synced to multiple devices, encrypted in transit and at rest by the password manager.

But, this all stops working when your Time-based OTP is generated on a Mac with a clock running over a minute fast!

Continue reading “OTP codes from Mac not working due to Mac clock running fast”

Favorite monospaced coding fonts as of late 2018

As a professional software developer, looking at source code has been a huge part of my job for a couple of decades now. It’s really, really important that the display I’m looking at is sharp and properly color-calibrated for appropriate contrast, and that the font I’m using is clear not only when reading letters, but also when displaying various special characters that are commonly seen in source code (so that things like { and } are obviously different from ( and ) and [ and ], and so that @ is clearly different from & or * or %.).

For this reason, every few years I check out the latest and greatest “programmer fonts” and see which one will let me make the type really small while still being clearly legible, so I can get lots of source code on the screen at once.

Read on to see my current favorite programmer’s font, and the ones that I think are almost as good.

Continue reading “Favorite monospaced coding fonts as of late 2018”

Solving macOS Error -69784, “Unable to create Core Storage Logical Volume Group”

FileVault’s full disk encryption is a really nice feature of macOS, and making a bootable full-disk daily backup of your Mac’s internal hard disk or SSD using Carbon Copy Cloner or SuperDuper! is a great way to avoid downtime if your internal hard disk dies. You just reboot from the backup drive and get back to work, having lost at most 1 day of work.

However, you may encounter trouble when trying to create an encrypted bootable volume on your external backup drive. I had no trouble finding helpful articles to tell me how to reformat the external drive as encrypted, or even to convert the disk non-destructively to an encrypted volume, but none of them actually worked. In every case, the UI was happy to say it was gonna encrypt the drive and even gave me a recovery code and took a passphrase for the encryption, but then failed with the following message:

Unable to create Core Storage Logical Volume Group.

Continue reading “Solving macOS Error -69784, “Unable to create Core Storage Logical Volume Group””

Making macOS High Sierra 10.13.1 work with 2 displays again

I have a Mac Mini (“Late 2014″) hooked up to an Asus PB278Q 27” display and a Dell 2405FPW display. This setup has served me well for two years, but today the Mac stopped talking to the Asus monitor for some reason. After some fiddling, I was able to fix it.

Continue reading “Making macOS High Sierra 10.13.1 work with 2 displays again”