logo
Header graphic 4 of 9

Categories

Archives

Other stuff

Other sites

I wish this site were powered by Django

February 23rd, 2008

Wordpress Plug-ins available

Filed under: General, PHP, Technology — jm @ 00:48

I packed up some of the code that I wrote to customize my site. It can be downloaded on my plug-ins page. The first two plug-ins available are:

  • maurusnet_geoip_amazon

    A plug-in that helps to embed Amazon partner links into your site by using MaxMind's GeoIP database to find the right Amazon site (country-wise) for your user.

  • maurusnet_archive_widget

    A plug-in that makes Wordpress' default "Archives" sidebar widget more accessible by putting it in a <form>-tag and making it work if JavaScript is disabled. You can see this plug-in in action right next to this post under "Archives"

I hope you find these helpful. If you use them, feel free to drop me a line, or a comment on the plug-in's page. I'd appreciate it.

Also, don't forget that the sourcecode of my bookmark search engine is also available on its help page

February 22nd, 2008

PHP sucks… now even more.

Filed under: General, Java, PHP, Python, Technology — jm @ 01:52

I finally made the time to update I'm sorry, but PHP sucks. This part of my site gets by far the most traffic and I found it important to update it to reflect all the changes that have occurred since I originally wrote it in 2006. I also created a new sub-section on programming languages where I'll write down trivia about Java and Python and other programming languages that I use daily, concentrating on weaknesses and bugs that are less-known, but can become highly volatile for a project.

Of course, I don't have nearly as much material on Java and Python like I had on PHP, but you never know, perhaps I'll even receive a few suggestions :-).

February 15th, 2008

The state of Django and Unicode support

Filed under: Django, Python, Technology — jm @ 14:11

I still get a lot of traffic from my post Django 0.95 has unicode problems, too, but a lot has changed since then. So I'll try and give a short overview:

While Django-0.96.1, the current stable version, has no real integrated Unicode support, the Unicode-branch was merged into Trunk on the July, 4th 2008 in changeset 5609. With that patch Django gained full Unicode support and it also is finally possible to use legacy databases. There's an ongoing discussion about allowing UTF-8 characters in usernames on the developer mailing-list in Django's authentication. Also a lot of "general functionality that's necessary for a real website"-patches have become available over the 12 months:

  • FileFields and ImageFields now work as expected in newforms since changeset 5819

  • There's a pretty stable patch for large file uploads available that passes all tests, but has not been committed yet in ticket 2070

The newforms-admin branch that aims to align Django's excellent administration application with the newforms library tracks Trunk pretty closely and Michael Trier has a screencast that shows how to convert an application to newforms-admin, so that might also be a good place to start if you want to use the newforms-admin application.

The GeoDjango branch that integrates Django's ORM with GIS support also seems to have become quite stable and was recently featured on the excellent This Week In Django podcast #8. This Podcast by Michael Trier has replaced the "This week in Django"-posts on the Django weblog. I liked "reading the news" better, but Michael does an excellent job, so tracking this Podcast is important if you're serious about using Django!

So there you have it :-), things have come a long way since 2006. Even more information can be found in the excellent (and freely available) Django book.

February 14th, 2008

Qmail recipes 1: Forwarding mail and changing the envelope sender

Filed under: Technology, qmail — jm @ 04:29

So, I figured out a few things about qmail, vpopmail and spamassassin recently and this post will kick off a small series of the more curious things I learned. This will not be a series of "setting up qmail for standard mail" how-tos, because enough of those exist already. If you need help with setting up qmail start here, but instead of netqmail, I'd recommend John Simpson's combined qmail patch and his service-qmail-smtpd-run script. So here's the first recipe!

How do I forward emails from an account and change the envelope sender?

If you want to forward bob@test.com's emails to alice@example.com, you just put "alice@example.com" into /home/bob/.qmail and /home/bob/.qmail-default and that's it, right?

A small cave-at of this technique is that it retains the original email's envelope sender. So Bob's email addresses (bob and bob-ext) are now permanently redirected to Alice, but if someone still sends mail from Bob's email-account, Alice might receive a bounce. If that happens the forwarding might break, because in qmail's case, the envelope sender will be "#@[]" (a null-envelope sender is explicitly allowed in RFC 2821, it was intended for bounces and such). However, simple spam-checkers, like the MFCHECK-patch for qmail, will refuse envelope senders without a valid MX record. So the bounce will never get through to Alice.

As it turns out, you can avoid qmail-local's forwarding in a .qmail file and pipe the message directly into qmail-inject, providing an explicit envelope sender using the QMAILSUSER and QMAILSDOMAIN environment variables like this:

|env QMAILSUSER='forward' QMAILSDOMAIN='test.com' \
   /var/qmail/bin/qmail-inject -a alice@example.com

