2006-02-28

Math: No Wizards on Weekends?

I noticed that I haven't been starting as a wizard in Nethack for a while. Maybe the DevTeam have special code for weekend players just like they have for the new and full moon? But that's jumping the gun. There are 13 roles in Nethack, so assuming that any role is generated independently at the start of a game, what is the probability that I wouldn't get a wizard after n starts? In other words, what is P(k=0) after n trials?

Using the binomial distribution C(k, n) * p^k * q^(n-k), let p=1/13, q=12/13, k=0
if n=20, p(k=0) = 0.20 and if n=40, p(k=0) = 0.04. So, I should only start to wonder about special code if I don't see any wizards in 40 starts!

2006-02-27

IE6 MHTML Case-Sensitivity and CSS Paths

We wanted to generate and send an MHTML file to a customer. The source HTML page was on our file system and it referenced some image files and CSS files. We could have used a ZIP archive instead, but since IE6 could create .MHT files, we thought we had a simple solution.

After generating the MHTML file, we opened it on another computer and we noticed that the styles were not working. After some hacking, it turns out that there are two problems with the MHTML file generated by IE6:

  1. The <link> tag and Content-Location contain an absolute path to the CSS file. We had to replace those path strings with a relative path string.
  2. Harder to spot but very annoying was that IE6 now treated CSS class names as case sensitive, so class="footer" and class="Footer" are different. IE6 ignores the case of class names when it opens HTML files!

It turns out that Firefox's MAF extension is a better solution. MAF generates relative paths for files (the first problem) and in this sense, generates better MHT files than IE6. I found it a bit ironic since Firefox does not, by default, open MHT files.

2006-02-23

Software: Excel Copy Chart as Picture

We were trying to copy some charts as pictures or images from one Excel workbook to another but Excel would not paste a chart as an image. One workaround was to paste the chart in a drawing tool, then copy and paste that image into the workbook. While this workaround was OK, it was rather cumbersome since there were many charts to copy. With a little bit of searching, I found that this was #9 in the Top 10 Excel Annoyances. To copy a chart as a picture, select the chart, hold down the Shift key, then select Copy Picture in the Edit menu (not available in the context menu).

Another Excel quirk I've just noticed but don't have time to chase down is why I get the Paste Special menu item after copying a chart while my colleague does not.

Nethack: Death by Exploding Wand

Things weren't going so well for Mannix the Monk. He'd finished exploring the Sokoban levels but only found a bag of holding, not an amulet of reflection. The Gnomish Mines had no co-aligned priest and the only temple in the main dungeon wasn't co-aligned either. He scraped together some money to gain some holy protection but that was all he could manage. Then, he killed a nymph with a force bolt spell and broke her looking glass (bad luck!).

Things go from bad to worse; he discovers a level with a barracks with plenty of soldiers. His centaur was too wimpy to take on these soldiers and was just hanging around. Retreating to the stairs, Mannix fries a soldier with a wand of fire. A sergeant rushes into the room and zaps Mannix with a wand of lightning, causing the wands in his pack to explode. Mannix cops the full blast and dies.

This was a pretty hard game. It really sucked not getting an amulet of reflection in the Sokoban level. Not finding a co-aligned temple or even a plain altar made it impossible sacrifice monsters to improve my luck. I didn't find any good gloves, helmets, boots or cloaks from any of the corpses. None of the floating eyes left any corpses, so I couldn't scan monsters in a level.

On the other hand, I suppose I was forced to be a bit more inventive. I tamed many cats, dogs and horses because I needed help fighting monsters, and used the magic whistle to herd them up and down levels. I even managed to charm a centaur and increased my skill at casting enchantment spells just before I walked into the fatal last level. If I'd been thinking straight, I'd have charmed more monsters (for example, I found some stone giants) and brought them with me to the last level, then zapped them with my wand of teleport to drop them among the soldiers.

2006-02-22

Misc: Graduate Engineer or Scientist Portfolios

After interviewing some engineering graduates, I noticed that hardly anyone brought documentation, reports or samples of their work to the interview session. It seems pretty strange to me because the interview is a graduate's big chance to make a strong impression, and giving us interviewers something to read or examine strengthens our rapport with the candidate. I suggest making a kit consisting of your transcripts, certificates, awards, reports or theses, pictures or samples of your software or hardware. Actors and artists always have their portfolios ready for interviews, so why not engineers and scientists?

2006-02-16

Misc: Better Graduate Resumes, Please

I read a resume to get an idea of the person it represents. Obviously, if your resume is vague or skimpy, I'm going to get an incomplete picture. Having recently perused plenty of graduate resumes, here's what I look for:

