Saturday, June 28, 2014

Android LG G Watch: First Impressions

My co-worker Ruchi gave me the LG G Watch to try this weekend, and I immediately thought it to be way too difficult for the average consumer to understand.  Since it has no power button, you have to plug it into the cradle to enable.  Also, for developers who didn't attend the I/O conference, you have to signup to join the Google Wearables Group before you can be whitelisted to download the Android Wear app.  Figuring that I had to wait at least an hour, I decided to try to use the watch later.

A few hours later, the phone defaulted into some type of retail mode, where it demo's the various functionality of the phone.  To exit this mode, I had to factory reset the watch to retry the pairing process.  The Android Wear app itself is buggy: it complains that you have to update your Google Play Services even when you have the latest version.  The smartwatch eventually showed up for pairing on my tablet, but then it failed to find Internet connectivity even though the WiFi was fully functioning.  Now I'm stuck in a state where the tablet can see the watch for pairing, but fails to do anything after the next step.

This launch for the Android wearables seems to have been rushed for the Google I/O conference. Here's hoping Google's actual release next week will actual polish all these issues.  For now, it feels like a half-baked product.

How to Factory Reset Android LG Wearable Watch

The watch has no buttons, so you have to plug it into the cradle to enable.

If your phone gets into "retail mode", you apparently have to push the small pin on the back of watch and swipe right on the screen until you get to the Factory Reset icon.

Wednesday, June 18, 2014

Building your own Python version for an easier debugging experience.

One of the major issues in using the stock Python distribution (i.e. Ubuntu) is that it's compiled with a bunch of optimizations in the final binary. You can install the debug symbols (via the python-dbg package), but if you want to be able to troubleshoot any C-based extensions, it's likely you're going to want to be able to examine what lines actually triggered segmentation dumps by using the core file.   In addition, if you can also break into a running Python process or want to inspect the memory structures to see what's actually being allocated, you unfortunately can't do this type of debugging with the standard build.

What if you simply wanted to have a version of Python that could be used for debugging? What if you still wanted to keep the standard version too? Here's the steps that I took to accomplish this goal.  To make sure the bzip2 and sqlite3 modules were installed in the Python distribution, I had to install the development packages for them.  I also had to override the default C compile flags by using OPT="" and CFLAGS="-O1 -g" (the -g flag produces debugging symbols)

cd /somewhere/you/want/source/code/
sudo apt-get source python
sudo apt-get install libbz2-dev
sudo apt-get install libsqlite3-dev
OPT="" CFLAGS="-O1 -g" ./configure --prefix=/home/rhu/.virtualenvs/pydev --with-pydebug
make install

The next step is to install the virtualenv package from source. Normally you don't need to do this part but because we are using a custom Python binary, we need to use it for the compile step.  You can download the latest version from  I decided to store it in the .virtualenvs directory that is normally created by the virtualenvwrapper package, which provides shortcuts to activate and deactivate Python virtual environments.

tar -zxvf virtualenv-1.x.x.tar.gz
cd virtualenv-1.x.x/
~//home/rhu/.virtualenvs/pydev/bin/python install

You'll need to activate the virtual environment by running the activate script. If you have the virtualenvwrapper package setup, you can also just type "workon pydev".

Note that all your Python packages will need to be recompiled.   They should inherit the same compiler flags used for building your Python package, so you should see "-O1 -g" compiler optimizations being used.  Note that I used the --with-pydebug flag, which will do some reference debugging and make your existing libraries incompatible.  By doing all of this work inside a virtual environment, you can avoid library conflicts with other installations.

(Note: using -O0 caused some code such as the librabbitmq to fail to compile for some reason, so I opted to keep the minimal amount of optimizations enabled.  If someone figures out what the minimal compiler optimizations to use that would allow the -O0 flag to be used, please let me know!  )

Saturday, June 7, 2014

How to remap Command-Tab to Alt-Tab on OSX..

I've been trying to find on Stack Overflow how to remap this key on OSX, and it appears you can accomplish this goal by using the powerful KeyRemap4MacBook program.

You'll want to download the install .dmg program and then use the software to upgrade to the latest version (for some reason, the beta version is not available on the main web site as a link).

The challenge?  How do you only enable this functionality on external keyboards, such as the Kinesis Essential keyboard?   Here's the XML that I generated that worked, relying on the docs.

Once this configuration is setup, you need to click on the reload XML and go to Key remap and enable the configuration (search for "Kinesis").

You'll also want to grant the AXNotifier program the ability to monitor changes in your window, which allow you to be more granular about what programs you want to target.  For instance, if you want to remap keys for page up and page down in Emacs, you can use the following Gist: