Colddirt Information

Published on Tuesday, May 29, 2007


Note: Colddirt's source code is run from Django SVN, check out on May 10th-ish. If you are using a newer branch, some things have changed. i.e. clean_data has been renamed cleaned_data. Remember to check the BackwardsIncompatible page in the wiki.

Part 1: Simple AJAX with Django
Part 2: Django Newforms Usage
Part 3: Search with Django
Part 4: Django's Syndication Framework (simple)
Part 5: Django's Syndication Framework (little more complex)

Feel free to see the source code from Github.

Ubuntu Upgrade

Published on Saturday, May 26, 2007

Having been in I.T. for quite a few years, upgrading can sometimes be quite a hassle. Having switched to Linux for many years, the crazy upgrade madness of windows is gone. So, how easy is upgrading in Linux?





Yea, pretty darn easy, I must admit. And my system certainly isn't normal! It has been an upgrade from Debian Sarge(ish) -> Ubuntu LTS(ish) -> 6.10 -> 7.04... The only hiccup was at some point when the fonts were reinstalling (I totally ignored the "close all programs" warning:





Solved: NO PUBKEY

Published on Friday, May 25, 2007

I've received this error more than once, so I'm finally writing my notes how I solve it.

Error message:


W: GPG error: http://security.debian.org stable/updates Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A70DAF536070D3A1

This really is just your standard don't-have-the-gpg-keys error. So, get'em -- take the last eight digits from the long NO_PUBKEY string that is displayed on your computer. If you are using Debian 4.0, the above key is likely correct; if you are using Ubuntu or another version of Debian, it will be wrong. (The last eight digits are used as an identifier at the keyservers). Then:
gpg --keyserver subkeys.pgp.net --recv-keys 6070D3A1
gpg --export 6070D3A1 | apt-key add -


Repeat if necessary. All done, just do an apt-get update and no more warning!

Bare-metal Restore

Published on

As you can see by my previous post, my question to squeeze more req/sec from the server, I decided to try out Gentoo (again, last time was four years ago). Now, I like Gentoo, there is no doubt about that. However, I realized things took just too long to get set up. I guess that is the disadvantage of a source based package management tool. Back to Debian I go.

Two hours later everything was up and running -- and I guess I can't complain about a two hour bare-metal restore from one distro to another. And let me iterate, this isn't just a typical LAMP boxen. It's got:


  • apache/mod_php/ssl with ~10 domains

  • apache/mod_python/ssl with ~4 domains

  • lighttpd with ~5 domains (static files)

  • about 8 gigs of web data/images

  • svn repos + web_dav access

  • mysql restored

  • postfix(chroot)/dovecot/sasl + mysql auth

  • home dirs restored

  • chrooted users again



I'm sure I missed something on this list, I was typing pretty quick. Well, that's the update. I'm gonna go tinker with mod_cache some.



Postfix/Dovecot + MySQL

Published on Thursday, May 24, 2007

As you can see by another post, I decided to reinstall the server. This isn't really a problem, I have pretty good backups. I've installed apache and friends a bagillion times. However, Postfix(chroot)+Dovecot authenticating from MySQl, that doesn't install quite so smoothly.
Just for my future reference, and maybe helpful for somebody, someday. Clearly not a tutorial. The postfix chroot = /var/spool/postfix

cannot connect to saslauthd server: No such file or directory



First, get the saslauthd files into the postfix chroot. Edit /etc/conf.d/saslauthd (or /etc/default/saslauthd), and add this:
SASLAUTHD_OPTS="-m /var/spool/postfix/var/run/saslauthd"


Second, add it to the init script.
stop() {
        ebegin "Stopping saslauthd"
        start-stop-daemon --stop --quiet /
--pidfile /var/spool/postfix/var/run/saslauthd/saslauthd.pid
        eend $?
}


Third, maybe, change /etc/sasl2/smtpd.conf (or /etc/postfix/sasl/smtpd.conf) and add this:
saslauthd_path: /var/run/saslauthd/mux


Ok, that error should go away now.

Recipient address rejected: Domain not found;


