Desert Island Discs

As per the Radio 4 programme – which I don’t actually listen to because well I don’t own cordoroy and I loath Coldplay (post 2007-ish anyway).

In no particular order and currently incomplete:

  • Nina Simone – Sinnerman
  • Israel Kamakawiwo’ole – Somewhere over the Rainbow
  • Otis Reading – Sittin’ on the Dock of the Bay
  • Johnny Cash – When the Man Comes Around

Image Transitions using Scriptaculous

Although I’m not a fan of creating a javascript library for all the little simple tasks – you know the really simple things – I have created a simple library for this.

It’s purely because I quite often have to put this effect into a website and I wanted a nice re-useable method t going on with.

Firstly it’s just javascript and HTML – no back-end coding so I wouldn’t use it to show an image library – where you should be able to handle non-javascript users.  This is purely aimed at showing transitioned images on a website with no user interaction.

I’ll add a demo page later and put the link at the bottom of this post.

The javascript library is available for download via my downloads page and I won’t go into detail about.  It simply makes use of Prototype and Scriptaculous – so if you are into jQuery or mootools you’ll want to look elsewhere.

Firstly let’s look at the essential parts of the HTML page and then we’ll look at how to use the library for your purposes.

First we create a DIV (or another container) that will hold the images.  To make sure your website looks OK without javascript, you must provide a static image in the DIV.

Then we create a container (another DIV or a UL or whatever you fancy) and put A tags inside that point at each of the images we will be using.  The “title” attributes will be used as ”alt” alttribtes for the images.

<div id="divLinks" style="display: none">
  <ul>
    <li><a href="images/b_f_0_0_0_0.jpg" title="Image 1">Image 1</a></li>
    <li><a href="images/b_f_1_1_0_1.jpg" title="Image 2">Image 2</a></li>
    <li><a href="images/b_f_1_1_0_2.jpg" title="Image 3">Image 3</a></li>
    <li><a href="images/b_f_1_1_0_3.jpg" title="Image 4">Image 4</a></li>
  </ul>
</div>

<br />

<div id="divContainer" style="position: relative">
  <img id="imgStatic" src="images/b_f_0_0_0_0.jpg" alt="Image 1" style="position: absolute; top:0px; left: 0px;" />
</div>

<script type="text/javascript">
<!--
var images = new enjoyImageTransition(
 {
  callbackName: 'images', // must be the name it is declared as - used for callbacks
  containerId: 'divContainer', // images will be rendered inside this container - it doesn't need to be a DIV
  staticImageId: 'imgStatic', // the original image that will be rendered out once the process begins
  linkContainerId: 'divLinks' // an element containing A tags which detail all the images
 });
-->
</script>

This shows you the minimum configuration to use the library.

Let’s go through all the options available to help you configure how the images appear:

Option Default Value Description
containerId null ID of Container – DIV to hold the images
containerElement undefined actual container element – extended by Prototype
staticImageId null ID for the static image
staticImageElement undefined actual static img element – extended by Prototype
linkContainerId null ID for element that contains the A tags that point to the images
linkContainerElement undefined actual element containing the A tags – extended by Prototype
switchInterval 1500 time in milli-seconds between interchanges
transitionTime 1.2 time in seconds for EFFECT
randomOrder false show images in a random order
debugMode false alert you when it encounters an error
maxHeight 0 if not 0, images will be scaled to a maximum height (keeping aspect ratio)
maxWidth 0 if not 0, images will be scaled to a maximum width (keeping aspect ratio)
uniqueIndex (random) used to provide unique IDs to elements created by the script when used more than once on a page
currentImageIndex 0 index of currently shown image – provide this value when not starting from the first image in the list
lowestZIndex 500 alter this if your images need to be above/below other elements on the page
callbackName null declared name in javascript so we can use a simple call-back

Don’t forget to reference the javascript in your HEAD section (as below) and that’s about it.

 <script type="text/javascript" src="scripts/prototype-1.6.1.js"></script>
 <script type="text/javascript" src="scripts/scriptaculous.js"></script>
 <script type="text/javascript" src="scripts/enjoyImageTransition.js"></script>

You can download the javascript file from here: enjoyImageTransition.js as text.

The Recovery of Owen Hargreaves

I sometimes forget that we have Hargreaves in the physio room – it’s been so long since I saw him don a United shirt.

According to the papers his recovery is now a psychological one rather than a one physical one: Man Utd – What the Paper’s say.

I remember my time in Sport Studies and how important the psychological element is to a players ability; I used to run through skill moves and plays in my head repeatedly in an effort to use reinforcement to learn and incorporate new skills.  But to overcome 18 months of slow recovery is something else entirely: every day having to find some encouragement in the smallest of improvements and finding something of use in a day when you actually go backwards.

Best of luck Hargo.

Send Email with attachments in PHP

Although there are ways to send email in PHP using PEAR and other libraries, sometimes you’ll get stuck in a situation where that either isn’t possible or just too much of a faff.

The other day I decided to create a function for this purpose that I can use in my own library of code.

It can be dropped into your include files and used for simple emails without attachments, HTML emails or complex emails with multiple attachments.

I haven’t spent a great deal of time on this so it might not be 100% but works well for me so let me know if there are any flaws that need to be taken care of.

You can download the function (and supporting functions) from here: send email with attachments in PHP

PageRank tool walkthrough

I’ve added a video on YouTube to walkthrough using the PageRank checking DLL you can download from my website.

 (by the way, there is no audio).

 

Google Maps, UK Postcodes and GeoCoding

