2008/06/14

Last.fm event shoutbox feed - my first Greasemonkey script

I've just uploaded my first Greasemonkey script to userscripts.org. It is called Last.fm event shoutbox feed and can be downloaded from here.

It allows to follow the conversations in Last.fm event shoutboxes easily by subscribing to feeds created for them ('out of the box' Last.fm does not provide feeds for shoutboxes, my script uses hAtom to Atom/RSS transcoder).

Below you can see how it works.



UPDATE:

The script does not work with the new Last.fm, because the microformats were dropped during the re-design.

2008/05/01

Calling a .NET library from a VB6 application

Calling a .NET library from a VB6 application is pretty easy. There are many resources explaining how to do it (e.g. 1, 2, 3, 4). However, all of the (or at least the ones that I have read) forget to mention that, if you are using C#, there is a catch - the assemblies created in C# have a ComVisible attribute set to false by default. This simply means that they cannot be called from a VB6 application.

To change it open the AssemblyInfo.cs file, find the following line:
[assembly: ComVisible(false)]
and change it to:
[assembly: ComVisible(true)]

2008/04/29

Error "Unable to connect to SQL Server '(local)'. The step failed."

If you are using SQL Server 2000 and you have a job with a step that fails with the following error message:

Unable to connect to SQL Server '(local)'. The step failed.

it may mean that this step is configured to use a database that existed when the step was created but has later been dropped.

Moreover, if you don't remember what database this step should use, checking the step definition in Enterprise Manager won't reveal the cause of the problem, because there will be some database selected in the Database combo box (it cannot be empty) but it won't be the same database that the step is really configured to use (this database does not exist so it is not in the combo box).

To fix the problem select a new database for each failing step and save the changes.

2008/04/28

No Back and Forward buttons in Firefox 3

If you use as minimalistic version of Firefox as I do (which means that the Navigation Toolbar is hidden and all the buttons are moved from it to the space next to the address bar), after installing Firefox 3 you will notice that not only are the Back and Forward buttons missing but also you cannot add them from the Customize Toolbar window.

This is because the buttons are already added to the interface but they are not visible because the Navigation Toolbar is hidden.



Of course, the a Back/Forward button (two separate buttons from previous versions have been replaced with a single one) can be moved from the Navigation Toolbar to the place of your choice.

I encountered this problem after upgrading Ubuntu 7.10 (Gutsy Gibbon) to Ubuntu 8.04 (Hardy Heron), but it has nothing to do with Ubuntu. It is caused only by the fact that old Back and Forward buttons have been removed and a new Back/Forward one has been added. And it is placed in its default location (which is the Navigation Toolbar).

2008/03/27

Shrinking an outsized KeePassX/KeePass database

There is an error in KeePassX (and there was a similar bug in KeePass, too) that can cause the database file to grow at a very rapid pace (I don't know what triggers this growth). To be precise, the database size doubles every time it is saved even if a very small change is made.

My database reached 256 MB. KeePass running on Windows XP could not open it (because of an Out of memory error) while KeePassX on Ubuntu could open it but it was taking a few minutes. But the main problem anyway was the fact that I couldn't add new entries or make any changes because the file would grow again.

I tried to shrink the file by saving it as a new database or exporting and then importing it, but it didn't work. I also tried to find a solution on the Internet, but I only found an information that there was such a bug and it was fixed in Windows version. So after a few days I downloaded the KeePass sources, spent half a day (it's been a long time since I last saw a C++ code :) first trying to make them compile (I didn't have a libboost_regex-vc80-mt-sgd-1_34_1.lib library file; I installed it with BoostPro Binary Installer for Visual C++ - take a look here and here) and then trying to find a place in the code where the individual entries get loaded. :)

Finally, it turned out that the problem was caused by an attachment which was taking almost all space in the database file (it had a few KB when I attached it some time ago).

So I placed a line responsible for loading the attachment inside a try... catch... block and added a message box.
try
{
pEntry->pszBinaryDesc = _UTF8ToString((UTF8_BYTE *)pData);
}
catch (...)
{
AfxMessageBox((CString)"There was a problem with reading pszBinaryDesc " 
+ (CString)"field of " + pEntry->pszTitle + (CString)" entry.\n"
+ (CString)"This data has been LOST. However, you can now save the "
+ (CString)"database as a new file and its size should be normal again.", 
MB_ICONEXCLAMATION);
}
Thanks to this if there is a broken (outsized) attachment in some entry, an exception is thrown (important: if you try to run KeePass on Linux using WINE, this exception will not be thrown) and KeePass skips loading it and informs the user that such a problem occurred. Be aware that I didn't find a way to restore a broken attachment so some data is lost, but the database can be opened and saved as a new database. The new database has a normal size.

If anyone has a similar problem, let me know - I can e-mail modified sources or a compiled EXE file.

UPDATE:

A tip from an anonymous reader:
I was able to get around the same issue and shrink my keepass database via "File" -> "Export To" -> "KeePass Database" in v1.14. Using "Save As" wouldn't do it, but exporting did the trick!

2008/03/03

Invalid 'Remote table-valued function calls are not allowed' message error

Assuming that [11.99.120.12] is a linked server created on a SQL Server 2005 computer and pointing to a SQL Server 2000 computer, executing a simple query like this:

  SELECT *
  FROM [11.99.120.12].SALES_DB.dbo.ORDERS (nolock)

will fail with the following error message:

  Server: Msg 4122, Level 16, State 1, Line 1
  Remote table-valued function calls are not allowed.

This error message is not correct, since ORDERS is a table and not a function.

This query will run correctly only if the WITH keyword is used before the (nolock) hint:

  SELECT *
  FROM [11.99.120.12].SALES_DB.dbo.ORDERS WITH (nolock)

This problem is also discussed here.

2008/02/03

What I recently learned about casting an empty string (T-SQL)

SELECT CAST('' AS money)
-- .0000

SELECT CAST('' AS decimal(19,4))
-- Server: Msg 8114, Level 16, State 5, Line 1
-- Error converting data type varchar to numeric.

2008/01/10

Error when attempting to change a revision description (Subversion)

If you cannot modify a revision description in Subversion (SVN) because of the following error:

Repository has not been enabled to accept revision propchanges;
ask the administrator to create a pre-revprop-change hook

(or 'almost in Polish' ;)

Repozytorium nie ma włączone możliwości zmieniania atrybutów;
poproś administratora o utworzenie skryptu hook pre-revprop-change

it can be solved by creating an pre-revprop-change.bat file (in case you are using Windows) in the hooks directory of the repository. Of course the file does not have to be empty, it can do something like logging information about changes being made (because Subversion's revision properties are not versioned).

UPDATE:

On Windows 2003 BAT files cannot be empty - see here.