Drawing UML diagrams in OpenOffice Draw

In my search for a simple (and since my reasonably disastrous experiences with StarUML: stable) UML editor, I came across this set of UML symbols for use in OpenOffice Draw:

http://www.lautman.net/mark/coo/index.html

The author suggests you open the UML drawing and copy/paste elements from that into your own UML diagram. That is possible, but I prefer to add the elements from an OpenOffice Theme.

  1. Click the “Gallery” icon in OpenOffice Draw, or choose Tools > Gallery.
  2. Click on the “New Theme…” button.
  3. On the “General” tab, enter the name of the new theme, e.g. “UML”
  4. Drag the UML diagram elements from Mark Lautman’s ODG into the new UML theme. To do this, click on an element whilst holding the Ctrl key pressed. Keep holding Ctrl for a second or two. The cursor will turn into a “Copy” pointer; drag it into the empty UML theme area and drop it.
  5. The element will be added with a default title like “dd2014”, you can change this title by rightclicking the element in the Theme area and selecting contextmenu item “Title”, so sensible names will be visible in the list view.

Remove recent projects from Visual Studio 2008

To remove projects from the “Recent Projects” list in Visual Studio 2008, open regedit.exe and go to:

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\ProjectMRUList

You will find a number of keys here named “File1”, “File2”, etc. that contain paths to the projects in the “Recent Projects” list. Invalidate the paths of the entries you want to remove. (For instance, you can remove “vcproj” from the path.)

Now open up Visual Studio 2008 and click on one of the projects you want to remove. Visual Studio will detect the incorrect path and ask you whether you want to remove the project from the “Recent Projects” list; click Yes to remove the project from the list.

(Why isn’t this functionality available in VS2008?)

Text truncated to 255 characters when reading from Excel with Jet 4.0 OLEDB

One of those MS vagaries: text from my Excel sheet was truncated to 255 characters. See http://support.microsoft.com/kb/281517 for the reason. Apparently, the driver guesses the maximum length of a column by looking at the first 8 rows of the Excel sheet. The MS article tells how to change this number, but does not provide a workaround. My (ugly) workaround is: modify the Excel sheet by inserting an extra row at the top that contains more than 255 characters. A subsequent read will identify the column as bigger than 255 characters and read ALL text in the sheet.

jQuery UI problem with nested accordion and tabs widgets (solved)

An application I’m working on features tabs inside a jQuery UI accordion inside yet another set of tabs. The problem I was having was that, for some unknown reason, the accordion became way too high or way to narrow.

It turned out to be logically related to the nesting of the UI widgets and the order in which the widgets were created. If the accordion is rendered before the inner tabs are rendered, the contents of the inner tabs are (still) displayed below each other. The accordion calculates the necessary height based on these vertically stacked elements. Subsequently, the inner tabs are created and a big empty space remains inside the accordion. Another related problem is that when the accordion is created, the actual contents have to be visible for the height calculation to be performed properly. In my case, the accordion is not on the first (outer) tab that is visible by default, but on a subsequent tab, causing the accordion to be rendered with minimum height (approximately 50 pixels) by default.

The final solution was:

1. Create the (inner and outer) tabs

2. Select the outer tab that contains the accordion

3. Create the accordion

4. Re-select the initially selected outer tab.

All logical in retrospect, but isn’t that always the case.

McAfee = leet?

Whenever a scheduled virus scan starts, the number of scanned items remains on a suspicious number for a while… Is it just my leetz0rz laptop or is it an Easter egg? mcafee 1337Hmm…

Easter Egg on jQuery site

Digging around the script on the jQuery.com website I saw there´s an easter egg that uses the Konami cheat code, i.e. up arrow twice, down arrow twice, left arrow, right arrow, left arrow, right arrow, a, b. Rock on!
(Tested in Google Chrome only)

Mysterious additional HTTP GET: beware of the IMG tag!

This morning I solved one of those mysterious problems that cause insomnia, premature baldness and/or random acts of violence such as throwing anything out of the window with an on/off switch.

