Archive for the ‘tech’ category

Blogger to WordPress migration

March 10th, 2010

This blog post summarises my move from a Blogger blog that is published using the (soon to be deprecated) FTP publishing, to a locally installed version of Wordpress. My aim is to keep a majority the URLs the same, and seamlessly redirecting users and search engines on the ones I can not. I suggest at least skimming the blog post before starting the move. I also strongly recommend not skipping the backup. Okay, let’s go…

The first thing to do is to set up new installation of WordPress. This is well documented else where so I will not go through that here. I am assuming you have the technical ability to do that, and if you do not then perhaps WordPress is not for you.

Next make a backup of your Blogger blog. Do this by selecting “Export blog” from the “Basic” settings on the “Settings” tab in Blogger. This is important as the migration process will destroy your comments and loose other settings. If it goes wrong you will need this file to go back and try again.

Next you need to switch your blog to a “blogspot.com” address for an FTP published blog. To do this select “Publishing” from the top of the “Settings” tab in Blogger, click to option to switch to “blogspot.com (Blogger’s free hosting service)”, enter a temporary Blog*Spot address (that can be literally any text and you don’t need to remember it) and save the settings.

We are now ready to import the blogs in to Wordpress. Log in to WordPress and select “Import” from the “Tools” menu. Select Blogger (obviously) , click the “Authorise” button, and then “Grant Access”. With luck You should be able to click the import button next to the blog you want to, well, import. Wait while it does it’s magic. For some reason it thought I had fewer comments than I did that made the progress bar go mad, but I left it a while and it worked okay.

Next to fix the premalinks.

Set the WordPress permalinks setting so the format reflects your current blog. You can finds the setting in “Permalinks” from the “Tools” menu. If your old archive settings were for monthly archives with a php extension (like mine) then your new setting will be ”/%year%/%monthnum%/%postname%.php”. Add a “/%day%”, remove the “/%month%”, or change the “.php” as required. Remember to created the .htaccess file as requested when saving. If you archived by week then my apologies, but you are on your own with that one as there is no direct mapping between old and new.

Now to change the “slugs” so that the new post URLs are the same as the old ones. To do this we need to run some SQL and I will have to leave you to figure out how to do this on your hosting provider. Most ISP control panels will have a link to phpMyAdmin somewhere.

You can optionally find out what will need to be changed by running the following. This is totally optional and you don’t need to run this if you don’t want to. Not that if you run this at any time you unpublished posts will show up as hey don’t have any slug yet.

SELECT posts.`post_name`, meta.`meta_value`
FROM `wp_posts` AS posts, `wp_postmeta` AS meta
WHERE ( posts.`ID` = meta.`post_id` ) AND ( meta.`meta_key` = 'blogger_permalink' ) AND ( posts.`post_name` <> SUBSTRING_INDEX(SUBSTRING_INDEX(`meta_value`,'.',1),'/',-1) )

If you changed the default settings when installing WordPress remember to replace the “wp_” prefix with the one you changed it to. Do this will all the SQL in this post.

One difference between Blogger and WordPress is that Blogger allows you to have multiple posts with the same files names posted of different days, weeks, months or years (depending on your old Blogger settings), while WordPress requires a unique “slug” filename regardless of the date. With four years of blogging I have been lucky and had no duplicates. If you do have a duplicate then WordPress will rename one of them by editing the post after the import. You can find out how many times each name is used by running the following (rather quick and messy) SQL…

SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(`meta_value`,'.',1),'/',-1), COUNT( SUBSTRING_INDEX(SUBSTRING_INDEX(`meta_value`,'.',1),'/',-1) )
FROM `wp_posts` AS posts, `wp_postmeta` AS meta
WHERE ( posts.`ID` = meta.`post_id` ) AND ( meta.`meta_key` = 'blogger_permalink' ) AND ( posts.`post_name` <> '')
GROUP BY SUBSTRING_INDEX(SUBSTRING_INDEX(`meta_value`,'.',1),'/',-1)
ORDER BY COUNT( SUBSTRING_INDEX(SUBSTRING_INDEX(`meta_value`,'.',1),'/',-1) ) DESC

If you have a duplicated name where count is greater than 1, then make a note of it and rename one of them after the import. If you want to make the old URL point at the new page you will need to add something to the htaccess file.

Now we are ready to change the slugs. To do that just run the following SQL script…

