Random Quote:

Living with the new car

As mentioned in a previous post, I’ve bought myself a new car, and picked it up last Monday morning. On the whole, I’m impressed! Here are the good and bad points:

The features I like:

  • I’m averaging 54mpg out of the car. This is really impressive, considering the sort of driving I’m doing. My journey to work is half motorways and half hilly country roads. I’ve driven a couple of hundred miles in it so far, and only used about a third of the tank!
  • The car is comfortable, easy to get in and out of, and looks fantastic.
  • There’s a warning beep if you drive away without putting your seat belt on.
  • The trip computer. This is the first car I’ve had that’s had one of these on, and it’s interesting to find out what the instant mpg is, the total mpg for the trip, the trip time and so on.
  • You can set an alarm to buzz when you go over a certain speed.
  • There’s a useful “mute” button on the steering wheel for the radio.
  • The lights turn off when you switch off the ignition, this means it’s impossible to leave the lights on and wear the battery flat.

The things I’m not so keen on:

  • It doesn’t have Blue&Me. This is because it’s a 2008 model, and Blue&Me was an optional extra last year. So I still have to use the wireless radio adapter for the iPod. I’m not overly bothered about the bluetooth thing, I hardly ever need to use the phone when I’m driving, but the iPod functionality would have been nice. My fault this one, I should have checked before I bought the car (not that it would have stopped me, probably)
  • The Astra had wider door pockets, with a curve at the front big enough to put a bottle or can in. The Punto has drinks holders, but I’m not convinced they’re deep enough to hold a bottle upright when going round a sharp bend!
  • The clock in the Astra was connected to the radio’s RDS system, so it always kept itself up to date. I don’t think the clock in the Punto does this.
  • There’s no light in the boot.
  • There doesn’t seem to be a spare wheel, only some sort of compressor to fix punctures by the side of the road. I’ll have to check this with the dealer.
  • I can see part of the dashboard trim reflected in the tinted windows when I look in the wing mirrors.

But these are minor quibbles (well, everything but the spare wheel is a minor quibble!). So far, though, I think I’ve made a good choice with this car.

No Comments

A word from the wise…

My son said today that the reason I wear a baseball cap on my head on sunny days is that if I didn’t, the sun would burn a hole in the top of my head, then in the back of my head, because there’s nothing in the middle to stop it….

Talk about saying it as you see it!

No Comments

You’re hired

I think we should put all the fired Apprentices in the cabinet, they’ll do a much better job than the current lot!

No Comments

Saving time

The stockroom guy at work said it would take two people a month to enter the prices for all the stock items into the new accounts/stock system. I spent three hours preparing the data and importing it, thereby saving nearly 300 man-hours of work. Will I get a thank you? Will I get a bonus? Will I get I warm fuzzy feeling of a job well done?

One out of three ain’t bad.

No Comments

Bought a new car!

After five and a half years and over 85,000 miles (plus the 22,000 miles the car had on it when I bought it), I’ve decided that it’s finally time to trade it in for a newer model. I’ve been extremely impressed with the car (a Vauxhall Astra), it’s still solid and reliable, although it’s now starting to show signs of age. There’s an intermittent squak from the wheels, and the ride isn’t as good as it used to be. These things could be fixed, but it’s probably better to change the car before I have to spend lots of money keeping it going, rather than after! When I bought the car I said I was going to keep it until it had done 100,000 miles, and it’s done that admirably. Part of me will be sorry to see it go!

So, what to get as a replacement? I know car dealers are getting a bit desperate to shife stock at the moment and there are some stonking deals to be had on a brand new car, but most of them are still out of my price range. I visited a few dealers, picked up a few brochures, and had a test drive in a Toyota IQ. This is a really nifty little car, perfect for town driving, it’s tiny on the outside but more than big enough on the inside for a driver and passenger. It felt like a bigger car when I drove it as well, I didn’t feel that it was going to tip over on the corners or anything like that. But (there has to be a but, doesn’t there?) I don’t think it would be suitable for the relatively high mileage I do, and it was also quite expensive. The car has only just been launched, so there aren’t any second-hand ones available on the market yet.

Another car I was tempted to look at was the new Ford Fiesta. This car has had excellent reviews, and I read in What Car magazine about a chap who’s bought one who does about 200 miles a day, so at least he’s pinning his hopes on it being solid and reliable! Again, it’s a brand new car and there aren’t any used ones available yet, as a result I discounted this car on the basis of price.

