Internet explorer does not recognise “apos” entity in XHTML

August 18, 2008 @ 11:47 am by walter — Filed under: Technical

In short: wanted an apostrophe in a website, so coded it with the ' entity.

Looks correct in Firefox, Konqueror, Safari … but Internet Explorer shows the text “'” not the apostrophe.

Actually, the ' entity is not defined in HTML, but it is one of the standard XML character entities, and the website is clearly identified with the header:

< ?xml version="1.0" encoding="utf-8"?>< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

.. and it validates correctly with http://validator.w3.org/ - so this is clearly an Internet Explorer bug.

Sigh. Upshot - use &#39; for apostrophe instead. Valid XHTML but also valid in HTML, so IE displays it as expected.

IE users can see the difference here: ' vs ' - other browsers will see two apostrophes.

Linux on a WinDev’s Laptop Part3 - CDArgs

August 8, 2008 @ 11:11 am by walter — Filed under: Linux

CDArgs is an essential tool for me to aid navigating directories in a command shell (terminal) window. I used to have my own little utility on Windows, but this is waaay better.
(more…)

Linux on a Windows developer’s laptop - Part 1 of N

July 17, 2008 @ 2:31 pm by walter — Filed under: Linux

Well, I have a new laptop computer (Asus M51sn) as my primary machine, and finally I get to use Linux as my personal operating system - something the rest of my household has done for years. A reversal of the usual story where the geek uses Linux (or BSD or…) and has a partner or kids using Windows (usually because of lack-of-geekdom, or the need to play games).

I have been running such cross-platform apps as Openoffice.org and Firefox/Thunderbird but still had a very heavy need for Windows-only tools for a good deal of my day job - programming in .NET and Visual Foxpro. I wasn’t happy with running such things under Wine and my old computer wasn’t grunty enough to virtualise a Windows development environment (heavy development with ASP.NET websites or Windows Mobile PDAs was bringing it to its knees a bit anyway).

This has changed, and though I’m not the most reliable blogger in the world, some of things I’m doing to make this work could be interesting to the world. So here I go.
(more…)

Configure svnserve password file with absolute path on Windows

October 26, 2007 @ 4:27 pm by walter — Filed under: Technical

Here’s one for Subversion administrators. If you set up the svnserve daemon you’ll usually need two configuration files. svnserve.conf lives in the repository’s conf/ directory, and has a setting pointing to a second file containing usernames and passwords, like so:

[general]
password-db = users.txt

According to the Subversion book,

The value of password-db can be an absolute or relative path to the users file

The way svnserve determines this is by checking for the first character of the path, if it is a “/” then it is an absolute path.

This is fine on a *nix platform. But how does this work on Windows? If my password file is, say F:/svn/users.txt, then do I specify one of these?

password-db = F:/svn/users.txt
password-db = /F:/svn/users.txt

As described on this (rather old) thread, neither of these work, giving an error message like ” svn: Can’t open file ‘F:\svn\repos\test\conf\F:/svn/users.txt’: The filename, directory name, or volume label syntax is incorrect.”

