Out of Hanwell

July 29, 2006

Drip 0.5

Filed under: IE Memory Leaks — Matthias Miller @ 3:10 pm

I’ve just released a new version of Drip. Here are some things that make this a great release:

  • Drip finds more memory leaks than ever before.
  • Drip can not only display leaked items, but can also show items that are currently occupying memory.
  • Drip shows more accurate memory usage.
  • The Drip user interface continues to be improved to make it simpler and easier to use.

But the greatest thing, I think, is the new memory usage graph that displays current memory usage or the current DOM usage:

Drip 0.5 Screenshot

Special thanks to Hristo Deshev and Johan Rosman for their interest and contribution to the project.

You can report any problems at the SourceForge project page.


July 27, 2006

rdesktop on the Mac

Filed under: Uncategorized — Matthias Miller @ 9:30 pm

I used my notebook quite heavily for terminal services, so I was quick to download Microsoft’s Remote Desktop Connection Client for Mac when I got my MacBook. However, it was quite slow even at low color depths. One evening I tried using it to code, but it was very unproductive. After that, I used it mostly to check e-mail. I finally decided to see what it takes to install rdesktop.

Although it took a bit of time to set up, I was very glad I did. It’s very fast and very useable, and it certainly beats Microsoft’s client. I have documented, as best I could, the steps required to set up rdesktop. I apologize in advance for any mistakes. But let me tell you, it’s well worth it!

Getting It Installed

  1. Find and insert your Tiger installation CD.

  2. Using the Finder, locate the Xcode Tools package and install it.

  3. Open the Terminal and run the following command to install X11:

    open /Volumes/Mac\ OS\ X\ Install\ Disc\ 1/System/Installation/Packages/X11User.pkg

  4. Download the latest stable version of rdesktop (1.4.1 at the time of this post).

  5. Assuming you downloaded the package to your desktop, run the following commands in the Terminal:

    cd ~/Desktop
    tar xzf rdesktop-1.4.1.tar.gz
    cd rdesktop-1.4.1
    ./configure && make && sudo make install

    Once that’s done, you can delete the extra files from your desktop.

  6. You should now be able to open X11 from your finder and run rdesktop with the following command:


Fixing the Alt Key

When I first ran rdesktop, I found that the alt/option key did not map as I expected. The solution is simple:

  1. Create a file called ~/.Xmodmap with the following contents:

    clear Mod1
    keycode 66 = Alt_L
    add Mod1 = Alt_L

  2. Open X11 preferences (Cmd+, from X11) and disable “Use the system keyboard layout”.

Streamlining It Further

Although this allowed me to use rdesktop to connect to my computer, it was still too much work, so I decided to streamline the process a bit.

  1. Create a file ~/rdesktop-mycomputer.sh with the following contents:

    /usr/local/bin/rdesktop -f -a 16

  2. Run the following command from the Terminal:

    chmod +x ~/rdesktop-mycomputer.sh

    You should now be able to run open-x11 ~/rdesktop-mycomputer.sh to open rdesktop in X11.

  3. Unfortunately, xterm gets in the way when you want to use full-screen rdesktop. To keep it from launching, run the following command:

    cp /etc/X11/xinit/xinitrc ~/.xinitrc

    Then, using a text editor, open ~/.xinitrc and remove the line that reads “xterm &“.

  4. Finally, open the Finder, Applications, AppleScript, Script Utility and create a new script with the following code:

    do shell script "open-x11 ~/rdesktop.sh &"

    Save the script in the “application” file format in a convenient location, such as your desktop.

  5. You’re done! You should now be able to launch your rdesktop session with a single click!

July 24, 2006

Back to the Mac

Filed under: Uncategorized — Matthias Miller @ 9:26 pm

I have now owned three Apple computers. I first bought an iBook about nine months ago, but finally sold it because it was too slow to do anything useful. (It took about 15 hours to compile Qt/Mac.) Then, six months ago I bought a Mac Mini, and I’ve used it periodically for some software development. But it’s been sittng in the corner and has received very little attention. That one’s leaving, too.

I’ve now got a MacBook, which I’m dual-booting, to replace my Dell Inspiron notebook. I’m writing this post in Kubuntu. Out-of-the-box hardly describes the installation of Kubuntu on the MacBook. With a little help, however, I got it done using the alternate Dapper CD for the base install. If I could only get the key mappings to work as they should and could get it to run a bit cooler, I’d be pleased. As it is, I’ll likely end up primarily using Tiger.

To all the Mac users, it’s good to be back.

July 15, 2006

Upgrading to b2evolution 1.8 beta

Filed under: Blogosphere — Matthias Miller @ 5:22 pm

I just upgraded to the b2evolution 1.8 beta.

Things I like:

  • It allows a cleaner anti-spam solution provided by the Akismet plugin. The previous hack protected me from tens of thousands of spam comments and trackbacks. I have no plans to start using the new captcha or moderation features. (Did I mention that I like Akismet?)
  • The statistics and graphs are neat.
  • I’ll have to actually use it to find the rest.

Things I don’t like:

  • There is no documentation explaining how to update a live system. Is this even possible? I ended up taking down my blog temporarily.
  • This upgrade completely broke my custom skin, so I spent quite some time reassembling it. It’s still too cluttered and has a number of glitches. (The comments look awful.)
  • The skin isn’t showing my list of categories.
  • There are so many settings that I can’t find any of them.

