Category Archives: Coding

Copy changed files from CVS repository

While converting my cvs repositories to git I needed to copy all the changed files from my working directory into a temp directory and then into my git working dir. This was the solution that I came up with:

cvs -qn update -d 2>/dev/null | grep '^[M|\?|P] ' | awk '{print $2}' > files.list
while read file; do cp -r -f --parents "$file" /tmp/dest/; done < files.list

Basically, cvs -qn update -d does a mock update (doesn’t change files), piped to grep to only list the changed files, use awk to exclude the M, P, ? etc, output to a file.

Loop over the lines in the new file using the cp –parents to preserve directory structure

Optimized vBulletin (Part 2)

I’m just trying out a new method to optimize vBulletin’s front end scripts and CSS. It’s still a work in progress but these are the results I have seen on my test site (

Without GZIP

Base VB (v3.6.8)

vbulletin_global.js – 43.8KB
vbulletin_menu.js – 17.8KB
vbulletin_read_marker.js – 6.7KB
vbulletin_md5.js – 9.6KB

JS total – 77.9KB

css – 5.7KB

Using minify

vbulletin_global.js – 23KB
vbulletin_menu.js – 10.4KB
vbulletin_read_marker.js – 3.3KB
vbulletin_md5.js – 6KB

JS total – 42.7 (45.1% savings)

css – 4.1K (28% savings)


Base VB (v3.6.8)

vbulletin_global.js – 12.5KB
vbulletin_menu.js – 4.7KB
vbulletin_read_marker.js – 2KB
vbulletin_md5.js – 3.3KB

JS total – 22.5KB

css – 1.3KB

Using minify and GZIP

vbulletin_global.js – 6.9KB
vbulletin_menu.js – 2.7KB
vbulletin_read_marker.js – 1KB
vbulletin_md5.js – 2.1KB

JS total – 12.7KB

This is an extra 43.5% savings on top of GZIP. A total of 65.2KB (83.7%) savings from the original.

css – 1.1KB

An extra 15.3% savings on top of GZIP. A total of 4.6KB (80.7%) savings from the original.

This is a huge improvement over the original file sizes and speeds up rendering of the page quite a bit. The new method doesn’t require you to download JS replacements for each version of vB, instead it works off the existing files. Hopefully this will silence the people who complained about copyright/piracy issues with me distributing the JS files (even though they’re distributed to every browser that downloads the page).

I’m also looking at some other ways to speed up rendering as much as possible. Stay tuned for downloads and a full write up.

vBulletin JS Min

I realized today that vBulletin’s Javascript was just too bulky and didn’t really need to be, especially when you have no plans to customize it yourself. So I grabbed all the packages of 3.6.x and minimized all the Javascript. In most cases the Javascript files are 50% of the original, which saves bandwidth and speeds up the loading of your forum.


  • Backup all the .js files from the clientscript directory under your forum root.
  • Copy the files from zip file that matches your version of vBulletin into the clientscript directory.
  • Done!


vBulletin 3.6.0
vBulletin 3.6.1
vBulletin 3.6.2
vBulletin 3.6.3
vBulletin 3.6.4
vBulletin 3.6.5
vBulletin 3.6.6
vBulletin 3.6.7PL1
vBulletin 3.6.8

Multiple versions of IE on one PC

I’m always getting grief from my managers about not testing in IE6, which is hard when IE7 is installed on all machines these days. I recently found a little install tool which allows you to run multiple versions of IE on the same machine. It doesn’t fully install IE, just the dll’s and uses dll redirection to trick windows into running an older version of IE.

Although it’s not perfect, it’s a lot easier than running a virtual PC for each version.

The install can be found here:

Google Sitemap Generator

I was dissapointed when I saw the current Google sitemap generators available, so I wrote one.

– Generates Google sitemaps
– Generates Yahoo! sitemaps
– Generates plain text sitemap
– Splits sitemaps up into smaller files (as per Google’s instructions)
– Creates sitemap index file
– Pings Google/Yahoo!

This is the first release, so there’s probably some bugs in there somewhere. Please let me know if you find any. There are some examples in the zip file.

To best use the classes, set the variables on the page you call the class from, rather than editing the class file (so changes aren’t lost when you upgrade).


$sitemap = new Google_Sitemap();
$sitemap->doPing = false;
$sitemap->gzip = false;
$sitemap->baseurl = “”;


Version 0.2 – 14/05/2007

Fixed problem with script using too much memory when trying to sitemap hundreds of thousands of pages.

Double byte and PHP (unicode problems)

A while back I ran into a problem with PHP, how can I read in files that have double byte (unicode) characters and display them in a form that any browser can read. Most programming languages don’t handle these characters very well, and end up with non sense instead of passing through the correct text.

This function should be able to strip out any unicode characters from text and return them as html entities (something none of the core PHP functions are able to do).

function removeuni($content){
preg_match_all(“/[\x{90}-\x{3000}]/u”, $content, $matches);

foreach($matches[0] as $match){
$content = str_replace($match, mb_convert_encoding($match, “HTML-ENTITIES”,”UTF-8″), $content);

return $content;