Skip to main content
 

Creating a Wordpress redirection page

This is the simplest way to add a page redirection feature to your WordPress theme.

First, create a new theme file called redirect.php with the following contents:

<?php
/*
Template Name: Redirect
*/
the_post();
header('Location: ' . get_the_content());
die();

To create a new redirection page:

  1. New page, change the template to 'Redirect'
  2. Switch to HTML editing mode and put the url in the content area.

 

Release 1.1 - wordpress-basetheme

The aim for wordpress-basetheme is  a bare bones, well structured, easily customisable WordPress base theme.

You can build on it to speed up your own theme development. It's so minimal that I wouldn't recommend it as your final site theme. Instead it makes it trivial to apply your design to a WordPress blog, or to build out from this starting point. This site is build on top of the project for example.

Version 1.1 is now available
Download | View on GitHub

Changes:

  • updated styling and version
  • previous next buttons on singles
  • ie style targeting (unused), remove admin bar until supported, top nav
  • archives added and accessibility improvement
  • date permalinks
  • consistent titling
  • edit link in footer, no home
  • moved comments into its own template file
  • padding issue

Your feedback is welcome.

 

Wordpress Base Theme

I've released a first look at "Wordpress Base Theme", a bare bones base for your own themes:

  • DRY
  • KISS
  • easily customisable WordPress base theme.

You can build on this to speed up your own theme development.

 

DisplayAnything3

DisplayAnything3 is a file and image gallery module for SilverStripe 3.0 with a big list of features. I'm looking forward to trying the module on a future project.

 

Clear writing

The best way to write a clear blog post is to paste your draft into a text-to-speech engine such as tts-api.com and listen to the output. If you can't easily understand what is said then that will most likely indicate problems with your sentence structure.

 

When Get-ADUser does not return the complete user

When writing a Powershell script that checks for changes to Active Directory users, you may find that all users change every time you run the script. One explanation for seeing this behaviour is because Get-ADUser does not return all the fields. A field that is not returned can never be equal to a string value.

For example, let's consider the following code:

$csv_file  = "users.csv"
Import-Csv $csv_file | ForEach-Object { 
    $username = $_.USERNAME
    $ad_user = (Get-ADUser -filter {sAMAccountName -eq $username})
    if (!$ad_user) {
        # create account, it does not exist
    } 
    else {
        $filter_accountchanged = { $ad_user.DisplayName -cne $displayname }         
        if ($ad_user | Where $filter_accountchanged) {
            # update existing accounts with changes 
        }
        else {
            # account exists and has not changed
        }
    }
}

You will find that all existing accounts come up as having changed. This is because $user.DisplayName is not returned by Get-ADUser.

The issue is resolved by asking Get-ADUser to return all properties:

$ad_user = (Get-ADUser -filter {sAMAccountName -eq $username} -Properties * )

Now all properties are returned, and the "account change" filter works as expected.

 

SilverStripe Gists

I've released the following data extensions (might pack them up as modules):

  • HiddenFields DataExtension: Takes form fields specified through $hidden_fields and hides them from edit form. View code
  • Description DataExtension: Specify a $db_descriptions array to DataObjects to attach formfield descriptions. View code

 

Windows 8 a catastrophe for Games?

Interesting article by Tom Phillips interviewing developers about Windows 8 and it's closed Windows Store, with this gem of a quote from Introversions' Chris Delay:

"I really don't want to see the PC becoming a closed platform. Microsoft is not a company that's able to benignly oversee that process. They will f*** it up. We'll all be doing Kinect support and 16 language versions, we'll all be supporting a Microsoft Office plug-in. It's my own worst nightmare.

[...] “The PC continues to be as relevant as it was ten years ago, despite consoles coming and going, because it is an open platform. If that changed it would be terrible.”

It's interesting times for the gaming industry, indeed.

 

OptimisticLocking SilverStripe Module Release

Some of you might be interested in my first ss module: silverstripe-optimisticlocking

