Archive for April, 2008

My Renewed Love for Virtualization

Wednesday, April 16th, 2008

Every once in a while I need to use windows centric applications at work. IE is the least of my problems since it seems to work semi-reliably under Wine. But sometimes I need to test things in a full Windows environment, or run into an app that is just to much pain in the ass to install on Linux. This is why in the past I commandeered an old decommissioned desktop barely capable of running WinXP and I plopped it under my desk as my “windows machine”. I would then rdesktop to it whenever I needed to something windows centric. The machine was aged, but it worked quite well when I had a really old and slow laptop. You could barely tell the difference between the two as they were both crawling at the same speed.

Now that I got upgraded to a much newer, and much nicer machine the difference between the two became noticeable and somewhat annoying. My laptop is set up as dual boot with Windows XP but since I can do 90% of my work from under Linux I have my whole working environment set up and ready to go when I boot Ubuntu. Rebooting into windows every time I needed to do something there would be silly - especially since I’m used to working in that two-machine mode anyway.

So I figured since my machine is several times powerful than that puny desktop, I could probably emulate it and get comparable and better results. When I tried virtualization in the past it usually performed poorly due to my hardware specs. So I never really used it extensively. It was more for novelty value - for example installing an obscure Linux distro in a VM to check it out. I never really used virtualization on a daily basis, because of the poor performance. My current laptop however seemed strong enough to be able to handle an OS that was not a huge resource hog. That security talk from last week gave me the final motivation to get it all together and actually set up an environment which I could use regularly.

I briefly talked with the security expert after his presentation and naturally we chatted about virtual machines since this was major topics he discussed. He mentioned he was all about virtual machines. For example, he said liked to keep his work and play environments separate. So when he took his work laptop home, he started a virtual machine in full screen mode and then did all his casual browsing and entertainment from there. He could install whatever he wanted without making the machine unstable, and didn’t really really worry about viruses that much since he could always just roll back to the last clean snapshot. So if this guy could do this, then so could I.

So I installed VirtualBox on my machine, then grabbed Windows 2k CD and created myself a virtual machine of my own. End result is that my 2.4 GHz dual core laptop with 2GB of RAM is able to comfortably run a Windows 2000 session. And by comfortably I mean that I’d be actually using both machines to do real work. So on the Ubuntu site I may have the following things running:

  • Kontact
  • Firefox
  • Komodo Edit
  • Several gVim sessions
  • Seveal open Konsoles
  • 2 rdesktop sessions

On the VM side I would have the following open:

  • Excel
  • Monarch
  • IE
  • Adobe Reader

Both environments remain responsive, and there is no sign of slowdown at any point. VirtualBox even has the so called “seamless mode” which removes the VM window and makes the program windows appear as if they were running natively. Kinda like Parallels on OSX. Still, the Windows apps in this mode are sort-of confined to a single virtual desktop (I usually work with 6 or 7) which limits the usability of this mode. Also, they only see the virtual file system, so after experimenting a bit I switched it back to windowed environment. I sort of like the clear separation - and the VM window almost feels like just another rdesktop session which works out great for me. And now I can literally take my “windows box” with me everywhere I go.

If you haven’t tried this yet, and you have the hardware for it I highly recommend jumping onto the virtualization bandwagon. If you are already on the bandwagon, let me know what OS’s do you run virtually and how you use them!

Women in CS

Tuesday, April 15th, 2008

Sometimes I wonder why there are so disproportionately few women in my field. What is it about Computer Science that sends most women running for the hills. I think this is a question that should be directed at sociologists more than at CS people, as it seems to be more of a social issue more than anything else.

I can imagine what scares people away from this field in general. There are 3 factors I can think off which make most people think long and hard about deciding on a career in CS. First one is of course the computer geek image which seems to be deeply socialized into every single individual at a very early age. Every cartoon, movie or video game always portrays the computer specialist as a pimpled geek with thick glasses and the canonical pocket protector. Every once in a while you will see a “hacker” in there who is hip, cool and awesome. But Hollywood hackers are always self taught whiz kids who hate the man and do not need some stinking degree from a university.

