Removing Unused ContentTypes

I’ve been cleaning up my personal blog a bit, and I noticed that my tagging system recently broke. I’ve investigated the cause, and it appears to be because I removed some apps but the contenttypes remained. This meant that whenever I tried calling a tag with a TaggedItem that had been deleted, I was getting this error: 'NoneType' object has no attribute '_meta' The solution is to first list all app_labels for contenttypes, and then delete any not in use.
Read more

Integrate imified into Django

I recently had the desire to send small updates to my so called lifestream page via XMPP/GTalk. I played around with Twisted Words and several other Python XMPP clients, but I didn’t really want to keep a daemon running if unnecessary. It turns out imified took a lot of the pain out of it. The steps for me were as follows: Create an account with imified, and create a URL, e.g. /app/api/ We then configure the urls.conf
Read more

Enable ICMP through UFW

I like using Ubuntu’s UFW command, but today I needed to allow outgoing ICMP. I received results as so: $ ping 4.2.2.2 PING 4.2.2.2 (4.2.2.2) 56(84) bytes of data. ping: sendmsg: Operation not permitted ping: sendmsg: Operation not permitted ping: sendmsg: Operation not permitted To allow outbound icmp I edited ‘before.rules’ and added the following lines. $ sudo vi /etc/ufw/before.rules # allow outbound icmp -A ufw-before-output -p icmp -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT -A ufw-before-output -p icmp -m state --state ESTABLISHED,RELATED -j ACCEPT
Read more

Using HTML in a Django form label

I recently had the need to add some HTML to the label for a form field using Django. The solution is pretty easy, except I didn’t see it written explicitly anywhere, and I missed the memo of the function I should be using. My form first just had the HTML in the form label as so: from django import forms class AccountForm(forms.Form): name = forms.CharField(widget=forms.TextInput(), max_length=15, label='Your Name (why?') However, when I displayed it, the form was autoescaped.
Read more

Ubuntu 10.04, Django and GAE - Part 1

I’ve started to get into Google’s App Engine again, and have started developing a simple product that I had a use for. The initial first draft was a quick 200 lines in webapp, and it worked great. However, I’m starting to find certain things quite cumbersome. I’m a huge fan of Django, and but also about keeping things as simple as possible, which is why I picked webapp to begin with. I’m now considering making a swap to Django, but there are some development issues; namely, I’m using Ubuntu 10.04, Python 2.6, and Django 1.2. This setup presents several setbacks, as GAE has the requirement of Django 1.1 and Python 2.5. There are two solutions that I found: a) use virtualenv, …
Read more

Ubuntu 10.04, Django and GAE - Part 2

All my Django sites are running 1.2, which poses a conflict with writing apps for Google’s App Engine, as use_library currently only supports < Django 1.1. There are two solutions that I found: a) use virtualenv, or b) chroot, which I’ve already detailed. This document will hopefully show you how to create a virtual environment to use a secondary django version, especially for GAE. Of the two options, I think this one is a bit quicker, but there will likely be tradeoffs that a chroot environment can deal with better, e.g. python imaging (I don’t use it for GAE). First, install PIP and virtualenv:
Read more

Debug Postfix Tip

One thing I love about open source stuff is that the developers usually take great care to allow awesome debug messages. There’s a catch-22, however: how much logging to enable? Today I was creating a Postfix/Dovecot/Postgresql install and I kept getting an error message in mail.log, but it wasn’t very helpful. Luckily you can turn up the verbosity in Postfix for error messages. You’ll need to find out what component is in error, e.g. “postfix/virtual[4467]: warning:”, and then open master.cf. Add a -v to the end of the daemon that’s faulting, and you’ll get more logging than you know what to do with.
Read more

Retiring Old Websites

Sometimes all good things come to an end. There aren’t too many links going into either of these sites, but I’d like to redirect all of them to a page on my blog saying the website doesn’t exist anymore. I’ve already created simple screendumps for nostalgic purposes with the Firefox plugin Screengrab!, so the remaining simple server-side steps are: Edit the DNS records from the live server to the server with the notice page is on. Create a new vhost on the server the notice exists on, add old websites as ServerAlias. Add a redirect in the vhost to the notice about the retired sites. Reload apache config. The below vhost entry will redirect any link to the retired sites to the notice …
Read more

Reduce Bandwidth By Shrinking Images

A friend has a simple WordPress-based website that I set up for him a few year ago - and he likes to post a lot of images. For various reasons I have it hosted on my VPS in Australia, which only comes with 15GB of bandwidth, most likely because I got a crazy good deal on it. The problem is, that isn’t much bandwidth. Each page of his site was previously using almost 10MB of bandwidth per view - which meant the 15GB was running out. I deduced the high usage in Firebug and noticed it was gasp from large images, some almost 1MB large. The images on the server are contained in subdirectories under a gallery folder - and I wanted to resize them. What I actually wanted to do was:
Read more

Vortex86DX Instructions from ICOP

Alexandru T. and I have exchanged a few emails, and he sent through a few helpful suggestions that were provided from ICOP. I have included them below. Thanks Alexandru! Install Debian 5.0 on a normal PC (using a netinst image, for minimal install) After installation boot normally from the same PC Then, take the kernel from ftp://icop.com.tw/DIS_info/VDX/operating_system/VDX_Linux/linux-image-2.6.30-vortex86mx_1.0_i386.deb and then issue the following commands : # dpkg -i linux-image-2.6.30-vortex86mx_1.0_i386.deb # update-initramfs -k 2.6.30-vortex86mx -c # update-grub # restart Then take the hard-drive and install it on the Vortex86DX When GRUB menu appears, press “e” and modify the boot loader as …
Read more