2005-12-22

Review: Avalon (2001)

Simon wondered what I thought of Avalon, and I sent him a quick reply. Here's a longer review with possible spoilers. Caveat: I watched Avalon on late night telly, so it might have been a less than engrossing experience compared to watching it in the cinema.

In a dreary and depressed city, people play a virtual combat game called Avalon to earn a living. One of the aces is Ash (Malgorzata Foremniak), a loner who lives with her Bassett hound (a recurring mark in director Oshii's films) in an small flat full of books. She finds out about an extra level in Avalon that can only be entered by defeating the Ghost. Initially reluctant, she joins an old team mate, Stunner (Bartlomiej Swiderski) and a mysterious Bishop (Dariusz Biskupski), in finding this Ghost.

Avalon is fairly dull and plodding. Director Mamuro Oshii overuses repetition in the first half of the film to suggest that Ash's world may be just a simulation. The central plot element of the film, the Avalon combat game, is devoid of tension and linear (defeat the grunts, then beat the boss). In the game, none of the actors look or move like players in fear of their (virtual) lives. The only standouts are the production design of the bleak city and cinematography.

0.5 out of 5 stars.

2005-12-16

Maths: Linear Programming using lpsolve IDE

Quick background: a Mathematical Program (MP) is a mathematical formulation of an optimization problem. Solving an MP means finding the minimum or maximum of an objective function subject to a set of constraints (or limits). A Linear Program (LP) is a subset of MPs where the objective function and the constraints are expressed using linear coefficients (i.e. only + and -). Here is the FAQ and a more thorough definition.

I decided to relearn Linear Programming (LP) so that I could better understand one of my company's products. I've used the solver in Microsoft Excel but it can be inconvenient to translate LP problems into the spreadsheet format. Also, the standard Excel solver is limited to a small number of variables and constraints. Luckily, there's other solvers on the 'Net. First I tried a Python solver, pysimplex, but I couldn't install it on Python 2.4. Then I tried the Windows version of GNU Linear Programming Kit (GLPK) but it doesn't seem to have a user front-end. Finally, I found lpsolve IDE in the Progdigy site, which as a bonus, has both an IDE and the lpsolve solver. Note: lpsolve is also available separately from the lp_solve Yahoo group.

I found the Lpsolve IDE is pretty good for doing exercise problems. It can check the syntax of your problem and display the solution's objective and constraint variables. So far, so good.

2005-12-12

Software: Foxit PDF Reader

Adobe's PDF Reader, acroread 7.0, started scanning PDF documents for the reading order before displaying the document's content. I couldn't figure out how to turn off that feature, so I ditched it and installed FoxIt Software's PDF Reader. It's small compared to acroread (the installer is only 1.1 Mbytes vs 20.8 Mbytes) and starts in a flash. Way to go!

2005-12-10

Review: HarperCollins Concise Handbook for Writers

I was never terribly happy with my writing, so I sought to improve it. One of the books I recently read was the HarperCollins Concise Handbook for Writers:

Title: HarperCollins Concise Handbook for Writers
Authors: Peter Dow Adams and Amy Tickle
Year: 1994
ISBN: 0-06-501994-6

Stars: 4/5

This is a textbook on writing papers for American college students. It provides advice on: how to research, plan and structure one's work, the appropriate style for papers, constructing paragraphs and sentences, the use and misuse of common words, and grammar, spelling and punctuation.

The lessons are written in a direct and authoritative style, and worked examples are provided. The explanations are enhanced by the use of proofreading marks and diagrams.

In addition to the usual table of contents, glossaries and index, every entry in the table of contents shows both the topic and an example, each page has a tab at the edge with an abbreviation of the page's topic, each tab is aligned with the abbreviated table of contents and there are many tables that summarize different categories of words. These devices make the book easy to use as a reference.

I have only used this book for a short time but it has already helped me write more confidently and smoothly.

2005-12-05

Misc: ABC's My Favourite Film

The Australian Broadcasting Corp (ABC) ran a survey called "My Favourite Film" (MFF) and did a (rather cheesy) special last night. The most amusing part is the faux review of the programme by David Stratton after the end credits, where he mentions his Movie Show co-host Margaret Pomeranz's award-winning bit part in "Priscilla, Queen of the Desert" and the dreadful bearded guy in the special.

If the results of MFF are to be believed, then either Australians are closet SF fans or geeks have manipulated the survey because the top ten films are:

1. The Lord of the Rings Trilogy
2. Amelie
3. Blade Runner
4. The Shawshank Redemption
5. Donnie Darko
6. Star Wars: Episode IV - A New Hope
7. Pulp Fiction
8. The Princess Bride
9. Gone With The Wind
10. Fight Club

You can find the top 100 on the web site.

2005-12-04

Nethack Death by Carelessness

My female human barbarian was in level 17 when she got jumped by six fire giants in an unlit room. They shouldn't have been a problem normally, except she was burdened, so she used one turn to drop her bag of holding then used another turn to put on her ring of regeneration. These two moves cost her half her hit points. She finished off one giant and caused another one to flee, but caught up in the heat of the moment (I forgot to monitor her HP), she proceeded to fight the remaining giants instead of withdrawing. Death by carelessness, I'm afraid.

She was a promising character, having finished the Gnomish Mines and Sokoban levels, and was about to go on her mission. She had acquired all the usual intrinsics, was invisible, was stealthy (had Elven boots), had extra luck which did not time-out (luckstone from the Mines), wielded Firebrand (no enhancements yet because she only found one uncursed scroll of enchant weapon), amulet of reflection (from Sokoban levels), +2 gauntlets of dexterity, banded armour and cloak of protection. She had also identified most of the gems, armour, scrolls and potions. She even found three magic markers and an uncursed magic lamp.

Despite all her armour, her AC was a poor -6. Her pet dog, Fido, was polymorphed into a vampire lord in the Mines so it made short work of all the guards and shop keepers in Gnometown. Unfortunately, she let Fido kill the co-aligned priest of Crom, so she lost the opportunity to improve her natural AC by donating to the temple. That's a good reason to keep pets on a short leash!

2005-12-01

Software: Microsoft Word 2000 Search-Replace Capitalization

When using Microsoft Word 2000, if you try to replace an all uppercase string (e.g. XXXX) in a document with a mixed case string (e.g. FileName), then Word helpfully makes all letters in the replacement string uppercase (e.g. FILENAME). On the other hand, if the original string had mixed case (e.g. XxXx or xXxX) or was all lowercase (e.g. xxxx), then the case in the replacement string is preserved.

If the original text is all uppercase, then the workaround is to select the Match Case checkbox in the Find and Replace dialog.

This is just a plain annoying feature. I can't think of a reason why anyone would want their replacement text to be changed based on the case of the search text.

2005-11-27

Software: Do They Want My Money?

Trading Post sure makes it hard to place an advertisement on-line! First, I have to install Macromedia Flash and restart my browser. Having done that, I was expecting something really special for this wonderful Flash interface. What I go was a UI that works worse than a normal web page. It takes a minute to load (I still only have dial-up) and only has to display seven pages of forms. When I have to submit an image, I can't cut and paste the path into the text field (I use 2xExplorer's Alt-C function) but I have to use the Windows file browser to navigate to the folder containing my file then press the Open button. Ho-ho-ray.

