Saturday, June 28, 2014
How to Factory Reset Android LG Wearable Watch
The watch has no buttons, so you have to plug it into the cradle to enable.
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)
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 http://pypi.python.org/packages/source/v/virtualenv. 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.
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! )
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 http://pypi.python.org/packages/source/v/virtualenv. 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 setup.py 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! )
Monday, June 16, 2014
Learning Python's C Extension API through librabbitmq
Another writeup here about how to use Python's C Extension API:
http://engineering.hearsaysocial.com/2014/06/16/learning-python-c-extensions/
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:
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:
Wednesday, May 21, 2014
Experiences with Celery v3.1
Our experiences with Celery v3.1 so far:
http://engineering.hearsaysocial.com/2014/05/21/experiences-with-celery-v31/
http://engineering.hearsaysocial.com/2014/05/21/experiences-with-celery-v31/
Saturday, May 10, 2014
Celery v3.1 asynchronous loops
I've written an entry here about Celery v3.1 and issues with the current async loop design:
http://engineering.hearsaysocial.com/2014/05/02/celery-v31-and-async-loops/
Pull request here:
https://github.com/celery/kombu/pull/353
http://engineering.hearsaysocial.com/2014/05/02/celery-v31-and-async-loops/
Pull request here:
https://github.com/celery/kombu/pull/353
Saturday, April 12, 2014
Twilio and Heartbleed
Seeing these errors? It seems that when Twilio changed certificates after the Heartbleed incident, they also may have created issues with older httplib2 libraries that do incorrect cert validation.
CertificateHostnameMismatch: Server presented certificate that does not match host api.twilio.com: {'notAfter': 'Apr 10 23:59:59 2015 GMT', 'subjectAltName': (('DNS', 'twilio.com'), ('DNS', '*.twilio.com')), 'subject': ((('countryName', u'US'),), (('stateOrProvinceName', u'California'),), (('localityName', u'San Francisco'),), (('organizationName', u'Twilio, Inc.'),), (('commonName', u'*.twilio.com'),))}
It turns out that the logic for the host check is pretty faulty. Since there are two alternate names defined (twilio.com and *.twilio.com), the for loop needs to iterate across the second one. However, because the regexp pattern fails on the 1st entry, it returns false and fails the validation. (Pdb) host
'twilio.com'
(Pdb) hosts
['twilio.com', '*.twilio.com']
for host in hosts:
host_re = host.replace('.', '\.').replace('*', '[^
if re.search('^%s$' % (host_re,), hostname, re.I):
return True
return False
Upgrading to httplib2 v0.8 seems to have done the trick. Why? Note where the return call is made now:for host in hosts:
host_re = host.replace('.', '\.').replace('*', '[^.]*')
if re.search('^%s$' % (host_re,), hostname, re.I):
return True
return False
Subscribe to:
Posts (Atom)