I found an internet broker (www.buyacar.co.uk) and had a look at their prices for different makes and models, and happened to look at their prices for Fiat Puntos. Wow, very impressive, might be worth a look, this one! Off I went to the local dealer, picked up a brochure, and booked a test drive for the next day. I’d decided I wanted a diesel car this time round, the sort of driving I do would make a diesel cheaper in the long run, even after the higher initial price and higher cost of fuel. The test drive I had in the car was very short, the dealership was short-staffed that day, but they asked me to come back the following weekend and I’d be able to take the car out on my own for an hour.

I wasn’t initially too impressed with the car, the gear change took a little getting used to, and I stalled it once or twice, but that was probably because I wasn’t used to driving a diesel, or maybe the pedal in the Fiat was a little stiffer then the one I was used to in the Astra. I was willing to give the car another shot, though.

The next weekend I went back and as promised, was given the keys to a car and asked to bring it back in about an hour. I took it on the route I use to go to and from work every day, which is a route that provided a mixture of motorway driving, country roads, and start/stop town driving. I worked out how to use the trip computer, and used to tell me the average fuel consumption for the trip. When I returned the car to the dealer it was reading 59.8 miles per gallon.

By now my mind was pretty much made up. The car was nice to drive, it had all the bells and whistles on it that I wanted (specifically somewhere I could plug my iPod into!) so the only thing left was to work out a deal. I didn’t need to haggle with the guy, he gave me a decent trade-in on my car, and offered me a price I was prepared to pay on a car with the level of trim that I wanted. Actually, it was the car I’d driven on the short test drive the previous weekend. First registered 11 months ago, the car had stood on the dealer’s forecourt and only been used for short test drives in all that time. It’s only got 77 miles on the clock! He’s giving me the full three-year warranty and will make sure the car has been checked over and is in tip-top condition before I pick it up, which should be next Monday if the finances go through without a hitch.

Even though the car was registered last June, I’m still treating it as a brand new car, because even if you buy one that’s only got delivery miles on it, it could have been sitting out in the elements for several months anyway.

Roll on next week!

No Comments

Still not grown up

Following on from this post, I can tell you that I have since bought myself… er, my son (cough, cough) one of these Mindstorms sets. Actually, I ended up buying two from eBay, as both auctions ended about the same time. Haven’t sold the other one yet, it’s sitting on top of my bookcase at home. I can’t believe it’s been five years since I made that original post though!

No Comments

Anatomy of my WordPress plugin

For those not in the least bit interested in how a WordPress plugin is put together, move along. There’s nothing for you to read here. For those that are left, here’s a description of how my wordpress widget to show images from a pixelpost gallery is put together.

Installation:

Copy the l2pp.php file into /wp-content/plugins/pixelpost-widget. Download your pixelpost config file from wherever it is currently, and re-upload it into /wp-content/plugins/pixelpost-widget/includes

Log on to your WordPress control panel as an administrator.

Activate the plugin.

Look at the “Pixelpost Widget” section in the “settings” tab on the admin menu, and set the display options there.

Add the widget to your sidebar and save changes.

Take a look at your site to see if it’s worked!

Behind the scenes:

The plugin is a pretty straightforward one, which is why I’m going to explain it line by line here. At the top of the plugin is the header, the first few lines have to be entered according to WordPress’s rules, so that the plugin details appear on the admin control panel. Following that is the GPL licence.

<?php
/*
Plugin Name: Link To PixelPost
Plugin URI: http://www.danielfreedman.co.uk
Description: Plugin for displaying random thumbnails from a pixelpost database
Author: Daniel Freedman
Version: 0.2
Author URI: http://www.danielfreedman.co.uk
*/