Going back a few years I downloaded a UK postcode database that mapped Outcodes (the first part of the postcode) to approximate Lat/Long co-ordinates.  When used correctly you could use the data to find which postcodes were closest (distance matching) or simply the distance between two places by comparing the Lat/Long co-ordinates with a bit of maths.  The main drawback was the need for a database that was only accurate to within a few km – no good for showing actual locations on a map or for local services – as the co-ordinates returned were for the centre of the Outcode.

Nowadays however Google’s geocoding service allow you to calculate distances between two addresses or postcodes effortlessly.  You can then plot these directly onto a Google map and best of all, it’s all free to use.

My latest project provided an opportunity to make use of this facility.  I had initially intended to use UpMyStreet or Google Local Search to furnish the information my client needed.  Upon inspection however, neither service had a comprehensive enough list of local services.

The decision was made to go back a step and manually enter what the client deemed the most important local landmarks or services.   This was done simply by providing a postcode or partial address and from this I was able to provide the distance to the service and plot it on a map.

There are many useful applications for this and I’ll be adding some of these facilities to this website over the next few weeks I hope.  As I add facilities I’ll be sure to add source code to demonstrate how simple these operations have now become.

Using the PageRank DLL in your applications (VB.NET)

To complete this walkthrough you’ll need to download the PageRank DLL.  This is included in the PageRank Checker download on the downloads page.

Extract the ZIP file.  The DLL file is in the path: GetPageRank.zip\PageRank\bin\Debug

Make a note of the path as you’ll need it later.

 

Start by opening up Visual Studio (or Developer Express etc) and creating a new project of type: Windows Application.

Then add the following controls to the main form:

Label: Text = “Website URL”

Label: Text = “Google PageRank:”

Label: Name = “lblResult” and Text = “-”

Textbox: Name = “txtURL”

Button: Name = “btnGo” and Text = “GO”

 

The next step is to add a reference to the DLL into your project.  Generally you would right-click on the Project in the Solution Explorer and select “Add Reference”.

When the dialog box eventually opens up, select the “Browse” tab and find the DLL file which should be called “PageRank.dll”, then click OK.

 

OK, double-click on the button you’ve labelled “GO” which will create an event handler for the button’s OnClick event.

I’ve provided the code in C# and VB.Net

Directions for C#

Add the following line to the top of the file:

using PageRank;

Then inside the event handler:

TGooglePR prCheck = new TGooglePR();
lblResult.Text = prCheck.ReturnPageRank(txtURL.Text);

and you’re done.

Directions for VB.Net

Add the following line to the top of the file:

Imports PageRank

Then inside the event handler:

Dim prCheck As New TGooglePR()
lblResult.Text = prCheck.ReturnPageRank(txtURL.Text)

and you’re done.

Just run the project and enter a full URL in the textbox before clicking on “GO”.  The Google PageRank will be shown in the label within a second or so.

Enjoy.

Plus I’ve done a video walthrough in C# and posted it on YouTube: http://www.youtube.com/watch?v=F9MgNVmJnro

The Project Location is Not Trusted

Ever got this dialog box: "the project location is not trusted" ??

Yeah me too. A recent change in network infrastructure and folder-redirection caused this issue to surface.

The way around it is well documented but sometimes there are other factors to consider.

First, take a look at Microsoft’s fix for this: The Project Location is Not Trusted Dialog Box

Then if you still have a problem like I did, check the location is not in your Trusted sites list in IE (thanks to the following page: http://discuss.joelonsoftware.com/default.asp?dotnet.12.334487.2

I know the author of that page didn’t solve all his problems but removing the network location from my Trusted Sites list sorted out my problem straight away.

AR

IRPStackSize Registry Fix for “Not enough server storage space available to process this command”

I haven’t updated my website much lately – guess I’ve been really busy at work. I’m currently working on some Server 2003 projects and have been playing around with Group Policy, roaming profiles and redirected folders.

These are not new subjects to me but as I tend to do more development work nowadays, it usually means long periods between server work and the things you don’t do every day fall out of your memory.

I had a real grapple with what I initially thought was permissions issues the other day but turned out to be caused by poor allocation in Server 2003 by default.

The situation arose when I was trying to get client machines to create and update roaming profiles (all done in a test environment before going live). The actual error condition was “Not enough server storage space available to process this command” and after trawling about I found the fix to be something going back to Windows NT times and a resistry hack to enable or increase the IRPStackSize. Updated the registry and the problem was solved.

The fix is available here: IRPStackSize Registry Fix

AR

Effect of HTTP 403-6 Error on Google

A few days ago I discovered through Google Webmaster Tools that some of my sites were unreachable by Google. In particular Google reported my homepage as unreachable and many of my sub-pages returned the same 403-6 error.

After checking my website both with various browsers and response grabbers located around the world I determined that the problem was definately not with the way I had designed the website or configured the hosting.

The HTTP 403-6 error means that an incoming request has been denied (Forbidden) because the IP address is banned or rejected in some way. Initially I tried to determine if this was because of some response error on my part; this was not the case.

I checked my server logs and could see the same errors showing up on every request that came from the GoogleBot (incidentally all requests were on the same IP). I notified my hosting provider and eventually the problem was rectified and the IP address used by GoogleBot at that point in time was unblocked.

I re-submitted my sitemaps and shortly afterwards the errors started to disappear from Google’s Webmaster Tools portal. I hoped that I had got to the root of the problem in time.

The next day while routinely checking websites I discovered that the homepages had disappeared from Google’s search results. Initially I thought that the sites had dropped on their keyword matches but “site:URL” checks showed the actual pages had been dropped.

It has taken 2-3 days for these pages to reappear in the search results and I am still waiting for some pages to come back in. Personally I found the timing to be very bad as I am trying to build Google’s confidence in my websites.

This all points to one of my main tips for SEO. It doesn’t matter about anything else if Google etc cannot see your website. Choose your hosting company carefully.

AR

Return top