If you’re like me, you end up doing a lot of testing in virtual machines. I run several VMs that do various different tasks for me so that I don’t have to sully my Mac with packages I rarely need, etc. So what I do is create a VM and give it a local hostname defined in my /etc/hosts file.

Recently, after my upgrade to OSX Lion, I started running into an issue where it would take over 5 seconds to connect to any of my VMs using any protocol (SSH, HTTP, etc). After several hours of troubleshooting, and several Wireshark sessions later, the truth of the matter was plain:

OSX is now doing IPv6 by default with no way that I have found to disable it yet, and so that means that if you have hosts that you want to reference with locally defined hostnames, you are going to have to create an IPv6 entry for them as well.

Here is a great site that I found that helps with the conversion: SubnetOnline.com

I am sure that there are better ways to do this, but I just wanted to share this quick little hack that I found with you. If you have a better way, please let me know!

I have recently upgraded to OSX Lion, and I have to say that I love everything about it. Except for one thing. In many apps, the key repeat has been disabled in favor of the new press-and-hold popup for getting alternative characters.

This is fine for most apps, but for apps like PyCharm where I use vi key maps, it becomes very, very frustrating.

I came across this little tip to re-enable the key repeat, and my life is measurably better (first world problems, I know…).

Run the following in your Terminal.app:

$ defaults write -g ApplePressAndHoldEnabled -bool false

Then reboot, and you should be good to go!

We use a Campfire at Needle for our day-to-day communication between our tech team members and other business members. We really like Campfire’s ability to store files, conference call and keep transcripts even when you are not logged in. We get GitHub commit messages, Pivotal Tracker story updates and more scattered in our conversations.

These one-way updates are very nice, but I thought it would be nice to be able to have a bot that sat in the channel and could take commands from anybody and do more complex tasks for us without us ever having to leave Campfire. To solve this problem, I wrote Campy, a pure Python Campfire bot with an extensible plugin system.

The first plugin I wrote as a proof of concept is a Google image search plugin. You tell the bot some search parameters that you would like it to search for, and you get back an image inline in your chat transcript. Don’t worry, safe search is on by default so you don’t get any NSFW images back.

The second plugin I wrote was the all-important Pivotal Tracker plugin. This plugin lets you do the following:

  • pt story create "Title" "Description" bug|feature|chore|release – Create a story

  • pt getmine started|finished|delivered|accepted|rejected|unstarted|unscheduled – Get a list of all stories that belong to you

  • pt start #story_id – Start a particular story.

  • pt start|tell next bug|feature|chore [mine] – Start or tell the next story of a given type. Optionally supply ‘mine’ at the end of the message to only work on your own stories.

The plugins system is very extensible, so you can create a plugin to do pretty much anything!

You can get Campy here: https://github.com/bbelchak/campy

A few months ago, I started investigating the health benefits of standing while I work at my computer. The benefits are myriad, and include:

  • More calories burned. Standing at a desk while you work can actually burn around 300 calories per day more than sitting.

  • Standing at a desk helps people with back problems. Humans were not made for sitting, and doing so for long periods of time can be really hard on your hips and lower back.

  • Improved posture. Standing can help improve your posture, which can relieve pain in your lower and upper back, and neck.

  • More breaks. I find that I take more breaks, which makes me happier and healthier. While standing, it is easier to just walk away instead of hauling yourself out of a chair.

After my research, I decided to convert my cheap IKEA desk into a standing desk by raising the legs up as far as they could go and then stacking books and Rubbermaid bins to get the height on the keyboard and monitors right. Here’s what I ended up with:

As you can see, it is less than ideal. It forced me to stand 100% of the time, and in order to take a break from standing, I needed to disconnect my laptop from everything and take it to a chair. Not awesome.

I reverted back to a sitting desk, and kept wishing for a standing option that would allow me to quickly change to a sitting position if I got tired, without having to deal with completely rearranging my work area.

Then, I discovered the Ergotron WorkFit-S while searching around for standing desk options. I loved the youtube video I found here:

I bought the WorkFit-S Combo (laptop + LCD) on Amazon with overnight shipping with my Amazon Prime account, and it arrived very quickly. I was a bit worried because the tech specs indicated that the maximum monitor size is 20” while using a laptop. I spoke with one of their marketing people on Twitter, and they were very helpful, checking with their support staff and product managers to provide me with any tips that they could dig up while I anxiously awaited the FedEx delivery guy.

When I received it, I immediately installed it on my desk. It took approximately 15 minutes to get it built and installed on my desk. My 24” LCD fit perfectly on the right, with my laptop on the left. I think the concern with the size of the monitor is not necessarily the size, but the weight. I could probably fit a 27” on here without a problem if it was light enough. My LCD and laptop are probably right on the edge of the maximum weight. Since the up and down motion is achieved with a pulley system, I had to adjust the tension a bit to get the balance right.

I did have to move it after I’d installed it in the center of my corner desk because the mouse tray kept hitting the desk where it curves.

The thing will attach to virtually any surface, but they also make a wheeled cart that has similar features.

I am very happy with it so far, and I look forward to reaping the benefits of standing, while having the option to sit!

The Ergotron WorkFit retails for around $399 and you can find them on Amazon.com or elsewhere.

In my previous post about unit testing for django, I laid the groundwork for how to unit test any django application. One nice feature that django includes with its test framework is the test database syncing. Even better is if you are using South to do database migrations - it will run the migrations in  your test environment for you.

However, what if you are using a NoSQL database backend like MongoDB, Cassandra, CouchDB or something similar and you aren’t using the Django ORM? How do you handle setting up and tearing down the database environments?

The good news is that Python’s unittest framework makes this easy. You can override the setUp() and tearDown() on each TestCase that you build. Here is a snippet to get you started:

import pymongo
from django.test import TestCase

# It would be best to define this in a utility class somewhere
def get_db(db_name=None):
    """ GetDB - simple function to wrap getting a database
    connection from the connection pool.
    return pymongo.Connection(
                settings, "MONGO_DBNAME_PREFIX", "") +
                (db_name or settings.MONGO_DBNAME)]

class MyTestCase(TestCase):
    fixtures = ['test_data.json']
    def setUp(self):
        self.db = get_db('test')

    def test_doc_published(self):
        # Set up a document to save
        doc = dict(text="test",
            {'user_id':1})['text'], 'test')

    def tearDown(self):

What this does is setUp() a collection in the mytestcollection collection, runs the my_doc_published test and then tears down the test database environment by dropping the mytestcollection collection.

Things to remember for setUp() and tearDown():

  • setUp() is called before every test method in your TestCase class.

  • tearDown() is called after every test method in your TestCase class.

  • tearDown() is called even if your test methods fail or error out.

And there you have it! Django makes testing even non-ORM datasources a snap, if you know how to wire it up. UPDATE: Some would say that database fixtures and setting up/tearing down database environments as part of your unit tests is not “unit testing”. This is not entirely accurate, because in order to do unit tests that rely on backend data, you must instantiate and tear down pristine database environments.