/* Copyright 2009 Daniel Freedman (email : )

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

Now we come to some actual code. I don’t think it matters which order the functions appear in the plugin code, they are executed as and when needed. The first function I’ve put in is one that registers the widget with your WordPress install, and the add_action statement inserts a “hook” into your blog’s startup code, telling it to initialise the widget once all the plugins have been loaded.

function init_linktopp() {
register_sidebar_widget("PixelPost Gallery", "l2pp_showthumb");
}

add_action("plugins_loaded", "init_linktopp"); // get wordpress to start the widget once all the other plugins are loaded

The next function tells WordPress where to find the settings page for your plugin, and the add_action statement hooks it into WordPress itself so it appears on the menu.

function l2pp_admin_actions() {
add_options_page("PixelPost Widget", "PixelPost Widget", 1, "PixelPost Widget", "l2pp_admin");
}

add_action('admin_menu', 'l2pp_admin_actions');

Next up is the code that handles the settings page, which allows the user to tweak how the widget displays on the screen. The options are stored in WordPress’s internal options database, with the get_option and update_option functions used to read and update the option values. The form is a fairly straightforward html form, when the “Update Options” button is pressed the form “loops back” on itself, so we check to see if $_POST['update_options'] is set. If it is, then we have some options to update, if it isn’t, then we retrieve the current values for the options from WordPress.

There are three fields on the form, the first being the number of thumbnails to show on the screen, the second being the heading to use if we’re only showing one thumbnail (for example “one of my photographs”) and the third being the heading to use if we want to display more than one thumbnail (for example “some of my photographs”).

The “require” statement inserts the code from the pixelpost config file, and as it’s a requirement and not an include, the code will stop running at this point if the file doesn’t exist. The downside to this is that any other widgets below this one on the sidebar won’t be displayed either.

function l2pp_admin() {
require "includes/pixelpost.php";
if (isset($_POST['update_options'])) {
// we're updating the form, so save all the options

$numthum = $_POST['l2pp_numthum'];
$stitle = $_POST['l2pp_singletitle'];
$mtitle = $_POST['l2pp_multititle'];

update_option('l2pp_numthum',$numthum);
update_option('l2pp_singletitle',$stitle);
update_option('l2pp_multititle',$mtitle);

?>
<div class="updated"><p><strong><?php _e('Options saved.' ); ?></strong></p></div>
<?php
} else {
$numthum = get_option('l2pp_numthum');
$stitle = get_option('l2pp_singletitle');
$mtitle = get_option('l2pp_multititle');
}

?>
<!-- the options entry screen -->
<div class="wrap">

<h2><?php _e( "Settings for Pixelpost Widget") ?></h2>

<form method="post" action="">
<table>
<tr><td><?php _e("How many thumbnails to show?" ); ?></td><td><input type="text" name="l2pp_numthum" value="<?php echo $numthum ?>"/></td></tr>
<tr><td><?php _e("Heading for one photo (e.g. Random photo):");?></td><td><input type="text" size="30" name="l2pp_singletitle" value="<?php ECHO $stitle; ?>"/></td></tr>
<tr><td><?php _e("Heading for multiple photos (e.g. Random photos):");?></td><td><input type="text" size="30" name="l2pp_multititle" value="<?php echo $mtitle; ?>"/></td></tr>
</table>
<p><?php _e("If the second heading is left blank the first heading will be used.") ?></p>

<p class="submit">
<input type="submit" name="update_options" value="<?php _e('Update Options') ?>" />
</p>
</form>
</div>

<?php
}

Finallly we come to the main function in the plugin, the one that actually shows the thumbnails on the screen. Once again we check for the pixelpost config file, so we know where the database is and how to log on to it. Then we make a connection to it. WordPress has a “database object” defined somewhere in its code, and this means we can create a new object and give it the details of a different database. This is how the plugin is able to get information from the pixelpost database while still leaving the rest of WordPress to use its own database.

function l2pp_showthumb() {
require "includes/pixelpost.php";

// connect to the PixelPost database
$ppdb = new wpdb($pixelpost_db_user,$pixelpost_db_pass, $pixelpost_db_pixelpost, $pixelpost_db_host);

Next we find out how many thumbnails we’re supposed to display, and we run a query on the pixelpost database to get that number of records, and order them randomly. We also check that the date and time of the image on pixelpost is before the current date and time, so it shouldn’t show any images you’ve set to be posted in the future.

//Get random image(s)
$numthum = get_option('l2pp_numthum');

$random = $ppdb->get_results("SELECT id, image, datetime FROM " . $pixelpost_db_prefix . "pixelpost where datetime <now() ORDER BY RAND( ) LIMIT " . $numthum );

We do another query on the pixelpost options table, to get the mail url for the pixelpost blog, and the path to the thumbnails folder on pixelpost. This is so the images are actually displayed, and the link to the pixelpost blog still works when you click on a thumbnail.

After that query we start outputting some data. First we output the heading to the screen (if more than one thumbnail required and a suitable heading is set, then use that one, otherwise use the heading for a single thumbnail).

$meta = $ppdb->get_row("Select siteurl, thumbnailpath from " . $pixelpost_db_prefix . "config");

echo $before_widget;
if ($numthum > 1 &amp;amp;amp;&amp;amp;amp; get_option('l2pp_multititle')) {
$title = get_option('l2pp_multititle');
} else {
$title = get_option('l2pp_singletitle');
}
echo $before_title . $title . $after_title;
echo '<div class="box">';

Then we enter a loop to print each thumbnail. The foreach statement looks at the results from the “random image” query we performed earlier, and executes the code in the loop with each image’s information set to the $oneimage object. We then make up an html link, with the link “text” being the image itself.

foreach ($random as $oneimage) {
echo '<a href="'. $meta->siteurl . 'index.php?showimage=' . $oneimage->id . '"><img src="' . $meta->siteurl . $meta->thumbnailpath . 'thumb_' . $oneimage->image . '" /></a>&amp;amp;amp;nbsp;';
}
echo '<br />';
echo '</div>';
echo $after_widget;
return;
}

The last bit looks complicated, but actually produces a link that looks like this:

<a href="www.mysite.com/pixelpostblog/index.php?showimage=1"><img src="www.mysite.com/pixelpostblog/thumbnailfolder/thumb_img001.jpg></a>

And that’s it! It used to be a bit more complicated than this, but the more I learned about plugins and widgets the less code I found I actually needed in order for it to work properly. You can download the plugin from WordPress if you want to try it for yourself.

No Comments

Ok, I admit it…

I’m a bit of a geek, and having worked in the computer industry for 20 years or so, I can’t help this geekery spilling over into my home life. So when I get something new (in this case the WordPress blog) I like to delve behind the scenes and see how it all fits together.

As a result, I’m able to tweak the system to get it to work the way I want it to work. Nothing major, just little things here and there. The first thing I did is to find a theme I liked the look of. You’re looking at it now :-) But there were one or two things about it I didn’t like. For example, the monthly archives. When you click on a monthly archive, I want the entries to be shown chronologically, instead of “last post first”, which is the default behaviour. Doesn’t it make more sense to have the first entries at the top of the page, so you can just read it all in the right order? I think it does, so I changed that. I still need to play around with the stylesheet and layout a little bit, I don’t like the way the post headings show up differently in archive listings to the way they show on the main page. This may mean that I develop my own theme from scratch, we’ll see how it goes.

The other thing I’ve done, is to write a plugin for WordPress that shows random images from my Pixelpost photo blog over in the sidebar. As this was the first plugin I’d written, it took a few hours, even though I’d done some php and mysql stuff before. I just wasn’t familiar with the way WordPress wanted things to be done. But, as you can see, I got there in the end. The plugin went through many changes before it ended up as the finished article.

I first thought about having it show the latest image, one random image, and a random category. Then I simplified the idea just to show a few random images. Then I wrote a settings page for the admin user to enter the details of the pixelpost database (since the plugin would have to get its data from the pixelpost database it would make sense if it knew how to connect to it). Then I realised that the settings for the database are held in a config file, just as they are with wordpress, so it might as well read the settings straight from the file. Then I widgetised the plugin, and moved all the settings to the widget control panel. Then I realised that if you log in to the blog as an author instead of an administrator, you can’t see the widget control panel, but you can still see the settings. So I moved them all back again. Then I put some code in so the user can define the headings, and to say how many columns they wanted the images showing in. Then I realised that the sidebar automatically wraps the images when it needs to, changing from three columns to two, so I took that bit out. And the final result is what you see here! Easy, isn’t it?

That’s the beauty of open source software, if you don’t like something, you can change it. Mind you, that’s the same as saying if you don’t like having to go to work on public transport, why don’t you learn to fly a plane and do it that way instead?

No Comments

The lesser spotted fantastic bank holiday weekend

Today was a good day. In fact the whole weekend’s been pretty darn good. Saturday I spent the day with my son at my parents house, copied some of my dad’s old cine film to dvd, copied it from there onto my PC, and started playing around with tidying it up. More on this in another post I think.

Yesterday I got out on the bike and rode 60 miles, up onto the hills, took some photos and rode all the way back again! Have a look here and here for a couple of pics. I also took a car for a test drive, as my car has now done 107,000 miles and I think it’s time I changed it before it fall apart. Again, more about this in a future post.

And then today my ex and I took our son for a day trip to Morecambe, where we played on the beach, soaked up the sun, and ate far too much junk food. Take a look ay my favourite pic of the day.

And to cap it all, the sun shone. Sheer perfection, couldn’t have wished for anything better.

No Comments

Test of embedded video on youtube

Ok, so it may not be so impressive to some, but this is the first time I’ve done this!

This is a short clip from a Super 8 cine film my dad shot on my first birthday, back in December 1967. I had hair on my head back then!

Oh, and don’t be thinking your speakers have broken… dad’s cine camera didn’t record sound :-)

No Comments