The Mighty Text File

Don’t get me wrong, databases are cool. As a PHP programmer and web developer, I use relational databases every day, and for complex data sets, searching or sorting, nothing is better. The problem is that as soon as you are using a database, no matter how small, you suddenly have a whole bunch of extra overhead. You need to have a database server, write SQL queries, optimize results, and (my least favorite) build some sort of admin interface to actually add/remove/edit the data. If you are just doing a simple project, all this seems like a lot of work for a very small result. Enter the text file.

For many purposes, storing the data in a flat text file can be just as effective as a full database, and it is so much quicker and easier to work with. Want to add an item? Open the text file up in Notepad and add it in. Same for removing and editing. No muss, no fuss, no admin interface needed. For the first 3 years or so, this is how operated. The one downside of using a text file for this kind of project is that is can be a little tricky to read back in a useful way, my first text file base projects had a lot of file[0].” “.file[2]. Which works fine, but is a little opaque if you don’t know the exact format of the text file.

To solve this problem, I wrote the following handy little function and have used it in a bunch of projects since:


function parse_data_file($path,$delim='|'){
	$items = file($path);
	$headers = array_shift($items);
	$headers = explode($delim,trim($headers));

	$out = array();

	foreach($items as $row => $item){
		$item_array = explode($delim,trim($item));
		foreach($item_array as $col => $field){
			$out[$row][$headers[$col]] = $field;
	return $out;


When given the path to a text file, this function returns all the data in an associative array with the column names based on the first line of the text file.

For example, given the following text file:


The function would return the following array:

array {
	[0] => array {
		[first_name] => Bob
		[last_name] => Fredson
		[phone] => 5551235678
		[fax] => 5551235678
	[1] => array {
		[first_name] => Fred
		[last_name] => Johnosn
		[phone] => 5551875678
		[fax] => 5551274678
	[2] => array {
		[first_name] => John
		[last_name] => Bobson
		[phone] => 5551231178
		[fax] => 5551234445

Note: The function defaults to the pipe character, “|”, as a delimiter. I chose this character because it will probably never come up in the data and it also looks as much like a seperator as possible. If you want to use a different delimiter (“;” or “#”, for example) just pass it as the second parameter.


As everyone should remember, way back in 2005, there was a lot of controversy about GTA3 San Andreas and the whole Hot Coffee mod thing. Just to remind you, this was a downloadable hack for the PC version of GTA3:SA that allowed players to access a ridiculously tame “having sex” mini game when one of your in-game girlfriends invited you in for coffee. I don’t know if there was ever an official statement from Rockstar, but it was obviously something that they experimented with in the development process and then rightly decided to drop because it was a horrible idea, completely unnecessary, and needlessly offensive. To be clear, the mini game was not accessible in the game in any way, no cheat codes or game glitches would ever allow you to see it. The only way was to go out and download this special patch that modified the game and added it in. Despite this, various advocacy groups (including Jack Thompson and  Hillary Clinton) lost their shit and forced to the ESRB to reclassify the game as Adult Only, which caused Walmart, Target, Best Buy and many others to pull it from their shelves.

This got me thinking: if a game has to be responsible for everything hackers can do to it, why not other pieces of software? Microsoft Office is the obvious example, as it is installed an pretty much everyone’s computer already and is in daily use by millions of people around the world. What if some malicious “hacker” (eg. me) were to make a “mod” that added naked tits to the previously wholesome MS Office assistant? Would Microsoft have to recall the program and make it only purchasable in seedy back alleys? After all, think of the children!

So, for your enjoyment, I present my new MS Office assistant:

Installation instructions:

  1. Download above
  2. Unzip file. You should have nude.asc
  3. Move nude.acs into C:/WINDOWS/MSAGENT/CHARS
    or C:/WINNT/MSAGENT/CHARS folder, depending on your operating system.
  4. Launch MS Word (or any other Office program)
  5. Go to Help > Microsoft Word Help (or push F1)
  6. Right click on the Office Assistant that pops up, click on Choose Assistant…
  7. Click the Next button until you see the tits
  8. Click OK
  9. Complain to your local parental advisory committee

NOTE: This is only tested on Office XP for Windows XP, YMMV.

If you can’t get it to work, I have included a screen shot after the jump (NSFW, obviously)

Continued reading >

PowerPoint Bulk Image Import

PowerPoint sucks. I don’t think there is much of an arguement about that. It is slow, bloated and difficult to use and even when you do get it working, the presentations tend to be somewhat lacking. Nevertheless, it has become the defacto standard (much like Word and Excel) and it is pretty much unavoidable in the business world.

A few years ago, I was working full time as tech support and graphic designer for a company whose boss gave a lot of presentations.  Coming from a background of transparencies and slide projectors, most of her presentations were composed of lots and lots of full frame images. It often fell to me to import all these images into the PowerPoint presentation, a process that consisted of creating a new slide, inserting the image on to the slide, sizeing it to fit and centering it. Repeat until dead. I knew there had to be a better way, but the few bulk import plugins I found online were 1) commercial and 2) windows only. It didn’t seem like it should be that hard a problem, so I set about trying to automate the process myself using Applescript. It turned out to be a little more complicated then I thought, necessitating a crash course in Visual Basic for Applications and way to much digging around in Microsoft developer documentation, but I am pretty happy with the end result.

I figured other people might be in the same boat, so I have cleaned it up a little and am posting it here for your downloading pleasure.

PowerPoint Bulk Image Import [zip]

Usage Instructions:

  1. Unzip file (you should have an Applescript executable called PowerPoint Bulk Image Import)
  2. Launch PowerPoint
  3. Launch PowerPoint Bulk Image Import
  4. Choose the folder containing all your images
  5. The script will make a new PowerPoint presentation and import all the images, one on each slide
  6. Now that you have a bunch of spare time, go watch the latest video over on


  • Mac OS 10.3 or higher
  • Microsoft PowerPoint X or higher (tested with PowerPoint X and 11)

One really cool use of this script that I realized afterwards is in compressing an overly large presentation. Depending on your computer, PowerPoint tends to crap out when presentations get over 300 MB or so. It will crash more often and every slide will take much longer to load. Since PowerPoint for Mac (at least every version I have used) does not have a way to downsample images to the slide resolution, loading up a couple of hundred high res jpgs can quickly put you over this limit. I cool trick I have found is to set the presentation up how you want it and then go to Save as… and save it as a series of jpegs at whatever resolution you are showing the presentation. You will now have a folder full of downsampled jpegs at the perfect resultion. Use the bulk Import script the re-import all the images into a new presentation and you should have saved a lot of space. Using this technique, I have turned a 500MB presentation into a 75MB presentation without any oss of quality when projected.

Disaster Movie Re-Cut

Six months ago I wrote a script for LoadingReadyRun called “Movie” Movies Movie, the video is a parody of the horrible “spoof” films by Jason Friedberg and Aaron Seltzer. In order to write the script, I actually sat through Meet the Spartans (with a heavy hand on the fast forward button) and I confess that I have had a morbid fascination with their movies ever since. As a comedy writer, I find it is almost worth seeing the absolute worst that the genre can produce, just so I know what to avoid. What I really find interesting, though, are the brief glimpses of genuinely half decent comedy that will occasionally surface. Maybe there is a third, uncredited writer that manages to sneak some comedy into the script while Friedberg and Seltzer are at lunch, but I choose to believe that deep down inside one or both of these talentless hacks, a tiny sliver remains of a young, idealistic, comedy writer who just wants to make it big in Hollywood. They have tried to crush him, time and time again, replacing satire and parody with sloppy references and repetition, but yet, every once in a while, this inner comedian will give a tiny flutter, like a poor baby bird with a broken wing, causing them to snap out of their self induced coma and write an actual joke.

As an exercise, I thought it would be interesting to take their latest masterpiece, Disaster Movie, and edit it down to just all the funny bits. Unsurprisingly, this resulted in a very short film. Rather then just show a bunch of clips, though, I had the idea that maybe I could re-edit the film in such a way as to preserve some semblance of a story while hitting all the actual jokes. The end result is a little choppy, but I think it worked pretty well. My new 8 minute, 38 secs long version has pretty much the same plot as the original, but in theory should have at least 10x the humour density.

WARNING: This is in no way an endorsement of Disaster Movie. If you enjoy the re-cut version, feel secure in the knowledge that you have seen every even remotely funny bit of the film. Do not rent the movie from your local video store. I have suffered the pain of watching it so that you don’t have to.

Get the Flash Player to see this player.

If you are curious as to what was cut out, check out this detailed spolier at