Tuesday, April 21, 2009

Finally: One language, three worlds.

Eureka. At last. With the release of the System.Windows.Forms assembly for Mono a dream comes true. Well, this sounds a little over the top but it felt like that the first time I got my 'SimpleTerm' application running on Ubuntu. SimpleTerm is C# application for serial port (RS232) communication that I originally created for the PocketPC using SharpDevelop. By using only CLR functions that are available in the Compact Framework I could build an application that runs on a PDA and a desktop, unchanged!. So it was exactly the same bytecode on both platforms. Now this does not work on the Mono platform (although there seems to be a way to patch the bytecode itself) but after I imported the project into MonoDevelop and just compiled it, it actually worked ! Which could be considered as a breakthrough merely for the fact that it supports serial communication !. So it's not just a 'Hello World window' with an OK button but its a real application that even supports the most underappreciated form of digital communication. And I say 'underappreciated' because the RS232 specification was established in 1969 and it has been the main form of communication between computers for over 35 years. But it is only since the release of System.IO.Serialport in version 2 of the CLR that serial communication is really supported out of the box in a mainstream development framework. I know this is not an issue for most people, but if you are working with instruments and microcontrollers whose only means of communication is still plain RS232 it is a real revelation.
The image shown here is a combination of three screenshots, one of a PocketPC emulator, one from an Ubuntu system running within a virtual machine and one from a 'standard' Windows XP computer. The text in the main window of the application shows the result of a call to 'Environment.OSVersion' which indeed reports the operating system and version on all three systems.

Saturday, March 14, 2009

Creative AdWords


Usually I feel the 'intelligence' of Google is impressive. Almost every search I do leads me to the right pages within the first two or three results. And the ads shown on the right of the search pages are also often remarkably relevant. That's why the WTF page shown here really surprised me. (Yes, you hae to click on it to see the details). I saved it as a screendump, since it is unlikely that you would get the same results if you visited the original article now.
On the other hand, the WTF site is definitely a site for real nerds, so the first ad ('How To Pick Up Girls ?') might be in the right place after all.
For those of you that do not master the Dutch language: ad 3 and 5 both lead to shops that sell underwear. Clearly AdWords got mislead by the multiple occurrence of the word 'String' in the source code Which is strange if you realise that Google programmers are probably among the 0.001% of people whose first association to this word is 'string of characters'.

Friday, January 16, 2009

Is a €550,- Netbook still a Netbook?


With the introduction of the ASUS PC S101 you start wondering what the definition of a Netbook is. The S101 has a larger screen and a bigger keyboard and this of course is reflected in the price of approximately €550,-. Well, maybe I see it wrong, but for €550,- I can already choose from a myriad of different 'normal' laptops that already have a larger screen and keyboard. And way more storage capacity than the internal 32 GB SSD of the s101.
ZDNet defines a Netbook as 'A subnotebook computer that costs less than US$400 and incorporates an Intel Atom microprocessor'.
I would add to that the following:
- Weight less than 1.5 kg
- Runs from batteries for at least 4 hours
- Wifi
- Solid state disk
- Maximum 10 Inch screen

That's a netbook, or else it should just be referred to as portable computer.

Thursday, December 18, 2008

The Netbook Marketing Miracle


Once again proof that you should never be too sure about what the market does is shown in this article Based on his experience and market research the author very clearly proves that computers like the current generation of Netbooks never were and never will be successful. The funny thing about this is that is was written Michael Mace, a former employee of Palm Computing. And the company that is publishing it (Rubicon) actually advertises to be an expert in marketing. Now I'm not saying this company is not good at their work. It's more proof of the fact that nobody ever can predict what sells and what not. The most frightening thing for marketeers should be the fact that the product this article refers to (the Palm Foleo) was introduced in 2007 and was considered a flop end cancelled even before it was was ever sold. Yet it's difficult to see the difference between this box and the ASUS EeePC 700 which was introduced only a few months later. And a year after that Netbooks are responsible for almost 30% in all computer sales. So I wonder what Palm CEO Ed Colligan thinks when he reads back his this announcement.

Tuesday, November 18, 2008

Fun with shrinking URL services