2005-11-25

Review: How to Begin Studying English Literature (1987)

English Lit. has always been a mystery to me; I'd never quite figured out what to discuss after reading a novel or poem. I'd make a reasonable guess in an exam, write some answer and seem to do well enough. But I felt that had to be a systematic way to study literature, just like mathematics or science. This high school guide, How to Begin Studying English Literature, gave me a fair idea how to start:

(This review is for the 1987 edition.)

This guide provides basic study techniques for students of English in the UK. The first part covers analysis; how to find themes in a work, how characters support a theme, the general structure of a story, the use of style and imagery, and how to study irony. The second part describes how to compose and write essays during an English examination.

The language in the book is kept simple and there is hardly any jargon. In each chapter, a method for studying each topic is first described and then a worked example is demonstrated. No particular interpretation is pushed and the student is encouraged to read works and come to their own conclusions. All the techniques are then brought together in the chapters on essay writing.

Although aimed at students, this guide would help anyone who is interested in gaining a better understanding of literature.

2005-11-20

Review: Pandora's Star

Woo-hoo! My first fiction review for Amazon:

Hundreds of years in the future, fusion power and wormhole technology has enabled mankind to colonize hundreds of worlds in the galaxy. Rejuvenation therapy, cloning and memory copying allow anyone with enough money to live indefinitely. Life's pretty idyllic for citizens; there's plenty of space to live in, mankind has met no hostile aliens and the Commonwealth government is fairly benign. Naturally, this utopia is threatened by forces within and without.

