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 WinDev’s Laptop Part2 - File system

July 17, 2008 @ 3:39 pm by walter — Filed under: Uncategorized

I used a lot of cross-platform software already, so moving this off Windows to Linux was easier than it might have been. I pity anyone trying to migrate from Outlook on a dead Windows machine to anything else, for example.

I may have broken a few rules in how I’ve set up my Linux computer, but this is a personal computer, not a server, so I feel justified in creating a new partition and mounting it as /data.

One rule that I have broken is partly a personal one. But this is the rule anyway: My documents and application data belong in my home directory. Don’t create funny non-standard subdirectories under the root file system.
So of course the first time I have a computer to myself I break this rule.

This laptop came with a 250GB disk. I’ve partitioned it like so:
/boot - 6GB
/ - 60GB
/home - 60GB
/data 40GB
(plus stuff like swap and about 80GB unpartitioned space ‘cos there is just so much spare)

I highly recommend to anyone to put /home on its own partition. Means you can wipe out your root file system with a fresh OS install, without having to restore all your personal data. (You did back it up anyway of course…)

The reason I have this separate /data partition is partly because I want to share it neatly as a drive D: under my Windows Virtual machine, and also because I might need to change file systems (eg to NTFS) in order to make certain Windows things work. Could be interesting..

Where I don’t have a great need to share files, I keep them under my home directory in a “my” subdirectory. ~/my/documents and so forth. Not KDE defaults, but this way I get to choose the organisation and I can just back the whole lot up. I don’t recommend creating lots of subdirectories (work, personal, mail etc) directly in the home folder, there’s enough cluttering that already.

I’ve also used fusesmb to connect my network under ~/Network. An article about that in the Ubuntu community docs wiki.

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

@ 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…)

What does “landlgme” mean?

October 29, 2007 @ 11:51 am by walter — Filed under: Uncategorized

My Nokia cellphone has “predictive texting” - where the phone attempts to match the best word for the sequence of digits pressed. For example, if I type in 74663 if comes up with “Phone” (5 button pushes instead of 10, often the improvement is better). This is quite good for clumsy texters like me who spend five minutes entering a two-sentence message.

It works most of the time, although there are a couple of words, usually short ones like “if” or “me”, which it gets consistently wrong. Sometimes it is a bit cute seeing the word develop as it makes the best guess on partially-entered words (eg along the way to “phone” it goes through s, pg, sin, sion, phone)

If the phone doesn’t have a suitable guess at what word I want, it beeps and comes up with a button labelled “Spell”, where I can use the old-fashioned way to enter the word.

Well, today I wanted to use the word “landline” (ok, maybe it’s not a word, but Im txting k?). So I pressed the required buttons: 52635463.

The phone’s suggestion: “landlgme”

No beep and “Spell?”. And I am at a loss to work out where it thought I was going with this one.

The only reason I thought this worthy of blogging was because I tried typing “landlgme” into Google to see what might happen. After all, it might be a famous town in Finland or something. And Google said:

Did you mean: landline
Your search - landlgme - did not match any documents.

Hurrah for Google. And of course, now if anyone with a Nokia phone tries to enter “landline” (or “janekind” or something), and then gets curious, they’ll be led straight to this blog post as the only search result. Perhaps even you who is reading it right now.

As usual when I struggle with the cell phone’s UI, I conclude I really should have just phoned the person I was sending to .. after all, my message in this case was essentially “Please call me”.

P.S. Yes, I’m aware the phone may not just use a dictionary to guess partial words, but I still don’t know what it thought it was doing.

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…)

Next Page »