Skip to content

Apache dynamicaly configured vhosts

I want user to be able set up development sites on a server without the need for creating dns entries or apache vhost files. My current working solution to this has two elements.

Firstly creating a wildcard dns entry. This is a dns entry which starts with a wildcard “*” followed by the domain (or in this case subdomain).

*       A

Any request to will then be directed to the named server regardless of their prefix eg (,

At this point the apache server receiving requests from these hosts will have no idea how to deal with them so we must create a dynamic vhost file.  A detailed description of a dynamic vhosts can be found on the Apache site, but basically what it will do is take the server name from a request and use it to set the document path etc in the vhost dynamically. So using the configuration bellow

# get the server name from the Host: header
UseCanonicalName Off

# this log format can be split per-virtual-host based on the first field
LogFormat “%V %h %l %u %t \”%r\” %s %b” vcommon
CustomLog logs/access_log vcommon

# include the server name in the filenames used to satisfy requests
VirtualDocumentRoot /www/hosts/%0/docs will point to the documents in directory /www/hosts/ and will point to /www/hosts/ So in effect this means all a developer has to do to have an accessible dev site is to create the proper name in the proper directory.

Posted in geek, sysadmin.

Tagged with , , .

A train of thought

ink repelent form fields, great idea!

ink repelent form fields, great idea!

First the rant, why is it so bloody difficult to write the date in the little box on my train ticket? Every morning before getting on the train I dutifully attempt to write the date in the little boxes provided (on pain of death or a fine by scotrail) but the shiny orange surface seems to be a natural ink repellent. So I scribble on the ticket to get the ink flowing then chisel into the date field and hope enough ink remains in the gouged out channels to make an approximation of the correct date. A minor annoyance but one which shows a common problem which can cause user experience woe.

A little background first, the multi-journey ticket allows you to buy your 10 journeys in advance. The tickets are valid for a month and have the expiry date printed on them. Buying tickets like this is good thing because you get discount price and you don’t have buy a ticket each day. However the ticket did not originally have the date fields, these were added in an attempt to cut down on fraudulent use. So what we had was operational system that had to be retrofitted with additional functionality in the existing interface. The experience for end user is  not a happy one.

The user either ignores it and hopes for the best, tries to use the broken interface or changes their behaviour to improve the interface (carry a felt pen ). What interests me is how much thought went into decision making process that led them to make people attempt to write on something which was never designed to be written on? The constraints of cost, space and working within an existing framework are obvious but it would be interesting to follow the train of thought that led to a perhaps unavoidable sub-optimal destination.

I suspect it one that is not foreign to those working in the field of software development where an essential (but unforeseen)  feature   has to be shoehorned into an existing framework. The right thing to do would be to rebuild the interface with the new functionality in mind,  for once put the user first and ask the question, is this feature there to make our life easier or our users?

Posted in geek, misc, Uncategorized.

Install Python modules on a shared host

Sandbox python modules in your home directory

Sandbox python modules in your home directory

Recently had to install a python module for pdf generation reportlab on my shared Dreamhost server. Problem is by default a python module needs to be installed by root so it can be universally available to all users.

The way round this is to append the the install command with the path to your home directory.
python install --home=~
This will then install the module in /lib/python/ within your home directory. However if you then try to import this module the python interpretor will not find it.

To make python look for the module in the /lib/python/ directory in your home folder as well as in the system directory you need to append it to your python path. The best way to do this is to add it to your .bash_profile. Add the line
Then logout and in again to reload your bash_profile or just run the command.
. ./.bash_profile

Posted in geek, python.

Tagged with , , .

The plot thickens? Well not really…

Had another look at the City Chambers today to see if I could find any numbers similar to the strange 7 (or is that 2?). Looking on the front door of the City Chambers I saw this number.

82 George Sq

82 George Sq

Apart from the coincidence of it being the same as the upside down number round the corner I wonder why it isn’t no 1 George Sq as you’d image the premier building of the city would be. Unfortunately it doesn’t look much like78 upside down.

Not that much like 78 George Sq

Not that much like 78 George Sq

Posted in misc.

78 Cochrane St?

78 or 82 Cochrane st

The number above appears on the Glasgow City Chambers, there is something obviously strange about it. The letter seven is an upside down 2. Could this be a mistake? (however the other column has the same number), is it just a fancy script or is there a more secret and sinister meaning. Could 82 Cochrane St (an address that “officially” doesn’t exist) be the location of the shady overlords who really control things. This being the internet I’m bound to conclude… yes, it is.

82 or 78 cochrane st

82 or 78 cochrane st

Posted in misc.

Are we missing the point of Twitter?

There is no doubt that from the mainstream point of view Twitter has been the tech story of the year, the arrival of the celebrities,news media, corporations and politicians has led to an explosion in use of the service. The attraction of Twitter is obvious, it’s very accessible and it brilliantly mixes the ability to broadcast to potentially vast audiences with the intimacy of conversation. The ability to sms to Twitter and the range of applications (that have been made possible by having an easily implemented API) means that the majority of usage is not through the Twitter website, this disconnect from the website shows us what Twitter really is. With Twitter we have seen the coming of age of a new medium that can be standardised and universalised in the same way email was.

We take it for granted now that email can be sent and received by anyone with an internet connection, an email account and some sort of software client, be that a dedicated application or a web interface, to anyone else with a the same facilities. However this was not always the case, before the adoption of the standard protocols we know today such as SMTP, POP and IMAP different organisations and ISPs had their own incompatible electronic mail systems. If you were on one and your friend was on another you could not send them mail. Looking back we can see the pointlessness of such a systems and history has shown us that by having standard protocols email communication has become so ubiquitous we barely give it a thought and providers of email facilities have to compete on price, quality of service and features rather than exclusivity. However that fragmented landscape of data silos and walled gardens is where we are regards to the phenomenon that is microbloging.

OpenMicroBlogging is an effort to create an open standard for micro-blogging. Our goal is a specification that allows different messaging hubs to route microblogging messages between users in a near-realtime timeframe, Evan Prodromou.

The most well known and widely used implementation of the OpenMicroBlogging standard is the Laconica platform as used by Evan Prodromou, the creator of Laconica took the decision to make the platform as accessible as possible so it requirements are modest. It’s written in php and can use common database back ends (mysql, postgres, etc), the aim is that it would be relatively easy to install (it took me less than hour to set up a Laconica instance on a beige box server at home) even in a shared hosting environment. If you go to the site you will see a Lanconica instance looks a bit like Twitter and will even accept Twitter API calls. However the difference is is part of a federated network of OpenMicroBlogging instances. In practical terms what this means is that you can interact with users on any other Laconica instance in the same way you would users on your network.

The implications of federated OpenMicroBlogging go far beyond the media hype of Twitter. Interest groups (inevitably there is already an “adult entertainment” server ), companies or even individuals are able to run their own server and control their own micromessaging environment, content and the level of access others have to it. There is a slight irony that the open source platform allows you to have a completely closed private network if you wish. Obviously the ability to have an in house private system could be very useful within companies and organisations. From an agency point of view the ability to offer clients a microbloging network as a service in same we currently do with email, especially if that platform allows a fine degree of control in what resources can be accessed, would a good way to give added value with minimal development costs.

Another opportunity that this platform would give is the ability to mine a vast new datastream. This is already done to a certain extent on Twitter with trends and search but other functionality such as track (which lets you track keywords in the public timeline) have been withdrawn. However within the open microblogging environment the level of data introspection could be as detailed as you wish. Which may be why Google seem to be getting on board.

Significantly Google have recently announced that their open source microblogging platform Jaiku which is available through their app engine will be able to support Oauth, the authentication protocol which is one of the key elements in federated microblogging. Some see this as the big boy of the web’s first step in making Jaiku a fully OpenMicroBlogging compatible platform and it will need the involvement of such a big hitter to push forward the standard. As with any network the critical mass of users has to be reached for it to be really useful and at the moment is Twitter is the de facto micro blogging platform. Whether they open the doors and in one stroke make microblogging email 2.0 or go the way of the proprietary email systems of the past only time will tell.

Posted in geek.

Tagged with , , , .

SQLite manager firefox plugin

Just found this incredibly useful tool which gives you a nice gui fronted for sqlite database management and creation. Unfortunately it seem the developer is longer supporting the project. Great  firefox plug-in though

Posted in geek.

Command line weather forecast

For those who like to live in command line and python script to tell you what the weather is like (although if you live on the CL you probably don’t go outside much so it’s pretty irrelevant).

The weather forecast is from Yahoo weather, after entering your locale get the code from the url, for example is Glasgow. The part we are interested in is the code “UKXX0123″.

Save the script as “weather”, make it executable and put in executable directory like /usr/local/bin

Now open a new terminal window and you should get this:

test@testing:~$ weather

Current Conditions:
Partly Cloudy, 13 C
Mon - Partly Cloudy. High: 14 Low: 7
Tue - Partly Cloudy. High: 16 Low: 8

Now the code.

#!/usr/bin/env python
import feedparser,re
for line in forecast[0:-2]:
    print line

Posted in geek, python.

Tagged with , , , .

python file comparison tool

Alpha version comparison tool, can be run from the CLI with two directory paths as arguments. /foo/bar/dir1/ /foo/bar/dir2

Or imported as a module.

Give option for recursive searches, at the moment subdirectories are ignored.
More elegant error handling for permissions errors etc..

import hashlib
import os
import sys

class Comparison:
    """compares files in two directories, returns standard output and list of 
    common files with different content,files unique to directory one,files unique to directory two
    and count of identical files. Does not search recursively sub-directories are ignored"""
    def __init__(self):
    def compareFiles(self,file1,file2):
        """compares text and binary file content of two files by matching hashes, 
        returns 1 if files are different 0 if identical"""
        #comparison is not recursive, sub directories are ignored
        if os.path.isfile(file1) and os.path.isfile(file2):
            if x.digest() == y.digest():
                return 0
                return 1

    def compareDirectories(self,dir1,dir2):
        """Compares two directories proccesing common files with the 'compareFiles' function,
        lists unique files for each directory and counts unique files """
        #add trailing slashes if needed
        if dir1[-1] is not '/':
        if dir2[-1] is not '/':
        common=list(set(d1) & set(d2))
        for file in common:
            if self.compareFiles(dir1+file,dir2+file) == 1:
        return [changed,ind1,ind2,id]
    def compare(self,dir1,dir2):
        """Processes results of compareDirectories for screen output"""
        if r[0]:
            print "Common file(s) with different content"
            for f in r[0]:
                print f
        if r[1]:
            print dir1+" unique files"
            for f in r[1]:
                print f
        if r[2]:
            print dir2+" unique files"
            for f in r[2]:
                print f
        if r[3]:
            print str(r[3])+" identical files found"
        return r
print "\n"
print "\n"

Posted in geek, python.

Tagged with , , .

Introduction to the info entry for the unix “date” command

Our units of temporal measurement, from seconds on up to months,
are so complicated, asymmetrical and disjunctive so as to make
coherent mental reckoning in time all but impossible.  Indeed, had
some tyrannical god contrived to enslave our minds to time, to
make it all but impossible for us to escape subjection to sodden
routines and unpleasant surprises, he could hardly have done
better than handing down our present system.  It is like a set of
trapezoidal building blocks, with no vertical or horizontal
surfaces, like a language in which the simplest thought demands
ornate constructions, useless particles and lengthy
circumlocutions.  Unlike the more successful patterns of language
and science, which enable us to face experience boldly or at least
level-headedly, our system of temporal calculation silently and
persistently encourages our terror of time.

…  It is as though architects had to measure length in feet,
width in meters and height in ells; as though basic instruction
manuals demanded a knowledge of five different languages.  It is

no wonder then that we often look into our own immediate past or
future, last Tuesday or a week from Sunday, with feelings of helpless confusion.  …

— Robert Grudin, `Time and the Art of Living’.

Posted in geek.