We always had this image problem - only exception was the brief period of the .com suck when creating static HTML pages was more profitable than selling crack, and having CS degree meant you were supposed to be disgustingly, filthy rich by the age of 25. So while the nerd image was still prevalent, it was sort of upgraded to “rich nerd” which, if you think about it was not that bad.

Right now we are in almost an opposite situation due to outsourcing. Popular opinion is that US based CS graduates cannot compete with their Indian counterparts who allegedly work for shiny baubles. So the new image of a CS graduate is a computer nerd with a pocket protector, flipping burgers at Mickey D’s because his job was shipped overseas.

The third and final strike against CS is the emergence of some sort of faux neo-ludism in the recent years. These days it seems to be fashionable, and in good taste to loudly declare your disdain for these damned computers. I’m always amazed at how many people are literally beaming with pride when they tell me they are computer illiterate. As if it was some sort of badge of honor. They almost want to be praised for their ineptitude and be reassured that their almost criminal ignorance of technology doesn’t really matter because “that’s why we IT guys are here”.

People also often brag about how bad at math and/or spelling they are, but if they produce a report full of typos or mess up the numbers for the last quarter no one will give them a break. This is why people use spellcheckers, calculators and proofread their work. But if someone is “bad with computers” they can royally fuck something up and no one will blame them because everyone knows “Bob is bad with computers”. Young people pick up on this message and see that if you never bother to learn technology no one will ever expect you to do certain things on your own, and will give you special treatment. In fact managers and high ranked official tend to be the most clueless and the most vocal about their lack of skill. So wherever they go they take a throng of IT people who make stuff work for them. This image is also very prevalent in the media and functions almost as the polar opposite of the typical geek image. So while CS people are nerds with no carrier prospects, the truly successful, beautiful and admired individuals tend to be computer clueless.

Put all of these things together, and you can probably see why CS admissions are so low, and are falling each year. Our field just has a really bad rep. We have no street cred so to speak.

What I find interesting is that men are able to shrug off these stigmatic stereotypes much more easily than women. Why is that? All the 3 factors seem to be equally discouraging for both sexes. Maybe some of the female readers could shed some light on this for us. I know there is at least one or two of you out there. )

After contemplating this for a little while, I think I have 2 potential answers. For one, CS has been historically a male dominated field. Most of the the big names out there, the most elitist, accomplished and widely renowned researchers of the past were mostly dudes. Therefore talented women are often up against tough and sometimes prejudiced competition in the academia. It is tough to get stuff published in more exclusive and prominent peer reviewed journals, if the reviewers often have preconceived notions about your abilities based on your sex. And let’s face it, old dudes may often have “conservative” world view and “old fashioned” beliefs about women, and the role of kitchen in their daily lives. Some ladies may consider this as a challenge and are invigorated by this potential opposition, while others shy away from this sort of unfair competition. So this is an important factor, but I don’t think it is the only one.

For example, I find it hard to believe that high school would girls decide not to take a computer science course because of the glass ceiling issue in the academic world. After all, male students tend to outnumber females in CS courses even at the earliest levels. So somehow we must be socializing girls to shun computer science at a very early age - perhaps even before they hear about it for the first time in school.

I think part of the issue is the strange double standards we have for little boys and girls. They are encouraged to take part in different activities, to take up different hobbies and play different games. This is why we have a whole bustling industry producing video games targeted mostly at young boys and adolescents. This has started changing in the recent years, especially in the console market. Still, boys are more likely to be more familiar with technology having played, installed and downloaded or even tweaked and modified many games before they ever get a chance to take a technology course in school.

But video games and their target market are only a symptom of this double standard. They only show that these traditional roles and behaviors for boys and girls are deeply ingrained in our psyche. Boys are almost nudged towards technology, and encouraged to tinker, play and explore, while girls are taught restraint and almost nudged away from it.

But this is just a speculation, not based on personal observation and not supported by any concrete data. I’m talking about this, because the real question we have all been asking for years now is: how to get more women interested in Computer Science. What do we have to do? How do we advertise to them? How to we draw them in?