The "-a" parameter is important, because it prevents qmail-inject from resending the forwarded mail to everybody listed in the email's "To:", "Cc:" and "Bcc:" headers. By using "-a" the email will only be sent to Alice.

Usually qmail-local would put the forwarded mail directly into the queue again, by bypassing this and going through qmail-inject we get more control over that process.

My qmail recipes:

03/02/2008: The second recipe is online here: Integrating qmail with nixspam and spamassassin

February 12th, 2008

Content optimization

Filed under: PHP, Technology, Web — jm @ 19:07

Experimenting with YSlow, a FireBug plug-in for Firefox, has proven very productive. I've said it before: FireBug in combination with the Web Developer Toolbar and Jesse's Bookmarklets makes Firefox the best web development environment around.

So I spent an hour today improving maurus.net's YSlow rating. In detail, I added general output compression support by enabling zlib.output_compression in my php.ini and adding a deflate filter for JavaScript and CSS files. I also added "Expires"-headers to images, CSS files and JavaScript files. These optimizations alone, together with disabling ETags, as recommended by the YSlow FAQ, made a huge difference in this site's loading speed. Last but not least, YSlow pointed out some redundant <script> tags on the front-page.

Here's the Apache configuration I used:

FileETag none
ExpiresActive On
# images and css expire after two weeks
ExpiresByType image/gif A1296000
ExpiresByType image/jpeg A1296000
ExpiresByType text/css A1296000
AddType text/javascript .js
ExpiresByType text/javascript A1296000

AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/css

While I did all this, I also had to solve the problem that updating files for my weblog wouldn't be as simple anymore, because users would visit my site with old stylesheets and JavaScripts for two weeks when I updated my site. I decided to do the following:

  • JavaScript libraries like YUI now live in versioned directories like /yui-2.4.1/.

  • All CSS files and JavaScript files that belong to my site get a query-parameter appended to their URL that is equal to their last modification date. Thus, as soon as the file changes, its URL changes, too. Here's an example of how I load a CSS file in my header.php:

    @import url(realstyle.css.php<?php 
    echo '?ts=' . 
    date('YmdHis', 
      filectime(TEMPLATEPATH . '/realstyle.css.php')); 
    ?>);

    The resulting URL looks like this:

    @import url(realstyle.css.php?ts=20080212171452);

In summary, with a primed cache, this site will now load a lot faster than before, but if I change anything the changes will still be reflected the moment I make them. The only caveat is that I can't change images on the fly without changing their filenames, but that doesn't bother me much because I never did that anyway.

February 06th, 2008

Yay, shipping software rocks

Filed under: General, PHP, Python, Technology — jm @ 02:02

I always like that feeling when you're getting something out the door, even if it's just a small update to your own site. So check out the new front page. Having just 5 recent links from del.icio.us which additionally required you to allow JavaScript from a different domain always bugged me. This has finally changed.

You can read about the cute little webservice that powers the new front page here. Like most software I write right now, it's written in Python.

Aside from that I refactored a few small bits of the theme

  • The magnifying glass in the header has a darker background to make it more prominent

  • The included copy of Yahoo! UI is now 2.4.1

  • I whipped up a plug-in to modify WordPress' included "Archive" widget so that it's more accessible when it's in select-box form (it lives in a form now and has a "Go"-button)

  • Subsequently I switched off the long monthly archive list in the weblog's sidebar. I wanted to do this to make room for future enhancements.

The beautiful part of it is that I had a good excuse to do all this because I needed to acquaint myself with different autocomplete widgets. Now back to doing real work...

February 03rd, 2008

YUI 2.4.0 has been out since December, finally adds CSS selectors

Filed under: Technology, Web — jm @ 15:49

I missed a lot of news since November. In the meantime, Yahoo! UI 2.4.0 was released, which finally adds CSS selectors. Over the last few months I pretty much tightened my belief that I'd currently only consider 3 JavaScript libraries for web development:

  • Yahoo! UI, because it was the first library with a real commitment to non-obtrusive JavaScript (which also includes the ability to work with other libraries).

  • JQuery, because its idea of "chaining" commands and selectors, as well as that it was the first library to allow you to select subsets of XHTML pages loaded via XMLHTTPRequest. The new YUI release goes a long way to close that gap.

  • moo.fx and mootools if I need a very light-weight framework that keeps download size to a minimum, or if I just need some JavaScript helpers.

I don't recommend prototype.js/Scriptaculous or dojo anymore, primarily because prototype.js had bugs in the past that I tripped over and it tends to conflict with other libraries and dojo's documentation sucks, I never seem to find what I'm after.

This page runs with YUI btw. Now... back to reading 23000 other news items that I missed since I moved back to Munich :-).