This is a very simple module that prevents your site users from losing data. It works by by blocking the save process if the record changed since it was retrieved, preventing accidental overwrites. (user1 starts editing, user 2 starts editing, user1 saves, now user2 can't overwrite user1's changes). By default, Silverstripe lets you lose data by overwriting the record on save.

You might know that Pages benefit from versioning (so you can restore to a previous version), however by default DataObjects don't have versioning enabled so this module will come in handy then (AFAIK it's not trivial to enable either).

If feedback is good, I will try to add it to the SilverStripe modules list.

 

Carbon Powershell support is here!

I have been working with Carbon over the last weeks and one thing I noticed was that having to navigate through the admin menu repeatedly was getting a bit long in the tooth. Sure, for the occasional admin task it's useful to have the admin close to the site itself.

After adding deployment through powershell it became clear that switching between admin and commandline is not ideal either. So I decided to implement all administration throughu the powershell script.

With 0.2.3 you can add the following parameters to the script:

  • login: login to admin
  • draft: create draft
  • generate: generate static site
  • deploy: deploy to live
  • clear_cache: empty cache

The script will also tell you the correct syntax if you get it wrong. Happy carbonating!

 

Carbon 0.2.3 Released

I've released another version of Carbon, the framework powering this website. It's really a refinement and bugfix release, with the following changes:

  • config: Admin password now needs to be manually enabled
  • cache: Correctly generate htaccess
  • deployment: only replace hostnames in text files
  • cache: only write cache when caching is enabled.
  • theme: remove older articles link (non functional)
  • deployment: new feature - replace hostname from a to b before deploying cached site

Releases are available via github by clicking on tags.

Screencast

To celebrate the new release, I've also recorded another screencast (list of screencasts). In Screencast #4, we create a new post using the admin interface; use the generate site feature to create a full static cache; and finally run the powershell deployment script to deploy to my host over sftp.

All in under 2 minutes!

 

PHP 5.5 drops support for Windows XP / Server 2003

PHP 5.5 will no longer support Windows XP and 2003. Those systems are around a decade old, so PHP is pulling the plug on them.

It was already mentioned on the PHP 5.4 release changelog. It makes sense, but I’m sure it will cause some issues with organisations who have not been paying attention. I would encourage all developers to sign up for the PHP Announcements mailinglist.

 

Modern technology

Today’s experience of trying to watch the formula 1 race at Silverstone was a frustration of modern technology and drm issues:

  • the Virgin media box only recorded the first hour of the BBC Broadcast. Disappointed.
  • I then navigated to the Virgin media version of BBC iPlayer. However it does not list Formula 1 races, due to licensing restrictions. sigh annoying.
  • I loaded up the iPhone version of the BBC iPlayer. It has the race but it visually it looks like an amateur YouTube video. Connecting it to the HDTV with the Av cable might tell the app to switch to an Hd stream, but alas the picture is twice as muddy. Frustrating.
  • Booted up the laptop to view the web version, which is as blurry as the iPhone version. Let’s download it perhaps it’s higher quality? Hopeful.
  • iPlayer desktop is installed then crashes. Typical.
  • Adobe Air wants to be updated which happens as the programming preventing the update just crashed. Really?
  • iPlayer desktop loads but does not let you browse any shows. Losing interest fast.
  • Downloading Formula one British Gran… 2.3Gb this is looking good. No streaming? I’ll start watching on the iPhone in the meantime. Tolerating.
  • 11 minutes later the abbreviated title expands to ’d prix qualifying’. Getting pissed.
  • downloading the actual grand prix. Watching more on the iPhone. Maybe this is as good as it gets?
  • connecting the laptop over HDMI. Download is finished! Turns out visuals are better but framerate is choppy. Can’t be arsed anymore. I’ll watch it on the laptop.

Does it have to be this hard, Virgin, BBC, Acer, Toshiba, Apple?

 

Fixing Samba network-share change notifications

Today a problem came up where the files on my Samba fileshare did not indicate to my Windows system that they were changed. Software that relies on this information such as TortoiseHG and SimpleLESS would not know that the file had changed. This was especially obvious with SimpleLESS which should take the .less file and process it, but wouldn’t.

