Hyper Key on Mac without Karabiner

A Hyper Key is an extra modifier key that can be used to add extra keyboard shortcuts in tools such as hammerspoon. The most common method on a Mac was to use your Caps Lock key as your Hyper key using a tool called Karabiner Elements. The issue with Karabiner though is that it is a kernel extension and keeps running into problems with newer OS X releases. If your only use case for Karabiner is to remap the Caps Lock key - you may be able to use the OS X native hidutil utility to achieve the same result.

For example, the code below remaps the Caps Lock key to F18.

hidutil property --set \

F18 can later on be used in hammerspoon as a modifier to bind to various functions.

The above hidutil setting does not persist after reboot - so it can be configured to be set at boot using launchctl

Put the xml below into ~/Library/LaunchAgents/com.local.KeyRemapping.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
              "HIDKeyboardModifierMappingSrc": 0x700000039,
              "HIDKeyboardModifierMappingDst": 0x70000006D

There is also a handy generator located here in case you’d like to remap other keys.

Philips 346B1C

If you’re looking for a good monitor for your home office setup, I highly recommend the Philips 346B1C.

Things I like:

  • Nice wide, curved, screen.
  • Reasonable sRGB color accuracy for the price.
  • Display Port over USB type C - works well with newer gen Macbooks.
  • The same type C cable also powers the laptop and connects other USB peripherals.
  • Convenient USB expansion ports on the side to plug in a keyboard/mouse.

Philips 346B1C

America from the Air

The skies were mostly clear at the start of a recent flight from the Bay Area heading back home so I took the opportunity to take some aerial pictures with my Pixel 4 XL, It was very intriguing to see the changing landscapes over the breadth of the continental US. I tried to identify some of the locations that I was flying over. I wanted to get every state but missed quite a bit of the flyover country in between due to cloudy weather.

Compile Commands on Android

The clang compilation database (compile_commands.json) is a json file that has instructions on how to compile your file. If your project uses soong, you can follow the instructions here

However, if your project does not yet build with soong, you can use bear to generate it from make files on Android.

  1. Install Bear
  2. Create an incremental_build.sh script with the following contents and put it somwhere, like in ~/bin
. build/envsetup.sh
lunch $TARGET_PRODUCT-userdebug
cd $1
find . | xargs -I {} touch {}
mm -j32
  1. Run the following on the target you’d like the compile_commands.json for, for example - you can do the following for surfaceflinger
bear bash ~/bin/incremental_build.sh \

Hugo Reboot

My blog was previously based on Octopress - decided to just switch to Hugo today after I had a few issues with Ruby. So far the experience has been quite smooth and Hugo works well on Windows too. I’m using a slightly modified version of this theme

C/C++ Source Code Completion With YouCompleteMe and Vim for Android and the Linux Kernel

YouCompleteMe is currently the best clang based completion engine for vim/neovim and there is also an emacs version.

A gif is worth a thousand words -

vim ycm completion

I’ve been using YCM for a while for C/C++ code completion in the Android source tree as well as the Linux kernel and it just works without any need to generate tags. It also does syntax error checking on the fly with syntastic, which is an added bonus. The basic idea is to rely on .repo as a marker to set up the necessary header paths in ycm_extra_conf.py for userspace and Kbuild as a marker for the kernel. Here is my configuration for vim. The python part of the configuration below also works with emacs.

  • Install vim > version 7.04 or the latest alpha version of neovim. This can be easily done with brew on OSX or linuxbrew on Linux.
  • Install YCM for your OS with the clang completer. I’ve only tested Linux and OSX
  • Configure YCM with the following options in your ~/.vimrc
let g:ycm_complete_in_comments_and_strings=1
let g:ycm_key_list_select_completion=['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion=['<C-p>', '<Up>']
let g:ycm_autoclose_preview_window_after_completion = 1

"This assumes your kernel directory has the word 'kernel'
if getcwd() =~ "kernel"
    let g:ycm_global_ycm_extra_conf='~/ycm_extra_conf_kernel.py'
    let g:ycm_global_ycm_extra_conf='~/ycm_extra_conf.py'
  • Copy the contents of this gist into ~/ycm_extra_conf.py and that should be it for userspace code!
  • To configure the kernel for code completion, copy the contents of this gist into ~/ycm_extra_conf_kernel.py. This may or may not work on all kernels, I’ve had varying levels of success depending on the level of clang support in that kernel version, It does seem to work fine with kernel 3.10.

UPDATE - Aug 25, 2015: Updated this post with links to the full config files and edited the ycm configs to avoid the need for sourcing the build environment.

Mermaid: Javascript Based Sequence Diagrams and Graphs

Mermaid is a nice javascript library to generate sequence diagrams, flowcharts and graphs from markdown-like-syntax. It is based on d3.js.

It also has a command line tool, but there is currently no option to style the output with that tool.

I wanted to use it internally for personal projects along with some CSS styling so I threw together a small webpage using angular that generates mermaid diagrams from it’s syntax. The webapp is located here (source)

Right now, I typically type out the syntax and just take a screenshot with ⌘+Shift+4 to embed it in my documents - though I hope this can be improved with proper sharing features in the future.

UPDATE: The webapp has been merged into the official mermaid repository and is located here and several major improvements have been made since!.

Of docking Stations 4k Monitors

Macbook Pros are powerful developer machines that you can hook up monitors and keyboards to to convert into nice workstations. Yet, Apple doesn’t provide any standard dock for them. Enter, the Caldigit Thunderbolt Station, which is a great little docking station for expanding peripherals for devices that support Thunderbolt.

I have a keyboard, mouse, headphones and an Android device for debugging connected to this docking station. Originally, I also had one 4k monitor hooked up as well with DisplayPort 1.1. However, DisplayPort 1.1 is only capable of 4k@30fps. For regular use, 30 fps is too janky for my eyes, so I had to go back to 60 fps. Option one was to go back to a lower resolution - but that’s not progress!

So I chose Option two - which was to switch the display to DisplayPort 1.2, support for which came in a point update to Mavericks.

Unfortunately, the bandwidth on the first version of thunderbolt is still not sufficient to drive the 4k monitor@60 Hz. This meant that I in the end still have to connect two thunderbolt cables to my MBP, one for my peripherals (keyboard, mouse, debug USB cable, ethernet) and the other for the 4k monitor.

I’m happy with this solution though, since I still do not have to plug in all of the other peripherals each morning as I get in to work.