PC Plus HelpDesk - issue 265

Paul Grosse This month, Paul Grosse gives you more insight into some of the topics dealt with in HelpDesk.

From the pages of HelpDesk, I look at:

  • Disappearing files;
  • Hidden words;
  • Window Manager Options;
  • Xserver keyboard shortcuts;
  • Modelling your chances; and,
  • Tables by hand.


Disappearing files

UNIX-like systems such as Linux don't use a hidden attribute as Windows or Mac OS X do, they use a different method to hide files. Try this...

Open the Konqueror file browser and create a file called '.test.txt' by right-clicking on the file listing and selecting 'Create New', 'Text File...'. It appears that the file has not been created.

Do exactly the same again and it will say that the file already exists.

So, what's going on?

The first part of the answer is to understand that in UNIX, there is no such thing as a file extension. The dot is just another character that appears as part of the file name. If you want to select all files that end with, say, '.gif', you (or, more likely, the system) just use a regular expression that looks at the end of each file name for the '.gif' string (m/\.gif$/) - this is not the same as looking for an extension called 'gif'.

The second part is that a file with a name that starts with a dot, under UNIX-like systems, is hidden from casual directory listings.

To see them in the Konqueror file browser, you need to select 'View', 'Show Hidden Files' and they will appear.

At the command prompt, use 'ls -a' to see them.

Simply put, there is no hidden attribute as there is under Windows or Mac OS X (Mac OS X also uses dot files and has a file in the root called '.hidden' so that is a complete mess).

Dot files and directories are hidden so that they don't get in the way when using the system under normal circumstances.

It is only a convenience issue and you can still enter hidden directories and open hidden files in the normal way.

Hidden words

Meta tags died a while ago when search engines stopped using them so you might ask yourself; is there currently a way of getting a web page higher in the rankings?

In reality, the usefulness of Meta tags in HTML pages went when people started abusing them. Some search engines didn't use them at all and others simply scored lower the sites that did abuse them (usually by using the same words over and over again in them to fool the search engine).

Nowadays, search engines look at the content of the page to judge its relevance and one factor is how many times a particular, searched-for word appears close to the beginning. Again, this is all well and good assuming that people are playing the game honestly.

Some sites have already cottoned on to the idea that you can cheat and you will find that if you drag the mouse over the top of a page, you occasionally find that there is some extra text that has been coloured the same colour as the page background.

Essentially, these sites are cheating the search engines and before long, this will be stopped.

Click here to see such a file in a new window.

Window Manager Options

KDE's Window Manager Options offer capabilities that Windows users can either dream of or pay for.

Whilst more than you get with Windows any way, the buttons in the top right of a desktop window are only the tip of the iceberg. The three on the right, you are already familiar with but the left hand one makes the window appear on all desktops - you can use 20 desktops to organise yourself with if you want to.

Right-click on the title bar and you get a drop-down menu that lets you do a number of things including specifying its position relative to others in the desktop's window stack and something called 'shade'. This is where the window scrolls up so that all you can see of it is the title bar.

With a small memory footprint on a UNIX-like system such as Linux, you can have many windows open at the same time so being able to spread them across multiple desktops and scroll them up is quite useful.

The default behaviour for double-clicking on the title bar is to maximize/minimize the window but you can configure this to be any behaviour. Shading is quite useful to have as the double-click behaviour although your own circumstances might hint at a different option.

Xserver keyboard shortcuts

If you've recently changed your monitor, you might think that it can work at different resolutions to the default you have and the only way to find out is to try them out. You can use the dialogue box on the right but there is an easier way.

You can see if your screen can take one of these by pressing [Ctrl][Alt][+] or [Ctrl][Alt][-] on the number pad. Some times, when you have configured your X server, you end up with a configuration that has too high a resolution for your screen and you can use these keyboard shortcuts to get you to a screen resolution that works.

As an alternative, you can use [Ctrl][Alt][Bksp] to kill the X server altogether.

Another use for this particular key sequence is if you have a program - such as a game - that hangs the server and you can't SSH into the machine from another on your LAN to kill off the program. [Ctrl][Alt][Bksp] works almost every time and is quite a good one to remember.

Modelling your chances

