Quickly Creating Python and Django Projects with Buildout

Terminal
Buildout is an awesome build management tool for Python projects, managing dependencies and featuring rich recipes for accomplishing advanced tasks. The main problem seems to be that documentation is lacking and/or terrible. Plus, project setup is painstaking and difficult to get right. Since I have years of experience in Maven, where creating a buildable project takes (literally) seconds to accomplish, this initially made Buildout too much of a hurdle. However, that’s now changed, as I’ve recently released version 0.1.0 of buildout-starter, an installable Python script to make creating Python and Django projects with Buildout a snap.

Continue reading

Adding Icons to a Theme in Elementary Luna

Elementary Luna IconSince I’m using Elementary Luna as my daily driver, I’m using it with a lot of apps not designed with it in mind. Rather, the Elementary icon set doesn’t include icons for these programs, such as Eclipse, NVIDIA X Server Settings, Skype, etc. Luckily, a beautiful icon set called Faenza does. By installing Faenza and patching our Elementary icon set with links to Faenza icons, we can fill in the gaps in our icon set.

Continue reading

Creating Long-Term Backups with Amazon Glacier on Linux

Amazon Glacier LogoIf you haven’t heard about Amazon Glacier already, it’s definitely something to be excited about. Amazon Glacier is a service that makes it extremely affordable to store gigabytes upon gigabytes of data for the long term in the cloud. Your data is stored immediately, but retrieval requests take at least 4 hours to make your data available again for your downloading. Let’s back up a ton of files on Linux to Glacier.

Continue reading

Quickly render text from the command line using Jinja2 and Django templating

Django LogoBoth Django and Jinja offer awesome string templating libraries. I wondered how difficult it would be to simply script some string templates for use in Bash scripts, and I found that it’s really not so hard at all.

To start, we’ll use Jinja, since I like it a bit better than Django and it seems to be faster and more lightweight. First, ensure that the Jinja2 library is installed on your system. Since I’m on a Debian/Ubuntu derivative, this is as easy as sudo apt-get install python-jinja2. Now, let’s template!

$ python -c "import jinja2 ; print jinja2.Template(\"Hello, World\").render()"
Hello, World

Let’s use a filter to convert the amount of bytes in one megabyte into a more readable value:

$ python -c "import jinja2 ; print jinja.Template(\"{{ bytes|filesizeformat }}\").render(bytes=\"1500000\")"
1.5 MB

Due to an issue in Jinja2 which hasn’t been largely released yet (as of 2012-01-16), the filesizeformat filter has an issue which will cause values to render as 0.0 MB instead of the expected result.

Awesome, now onto the same thing in Django. Make sure that Django is installed and continue:

$ python -c "from django.template import Template,Context ; from django.conf import settings ; settings.configure() ; print Template(\"Hello, World\").render(Context())"
Hello, World

As you can see, Django is a lot more verbose to get the same result. In any case, we’ll move on to formatting file sizes:

$ python -c "from django.template import Template,Context ; from django.conf import settings ; settings.configure() ; print Template(\"{{ bytes|filesizeformat }}\").render(Context({\"bytes\":\"1572864\"}))"
1.5MB

These simple examples should allow you to do some pretty rad stuff with command-line templating in Django and Jinja2.

A Better Magic Trackpad Experience in Linux

If you’re like me, you own a nice Apple Magic Trackpad. You’ve also paired it with your Linux box and it’s working great. However, it could probably work better. The defaults for the device are, in my opinion, pretty unresponsive and at times really bizarre. Let’s walk through some hacks and fixes in order to get things working better.

Continue reading

Patching btusb to enable compatibility with the BCM20702A0 chip

I just recently built a brand new machine and noticed that I wasn’t seeing my Bluetooth chip. After a bunch of digging, I found that my Broadcom combo chip which came with my ASUS Maximus V motherboard hosted both a BCM43228 WiFi module and a BCM20702A0 Bluetooth module. Stranger still is that the Bluetooth chip is actually an embedded USB device running on the PCI port.

Continue reading

Fix Bluetooth on a MacBook Pro 8,1/2/3 with B43

If you’ve been following the blog, you probably noticed that I recently had a lot of issues with Bluetooth on my MacBook Pro running Ubuntu, and then had them resolved by an awesome commenter. Apparently, if you disable Bluetooth coexistence protection in the B43 driver, then Bluetooth will be able to coexist with WiFi. I have no idea how this makes sense, so don’t ask :)

I demonstrated how to do this with modprobe:

# remove b43
sudo modprobe -r b43
# reinsert b43, with the right settings
sudo modprobe b43 btcoex=0

Unfortunately, this doesn’t work permanently, as whenever you reboot, the B43 driver is loaded with the evil Bluetooth coexistence setting enabled (again, this means that Bluetooth will not work). Thus, we need a permanent solution! Pop open your favorite text editor as root and edit /etc/modprobe.d/options and append the following line:

options b43 btcoex=0

Voila! Go ahead and reboot to test your settings. No more modprobing every time you boot!

MacBook Pro 8,1/8,2/8,3 Bluetooth Issues on Linux


Oh, by the way, I just got a shiny new MacBook Pro to run Linux on! Hooray! It’s an awesome machine, but I just wanted to post this bug to the general public to save people the 3 days I’ve spent trying to figure it out.

Essentially, what it boils down to is this: the b43 Linux driver that you’ve compiled and installed interferes hardcore with the adjacent Bluetooth chip on your MacBook.

Let’s do a little test to demonstrate. While connected to a WiFi network with b43, put a Bluetooth device into pairing mode near your machine. Make sure the bluez package is installed. Next, run the following:

$ hcitool scan
Scanning...

You’ll probably see it say Scanning... and then… nothing. It won’t see your device. Period.

Let’s continue with our experiment. Unload the b43 module with sudo rmmod b43. Your internet will go down if you’re on WiFi. Now, run hcitool scan again.

$ hcitool scan
Scanning...
    XX:XX:XX:XX:XX:XX    Nexus One

Aha! Found you! So, it seems that the problem is with the driver itself. This is kind of a bummer, to say the least, but hopefully they’ll have it patched soon. Until then, sudo modprobe b43 and continue on, weary warrior.

For the record and for Google, I’m running a 2011 MacBook Pro 8,3 with Ubuntu 11.10 Oneiric Ocelot 64bit/amd64.

Update: A Working Workaround!

As noted by Benoit in the comments below, you can actually get things working with a little workaround. First, unload the b43 driver from the kernel:

$ sudo rmmod b43

Next, reload the module, turning Bluetooth coexistence support off:

$ sudo modprobe b43 btcoex=0

As counterintuitive as it seems, it works! Hooray! I’m now able to listen to music with my Bluetooth headphones and use the built in B4331 wireless card in my MacBook at the same time!!! The only issue I’ve encountered is that when you’re spiking and getting really high upload/download rates, you’ll notice that Bluetooth audio skips a bit. Luckily, this is a pretty minimal problem and doesn’t prevent you from using your Bluetooth or your B4331 WiFi card in your MacBook Pro.