Software Woes

Rants, tips and tricks

Tuesday, September 30, 2008

FBCon08 Sparky Auction

Here's the video of the part of Mad Auction, showing how well Sparky went...

Monday, September 29, 2008

Firebird Conference 2008

The conference was held in Bergamo, Italy. Here are some pictures from the city and the event:

FBCon08 Bergamo

Sunday, September 21, 2008

Memory usage of kernel modules

Today I got a reply on that question on the newsgroup I read, and it's really simple:

# slabtop
# cat /etc/slabinfo

I thought just to note it down here, so I don't forget.

Thursday, September 18, 2008

WinGit broken when merging

Problem is that git-var does not work when you type 'git var', but only when you type 'git-var'. So, the merge script bails out with message.

Fix: edit c:\Program Files\Git\bin\git-merge and change all 'git var' to 'git-var' and you're done.

WinGit version 0.2.

Stack Overflow

This is the first Web 2.0 application I would dare to call amazing. In case you've been on the moon in the past few days, I'm talking about

Idea is probably nothing new, but the way it is done is brilliant. What is it all about? Well, suppose you are a programmer like myself, and you run into some minor problem you cannot manage to solve using the 4 proven techniques of solving programmer's problems:

- look into manual
- experiment
- google
- try to restart

I just made this up, but I like it :)

Anyway, if you don't know how to solve it, the last resource is to ask a friend or colleague who might know. But, with StackOverflow, you get access to thousands programmers in the world, and some of them surely know an answer to your problem. And, since website is live with questions and answers all the time, you'll get the answer really soon. A typical use case for me:

- have a problem
- go to SO and post a question
- while I wait for the answers, I browse the existing questions and reply, vote, etc.
- I check back every once in a while to find the answer and test it right away in my code
- b.e.a.u.t.i.f.u.l.

This works simply because, while waiting for an answer, I managed to send replies to 5-10 other people. And once you get a critical mass, it's a ball that keeps rolling. Simply because you know you will get answers there.

And, of course, there's the whole rating, ranking and reputation (RRR?) system that gives you a warm feeling that while contributing to the general cause, you are building your image.

Wednesday, September 17, 2008

Git broken in Slackware 12.1

Actually, it works fine if you only do Git stuff. However, I tried to pull my Subversion repository using git-svn clone. And this is what I got:

Can't locate in @INC (@INC contains: /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/5.8.8/i486-linux-thread-multi /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/i486-linux-thread-multi /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i486-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl .) at /usr/lib/perl5/vendor_perl/5.8.8/ line 93.
BEGIN failed--compilation aborted at /usr/lib/perl5/vendor_perl/5.8.8/ line 93.
Compilation failed in require at /usr/bin/git-svn line 45.
BEGIN failed--compilation aborted at /usr/bin/git-svn line 45.

Nice. :(

Trying to find and install it turned out to be a nightmare - and I decided to wake up before spending more than 2+ hours trying to make this work. I'll just take the current state of SVN repository and import that into Git as a starting point... losing a year's worth of history.

Nevermind, life goes on. I hope Pat will fix this in next Slackware release.

VirtualBox review

I'm not using virtualization that much (every once in a while to test some software on different platforms), but I was a big fan of VMWare. Although some of it's components are a PITA to set up on Linux, it still works much better than QEMU (yes, with all the kernel drivers and stuff) and it doesn't require me to recompile my kernel like Xen.

However, there's a new kid on the block: VirtualBox. At first it didn't promise much, but that was only until I installed it...

Now, this is what I call USER FRIENDLY application. While I'm sure VMWare is great on Windows, on Linux its setup simply sux (in case you wish to only use freeware stuff). To get more to the point, VMPlayer and server tools are free. So, in order to use it like that, you can for example use QEMU's tool to create a blank .vmdk file and then run VMPlayer to install OS in it. Also, you need to answer a lot of useless questions during installation, and you need to extract host-tools (or whatever is the exact name, I forgot) from the server .iso file. But, that's not the main problem. First main problem is creating and editing .vmx file (by reading the instructions from the Internet?). Second main problem is creating the shared folders (i.e. a directory shared between guest and host OS). And the third main problem is switching between real CD/DVD ROM device and some .iso file (by editing .vmx file? Come on).

VirtualBox solves all these problems perfectly. Install is dead-simple. Creating a new image is only a few clicks in GUI (yes, even I'm a 'console' guy, I like slick GUI that makes stupid things - stupidly easy to do). Adding host extensions is a single click in the menu! Adding CD/DVD device or an ISO image is also dead-simple. And this brings me to shared folders. It is not hard to add one, but letting the guest OS know about it is not that easy. I had to look into manual for that one, and guess what: VirtualBox has one of the best application manuals I ever read. It's clear, concise and right to the point. It does not try to teach you how to turn on the computer like most of the 'generic' manuals out there, nor it tells you what's on the screen (we're not blind!). It gives the information a regular user would need, questions that might actually get asked.

Now, as I wrote, I'm not a hard-core VM user, so it might lack some advanced features I don't use. But, for a simple "test how my application works on this or that operating system" type of job, VirtualBox is perfect. IMHO, it's the best VM product for the Linux Desktop.

Thank you Sun, for making this gem open source.

Tuesday, September 16, 2008

wxGrid with virtual storage and multirow or multicolumn cells

I'm working on a project that uses wxWidgets as a GUI library. In it, I have a grid (wxGrid class) that has some of the cells that span multiple columns. Now, it's very simple to make it work when you have a regular wxGrid. But, when you use virtual storage, you need to go through some steps to make sure multi-column span is done right.

There is no documentation on how to do this, so I first googled, and failing to find the explanation like the one I'm about to write now, I experimented. Finally, when some things just didn't work right, I had to dig into the wxGrid code to find out what is the correct way to do it.

If you ever used virtual grid, you know that you need to have a class that derives from wxGridTableBase. I have it, and in my class I override the function GetAttr to get various effects at runtime (saving both on memory and speed). In this function you can set the cell attributes (color, font style, etc.) by reading the info from your own virtual storage (this can be very useful if you want, say, negative numbers to be red). Anyway, in this class you use an object of class wxGridCellAttr, set its attributes and return pointer to it. Make sure you use cellAttriM->IncRef(); before exiting, since the caller will call DecRef() after using the info to render the cell on screen.

Now, on to the cells that span multiple columns or rows. To create a cell like that, you need to set the attribute for that cell, but also for all cells it 'covers'. All this is done via SetSize() function on wxGridCellAttr object.

Let's take for example a cell that spans one column and two rows: a cell at coordinates (3,5). This means that cell at coordinate (3,6) would be covered by this. So, for the cell at (3,5) you need to use:

cellAttr->SetSize(2, 1);

and for the cell at (3,6), you need to use:

cellAttr->SetSize(-1, 0);

This -1 and 0 is crucial for selection and cursor movement to work correctly. If your cell spans even more cells, you need to SetSize for all of them. For example, if the cell in above example would span 3 rows, the row at (3,7) would need to use:

cellAttr->SetSize(-2, 0);


Hopefully, something like this will be added to wx manual one day. Until that happens, read my blog ;)