Running PHP 5.2 and PHP 5.3 on OSX

With the release of Snow Leopard Mac users have been provided with version 5.3 of PHP already installed and are one commented line away from running it with Apache. Upon installing Snow Leopard I thought "great! shiny new things!", then discovered all my projects down and out from all the shiny goodness. So I needed to get my PHP 5.2 working again. Back on Leopard I'd been using the Entropy PHP package created by Marc Liyange since it comes with all the extensions I needed. Now I didn't want to lose PHP 5.3 as I'd like to play around in it when I have some more spare time. So the ideal situation would be to have both installed and be able to switch between them with as little as an Apache restart.


My current situation is that I'm running PHP 5.2.9 with 5.3 disabled by commenting out the php5 line in httpd.conf. Now to switch back is the hard bit. So far I've not found a nice way to switch back, mainly because I haven't had the time. At the moment if I want to switch back I remove the Entropy package by deleting the folder and uncommenting the line in httpd.conf. In theory there has to be a link between Apache and the Entropy package to make my PHP run (magic?) which hopefully it is possible to disable. As soon as I get the time I'll work out a cleaner solution.

 

EDIT: Joel Moss (who prompted me to document this in the first place) came up with a solution by wrapping one of your PHP's in a FastCGI wrapper allowing a simple change to the httpd.conf file to switch between the two versions. However the solution proposed by Mark Story seems more up my alley (I'm lazy and running a script suits that trait far better!).

 

Now I just need the time to get round to actually setting one of these up...

......................................................................................................................................................

Stacking Movie Files in XBox Media Centre

I'm the first person to admit that I have some fairly obsessive habits when it comes to making things look nice and neat, more specifically in the media files department. So while playing around with getting my Films folder all neatly into XBox Media Centre (XBMC because I'm lazy and abreviations FTW) when I found that my films in multiple files weren't stacking properly.


What is Stacking and Why Should I Want This Ambrosia of the Gods?!


For those of you unaware of this nifty little feature it lets you take those split film files you have, in formats such as Film (part 1).something and Film (part 2).something and turn them into Film.something with XBMC magic. In technical speak it literally stacks them on top of each other so you see one file instead of many based on the numbering.


Now, I prefer the format Film (1).something to all the others I've seen. I don't need to know it's a part or a disk, this is assumed by the simple action of just having the parenthesis (yes, it means brackets but I'll damned well sound fancy now I have a dictionary at my fingertips!). This of course lead to some hacking of XBMC, which as a very standard nerd I love doing because it involves hacking at something for ages to make the tiniest little change. This, as it turns out, is actually very easy. The folks over at the XBMC project let you fiddle with all sorts of things using XML files (a personal favourite of mine) to control various eccentricities of your media centre. They also document stuff, so I love them, big time. While perusing here I found the advancedsettings.xml file that basically lets you do everything, even the dishes in some lovely xml tags. The tag you'll want that lets you play with stacks within this file is the <moviestacking> tag where you can place a regex filter. Below is my version for your viewing pleasure:

 

<advancedsettings>
    <moviestacking action="append">
        <regexp>()[ ]+\(([0-9a-d]+)\)(\....)$</regexp>
    </moviestacking>
</advancedsettings>

 

The append section means the rule is appended to the default XBMC rules and the advancedsettings tags are there because, well, it's the advanced settings file. Save the file in your userdata folder, restart XBMC and voila! you'll see the files that you've named in the format I (and thetvdb.org which I use as the default library for Tv Renamr) use will stack through what I can only gather is XBMC magic, or regex - which I'm reliably told involves ninjas anyway and they're practically magic. Enjoy!

......................................................................................................................................................

Tv Renamr - Finally

For the last few years I've always wanted to create a program that renamed the TV files I had into the nice neat format that I seem to spend so much of my spare time doing manually. Well, on my birthday I decided to take the plunge, stop talking about it and get my arse in gear. On that day, 22 years after my mother labouriously gave birth to me Tv Renamr was created in what I have no doubt was a far less spectular fashion than the miracle of child birth. I started off with a short script in Python with various bits taken de facto from the internet. It sort of worked, as long as your files were in the correct format to begin with, which was a pretty narrow groove for your files to be. Which of course mine weren't.

 

Fast forward to a few months later and roughly the present day...

 

After the joy of final exams and the stress of moving back in with my parents and some random hacking away at my code I've ended up with a nicely object oriented Python API that takes a few formats and gives the user a variety of ways to rename TV files. I've even had a crash course in python testing, something which has recently proved invaluable to being able to dip in and out of the project as I please. The passing in of files and information is now pretty much complete, a user can choose the series name, the season number, the episode number (if you're doing a single file) and even specify a regex expression which is always useful if like me you want to make sure your Stargate SG-1 rips are perfect. I even have tests to back up my work, which in a personal project is a first for me, but damn is it awesome to see that growl popup with a green tick. It's like a giant thumbs up!

 

Next on the agenda is customising the output. The more important part of this is letting the user specify how to deal with characters that aren't supported by their file system. While Python already deals with this, I want to give the user the choice to specify what characters they want replaced and how. Then it's onto the output format, which I'm ignoring for now, because it sounds big and I haven't even got a test file ready for it yet *eep*

 

This project has taught me a few things about myself and coding along the way - coding stuff you're really interested in is hellishly fun (I've literally lost days to this project without even noticing) and doing it in a language you've barely tried before is a massive confidence boost to your skill level.

 

The project is of course hosted on my github page at http://github.com/ghickman/tvrenamr/tree/master where you can download it or clone it to your neat little heart's content. If you find any bugs or problems, please dm/@ me on twitter (@ghickman) or contact me direct on here.

......................................................................................................................................................

A New Place for my Thoughts

Well it's taken about two years of very intermittent work but I've finally got a blog up, wewt! So this will be the focal point of my online 'presence' if you will, where I can share my thoughts and ideas and if you like them, maybe you'll carry on reading them.

 

So, what have I been up to recently. Well, my first semester third year exams have just finished which means I've had time to play around with my favourite PHP framework CakePHP again which lead me to getting the blog up and running finally. I'll be making some more updates to the site with some front end furnishings like a tag cloud but mainly back end changes so I have something nice to look at when I make a post! On top of fiddling with the blog I'll be ploughing on with the dissertation (a bug tracking system of sorts) and polishing off a website for my girlfriend.

Apart from playing with cake I'm also collaborating on a project with my friend Rich called FeedzMe; an RSS feed plugin for the python BitTorrent client Deluge. You can usually find either of us lurking at #deluge on freednode if you have questions about anything and the project itself is hosted on github.

......................................................................................................................................................