UPDATE `wp_posts` AS posts, `wp_postmeta` AS meta
SET posts.`post_name` = SUBSTRING_INDEX(SUBSTRING_INDEX(meta.`meta_value`,'.',1),'/',-1)
WHERE ( posts.`ID` = meta.`post_id` ) AND  ( meta.`meta_key` = 'blogger_permalink' ) AND ( posts.`post_name` <> '')

Now we need to fix the links to the archives and the labels. To do this I got the server to direct the browser from the old URLs to the new ones using a 301 (permanent) redirect.

First I create a directory called “archive”, create a file in it called “.htaccess” and cut and paste the following code in to it…

RewriteEngine On
RewriteBase /blog/
RewriteRule ^([0-9]+)_([0-9]+)_([0-9]+)_(.*)$ $1/$2/ [R=301,L]

My blog is stored in a subdirectory “blog”. Simply change the RewriteBase line to reflect your blogs location. If you used the day in your old archives then add “$3/” after “$2/”, and remove the “$2/” if you archive by year.

Now for the labels create a directory called “labels”, create another file in it called “.htaccess” in it, and cut and paste the following code in to it…

RewriteEngine On
RewriteBase /blog/
RewriteRule ^(.+)\.(.*)?$ category/$1/ [R=301,L]

Again change the RewriteBase for your blog. This should work whatever your blog settings are.

Finally the RSS feed has also changed so add the following to your blog’s main .htaccess file.

RewriteRule ^atom\.xml$ /feed [R=301,L]
RewriteRule ^rss\.xml$ /feed [R=301,L]

If you don’t want to take down your web site while you are doing this then you can install the blog elsewhere to do the port, and then move the WordPress install in to place. You will also need to change all the references in the database from the temporary URL to the normal one. Just changing the settings in WordPress is not enough. I did the install on a subdomain using the same file structure at the live site, backed up the database as SQL (after the port), did a find a replace of the SQL replacing the temporary domain name to the normal one, and finally run that SQL to replace the old data. Then when I copied the WordPress files across it just worked.

I hope this is of help and I wish you luck in your move. I really can not help with dozens of noddy questions, but if you are really stuck then feel free to get in touch and I sell see if I can help.

You can still switch to Blogger FTP publishing (for now)

March 6th, 2010

This blog post might be of use to you if you, like me, you are migrating your Blogger blog to WordPress. As you may have read I am having to move my blog because Blogger is removing it’s publish by FTP feature.

When you first try and migrate your posts it will fail. After a bit of head scratching I realised that this was because the WordPress “import” migration relies on the blog being hosted on a “blogspot.com” address and not on a custom domain. You can easily change this temporarily without affecting your current blog. Just clock the appropriate option under “Publishing” from the blog’s “Settings” tab.

If you then want to edit your old template to redirect the old URLs to the new ones, or are just testing the migration process, you will need to switch back to FTP. This would not be a problem if Blogger had not removed the FTP option already, but they have, so it is. Fortunately the feature is still active and it is just the link that has been removed.

So, to switch back now you need to look at the address of the page when you are creating a post or editing blogger settings. Make a note of the “blogID” from the line. Then paste the following in the address bar replacing XXXXXXXX with the blogID value.

http://www.blogger.com/blog-publishing.g?blogID=XXXXXXXX&publishMode=PUBLISH_MODE_FTP

You can then check all the details, enter the captcha, and save the setting to get back to where you were before. I hope this is of help.

March 2010 Events

March 1st, 2010

People ask me to let them know when something is happening that they might be interested in and I try and do that, but this month there are so many events I thought I would also summarise them here…

  • March 4th is another Dorkbot Newcastle in the Life Lab at the Centre for Life. This month Sam Goldwater talks about animation techniques, David King talks about his KISS ethos (Keep It Simple, Stupid), and Brian Degger talks about the curve from scientist to new media.
  • March 12th is Datarama. This month is an AV and Science festivals special at the Start and Shadow. This is a show and tell with a artistically creative slant. You never quite know what you will see and it is worth a visit.
  • March 13th and 14th is the second Maker Faire at the Centre for Life. This is a chance for the UK’s mad inventors (including me) have a chance to show off there creations.
  • March 17th NE Bytes is back at Newcastle University. This month features Visual Studio 2010 with Richard Fennell and Matt McSpirit from Microsoft talks about System Centre in the R2 Wave.
  • March 20th and 21st is BarCampNorthEast3 at the Centre for Life. This is a chance to share your experiences and skills with others and you are coming. Attendance is mandatory but I promise you that you will enjoy it. :-)
  • March 29th is Super Mondays. This month is all about mobile payments featuring John Lunn from PayPal.