It turns out that the cause of this is that on the linux system the system time was off by a large margin. Using Arbab Nazar’s article on setting up time synchronization fixed the issue and prevents it from reoccurring.

 

Facebook wants to be your email

Gervase Markham’s writes about the changes to your Facebook profile, where now by default a @facebook address is shown instead of your own email address:

The email instead goes to my Facebook inbox, and I don’t get a notification email to say it’s there.

So this is why Facebook introduced it: They want you to go to their site to check for email. They don’t want to send the messages to your email and have you interact there, they don’t want you to use a search engine to find content, and they don’t want you to use forums and instant messages to talk to people. They don’t want you ever to get the idea to leave the site.

 

Enable SWF files in Mahara

By default the Embedded Media Block allows you to embed FLV and MP3 files into your pages. However Mahara 1.5 also supports the following files:

  • AVI Video File
  • MP4 Video File
  • MPEG Movie
  • Quicktime Movie
  • SWF Flash movie
  • WMV Video File

Site administrators can enable these formats by going into Site Administration > Plugin Administration_ (under Administrator Extensions) > file/internalmedia (under Plugin type: blocktype) > Config. Then simply tick the file types you want to enable for users.

 

Setting up a VM based development system - Part 1

I recently set up a local development server running Ubuntu on VMware player. I thought it would be interesting to document the process and instructions so that it will be useful to others, and you can follow along / correct / improve this guide. On completion of this series you will end up with a complete LAMP local development system..

Installing Ubuntu

You will need:

Install VMware player (VMP). Restart the pc if necessary.

I’m installing the virtual machine on my USB harddisk, this way I can take my whole development with me on the go (home/work) - this is great because you only have to set all this up once, instead of on every machine you plan to use it on.

Start VMP and “Create a New Virtual Machine” and browse to the downloaded .iso. As part of the Easy Install Information write down the login:

username: __________ password: __________ 

Store the VM on your removable drive.

On the Specify Disk Capacity screen you will want to go higher than the recommended disk size, I chose double (40GB). Make sure you have enough free space available, check this before continueing. I went for double the recommended amount as I want to avoid to repartition later. Accept the other defaults and Ubuntu will start. Keep waiting as Easy Install is installing Ubuntu on your behalf.

If you are a chmod 777 user (jackpot settings), this is a great time to read up on file system permissions by reading the article series starting with “Linux File Permission Concepts” (click next in the summary, there are 5 articles in total): http://articles.slicehost.com/2010/7/17/linux-file-permission-concepts

After a restart the login screen appear and after a successful login you will see the desktop. Because we are going to install a bunch of software let’s make sure everything we already have is up to date. Start the update manager > Settings > Ubuntu Software > Other > Select Best Server. This will speed up downloads. Check again and install updates.

Time to read some more, btw have you created a new tag for all these bookmarks yet? When you are finished reading the above articles, here are some really good resources to read later:

You should now have a running Ubuntu system.

(Source: donationcoder.com)

 

Silicon Knights: "used games are cannibalising the industry"

Silicon Knights boss Denis Dyack talks about used games effect on development budgets:

"I don't think as an industry we can afford $300 million budgets. Some games can, don't get me wrong - for a game like Call of Duty, if they had a $100 million budget, or whatever their budget is, they can afford it. That's not the industry, that's sort of a one-off.

Perhaps there is a point after which it makes little sense to spend more money as you simply cannot recoup it in the market. I'm guessing this limit is probably closer to $0 than $300 million.

source Gamesindustry International.

 

I Won The Windows Phone Challenge, But Lost 'Just Because'

This sounds like a situation where I hope some rep from Microsoft will intervene and offer the guy his reward.

via I Won The Windows Phone Challenge, But Lost “Just Because”

 

Piratepad Beta

This is a online document creation tool that you can work on in realtime with other people with chat. Good for notes and documentation or getting feedback where the other party can make amendments in realtime. (click frog to start)

via Piratepad Beta