Get Weechat meta keybinding to work on a Mac

I recently began using Weechat as my IRC client on Ubuntu. I typically work on an OSX laptop and use Terminal to SSH into my Ubuntu workstation where I keep weechat running in a tmux session. This works great, but I had trouble getting META keybindings to work.

I wanted to use the option ⌥ + ↑ / ↓ arrow keys to navigate jump between windows. These commands will add those keybindings to weechat:

/key bind meta-A /window up
/key bind meta-B /window down

However after adding these bindings it still didn’t work for me. After some exploration I discovered Terminal needed to be configured to send the expected the key codes when pressing the option key. I manually added these by opening “Terminal > Preferences… > Profiles > Keyboard” and adding the following entries into Terminal’s Key/Action table:

Key: Cursor Up
Modifier: Option
Action: Send Text
input: \033A (enter this by typing the Esc key, then shift+A)
Key: Cursor Down
Modifier: Option
Action: Send Text
input: \033B (enter this by typing the Esc key, then shift+B)

And this solved the problem!

Note: selecting “Use option as meta key” did not have any impact on this scenario.

How to connect Apps to Google services after enabling Two Factor Authentication

I enabled two-factor authentication on my Google account today, and the change caused my chat client to lose access to my Google Account (I use Messages.app on OS X to connect to Google Talk). When I enabled TFA, Messages.app showed this message:

talk.google.com
Messages can’t log in to user@domain.com because your login ID or password is incorrect.

Entering my Google Account password did not resolve this. It turns out that enabling TFA causes Google Account passwords to no longer work with Apps. You must instead setup and use App-specific passwords, which is done using Google’s App passwords page.

In my case I had already entered my Google Account password into Messages.app (as opposed to the Google generated App-specific password), and been denied access by Messages.app. This tripped things up. Messages.app continued to reject the now correct App-specific password another half-dozen times. If Messages.app has already rejected your password, try restarting the app and re-entering the correct App-specific password. That seems to work smoothly.

In summary, if you enable TFA on your Google Account you’ll need to create App-specific passwords for your apps to use to connect to Google services such as Google Talk:

  1. Enable TFA on your Google Account (Sign-in & Security page).
  2. Generate an App-specific password for Messages.app (Google’s App passwords page).
  3. Quit Messages.app, re-open, and paste the App-specific password into the dialog when you connect.

Hope this helps.

Pattern Traps

Design patterns are ideas for solving problems that commonly occur in software development. Patterns provide a language framework for programmers, helping us to discuss abstract concepts in an efficient manner.

If you’re not familiar with design patterns, I highly recommend reading the seminal work by the Gang of Four: Design Patterns: Elements of Reusable Object-Oriented Software. Its a bit dry but an excellent read. I remember when Joshua Storck recommended the book to me many years ago; it opened my eyes to a higher level of programming and helped me grow from a task implementer to a software designer.

Patterns are helpful for structuring thought around problems and forming elegant solutions. However, there are a few things to keep in mind: Patterns have consequences, and patterns are not best-practices. Programmers must still apply thought. Terry Chay describes this in his article, Challenges and Choices.

I just came across an article by Amy Hoy in which she describes the dangers of over relying on patterns. She’s spot on:

People no longer treat patterns as the shared wisdom of experts, however. They are inclined less to bang their heads against a problem and then consult the Book of Wisdom to see what it says about their particular problem. Instead, they treat patterns as Wal-Mart for decisions. They don’t know what they want, exactly, but hey, this little item here on the shelf looks like a potential candidate.

They start with a pattern and see how to make it fit.

This is bassackwards.

We all build our own patterns around problems we’ve encountered. But just as with design patterns, its important that we force ourselves to think through problems creatively before jumping to more commonly treaded paths.

Installing MacFusion

I recently setup a new MacBook Pro for web development. While trying to mount a samba share I discovered MacFusion, an application that lets you treat various remote storage mechanisms as if they were folders on your local hard drive. MacFusion is built on top of MacFuse, which is the OSX port of the Linux based FUSE that facilitates building filesystems that run in userspace.

Continue reading “Installing MacFusion”

Organizing log files into date based directories

I recently had to grep through a few hundred thousand log files in a single directory. The logs dated back several years and had never been organized into directories. In fact, there were so many log files that grep’ing the directory resulted in an “argument list too long” error. This error is described clearly here, and the quickest solution is to use find to pipe the filenames into grep using xargs:

find . -name "*.log" -print0 | xargs -0 grep "xyz"

Continue reading “Organizing log files into date based directories”

The new VCR

The garage door opener is to me what the VCR was to my parents. After struggling with the garage door for a few hours, I decided I better write down some instructions.

I have a Craftsman garage door opener with three buttons on the controls. It uses rolling codes but aside from that all I can tell you is it sucks, its loud, and it never seems to do what I want it to, like opening.

Continue reading “The new VCR”