Archive for September, 2009

Learning Event Generator

September 26th, 2009

The learning event generator is something which I was shown on the first day of my PGCE. It was demonstrated and was intriguing to say the least! It would be an interesting way to allow the children we teach to decide their own activities.

I have been in a coding mood today so thought that I would bash together a tiny little PHP script to emulate the same thing. Yes it’s basic but works from two text files which are defined in the first few lines of the file itself. It’s not the most elegant bit of code I have ever written but if you know anything about PHP or have a web server then why not have a fiddle and see what you can make it do?

Consider this… it doesn’t have to be learning events. Why not use it as a kind of ‘What shall we do tomorrow?’ kind of thing. eg: ‘Do a 5 mile run with a friend dressed as a horse’ or ‘Do go out and get a bit merry’.

The Code

<?php

$cwd = getcwd();
$outcome_source = $cwd . '/' . 'activities.txt';
$method_source = $cwd . '/' . 'methods.txt';

$outcomes = file($outcome_source);
$methods = file($method_source);

$outcome = trim($outcomes[array_rand($outcomes)]);
$method = trim($methods[array_rand($methods)]);

echo 'Do ' . $outcome . ' as a ' . $method . '.';

?>

The Download

The file is available as a download here: Learning Event Generator (1.23 kB)

References

The original idea is available on the following website and is credited to John Davitt

PHP File Rename Script

September 26th, 2009

Ever downloaded an archive of files and all of them had file names about 200 characters wrong with the same string in each? It’s more common that you might think… If you look at any audio archives you may have acquired, the chances are that the file names will have the quality in it (192 or 128 etc..). Additionally if you have video files the resolution or quality might be present.

I, for one, don’t really care what the quality is in the file name and would prefer it to be readable. I spend a lot of time removing this extraneous data so decided to make a short PHP script to remove certain strings on mass.

See the following code which can be run from the command line using the following format:

php -f <filename> <text_to_remove> [int live_mode=0]

Code

#!/usr/bin/php

  [int live_mode=0]';
    exit;
} else {
    $remove = $argv[1];
}

$live_mode = (int)$argv[2];

if ($dir = scandir($cwd)) {
    foreach ($dir as $file) {
        $path = $cwd . '/' . $file;

        if (!in_array($file, $ignore)) {
            if (!is_link($path) && !is_dir($path)) {
                if (strpos($file, $remove) !== false && $file != $_SERVER['SCRIPT_FILENAME'] && $file != $remove) {
                    $output .= 'Renamed "' . $path . '" to "' . $cwd . '/' . trim(str_replace($remove, '', $file)) . '"' . "\n";

                    if ($live_mode) {
                        $new_path = $cwd . '/' . trim(str_replace($remove, '', $file));
                        rename($path, $new_path);
                    }
                }
            }
        }
    }

    if ($output) {
        $output = ($live_mode ? 'LIVE':'TEST') . ' MODE' . "\n\n" . 'Text to remove from filenames was "' . $remove . '"' . "\n\n" . $output;
    } else {
        $output = 'There were no matches by your criteria: "' . $remove . '"';
    }    

    echo $output . "\n\n";
}

?>

Download

To download the code in file form click the following link: File Rename Script (783 bytes)

Think Visibility 2, It’s all over (for now)

September 13th, 2009

Well, although I generally don’t do plugs I stepped out of my norm in my last post to advertise Think Visibility 2 so it seems only fair to let you know how it went.

Firstly a real well done to The Hodge for organising such a fantastic event. The quality of speaker and diversity in the talks made for a really interesting day. My only wish was that there would have been more time and more speakers. Not a criticism really but by the time you have watched one or two talks you realise you could sit there all day and absorb information from the guys that are up there doing their stuff.

I was really only there to help out however the actual delegates all seemed to be getting on well and networking with each other. It was a little sad watching a room full of grown ups (mainly men) sitting ‘playing’ on their iPhones ‘Tweeting’ through the entire thing but that is kind of expected given the nature of the event. This, however, was cleverly exploited when the delegates were asked to ‘Tweet’ in questions for the ‘panel show’ which amused everyone around the half way mark.

My personal favourite talk was on usability studies using eye tracking techniques to record the unconscious interest of the brain. It kind of confirmed that amazons site design is rubbish and that you can design sites to hide content you don’t want the user to red right in the middle of the screen. There were also numerous WordPress talks which proved interesting indeed. Joost De Valk for one, although not the most inspirational speaker, had some good ideas to talk about and plans for great things to come.

To conclude briefly a great time was had by all, friends were made, business cards exchanged and geeky (and some non geeky) brains were picked. So thanks once again to Dom for organising the event and all the speakers/delegates for making it such a good event. I imagine everyone is now really looking forward (and saving up for) Think Visibility 3 which I beleive is in March 2010 (keep an eye on The Hodges site for more info).