Completeness
Write a complete timeline of what you've done recently without leaving any huge gaps. What's a huge gap? It depends on how precise you are. If you list your activities by the month, then you should explain any multi-month gaps (other than summer vacations). If you list by the year, you should explain year-sized gaps. For example, "In 2001, I took one year off studies to live in Vietnam."
Clarity
Don't obfuscate and don't be vague. Bad writing leaves a bad impression.
Academic record
Just give me the facts. "Bachelor of Electronic Engineering and Science, Honours 2A, 2006, University of Northern Mars" is fine. Better still, attach a copy of your academic transcript. It's pretty useless writing "Credit / Distinction Average" because I can read the transcripts.
Projects
Your big chance to shine! Describe your project, your involvement, highlights and lowlights. "Rescued project from failure by heroically working two days and night to remove memory bugs" is pretty impressive. "Member of final year project team" or "Reports to Project Manager" is uninformtive and uninspiring.
Work Experience
Describe relevant work experience in detail. Who did you work for, what was their business and what did you do? As before, "Member of …" and "Reports to …" is uninformative.
Interests
What are you like when you're not a wage slave? Please don't slack off and write the usual trite "Reading / Socializing / Watching Movies / Playing Games / Jogging" list. What do you really like doing in your spare time? Run the Harry Potter fan club? Train for marathons by running 10 kms a day?
Referees
Don't care until you survive the face-to-face interview and we really want to hire you.

BIG TIP: Get someone else to analyse and criticise your resume. Yes, it's painful and embarassing. Face up to the fact that hardly anyone can edit their own writing.

It's your resume, not you, that will be compared against 50 others that arrive in my inbox. If your resume doesn't have enough information or is badly written, there's no way I can tell if you're a savant.

Disclaimer: I'm not a career consultant or recruitment specialist, so don't send me any resumes to review. I'm just the dude who tries to review resumes as fairly as possible.

2006-02-08

Software: Regulator Regular Expression Editor

Regulator is a nifty regular expression (RE) editor written for the .Net environment. With this tool, you can create and edit REs, test them against sample input and get tooltips as you edit your REs. I found the user interface a little unintuitive initially (the input and output panes should be swapped) but I got used to it after reading the quick start in the online help. Some other features: describing your REs in English and generating VB.Net and C# source code from your REs.

Misc: Dull, dull, dull job applications

Graduates, take pity on the poor sod (like me) who has to read your applications looking for that handful of interesting candidates to interview. I've just read 50+ applications and resumes (and read another 50+ late last year) and almost without exception, they were dull, dull, dull. Anyone who did something out of the ordinary automatically jumped to the head of my list. Where are the innovative final year projects? Don't you take any difficult units? Just for computer science, I didn't find anyone who studied compilers, computer architecture, mathematical logic, computability or information theory, who implemented a game or a utility, contributed to an open source project, wrote an FAQ or even has a Web site!

Corollary: Don't write rubbish. Interesting doesn't mean you have carte blanche to write whatever rubbish comes to mind. If you claim to be an expert in Babbage difference engines (or more prosaically, C++ or SQL), you'll be certain that we'll find someone to ask you about your expertise.

If you want to be taken seriously, you have to rise above the ordinary graduate who only did the required units.

2006-02-02

Software: XML Schema Global versus Local Elements

After my encounter with namespaces in XML Schema, I was left wondering when a schema designer should or should not make local elements belong to the target namespace (or made global). The best discussion I found was in this thread which was summarised in the Hide Namespaces Versus Expose Namespaces article.

Software: XML Namespaces and Schemas

This error message from Altova's XMLSpy bit me while I was testing an XML Schema:

Unexpected element 'title' in element 'book'.  Expected: title

Here is the sample document:

<?xml version="1.0"?>
<book
  xmlns="bookSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="bookSchema book.xsd"
  >
  <title>Snoopy</title>
  <author>Charles Schulz</author>
</book>

And here is the schema:

<?xml version="1.0" ?>
<xs:schema
  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  targetNamespace="bookSchema"
>
  <xs:element name="book">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="title" type="xs:string"/>
        <xs:element name="author" type="xs:string"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Since I wasn't making any headway with XMLSpy's validator, I tried xsv from the University of Edinburgh and I received a more meaningful error message:

element {bookSchema}:title not allowed here (1) in element {bookSchema}:book, expecting [{None}:title]:

It turns out that in the XML Schema, title is not by default in the bookSchema namespace (see Qualified Locals in XML Schema Primer). The solution is to either add elementFormDefault="qualified" into the schema and force all local elements into the namespace or ensure that only the root element is in the namespace (using <bk:book xmlns:bk="bookSchema">) while its descendants are not in any namespace.