Entries for archive: 2006-08

Found 23 entries.

Will Code for Coffee

After 3 days without a good coffee, I'm in need of one. I'll even code...

After 3 days without a good coffee, I need to take desparate measures. I may code, if necessary.

Wellington airport gave me a good coffee from Fuel.

Sydney airport gave me something I'd expect on the flight itself. I tried it, and tried it again, then left the rest - it was not worth it.

Hong Kong airport forced me to go to Starbucks, which I didn't really want to do, but kinda had to. It was okay.

Since being in London, I wasn't in the situation to get one and on the way up to Liverpool, the motorway service station had them for the (converted) rate of $7 a pop. I declined buying one.

Hmmm, maybe I'll not get a good one for three weeks. Maybe this is the time to give up completely, as I have been thinking for a while - I drink too much.

Labels: coffee, airport, code

Inserted: 2006-08-27 09:40 (5 years, 5 months ago)

WPoW #0006

Taken 2004:04:25 16:31:13:

WPoW 0006

Labels: blue-sky, wpow

Inserted: 2006-08-23 07:49 (5 years, 5 months ago)

Trackback Now Added to Site

So I did it on Saturday and had to wait until Tuesday evening to deploy.

As you know, my server hosting company took the Mick and had routing problems for 4 days. It's hard to go over and fix it yourself when you are in New Zealand and they are in Denmark,

Anyways, now that I have access to my server again (and hence my web admin, my email, my SVN and other stuff) I have updated the site to add trackbacks.

Currently, the DB changes have been made, the site calls the Perl Modules at the backend to display the trackbacks, the admin displays and audits them, so the only thing left to do is publish the trackback link for each entry...

...but I'm going to use this \[p]{trackback form|http://www.reedmaniac.com/scripts/trackback_form.php} first to test it all out.

Labels: trackback, kapiti-geek-nz

Inserted: 2006-08-22 23:48 (5 years, 5 months ago)

Finally, I am Back