One of the web forms I’m working on stores an object in the Session scope. The object  is being created on the initial (non-postback) call of the webpage and fetched from the Session on subsequent postbacks. One particular part of the page utilizing AJAX caused the object to be reset to its initial state and that was when the detective work started.

Firebug showed that after loading a dynamic part of the page an additional HTTP GET was done. It turned out to be an IMG tag with an empty src attribute, i.e.

<img src="" />

that was filled in after dynamically inserting the HTML, causing the aforementioned HTTP GET by the browser. The solution was to point the IMG to a valid (empty) image first and overwrite that later.

This reminded me of a similar case I had a long, long time ago in a place near, nearby where a piece of faulty HTML also caused an additional GET. Exercise for the reader:

<body background="#FFF">

(Yes folks, that was in the day that CSS did not exist yet and “Auto-complete” referred to a letter stating that your T-Ford was ready.)

Copying text using Javascript URLs and TinyURL.com: cloud clipboarding!

The company where I’m currently doing a project has two separate networks: one small network that is used by the developers for a new application and
another network, used by the rest of the company, where the application is deployed to.

Today I wanted to copy a small piece of SQL from my PC to the server in the network. Because using a USB memory stick takes too much time (insert the stick, copy the text into a text file, store the file on the stick, etc.) I thought: apart from using webmail, can’t I store the text somewhere on a site and download it from there, preferrably using a small URL?

The first site that comes to mind is tinyurl.com. But I would then have to create a specific page first and shorten the URL afterwards, wouldn’t I?

Good news: tinyurl.com supports javascript URLs! So I simply created a new tinyurl.com link to:

javascript:f();function f(){document.write('<pre>the text that needs to be copied goes here</pre>');}

and opened up http://preview.tinyurl.com/ in a browser on the server and there you go! Cloud clipboarding!

 

UPDATE: some more Google-ing on the matter revealed two sites that do just this (but easier 😉 which are: http://cl1p.net and http://www.pastebin.com/ Once again this proves that anything you think up already exists somewhere else.

Handy Perl DateTime modules

I was working on a Perl script today and encountered the following two great DateTime format modules.
http://search.cpan.org/dist/DateTime-Format-Baby/
http://search.cpan.org/dist/DateTime-Format-Bork/
Good to see in the Changelog that someone even found a (fixed) bug in the Bork module. 🙂

Yearly WTF – the most terrible code I’ve seen in months

Today I came across the most terrible piece of code I’ve seen in months. Years. One would suspect the original programmer deliberately intended to cause chaos and despair.

It starts off with some Hungarian notation to throw you off-balance; check out the “strBetaald” variable which seems to be a string but is in fact a boolean:

string strValue = "";
string strCheck = "";
string strPaid = "";
string strProcess = "";
bool strBetaald = false;

Then the code proceeds to loop through XML nodes, setting the variable “strValue” to a certain value if the XML node name is X, and setting it to another value if the node name is Y. At the end of the run, strValue contains… what value? Well, doh, that depends on whether we came across X or Y first! The variable probably isn’t that important, since it just gets logged in a financial application database in approximately 50 lines down or so. Hey, how about a small coffee break, anyone?

In the middle of the loop we find the following gold nugget:

if (strCheck != "true".ToString())
{
    strCheck = strCheck;
}
else
{
    strCheck = strCheck;
    // some other stuff..
}
bool bet = Convert.ToBoolean(strBetaald);
bool chk = Convert.ToBoolean(strCheck);

So here we’re converting the string “true” to yet another string (just to be on the safe side) and to be really sure about getting the correct value, we assign the variable to itself.

Finally, we’re converting the boolean strBetaald to boolean, to be absolutely completely 100% positively certain that we’re right about this whole true/false thing because somewhere we read that there’s this weird thing called fuzzy logic and it may be lurking inside the compiler somewhere.

It all does make sense, so why am I so worked up about this?