Finally March 10th and 24th is the fortnightly Newcastle Coffee Morning from 8:30am at the The Settle Down Café. Just a chance to have a cupper and a chat before work.

That is it for now. I recommend all these events. There are more details on the events web sites but feel free to ask me if you want any more details.

What domain should I use?

February 13th, 2010

I have now decided to move my blog to WordPress following Blogger discontinuing there FTP service. Thank you for the words of advice.

I have another decision to make now and your input would be appreciated. The question is… Should I move this main “tech, rant, fun” blog to another domain.

A while ago I registered “alistairmacdonald.org” and “macdonald.info”. My intention was to use these as my professional front-end and keep my “agm.me.uk” for more personal projects. Last year I managed to register “alistairmacdonald.com” that I was planning to use instead of the “.org”. I also have a few “.co.uk” domains that I never used in the end including “Millisecond”, “Multitrack”, and “Stereophonic”.

I know a few people don’t like my “agm.me.uk” address. The reason why I like it is that it is short, AGM (my initials) are memorable, and it is controlled by Nominet so subject to UK and not oversees law. The down side is that the domain does not instantly identify it’s self as mine, the “.me.uk” is often sometimes with “.co.uk”, and more recently people have been missing off the “.uk” with the addition of the “.me” top level domain.

No matter what happens I anticipate still using “agm.me.uk” for my pet projects and micro sites. I am also actively moving some pet projects to the domain in a cost saving exercise.

So, what are your thoughts?

My blog will be moving

February 3rd, 2010

My blog here is managed by Google’s Blogger and hosted on my own web site on a Rails Playground server. This is done by giving Blogger FTP access to my site that is used to upload the pages when they change. Sadly Google are deprecating this FTP feature and I will either have to run the blog from the Blogger’s servers (but I can use my own domain name) or host the my blog myself.

I have always had a plan in place to move my blog from Blogger to WordPress. This will continue to be hosted on my web site and the URLs will not change. You never know when a service will disappear so I tend to plan ahead like this. There is a nice migration path and this is currently my favoured solution.

My main concern about moving to WordPress is the amount of comment spam that friends get despite using recaptcha. I have had to disable the comments on the BarCampNorthEast web site that was receiving a couple of spam comments a day.

So, do you think I am doing the right thing. Should I use WordPress or something else? Should I use another comment service like Disqus to cut down on spam, or should I host the whole thing somewhere else? All comments welcome (unless they are spam :-) ).

USB printing on Ubuntu 9.10

January 31st, 2010

Last year a purchased an Aspire Revo R3600 with a 160GB HDD that I installed Ubuntu on. It has been a great little machine and I am very pleased with it.

Somewhere down the line my old LaserJet printer (from Freegle/Freecycle) that is connected using a cheep USB to Parallel adapter (off ebay) stopped working. It is a problem that many people appear to have had when they upgraded Ubuntu 9.10 (Karmic Koala). After a bit (okay, a lot) of debugging I have figured out that you need to treat the USB device as a parallel printer and not the default USB printer. To do this change the URL prefix from “usb:” to “parallel:”, or if that is nonsense to you use the following instructions.

  • Go to the printing devices by selecting “System”, “Administration”, and then “Printing”.
  • Right click on the old printer (if one is there) and select delete.
  • Click the “New” button.
  • Select “Other” and enter the device URI as”parallel:/dev/usblp0″.
  • Select your printer as you would normally and it should then work (a reboot may be required).

Remember this is only for if you are using a parallel printer with a USB converter. I hope this helps you, and if it does and you have posted for help elsewhere, please help someone else by going back and posting the answer (or link back to here). Finally, before you smug Windows users start having a go, it took me longer to get the converter running on my XP machine. :-P

Mr Duck’s Amazing Web Site

January 15th, 2010

So, at long last Mr Duck has his web site. I have been taking pictures for Duck 365 for the last year, and stupidly have agreed to continue by popular demand. What I never quite got round to was making a web site for it. Eventually I managed to find some time by using the good old excuse of it being a learning exercise.

