Smart "Back" Button for Wordpress posts/pages

While coding a Wordpress site, I wanted to add a back button for posts and pages.
Hierarchical pages should obviously point back to their parents, but what of non hierarchical pages?

If a user navigated from the "Gallery" page to the "About" page - I would like the sites "back" button to return him to the "Gallery" page. This could be easily implemented using JavaScript but why use user-side scripting when you can generate the code on the server side?

The obvious solution would be to use the referring URL as a target for our "back" button. We must now avoid two special cases:

  1. The page is a sub-page and the back button should point to its parent.
  2. The previous URL was an off-site URL, and the back button should not appear at all.
This code snippet solves both problems: if the post is non-hierarchical, the referring URL is checked - if no URL is provided, or if the URL is off-site, no "back" button is displayed.
$ref_url = wp_get_referer();
$ref_parse = parse_url($ref_url);
$my_parse = parse_url(get_permalink());
if (($ref_url==get_permalink() || empty($ref_url)) && $post->post_parent) {
 $ref_url = get_permalink($post->post_parent);
if ($ref_parse[host]==$my_parse[host] || $show_back_to_parent) { 
 echo $ref_url;

When transmission-daemon settings won't update

The transmission-daemon wiki instructs users to edit settings.json at
But you may find that editing that file has no effect on your daemon. In such cases, you might want to try the following:
1. Stop the daemon (sudo may be required)
/etc/init.d/transmission-daemon stop
2. Edit the settings.json file found at:
3. Restart the daemon
/etc/init.d/transmission-daemon stop

If that doesn't work, you may want to look for the settings file here as well:

This solution by elico of the Ubuntu Forums ended hours of frustration caused by useless edits to the settings.json file in my home directory. I hope you find it helpful as well.

How Dropbox saved me from an SSD faliure

I've long held that laptops are an inherently unsafe place for your data. Laptops can be stolen or lost, HDDs are prone to damage due to frequent transportation and of course:  laptops tend to be used in dangerous places and are consequentially prone to drops and liquid spills.

About two months ago I figured I'd remove one risk factor from the equation, and got myself a spankin' new SanDisk SSD (the 60GB 'Ultra' model). Unfortunately, that disk just died without warning this morning.

While that SSD contained several academic assignments due in mere days as well as the images from my latest commercial photo-shoot, you might expect to find me up a certain creek without a paddle.

Fortunately, I was well prepared for such occurrence:
All my critical data, including my image catalog reside within my Dropbox folder. This reduces my risk of data loss - as I can only lose un-synced files.
Since I rarely venture too far from a high-speed internet connection it's unlikely that I'd lose more than a days work. In this case, I lost nothing (excluding possibly some saved StarCraft II replays).

Backup is actually a secondary function of my Dropbox setup, the main perk is immediate synchronization with my desktop. By the time I get home, my lecture notes are already on my desktop. I can spend a weekend away from home, work on my projects, and return to my desktop without ever worrying about merging file revisions.

A convenient smartphone app even allows me to send out links to my Dropbox files on the go. This is very handy for sending out a resume at a moments notice or submitting a paper at the last minute.

Dropbox only comes with 2GB of free space, which would usually cover any schoolwork you might have but hardly a photography catalog. You can get more space by refereeing customers to the service (you'll notice my deviously placed referral code in the previous links), or pay for 50-100GB plans.

I manage just fine with a free Dropbox account and some referral awarded space. If you need more, Google Drive, Apple iCloud and *shudder* Microsoft SkyDrive offer similar services. Depending on your needs, you may find one suites you better than the other. Engadget has a nice comparison article up here. Note that Dropbox is the only provider that allows you to earn extra free space.

If you are unfortunate enough to be using a laptop as your main computing platform - you should consider CrashPlan as a backup solution. They offer unlimited backup plans for about $50/yr. which is much  cheaper than the above mentioned services and well worth the price if you can do without folder syncing.

I use CrashPlan to backup my desktop(s), and since my Dropbox folder syncs to my main desktop - it is automatically backed up with CrashPlan as well!

As for SanDisk - I'll be replacing the drive under warranty. I hope the next one lasts longer...

Slim down your bloated Starcraft II installation.

Having recently replaced my laptops spacious 250GB HDD with a measly 60GB SSD, it became hard to justify wasting 10GB of space just so I could play an occasional game on

Opening up my SC2 directory, I found approximately 5GB of files under the "Campaigns" folder, and an extra GB of files under the "Versions" folder.

Having already finished the campaign, I began to wonder if I really need these extra 6GB of game files...

WARNING! removing files from your SC2 directory may mess up your installation, erase saved games, replays and possibly cause severe bodily harm (though the latter is VERY unlikely). Also, note that the Blizzard support staff explicitly stated that you should not delete any game file in this forum post - attempt at your own risk!

That said, I've found that you can delete the two folders under the "Campaigns" directory, as well as all but the latest (highest number) "Base#####" and "Shared####" folders under the "Versions" folder.

I'm told that deleting the old "Base" and "Shared" folders will prevent you from viewing old replays, so you might want to keep them around, since they don't take up that much space.

Withe these files removed, my SC2 installation takes up less than 4GB of space, and I can still play multiplayer games on without issues.