The first hundred-odd pages set the stage and are a bit tedious. There's plenty of characters and each one gets a certain number of pages. Unfortunately, their stories are told with the same style so it's hard to be really interested in them. Once the Commonwealth decides to explore a stellar anomaly, the characters become better defined, the plot picks up pace and the story races to multiple cliffhangers.

Hamilton's great at writing action and creating detailed universes, but his writing can be boring elsewhere. For instance, it was a chore to read the horse-trading between senators for the presidency in the Commonwealth and his characters seem to only experience intimacy by having sex (and plenty of it). Minor niggles aside, this is a very enjoyable space adventure and I look forward to the sequel.

2005-11-14

Effing CD Command

This bites me every couple of weeks: the cd command in the Windows command shell (cmd.exe) does not treat directories and drives consistently. After all these years of working in Windows, you'd think that I should have engraved into my mind that when I want to use a directory in another drive, I should type either drivename: then cd path or cd /d drivename:\path. Then I forget and I blithely type cd drivename:\path. Even worse is that cd does not give an error message that it has not changed the current directory.

17-Jan-2008: In PowerShell 2.0, the cd command (alias of Set-Location) now consistently changes drives and directories. Hoo-ray!

2005-11-12

Review: Linguistics A Very Short Introduction

I was hoping to find out more about linguistics but this book wasn't much help. Here's the review I wrote for Amazon:

This book starts interestingly with the question of the meaning of words, how we encode sounds with symbols and how languages change over space and time. Unfortunately, from Chapter 4 onwards, the discussion becomes quite hard to follow because it relies on many linguistic terms and complex sentences. For example, I had to re-read this sentence in page 65 several times to understand it:

"This ['distributive' element] distinguishes a set whose members are in some way differentiated; so, for example, forms that might be glossed as 'flower-DIST' could be used of flowers that, as well as being two or more, are not all of the same sort."

The editing and formatting of the book could be better. Some linguistic terms (e.g. "gloss" in page 50 and "genitive" in page 110) are first introduced in an example rather than in the main text. Sometimes examples, captions and quotes are in boxes in a bold font (e.g. in pages 93, 94 and 95) but other times are formatted as a standalone paragraph (e.g. in pages 77, 78 and 79). Poor formatting has resulted in a photograph of Chomsky and some text in page 90, then a description of his ideas in a box starting in page 91 but with the final sentence in a box appearing in page 92.

Many pages in this short (152 page) book are wasted: four pages are allocated to photographs of linguists and eight pages are used to advertise other books in the series! I would have preferred to see some of these pages used for a glossary of terms.

2005-11-11

Software: Google Desktop 2

I don't how long Google Desktop 2 has been available, but I found it today and installed it. From my quick test, it worked as well as the previous version and now supports the "filetype:" keyword. That keyword is useful for restricting the search results to files with specific extensions. For example, adding "filetype:pdf" would restrict the results to just .pdf files.

2005-11-02

Review: Learn German The Fast and Fun Way

I'm pretty leery of any book that claims to teach something the "fast and fun way" and unfortunately my suspicions have been proved right again.

2005-11-01

2005-10-26

Review: Complete Guide to Learning a Language

Skimmed this book to see if there were better ways to learn another language other than listen, read, practice and analyze. As I wrote in my review, I wasn't impressed.

2005-10-13

Software: Data is King (was Elvis)

Two Mad Penguin interviews with OpenOffice developers discuss the importance of open data formats.

Gary Edwards explains why clean XML (or an open XML format) allows an organization to avoid being locked into a vendor's solution and then being left high and dry when that vendor goes belly up. Florian Reuter describes using XForms for OpenOffice's forms and the difficulties in writing importers for proprietary document formats.

It heartens me to find good arguments for developing open data formats. Data migration is a well-paying but messy task whose complexity is always underestimated.

2005-10-04

Software: IE6 Fieldsets Leak

When creating HTML forms with the <fieldset> element, I add some padding so that the elements within the fieldset do not touch their container's border. In the CSS box model, padding is the amount of space between a box's border and its contents.