Actually I was never even aware of the fact that there are services that allow you to abbreviate URLs. Until I stumbled upon them in Twitter. (Also a service I was not aware of, but that's a different story) Apart from the obvious 'Why Did I Not Think Of That' moment, the second thought that came to me is that it would be fun just to type in random combinations of letters, and see where it gets you.
So I started with rurl.org/aaa to find out what the best fishing spots are in Russia.
And I cannot read rurl.org/zzz , but somehow I think it has something to do with a jubileum.
Even funnier it is to use combinations that have a meaning, like my initials: rurl.org/caj which bring you a surprising technical paper by Scott Hanselman.
And of course rurl.org/sex , which does not bring you what you might expect...

(And if you want to know how it works, check out this article by Jeff Atwood)

Monday, November 03, 2008

Chair or no chair-man..

Not at all related to any of my blog entries, but just too funny to let it pass by unnoticed. This Chairman of the South African Finance Portfolio Committee proves that the national tv station indeed lacks the money for maintaining it's furniture.

Wednesday, October 22, 2008

Would you trust anyone with your passwords ?


For a while I've been using the Foxmarks Firefox extension. It's an excellent way to keep all your bookmarks in sync on every PC, even on my EeePC with Firofox under Linux. Once installed you can almost forget about it and it just does what it has to do in the background. Great. And then recently there was an automatic upgrade that asked me the following question : 'Do you want to use the Password Sync feature ?'
So I could synchronize my 100+ passwords on all my PC's too ? Great, I thought for a few seconds. Until I realized that this would imply that everytime I log on all my passwords are send to a central server. To a place I have no idea where it is. Controlled by a company I almost know nothing about. The 'About Us' shows some reliable names, including the famous Mitch Kapor, who's known to have so much money that he really couldn't care less about my ample savings on a foreign Iceland bank account. But what about the others ?
Of course Foxmarks says the passwords are safely encrypted. True. But how can I check that ? Well, I could probably check that using some network-spy software and a lot of hard work. But even if I were a hardcore hacker I would do this only a once or twice. Certainly not every time I use the service (then I would be better off by writing all my passwords on the back of my hand every day..).
And a year from now I probably don't even realize that I'm still using this feature. and the plug-in is updated automatically. So if for example a year from now update 30.134 is installed, and by accident this plug-in 'forgets' to encrypt the passwords ? Or it uses some type of encryption that is easy to decode by the Foxmarks programmers. Who may not be the same trustworthy team that founded the company in the first place as Foxmarks by then could have been purchased by a Nigerian Investment Company.

Friday, October 17, 2008

Silicone spray or Mortgages, both can kill the system

I'm not even sure Joel Spolsky thought of it when he wrote this article about the way commission based sales systems eventually always seem to backfire at the company, but the current financial crises is certainly the the biggest proof that this works on any scale...

Thursday, September 04, 2008

Speed up with Chrome

There is much buzz around the new Google Chrome browser. I suppose most of you have (like me) downloaded it, played around with it and then continued to use Firefox for everyday use. After all, the shiny clean look is impressive at first and the page preview look is fun, but the lack of (visible) UI elements and the fact you have to do without all your usefull plugins like Adblock, Foxmarks ,FireBug and Webdeveloper soon makes you return to Firefox.
And this is intentional. Chrome is not (yet) for everyday browsing. It's created as a platform for web-based apps. The importance of chrome is mainly in what you see in the image below.




These are the results of the V8 Javascript benchmark. The higher the score, the better. So yes, the Javascript V8 engine as used in Chrome performs roughly 30 times better than the engine in IE6. And this is really important these days, since Javascript is the engine that powers all these popular AJAX based web applications like Basecamp, Google docs, Flickr or Twitter. So, as predicted by Jeff Atwood in his article about Javascript, the speed of Javascript is going to be more important. And when you believe (as Google does) that the future of computing is in the browser, Chrome is the logical platform. What really surprised me though is that it lacks a 'full screen' function. After all that is what you'd really expect from a browser that is supposed to replace your desktop ?
And yet you still cannot launch any browser without having an operating system. And right now Chrome only runs on Windows...

Friday, August 22, 2008

Dreaming on: Chandler 1.0 released

You might not have noticed, but on August 8th, 2008 at 1:47 pm, Chandler, the ' "Note-to-Self Organizer", designed for personal and small-group task management and calendaring' finally came to release 1.0 ! Now Chandler is an Open Source project, and 80% of these projects probably never reaches this stage at all, but Chandler is a special case. It is created by the Open Source Application Foundation which was founded and and is sponsored by Mitch Kapor. The Chandler project is a unique example of where a project that has no deadline and an unlimited funding can lead to: unlimited development.
And no matter what finally comes out of it, the first three years of the project already gave us the magnificent novel by Scot Rosenberg : Dreaming in Code. A great book that may well outlive the software itself. It describes the development process from the initial idea upto version 0.7. Three years have passed then and Rosenberg realises he just has to draw the line himself and publish the book before the project is finished. And he was right. The book was written by the end of 2005 and so it has taken roughly two and a half years before they they finally came to version 1.0 . I'm glad he didn't wait for that, since by now I already read the book twice. I really recommend it to any developer, manager or just anybody using software (Yep, that's you by default, or you would not be reading this..).
Apart from it being really fun to read, it's description of ever shifting deadlines, continuously changing specifications and numerous code re-writes is so recognizable to me as a developer. Just check out Joel Spolsky's review to see what I mean.
And what about the software itself ? Well, I haven't tried it yet but the concept is great, though not as revolutionary as it might has seemed in 2002. As already mentioned in the book, 37Signals already provides most of the functionality as a web application. With all the benefits: no server maintenance, available everywhere through every browser and automatic upgrades.
But the Outlook / Exchange combination is still used in many corporate environments. And since Chandler is aimed at replacing that, they might still have a chance.

Thursday, August 21, 2008

Easy C


After reading this 'Daily WTF' I first laughed, but then I suddenly noticed the this particular line:
/* arithmetic operators */
#define MOD %

.. when I realised this actually solves one of my little annoyances that I had for as long as I program in C or C# : I never remember the 'modulo' operator !
Since it's not something you need everyday I always end up looking at some kind of standard C manual to find out what it was. And nine out of ten times I first hit a compilation error because I use the (non existent) mod(x) function. I think this has to do with the fact that the '%' sign is not in any way related to a 'real' mathematical operator like +, -, / or * . Probably the C language developers just felt that the modulo operation should be a keyword, and the % was the last unused character on the keyboard.
And what about the '==' versus '=' mistake, often marked as the most frequently made mistake in C programming ? Using just ' #define EQUALS == ' would really eliminate this type of error. So maybe there is something to say for this 'Better C'. If it helps you in writing programs faster because you it makes things look more natural to you, then why not do it like this ?

Wednesday, July 02, 2008

Serial communication on the EeePC

Whenever I get a new computer, or just anything that is programmable, my first thought is " Will it do RS232 communication ?" That's mainly because I'm working all the time with instruments and micro controller based systems whose main or only form of contact to the outside world is still plain 9600 baud 8N1 RS232 comms...
And for the EeePC the answer is yes.
I connected a fairly standard USB-Serial converter. This device is based on the Prolific 2303 chipset which is very common in most converters these days. The EeePC recognizes and starts it immediately, although this is not immediately obvious. The KDE desktop does not show any sign of activity, and there is no way you can even check it's appearance through the desktop. To be sure it installed, open a console and type 'dmesg'.
[Inline Rant]
(Don't ask me why almost everything on Linux requires typing 5 to 10 letter acronyms for tasks you never even knew existed.. [growisofs, nifd, mozplugger, fstab-sync ??? And these are just a few of the most popular commands.])
[Inline Rant End]
Well, if your USB converter gets recognized it will show up in the last couple of lines of text shown to you. And if so, it's available as /tty/ttyUSB0 (U-S-B-Zero). Now it's time to do something useful. First you will need a communication program, which is not available in the standard EeePC distribution (or 'distro') so you will first have to instal additional repositories: this entry on the eeepc wiki shows how.
Now just start the Applications->System->Synaptic, search for minicom, Cutecom or GTKCom and install it.
I started using minicom, but apart from this being a bit like going back to the eighties (It's a Procomm /Telix for DOS clone..), I could not get it to send what I typed. It did set the Modem Init string, and received all characters I was sending to it, so I assume my USB-Serial adapter works.
So I moved to Cutecom, and this works fine. Cutecom is pretty simple and straightforward, but that's merely a plus if you use it on the rather limited screen of the EeePC.


EeePC is here !


It's obviously the most desirable gadget of the moment. The ASUS EeePC with it's 7" screen, small but complete keyboard and it's beautiful 'Pearl-Shine' white finish. And it's also a real computer. 900Mhz Intel Celeron, 512 MB RAM, 2 Gigabyte flash hard disk, WLAN, Ethernet, VGA output and 3 USB connections make this little box a full fledged PC with capabilities one could only dream of a few years ago. It comes with a Linux OS, and it boots in something like TWENTY seconds. It has many pre-installed apps, like the complete OpenOffice suite, FireFox and Thunderbird, so 90 to 100% of your daily work is covered. And that's what it's for. I think if you buy it as a'multi purpose' desktop PC replacement and expect to work exactly like your WindowsXP machine you're missing the point (and you get rants like "I hate my EeePC"). Nobody complains about his multi media phone not being able to run OpenOffice. That's not what it was designed for.
On the other hand, if you are a geek like me and are tempted by the possibilities of this platform then there is plenty of room for experimenting. But I'll keep the original setup intact because that's really ideal if you want to get some work done in confined spaces like an airplane chair on a low cost flight..

Monday, May 26, 2008

Too hard, or a challenge ?

Quote:

'it's a fun programming exercise that you're doing because it's just hard enough to be interesting but not so hard that you can't figure it out.'

Never thought of it that way, but this is indeed the kind of project I like to do most. And if most programmers are like me they will always tend to bend a projects towards this edge. If it's too simple we'll add functionality that creates new challenges. And if it seems just to hard we try to figure a way around it (buying a third party library or let someone else do it..) so we can spend more time at the things we like, like the slow fading in and out of our super-fancy splash-screen...

Friday, April 25, 2008

Arcade Games

So I'm not the only one. I already tried to explain in one of my previous posts how I felt about Arcade gaming, but if you read Jeff Atwoods blog about the subject you know exactly. I could not have said it better.I think the only difference between me and Jeff is that he needed a car to get to the arcade, and I could go by bike...

Tuesday, November 20, 2007

The Mysterious Breakpoint

(Or how even Microsoft programmers sometimes forget to clean-up..)

While working on a piece of software that relied on a ActiveX control, I regularly found my debugger stopping at an address somewhere in memory that was not part of the program. First I tried to find out where the bug was, then I found that just continuing the program worked fine, and that there were apparently no side-effects. But it kept stopping there, no matter how much of the debugger features I disabled. So I decided to get into it a bit deeper and found out it always stopped at an address named 'DbgBreakPoint' in module NTDLL.DLL. It looked like it stopped on a breakpoint, but not one that I had set. And the 'Disable all breakpoints' option in the Borland C++ Builder debugger did not make any difference. It really looked like Microsoft forgot to remove a breakpoint from one of the most important DLL's in Windows. A bit of Googling made clear that this was indeed the case, and also that it was not easy to get around it. Patching NTDLL.DLL appears impossible since it is one of the most 'protected' core-pieces of Windows. If you try to modify it, Windows will just 'restore' it on start-up. And if you are clever and modify the backup copy it uses for this restoration, Windows just won't start at all...
So the only way around seems to 'patch' the DLL in memory after it is loaded by your program by overwriting the memory location containing the breakpoint with a 'NOP' instruction. Here is the function to do it:

void PatchINT3()
{
unsigned char NOP=0x90;
void* pNTDLL;
DWORD BytesWritten ;
FARPROC Address;
if (Win32Platform != VER_PLATFORM_WIN32_NT){ return; }
pNTDLL = GetModuleHandle("NTDLL.DLL");
if (pNTDLL == 0) {return;}
Address = GetProcAddress(pNTDLL, (LPCSTR)"DbgBreakPoint");
if (Address == NULL){ return;}
unsigned char Byte= *(char *)Address;
if (Byte != 0xCC) {return;}
try

{
if (WriteProcessMemory(GetCurrentProcess(), Address, &NOP, 1, &BytesWritten))
{
if(BytesWritten == 1)
{
FlushInstructionCache(GetCurrentProcess(), Address, 1);
}
}
}catch(EAccessViolation &E){}
//Do not panic if you see an EAccessViolation here, it is perfectly harmless!

}

I suppose anyone who got to here has enough knowledge of Windows programming to see how it works :-)
And so, by calling PatchINT3() at the start of the program the breakpoint is erased and won't show up again.
(Thanks to Peter Morris at HowToDoThings , who wrote the Delphi version that I translated here)

Monday, October 22, 2007

Serial Communication Trouble

Ever since the 'real' serial comport (the hardwired connector on the rear of your PC) has been replaced with all types of 'virtual' alternatives like IR ports or Serial to USB devices, it has been a cause for all kind of trouble. And I've seen many of them, but the one I found this morning was new to me. Suddenly one of the programs I've written myself showed 18 comports to choose from. Now the program uses a dedicated function to enumerate the available ports, so obviously I thought it had something to do with a bug in my software. Also because the 'Hardware manager' of the PC only showed the two comports that are actually available. On the other hand I found that some other software that uses serial ports showed the same behaviour.
So I looked at the registry ( HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM) to find out which port were actually registered. And this showed all 18 as \Device\VComxx, where xx is the port number. So obviously something was creating virtual serial com ports. But what? I did not add any hardware to my PC that could cause this, nor did I install any serial com port related software or drivers.
So finally I located in the System Properties -> Device manager under 'System Devices' two suspicious entries: 'NCF Virtual serial bus enumerator' and 'VXCOM port'. The first turned out to be the 'Nokia Communication Framework', something I installed long ago in an attempt to communicate with my Nokia phone. After searching on the web for the second one, I found only a few entries, but it seems this one is related to the Windows Mobile 6 SDK, which I indeed installed last week. And when I disabled this driver, the problem was gone.
Apparently VXCOM is a virtual com driver used for the SmartPhone emulator. Why it reserves 18 ports at startup, even though I never used this emulator is a mystery to me...

Sunday, September 09, 2007

Mouse toTrackball to Centipede


Born in '65, it's inevitable that I grew up playing arcade games in the local arcade, re-discovered the joy of the simple games of those days and found my way to the MAME project.
I downloaded the the MAME executable and a bunch of (illegal...?) games, and I carried it with me several years, copying it to every new PC, and occasionally playing some of my favourite games. What always created a slight itch was the fact that playing on a computer keyboard does not really come near the 'real arcade experience'. So, like many others.. I would love to build a real arcade cabinet, with real joystick, trackball, spinner and fire buttons. Of course I lack the time to build it, a place to store it and even time to play it, but the idea remains. Looking around I found several on-line shops that sell all necessary parts from controls to marquees to make it look exactly like the original, but adding it all together it gets quite expensive. Certainly controls like a trackball and a spinner are costly items. And actually a spinner does not seem like a difficult thing to make yourself, but I decided to start with the trackball, since I already owned this. It is a Wico-trackball that was manufactured in 1983(!) for the then popular TI-99 home computer. Actually this seems bad timing, since TI exited the home computer market by the end of '83... Well, I bought the trackball a few years later for a few bucks, and first interfaced it to my Commodore 64, but hardly ever used it. Since a trackball and a standard computer mouse (the ball type) are very similar I thought it would not be too difficult to combine the two and have a 'mouse compatible' trackball. Fortunately 'standard' mouses can be found in large piles lying around unused in almost every office, so I soon found a suitable Logitech USB type that no one cared about anymore. First I thought it should be possible to use the original optical switches of the Wico, and just wire these to the mouse electronics. But since neither the mouse nor the trackball switches have any type numbers stamped on them so I could not easily compare the connections and make a new routing plan, I decided it would be easier just to remove the switches from the mouse, and mount them inside the trackball, completely discarding the original trackball electronics. So I just removed the Infrared LEDs and the opto switches from the mouse board, mounted them on a piece of prototyping board, and re-wired them to the original contacts. The image here shows the result. Bottom right you see the original mouse electronics. Bottom left you see the piece of prototype board holding the LED and the opto-switch. Right top you see a little piece of the second board just before it's put in place. Top left you also see the contacts of the 'fire' button. The wires from this I just cut to the right length and soldered them to the rear of the switch that used to be the left mouse button.
And it works great!. Finally I can play one of my favourites (Centipede) the way it was intended. So now I'm ready to take the next step: build a 'Rotary controller' or 'Spinner' for my all time favourite game : Tempest .Right now I'm chasing another unused mouse...

Wednesday, August 15, 2007

The Big Step: Microsoft Visual Studio

So it finally had to happen. I purchased and started to use Visual Studio 2005. After using Borland C++ Builder for more than 10 years for all my Windows (and even DOS) programming, the Pocket PC platform turned out be the decision maker. From the start the only way to write programs for the Pocket PC platform has been through Microsoft. And they also made it very easy by giving away the free Embedded Visual Basic, followed by Embedded VisualC. But today, now everybody has a Pocket PC, none of these tools is being supported, and they also refuse to work with the new Windows Mobile 5 devices. Now this could be a great starting point for some Microsoft bashing, but actually I read some explanation on a MS-Developer blog that makes sense. Since the embedded versions where completely separate projects within Microsoft, the development and support started to suffer from the fact that the developers also worked on the commercial Visual Studio product. And it's just a fact of life that supporting a commercial product has a higher priority...
But I've written all my software using EVC 3 and 4. And so I struggled some time by using old PocketPC's for debugging, actually waiting for Borland to come up with the 'Delphi for PocketPC'. But I don't think this will happen for a while, and I even wonder if they ever will produce something for the PocketPC platform. So I finally had to get Visual Studio 2005 to continue supporting my embedded Visual C apps. Fortunately I could go for an Visual Studio 2005 Upgrade, because I already owned C++ Builder, making it a bearable € 250,-.
And now I must agree, the Visual Studio environment a a giant leap forward compared to the old EVC programs. The editor is much more up to date, it compiles faster, has a better debugger, and (surprise, surprise) also supports direct emulation on your desktop PC, even when your program uses ActiveX controls or external DLL's !.

Tuesday, May 01, 2007

Creating Q-Web

To visualise data that is related to geographical locations (e.g. the local weather) nothing beats a good map with some clear symbols that reveal data from a database. The following series describes my route towards a database driven ASP.NET application that shows data as collected by the 'Discharge measurement' stations. The company I work for (Qmetrix) supplies these stations to local water management authorities. They measure the flow of water in a river or stream, combine it with the water-level and the local depth-profile and calculate the total cubic meters of water per second that passes by.
First I needed a nice map. I used MapBuilder, the excellent tool to manipulate Google maps. Now what I need for the webpage is a image for the area of interest, for which I know the exact coordinates of the left-top and right-bottom corner. Here is how:
In MapBuilder first click 'New Map' and enter a (short) name and a description. Then return to 'Edit Map'. Disable the 'Automatic Zoom' feature. Make sure the area of interest is completely visible. (Find it quick by just typing the name and country of a city that that in the area in the "Location Search & Quick Navigation" box )
Click in the left top corner, this will show a blinking marker. Select a small marker type, type 'Left Top' in the 'Caption' box and click 'Add'.
Repeat these steps for the 'Right-Bottom' marker. Now click 'Save Center, Zoom, Maptype'. Select 'Map Controls' in the menu, and disable all visible features. Don't forget to click the 'Save' button at the bottom of this screen.
Now choose 'Preview' in the menu. It might be required to shift the map a little to get both markers in the right place.

If required you can go back to the 'Map Controls' screen, and increase the map width and height. Now if you don't want to include the Google and Mapbuilder trademarks you must make sure they fall outside the area as enclosed by the two markers. If the map is right, capture the whole screen, using a screen-capture utility or just [Shift][PrtScreen]. Load the captured image in an image editor, and cut out the exact area Top left to Bottom right. Save this as a new (.jpg or .png) image.
Now go back to MapBuilder, and make a note of the exact coordinates of Top-Left and Right-Bottom. (I usually just click on the markers, and Copy-Paste the 'Latitude' and 'Longitude' fields to a Notepad text file.)
While this text file is open you might also write down the exact sizes (in pixels) of the map image we just created. Usually this can be found using the image editor, but you can also locate the file in Explorer, right click it and select 'Properties'. Hidden under an 'Advanced->' button you find the exact size of the image in pixels.