agaskar.com

ragaskar's blog

apt-get: Sub-process bzip2 returned an error code (2)

If you get this error, it can seemingly be fixed by commenting out all your sources (in /etc/apt/sources.list, and possibly in /etc/apt/sources.list.d) and doing an 'apt-get update', then uncommenting them and 'apt-get update'-ing again.

Which really isn't so much a "fix", as it is a workaround, but hey, it works! I'm ok with it being magic for now.

As a side-note, if you're running etch, you want the git from the etch-backports repository (which started this whole mess for me). The etch stable version is 1.4.4, which appears to have a slightly different command set -- ie, 'git init' does not work. That was enough for me to want to make sure I'm using the latest. Not sure if there's incompatibilities between old and new versions of git, but no sense in taking any chances.

Reverting to XP from a dual-boot GRUB.

My old laptop (a Dell Inspiron 2200) was configured to run XP and Debian Etch. It turns out that I was using Photoshop and Illustrator enough that I rarely booted into Linux

Tangentially: I've since found that VMware on a sensibly speedy machine works fantastically: I've got an Ubuntu install running alongside XP, and it's very convenient to be able to switch into an Linux environment without needing to reboot. Out of 3 GB of RAM, it has 1 GB dedicated to it and 10 GB diskspace. Performance of the VM seems fine (I've turned on paravirtualization, fwiw) and seems to have no noticeable effect on my day to day usage of XP (although the only memory hungry XP app I use is Firefox).

As I'm using the Gateway m6824 as my primary machine now, my older laptop travels with my girlfriend to her job; due to the awkward partitioning decisions I made (out of a 40GB machine, I allotted 10GB for each primary boot, and then used the remaining 20GB space for file storage and Windows paging) it was starting to become troublesome for her to run. After the jump, I'll go into detail about how I rolled back to a pretty vanilla XP install on one partition without a reinstall.

Auto-completion with apt-get

tab completion with apt-get install is possible by sourcing the bash_completion script -- which should already live in /etc/bash_completion if you're running debian. Simply type:

source /etc/bash_completion

Very handy -- I've sometimes had to look at package names two or three times before typing them in correctly. This also enables tab completion for a number of other things.

To have bash_completion enabled every time you login, add the following line to your /etc/profile file:

source /etc/bash.bashrc

Then open /etc/bash.bashrc, and uncomment or add the following lines:

# enable bash completion in interactive shells
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

EDIT: I've read some complaints that bash_completion overrides or breaks typical tab-completion behavior. I haven't noticed any instances yet, but caveat emptor.

Django On Google App Engine -- First Thoughts.

I'm in the midst of converting a semi-complete Django application to deploy on Google Apps Engine. It's not going as smoothly as I'd like, to say the least. After the jump, my first thoughts on the subject and a couple gotchas I ran into.

Handling GET vars in django templates using custom template filters.

Django has some fantastic features for pretty URLs, but I haven't been able to find an elegant way to handle multiple GET vars.

Now, it may just be that making requests with GET vars isn't very 'django'-like, but I find GET vars are a very appropriate vector for view filters. Sticking sort and search filters into a URL is problematic, because it will result in unnecessarily long URLs filled with placeholders. After the jump, I look at some examples and explain how I've decided to solve the problem (for now).

Installing XP on a Gateway M-6824 Laptop

I'll admit it -- I gave up on Vista. It seemed like every 20 minutes the extra loud fan on my Gateway M-6824 would start whirring, and I was super-annoyed by the two-step flow to the Task Manager. (I hated the obviously tacked-on User Access Control, but that was quickly turned off). After the jump, a touch more whining about Vista and how to install XP on a M-6824.

BeautifulStoneSoup: Getting XML tag properties

BeautifulSoup is pretty easy to use, but I find the documentation confusing at times -- some of the simpler applications aren't covered in sufficient detail, or at all. One of these is a clear example regarding the fetching of XML tag attributes, a pretty common task. Getting a tag attribute is covered in the documentation here:


The attributes of Tags

Tag and NavigableString objects have lots of useful members, most of which are covered in Navigating the Parse Tree and Searching the Parse Tree. However, there's one aspect of Tag objects we'll cover here: the attributes.

SGML tags have attributes:. for instance, each of the <P> tags in the example HTML above has an "id" attribute and an "align" attribute. You can access a tag's attributes by treating the Tag object as though it were a dictionary...
[goes on to show an HTML example with ID attributes]

Although it's not made explicit, the same sort of syntax can be used to grab attributes from XML tags. This means that getting an XML attribute from BeautifulStoneSoup is as easy as soup.tag['attributename']. The one gotcha is that BeautifulStoneSoup converts everything to lowercase -- if the actual XML looks like <tag AttributeName="foo">, then soup.tag['AttributeName'] raises an exception. This part isn't so well-documented.

Let's look at a brief real world example after the jump.

Super simple Drupal clean URLs with lighttpd.

Agaskar.com runs lighttpd to squeeze the most it can out of a tiny 64M VPS (which, believe it or not, Drupal 6.x can run on -- I usually have about 2-4M free at any given time, and probably could've had a bit more had I chosen a 32-bit architecture instead of a 64-bit one!) I've been meaning to turn on clean urls on agaskar.com for awhile, but everything I'd read about drupal clean urls with lighttpd seemed to be a bit of a hack (redirecting a 404 to the index.php page) or reputedly didn't work perfectly.

This URL rewrite solution using a LUA script, however, seems to work great and only took 5 minutes to drop in. Read on to learn about the minor changes to these instructions I made in order to get it working on my server.

Another reason to love django: the regroup template tag.

If you've ever done any CMS work, you'll know that you'll often want to group a list of database records together by date or another properties. Django makes this easy with the regroup template tag. Read on to find out how it works.

admin page memory issue / WSOD with free tag taxonomies in Drupal

If you're using free tagging, you will eventually WSOD (White Screen Of Death) your admin content manage page. I say eventually, because one of our projects has 64M of mem allocated to each PHP thread (a non-trivial amount, imho -- if you're wondering, it's set that high to permit large uploads) and it's WSOD-ing on 32K tags. Now, 32 thousand tags might seem high in the context of creating a useful taxonomy, but consider that flickr hit twenty million (presumedly unique) tags this January 2008 after about 4 years of operation, so it's not absurd to think that this issue might affect you if you use free tagging.

After the jump, an explanation of why this field white-screens, and how to fix it.

Syndicate content