21 December 2010

Logitech Illuminated Keyboard BIOS Problems

I've read complaints that Logitech's Y-UY95 illuminated keyboard won't work before Windows boots up (therefore you cannot access the BIOS), and that it might make the computer hang for 0.5 - 3 mins or so during boot. (link, link, link, link)

But with my Acer Aspire, it actually prevents the computer from booting at all. (Well, it might be a 3-minute freeze only. But I need my computer to boot up in an instant if there's an emergency, so...) If I plug it in after booting, it works fine. As similar problems seem to affect many different computers, I think it must be an issue with the keyboard. I've contacted Logitech and am waiting for their reply.

Update: In their reply, as I expected, Logitech suggested that my BIOS was too old to support the wireless illuminated keyboard. The problem is, I tried to use the wired one. Waiting for another reply.

Update2: We didn't get any nearer to the solution, even after receiving some advice about how to make my mouse work. I'm returning the keyboard.

29 November 2010

Windows Mobile 7 on HTC Mozart - A Marriage Made in Hell

I've long been an advocate of Microsoft products, telling people everywhere I go how much development work goes into a system like Windows; that it's much better and secure than it looks, and that if one knows how, one can create an environment under Windows as customizable and professional as under Linux.

I've used simple mobiles, Palm OS, and Windows Mobile 5. Then, we decided to get an HTC Mozart form Orange with Windows Mobile 7. We shouldn't have.

Although the hardware is as advanced as that of any state of the art iP* product, unless you want to spend your time watching videos you can't download or listening to music you can't buy, my old Nokia 2630 seems to be more flexible and customizable than this -- for want of a better word -- monster.

You simply can't customize HTC Mozart, even if you want to change the simplest things. There are no profiles that would allow you to change all sound / alert / vibration settings at once. You can only select from 10 short alerts to notify you about an incoming message or e-mail, which is useless if such messages are supposed to wake you up during the night. You cannot change the theme -- you are stuck with large colourful rectangles that are visible from yards away, and take up way too much of the otherwise large screen. There is no extension SD slot, and no explorer to give you a hint about data, resources (horrible dictu, files) on your device. Oh, and you don't get a Windows Mobile 7 DVD from Orange, for reasons we couldn't discover.

It won't communicate with ActiveSync; you need a Zune account to upload something to your phone, and an Xbox Live account to play a game. The oversimplified OS seems to be designed for playing music, videos and games -- but it's pretty useless for anything else. Earlier versions did a much better job at putting your office into your hand.

As a sample, here is the menu you see on the phone:
  • Phone (I think; I haven't inserted the SIM card, so it says "No SIM")
  • People (get contacts from your SIM and Facebook)
  • Messaging
  • Email setup (why not integrated into messaging?)
  • Orange Weds
  • Orange Maps -- Coming Soon
  • Your Orange
  • Orange Daily
  • Internet Explorer
  • Games -- Xbox Live
  • Calendar
  • Pictures (connect to Facebook to upload quickly and easily pictures you really shouldn't)
  • Music & Videos
  • Marketplace
  • HTC Hub (a nice combination of the marketplace and today's weather)

By touching the "right" arrow you finally get to a more detailed list of what you can do with your phone. Here, in addition to the above, one can find:
  • Alarms
  • Calculator (no square root)
  • Camera
  • Maps (nice and quick, with satellite view)
  • Office (simple but works)
  • Orange Maps Navigation
  • Settings

And that's it. Why bother with task manager or advanced config? Memory or power management? But these weren't my immediate concern. Desperate to find a way to change the message and e-mail alerts, I hoped I could use a recorded message. But there is no built-in application to record some sound. Or leave a voice note. I searched the marketplace, but still couldn't find anything. I connected the phone to my computer running Windows 7, expecting that I could upload an mp3, or find a hidden folder to add my file to so that it would appear in the menu. Obviously, they couldn't communicate; you're not allowed to access your phone even as a simple storage device. And I thought I wouldn't have to hack into a mobile to change the way it rings.

With Windows Mobile 7, Microsoft seems to have recreated the claustrophobic feeling I had with iPods. "Perhaps too simple," suggests Daniel Robinson in his review. Well, it turns out to be an understatement.

Update: Windows Mobile 7 doesn't seem to communicate with Outlook, and you can only install software from the marketplace. You cannot enter the name of a wifi network you'd like to connect to; you can only select from the visible ones, which means that the phone cannot connect to hidden networks at all.

29 October 2010

Macros in Kate editor version 2.5.5

Update: For macros in Kate version 3.8.4, please see this post.
It turns out that despite appearances, it is possible to write macros in Kate, as it supports an ECMAScript (JavaScript) -based scripting language. What's more, these macros, if set up correctly, can be invoked with a couple of keystrokes only.

Although the official Kate handbook describes these scripts in detail, the documentation is for Kate version 3.4, whereas I'm using 2.5.5. Many of the functions listed in the handbook are not available, so I decided to post about the ones I found under 2.5.5.

My main aim was to create simple macros that insert some text at the cursor.

Location of the scripts

The scripts should be located in a share/apps/katepart/script folder. It might be necessary to search a bit, as the exact location might be different on each system. Scripts under Kate 2.5.5 do not have functions in them, so you'll have to name the files the way you'll invoke the macros. For example, if you want to run a macro by typing s or st, then the filename will have to be s.js or st.js. More on how to run a macro later.

Writing the script

This is a short script that can be used to insert some text at the point where the cursor currently is. The following should be the entire contents of the file.
text = "TextToBeInserted";

And that's it. You can use the usual things in the string, like \n or \".

If you want other functions or objects, you can look at the scripts already there in the directory, or look into the Kate source code (Google will do that for you), and use try and error.

Running the script / macro

You'll have to restart Kate after creating or modifying the script files. I don't think there's a way to tell Kate to reload them. After that's done, you can run a macro by typing its name in the command line. Press F7 to get to the comand line, type, for example, s or st, and hit ENTER. I know it's 3 (or more) keystrokes, and not one, but it's better than having no macros at all.

27 October 2010

Testing for bless-edness in Perl

Using ref($o) to test whether $o is an object is obviously not enough, as it might be a simple unblessed reference. The following solution is almost perfect:

This tests if $o is a descendant of UNIVERSAL, where the isa method is defined.

However, the above is also true of classes! That is, in the following case, the condition is true:

package mypackage;

package clientcode;
if( UNIVERSAL::can('mypackage','isa') ){ ... }
As an aside, let me note that isa can also be called in a class context, which means that the following is also true:

package mypackage;

package clientcode;
$o = 'mypackage';
if( $o->isa('mypackage') ){ ... }
All in all, it seems the only reliable way of testing whether something is an object is to test whether it can 'isa' and to test whether it is a reference as well.

25 September 2010

Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER)

You might see this exception in Firebug from time to time. As I've found very little information about what may cause this, and was forced to debug some obscure piece of code for hours to get to the problem, I thought I'd post a possible cause of this exception.

.insertBefore() can throw this exception if what you try to insert is undefined, as in the following example:

<div id="hello">Hello</div>
<script type="text/javascript">
function returnundef(){ return; }

Note: IE will give a "Type mismatch" error in this case.

Strangely, you get a simple "VAR not defined" error both in IE and Firefox if you use an undefined variable.

12 August 2010

An Addition to the LED Icon Set

As a little addition to the LED Icon Set (http://led24.de/iconset/), I've created left-right and up-down arrows that match the style of the other arrows in the set. I hope someone will find these useful; feel free to use them in any project.

Arrows arrows.zip

10 May 2010

Overlapping floats

As if it was a continuation to a previous post, I came across a problem in Firefox (and in Chrome and Safari) when I developed a 3-column flexible layout with floats and negative margins:

<div style="border:1px solid blue; width:100px; height:100px; position:relative;">
<div style="border:1px solid red; width:30px; height:80px; float:left;">
<a href="link">link</a>
<div style="width:100%; float:left; margin-left:-34px; border:1px solid green;">
<div style="border:1px solid green; margin-left:40px;">text</div>


In Firefox, the green (second left) float, because of some negative margin, overlaps the red (first left) float, rendering the link unclickable. Interestingly, this does not seem to be an issue in IE8 and Opera. Setting the z-index did not solve the problem.

A solution is to create a new offset container out of the red float. Simply add position:relative to it:


If you look closely, the borders show that the red float is now in front of the green one, although it comes first in the code (this difference is visible both in Firefox and IE), and the link is now clickable.

5 May 2010

Difference between function declarations in JS

After a little (re)search, I couldn't find any mention of this, so I'm including this observation here. It concerns a difference between the two more common ways of declaring a function in JavaScript. While with function myfunc(arg){...}, it is possible to call myfunc before the declaration, when using var myfunc=function(){...}, myfunc is not available before the declaration. In other words, function names are stored during compilation, while variables (not surprisingly) get their values during execution only.

That is, this results in an error:

var myfunc=function(x){ alert(x); }

While this works fine:

function myfunc(x){ alert(x); }

For other aspects of function declarations, objects and prototypes, please see http://www.permadi.com/tutorial/jsFunc/index.html.

10 April 2010

Firefox makes DOM standard compliant on change

Firefox seems to take some liberties with the DOM: it inserts and closes
elements to make the structure (more) standard compliant, but only if something
is changed. As this does not seem to be done by any other major browser,
debugging problems caused by this can be tricky.

To take an example, the following code has block-level elements inside an inline

<a href="#link">
<div id="container">text1</div>
<script type="text/javascript">
document.getElementById('container').innerHTML='new text';

When the JavaScript runs, apart from modifying the content of the first DIV,
Firefox also inserts a new A element around the content:

<a href="#link">
<div id="container"><a>new text</a></div>
<script type="text/javascript">
document.getElementById('container').innerHTML='new text';

Its behaviour is inconsistent: in structures similar to the above, it may also close
the outer A element before the opening DIV tag (and re-open it after the second
closing DIV tag again), making the whole structure wholly standard compliant.

Naturally, the easiest way to avoid this is to create standard-compliant code.
But it may be useful to be aware of this feature of Firefox, just in case.

2 April 2010

Transparent Links Are Not Clickable in IE

Oh yes, I forgot. Although it works fine in Firefox, in IE(8) you can't click on a transparent link placed on top of something else if there is something below it. Take, for example, the following code:
<div style="width:100px;height:100px; position:relative;border:1px solid blue;">
<div style="width:100px;height:100px;">content<br />content</div>
<a style="position:absolute;left:0;top:0; width:100px;height:100px;" href="link"></a>

Which produces:


In IE, you can't click on the link above the text. (It may work fine elsewhere.) Interestingly, giving a background colour to the A element makes it immediately clickable:
<div style="width:100px;height:100px; position:relative;border:1px solid blue;">
<div style="width:100px;height:100px;">content<br />content</div>
<a style="position:absolute;left:0;top:0; width:100px;height:100px; background-color:red;" href="link"></a>


Hence a possible solution: create a transparent image, and use it as a background image of the A element. It will work as expected.

20 March 2010

Low-level error: jQuery fadeOut fails in FireFox

Another hard-to-debug error (possibly a mistake in jQuery, but might be something in FF as well) is that $().fadeOut may fail to actually hide the element in Firefox. I have come across this when I tried to hide a floated container that was the only thing inside another container. Adding a further sibling element, or removing the float immediately resolved the issue.

Duplicate content bug: text appears twice in IE7 and IE9

The double or duplicate content error is very hard to re-create and to debug. The symptom is that some content (usually text) appears twice on your screen, the second one usually in a margin. The two copies are, in fact, the same: selecting part of either copy will result in a highlight at both(!) places. Quite weird.

This error usually affects IE7 and IE8 in compatibility mode. I have found two things that can cause this:
  • A floated container with block-level content only. Try to put some small inline content into all containers around the affected area. Having no inline content can also cause vertical misalignment in the same browsers.
  • Two HTML comments following each other immediately. This can be tricky to spot, especially if you're using SSI includes.