28Akismet is fantastic

Akismet is fantastic

Spam is a major issue for a lot of bloggers and I’m one of them. I currently run quite a few WordPress based blogs on various topics and niches and although I knew about it I never got around to setting up Akismet. For those of you who don’t know, Akismet is a service which let’s you protect yourself against spam. It is available as a plug-in (comes packed with WordPress as standard) and only needs an API key from WordPress.com to work.

Before setting it up I was getting several hundred spam comments each week – I know this isn’t anywhere near as much as some get but still it was very annoying. A few days ago I thought I’d spend a minute on each of my blogs installing Akismet and since then exactly 0 spam comments have come through.

So I have to say, for all of you who aren’t yet using Akismet on your WordPress blogs – I highly recommend it.

23WordPress post scheduling

WordPress post scheduling

WordPress Post SchedulingI just wanted to let you all know about post scheduling in WordPress. If you haven’t already given it a go I’d highly recommend you go take a look. Basically it allows you to instead of publishing a post immediately you can schedule it to be published at a specific time and date in the future. This means that if one day you manage to crunch out more posts than you normally would you could have them published in a few days or so instead.

For me this is great as I maintain quite a large amount of desktop wallpaper sites, all running on WordPress. All of these sites need to be kept up to date with regular wallpaper updates. Instead of dropping by every other day and adding a new wallpaper I just add a load of them every two weeks. Then, over the course of the next two weeks the wallpaper posts are automatically published without me doing anything.

Another great use for this is if you plan on going away for a little while. For example, over Christmas I’ll be away for about 3 weeks (Spain, wooohoooo!) but you can be sure that my sites will be kept up to date.

So go ahead, check it out! It’s on the top right hand side of the “Add New” section of WordPress.

22Using numbers to represent data

Using numbers to represent data

I’m currently in the process of rebuilding one of my older sites from the ground up. One thing that the new version makes use of is a field in several database tables called ‘state’. Basically, this holds an integer value ranging from 0 upwards where each number represents a specific meaning. For example…

0: Inactive
1: Active
2: Processed
3: Archived

The reasons for doing this are quite simple; it saves space in the database and is also a lot easier (and nicer) to work with.

Now, previously, when for example I wanted to loop through each row and display the textual meaning of each of the values I would either use a switch statement or a big if-else statement block. Now though I make use of a much simpler method…

1
2
3
4
5
6
7
8
9
function number_state($state = 0, $labels = array())
{
	$text = $labels[$state];
 
	if($text == "")
		$text = "Unknown";
 
	return $text;
}

This function simply takes two parameters. The first is the number itself; the second is an array of the corresponding value meanings. To use it just do this…

1
echo number_state(1, array("State zero", "State one", "State two", "State three"));

Or, in a simple loop…

1
2
3
4
for($i = 0; $i <= 3; $i++)
{
	echo number_state($i, array("State zero", "State one", "State two", "State three"));
}

It’s a nice and simple solution to a simple problem. From my perspective it is much better having something like this compared to big chunks of code doing the same thing.

15Blog Action Day

Blog Action Day

Today, the 15th of October is the annual event of the one and only, Blog Action Day. Blog Action Day, or BAD, is primarily a web based community driven event where hundreds of web sites owners write about one particular topic with the aim of raising awareness. With thousands and thousands of web sites pledging to post today, millions of readers from over 140 countries will find out a great deal more about this years topic of climate change.

I just thought I would write this post to try to not only raise awareness of this years topic but mainly to let you know about BAD and perhaps, if you have a web site, encourage you to join in and help the cause.

11How to use bookmarklets

How to use bookmarklets

BookmarkletI’ve just added a whole bunch of tweaks to my URL shortening site, Shrten. Some of the changes are visual though some are under the hood making the site easier to use and overall much, much better. But this post isn’t about that; it is instead about bookmarklets and how you can use them on your own site.

On Shrten you can now drag a link into your browsers toolbar and then when clicked it will instantly create you a shorter url for the page you are currently viewing.

This is the first time I’ve ever used a bookmarklet on any of my sites and I have to say that for apps and services such as URL shorteners it works fantastically! So, how can you do it?

