Posts Tagged ‘source code’
DOS: Get the directory name from a file path
If you need to write a DOS batch file that takes a file path as an input parameter and needs to do something to other files in the same directory as the input file then you’ll find there is no easy way to get the file’s directory name into a variable. You could pass in the directory name as a separate parameter but that seems like [...]
Writing WordPress posts offline in Word with the help of VBA macros
If you want to write your WordPress posts offline (i.e. in a separate editor to the WordPress editor), then you may find you have to spend a fair bit of time reformatting the blog post to add any required WordPress formatting before you can publish. There are lots of reasons for wanting to write your WordPress blog posts offline. You may not [...]
Triangle Identification – C++ solution and test code
Here is another interview coding question that I have heard of. You have to write a function to identify the triangle type. You have to return a number between 1 or 4 to identify either a valid triangle type or an error. The solution is very simple requiring only one condensed line of code to identify each triangle type. Two lines of code [...]
Reverse the words in a sentence – C++ solution and test code
Here is a solution to the standard interview questions of reversing the letters in the words of a sentence. It is a more complex version of the even more common "reverse a string" question. I also include my test code. There are two main parts to this. The first identifies where the word boundaries are. The second reverses the letters between [...]
Picking the 5th from last element in a singly linked list
Here's another of those fun coding interview puzzles. The kind that companies like Microsoft or Google might ask you. Given a singly linked list, select the 5th from last element. I'm writing the solution in C++ but the solution in Java would be almost identical. I'm also putting up my test code. The restrictions are - you can only make one [...]
Batch processing photos with DOS and ImageMagick
For my recent walking project I knew I was going to be taking lots of photos. I wanted a DOS script which would batch process the JPEG photos from my camera into the 'full sized images' (which are much smaller than the raw camera images), and the poloroid-like thumbnails. The excellent ImageMagick tool provides a way to generate poloroid-like [...]
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 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 [...]