This got me thinking: Is there any way to provide more of a one-click upgrade experience? Why can’t the backoffice pull down the new source and upgrade the database, at least for minor versions?

Update: If you’re using the Akismet plugin in the 1.8 beta, you verify that Plugins::trigger_karma_collect (in blogs/inc/_misc/_plugins.class.php) calls $this->load_plugins_table();. Compare with the CVS source if you’re not sure.

JavaScript Variable Declarations (part 2)

Filed under: JavaScript — Matthias Miller @ 9:59 am

I just tried throwing my nasty variable declarations at JSLint (using its undefined variable detection):

function assign()
i = 10;
var i;
alert(typeof i);

It gave back the following errors:

  • Problem at line 4 character 8: Var i was used before it was declared.
  • Problem at line 4 character 8: Identifier ‘i’ already declared as global

I assume the first error message is only a stylistic preference, like so many other lint warnings, but I would enjoy like to hear Crockford’s explanation. I was a bit surprised by the second warning, because that’s not the case.

I then tried the following code:

function foo() {
return bar();
function bar() {
return 10;

JavaScript Lint does not handle this very well at all, reporting that that foo doesn’t always return a value and that bar is unreachable code, neither of which are true. JSLint simply reports, “Inner functions should be listed at the top of the outer function”, sidestepping the issue entirely.

I’m not sure whether its worth the cost to solve these problems completely, since the purpose of a lint (for me) is more pragmatic than idealistic. But it’s no wonder developers are confused if they’re been getting misleading warnings from both lints. If there’s a cost-effective way to improve it, I’ll do that.

Update: Crockford defends these warnings on the basis that it makes code easier to read and understand.

July 12, 2006

JavaScript Variable Declarations

Filed under: Uncategorized — Matthias Miller @ 8:37 pm

JavaScript Lint continues to surprise developers with warnings about variables. They do know that variables will be global if they forget to use the var keyword. For example:

function assign()
i = 10;
alert(typeof i); // shows "number"

But many of them don’t know what this does:

function assign()
i = 10;
var i;
alert(typeof i);

Is i a global variable (“number”) or a local variable (“undefined”)?

If assign would return i, what would this show?

function assign()
i = 10;
var i;
return i;

If you don’t know the answers to these questions, find out for yourself. Was it what you expected?

Update: The inquisitive should read section 10.1.3 of the spec, which describes variable instantiation: Every execution context has a variable object, to which formal parameters, function declarations, and variable declarations are bound. These variables are bound upon entering the execution context. That’s why the i isn’t global.

July 10, 2006


Filed under: Uncategorized — Matthias Miller @ 10:43 pm

Through the benevolence of an unnamed sponsor, you can now access the JavaScript Shell at a new location: http://www.jconsole.com/

The point is not, of course, to take advantage of somebody else’s hard work. That page doesn’t link back to me, and I see no reason that it should. Rather, it prominently links to the original shell.

There are two reasons for giving this its own domain:

  • It’s easy to remember.
  • I can update it with fixes for things that don’t work. (For example, I can finally apply the patch that I submitted nearly a month ago to Jesse Ruderman to provide better auto-complete in Internet Explorer.)

The JavaScript Shell is a tool that I use a lot. If you haven’t yet, try it out.

July 3, 2006

Cross-Window Events

Filed under: JavaScript — Matthias Miller @ 4:34 pm

Diego Perini recently pointed out to me that many JavaScript libraries or event helpers do not support cross-window events in Internet Explorer. If you’d like to use JavaScript to set up an event handler for an element in another window, whether in an IFRAME or in a popup window, you’re out of luck.

Here’s the problem: When a function is invoked, window always points to the window in which the function was defined. Of course, this behavior is necessary so that functions can access global variables in the scope in which they were defined! The global window variable is no exception. If the callback is not defined in the same window as the target element, accessing the event object will retrieve the event for the wrong window.

The solution is to depend on this (the target element) to determine the window containing the element. Deigo suggested retrieving the event like this:

function fixEvent(event) {
event = event || ((this.ownerDocument || this.document || this).parentWindow || window).event;
// fix event
return event;

Both ownerDocument and document will be null if the event is attached to the document itself. This code falls back on the context of the current window if the element’s window could not be found.

For interest’s sake, here are several solutions that don’t seem to support cross-window events. I’m not entirely surprised that neither of the addEvent functions support it, since they’re lightweight helpers. But I wonder whether there are any more fully-featured libraries (similar to jQuery) that support it.

Here is a test case:


    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Cross-Window Events</title>
        function registerClickHandler(elem) {
            elem.onclick = eventHandler;
            //elem.attachEvent('onclick', eventHandler);
        function eventHandler(eventParm) {
            // find the actual event
            var reportedEvent = eventParm || event;
            var actualEvent = eventParm ||
                ((this.ownerDocument || this.document || this).parentWindow || window).event;
            window.alert('The event, as reported by many frameworks, is:\n\t' + (reportedEvent) + '\n\n' +
                'The actual event is:\n\t' + (actualEvent));

    <iframe id="my_frame"
	 src="javascript:'<html><body>Click Me!</body><script>top.registerClickHandler(document.body);</script></html>'"></iframe>


Are there any libraries that can rise up to the challenge?

Update: I failed to mention that attachEvent will pass the event as the first parameter to the callback function, so this isn’t a big issue when attaching events that way. Using the parameter would be a quick way to get PPK’s addEvent to work in this situation.

Blog at WordPress.com.