Fortunately there is a solution - use a UNC path. On Windows, the prefix “\\.\” (or //./) represents the local machine, and the following works just fine, with no need to resort to any other tricks like setting up a network share, or duplicate copies of the password file:

password-db = //./F:/svn/users.txt

Get IP Address that your PC presents to the world (C#)

May 4, 2007 @ 9:10 pm by walter — Filed under: .NET

Here’s a question, posed on the Universal Thread - how do you find out the IP address that your PC presents to the world?

This is something that your PC cannot answer for itself. For example, my PC currently is aware of at least three IP addresses - 127.0.01 is the “loopback” or “localhost” address which is never seen outside of the PC (This is quite standard, pretty much every computer with TCP/IP ability will use this address). I’ve also got the IP address my PC’s wireless ethernet card is using, currently 192.168.33.90 (but this could change, it is assigned by my router via DHCP). Finally there is also 192.168.84.6 which is the current address of my VPN link into the office. But none of these are the IP address that the world sees.

What the world sees - for instance a web server or mail server - is actually the IP address of my router’s external interface. In my case something like 203.x.y.z (again, the x,y,z change). To capture this, requires something on the other side of my router that my PC can query.

This is pretty easy as long as you have an external web server. For example, here’s an ASP.NET page (call it getip.aspx) that returns the requesting computer’s IP address:

< %@ Page language="c#"  %>< % 
    Response.Write( Request.UserHostAddress );
%>

Or if you want a PHP version instead, here’s getip.php:

< ?php
 print $_SERVER['REMOTE_ADDR'];
?>

You can test these simply by typing the address of into a web browser. And in fact there are sites such as http://checkip.dyndns.org/ which will give you the same information. But what if you want this value in a program. In .NET v2 it’s pretty easy. Here’s my getip.cs

using System;
using System.Net;

public class GetIpApp
{
   static void Main( string[] args)
   {
      if( args.Length&lt;1 ) {
         Console.WriteLine( "Usage: getip <url>" );
         return;
      }
      WebClient client = new WebClient();
      
      try {
         string strIpAddress = client.DownloadString( args[0] );
         Console.WriteLine( "IP Address is: {0}", strIpAddress );
      }
      catch( Exception ex ) {
         Console.WriteLine( ex.ToString() );
      }
   }
}</url>

Use this test program simply by passing a URL as the first argument from a windows command line, like so

C:\\work\\getip>getip http://your.server.goes.here/getip.php
IP Address is: aaa.bbb.ccc.ddd

C:\\work\\getip>

Now come a couple of things to tidy up.

Converting the IP address from a string to other forms, error handling and so on I leave up to you. You might want to look at the method System.Net.IPAddress.Parse() for instance.

The web pages above actually return invalid HTML. To play nicely by the rules you should really change the HTTP content type to text/plain (or return valid html and your client program needs to do a bit more parsing). This makes the C# version:

< %@ Page language="c#"  %>< % 
    Response.ContentType = "text/plain"; 
    Response.Write( Request.UserHostAddress );
%>

and PHP:
< ?php
 header( 'text/plain' );
 print $_SERVER['REMOTE_ADDR'];
?>

Finally, I should mention that even with all this effort, the IP address the web server gets may not be the IP address you desire. For example, your ISP might be operating a caching proxy server and so the address of that is captured instead. The easiest way around this is to connect to the web server using a non-standard port (not port 80) which the proxy server will not intercept.

If this is not possible - perhaps because your web server is provided by someone else and you cannot get it to listen on any other ports, or your firewall is restricting what external ports you can attach to, then the technique used depends on the particular proxy server. Some proxy servers are deliberately anonymous and there simply is no way at all. You can find a small discussion about this on the What is My IP address web site.

(Note the code samples in this post may be reformatted slightly by the blog software, so don’t trust an exact copy and paste!)

Install Net::DNS perl module to make SpamAssassin blacklisting go

September 22, 2006 @ 1:12 pm by walter — Filed under: Linux

This was very frustrating - so I’m writing this in case someone else uses Google to find the answer, and finds me. My problem: RBL checks in my mail gateway weren’t working, and a missing Net::DNS turned out to be the cause. (more…)

Enabling sound for non-root Linux users

September 9, 2006 @ 10:22 pm by walter — Filed under: Linux

A few weeks ago I let my kids loose on a newly-setup computer running Kubuntu (a flavour of Linux). This is a shared computer between the two of them, and unlike any previous linux desktop I’ve configured, the primary users are not logging in with the account name entered into the nice Kubuntu setup program.

The problem was the silence. More specifically the silence of any of the programs running on either kid’s desktops. (more…)

Transmogrifying colours (or, gradients the hard way)

September 5, 2006 @ 10:21 pm by walter — Filed under: Visual FoxPro

I found myself needing a way to convert a colour some of the way toward another colour. Possible use cases include

  • Lightening or darkening a shade
  • Recolouring a palette to match a colour scheme
  • Gradients and blends

Now, this is probably a specialised sort of function. With GDI+ (or the .NET System.Drawing) there are better ways to do gradient fills, and transparency may be a more understandable way of doing blending or merging. Still, it was a short function that took a deceptively long time to write, so you might find it useful. (more…)

What Financial Year does a date fall in?

September 1, 2006 @ 9:15 pm by walter — Filed under: .NET

The problem to solve is this: given a date (eg 1st September 2006), what financial year does it belong in?

A January to December financial year would make things simple, but this actually unusual. In New Zealand most common is the year ending 31st March, although many companies follow other conventions especially if they are part of a multinational corporation. See the Wikipedia article for more details.

I was surprised to not find a function for this in our company’s standard libraries, but I needed it, so I dusted off my brain and set out. And it wasn’t entirely obvious! (more…)

Windows essential command-line utilities

@ 12:05 pm by walter — Filed under: Technical

I often find myself wanting a number of command-line utilities for fixing problems, applying patches etc without having to be physically there. I might be on the phone to someone, or accessing a PC remotely, so I can’t copy them on via a CD or USB stick. Small, reliable programs that do the job well, with a minimum of fuss - thinks like editing configuration files, viewing logs, getting patches, zipping or unzipping files.

I’ve collected a few over the years, and some of them I’ve packaged up and put on this website. Mostly for my benefit, but you might have a use for them too. (more…)

Next Page »