coderefinery

Linux: Fixing an unreliable network connection with ASUS P8Z 68-V onboard LAN

Recently I got a new ASUS P8Z 68-V motherboard and CPU, and had been having some strange network issues with it when running Gentoo Linux. The problems included connection failures after random periods of time and generally slow download speeds. The only way to get the connection running again after it failed (which was every …

Linux: Fixing an unreliable network connection with ASUS P8Z 68-V onboard LAN Read More »

Nosetests: Capturing log messages written to stderr

This is a tip for using the Python logging module in conjunction with unit-tests. When using the root logger to write debug messages, e.g. ¬†import logging .. logging.debug(‘x = %s’ % x) to capture the messages and write them to the console when running nosetests, pass ‘root’ to the –log-debug nosetests option. E.g. nosetests test_module1.py …

Nosetests: Capturing log messages written to stderr Read More »

Ubuntu/Debian: see files installed by package

Checking the files installed by a package is easy enough with the Synaptic package manager (Right-click package > properties > installed files tab). Here’s how to get that information without leaving the comfort (cough) of your bash terminal: $ dpkg-query -L package_name For example: $dpkg-query -L flashplugin-installer /. /usr /usr/lib /usr/lib/xulrunner /usr/lib/xulrunner/plugins /usr/lib/mozilla /usr/lib/mozilla/plugins /usr/lib/iceape …

Ubuntu/Debian: see files installed by package Read More »

Vim: pasting text without it cascading

If you’re like me and use highlight + middle click pasting in Linux a lot, you may have tried to paste text in a Vim window at some point… with surprising results. For example, highlight the following text: import re for test_string in [‘555-1212’, ‘ILL-EGAL’]: if re.match(r’^\d{3}-\d{4}$’, test_string): print test_string, ‘is a valid US local …

Vim: pasting text without it cascading Read More »

MySQL + ODBC + Python

How to connect Python programs to a MySQL database using ODBC on Ubuntu 10.04 LTS (Lucid) This guide assumes you already have a MySQL server set up somewhere Install needed packages: sudo apt-get install unixodbc unixodbc-dev python-dev libmyodbc (libmyodbc is the MySQL driver for ODBC) Get current version of pyodbc: If you have python-setuptools installed: …

MySQL + ODBC + Python Read More »