Everyone seems to be talking about modifying the curriculum, or shifting focus away from this or that. But if girls are getting shunted away from technology right from the get go there is not much do. By the time they reach school age, where they can be exposed to computer science many of them can already be pre-programmed to dislike it. Perhaps we should be targeting parents and early childhood education programs instead.

It’s just a thought. What do you think? What is your take on this issue? I’d love to hear what the female readers have to say about this. Feel free to tell me I’m totally wrong ladies!

Update 04/16/2008 09:47:17 AM

After listening to several opinions on this I must conclude that we (and by we I mean men of CS) should stop trying to figure out how to attract ladies to this field, and just ask them. There are after all organizations for women in cs that among other things are working on this very cause on a daily basis. So what we ought to do is to ask them how we as representatives of the “majority” can help them in their efforts. If we just guess, and do things without consulting women themselves we might actually be counter productive and do more damage than good.

Generate Outlook Calendar Events with PHP and iCalendar

Monday, April 14th, 2008

The internal web application at my company tends to send out a lot of email notifications. Some of them are reminders about various deadlines. Recently I got a feature request to allow people to add these reminders as events to their Outlook calendar.

Outlook supports two calendaring formats vCalendar and iCalendar. I opted to go with the later one because it is an open standard and at least in theory should work with other calendaring applications. The apps which support iCalendar standard can export their events as .ics files which can be seamlessly exchanged between the applications. So my task was to generate such a file on the fly and either link to it, or attach it to the reminder emails.

You can actually serve the ics file directly from a php page by telling the browser you are sending it a text/Calendar mimetype. You do this by sending appropriate headers:

header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=calendar.ics");

This will force the browser to interpret the input as a ics file and will show the user the dialog asking him to open the file in an external application. Then you simply need to output the appropriate data in the iCalendar format, which is relatively simple. Here is a very simple event you can copy and paste into your PHP file:

header("Content-Type: text/Calendar");
header("Content-Disposition: inline; filename=calendar.ics");
echo "BEGIN:VCALENDAR\n";
echo "VERSION:2.0\n";
echo "PRODID:-//Foobar Corporation//NONSGML Foobar//EN\n";
echo "METHOD:REQUEST\n"; // requied by Outlook
echo "BEGIN:VEVENT\n";
echo "UID:".date('Ymd').'T'.date('His')."-".rand()."-example.com\n"; // required by Outlok
echo "DTSTAMP:".date('Ymd').'T'.date('His')."\n"; // required by Outlook
echo "DTSTART:20080413T000000\n"; 
echo "SUMMARY:TEST\n";
echo "DESCRIPTION: this is just a test\n";
echo "END:VEVENT\n";
echo "END:VCALENDAR\n";

This will generate an event called TEST to happen on April 13 2008. Note the fields which I marked as required by Outlook. This is important. They are not required by the iCalendar spec so some examples out there skip them. If you do however you will get this lovely error message when you open the file in Outlook:

Microsoft Office Outlook cannot import vCalendar file. This error can appear if you have attempted to save a recurring Lunar appointment in iCalendar format. To avoid this error, set the appointment option to Gregorian instead of Lunar.

Gotta love Microsoft and their through, meaningful error messages. In this case the message is absolutely meaningless and the problem has nothing to do with “Lunar appointments” whatever the hell those are. You are simply missing the METHOD, DTSTAMP and UID fields.

I used REQUEST for the METHOD field but you can also try PUBLISH and few others. As far as I can tell the difference here is how the calendaring application will present the opened file to the user. If you use REQUEST it will give them a button to Accept or Reject the event. If you use PUBLISH they will be asked to save or cancel. Either way is acceptable by me.

The DTSTAMP field is, as the name suggest the date stamp when this event request was generated. As you can see I’m generating it on the fly.