It’s quite simple to be honest and consists of just a single link with a tiny bit of JavaScript. Take a look at this:

1
<a href="javascript:void(location.href='http://shrten.com/url/'+location.href)">Shrten</a>

The little snippet above is the exact bit of code I’m using on my site. Basically, when clicked it will redirect the user to http://shrten.com/x where x is the url of the current page the user is viewing. This can be put to all sorts of uses and I definitely recommend that you should take a look at it. It’s easy to implement and even easier to use!

10Say goodbye to the calendar

Say goodbye to the calendar

WordPress CalendarOver the last couple of days and hopefully over the next couple of weeks I’ll be tweaking this site to make it that little bit better. This ranges from perfecting my permalink structure to dropping in some features and extras to help make browsing this site more enjoyable. One of the things which I done very early on when I was developing the theme to this site was to remove the WordPress calendar. I think you should do the same!

As long as your blog posts are not strictly tied to specific dates then ask yourself, do you actually need the WordPress calendar in your sidebar? To begin with, it usually looks terrible (it can be tricky to style) but it also serves no real purpose to your readers. Look at it from the readers perspective and ask yourself how many times have you ever used the calendar on someone else’s site to find what you’re looking for. Whilst some of you may be able to say ‘once or twice’ it really isn’t worth taking up all that space in your side bar when only a handful of people use it.

If people want something they will most likely make use of the search feature so I really don’t see why the calendar should be there. Keep your theme uncluttered and free from unnecessary bits like this.

9Password algorithms

Password algorithms

Password algorithmI’ve just read a post by Daniel over at Daily Blog Tips entitled “Develop an Algorithm for Your Online Passwords and Never Forget One Again“. Now, the basic idea behind what Daniel is saying is to come up with some sort of algorithm which you can then use to securely create the passwords which you would use on any sites you visit.

At first glance I think that this is a fantastic idea. Provided that your password algorithm is unique enough and can be remembered (and applied) easily then it could be a great solution to both generating new passwords and retrieving existing passwords. But I see one problem with the password algorithm approach: logic.

Whilst having a password algorithm is something which would in some cases make it easier for you to create and remember passwords it also introduces a logical way of working them out. Sure, in order to know the password you’d have to firstly know the algorithm but this really just brings us back to the original problem. The whole reason for having a password is so that only people who know it can access the account – so in other words, your primary aim is to keep the password a secret. Using an algorithm approach, all you’re really doing is replacing the password with a method; you still have the same priority of keeping it a secret only this time it’s not just a single password for a specific site but potentially the key to unlocking all of your passwords.

So, to sum it up, what would you prefer? Would you prefer to disclose a single password for a single account or the algorithm to every password you have? For me the choice is clear – the more random, abstract and obscure, the better and more secure the password is.

8Should you use the WWW?

Should you use the WWW?

301 .htaccess RedirectYou may or may not know that when accessing a web site you usually have the choice of typing in http://www.domain.com or just http://domain.com -the difference is of course whether or not you include the www. Both of these will normally bring you to the exact same web site with no cosmetic differences what so ever.

The truth is that although including or excluding the www in a url makes absolutely no difference to the end user it can have a huge impact when it comes to search engines. For example, Google and Yahoo will treat both the http://www.domain.com and http://domain.com addresses as two completely different sites. So what does this mean? Well it means several things one of which is duplicate content. The search engines will see that both sites (although its the same site) have the same content and will therefore most likely exclude one from the search engines. With regards to Google PageRank your site will also be trated as two different sites each one having its own pagerank values assigned to it.

The fix is easy! Firstly decide whether you want to use the www version or the non-www version. To be honest it doesn’t really matter which one you use as long as you use just one of them. Then, you can either use some sort of 301 redirection or add one of these snippets of code into your .htaccess file.

Removing the www

1
2
3
RewriteEngine On 
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

Forcing the www

1
2
3
RewriteEngine On 
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

Of course in the examples above make sure you replace “domain.com” with whatever your actual domain is. This topic has been further explained – read Remove the “www” from your URLs for more information.