Pages

2.08.2016

On alarming

https://docs.google.com/document/d/199PqyG3UsyXlwieHaqbGiWVa8eMWi8zzAn0YfcApr8Q/edit

Debugging with certainty

One of the things I've been trying to learn lately is how to debug. I've always dreaded the thought of debugging someone else's code as there's no documentation, or their code is terrible, or I'm dumb, or all of the above. I'll say to myself "there's not much that I can change if those are the reasons, other than damning my luck". But that's no solution.

After talking with a very brilliant co-worker and friend, he suggested me to watch this talk. He knew I'd bite instantly as the speaker is a Clojure developer and I'm a Lisp fanboy. I have to say that I loved the talk but for a deeper, less obvious reason. I'll explain.

Debugging with the Scientific Method gives you certainty in an uncertain situation. Those familiar with psychology will agree with me that there's nothing the mind avoids the most other than uncertainty. Not knowing what to do or where to go makes you feel uncomfortable and, if you are prone to it, panic. Under such circumstances, one of the responses is to flee. Quit. Surrender. Give up. Probably try tomorrow?

Having a tried and true method to debug (and fix) things is The Silver Bullet. No matter what your problem is, no matter how badly documented or how many sins in your codebase. Follow the process. Carefully. Systematically. It will take time (screw schedules!) but you'll fix it. That's a certainty.

Emacs + OSx + iterm2 = Meta key works!

Three years ago I got a Mac laptop at work, and it was my first contact with Mac/OSx. Two of those three years I avoided using it for any meaningful work. There were weeks at a time that I didn't even carried it with me. Not so much because I didn't like it (hey, it's a Linux under the hood!) but because all my work environment was already set up in my work desktop and I'm not a fan of duplication.

Everything was well until curiosity got me (and I started working from home more frequently) so I decided to get out of the comfort zone and really try to use it. It's been a year already. I can say that the most painful thing has been getting the Meta key in Emacs to work correctly. I was able to avoid finding a solution for a year (boy, am I lazy!) and settled with half-solutions like using Esc instead, but now it is inevitable to find one since I bought a personal laptop recently. 

I tried first some of the stuff here: https://www.emacswiki.org/emacs/MetaKeyProblems
The first more or less useful set up was to swap modifier keys in System Preferences but that changed the whole layout for other applications and it meant strain injury for apps that weren't emacs. 

Finally, this is the stuff that worked:
  • In System preferences: 
    • Keyboard > Modifier keys > Reset all to default
    • Spotlight > Uncheck "Spotlight menu keyboard shortcut" or set it to something else 
  • Install and launch iterm2
  • In the iterm menu > Preferences > Keys > Remap modifier keys, set:
    • Left command key: Control
    • Right command key: Control
    • Leave the rest on default
  • Now in iterm menu > Preferences > Profiles, set:
    • Left option key acts as: +Esc
    • Right option key acts as: +Esc
  • Profit!
Happy emacs!