Tuesday, July 31, 2007

Wireless, the eternal headache

New computer means re-installing operating systems, joy. Wireless hardware has always been a constant headache, no exception this time.

Netgear WG121 USB in Windows XP, I had to go through the following steps:
1) Plug it in.
2) When Windows recognizes it and wants to install drivers, you must "cancel".
3) Pop in the CD and use setup.exe to install drivers yourself.
4) Reboot.
5) When windows wants to install drivers again after startup, "allow". Let it search the HD for drivers automatically, it will find and reinstall drivers - from what I can see, it copies from and to the same location.
6) Reboot
7) The Netgear connection wizard pops up and wants to disable Windows' own management of wireless connections - "allow".
8) Wait a couple of minutes while seemingly nothing happens, until the wizard window hangs and stops responding, kill it with Windows process manager.
9) Reboot. Now you can start the wizard from the start menu and you can finally configure settings and start using connection.
10) Discover that the connection hangs while downloading large files - for instance the new Kubuntu 7.04 installation CD ISO.
11) Swear a lot, reboot, download the 2.0 drivers and firmware zip from Netgear's site.
12) Go into control panel, uninstall the original drivers and tools completely.
13) Reboot and repeat steps 3-9, this time with the 2.0 drivers.

Any deviation from these steps will make the driver installation fail and the hardware unusable, you will have to uninstall and restart from step 1.

Netgear WG121 USB in Kubuntu 7.04 Feisty Fawn: This is what I had to go through
1) Read that some people claim it works out of the box. Plug it in, notice that nothing at all happens, plug in long network cable borrowed from work instead.
2) Find the following page.
3) Do NOT download the packaged version of ndiswrapper through Synaptic/Adept package managers, use wget to download the latest version from Sourceforge.
4) Remember to unplug the hardware if you have plugged it in, having it in will cause installation to fail.
5) Compile and "make install".
6) After following instructions on page from point 2 above and nothing works (only one light on device is on, /var/log/messages says probe failed with error code -22) after hours of trying to recompile and modprobe different versions, Google. Try to find relevant information without clicking on links from Google keyword bombing spam scumbags. Eventually I found that Feisty has a regression bug - wrong Prism firmware is included in /lib/firmware for that kernel version. So, download the latest firmware compiled by the maintainer and overwrite one of the files in /lib/firmware/ with a completely different name.... I'd post a link to the detailed instructions of course, if I could find it again! I believe I read it at the Ubuntu bug forums.
7) Reboot, now it works... for around 30 seconds, when it locks up until next reboot. Google some more, find that other people have the same problem but no one has found a reliable solution.

Give up and install the PCI card I bought last time for this. I think it is a D-link card. The drivers for Windows are even more horrible than the Netgear WG121. I haven't been able to get it to work at all with Windows actually, but it works fine with Linux and ndiswrapper. So I have to have two devices, one for Windows and one for Linux.... Bleh.

Perhaps newer generations of hardware are better? Can anyone recommend something that works with a minimum of hassle with both Windows and Linux?

Tuesday, July 17, 2007

Good Chinese food in Stockholm

Unfortunately it is difficult to find good Chinese food in Sweden. I have read that there is actually a reclusive Swedish-Chinese millionaire who lends money to families who want to start restaurants, providing they follow his guidelines. In other words, many restaurants are parts of a franchise just like McDonalds, which may explain why so many of them look the same, have the same muzak, the same price range, and the food at them is so similar and tastes so bland.... To me they fill the price and quality niche between fast food joints and "real" restaurants.

The "Asian restaurant" syndrome is another pet peeve of mine by the way.... Instead of interesting fusions of kitchens with new crossover dishes being invented like in Australia for instance, in Sweden we get generic "Asian" restaurants where sushi restaurants have started to include a few standard Thai dishes on the menu, Chinese restaurants always have some bad sushi, and so on. You get a lot to choose from but very little that has been cooked with any passion or finesse.