Below is an example of a fieldset definition that has a legend in the fieldset, a label and a field:

<div style="background-color:9dbc80">
  Hello world
<fieldset style="background-color:#d1dfd6;margin:0px;
padding:4px;border:1px solid black">
  <legend>Test legend</legend>
 <label>Test:</label>
 <input type="text" value="This is a test"/>
</fieldset>
  Bye world.
</div>

And below is a rendering of the example defintion.

Hello world
Test legend
Bye world.

If you are using IE6, you should see that the background of the fieldset extends beyond the border to surround the legend text, while if you are using Firefox, the background is entirely enclosed within the border of the fieldset. Even worse in IE6, the amount of area beyond the margin depends on the padding value!

2005-09-29

Software: Winzip In-place Editing Annoyance

Winzip allows a user to edit a file in an archive, edit that file, then save that file back into the archive after the user has closed his or her application. However, if you try to edit a file that is in a folder in an archive, Winzip does not place that file back in that folder. What is annoying is that you only find out about this limitation after you edited the file and tried to save it. Even more annoying is that there are now two copies of your file in the archive! Gritted teeth!

2005-09-28

Software: WinCVS Locate File Feature

When using WinCVS, sometimes I want to copy the path of a file so that I can tell a developer which file to change by e-mail. By accident, I found that WinCVS would print the location of a file in the Output pane if I drag and drop a file in the File Pane. In the illustration, the top right hand pane is the File Pane and the Output Pane is the bottom pane.

2005-09-22

Software: Simple Javascript Regular Expression Search and Replace

Here's a simple regular expression search and replace in Javascript (for JScript, replace alert with WScript.Echo). I wrote it as a test for another script to modify a configuration file.

var s1 = "Hello World"
var s2 = s1.replace(/Hello/, "Goodbye")
alert(s1 + "," + s2)
var s3 = s1.replace(/(Hello)/, "$1 Googly")
alert(s1 + "," + s3)

If you run this script in a Web page, you should see the first alert dialog containing "Hello World,Goodbye World" and a second alert dialog containing "Hello World,Hello Googly World".

In this example, the parentheses (()) enclose a match pattern and the dollar ($) symbol represents the matched string (i.e. $1 is the first matched string, $2 is the second matched string, etc.).

2005-09-19

Software: Oracle ORA-12638 Credential retrieval failed

Sometimes the Oracle server throws an ORA-12638 error after I drop tables from a database with active connections and subsequently try to run SqlPlus on the server computer. My previous solution was to reboot the Windows server computer. Hey, when in Windows, do what the locals do.

A better solution can be found here. Since Oracle administration is not my game, I'll just accept that Martti's solution works and not ask any more questions.

2005-09-16

Misc: High Petrol Prices Starting to Bite?

This week, it's taking me about 10% less time to drive to work. Are higher petrol prices starting to bite and forcing commuters to use alternatives? Are some schools starting their term break a week early?

2005-09-15

Nethack Death - Cleaved by Tsurugi Muramasa

It was going pretty darn well; I was a samurai with AC -26, strength 18/26, dexterity 18, blessed +2 Greyswandir, invisible, can see invisible, ring of slow digestion, amulet of reflection and a whole raft of intrinsics. I had finished the mines and Sokoban levels and cocky enough to take on my nemesis. There was no problem dealing with the ninjas and ronins in the donjon. Finally, I met Ashikaga Takauji. We fought for five rounds then his Tasurugi of Muramasa cleaved me in two. WAAAAAH!

After that traumatic event, I realised that I should have wielded my blessed +5 Snickersnee instead, since samurai can be expert in long sword but not saber.

Software: Winzip Letter Case Annoyance

I wanted to extract a specific file out of a WAR file, so I fired up Winzip, got file path in the archive (web-inf\web.xml), then tried to extract it with jar xf file.war web-inf/web.xml.

No go; jar could not find that file. After ten minutes of head-scratching, I got a list of files from the archive with jar tf file.war and saw that the path was really WEB-INF/web.xml!

Why extract that file using jar? I'm hacking a script to customize the hostname in the web.xml file for the daily build and installation of our WAR file.

2005-09-12

Misc: Tidied Hobby Web site