The UID is supposed to be a unique identifier for this event, for some internal use. It is recommend that the right hand side of the UID be the host name or some unique identifier for the domain. I’m not exactly sure what the significance of this field is - I suspect it may be meaningful in certain situations, where the calendaring app is internally sorting the data. As you can see I use the date stamp on the right, followed by a randomly generated number, followed by host name which is pretty much what they advocate in the spec. It should yield UID’s that are sufficiently unique for each event. Some examples out there just use 0 or 1 here which doesn’t seem to be following the specification, but nevertheless it works just fine when you test it. However I figured it’s better to do it right, rather than run into weird issues much, much later.

I think the rest of the fields are pretty much self explanatory, with exception of PRODID. That’s the funny one. It is supposed to uniquely identify the product which has generated this event. In other words it is the place to pimp out your company and your software. And yet, all the online examples use the same 2 or 3 strings, showing blatantly that most people just copy and paste a working example into their production code and then blog about it without ever actually bothering to read the spec itself.

This is how I did it. I’m sure there are more elegant ways to accomplish this, but my email reminders will simply link to an appropriate php page which will fetch relevant data from the database and build appropriate ics file. I hope someone out there will find this writeup useful. And if I see “Foobar Corporation” in the future writeups, I will know you copied from me, and didn’t even bother reading the rest of the post. )

Adobe AIR Linux Alpha

Friday, April 11th, 2008

At the beginning of the month, Adobe finally had a sudden bowel movement and defecated an AIR release for Linux all over the internets. Naturally it is an alpha release, which means some things may still be very, very broken.

If you don’t know what AIR is, chances are you also don’t know about Twitter, which means you have been living under a rock for the last 900 years. I’ll explain it anyway. AIR was designed to be a platform for lightweight desktop applications, and has been essentially hijacked by Twitter enthusiasts. The most notable applications running on this platform right now are Twitter clients such as Snitter or Spaz. I’m sure it has some other uses, but I don’t know them. The only AIR apps I have seen so far are Twitter clients, and clients for other Twitter like services. If you know some interesting non-twitter related AIR apps I would love to see some links.

I complained about this before but the selection of Twitter clients on Linux is piss poor. Go to Twitter Fan and just look at the linux section. We have two emacs based clients, a vim based client, one written in bash, one which is essentially curl+zenity, a gnome desktop widget, and two or 3 more clients which just wouldn’t work properly on my machine due to bugs or dependency issues. If you scroll up and down you will see that Windows and Mac have all these nice, shiny graphical clients rich in features.

I installed Linux version of AIR to see if some of the nice AIR twitter clients will work on Linux the same way they work on Windows. The answer is - sort of. I installed both of the clients mentioned above: Snitter and Spaz. Nice thing about Air is that the installation looks and feels exactly the same as on windows. So you get a very pretty graphical installer. I’m using Kubuntu (Gutsy) so the apps got installed in /opt which frankly is where I’d put this type of stuff given a choice. The installer also put shortcuts into my KDE menu, although they used the full package name which contained a very long checksum of some sort. Still, I’m not complaining - it works as expected.

It took me a little while to figure out how to uninstall AIR apps until I realized that they are actual deb packages. So you can easily remove the apps you don’t need using aptitude which is great news. Too bad they don’t let you know about this when you are installing apps. I had to go to their Linux FAQ to find out about it.

The apps are a slightly different story. You can look for yourself. Here is how Spaz looked for me:

Spaz under Kubuntu

You can see a little blue background on this shot - this is not because I did a sloppy cropping job, but because I wanted to show you that the drop-shadow transparency that some of these apps use is not working here. On windows the edges are nicely rounded and have that faded shadow effect. On linux you get the ugly opaque black border. I guess this is one of these features which was not implemented in in the Alpha release.

Spaz also had major problems remembering my username/password. It would keep it in memory for the duration of my session, but when I closed and reopened the app it prompted me to type them in again. Initially I thought it was because Spaz was trying to write some config file in /opt but that was not the case. I guess this is another Alpha related bug.

Snitter didn’t have this issue and remember my password correctly. It also had the same border issue but I already expected that:

Snitter on Linux