(Host or domain name not found. Name service error for name=domain.com



These are actually the same type of error. Copy /etc/resolv.conf into the chroot.

fatal: unknown service: smtp/tcp



Copy /etc/services into the chroot.
I searched google for these answers, to a certain degree at least, but couldn't really find much. Then I remembered "crap, this is a chroot, it needs things" -- and fixed stuff. If you came here from google, and these super quick notes were helpful, feel free to leave a comment, or contact me directly if you have any questions.

The Gentoo test

Published on

I have a love-hate relationship with Linux. I love it because if there is a problem, I can actually tinker and find the problem and fix it. But I hate it because I like to tinker.

Recently I've been doing a fair amount of Django programming -- enjoying every minute of it. After completing several of my projects I decided to do some benchmarks, and the results are in! Generally I can server cached/semi-cached pages at about 200req/sec. 200req! Considering this is 5,000,000 or so requests a day, and a number I am never going to reach, I still began to wonder: why isn't it higher? I mean, serving a static html page is at like 1000+ req/sec, so why would a cached page be significantly different? I started exploring and noticed that Apache would spike the CPU. Ok, time to be thorough, and as I said, I like to tinker.

I tried lighttpd as a fastcgi to python -- not a significant different, basically the same. Next I tried several versions of python -- one from 2.4 and one from 2.5, one as a package and one from source -- same results. High cpu usage. Thinking it could be something related to my VPS (or some odd limit within Debian) I decided, ok, I'll reinstall.

I reinstalled and got things working pretty quickly. The only slight hiccup was postfix/dovecot, cause postfix insists on being in a jail (and my configs are all setup for that). Also, Chinese support in Apache isn't working. Regardless, I re-ran the benchmarks and the results were the same -- so, it isn't related to my previous install after all. Doh.

I'll evaluate Gentoo as a server setup for a little while, but I'm thinking I'll do a quick reinstall of Debian.


Generating a Self-Signed SSL Cert

Published on Friday, May 11, 2007

I have the need to generate an SSL cert (Apache2) about once every 3 months. And since I'm cheap, I don't ever actually *buy* one, I just self-sign it. And every time I forget the commands needed. So, here they are, for my reference only.
1) Generate Private Key

openssl genrsa -des3 -out server.key 1024

2) Generate a CSR

openssl req -new -key server.key -out server.csr

3) Remove passphrase

cp server.key server.key.org
openssl rsa -in server.key.org -out server.key

4) Generate Self-Signed Cert

openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

Django SVN Update Goes Splat

Published on Wednesday, May 9, 2007

I'm writing this just in case somebody runs into this same issue. I'm about to go live with a website and figured it would be best to have the latest SVN snapshot checked out from Django. I updated, and noticed that my voting module didn't quite work as expected. I was getting the following error:
'module' object has no attribute 'GenericForeignKey'


I jumped into Trac and noticed that just yesterday some things were rearranged. In short, if you are using generic relations, you'll need to change two parts of your code. First, the generic relations field must be imported out of conttenttype.
from django.contrib.contenttypes import generic


And second, you'll need to change the 'location prefix' (for lack of a better description:
From:
generic_field = models.GenericRelation(SomeOtherModel)


To:
generic_field = generic.GenericRelation(SomeOtherModel)


All should be find from there on out. For more information, take a look at the reference wiki article.

PNG Transparency and IE

Published on Monday, May 7, 2007

I Hate IE!
I've vowed to not use transparent PNGs until almost everybody has switched to IE7, where they are actually supported (despite being supported by every other major browser). I've done the hacks, and have had good results. I like using PNGs, I'll admit it. Inkscape exports them directly, however one slight problem: transparency still exists. This isn't really a problem since I'm not layering images, or is it?
My initial assumption is that IE would simple pull the white background and everything would be dandy. Well, we all know what they say about assumptions.


A few options exist:

  • Convert them to GIFs

  • Try some sneaky PNG IE hack

  • Do a rewrite and send all IE6 traffic to download firefox. Err... Do a rewrite and send all IE6 traffic to download firefox

  • Open each in GIMP and add a white background

  • Use ImageMagick and convert the background to white.


We have a winner! The problem is, for the life of me, I couldn't figure out a simple convert command to do this. The quick bash script would suffice:
#/bin/bash
CONVERT=/usr/bin/convert
for image in *.png; do
 $CONVERT -background white $image $image
 echo "Finished converting: $image"
done


Note:This is gonna convert all PNGs.


So, no the transparent GIFs have a "white" base layer, IE renders them fine, normal browswers render the images fine, and I'm allowed a cup of coffee. I hope this helps somebody, if so, leave a note!