The site is a little tong in cheek fitting in with the Mr Duck back story. It is the web site that a small yellow plastic duck would have asked for. :-) It has a lot of new CSS layout in it that I have used as an experiment, but it does degrade gracefully. The thing that most amazed me is that the CSS font-face actually works, although there are bugs that I needed to work around. Also I accidentally I created a new simple templating system using an error document to catch the requests and build the web page. I shall probably build on this for other projects.

I have also found a new way to work on IE computability. It appears that IE6 and IE7 have very close layout problems. The markup for IE6 also fixes the problems for IE7. So what I have done is built the site using Chrome and Firefox, and then fixed the layout in IE6 for IE7 and below in a separate conditional CSS file. Then all I needed to do was work around the PNG transparency issues for IE6 and below in a second conditional CSS file. Everything else just works then, and I only needed one version of IE installed for development.

The best thing about the site from my point of view is that it should be zero maintenance. It automatically pulls the pictures from flickr and even uses flicker to manage the comments. I decided not to display the comments on the site at the tims as there a security implications of allowing users to add content to your site, but I do display a comment count and link back to flickr. I even dynamically generate the site map and RSS feed.

There are a few more things I would like to do. I plan to add some slow cloud animation, improve navigation, and intermittently add a few more random Mr Duck images to the background. For now though I will leave it or I will just not get anything else done.

So please check out “Mr Duck’s Amazing Web Site”, and you can also follow his antics on Twitter. Also please let me know if it works well or not on your browser and if there is anything else you would like to see.

I like Twitters Retweet feature

December 3rd, 2009

Can I just put on the record that I like Twitter’s Retweet feature.

In March I blogged about how I would like to see a Retweet feature built in to Twitter and we have recently seen such a feature slowly rolled out.

It takes a little getting use to seeing other peoples’ icons in your stream, but I have grown to find that useful as well. I was also worried that because it is so much easier to retweet that people might get carried away, but this has not happened, and you can block the retweets from just one user but still see there own tweets. What I love the most is that fact that when several friends retweet something I only get it once instead of several times like in the past. I am back in control.

As with most things the reception has been mixed, but on the whole most of the people I am following are using it, and although some like it and some prefer the old way of doing RSs, I don’t think it can be described at “Hated”. I only mention this because of the Tech Crunch article who’s title annoyed me enough to write this post. I feel that article just a personal view of Mike Butcher and not a valid statement of fact.

Chocify, it’s the future

November 23rd, 2009

Today I came up with a cracking idea for a web service called “Chocify”.

People have been using Spotify to jointly build up playlists for the day, the season, or events. Why can this not be extended to chocolate? For example I like the idea of starting off with a KitKat Chunky, followed by a slightly more sticky Twix, and throw caushion and commen sence to the wind and top those off with a Double Decker.

Now, someone could see my mistake, that being the lack of a Crunchie bar, and insert it in to the eat list for me. I can also share this list with anyone I am visiting who needs to get supplies, or anyone who shares my taste in chocolate.

I know what you are thinking, but there is a revenue stream here. Yes people can take the lists and head down the sweet shop, but just imaging the convenience of a “buy it now” button, and within two or three months the postman (or woman, we don’t want to be sexist at Chocify) will deliver them to your door.

The domain name is still available but won’t be for long with such a great idea. It’s a winner. Anyone want to invest?

Happy Twitter birthday to me

November 17th, 2009

It was three years ago today that I first signed up to Twitter. I was user number 12838, and you can check your own number by clicking on your RSS feed and looking towards the end of the URL. Luckily the user name alistair was still available at the point.

I can not remember my first tweet, and Twitter removed all the older ones before I was able to make a backup, but like so many people’s first tweet it was along the lines of “Figuring out what Twitter is”.

Although I have not used it continually for three years I have for the last couple and and frighteningly it has become part of my life. I have made some great friends through it, keep in contact with a lot more, become part of one of the best (and possibly maddest) photo walk groups, know what is happening in the tech and non tech world as it happens, and feel part of a great set of online communities.

Originally it was a great way to keep in the loop and know what friends are up to. Today people are more open and broadcasting to the works when then tweet, but as a result they are [very sensibly] less open, and that in many ways is a shame. I am considering doing the same by being slightly less open and unprotecting my updates.

I think the secret of Twitter’s success is naturally luck, but also adapting it’s self and allowing user to almost add functionality. I don’t know if it can maintain it’s position forever, but unless it does something really stupid I see it continuing for quite a while.