...and not very happy with the downtime... :-(

So \[p]{my dodgy server provider|http://easyspeedy.com} had major routing problems on Saturday. This continued into Sunday. Monday was completely wiped out and I'm back just about the end of Tuesday.

Apologies to anyone trying to get the site but I tried my hardest to get them to fix it - and even when they said they did, it still didn't work.

Now, just to put the other side of the story, I've been using EasySpeedy since March and have been so happy with them, I like them, they were the cheapest I found at the time (and have now found \[p]{ServerPronto|http://serverpronto.com} which is cheaper still - by far) and have, up until now, given me no hassle whatsoever.

I know that these things happen, that either servers might go down, or routing problems happen, but the fact that it took four days to come back is a little disturbing. And when they did say that it was resolved, it wasn't.

Anyway, am I glad I can see these pages again...I've kinda missed them.

Labels: server-pronto, downtime, easy-speedy

Inserted: 2006-08-22 23:16 (5 years, 5 months ago)

WPoW #0005

Taken [unknown]!

Nice Blue Sky

Labels: blue-sky, mountain, wpow

Inserted: 2006-08-18 20:18 (5 years, 5 months ago)

My Navigation Kinda Sucks

After reading an article on "Web Navigation", I realise my fundamental flaws in my site's design. An update to be scheduled soon I think.

The article in question is \[p]{Where Am I?|http://alistapart.com/articles/whereami} by Derek Powazek. Even though there are some obvious points in there, it's amazing what you forget, don't think about or just plain ignore.

Whilst reading through the article, I kept referring back to these pages on kapiti.geek.nz. As it turns out, I need to update a few things:

  • whilst I tried to provide some sort of "Where have I been?" using the stacked menus of the left, it fails miserably
  • the breadcrumbs (which I must admit, I've always liked) have a "Navigation>>" line above, but nothing happens in there - why?
  • the original design also had the above menu options highlighted when you were in that section - I didn't do it
  • and I am lazy since I don't un-link the links for the page I am currently on

So overall, I give myself about 4/10 and a note from the teacher which says: "Andrew must try harder and not let himself be distracted by others talking at the back"!

Labels: web-design, kapiti-geek-nz, usability

Inserted: 2006-08-18 00:04 (5 years, 5 months ago)

CAcert is Cool

Learning a bit about CAcert recently, I signed up immediately since it "Just Makes Sense". Oh, and I can get an SSL certificate for my server too - for free.

Following on from Andrew's \[p]{CAcert Bandwagon|http://blog.etc.gen.nz/index.php?/archives/7-CAcert-Bandwagon.html} entry, Catalyst IT will very soon (from tomorrow I think) have enough people to fully assure someone, anyone, everyone ... providing they have the relevant ID of course :-)

We'll be a good seed in Wellington to grow the number of assurers and get this \[p]{CAcert|http://www.cacert.org/} wagon rolling in our area. Once we've reached these dizzy heights, we should try to get ourselves onto the \[p]{Assurer Groups|http://wiki.cacert.org/wiki/AssurerGroups} page on the \[p]{CAcert Wiki|http://wiki.cacert.org/wiki/}.

(P.S. Just found an entry on the \[p]{CAcert News Blog|http://blog.cacert.org/} asking for assurers in \[p]{Coventry UK|http://blog.cacert.org/2006/08/159.html} to help them kickstart their area. I might give them a shout since I'll be staying with my brother there in a month or so.)

Labels: ca-cert, planet-catalyst, jms

Inserted: 2006-08-17 21:40 (5 years, 5 months ago)

Linux on Lenovo

Or what they say is a "ThinkPad Experience" under Linux.

Well, at least we know the hardware will work. Being able to buy a machine (without having to order a truckfull), from a manufacturer with Linux pre-loaded can only be good news.

See \[p]{ThinkPad T Series mobile workstations|http://www.pc.ibm.com/us/notebooks/thinkpad/t-series/workstation.html}.

Labels: planet-catalyst, linux, lenovo

Inserted: 2006-08-17 11:21 (5 years, 5 months ago)

WPoW #0004

Taken on 2004:07:04 13:56:21

A Frosty Day

Labels: mountain, snow, wpow

Inserted: 2006-08-15 23:05 (5 years, 5 months ago)

Earthquake #0001

At 2006-08-13 16:29.

I was sitting in my lounge and felt this one. After the initial quick shake, it was a slow rumble...seemed to go on for about 15-20 secs. Nothing too scarey, but the initial shake made the house creak :(

\[p]{Geonet Link|http://www.geonet.org.nz/x2609766g_l.html}

Labels: earthquake

Inserted: 2006-08-13 22:55 (5 years, 6 months ago)

Simple Insert and Update Logging in PostgreSQL

Being able to see at what time a row was inserted or updated in PostgreSQL is easy and can be put to good use.

In Using Base Tables in Postgres I showed how to create tables with inserted and updated times. Until now though, the updated column was exactly the same as inserted, but let's change that. Just to review our base table:

 CREATE TABLE base (
    inserted        TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated         TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
 );

Looking at this, both inserted and updated default to whatever the time is at insert. What we want though is to change the updated column whenever the row changes (ie. it is updated). To do this we need to set a trigger on the table which calls a function when each row is updated.

Diving right in, here's the function we need:

 CREATE FUNCTION updated() RETURNS trigger as '
    BEGIN
       NEW.updated := CURRENT_TIMESTAMP;
       RETURN NEW;
    END;
 ' LANGUAGE plpgsql;

It's a fairly simple function and basically says to set the updated column of the NEW (or in this case, the updated) row, and return it ready to be put into the table. Further information says that the return type is trigger (makes sense) and it is written in the PL/pgSQL language.

At the moment though, this function is standalone and isn't being called from anywhere. So let's create a simple table and set an updated trigger on it:

 CREATE TABLE news (
    id              SERIAL,
    title           TEXT NOT NULL,
    article         TEXT NOT NULL,
    LIKE base INCLUDING DEFAULTS
 );
 
 CREATE TRIGGER news_updated BEFORE UPDATE ON news
     FOR EACH ROW EXECUTE PROCEDURE updated();

We have told Postgres is to run this trigger for every single row that is ever updated in the news table. It runs just before the actual update therefore we can change the values of any fields in the NEW row inside the function which are then reflected in the table afterwards. In our case, the updated row will be changed to be the CURRENT_TIMESTAMP, which is what we wanted.

Try inserting a few news articles and see that for every row you added, the inserted and the updated fields are exactly the same:

 INSERT INTO news(title, article) VALUES('Aliens Invade!', '...stub...');
 INSERT INTO news(title, article) VALUES('Earth Loses!', '...stub...');
 SELECT title, inserted, updated FROM news;

Now update the second news item:

 UPDATE news SET title = 'Earth Wins!' WHERE  title = 'Earth Loses!';
 SELECT title, inserted, updated FROM news;

And we're done. This technique is certainly useful in some circumstances to help you track down what's going on in various parts of your database. Of course there are many more and comprehensive techniques for transaction logging but this is a simple one which might save your bacon one day.

Labels: postgresql, trigger

Inserted: 2006-08-13 18:58 (5 years, 6 months ago)

My New CMS is Coming Along Nicely

After a fair bit of work over the past month or so (since when kapiti.geek.nz started), my new CMS is starting to take shape.

Today, I finished off adding the content managed pages as seen in the (sparsely populated) Software section.

The best thing about the new Content type though, is that it fulfilled all of the criteria I want for all the new content types which I will be adding to it. So far, the Blog type (which is used for /random) is mostly there but doesn't quite fit the abstraction I want it to. The DB class is fine, but the display pages are lacking since I'd written them for this site before I wrote them for the CMS.

On the other hand, I wrote all of the display code for the Content type before I wrote anything for this site and it turned out well. Out of the box, the CMS will support 'text', 'code' and 'html' types - weird I know but it proves the concept. Despite this, I assign my pages a content type of Phliky then, in kapiti.geek.nz, I override the display of that particular type and don't have another jot of work to do :-)

Inadvertently, though I guess I am inclined that way, this new CMS pretty much follows the MVC pattern. I'm not always sure that this is necessary but once a project starts getting big, then it's the best way to go and hopefully this one will get bigger.

As an example, the database interface code is written in Perl modules. The admin interface (which could be termed the controller) is written in Perl/Mason and is a part of the CMS code. The View pages have default versions in the CMS code, but can be overridden with the website pages, which is the technique I used to display a phliky type in the content pages. This approach seems to be the way it turned out and the way it will continue to move forward.

Oh and by the way, I haven't yet worked out a name for it. At the moment, the working title is Fli since it is a play on Fly and hopefully should be really fast. If anyone has any suggestions, let me know.

Labels: perl, mason, cms, mvc, kapiti-geek-nz

Inserted: 2006-08-13 01:20 (5 years, 6 months ago)

WPoW #0003

Taken on 2005:01:02 16:09:58

Forrest Floor

Labels: photo, wpow, leaf

Inserted: 2006-08-12 17:27 (5 years, 6 months ago)

Google Sitemaps is Slightly Suspicious of Me

I submitted a sitemap to Google Sitemaps and confirmed that I owned the site. But wait, what's this obscure request...

To try out \[p]{Google Sitemaps|https://www.google.com/webmasters/sitemaps/login}, I firstly had to prove that I was the owner of this site. They gave me a URL of the form http://kapiti.geek.nz/google################.html where each # was a number or letter.

A while after I put the page on the site and Google had verified it, I looked in the server logs to see at what time it had been requested. Immediately after the page was requested, another request for the page http://kapiti.geek.nz/noexist_################.html was also there, which obviously gave a 404.

I think they are being slightly suspicious of servers which return a page for any URL requested which I guess is what the noexist request is to stop. Anyway, that kinda made me smile thinking that my server was doing the right thing.

As for the Sitemap itself, well I used the Perl Module \[p]{XML::Mini|http://minixml.psychogenic.com/} which is quite nice in a funny way. I thought that this Google Sitemap Generator would be good for a module, so I looked on \[p]{CPAN|http://www.cpan.org} - lo and behold, there already is one by \[p]{Jason Kohles|http://search.cpan.org/search?query=Google%3A%3ASiteMap&mode=module}.

Ah well (but that's a good thing).

Labels: perl, google, xml, kapiti-geek-nz

Inserted: 2006-08-12 15:58 (5 years, 6 months ago)

Site Admin Almost Complete for kapiti.geek.nz

After a short while playing with kapiti.geek.nz, I've pretty much done all the admin interface now.

You might have noticed over the week or so, I have done two main things: (1) I broke the posting of comments on the blog entries, and (2) I added a random quote to the top right.

Well, I've fixed the first and am now using the new admin interface to manipulate the blog and its entries. I also have an admin section for the quotes and for the (RSN) content managed pages.

I'm doing it all in such a way that if I want to re-use all these modules in a future project, I can and do so quite easily. This site is a DAMP site (of course), and after a while playing with different websites, I know what I want, how to do it and most of all, be consistent in my approach. This way future additions are easier.

At first, I wanted the administration to allow many users, with different roles and access permissions, but there are many \[p]{CMS tools|http://www.cmsmatrix.org/} out there which do all this - and they are huge, both in function and form.

My plan is to make something a lot smaller and allow any user to change anything. This means there will be the abilty for many people to log in, but no access rights or roles need to be assumed - everyone has the power to do anything. It will be ideal for personal sites and for small to medium businesses. Even so, I have ideas about how it could expand to fill in all these things, but I'm trying to repell them since that will ruin the overall plan - to keep it small.

Eventually, I will get everything together and release it on this page, but not until I have a few different content types and a consistent approach. There are other things on the way but I won't promise too much for the future.

Look out though for some recipe pages over the next week or so :-)

Labels: cms, kapiti-geek-nz, damp

Inserted: 2006-08-12 01:31 (5 years, 6 months ago)

Using Base Tables in PostgreSQL

Sometimes object inheritance gets in the way, sometimes it helps. In this case, a small bit of inheritance for tables in Postgres really helps.

Let's say you require all of your tables to contain columns of the same name and type. As an example, in a number of my Postgres databases, I like to have an inserted timestamp field on every table. This means I know exactly when that record was added - it's like a poor-man's audit.

Therefore, instead of adding the inserted column to every table, like this:

 CREATE TABLE news (
    name            TEXT NOT NULL PRIMARY KEY,
    title           TEXT NOT NULL,
    article         TEXT NOT NULL,
    inserted        TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
 );

You can try something like this:

 CREATE TABLE base (
    inserted        TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
 );

then:

 CREATE TABLE news (
    name            TEXT NOT NULL PRIMARY KEY,
    title           TEXT NOT NULL,
    article         TEXT NOT NULL,
    LIKE base INCLUDING DEFAULTS
 );

Of course, in this particular case, you don't save a lot of typing, but imagine if you had a 10, 20 or even hundreds of tables. You get the idea, but don't stop there. Here's another base table I use which also has a column for updated:

 CREATE TABLE base (
    inserted        TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated         TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
 );

Obviously, at the moment, this is exactly the same as the inserted column, but you'll see in the next article how this can be used to show the last time this record was updated.

Labels: postgresql

Inserted: 2006-08-12 00:54 (5 years, 6 months ago)

WPoW #0002

Taken on 2004:07:04 16:37:46

South Island Landscape

Labels: south-island, wpow

Inserted: 2006-08-10 22:30 (5 years, 6 months ago)

Google Code and Phliky

After finding out about Google Code today, I decided to put one of my projects on there - Phliky.

So far, it's going well. I've created the project (\[p]{Phliky|http://code.google.com/p/phliky/}) and organised my repository. In true Google style, it has a very clear interface and is also easy to navigate.

Saying that, the interface is quite sparse at the moment though, but I think that it will be filled out as time goes on. As an example, when you click 'Settings' in the top right corner (to change your Subversion password), there are no links to get back to the 'Project Home' and the other 3 main tabbed pages.

There is an \[p]{Issue Tracker|http://code.google.com/p/phliky/issues/list} and they do mention in the \[p]{FAQ|http://code.google.com/hosting/faq.html} that they created it to be minimal but configurable. Looking at the configuration for the Issue Tracker, it makes perfect sense that you can add your own Open and Closed Status values and Issue Labels (which I guess is the same as tagging an entry). This way, you can make the tracker work exactly how you work, though they do already provide a decent set of defaults.

One great thing about \[p]{browsing the repository|http://phliky.googlecode.com/svn/} is that, as soon as you have commited a check-in, it is already updated with the latest Subversion Revision - no waiting round for the web accessible source to update.

One slight problem I had with the repository though was when I checked it out using the URL I found, I didn't realise that it was already the trunk - serves me right for not looking close enough. I'm used to checking out the whole repository - trunk, branches, tags and all - so I ended up making trunk/ (again), branches/ (again) and tags/ (again)! Bugger. A bit of tidy-up later and I was good - am so glad it uses Subversion as opposed to CVS.

Overall then, I'm quote impressed and think that I'll like it even more in the future.

Labels: phliky, html, planet-catalyst

Inserted: 2006-08-10 22:22 (5 years, 6 months ago)

iPic4You now has comments

After releasing iPic4You to my family last week, I added the ability to comment on each other's photos - it's gone down a storm

I didn't realise what a difference it would make - but it does. This is especially true because all the people using it know each other which means that the comments actually make sense!

Already I can see the comments turning it from a nice photo gallery, to something a whole hell of a lot more personal - which was the plan in the first place.

Also, it's getting funny already :-)

Labels: photos, ipic4you

Inserted: 2006-08-05 23:05 (5 years, 6 months ago)

WPoW #0001

Taken on 2006:07:23 17:29:42

Sunset over Kapiti Island

Labels: kapiti, wpow

Inserted: 2006-08-05 12:57 (5 years, 6 months ago)

A Nice Day in Kapiti

Since April, it seems that there has been constant raining - but today is nice.

Which gives me the impetus to head out and finally get started on my wpow. That means Wellington Picture of the Week. Now, I'm not going to post a picture every week, nor will it be of Wellington necessarily (and once it has been happening for a while, no-one will remember what wpow means anyway.

So yeah...laters.

Labels: photo, kapiti, wellington, wpow

Inserted: 2006-08-05 12:24 (5 years, 6 months ago)

New Thinking for a CSS Approach

Having played with CSS using other people's styles, those of my own and those already existing, I had a thought the other day about how I would try it next time.

Even though CSS is supposed to stop us from putting layout details into the HTML, it has it's own layout v style problem. Take, as an example, the following CSS:

 div.content {
    margin-top: 3px;
    color: #333333;
 }

This, in my opinion, actually contains both a style (the color) and a layout (the margin-top). I know that CSS is supposed to be all styles, which is why it is in the accronym, but sometimes it gets in the way too.

As an example, on a rather large site I have been working on, there are quite a few different pages which share some generic styles but can vary greatly in the layout. It is a very data driven site rather than a content site, therefore, there are lots of finicky bits to help certain data stand out. The above class only contains 2 styles, but for some of these screens there are many, many more styles.

Recently, I've been thinking of a new approach to this problem. On a smaller website I recently completed, in a lot of cases I was assigning 2 or more classes to each of the HTML elements. Sometimes these were each of style and layout, but in some cases, it was two styles and in others, it was two layouts. As an example:

 .bg-shaded    { background-color: black }
 .bg-highlight { background-color: white }
 .bg           { background-color: gray }
 .fg-heading   { color: #FFF; }
 .em           { text-decoration: italic; }
 .right        { text-align: right; }
 .spaceit      { margin-top: 3px; }
 .padit        { padding: 0px 12px; }

Then in the HTML:

 <div class="bg-shaded fg-heading em right spaceit padit">This is extreme</div>

I know there are various ways to help with this, especially leveraging the power of the 'cascading' part of the standard. Also, the use of <h#> and <p> and the rest can help, but as I said, the site is very data driven and therefore most things end up in <div>s.

So the thought is that there is a generic.css stylesheet, in which go the standard styles used across the whole site. Then there is a styles.css stylesheet in which go the various text, font, colour, padding and border styles - it is these which can proliferate. But the main thing which became the hardest thing to cope with was the layout for each page since they were all very different, therefore, each page has it's own layout.css stylesheet.

As a small example, here are some stylesheets:

 file: generic.css
 
 * {
    padding: 0px;
    margin: 0px;
    font-size: 10px;
    font-family: Arial, Helvetiva, sans-serif;
 }
 file: styles.css
 
 .hdr   { color: #ffffff; background-color: #006d1b; }
 .sub   { color: #ffd96b; background-color: #108d18; }
 .em    { text-style: italic; }
 .upper { text-transform: uppercase }
 file: layout.css
 
 .rounded-hdr { width: 400px; background: url(rounded_hdr.jpg) no-repeat top; }
 .rounded-sub { width: 400px; background: url(rounded_sub.jpg) no-repeat bottom; }
 .squared-hdr { width: 400px; background: url(squared_hdr.jpg) no-repeat top; }
 .aquared-sub { width: 400px; background: url(squared_sub.jpg) no-repeat bottom; }

As an example then, you can choose a heading and subheading with rounded or squared corners:

 <div class="hdr rounded-hdr">A Heading</div>
 <div class="hdr rounded-hdr">A sub-Heading</div>
 <div class="hdr squared-hdr upper">A Heading</div>
 <div class="hdr squared-hdr">A sub-Heading</div>

(I know a div of class 'hdr' or 'sub' could have been used around the whole thing and then the internal classes choose the images, but this was just an example. It also retains a great deal of flexibility.)

You can assume that the number of styles, layout CSS and generic CSS is greatly increased on a much larger project.

I might not have convinced you, but I am planning to try this out next time I run across a site with a large number of page layouts.

Labels: css, html

Inserted: 2006-08-03 15:56 (5 years, 6 months ago)

Postgres Time Zones

Using Postgres when working with different timezones is great. Here's a small tip to help.

I was wondering today if there was a way to tell Postgres to default to a particular time zone when setting or retrieving 'timestamp with time zone' types. Using the SET... command seemed the way (at first), but after a quick look at the \[p]{Postgres documentation|http://www.postgresql.org/docs/7.4/static/datatype-datetime.html}, the PGTZ environment variable can be used to automatically set the default timezone upon connection.

Then Martyn (in work) made a good suggestion which was to set the variable in the Apache configuration. So I did...

...except it didn't work - at first.

I tried setting it to one of NZST, CEST and UTC, though only the latter worked. After reading a bit more and playing with tzselect, I tried setting it to Europe/London and Pacific/Auckland it worked perfectly. It seems to be very system dependent.

Once figured out, Postgres makes it all so easy. :-)

Labels: postgresql, apache, timezones

Inserted: 2006-08-01 22:44 (5 years, 6 months ago)