Many people struggle with statistics and with this problem, even the statisticians got it wrong - except for one person (it wasn't me - if only...).

Here's how it goes...

In a game show, behind three curtains are two booby prizes and a car - the booby prizes being goats (this assumes that you will find the goats less valuable than a car which probably doesn't hold for a large proportion of the world's population but let's just stick with it for the moment - most people that I've talked to would prefer the goat).

The contestant picks one of the curtains but it is not opened.

Here, the contestant has picked curtain number one, but it could have been any of them.

Next, the compare reveals one of the remaining goats (he knows which one has the car but doesn't let on).
The contestant can then stick with his/her choice or swap it. In the example on the right, the contestant can choose between curtains one or two.

Stick or swap. Which is more likely to produce a car? (remember that we are assuming that cars are more valuable).

The maths isn't difficult, it is just that it is, for the most part, confusing (even for statisticians).

Here are the choices:

  1. At the end, there are two choices for the contestant: pick the goat or pick the car. One of the goats has already been removed therefore it is 50:50. Easy. Swapping has no effect; or,
  2. The contestant is twice as likely to pick a goat at the beginning because two thirds of the curtains hide goats. Once a goat has been revealed, the one that the contestant has picked still has a likelihood of two thirds of being a goat therefore swapping with the other unopened curtain will produce a likelihood of two thirds of winning the car. Swapping will double your chances of winning to two thirds.

As even statisticians were confused about this, taking a mathematical approach to the stats is probably not that good an idea (although understanding it would make that approach quicker).

So, instead, let's do it the fun way by doing it with a computer program and letting the computer do what it does best - cracking it using brute force.

In order to crack it with brute force, we need to recreate the television studio environment in the program (the bits that matter, not the audience saying 'swap' and 'stick' in equal proportions, all at the same time).

First of all, we need to run two experiments - one where we swap and one where we don't so we'll use a loop with a variable called '$swap' and count the number of wins for each situation.

Next, we create the three curtains in the studio and insert goats and a car.

After that, we'll pick one and get the compare to reveal one of the goats.

After we've counted up the successes, we print out the results.

And, the answer?

As near as makes no odds, you are twice as likely to win the car if you swap.

Before flaming the PC Plus HelpDesk mailbox, run the program and play around with it yourself - it is correct. Click here to open up the directory containing the program files in a new window.

Another way to look at this problem is that if you are proposing a television program like this, you need to have some idea of what a series is going to cost.

If you assumed that swapping would have no difference (ie, that it was a 50:50 issue) then you would be in for a bit of a shock. If half of the contestants swapped then the result would be 50:50 but if the temperament of the audience was such that they were more likely to swap, the cost of the show would increase as more cars would be lost as prizes (assuming, again, that cars were more valuable than goats). It would be a good idea to model the worst-case scenarios so that you could cost the show appropriately (here, the worst case is a loss of 66% but with other games, it might be worse).

As an aside (Doh shabad ...)

By now, you should have worked out that by using the value of a variable called '$goat' in an array, and the same with '$car' (the values have to be different), you can make the program a bit more flexible and easier to read.

However, these are all in English. You don't have to have variable name in any particular language - even though Perl, BASIC and so on are all essentially English. So, here is the same program as above written in another language (and, just for the doubters, it does work - you can try it out for yourself).

#!/usr/bin/perl -w
# same program but just to show that you don't
# need variables that you can understand (they
# do mean something - can you guess what they actually say?)
$rogee_bakra = 0;
$chamak_kar = 1;
$saaraa = 3000;
foreach $badalnaa (0..1) {
  $jitnaa = 0;
  foreach (1..$saaraa) {
    @pardaa[0..2] = ($rogee_bakra, $rogee_bakra, $rogee_bakra);
    $maukaa = int(rand(3));
    $pardaa[$maukaa] = $chamak_kar;
    $chunee = int(rand(3));
    while (1) {
      $pardaa_utthaanaa = int(rand(3));
      if ($pardaa_utthaanaa == $chunee) {next};
      if ($pardaa[$pardaa_utthaanaa] == $chamak_kar) {next};
    if ($badalnaa) {$chunee = 3 - $pardaa_utthaanaa - $chunee}
    if ($pardaa[$chunee] == $chamak_kar) {$jitnaa++;}
  print "$jitnaa of $saaraa  =  " . int($jitnaa / $saaraa * 100 + 0.5) . "% for ";
  if ($badalnaa) {print "swapped\n"} else {print "not swapped\n"}

Have a go.

Tables by hand

Coding HTML by hand - even whole pages or web-parts by hand - has many advantages over using a GUI program to do the designing (just in case you were wondering, the PC Plus HelpDesk page that you are reading, along with just about every other one in the past have been put together using FrontPage Express 2.0.2 running on a Windows 98SE machine so I'm not against using GUIs).

By hand, you have better control over how tables are built and how you fill them - there are no hidden parameters that you need a dialogue box to see. Using cells that cover a number of columns or rows not only allows you to cut down on the total number of cells that a table takes up, but it allows you to use cell boundaries to align text.

However, there are ways of making more complex tables (those with cells that span multiple rows and columns) easier to see whilst you are editing them.

In the table tag ('<table>'), you probably have a number of different parameters including the 'border' parameter.

Normally, if you were creating a table such as the inset in the screenshot, you would have turned the border down to zero and forgotten about it.

But, with one cell taking up five columns and four rows; and adjacent cells adding to the potential confusion, all you need to do to find out where cell boundaries exist, is to go up to the table tag and set 'border="1"'.

You can now see where each cell sits in the table and editing is a lot less confusing.

Back to PC Plus Archive Index Page