I spring cleaned my hobby Web site over the weekend; I ditched the idea of writing the source in DocBook and using XSL to produce the final HTML pages. The whole process was too cumbersome for the eight or so pages I had on my site and a pain to test. Instead, I just edit the XHTML directly using gvim, preview and validate the pages on Firefox then upload them.

2005-09-07

Software: VNC Viewer Handy Shortcuts

Handy keyboard shortcuts for Java VNCViewer:
  • F8 to show the menu.
  • Shift-Ctrl-Alt-Del to send Ctrl-Alt-Del signal to remote Windows desktop.

2005-09-02

JScript To Launch Applications

Here's a quickie JScript program to launch a set of applications in Windows. I wrote it because I didn't want to always start these applications when I logged in to my workstation (which is what happens to programs in the Windows Startup folder). Save the text in a *.js file in your desktop, edit the list of applications, then click on the icon to run it.

var apps = new Array()
apps[0] = '"C:\\Program Files\\Bozinis\\2xExplorer\\2xExplorer.exe"'
apps[1] = '"C:\\Program Files\\Mozilla Firefox\\firefox.exe"'
apps[2] = '"C:\\Program Files\\Microsoft Office\\Office\\EXCEL.EXE"'
apps[3] = '"C:\\Program Files\\Microsoft Office\\Office\\OUTLOOK.EXE"'

function runApps() {
  var wshell = WScript.CreateObject("WScript.shell")
  for (var i = 0; i < apps.length; ++i) {
    var appPath = apps[i]
    wshell.Run(appPath, 1, false) // Don't wait for command to finish
  }
  wshell = null
}

runApps()

JScript and Windows notes

If your application file paths have white spaces, you need to delimit them by double quotes so that the Windows shell can find them. The outer-most single quotes tell JScript the start and end of a string. Backslashes in Windows paths need to be escaped by another backslash.

Software: Skype quirks and gotchas

Some Skype quirks and gotchas.
  • There is no way to view the history of a group chat in Skype (my version 1.1.0.79). The chat history files are stored in C:\Documents and Settings\username\Application Data\Skype\username but they are encoded in some proprietary format.
  • If you call someone and then close the call window before they answer, the call attempt continues. If the recepient answers the call, the caller does not see a call window but the line is established, so the receipient can eavesdrop.

2005-09-01

Software: Dumbed Down Tutorial - Weblogic Workshop

Weblogic Workshop has one of the most dumbed down tutorial instructions I've had the misfortune to read recently. If you follow the Windows steps, you end up with a Quickstart window and a Workshop window, when all that was required is for the developer to enter the path to the executable in a console. The Quickstart window is not used in the rest of the tutorial and consumes 25 Mbytes of RAM. Does BEA (the publisher of Weblogic) really believe that developers are sooo stupid that they can't launch an application from a command console? 2007-06-12: Removed URL to BEA workshop tutorial. Link is gone?

2005-08-25

Software: Firefox Text To Link

How many ways can you use text in a Web page as a link?

  • Highlight text with your mouse pointer, then drag and drop your selection into the address bar.
  • Hit F7, highlight text using the cursor keys, copy the text into the clipboard, paste the text into the address bar.
  • Install the Linkification extension. This extension makes all parse-able text in a page into links.
  • Install the Plain Text to Link extension. Highlight some text, then use the context menu to open that text as a link.

2005-08-23

Software: Firefox form history

It would be a neat idea to view values stored by Firefox's form completion feature. Then I could reuse text that I've previously entered in our local bug database form and make my reports more consistent. In Windows, Firefox saves form information in C:\Documents and Settings\username\Application Data\Mozilla\Firefox\Profiles\random.default\formhistory.dat. Unfortunately, that file is encoded in some proprietary XML database format and there is no reader (other than Firefox) for it. All I can do is delete all entries or delete individual entries using Shift-Del. It would be nice to have an editor like the Password or Cookie Manager. Dream on.

2005-08-16

Software: Firefox HTML Validator Extension

If you want a quick way to validate your web pages, try the Firefox HTML Validator extension. Install the extension, restart Firefox and you will notice a new icon in the bottom right-hand corner of your window. When your mouse pointer hovers over that icon, Firefox displays a tooltip with the number of errors, if any, in the current page. Select that icon and Firefox will display a View Source dialog with more information about errors in that page. Then, if you select the OK button in that dialog, Firefox displays a new window with the source view of the current page in one pane and two extra panes containing errors and help.

