tirsdag 28. desember 2010

Assigning restricted hotkeys (with the Win key) to whatever you like in Win 7/Vista

After installing Windows 7, I suddenly found myself unable to assign Win+Space to one of my most essential tools; Launchy. Thankfully, there's a registry fix:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\DisabledHotkeys

It's a simple expandable string containing all characters for which default Win-hotkeys should be disabled (it may not already exist, in which case you'll have to create it). In my setup, it contains a single space, meaning that the system hotkey Win+Space should be unbound and ready for anyone else to use. For example, had it looked like this:

" a13"

..then Win+Space, Win+a, Win+1 and Win+3 would not be bound and made available for other use. Remember to restart you computer for the changes to apply.

onsdag 25. august 2010

Oracle 9 and boolean values

Oracle has come a long way since 9, but there are still a lot of businesses using it. If you're one of them, and also happen to enjoy PL/SQL, you should be aware of the dangers of using boolean values as function parameters.

Now, we all know that you can't use boolean in tables - it's strictly PL/SQL-only. However, the blur between what's considered PL/SQL and what's not might get you banging your head against the wall without realizing what's actually the problem. As is my preferred fashion, I'm going to give you the bullet points:

  • Calling PL/SQL procedures and functions with boolean parameters within PL/SQL works without problems (of course)
  • Calling PL/SQL procedures with boolean parameters using EXEC works fine
  • Calling PL/SQL functions with boolean parameters using SELECT does not work
  • Calling PL/SQL procedures and functions using JDBC prepared statements and trying to bind a variable to a boolean value does not work
  • PL/SQL procedures and functions using boolean parameters with default values will work as long as you don't try to set them
  • Trying to make an int2boolean(..) function for use with SELECT statements won't work, since to the parser it returns an unknown datatype

It's not supposed to be easy, is it? Usually, the solution is simply to either

  1. Overload the function/procedure so that it accepts both boolean and int values (0/1 or whatever you like), or..
  2. ..skip using boolean altogether

This code shows some of it:

create or replace function bool_me(p boolean default false) return int is
begin
if p = false then
return 0;
elsif p = true then
return 1;
else
--p is NULL
raise_application_error(-20000, 'p is NULL!');
end if;
end;
/

create or replace procedure bool_me2(p boolean default false) as
begin
if p = false then
dbms_output.put_line('p is false');
elsif p = true then
dbms_output.put_line('p is true');
else
--p is NULL
dbms_output.put_line('p is NULL');
end if;
end;
/

create or replace function return_true return boolean is
begin
return true;
end;
/





SQL> set serveroutput on
SQL> exec bool_me2(true);
p is true


SQL> exec bool_me2;
p is false


SQL> select bool_me(true) from dual;
select bool_me(true) from dual
*
FEIL på linje 1:
ORA-00904: "TRUE": invalid identifier


SQL> select bool_me from dual;

BOOL_ME
----------
0


SQL> select return_true from dual;
select return_true from dual
*
FEIL på linje 1:
ORA-06552: PL/SQL: Statement ignored
ORA-06553: PLS-382: expression is of wrong type

tirsdag 24. august 2010

Network connections on Nokia S60

Do you have problems with network connections on Nokia S60 based phones? do you suspect that something is wrong with their implementation of HttpConnection? And perhaps SocketConnection too?

You're absolutely right. Forum Nokia won't tell you this (well, you can get some glimpses in for example KIJ001610 and KIJ000852), but you may be in a lot of trouble if you need to transfer large amounts of data.

I've done a lot of testing, and here's the conclusion:

  • The data you send using a HttpConnection is retained in memory. The VM will say it's gone, but Symbian won't. Send enough data and you get an OutOfMemoryError. This is regardless of the requests' size.
  • SocketConnection might be broken (see the knowledge base article mentioned above), but don't expect it to be fixed on newer models. This differs from device to device. N73, for example, works like a charm. N95 and 5800 do not.

So what do you do? Well, the only workaround is to

  1. Use SocketConnection (although this only goes for S60, remember)
  2. Make sure you keep the connection alive. Note that the server you're connecting to must also be configured for keepalive.
  3. Also note that keeping idle connections alive requires a lot more memory on the server.

Every time you open a new SocketConnection, you go one step closer to doom. "Doom" may occur after 70-100 times; I haven't tested it that thoroughly and it probably varies a lot between devices.

Hope this was of any help!