IE6 duplicate / random content

March 8, 2007 by Matthew Capewell

I had a strange issue with IE6 recently where there appeared to be a random character that was displayed when the page was rendered:

screenshot_before.jpg

It became apparent that it was actually the last letter from the above select element but it only happend in IE6 and not IE7 or Firefox.

The select element and the button are both floated, have % widths and are in a containing div which has an absolute width set in pixels.  After much searching I found this article and I was able to fix it by using the following style on the button:

margin-left: -10px;

and the page then rendered correctly:

screenshot_after.jpg

Don’t you just love IE6 bugs?!

Debug and time ASP.NET code using tracing

March 7, 2007 by Matthew Capewell

It is easy to get debug and process timing information out of an ASP.NET page.

To turn on tracing for a single page use:

<%@ Page Trace="true" %>

or to enable it at the application level put the following in the web.config:

<configuration>
  <system.web>
    <trace enabled="true" />
  </system.web>
</configuration>

The trace of a single page is output at the bottom of that page’s HTML or if tracing a whole application (website) then the trace information is available at the URL http://mywebsite/trace.axd

Debugging statements can be output in the trace by using the following commands in the code behind:

Trace.Write("Starting some code...");
Trace.Warn("Some important event occured!");
Trace.Write("Finished some code.");

Draw a straight line in The GIMP

February 7, 2007 by Matthew Capewell

Ever wondered where the line tool is in The GIMP?

All you have to do is select the ‘pencil’ tool, click on your image where you want the line to start, press and hold down the shift key and then click where you want the line to end.  The two points should (hopefully) now be joined up by a straight line.

Restart Apache in Mac OS X

September 22, 2006 by Matthew Capewell

To restart the Apache webserver service you can run the following command in a Mac OS X Terminal window:

sudo /usr/sbin/apachectl restart

Editting a file from the Mac OS X Terminal

September 22, 2006 by Matthew Capewell

To edit a file (for example /private/etc/httpd/httpd.conf) from the Mac OS X Terminal you can run the following command:

sudo pico /private/etc/httpd/httpd.conf

Enabling mod_rewrite on Mac OS X

September 22, 2006 by Matthew Capewell

In the file /private/etc/httpd/httpd.conf change the following line:

AllowOverride None

to:

AllowOverride All

In the file /private/etc/httpd/users/[user].conf change the line:

AllowOverride None

to:

AllowOverride All

Finally restart Apache using the following command:

sudo /usr/sbin/apachectl restart

Hosting ASP.NET 1.1 websites along side ASP.NET 2.0 websites

September 7, 2006 by Matthew Capewell

I haven’t been able to find much info on this but it is possible to run two websites (one .NET 1.1 and one .NET 2.0) on a single Windows Server 2003 server.

The key is to have them run in different application pools.

In IIS you can setup one website to run under the DefaultAppPool and then the other to run under a new one (e.g. DefaultAppPoolForNET2).

How to make a transparent PNG image for IE6 using The GIMP

September 7, 2006 by Matthew Capewell

I recently made what I thought was a transparent PNG but when I uploaded it onto the website it was transparent in Firefox but not in IE6.

After doing some searching, I found the following solution. Apparently IE 6 doesn’t support 24-bit PNGs with alpha channel so you need to convert the image to 8-bit.

  1. Open the original image.
  2. Set a proper background colour as oposed to it being transparent. It is best to make this colour similar to the background colour of the website to generate the antialiasing in your image borders in order for the image to blend nicely.
  3. Flatten the image (Image – Flatten image).
  4. Add an alpha channel (Layer – Transparency – Add alpha channel).
  5. Select the background color (Selection – By color).
  6. Clear the background colour (Edit – Clear).
  7. Convert the image to indexed color (Image – Mode – Indexed color).
  8. Save the image to the final PNG file (File – Save as) and remember to check: Save color values from transparent pixels.

Create Mac OS X AppleScript application to call Unix/terminal commands

September 2, 2006 by Matthew Capewell

To do this, load up the AppleScript editor and enter the following:

do shell script "..."

Replacing … with the command that you wish to run.

If the command requires administrator privileges then append the command with ‘with administrator privileges’ and then any subsequent commands with ‘and password’. For example:

do shell script "..." with administrator privileges
do shell script "..." and password
do shell script "..." and password

When the script is complete and tested save it as an ‘Application’ and tick the ‘Run-only’ checkbox.

Calling PHP from a Cron job

September 2, 2006 by Matthew Capewell

There are a number of options available to call a PHP script page from a Cron job. The option to use depends very much on your web host and how they have their servers configured. Option 2 is the one that I have found to work for me.

Option 1:
lynx -dump http://www.domain.com/file.php > /dev/null

Option 2:
php -q /home/username/public_html/file.php >/dev/null

Option 3:
wget http://www.domain.com/file.php

Option 4:
get http://www.domain.com/backup.php > /dev/null