Happy New Year!

Not posted for such a long while thought I’d better make sure I hadn’t forgotten how to type. Well Happy New Year anyway!

Microsoft Access shortcomings

I sometimes like to use Access as a quick and dirty tool in order to prototype a database idea. I generally much prefer to use SQL Server for obvious reasons.
Anyway, I was mightily surprised and somewhat disappointed the other day to run into a design flaw in Access that makes using Yes/No data types a bad idea.

After asking around on irc for an answer and getting none I decided to do what I should have done from the off and Google the problem.

I found out pretty quickly that Access has a flaw in the way it handles Yes/No fields - they can be only Yes or No and not Null - this is a problem when you do an outer join and then try to group by the Yes/No field.

Anyway, a full write up of the problem is provided by Allen Browne at http://allenbrowne.com/bug-14.html

My disappointment comes from the fact that he wrote this article in 2006 and I’m using Access 2007 and this isn’t fixed.

I am guessing that Microsoft have stopped working on the underlying Jet database engine and that this is the reason this has not / will not be fixed?

There is an Access workaround which consists of using a numeric data type with constraints - that too is detailed on the link above.

Using Perl under Windows

In an effort to reduce spam I decided I’d look at what good Open Source Anti-Spam software was available. I require it to work with Microsoft Exchange Server.
I soon settled on Spam Assassin which is written in Perl and very well regarded in the Linux world.
So, to set this up as I have you’ll need to download and install Perl, which under Windows means using ActiveState ActivePerl.
When Perl is installed head over here for info on how to Install SpamAssassin under Windows.

If for any reason you get any errors along the lines of ‘Package not found’ while attempting the ‘ppm install xxxxxx’ commands then that’s a problem with ActiveStates repository. A solution is to configure Perl to use a different repository.
#perl on Efnet IRC soon came up with adding theoryX as an additional repository.
You can use this command from your Perl bin directory:
C:\Perl\bin>ppm repo add theory58S http://theoryx5.uwinnipeg.ca/ppms

and you will see

C:\Perl\bin>ppm repo add theory58S http://theoryx5.uwinnipeg.ca/ppms
Repositories:
[1] ActiveState Package Repository
[2] theory58S

now your ppm install commands should work and you can continue the install process.

mod_rewrite for IIS

Apparently IIS7 is gonna have a url rewrite filter that will be compatible with Apache’s mod_rewrite. About time.
If you can’t wait or can’t upgrade then there are other options. I needed one for a site and found a nice free one called IIRF. It’s distributed under the Microsoft Permissive License.

If you don’t have any idea of what a url rewriter does - well it’s server side software that allows the browser to request http://foo/bar/bam and receive http://foo/something/dispatch.cgi?q=bam.
This is useful for easy to remember urls and also for search engine optimisation. Go google mod_rewrite for more details.

Mystery of the missing images

Just spent longer than I would have liked finding out why some images on my site weren’t displaying under Firefox 3 but were fine under IE7.
According to Firebug the images were being downloaded, but they were not being rendered. So, I looked at the rendered DOM source and could see that style=”display: none;” had been added to the img tag.
I was pretty sure that none of my scripts were doing anything like that, and after searching them all and checking the CSS for quite some time I eventually tracked the problem down.
And guess what!? It wasn’t a problem at all, it was the excellent FF plugin called AdBlockPlus just doing it’s job. The image path had the string ‘advert’ in it and had therefore had the offending style tag added. It was a very simple matter to disable AdBlockPlus for my site and that was problem solved!

Speeding up page impressions

I had cause to review a web servers performance recently after it was noted that one site was being served extremely quickly to the client and the other seemed woefully slow.

Well the webserver in this case was IIS 5 but the ideas discussed are relevant to other webservers such as Apache.

Firstly utilising a couple of excellent plugins for the FireFox 3 browser, namely Firebug and YSlow for Firebug, I was able to instantly see performance stats about how a server is serving a page to the client.

It was clear that the site I was reviewing wasn’t using any settings for caching and also wasn’t using gzip compression for on the fly compression of the HTTP response.

These sorts of thing can generally be set in a number of ways - either in server side script or configured for a given resource.

So, to summarise the changes I made in IIS for this site, I made sure all images were being stored in a folder called images from the root of the site. Then from IIS snapin right click the folder and choose properties, choose the HTTP Headers tab and enable content expiration for images.

Next I enable gzip compression by right clicking the computer icon in IIS and clicking properties, then choosing Edit under Master Properties and clicking on the Service tab - yeah pretty well hidden away really.

Under IIS if you choose to “compress application files” only the following will be compressed “asp”, “dll”, “exe”, I know this is true of IIS 6 as well as IIS 5 - search google for “Customizing the File Types IIS Compresses” to see how to get round that - you’ll likely want to add aspx and php if your server is supporting them.

Here’s the contents of a batch file that can be run on the server to set this up, just make sure that adsutil.vbs is available where the script is looking.

IISreset.exe /stop
cd c:\Inetpub\AdminScripts
cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoDynamicCompression true
cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoStaticCompression true
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcFileExtensions “htm” “html” “txt” “ppt” “xls” “xml” “doc” “js” “css”
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcFileExtensions “htm” “html” “txt” “ppt” “xls” “xml” “doc” “js” “css”
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions “asp” “dll” “exe” “aspx” “asmx” “ashx” “php”
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions “asp” “dll” “exe” “aspx” “asmx” “php”
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcDynamicCompressionLevel “9″
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcDynamicCompressionLevel “9″
IISreset.exe /restart