All Posts

Dispatching operations to UI thread in Silverlight

When programming on Silverlight it is quite common to create additional threads to handle background processing, client-server communication and similar non-interactive tasks. Quite often work of those threads also has to interact with the user interface (either it has to display a progress report or it simply creates objects that interact with the user interface eg. Canvas). Problem is, that trying to access GUI elements from any other than UI thread will cause Invalid cross-thread access exception and the program will stop.

Enumerate physical drives in Windows

Sometimes you need to find a list of all existing physical drives, so you can access them through Win32 device namespace for direct access. There is currently no WinApi call to do this, so device list has to be retrieved through QueryDosDevice call and then enumerated to find all PhysicalDisks. Here is an example in C#: // Native WINAPI functions to retrieve list of devices private const int ERROR_INSUFFICIENT_BUFFER = 0x7A; [DllImport("kernel32.

Convert OpenSSH private key to PuTTY private key for GitHub

Recently I started using GitHub as Git source control repository. I’m using Git Extensions for GUI repository management on Windows. When setting it up with GitHub I’ve followed the instructions in the GitHub guide and I ended up with my private SSH key generated in OpenSSH format. Problem is, Git Extensions uses PuTTY for SSH communication, which stores its SSH keys in different format. The solution is using PuTTYgen (bundled with Git Extensions) to load the private key (which is stored in id_rsa file in C:\Users\<username>\.

Simple division algorithm for ARM assembler

As I’m currently working on a compiler from a madeup language for compiler lectures, I had to find a rather decently fast division algorithm for ARM9, which is my target platform, since DIV command was introduced not sooner than ARM11 architecture. So I found a simple divison algorithm, that speeds up basic “school child” subtractive division with shifting: CMP R2, #0 BEQ divide_end ;check for divide by zero! MOV R0,#0 ;clear R0 to accumulate result MOV R3,#1 ;set bit 0 in R3, which will be ;shifted left then right .

Sabayon Linux 4.2, my take

Even though most people know me as a profound Linux critic, I’ve always been somewhat of a fan of Gentoo distribution. The greatest appeal of it was it’s rather simple and straightforward organization of configuration files and ability to customize the distribution to the tiniest of details. However, constantly waiting for portage to complete its compilation of source packages quickly grew tiresome on my slow server, not to mention that portage can be too bleeding edge for a server system, occasionally breaking important services.

Multi-touch on Windows

Multi-touch on laptops is a well-known feature of Apple portables, however it is a lot less known fact that MacBooks use practically the same touchpad hardware as other laptops and that other laptops are capable of multi-touch detection. Most portables use touchpads made from Synaptics and newer versions of those do have ability of detecting multiple fingers, however the Synaptics drivers have this feature turned off for marketing reasons. However it is possible to re-enable some of this functionality by using 3rd party software, the best by my experience being Two Finger Scroll project on Google Code.

Hardware troubles

Well, it seems my trustworthy server finally died completely and since I’m in Denmark I cannot debug the problem. So I moved this blog to another server. Side effect of this is that since I had to restore the posts, they all share the same publish date. Just a cosmetic problem :)

Debugging power problems in Windows 7

Powercfg utility is known at least since the time of Windows Vista, mostly for setting basic power options. However, in Windows 7 the powercfg gained new analysis modes, where it can analyze power consumption of the system, making it effectively powertop for Windows. Running powercfg /energy will start the energy analysis and store results in energy-report.html file in System32 directory containing results looking pretty much like these: Also, with powercfg /requests you can check what is currently blocking system sleep:

Application GUI to OS integration rant

I have no idea why exactly is it so hard to make sure a Java application integrates seamlessly into OS. Applications keep inventing their own file open dialogs (even though OS provides it’s own with your user settings), using their own graphical widgets and doing everything to kill user interface consistency. People, please read user interface guidelines for every OS you are targeting and make sure you conform to them. Even if that means that you need to write some OS dependent code.