Snitter exposed a different AIR bug to me. Whenever the Snitter window lost focus (for example, when you switched desktops, or brought another window to the foreground) it would simply disappear. The process was still running but the window would simply vanish. Killing the process and running the app again solved the process but it was not efficient enough. I’m suspecting it was trying to “minimize to tray” but didn’t know how to integrate with the KDE tray I was using.

So while both applications are perfectly functional, the seem to be using AIR features which are still missing from the Linux implementation. This makes them to annoying to be of use to me on a daily basis. I guess I’ll have to wait for the fully featured version until I can use one of them. In the meantime I found out an app which actually works semi-reliably on linux. It’s Thwirl:

Thwirl on the Linux AIR Release

It doesn’t work perfectly though. You need to disable the “hide on minimize” option or it will vanish when you minimize it. Remember that AIR has no clue how to put apps in the KDE tray. This may actually work with Gnome - I don’t know. I haven’t tried it. The second issue is that the popup notifications are a bit wonky. If you get more than one, they sometimes end up one on top of the other. The fade effect totally doesn’t work for them either - they just start blinking and jumping around. I’ll need to see if it can be disabled. Either way, Twhirl is a winner on Linux. P

As a side note, I would love to know if you are currently using any other Air apps right now. Especially if it they are not related to twitter in any way. I’m wondering where this platform is going. )

Btw, iVenus - you wanted some screenshots so here they are. )

Update 04/11/2008 12:37:00 PM

Actually, I take it back. Twhirl also forgets my password. ( It does remember the username though. Whatever these two apps do to store passwords is apparently still wonky in the linux alpha.

Blinking Dash Returns with Vengance

Thursday, April 10th, 2008

Remember my blinking underscore issue from February? It’s back again, and I still have no clue what is causing it.

Quick recap for new readers - I have a peculiar issue with my windows machine. Sometimes I shut it down, and it just won’t boot back up again. The damn thing goes through POST diagnostic at the beginning of the boot sequence and then just displays a blinking underscore/dash/cursor in the upper left corner of the screen. Apparently that indicates “boot failure” of some sort/ The data on the drive is still intact, and can be easily backed.

If you look through the archives here, you will see that I tried just about anything. Every time this happens I disconnect all the shit from this machine with exception of the mouse and keyboard hoping this is one of those odd USB related flukes. I then boot into recovery console, run fixboot and fixmbr commands, recreate my boot.ini with bootcfg /rebuild, run chkdsk and etc. Sadly going these motions usually doesn’t do squat. The only reliable way to get the machine working again is to format the drive and reinstall windows from scratch. But as it appears this is also only a temporary measure. The problem keeps coming back.

I’m beginning to suspect that my disk is faulty but I can’t really prove it (yet). I have ran chkdsk on this volume so many times I think I’m going to wear it out soon. At one occasion it told me the drive had a irrecoverable error on it and wouldn’t even attempt to scan it. Rebooting seemed to solve that issue, and all subsequent scans went through without major problems. On some occasions it said it fixed some errors but there didn’t seem to be any show stoppers in there. Anyone can recommend good hard drive diagnostic tools?

I’m thinking that perhaps something funky is going on in the boot sector, or perhaps the windows boot loader region which is just to subtle or to odd for chkdsk to worry about. This is the only thing that I can think of - I have literally no clue what else could be causing this issue. Then again, my drive is not that old. If I remember correctly I replaced it less than 2 years ago - in fact, it may still be on the warranty. I might still be able to return it back to Seagate and get a replacement. I will have to look into that.

In the meantime I ordered a new larger HD (I was running low on space anyway). This time I went with Western Digital. Once the drive ships (probably Friday although knowing my luck it will probably be Monday) I’m going to plug it into the machine, reinstall windows one last time and see how it goes. If I never have this issue again, then it means it was definitely a faulty drive. If it comes back after a month, I will know it must be something else. In either case I think I should just start putting together a new gaming rig for myself.

Worst of this is that I had some spare time yesterday and was planning to use it to finish KOTOR and then start on the final review post about this game. It seems that I will have to hold off with that until I reinstall windows again. It’s kinda sad that I will have to install the game for mere 20-30 minutes of gameplay I have left in order. But it has to be done. I need closure! (