2005-08-14

Software: Firefox's Search Bar

You can widen your Firefox Search Bar by editing your userChrome.css file. In Windows, it is C:\Documents and Settings\[username]\Application Data\Mozilla\Firefox\Profiles\[random].default\chrome\userChrome.css:

#search-container, #searchbar {
 -moz-box-flex: 600 !important;
}
Also, I found from the French Firefox site, but not in the English on-line help, that the keyboard shortcut for selecting the search bar is Ctrl-K.

Tip: The search bar is more useful than Smart Keywords in the Address field because it remembers previous search patterns while the address field does not.

2005-08-12

Misc: Pointless Contractions

Just now, I had to check out a project management module from CVS. What do you think it's called? Something obvious like ProjectManagement? project_management? No … it's called proj_mgmt. What a pointless contraction in this day and age.

2005-08-08

Nethack Insta-death - Drowned by giant eel

Here I was, a fully kitted up Peregrinator with lots of intrinsics, water-walking boots, AC -11, wielding Grayswandir, lots of gear and a blindfold, ready to tackle Medusa's Isle. Then an eel grabbed me and I drowned.

2005-07-26

Software: IE6 crops child elements

While trying to implement a list of buttons, I found that IE6 crops the tops and bottoms of child elements when the parent element is a block level element. For example, if the parent is a ul element, the li elements would be cropped.

If you are using IE6, you should see that the top and bottom borders of the following TEST boxes are missing. Firefox users would see two boxes with borders around each one, as expected.

  • TEST
TEST

Below is the code to generate the TEST boxes.

<ul style="position:absolute">
 <li style="border:1px solid darkgreen;display:inline;">TEST</li>
</ul>
<div style="position:absolute">
 <span style="border:1px solid darkgreen">TEST</span>
</div>

The work-around is to add padding at the top and bottom of the parent element, e.g. padding:1px 0px 1px 0px, resulting in …

  • TEST
TEST

2005-07-25

Software: Chubby IE6 buttons

I found that the padding IE6's form buttons is proportional to the length of the button's text. If you're using IE6 and viewing this page, you should see that the padding in the second button is larger than the padding in the first button.  

2005-07-18

JScript in IE6 to read database

Inspired by this Kuro5hin article, I hacked up a slightly nicer JScript implementation to read database tables and generate HTML tables in a browser using DOM functions such as insertRow() and insertCell().

Try it out

If you want to try it out, first create an Excel workbook called Test.xls with a page named DataTest. In DataTest, create one column with a heading StringValue and another column with a heading NumericValue. Enter some test data in those columns, then save the file.

Next, copy the HTML code at the end of this article, change the DSN path appropriately and save it in a file.

Finally, load the HTML file in IE6. When you select the Test button, the data in your workbook should be displayed in the browser.

Notes

If you start Excel and the user interface doesn't initialize properly, the cause is usually the Excel automation server not exiting. Just start Windows Task Manager, and kill the errant Excel.exe process in the Processes tab.

I chose Excel instead of Access as the database because it is easier to test simple programs without having to create a table design.

Sample JScript and HTML to read database

<html>
  <head>
    <title>DBTest for IE6</title>
    <script type="text/javascript">
      function readDb(tableId) {
        var conn = new ActiveXObject("ADODB.Connection")
        var dsn = "Provider=Microsoft.Jet.OLEDB.4.0;"
        dsn += "Data Source=C:\\CVS_STUFF\\HTML\\Database\\Test.xls;"
        dsn += 'Extended Properties="Excel 8.0;HDR=Yes;IMEX=1"'
        conn.Open(dsn)

        var rs = new ActiveXObject("ADODB.Recordset")
        rs.Open("[DataTest$]", conn)

        var outputTable = document.getElementById(tableId)
        if (!outputTable) {
          alert("Cannot find " + tableId)
          return
        }

        if (!rs.bof) {
          var rowIndex = 1
          rs.MoveFirst()
          while (!rs.eof) {
            var row = outputTable.insertRow(rowIndex)

            var c1 = row.insertCell(0)
            var data1 = rs.Fields('StringValue').value
            var text1 = document.createTextNode(data1)
            c1.appendChild(text1)

            var c2 = row.insertCell(1)
            var data2 = rs.Fields('NumericValue').value
            var text2 = document.createTextNode(data2)
            c2.appendChild(text2)

            ++rowIndex
            rs.MoveNext()
          }
        }

        rs.Close()
        conn.Close()
      }

    </script>
  </head>
  <body>
    <h1>DBTest for IE6</h1>
    <form action="javascript:readDb('testOut')">
      <input type="submit" value="Test"/>
    </form>

    <table id="testOut">
      <tr><th>StringValue</th><th>NumericValue</th></tr>
    </table>

  </body>