Enough negativity. Here are few tips for some better Chinese restaurants in Stockholm:
  • Lao Wai is a small vegetarian restaurant and definitely number one on my list. They always use authentic and fresh ingredients, for instance Chinese rice wine instead of sherry, never canned products or powders. They import Oolong tea from their own plantation and so on. They cook and serve orders to the table one at a time to be eaten immediately, so you will get the best experience if you share dishes with your friends the traditional way. They have tofu that tastes just like smoked sausages or chicken, so even meat eaters who normally don't like vegetarian food should enjoy it.
  • Formosa is the best one in Gamla Stan (Old Town) that I know of. Very crowded with Chinese tourists who come by the busload. Noodle soup with meat, shrimp and pak soi is my favourite.
  • Ming, just next door to the Crystal Plaza hotel used be really good, but I haven't eaten there in a while and I read in the papers that their star chef from China didn't get a renewed visa despite protests from the management of the restaurant and the hotel, so I'm not sure if it is still as good as it used to be.
  • Dragon House at Hornstull. This is a restaurant that gets very varied online reviews, from full marks to none, so either a competitor is trying to discredit them with a smear campaign or they have different chef teams with wildly varying skills. I have never been disappointed, but I always order from the special "traditional Chinese" menu and stay away from the buffet, the Thai food and the sushi. I recommend the small spicy chickens (beware of sharp bones though as they don't fillet the chickens, they just chop them up traditional style bones and all with a big meat cleaver) and the seafood pots with Chinese mushrooms (Seven Thunder Seafood I believe one is called). For the brave, they also have dishes like pigs stomach or crispy fried tripe with szechuan peppers (I don't know why so many are queasy about it though, the same people happily eat sausages after all). This is another restaurant where you should go as a big group and share the dishes with one another.

Wednesday, July 4, 2007

Opinions about Ruby

I have been reluctantly been forced to admit that some of the stuff you can do with Ruby is pretty damn cool. Now that I have had to try to debug a non-trivial (to me at least) application, I feel I can have an opinion on Ruby, and do this based on experience rather than prejudice.

First of all, documentation is poor for many libs. This is something that was raised at one of the general sessions at RailsConf 2007 in Portland, and got a very loud applause. I'm not just talking about tutorials or examples, many of them lack even minimal rubydocs. Many of them also do very little logging.

Secondly, I like checked exceptions. There, I've said it. This particular application failed silently somewhere, and from the few things I could get from the logs it seemed like a problem with SSL. After messing around for days trying to get this to work, I noticed something odd. At one place in the code, I had this:
@@services[wsdl_class].wiredump_dev = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log")
@@services[wsdl_class].options['protocol.http.ssl_config.verify_mode'] = OPENSSL::SSL::VERIFY_NONE

Now, if you switch around those lines, you get something funny, the wiredump logs aren't written. In fact, you could change it to
@@services[wsdl_class].options['protocol.http.ssl_config.verify_mode'] = blahblahblah
for the same effect. This is what finally clued me in to what was going on. In a completely different place in the codebase, the "model" code that fetches the SOAP object does a begin/rescue, assuming that any exceptions that occur are network related. I think that this was a valid assumption when the code was written, but later on some code had been refactored and some meta-programming magic goes on in a sub-lib to generate convenient helper classes and methods, and if you have a bug there, the generated exception is also silently swallowed and discarded. And this was application code by a very experienced programmer. Once other less experienced Ruby programmers (like me!) starts to mess up the code it quickly gets very difficult to understand what is going on.

True, you can sprinkle your code with
try {
} catch (Exception x}
{//Ignore}
in Java as well, but I believe this is rarer or mainly done by beginner programmers. Some very good frameworks to it too, but generally wrap the exception in their own layer appropriate exception and passes it on. Knowing that introducing a new checked exception breaks client code does make Java code less malleable, but on the other hand it might make the lib developers more careful about how they structure the code, and reminds them when they have to handle exceptions that sub-libraries might throw themselves, and when they can wrap the the exception in another (layer appropriate) exception and pass it on. I might be wrong though, we'll see if my opinion changes as I learn more of Ruby and other languages.