Peter's Blog

Redefining the Impossible

Posts made during February 2005


I wanted to use my favourite VIM script runscript under Ubuntu Linux. This script is my python IDE as it adds the following key presses:

F11
mark script to execute with python
F9
open output window
F12
run script, show results (stdout) in output window

However the F9 button was not working. This turned out to be because it was trying to open a file called 'Output window' which does not equate nicely to a unix file name. Running

:%s/Output window/Output_window/g

on runscript.vim in vim itself fixed the problem.


Filed under: linux php python ubuntu vim

2 Comments

Wanted to install the wonderful Cheetah Template Library on Ubuntu Linux and was rewarded with this:

> sudo python setup.py install
Traceback (most recent call last):
  File "setup.py", line 10, in ?
    import SetupTools
  File "/home/pcw/download/Cheetah-0.9.16a2/SetupTools.py", line 23, in ?
    from distutils.core import setup
ImportError: No module named distutils.core

Found this article which told me to install the python-dev package. Apparently the Ubuntu folk have decided to mess around with the Python standard library and chop it into small bits. I guess they enjoy searching through package lists more than I do.


Filed under: cheetah linux python ubuntu

1 Comment

Interesting to see that the new MSN Search can generate results in RSS format which is essentially XML and easy enough to crunch in python. You just submit a query and add '&format=rss' to the end, e.g.:

http://search.msn.com/results.aspx?q=peter's+blog&format=rss

gives this. What's useful about this?

  • can interrogate a search engine without screen scraping (hastle, hoping web page format does not change) or using the google api (limited to 1000 searches/day). There may well be terms and conditions that will stop bots doing 10,000,000 searches a day.
  • could set up aggregator to repeat search terms.
  • could be a use for firefox's live bookmarks.

Searching MSN for 'peter's blog' puts this site first smile Google reserves this for Tom Peter's Blog.


Filed under: blog firefox google python rss

1 Comment

I never did get around to trying to install awstats. I've been using Statcounter but I fancied trying awstats with reverse DNS turned on. I can't do this on my Site5 host as they don't like reverse DNS. I didn't install it on Gentoo as that looked like big time hastle.

I realised today that installing awstats under Ubuntu should be as simple as installing the awstats package and it almost is. I can install it on my home server, download my Site5 access logs there and let awstats format them up.

Here are the steps I had to take to install it:

  • Install awstats package
  • Edit a file called /etc/awstats/awstats.hostname.conf where hostname is the hostname. Put something like this in it:
    LogFile="/var/log/apache/access.log"
    LogFormat=1
    DNSLookup=1
    DirData="/var/cache/awstats/"
    DirCgi="/cgi-bin"
    DirIcons="/icon"
    SiteDomain="hostname"
    AllowToUpdateStatsFromBrowser=1
    AllowFullYearView=3
    
  • Make a directory called /var/cache and chmod it 777 so it can be used from the web server
  • Copy icons to web directory:
    cp -r /usr/share/awstats/icon /var/www/icon
    
  • Run this to update databases:
    /usr/lib/cgi-bin/awstats.pl -config=hostname -update
    
  • In your web browser, go to the url:
    http://hostname/cgi-bin/awstats.pl?config=hostname
    
  • Study the stats in quiet awe
  • Edit crontab to update stats automatically every night:
    crontab -e
    0 1 * * * /usr/lib/cgi-bin/awstats.pl -config=hostname -update
    

5 Comments

I saw in my logs that someone was searching on my site on how to create a Drupal block for flickr. It's easy:

  • On your flickr account, create a badge
  • Copy the badge code
  • in Drupal, create a block of type 'php' and paste the flickr code into it.

This will show selected or random photos in a selection of sizes. It works very nicely.

I chose to centre the pictures in the block by surrounding the code in a centred div:

<div style="text-align: center">
[flick code]
</div>

Filed under: drupal flickr php

5 Comments

Been working on a new theme for my sites, something with round corners and shadows, xhtml and css. It's a really hard process of trial and error, testing it out in available browsers:

  • Firefox
  • IE5
  • IE6
  • Mozilla 1.6
  • Lynx

I've just spent a few hours on a weird problem in IE6 showing round corner bitmaps: the images were all slightly corrupted, as if they were not being displayed in the right place by a few pixels or were being partially overwritten:

images/ie6bug.gif

I spent hours fiddling with this, making sure my gif's didn't have transparent bits, googling for IE6 bugs etc but no joy. On a hunch I checked out the Drupal site and saw that the rounded corners there were corrupted as well.

I tried my new site with IE6 on my desktop pc and it was perfect.

Problem must be something strange about the graphics drivers on my Dell Inspiron 500m laptop.

New theme coming soon: it's already XHTML validated and has earnt a little badge: unlike Drupals bluebeach smile


1 Comment

Put my new Drupal theme in place on my site. Some design notes:

  • It is xhtml + css, no tables, hand coded. That means big time trial and error.
  • It uses fancy rounded corners and shadows as these have been fascinating me. It's more a technology thing than a statement. My design skills are not good enough for this to be a statement.
  • It uses the Drupal phptemplate engine.
  • For a development tool I wrote a python script that would allow me to code the html like this:
    <div id="abox">
        <style>
            background: blue;
            font-family: verdana;
        </style>
        Hello Peter.
    </div>
    
    The python script parses this using the HTMLParser library, extracts all the <style> declarations and automatically generates the css file, e.g:
    .abox {
        background: blue;
        font-family: verdana;
    }
    
    I found this a better way for me to work, without having to switch between an html file and a css file (a process akin to maintaining c and h files in C programming).
  • The screen is resizable, it doesn't restrict the viewer to a 600 pixel wide strip down the middle of their £1000 21 inch monitor.
  • Choosing a colour scheme is hard for an engineer, especially a male one. I used this colour scheme generator in an effort to make it tasteful.
  • Tested on:
    • Firefox 1
    • IE 5
    • IE 6
    • Opera 7.54
    • Mozilla 1.6
    • Lynx

If it is broken in your browser then please let me know, unless you use some old version of netscape or IE3 in which case you should be accustomed to broken web sites.


Filed under: drupal firefox python theme

6 Comments

Apparently Ask Jeeves has bought Bloglines.

On friday Ask Jeeves spider was hammering my site for most of the day, thoroughly indexing it. It has been there before but this was quite intense. Could it be that Ask got a list of blogs from bloglines and were busy indexing them all? Or was it a glitch in their bot?


Filed under: bloglines

Add a comment

Google has given Petersblog.org pagerank 4! cool It has only been up for three weeks, an alias of bisiand.me.uk.

bisiand.me.uk is still 4 and www.bisiand.me.uk is still 3.

petersblog.org (without the www) is 4 as well, maybe google have figured they are the same.


Filed under: google pagerank

6 Comments

I hadn't been worrying much about comment spam recently as I had been banning it successfully in my .htaccess rules as every access attempt had a spammish referrer link.

Once past the .htaccess block they found a bug in my comment captch mod: by just posting without doing a prior read of the page the session was not being set up. I've modified the captcha code to cope with this. Note that this is still Drupal 4.5.1, I haven't upgraded to 4.5.2 yet.


Filed under: captcha drupal htaccess

Add a comment