</html>

2005-07-07

Software: Mark of the Web partie deux

Faced with the prospect of having to add MotW on every page I develop on my local disk, I had to find a better solution. Luckily, some nice people at PHD Computer Consultants Ltd explained how to disable this — cough — feature in IE6. In Tools / Internet Options / Advanced dialog, check Security / Allow active content to run in files on My Computer. Restart IE6 and load the offending file. No more Information Bar. Yay!

2005-07-06

Software: HTML behaviours

Tags in DHTML pages quickly get cluttered with numerous on-some-event="fn(id)" attributes, making it nightmarish to maintain hand-coded pages. Instead bind elements and behaviours (events and functions) separately from tags. Microsoft introduced behaviours for Internet Explorer 5.5 for special effects in a page but their implementation uses non-standard additions (unsurprisingly) to CSS. Ben Nolan wrote a browser independent behaviour library and Lambda-the-ultimate forum has a discussion. Using CSS selectors to specify elements allows multiple HTML elements to have the same behaviour and multiple behaviours to be mapped to one HTML element (as long as the events don't overlap). Très cool indeed!

2005-07-04

Software: Mark of the Web

Since "upgrading" to Windows XP Service Pack 2, IE6 annoys me with an information bar warning me about active content whenever I load a local HTML file with Javascript code. The information bar does not appear when I load the same file from a network drive or from a Web server. It turns out that this is a new feature to protect me from myself. The workaround is to insert a Mark of the Web, which is just a comment string that IE6 adds to every web page saved locally. For every day work, <!-- saved from url=(0014)about:internet --> inserted at the start of the file is enough. The number in the parentheses is just the number of characters after the closing parenthesis.

2005-06-21

Misc: Foiling Autodialers

When the phone rings at dinner time, it's usually some call center operator on the other end. Yes, its a wonderful offer but no thanks. Recently, some call centers have started using auto dialers to improve their staff efficiency because their operators don't have to dial out and wait for a response. The auto dialer only connects an operator when the recipient answers the phone. To foil these nuisances, just pick up the phone and say nothing. After about 10 seconds, the auto dialer hangs up. Other tips can be found in http://www.scn.org/%7Ebk269/data.html.

2005-06-01

Software: CSS Multiple Class Selectors

I just found out that HTML elements can have multiple (CSS) class names, such as <p class="Number ReadOnly">. This feature allows a design approach where the CSS class selector names are defined first. If the style definitions are independent of each other, then your elements can combine a number of styles. If you have a style sheet with these definitions ...
.ReadOnly { background-color : aliceblue; }
.Number { text-align : right; }
... and your elements have multiple class names ...
<input class="ReadOnly" readonly="true" value="ABCD"/>
<input class="Number" value="123456"/>
<input class="Number ReadOnly" readonly="true" value="34566"/>
... then ...
  • 123456 and 34566 should be right justified.
  • ABCD should be left-justified.
  • 34566 and ABCD shold have coloured backgrounds.

Software: Vim HTML Pretty Indentation

I initially wrote lots of dummy HTML table rows like this:
<table>
<tr><td>Blah</td><td>Blah</td></tr>
</table>
As the text in the table cells grew longer, the rows became harder to read and edit because they were wrapped over more than one line. So, I inserted a carriage return between every end and start tag. In vim, the command :%s/></>Control-Q Control-M/g< results in:
<table>
<tr>
<td>Blah</td>
<td>Blah</td>
</tr>
</table>
Still ugly. Now I want to prettify the text with indentation. I found tip 83. So, I moved the cursor to the start of the file, typed =G and got this:
<table>
  <tr>
    <td>Blah</td>
    <td>Blah</td>
  </tr>
</table>
Ahh, the power of vim!

2005-05-13

Software: CSS Selectors

Fresh from XSLT, I wanted to address sub-entities in CSS based on a top level element so that I wouldn't have to label every sub-entity with a class or id attribute. CSS selectors to the rescue! So, if I have the following HTML structure:
<table id="ATest">
  <thead>
    <tr><th>Head1</th><th>Head2</th></tr>
  </thead>
  <tbody>
    <tr><td>Data1</td><td>Data2</td></tr>
    <tr><td>Data1</td><td>Data2</td></tr>
  </tbody>
</table>
Then I can select different parts of the structure ...
table#ATest { /* Entire table */ }
table#ATest thead { /* Just the thead portion */ }
table#ATest tbody { /* Just the tbody portion */ }
table#ATest tr { /* All tr sub-entities */ }
table#ATest tbody tr { /* Just the tr entities in the tbody */ }
table#ATest tbody tr:first-child { /* Just the first tr in the tbody */ }
After some testing, I found that IE 6.0 doesn't support the use of the > selector for selecting the child (not descendent) of an entity nor does it support the :first-child pseudo class. Firefox 1.0x does support them, so I can have a different style for the first child of any entity.

2005-04-26

Java Formatting Currency and Dates

The easiest way to display a double in the local currency is to get an instance of NumberFormat currency formatter and use its format() method. The following example ...
import java.text.NumberFormat;

public class CurrencyFormatExample {
  public static void main(String[] argv) {
    NumberFormat cf = NumberFormat.getCurrencyInstance();
    double cost = 19.51;
    System.out.println("Cost = " + cf.format(cost));
  }
}
... produces ...
Cost = $19.51
Similarly, the easiest way to display a date is to get an instance of a DateFormat date formatter and use its format() method. Choose different types of date formatters to produce shorter or longer output. The following example creates four different data formatters ...
import java.text.DateFormat;
import java.util.Date;

public class DateFormatExample {
  public static void main(String[] argv) {
    DateFormat dfShort = DateFormat.getDateInstance(DateFormat.SHORT);
    DateFormat dfMedium = DateFormat.getDateInstance(DateFormat.MEDIUM);
    DateFormat dfLong = DateFormat.getDateInstance(DateFormat.LONG);
    DateFormat dfFull = DateFormat.getDateInstance(DateFormat.FULL);
    Date today = new Date();
    System.out.println("Today is ...");
    System.out.println(dfShort.format(today));
    System.out.println(dfMedium.format(today));
    System.out.println(dfLong.format(today));
    System.out.println(dfFull.format(today));
  }
}
... and produces ...
Today is ...
26/04/05
26/04/2005
26 April 2005
Tuesday, 26 April 2005

2005-04-21

Misc: Robust self serve petrol process

It was a busy evening at the Shell. I had to wait to refuel because one of the bowsers in my line wasn't working. Then I had to join a long queue to pay because there was only one cashier. "Pump 4, please," I said to the cashier when I reached the counter. The cashier looked puzzled. "Are you sure? It's been paid." I went out and double-checked. "Yep, it's 4." We worked out that someone else had paid the wrong bowser (mine) and since his or her amount was less than mine, I paid for the petrol from the other bowser and count myself lucky. Why don't customers pay the wrong bowser more often? Attendents can't match the person paying to the bowser. Perhaps by evolution, the self serve process is robust because:
  1. You can't pay for a bowser that is still pumping, so you have to quote a bowser that is both idle and not paid.
  2. If you quote the wrong bowser number, the person who used that bowser is probably in the shop and would hear you.
So, the incident happened because it was busy, the other person finished quickly, paid my bowser when I had just finished but I hadn't yet walked into the shop.

2005-03-15

Misc: On-line shopping for Region 4 DVDs

What a sad experience looking for Region 4 DVDs in Australian on-line shops; same prices (plus / minus 10%), same items, same unavailable items, minimal user interfaces to their on-line catalogues and eye candy that takes forever to load. The only substantial difference is how each shop calculates shipping costs! No reviews (except HMV) and no user history; nothing to draw me back. Compare prices with GetOnce and pick the cheapest shop.

2005-03-04

Misc: Procrastination

I finally created a blog after procrastinating for months. I knew I was going to do it because I wanted to publish something occasionally but as every procrastinator knows, some other task jumps to the front of our mental priority list and we never get around to it. Until today.