Technology, life, programming, travel and money.

Archive for July, 2008

AdSense Injection WordPress plugin tweaks

On this blog I use the AdSense Injection plugin (update: this plugin no longer seems to be available) to automatically add Google's targeted AdSense adverts to my posts. The plugin is excellent and has helped to make more money for this site but there are a few tweaks that I have done. First, I've made a modification so that if a individual [...]

Adding ‘Related Posts’ to WordPress articles and 404 error pages

Many blogs have a list of related articles after each of their posts. I wanted something similar for my WordPress blog but found it wasn't as easy to do as I thought it would be. At the same time I was interested in capturing any access attempts to non-existent pages (causing a 404 error), and showing a list of suggested links. This is [...]

Reverse a linked list – C++ source code

Reversing a linked list is a simple programming problem, which is often a interview question. In this case I'm referring to a singly linked list. I'll provide the C++ solution and the C++ test code. One of the easiest ways to reverse the list is to create a new head pointer, iterate through the list removing each item in turn and then inserting [...]

Dijkstra’s Algorithm code in C++

Dijkstra’s Algorithm code in C++

Dijkstra's algorithm is a famous algorithm that calculates the routes and distances from a start node to all other nodes in a connected graph where all the distances are positive. Here is a version which I wrote in C++. My aim here was to try to create a version that was easy to read, rather than the most efficient version. This version is [...]

Overheating noisy laptop problem

Overheating noisy laptop problem

Recently my laptop fan has been staying on longer and longer. It was making the laptop sound like a plane almost constantly. As well as the noise my laptop has been getting very hot. And it has been experiencing sudden shutdowns. I could be typing something and then it would shut off with no warning. If this sounds familiar to you, then like me [...]

Select 100 random values from a stream / linked list

Select 100 random values from a stream / linked list

Here's an interesting puzzle / interview question that I heard recently. Problem You have a either a linked list or a stream containing int values. You don't know how large the stream / linked list except that it contains 100 or more values. You need to write a method that selects 100 random values from the stream. You have to write the [...]

Friend Quotes – My first Facebook ‘app’

A few weeks ago I finished my first Facebook 'app'... Well, 'app' is too grand a word. All it does it display a random selection of your friend's quotes on your Facebook profile page. I wrote it just to see how easy it was to make a very simple Facebook extension. As it turns out it was very easy. Everything you need is on their official [...]