<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:thr="http://purl.org/syndication/thread/1.0">
    <title>Common Sense 4 Common People</title>
    
    <link rel="alternate" type="text/html" href="http://www.commonsense4commonpeople.net/" />
    <id>tag:typepad.com,2003:weblog-541750</id>
    <updated>2009-07-04T20:25:03+03:00</updated>
    <subtitle>By Dimitris Staikos (aka BruteForce).
Common Sense is a relative thing. Everybody has his own interpretation of what Common Sense is. Considering myself a Common Man, I write about how I perceive things pertaining to Common Sense.</subtitle>
    <generator uri="http://www.typepad.com/">TypePad</generator>
    <link rel="self" href="http://feeds.feedburner.com/CommonSense4CommonPeople" type="application/atom+xml" /><entry>
        <title>Search is sick, Bing is the cure</title>
        <link rel="alternate" type="text/html" href="http://www.commonsense4commonpeople.net/2009/07/search-is-sick-bing-is-the-cure.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2009/07/search-is-sick-bing-is-the-cure.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-6a00d8341d80a253ef011570c30755970c</id>
        <published>2009-07-04T20:25:03+03:00</published>
        <updated>2009-07-04T20:24:11+03:00</updated>
        <summary>Oh dear... This article at http://www.ms...</summary>
        <author>
            <name>Dimitris Staikos</name>
        </author>
        <category scheme="http://www.sixapart.com/ns/types#category" term="Web/Tech" />
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.commonsense4commonpeople.net/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>Oh dear...</p>
<p>This article at <a href="http://www.msnbc.msn.com/id/31084838/">http://www.msnbc.msn.com/id/31084838/</a> is titled "Microsoft ads say search is sick, Bing is the cure". Cute...</p>
<p>But, didn't anyone tell them that the Chinese word "bìng" <font face="Arial">(<span style="FONT-FAMILY: Arial; FONT-SIZE: 15px">病</span>)</font>, which is pronounced with the 4th tone, very similar to the English pronounciation of bing, means "sick" or "to get sick"???</p>
<p>More than 1 billion people, people that seem to believe in things like lucky numbers and "bad" sounds, people that feel that the number 4 is unlucky because it sounds like "death", these people say "<span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Arial', 'sans-serif'; FONT-SIZE: 14pt; mso-fareast-font-family: PMingLiU; mso-ansi-language: EN-US; mso-fareast-language: ZH-TW; mso-bidi-language: AR-SA"><font face="Arial"><span style="FONT-FAMILY: Arial; FONT-SIZE: 13px">wǒ bìng le" (我病了) and they mean "I am SICK". And MS hopes to make bing a new verb for searching and have them type in <a href="http://www.bing.com">www.bing.com</a> every now and then to do their searches?</span></font></span></p>
<p><span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Arial', 'sans-serif'; FONT-SIZE: 14pt; mso-fareast-font-family: PMingLiU; mso-ansi-language: EN-US; mso-fareast-language: ZH-TW; mso-bidi-language: AR-SA"><font face="Arial"><span style="FONT-FAMILY: Arial; FONT-SIZE: 13px">Oh dear... I think I need another drink...</span></font></span></p></div>
</content>


    </entry>
    <entry>
        <title>Firewire Expert Blog</title>
        <link rel="alternate" type="text/html" href="http://www.commonsense4commonpeople.net/2009/05/firewire-expert-blog.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2009/05/firewire-expert-blog.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-67354715</id>
        <published>2009-05-28T07:03:31+03:00</published>
        <updated>2009-05-28T07:03:31+03:00</updated>
        <summary>Hi everyone, Some weeks ago I posted a link to some Firewire informational videos. Now there is an insiders' blog about the history and business decisions that affected Firewire's development, written by the man himself, James Snider the Executive Director...</summary>
        <author>
            <name>Dimitris Staikos</name>
        </author>
        <category scheme="http://www.sixapart.com/ns/types#category" term="Web/Tech" />
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.commonsense4commonpeople.net/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>Hi everyone,</p><p>Some weeks ago I posted a link to some Firewire informational videos. Now there is an insiders' blog about the history and business decisions that affected Firewire's development, written by the man himself, James Snider the Executive Director of the 1394 Trade Association. Jeff Cat is just a nickname that James is using. In an act of shameless promotion I would say that I think it is worth your time to check it out.</p><p>Oh, and here's the link: <a href="http://www.firewireexpert.blogspot.com/" target="_blank">Firewire Expert Blog</a> </p><p>Have fun!</p><p>Dimitris</p></div>
</content>


    </entry>
    <entry>
        <title>the BOOK OF est</title>
        <link rel="alternate" type="text/html" href="http://www.commonsense4commonpeople.net/2009/04/the-book-of-est.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2009/04/the-book-of-est.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-65256337</id>
        <published>2009-04-09T15:11:00+03:00</published>
        <updated>2009-04-09T15:11:00+03:00</updated>
        <summary>This is a superb book that I picked up for a second reading. I own a used copy but with some effort you might find it somewhere: The Book of est on wikipedia The Book of est on Amazon Here...</summary>
        <author>
            <name>Dimitris Staikos</name>
        </author>
        <category scheme="http://www.sixapart.com/ns/types#category" term="Books" />
        <category scheme="http://www.sixapart.com/ns/types#category" term="Common Sense" />
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.commonsense4commonpeople.net/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>This is a superb book that I picked up for a second reading. I own a used copy but with some effort you might find it somewhere:</p><p><a href="http://en.wikipedia.org/wiki/The_Book_of_est" target="_blank">The Book of est on wikipedia</a></p><p><a href="http://www.amazon.com/Book-Est-Luke-Rhinehart/dp/003018326X" target="_blank">The Book of est on Amazon</a></p><p>Here is a small excerpt, which as soon as I read some minutes ago, just knew I had to post it. Apologies for the use of offensive language (to those that requiring such apologies):</p><p style="margin-left: 40px"><em>Let me remind you before I go on that I don't want you to believe a word I say over this weekend, just listen. Because the reason your lives don't work is that you're all living mechanically in your belief systems instead of freshly in the world of actual experience. You don't look at reality and then construct conclusions, no. No, you did that decades ago. You ass<span style="font-size: 12px; font-family: Arial"><span style="font-size: 11px; font-family: Arial">w</span></span>holes are roboting through life with your conclusions, and with your conclusions developed decades ago you are constructing reality! No wonder you've lost all aliveness. No wonder your lives don't work.</em></p><p>Have fun!</p><p>Dimitris Staikos</p><p /></div>
</content>


    </entry>
    <entry>
        <title>Firewire Informational Videos</title>
        <link rel="alternate" type="text/html" href="http://www.commonsense4commonpeople.net/2009/03/firewire-informational-videos.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2009/03/firewire-informational-videos.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-64299301</id>
        <published>2009-03-18T10:05:10+02:00</published>
        <updated>2009-03-18T10:05:10+02:00</updated>
        <summary>Hi all, The 1394 Trade Association (www.1394ta.org) recently started a series of Firewire informational videos on YouTube. These are like "video FAQs", not full fledged tutorials. However, these videos are not made by "self-proclaimed" experts but by the 1394 Trade...</summary>
        <author>
            <name>Dimitris Staikos</name>
        </author>
        <category scheme="http://www.sixapart.com/ns/types#category" term="Web/Tech" />
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.commonsense4commonpeople.net/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>Hi all,</p>
<p>The 1394 Trade Association (<a href="http://www.1394ta.org">www.1394ta.org</a>) recently started a series of Firewire informational videos on YouTube. These are like "video FAQs", not full fledged tutorials. However, these videos are not made by "self-proclaimed" experts but by the 1394 Trade Association, so you are guaranteed that what you will see and hear is accurate.</p>
<p>Surely the 1394 Trade Association has "promoting 1394 technology" in its mission statement, but it is not a marketing organization. These videos are not marketing material, but answers to common questions about Firewire.</p>
<p>You can check them out at: <a href="http://www.youtube.com/user/FireWireExpert">http://www.youtube.com/user/FireWireExpert</a></p>
<p>Currently there are only a few, but if there is enough traffic then the 1394TA will decide to invest more time and money on this approach. Surely enough, you can understand that it takes much more time to prepare a video FAQ than typing in 20 lines of text on some web page.</p>
<p>Also don't hesitate to email them your questions, if you happen to have any.</p>
<p>Have fun,</p>
<p>Dimitris Staikos</p></div>
</content>


    </entry>
    <entry>
        <title>Digital Misfortunes: Off-the-shelf end-user product mafia</title>
        <link rel="alternate" type="text/html" href="http://www.commonsense4commonpeople.net/2009/01/digital-misfortunes-offtheself-enduser-product-mafia.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2009/01/digital-misfortunes-offtheself-enduser-product-mafia.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-61222386</id>
        <published>2009-01-12T18:12:02+02:00</published>
        <updated>2009-01-12T18:12:02+02:00</updated>
        <summary>Happy New Year everyone :-) Although I planned to kick off 2009 with a much more inspiring article, I finally couldn't help it. I bumped onto a Digital Misfortune of such proportions that it was just impossible to resist the...</summary>
        <author>
            <name>Dimitris Staikos</name>
        </author>
        <category scheme="http://www.sixapart.com/ns/types#category" term="Digital Misfortunes" />
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.commonsense4commonpeople.net/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>Happy New Year everyone :-)</p>































<p>Although I planned to kick off 2009 with a much more inspiring article, I finally couldn't help it. I bumped onto a Digital Misfortune of such proportions that it was just impossible to resist the temptation.</p>































<p>Either it's me who is totally stupid or indeed software nowadays is designed by a blood-thirsty sadist mafia that plans to rule the world by killing all intelligent beings, or to be more exact, leading them to willfully commit suicide by banging their head on a wall, unable to stand the stupidity that surrounds them any longer. Some rock band had a song called "Mandatory Suicide"; now I think I finally get their message.<br /></p><p>



</p><p>



About a year ago I bought a nifty HP Photosmart  C7280 All-in-One printer for my Vista PC. It was basically OK. Then at some point I installed Office 2007. All was well until the day that I tried to color some text, which is something I don't do all that often.































</p><p>Ooops… Word crashed… Vista suggested that it searches online for a solution, so I said who knows let's take some chances. I mean I never ever had any useful results from any of Vista's suggestions, but hope never dies.</p>































<p>Sure enough Vista was absolute in its verdict: This is a known problem caused by the HP drivers when an HP printer is the default printer. Please make another printer the default printer until a fix is provided by the manufacturer.</p>































<p>Wow64! Way to go HP! I mean how many users around the world would have this HP printer, on Vista and use Office 2007 all combined together? About a handful I guess, so they probably missed that corner case.</p>































<p>This explains the situation below, where Microsoft XPS Document Writer is sadly configured as my default printer:</p>































<p><a href="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef010536c887f7970c-pi" style="DISPLAY: inline"><img alt="HPConfig1" border="0" class="at-xid-6a00d8341d80a253ef010536c887f7970c image-full " src="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef010536c887f7970c-800wi" title="HPConfig1" /></a> </p>































<p>This of course means that every time I wanted to print anything I had to remember and select the appropriate printer from the print dialog. Usability nirvana!</p>































<p>Now, I bought just one printer. Why would the HP installer install two printers? Never paid much attention to it, but it is important later in our story so I make a bookmark of it here. I always printed with the "C7200 series" since the Fax was named in the same way, so I thought this is the best choice. This printer was intended for home usage, so not that much printing took place. </p>































<p>However there were two issues:</p>































<ul>































<li>For every page printed I would get an empty page. 































<li>All pages had the text "[none]" lightly printed diagonally across the page. Didn't bother me that much, so I decided to postpone fixing for later. </li>
</li></ul>































<p>I am not sure if you noticed the big picture:</p>































<blockquote dir="ltr" style="MARGIN-RIGHT: 0px">































<p><em><span style="COLOR: #ff0000; FONT-FAMILY: Trebuchet MS">I bought an off-the-shelf product, meant for any end user, made from an established brand and since Day One I had 3 major usability issues that rendered my product almost unusable.</span></em></p></blockquote>































<p>The day came and today I decided to fix the 2 problems that I could fix.</p>































<p>Searching the web for the empty page issue I came across a fantastic discovery. You actually have to open printer properties, Advanced tab, click the "Separator Page…" button, and on the little dialog that shows that there really is NO separator page click "OK"!!!</p>































<p><a href="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef010536bef4ca970b-pi" style="DISPLAY: inline"><img alt="HPConfig2" border="0" class="at-xid-6a00d8341d80a253ef010536bef4ca970b " src="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef010536bef4ca970b-800wi" title="HPConfig2" /></a>  </p>































<p>It shows up as <strong><em>empty</em></strong> but it is not <strong><em>really</em></strong> <strong><em>empty</em></strong> I guess. Of course I had gone that far on my own, but I have the bad habit of pressing "Cancel" on dialogs where I change nothing. Here comes the first banging of my head on the wall. Thank heavens I didn't click OK during my investigations. Then the problem would appear magically fixed and I would have to bang my head even harder!!!</p>































<p>So I just clicked OK and the "empty page" problem went away! Superb technology!</p>































<p>Before I move on, let's rewind one bit and see things from the simple user's perspective. When I first opened the printer properties and went to the Advanced page I got the following:</p>































<p><a href="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef010536bef7ad970b-pi" style="DISPLAY: inline"><img alt="HPConfig3" border="0" class="at-xid-6a00d8341d80a253ef010536bef7ad970b " src="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef010536bef7ad970b-800wi" title="HPConfig3" /></a>  </p>































<p>Clicking on the "Separator Page" button was kind of problematic in this situation... I thought that this must surely be an UAC-thingy although there is no little Vista UAC icon on the dialog indicating to me that this is the case. I started to investigate, but it seems there is no way to start up Control Panel as administrator. A little while later I noticed this:</p>































<p><a href="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef010536c88ef8970c-pi" style="DISPLAY: inline"><img alt="HPConfig4" border="0" class="at-xid-6a00d8341d80a253ef010536c88ef8970c image-full " src="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef010536c88ef8970c-800wi" title="HPConfig4" /></a>  </p>































<p>I was totally dumbfounded. The menu was right there all along, at the beginning of the menu, but I had never seen it despite the countless times I opened the Properties entry which was all the way down. Now doesn't that strike you as a bit odd? Not to mention the duplicate menu items! Way to go! I don't know about you but I tend to think that it would be wiser to have the UAC icon inside the tab pages, so that simply clicking it would enable all restricted functionality.</p>































<p>So problem one is <strong>gone</strong>. Now let's move to the diagonal "[none]" issue. Here starts the great fun. For starters I was sure this was not an MS Office thing. All apps would print this way. So it had to be in the printer drivers. First I meticulously and repeatedly checked all the options in the printer settings dialogs. I mean this is an obvious thing right? There should be some setting to control it. Nope. Then I opened the HP utilities. Still no luck. So I decided to search the web.</p>































<p>Although trying to search for pages containing the exact term "[none]" is quite <em>funny</em>, soon enough I found that the thingy printed on the background of my pages is called a "watermark", which of course I knew as a term but failed to reverse-pattern-match it. So the HP online help docs stated that I should have an "Effects" tab and from there control the watermark.</p>































<p>However my properties dialog looks like this:</p>































<p><a href="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef010536c894d9970c-pi" style="DISPLAY: inline"><img alt="HPConfig5" border="0" class="at-xid-6a00d8341d80a253ef010536c894d9970c image-full " src="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef010536c894d9970c-800wi" title="HPConfig5" /></a> <br /></p><p>There is NO "Effects" page! And of course none of the existing tabs had anything related.</p>































<p>Then I thought that my printer actually is a C7280 not a C7200. The property pages come from the printer driver so I thought maybe I could update to a more specific driver and get the page to show up. No luck there too.</p>































<p>Then, in a moment of genius unprecedented in the history of mankind (ok maybe I am slightly exaggerating) I thought "<em>What if I open up the property pages on the other silly C7200 printer?</em>". Surprise!</p>































<p><a href="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef010536c897b2970c-pi" style="DISPLAY: inline"><img alt="HPConfig6" border="0" class="at-xid-6a00d8341d80a253ef010536c897b2970c " src="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef010536c897b2970c-800wi" title="HPConfig6" /></a>  </p>































<p>Hey, this dude has an effects tab! Here is what it looks like:</p>































<p><img alt="HPConfig7" border="0" class="at-xid-6a00d8341d80a253ef010536c89937970c image-full " src="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef010536c89937970c-800wi" title="HPConfig7" /></p>































<p>Finally!!! The watermark settings are uncovered! However, if you think I was done, keep dreaming. I am talking about <strong>sophisticated sadism</strong> here. I click on the "Edit" button and get this dialog:</p>































<p> <a href="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef010536bf02f5970b-pi" style="DISPLAY: inline"><img alt="HPConfig8" border="0" class="at-xid-6a00d8341d80a253ef010536bf02f5970b image-full " src="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef010536bf02f5970b-800wi" title="HPConfig8" /></a></p>































<p>Under great exhilaration I clear the Watermark Message, click OK and off I go to print a page!</p>































<p>"[none]" was once again printed on the page, but I could only read "<em>You are a sad case</em>".</p>































<p>I reopen the properties, effects, watermark, and sure as heck the "[none]" text was still there!!! I couldn't believe my eyes! Did I accidentally clicked Cancel instead of OK? I tried again and again but this sadistic piece of software would allow me to delete the text of the entry only to bring "[none]" back from the dead every time... Both sad and sadistic...</p>































<p>So I said ok, I will enter a space and get it through. I couldn't see any other workaround on the dialog, they even disabled the Delete button. Or maybe I could set the text to a dot, the font size to 1 and hope no one notices :-D</p>































<p>As soon as I typed the space some magic happened:</p>































<p><a href="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef010536c8a1c4970c-pi" style="DISPLAY: inline"><img alt="HPConfig9" border="0" class="at-xid-6a00d8341d80a253ef010536c8a1c4970c image-full " src="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef010536c8a1c4970c-800wi" title="HPConfig9" /></a> </p>































<p>Wow64!!! The watermark message is the watermark name too, so now I have an invisibly named watermark.</p>































<p>Needless to say, <strong>this DID the trick</strong>.</p>































<p>I don't know about you guys but this is evident to me:</p>































<p><strong><span style="TEXT-DECORATION: underline">This is not moronic design</span></strong>. <strong><span style="TEXT-DECORATION: underline">This is intentionally sadistic design</span></strong>. </p>































<p>This is design made so that people get conditioned to expect they will need support services and of course once conditioned, also pay for them. Instead of complaining about the crappy product the users will turn into happy, support-paying customers.</p>































<p>No wonder I get so many calls from friends and relatives to "<em>visit them because they have such a long time to see me and oh by the way if I could look into one little problem we have with the computer"</em>.</p>































<p>But I have long gone past the stage where I dreaded these visits. If even I feel stupid and enraged after my encounters with these off-the-shelf end-user products, then they must probably feel much worse, so I better lend a helping hand.</p>































<p>Have Fun (while you still can)!!!</p></div>
</content>


    </entry>
    <entry>
        <title>Tips on writing C macros</title>
        <link rel="alternate" type="text/html" href="http://www.commonsense4commonpeople.net/2008/11/tips-on-writing-c-macros.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2008/11/tips-on-writing-c-macros.html" thr:count="2" thr:updated="2009-01-02T13:45:24+02:00" />
        <id>tag:typepad.com,2003:post-59258522</id>
        <published>2008-11-30T21:02:31+02:00</published>
        <updated>2008-11-30T21:02:31+02:00</updated>
        <summary>Macros in C/C++ is an extremely powerful feature, basically one I can't live without. The use of macros has been widely debated and mostly they are labeled as 'evil', as a no-no. This is the usual moral dillema that shows...</summary>
        <author>
            <name>Dimitris Staikos</name>
        </author>
        <category scheme="http://www.sixapart.com/ns/types#category" term="Programming" />
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.commonsense4commonpeople.net/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>Macros in C/C++ is an extremely powerful feature, basically one I can't live without. The use of macros has been widely debated and mostly they are labeled as 'evil', as a no-no. This is the usual moral dillema that shows up whenever we have something with significant power in our hands: Anything that is powerful enough can be misused one way or the other. Should we then allow the usage of the powerful tool or ban it altogether so as to prevent its misuse (intentional or unintentional)?</p><div>
</div>
<div>There is no one answer. As usual it depends on the issue at hand. For example, you don't teach lethal blows to a person that doesn't realize the consequences of inflicting such a blow (e.g. an eight year old), but you teach them to your special forces.</div><div>Anyway, macros have been very useful to me throughout the years but all too often I see some basic mistakes in their use, so I have to provide some guidance that countless others have offered before me, still it is worth repeating.</div><br /><div>The two most common mistakes with macros are depicted in the following two line macro:</div><br /><div><span style="font-family: Courier;">    #define MYMACRO(a,b,c) \</span></div><div><span style="font-family: Courier;">    a = b + c; \</span></div><div><span style="font-family: Courier;">    b = c*2</span></div><br /><div>The author intended the macro call to 'look' as one statement, so he omitted the semicolon from the last statement. This way when you write MYMACRO(x,y,10); the semicolon you added at the end completes the incomplete statement at the last line of the macro.</div><div>Sure enough this is valid usage of macro syntax, but incorrect in a larger perspective.</div><div>What if I write:</div><br /><div><span style="font-family: Courier;">    if (SomeLogicTest())</span></div><div><span style="font-family: Courier;">      MYMACRO(x,y,10);</span></div><br /><div>Oooops... This will expand to:</div><br /><div><div><span style="font-family: Courier;">    if (SomeLogicTest())</span></div><div><span style="font-family: Courier;">      x = y + 10;<br /></span></div><div><div><span style="font-family: Courier;">      y = 10*2;</span></div><br /><div>I am pretty certain that this is NOT what the author intended. So most people with basic training avoid this pedantic mistake and instead define the macro as:</div><br /><div><div><span style="font-family: Courier;">    #define MYMACRO(a,b,c) \</span></div><div><span style="font-family: Courier;">    { \</span></div><div><span style="font-family: Courier;">       a = b + c; \</span></div><div><span style="font-family: Courier;">       b = c*2; \</span></div><div><span style="font-family: Courier;">    }</span></div><br /><div>This pretty nicely solves the <span style="font-family: Courier;">if</span> issue, surely there is no harm done adding a semicolon after the closing bracket. Or is there?</div><div>What about:</div><br /><div><div><span style="font-family: Courier;">    if (SomeLogicTest())</span></div><div><span style="font-family: Courier;">      MYMACRO(x,y,10);</span></div><div><span style="font-family: Courier;">    else</span></div><div><span style="font-family: Courier;">      MYMACRO(y,x,20);</span></div><br /><div>With the 2nd definition above, the above if-else will not compile and the programmer might as well act pretty surprised as to why. The semicolon after the closing bracket in if essentially 'terminates' the if statement, so then the compiler sees 'else' as the beginning of a new statement. Not digestable.</div><div>Some people try to avoid this problem by always writing their multiline macros with brackets and then never put a semicolon when they use the macro. That is:</div><br /><div><div><span style="font-family: Courier;">    if (SomeLogicTest())</span></div><div><span style="font-family: Courier;">      MYMACRO(x,y,10)</span></div><div><span style="font-family: Courier;">    else</span></div><div><span style="font-family: Courier;">      MYMACRO(y,x,20)</span></div><br /><div>Works like a charm, but... it doesn't <span style="font-style: italic;">look </span>right. It doesn't <span style="font-style: italic;">look </span>like the rest of the code. And this is not good for several reasons that I will not go into here. However there is a surprisingly easy solution:</div><br /><div><div><span style="font-family: Courier;">    #define MYMACRO(a,b,c) \</span></div><div><span style="font-family: Courier;">    do { \</span></div><div><span style="font-family: Courier;">       a = b + c; \</span></div><div><span style="font-family: Courier;">       b = c*2; \</span></div><div><span style="font-family: Courier;">    } while (0)</span></div><br /><div>Needless to say, this will always work. It absolutely requires that the semicolon is not omitted because the do-block is a single statement that has to be terminated, and then since it is a single statement it can be followed by an else block without problems.</div><br /><div><span style="font-weight: bold;"><span style="text-decoration: underline;">RULE 1</span></span>: Always write your multiline macros using this pattern:</div><br /><div><div><span style="font-family: Courier;">    #define MYMACRO \</span></div><div><span style="font-family: Courier;">    do { \</span></div><div><span style="font-family: Courier;">       </span><span style="font-style: italic; color: #00bf00; "><span style="font-family: Courier;">macro definition here</span></span><span style="font-family: Courier;"> \</span></div><div><span style="font-family: Courier;">    } while (0)<br /></span></div><br /><div>The only trouble you might get with this, is some smart-a$$ code analyzer screaming about a '<span style="font-style: italic;">constant expression in do-while condition</span>'. That's usually easy to turn off by adding some comment-directive to your macro definition. Just make sure you only use <span style="font-family: Courier;">/*C-style comments*/</span> in macros ;-)</div><br /><div>So our original macro now looks like this:</div><br /><div><div><span style="font-family: Courier;">    #define MYMACRO(a,b,c) \</span></div><div><span style="font-family: Courier;">    do { \</span></div><div><span style="font-family: Courier;">       a = b + c; \</span></div><div><span style="font-family: Courier;">       b = c*2; \</span></div><div><span style="font-family: Courier;">    } while (0)</span></div><br /><div>What are the remaining troubles with it? What about the following invocation: <span style="font-family: Courier;">MYMACRO(x,y,x+y)</span></div><div>As you can probably see the <span style="font-family: Courier;">b = c*2</span> statement will now expand to <span style="font-family: Courier;">y = x+y*2</span>.</div><div>Ooops, most likey not what the programmer intended :-)</div><br /><div><span style="font-weight: bold; "><span style="text-decoration: underline; -webkit-text-decorations-in-effect: underline; ">RULE 2</span></span>: Always surround macro arguments with parentheses inside the macro body.<br /></div><br /><div><div><span style="font-family: Courier;">    #define MYMACRO(a,b,c) \</span></div><div><span style="font-family: Courier;">    do { \</span></div><div><span style="font-family: Courier;">       (a) = (b) + (c); \</span></div><div><span style="font-family: Courier;">       (b) = (c)*2; \</span></div><div><span style="font-family: Courier;">    } while (0)</span></div><br /><div><span style="font-weight: bold; "><span style="text-decoration: underline; -webkit-text-decorations-in-effect: underline; ">RULE 3</span></span>: Keep your macros SHORT. Don't write 50-line macros, because when the time comes to chase down some bug you will soon find out that the only debugger that could step into macro definitions (SoftICE) is out of business. To the best of my knowledge, even WinDBG, the Windows kernel debugger, cannot step into macros. So, keep'em short.<br /></div><br /><div><span style="font-weight: bold; "><span style="text-decoration: underline; -webkit-text-decorations-in-effect: underline; ">RULE 4</span></span>: Be very careful when trying to use macros for speed optimizations (i.e. save a function call). I have seen even senior programmers get it wrong, because they didn't realize that passing <span style="font-family: Courier;">MyArray[x+3]</span> as a macro argument would lexically copy this expression in multiple locations in the macro expansion, causing the generated code to needlessly evaluate <span style="font-family: Courier;">*(Myarray+x+3)</span> again and again and again. Always have someone else, preferably more experienced than yourself, check these 'optimizations' with you.<br /></div><br /></div><div>I will sum up with a super hot macro tip, that doesn't have to do with avoiding mistakes, but with a thing I needed a billion times but thought was not possible, only to find out about a year ago that it is absolutely doable: Macros with a variable number of arguments, officially called variadic macros.</div><div>Yes, they are doable and they have at least one important usage:</div><br /><div><span style="font-family: Courier;">    KdPrint(("Writing debug output macros that don't require %s %s\n, </span></div><div><span style="font-family: Courier;">                 "double parentheses",</span></div><div><span style="font-family: Courier;">                 "in each invocation"));</span></div><br /><div>The magic keyword (or whatever it is actually) is:<span style="font-family: Courier;"> </span><span style="border-collapse: collapse; color: #333333; line-height: normal; "><span style="font-family: Courier;">__VA_ARGS__</span></span></div><div><span style="border-collapse: collapse; color: #333333; font-family: arial; line-height: normal;"><br /></span></div><div><span style="border-collapse: collapse; color: #333333; font-family: arial; line-height: normal;">The sample Win32 code below shows it all in action:</span></div><div><span style="border-collapse: collapse; color: #333333; font-family: arial; line-height: normal;"><br /></span></div><div><span style="border-collapse: collapse; color: #333333; font-family: arial; line-height: normal;"><span style="border-collapse: collapse; color: #333333; line-height: normal; font-size: 11px; font-family: Courier; "><span style="border-collapse: collapse; color: #333333; line-height: normal; font-size: 13px; font-family: Courier; ">    #define DBG_PREFIX "[FrameGrabber] "<br />    #define FGTRACE(_fmt, ...) \</span></span></span></div><div><span style="border-collapse: collapse; color: #333333; font-family: arial; line-height: normal;"><span style="border-collapse: collapse; color: #333333; line-height: normal; font-size: 11px; font-family: Courier; "><span style="border-collapse: collapse; color: #333333; line-height: normal; font-size: 13px; font-family: Courier; ">         FGDebugPrint(DBG_PREFIX _fmt, __VA_ARGS__)<br /></span><br />    void FGDebugPrint(char *format, ...)<br />    {<br />       char    szMessage[1024];<br />       va_list VaList;<br />       va_start( VaList, format);<br />       vsprintf_s(szMessage, sizeof(szMessage), format, VaList);<br />       OutputDebugString(szMessage);<br />       va_end( VaList );<br />    }<br /><br />    int _tmain(int argc, _TCHAR* argv[])<br />    {<br />       FGTRACE("Hello %d %d\n", argc, 2*argc);<br />       return 0;<br />    }</span><br /></span></div><div><span style="border-collapse: collapse; color: #333333; font-family: arial; line-height: normal;"><br /></span></div><div><span style="border-collapse: collapse; color: #333333; font-family: arial; line-height: normal;">Note that in the macro definition above, I broke my own rule about parameter parenthesization, but I had to since I count on string token pasting to get my message prefix at the beginning of the debug output message.</span></div><div><span style="border-collapse: collapse; color: #333333; font-family: arial; line-height: normal;"><br /></span></div><div><span style="border-collapse: collapse; color: #333333; font-family: arial; line-height: normal; ">Have fun!</span><br /></div><div><span style="border-collapse: collapse; color: #333333; font-family: arial; line-height: normal;">Dimitris Staikos</span></div></div></div></div></div></div></div></div></div></div>
</content>


    </entry>
    <entry>
        <title>The code is THE documentation</title>
        <link rel="alternate" type="text/html" href="http://www.commonsense4commonpeople.net/2008/11/the-code-is-the-documentation.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2008/11/the-code-is-the-documentation.html" thr:count="1" thr:updated="2008-11-21T16:10:49+02:00" />
        <id>tag:typepad.com,2003:post-58691086</id>
        <published>2008-11-18T23:50:31+02:00</published>
        <updated>2008-11-18T23:50:31+02:00</updated>
        <summary>Yeah sure... Sleep tight and noone is gonna rock your boat, at least while you are sleeping in it. This is a very luring statement. The reason it is so luring is that it is so obviously true. Or is...</summary>
        <author>
            <name>Dimitris Staikos</name>
        </author>
        <category scheme="http://www.sixapart.com/ns/types#category" term="Common Sense" />
        <category scheme="http://www.sixapart.com/ns/types#category" term="Programming" />
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.commonsense4commonpeople.net/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>Yeah sure... Sleep tight and noone is gonna rock your boat, at least while you are sleeping in it.</p>
<p>This is a very luring statement. The reason it is so luring is that it is so obviously true. Or is it not? Doesn't the program do <strong>exactly</strong> what the code tells it too? So the code is THE one and only <em>always up-to-date documentation of any program</em>. Right?</p>
<p>It is so convincing that you just can't resist falling for it, especially when faced with an aficionado that passionately claims that she doesn't need to write comments as "extra" documentation, because the code is THE documentation, and since she obviously writes top quality code, comments are simply redundant. A waste of screen estate more or less. Useless clutter around the actual documentation.</p>
<p>Sorry to break the news boys and girls... The reality is somehow different.</p>
<blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
<p><em><span style="COLOR: #ff0000; FONT-FAMILY: Trebuchet MS">The code is the imperfect translation into a programming language of the programmer’s imperfect understanding about what the program should do.</span></em></p></blockquote>
<p>You can figure out the rest. The code is THE documentation of the programmer's imperfect language translation of an imperfect understanding. <strong><em><span style="COLOR: #c00000; FONT-FAMILY: Trebuchet MS">It documents how the programmer failed to code properly what he failed to understand properly</span></em></strong>.</p>
<p>Anyone still battling on the issue of whether the code is THE documentation and whether comments (in any form) are needed or not, most likely hasn’t worked on a big project (300+KLOC) long enough (5+ years) to figure things out for him/herself.</p>
<p>Life is so sweet when 90% of the time you fool around your own code. Everything is so simple, because everything is in your head. However once you start spending 50% of your time on pieces of code that other people wrote, pieces of code you have NEVER seen before, or pieces of your own code that you wrote 4 years ago and haven't glanced at since, then life is not as sweet.</p>
<p>When you read code you are not familiar with, then you are doing the reverse translation, from imperfect programming language to imperfect understanding about the program's intentions. This is tough. Some may be better at it than others, but trust me... without good comments it can be much more painful and error prone than it has to.</p>
<p>So please, make others' lives easier. Let them cherish your memory after you are gone and enjoy fixing the bugs in your code. Because you WILL be gone some day and your code WILL still have bugs that need fixing.</p>
<p>Enjoy,<br />Dimitris Staikos</p></div>
</content>


    </entry>
    <entry>
        <title>Psychology is a science, NOT just Common Sense</title>
        <link rel="alternate" type="text/html" href="http://www.commonsense4commonpeople.net/2008/11/psychology-is-a-science-not-just-common-sense.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2008/11/psychology-is-a-science-not-just-common-sense.html" thr:count="2" thr:updated="2009-01-23T09:25:24+02:00" />
        <id>tag:typepad.com,2003:post-58067554</id>
        <published>2008-11-05T21:12:00+02:00</published>
        <updated>2008-11-05T21:12:00+02:00</updated>
        <summary>This is an excerpt from an excellent book that I am currently reading: It's no surprise that people who are faced with choices about how to influence others will often base their decisions on thinking that's grounded in fields such...</summary>
        <author>
            <name>Dimitris Staikos</name>
        </author>
        <category scheme="http://www.sixapart.com/ns/types#category" term="Books" />
        <category scheme="http://www.sixapart.com/ns/types#category" term="Common Sense" />
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.commonsense4commonpeople.net/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>This is an excerpt from an excellent book that I am currently reading:</p>
<blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
<p><em>It's no surprise that people who are faced with choices about how to influence others will often base their decisions on thinking that's grounded in fields such as economics, political science and public policy. What's puzzling, however, is how frequently decision-makers fail to consider established theories and practices in psychology.</em></p>
<p><em>One explanation is that, in contrast to how they regard the fields of economics, political science and public policy, which requires learning from outsiders to achieve even a minimal level of competence, <span style="text-decoration: underline;">people believe they already possess an intuitive understanding of psychological principles simply by virtue of living life and interacting with others</span>. This overconfidence leads people to miss golden opportunities.</em></p></blockquote>
<p>It is really sad to see otherwise smart people feverously deny any chance to improve their soft-skills, to attend seminars about human behaviour, influence, negotiations, etc. Their thinking appears to be something of the sort "<em>Hey dude, can't you see what great a manager I am? How did I get here? Because I am smart and because I am good, really good. I need no silly seminars to tell me how to do my job!</em>".</p>
<p>As the book says, they believe they already have ALL the skills they need, plus they believe (in their hearts) that they do a damned good job, almost perfe<span id="fck_dom_range_temp_1225899082012_370" />ct. They think that psychology is common sense; if you are smart enough you can figure it out by yourself. But it's not that way. Psychology is a real science and <span style="text-decoration: underline;"><strong>you definitely cannot figure it out</strong></span>. Just read a couple of good texts and after your jaw drops to the floor for a couple dozens of times you will know that <span style="text-decoration: underline;">you could never have figured it out</span>.</p>
<p>Needless to say, the competition will sooner or later do their part of the studying and inevitably they will outrun these managers and their companies. It's as certain as death and taxes.</p>
<p>Have fun,</p>
<p>Dimitris Staikos</p></div>
</content>


    </entry>
    <entry>
        <title>Sloppy sizeof Programming (Variation #2)</title>
        <link rel="alternate" type="text/html" href="http://www.commonsense4commonpeople.net/2008/10/sloppy-sizeof-programming-variation-2.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2008/10/sloppy-sizeof-programming-variation-2.html" thr:count="1" thr:updated="2008-11-04T22:56:59+02:00" />
        <id>tag:typepad.com,2003:post-57817891</id>
        <published>2008-10-31T20:55:00+02:00</published>
        <updated>2008-10-31T20:55:00+02:00</updated>
        <summary>This is another variation on my previous sloppy programming post. When something potentially dangerous is displayed on TV then we hear them say "Do try this at home". Well for this kind of sloppy programming I say "Don't try this...</summary>
        <author>
            <name>Dimitris Staikos</name>
        </author>
        <category scheme="http://www.sixapart.com/ns/types#category" term="Programming" />
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.commonsense4commonpeople.net/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>This is another variation on my previous <a href="http://www.commonsense4commonpeople.net/2008/08/sloppy-programm.html" target="_blank">sloppy programming post</a>. </p>

<p>When something potentially dangerous is displayed on TV then we hear them say "Do try this at home". </p>

<p>Well for this kind of sloppy programming I say "<strong>Don't try this at work!</strong>".<br />Only <em>try</em> it at home, where you can merrily shoot yourself (and just yourself) in the foot as much as your heart desires, leaving the rest of the world in blissful peace.</p><p>
</p>
Take a look at these 3 lines of C/C++ code:

<p><span style="font-family: Courier;">    HW_STREAM_HEADER       *streamHeader = &amp;srb-&gt;CommandData.StreamBuffer-&gt;StreamHeader;<br />    HW_STREAM_INFORMATION  *streamInfo   = &amp;srb-&gt;CommandData.StreamBuffer-&gt;StreamInfo;<br />    RtlZeroMemory(streamHeader, sizeof(HW_STREAM_HEADER)+sizeof(HW_STREAM_INFORMATION));<br /></span></p>

<p>There are 2 reasons why this code is flawed:</p>

<ol>

<li>It assumes that the <span style="font-family: Courier;">StreamHeader</span> and <span style="font-family: Courier;">StreamInfo</span> fields inside the <span style="font-family: Courier;">StreamBuffer</span> structure are <strong>declared</strong> one after the other. 

<li>

<p>It assumes that the <span style="font-family: Courier;">StreamHeader</span> and <span style="font-family: Courier;">StreamInfo</span> fields inside the <span style="font-family: Courier;">StreamBuffer</span> structure appear in consequent memory locations without any "holes" in between.</p></li>
</li></ol>

<p>Although the first assumption can be verified by looking at the header file, it is sloppy programming, because what if someone updates this structure in the future and declares something in between? The code will compile without any errors but it will cause some very nasty behaviour that will be hard to debug, unless you have familiarity with "break on write" breakpoints.</p>

<p>The second assumption is one that you should avoid whenever possible, because it might hold on one day and fail later (because the structs got new members or the code was compiled on an x64 system).</p>

<p>In general, unless a structure describes something that is <em>fixed, well known and never going to change</em> (e.g. Ethernet packet header, 1394 packet header, etc) DON'T write code that relies on the order of fields or their physical positions.</p>

<p>So the correct thing to do above is to make two separate calls to <span style="font-family: Courier;">RtlZeroMemory</span> instead of a silly, useless and totally unnecessary attempt to demonstrate your programming prowess and save one function call.</p>

<p>Keep in mind that very few things in this world are <em>fixed, well known and never change</em>. Let's take an example from the Windows API: GetVersionEx</p>

<p>The prototype looks like this:</p>

<p><strong>    <span style="font-family: Courier;">BOOL</span></strong><span style="font-family: Courier;"> <strong>GetVersionEx(</strong><strong>LPOSVERSIONINFO</strong> <em>lpVersionInfo</em><strong>);</strong></span></p>

<p>The structure looks like this:</p>

<p><span style="font-family: Courier;">    typedef struct _OSVERSIONINFO <br />    {  <br />        DWORD dwOSVersionInfoSize;<br />        DWORD dwMajorVersion;<br />        DWORD dwMinorVersion;<br />        DWORD dwBuildNumber;<br />        DWORD dwPlatformId;<br />        TCHAR szCSDVersion[128];<br />    }<br />    OSVERSIONINFO;</span><br /></p>

<p>This is a documented structure so it will NEVER change, right??? If it changes it will break all existing binaries that were compiled against that definition, so it can't probably change...</p>

<p>Sounds pretty convincing an argument, but of course it is pretty mistaken. Usually people write the following code to use this function:</p>

<p><span style="font-family: Courier;">    OSVERSIONINFO osvi;<br />    ZeroMemory(&amp;osvi, sizeof(osvi));<br />    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);<br />    GetVersionEx (&amp;osvi);</span><br /></p>

<p><br />The <span style="font-family: Courier;">osvi</span> variable is located on the stack for heaven's shake, so if <span style="font-family: Courier;">GetVersionEx</span> starts to expect something different then all hell will break loose.</p>

<p>Well, I am sure many developers have figured that out at one point or another, but for those of you who didn't have the time to bother thinking about "Why do some many Windows' structures have a size <em>thingy</em> at their very start?" here is the moment of epiphany:</p>

<blockquote dir="ltr" style="MARGIN-RIGHT: 0px">

<p><em>This is the trick that the Windows API uses to achieve backwards compatibility for binaries and forward compatibility for source code.</em></p></blockquote>

<p>The source code for <span style="font-family: Courier;">GetVersionEx</span> will look to something like this in 20 years from now:</p>

<p><span style="font-family: Courier;">    struct OSVERSIONINFO_1998 { ... };<br />    struct OSVERSIONINFO_2003 { ... };<br />    struct OSVERSIONINFO_2016 { ... };<br />    struct OSVERSIONINFO_2025 { ... };<br />    typedef struct OSVERSIONINFO_2025 OSVERSIONINFO;</span></p>

<p><span style="font-family: Courier;">    GetVersionEx(OSVERSIONINFO *pOSVI)<br />    {<br />        switch (pOSVI-&gt;dwOSVersionInfoSize)<br />        {<br />        case sizeof(OSVERSIONINFO_1998):<br />           return GetVersionEx_1998((OSVERSIONINFO_1998*) pOSVI);<br /><br />        case sizeof(OSVERSIONINFO_2003):<br />           return GetVersionEx_2003((OSVERSIONINFO_2003*) pOSVI);<br />        }<br />    }</span><br /></p>

<p>I know that it looks very ugly but do you see the beauty in it? This is the joy and nightmare of writing an operating system that you want to make backwards compatible.</p>

<p>You are free to change the system and yet old binaries will magically keep working for ever, even though the definition in the header file has been updated. Source code will always compile without requiring function name updates (GetVersionEx2 and then GetVersionEx3, etc) given that the existing struct member names do not change. As soon as you get an updated Windows SDK with a newer definition for OSVERSIONINFO and you recompile your code, immediately a new size is calculated by the compiler and your code calls the latest functionality (the functionality that fills in the latest structure).</p>

<p>So even for structs like OSVERSIONINFO, that are part of an operating system SDK, you should NOT assume that the order of fields will remain the same for ever. You can expect that the fields will be there for ever and usually new stuff is added at the end of the structure, but still you should NOT assume things about the ordering of fields in such structures.</p>

<p>In the FireAPI SDK I have designed for Unibrain I use a similar trick for backwards compatibility. All structures have a ULONG tag as their first member. So instead of switching on the size of the structure I switch on the tag.</p>

<p>It's a bit less convenient for the developer to write:</p>

<p><span style="font-family: Courier;">    mystruct.Tag = TAG_STRUCT_NAME;</span></p>

<p>instead of</p>

<p><span style="font-family: Courier;">    mystruct.dwSize = sizeof(myStruct);<br /></span></p>

<p>but... there is an added value when using a tag. Tag values are usually #defines so I can produce <em>very nice tags</em> that are:</p>

<ol>

<li><strong>Unique</strong>: sizeof(A) can be equal to sizeof(B) to sizeof(XYZ) etc, while my tags are unique. 

<li>

<p><strong>Easy to remember and recognize</strong>: Something like 0xBADC0FFE is much is easier to remember and recognize than 0x00000046.</p></li>
</li></ol>

<p>These two properties <span style="TEXT-DECORATION: underline">can be of immense value when you are debugging</span> some very nasty issue and you come to the desparate point where you are looking to plain memory trying to figure out what the heck is going on. When you see one of the tags somewhere you immediately know what kind of struct should be there.</p>

<p>If you think about it it's like an extra bit of manually provided <em>type information</em>.</p>

<p>It's about time to conclude, so I hope all the above have given you some new comprehension on the terrors of backwards compatibility, which explains partially why Windows gets heavier and heavier, bigger and bigger as the years go by.</p>

<p>Windows has to evolve and provide new features, still has to support literally millions of old applications, developed with older tools, older compilers, by companies that are closed, developers that were shot dead etc. These apps are NOT going to get recompiled or upgraded or anything else. And still they have to work because Microsoft customers are using them.</p>

<p>And they do work (well, in most cases at least ;-)). That my friends is <strong>a gigantic accomplishment and MS has my infinite respect for it</strong>.</p>

<p>Most people don't realize <strong>this huge backwards-compatibility burden on MS</strong> and simply cry "Go Mac, everything works fine there". Well, it's common sense I guess. If I have 2% of the market I can just change the kernel and all my APIs anytime I feel like it, give all my software houses a harsh time (as if I care) and life goes on and you are going to be "cool" again, running the laaaatest version.</p>

<p>Eventually people might get used to this, but let me see Apple try that if and when their market share grows to 30%, when countless businesses have developed business software on Macs and expect it to keep running for the next 15 years at least.</p>

<p>Personally I don't think that will ever happen, the business part I mean. Macs will mainly stay a <em>consumer thingy</em> (browsing, reading mail, listening to music, watching photos, blogging, etc) plus some specialized apps that have been traditionally superb on Macs. Who knows however? Stranger things have happened :-)</p>

<p>Have Fun and avoid drinking 0xBADC0FFE.</p>

<p>Dimitris Staikos</p></div>
</content>


    </entry>
    <entry>
        <title>Digital Misfortunes: Remote desktop messes up keyboard layout of logon screen</title>
        <link rel="alternate" type="text/html" href="http://www.commonsense4commonpeople.net/2008/10/digital-misfortunes-remote-desktop-messes-with-keyboard-layout-of-login-screen.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2008/10/digital-misfortunes-remote-desktop-messes-with-keyboard-layout-of-login-screen.html" thr:count="3" thr:updated="2009-06-24T12:40:38+03:00" />
        <id>tag:typepad.com,2003:post-57697891</id>
        <published>2008-10-30T03:31:00+02:00</published>
        <updated>2008-10-30T03:31:00+02:00</updated>
        <summary>It seems that lately I have been having a peak of digital troubles, which I have come to call "Digital Misfortunes". These are situations where programs or computers do not behave in the expected way and I have to utilize...</summary>
        <author>
            <name>Dimitris Staikos</name>
        </author>
        <category scheme="http://www.sixapart.com/ns/types#category" term="Digital Misfortunes" />
        <category scheme="http://www.sixapart.com/ns/types#category" term="Web/Tech" />
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://www.commonsense4commonpeople.net/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>It seems that lately I have been having a peak of digital troubles, which I have come to call "Digital Misfortunes". These are situations where programs or computers do not behave in the expected way and I have to utilize the "supernatural" powers that device driver development has given me in order to solve these problems.</p>



<p>So, since these things seem to happen more and more often I have created a new category in my blog, with that name exactly.</p>



<p>It really makes me sad to see that more and more problems keep coming up. What would a normal user do? Format and reinstall the OS? Most likely...</p><p>

</p><p>

Here is a summary of some of my latest digital misfortunes:



</p><ul>



<li>The wifi and ethernet ports of my laptop stop working. I think it is a hardware failure until a friend with the same laptop tells me he has the same trouble. It couldn't be a coincidence. The network adapters on 2 separate laptops getting damaged at the same time? No way...<br />Uninstalling the wifi card and the ethernet card from Device Manager and then doing a "Scan for Hardware Changes" fixed the problem. 



<li>My antivirus hits 100% CPU due to a silly utility generating a 10MB debug log on my disk in HTML format.



<li>If I put my brand new (6 months) Vista PC to sleep (standby) and then resume then the DVD drive is no longer "present". If I do a proper reboot it shows up again. I didn't have time to fix that yet.



<li>Just last night, Vista would not let me rename a folder on an external firewire disk for no apparent reason. After passing the UAC dialog I would get another silly dialog telling me "You need permission to do that ==&gt; Retry - Cancel". I tried that several times but finally gave up.<br />I had no open program or command shell using that folder and I could rename ANY folder below or above it in the folder hierarchy (folder tree), but not that one. I had to reboot so that I could finally rename the folder!



<li>The software of my mobile phone (that I run on the PC) informed me there was an upgrade that it could download for me. I agreed, the thing downloaded and crashed upon installation. Then of course it no longer worked. So I uninstalled it, then reinstalled the original, refused to upgrade, and worked fine for a while.<br />Then I thought may be I should try again, this time starting up the program with admin priviledges (Vista). Now it upgraded but didn't work (could not connect to the phone). I uninstall and reinstall the original version once more and now it wouldn't connect either. As the average user would do, I start the software in "diagnostic" mode and everything works perfectly ever after... 



<li>



<p>I try to do some kernel debugging from my laptop and get "Access Denied" when opening the Serial Port (USB2Serial) with WinDbg (the same with HyperTerminal of course). After trying to find who is the culprit (using Process Explorer and Handle) without result I start killing processes (bruteforce is my nickname) just to see who is blocking my serial port. I find one process that cannot be killed!!! I logoff and logon again and the process is still alive and kicking (with the same process id).<br />I use AutoRuns to remove it from startup, restart my laptop and now the serial port is working fine once again. Btw, that process was the mobile phone utility software :-D</p>



<li>



<p>I discover that everyone at the office is totally unable to connect to public shares on my PC although everything looks normal with the OS. As if that was a bad thing I start to fix it (I regreted that later...). The culprit? The CheckPoint client software that got installed when I installed some VPN software so that I could connect to the VPN of some client and debug their systems. It installed on my machine a strict policy from THEIR domain, which did not permit any file sharing of any sort.<br /><strong>They</strong> were wise of course, but me being a <strong>great fool</strong> stopped the CheckPoint services so that I could share files again with my collaborators...</p></li>
</li></li></li></li></li></li></ul>



<p>Anyway, just about 2 weeks ago I was hit by a particularly sweet one. So sweet and silly at the same time that it deserves its own post.</p>



<p>It was Sunday morning around 1pm. I was at the office packing my things and computers for a 4-day trip to Germany, for the 1394 Trade Association's plugfest (Interoperability Testing). My flight was at 4pm.</p>



<p>I had packed my test PC and as I was about to pack the cameras, being the test-obsessed guy that I am, I thought... "Hmmm let's do a final test with these cameras on the laptop before I pack them, just to make sure they are ok for the demos".</p>



<p>So I open up my laptop and start to login to Windows.</p>



<p>"Wrong Password".</p>



<p>I type again, a bit more careful this time.</p>



<p>"Wrong Password".</p>



<p>I type again, the characters <strong>one by one</strong>.</p>



<p>"Wrong Password".</p>



<p>What the heck? I connect through Remote Desktop and of course everything looks fine!!! I try to connect locally and... "Wrong Password". Darn!</p>



<p>Now just picture that: I have to be at the airport in about an hour, I haven't finished packing, and I cannot logon to my laptop!!! Sweeeeet!!!</p>



<p>I try to log on as local admin and in utter surprise find out that my keyboard cannot type the word "administrator". The keys are somehow messed up!!! Well, that explains the wrong password. I try to use the ALT+AsciiCode trick to type in the password, but it doesn't work. Things are really messed up.</p>



<p>Quickly I search Google for <a href="http://www.google.com/search?client=opera&amp;rls=en&amp;q=windows+xp+remote+desktop+keyboard+layout&amp;sourceid=opera&amp;ie=utf-8&amp;oe=utf-8" target="_blank">windows xp remote desktop keyboard layout</a> and I see the following as the second result coming straight from the Microsoft KB: <a href="http://support.microsoft.com/kb/906693" target="_blank">The default keyboard layout changes when you use Remote Desktop Connection to connect to a Windows XP-based computer</a>.</p>



<p>Blast it!!! I had to debug a PC in the lab during the week and instead of moving it to my office as usual, I moved my laptop there and Remote Desktop'd to it to do the debugging...</p>



<p>I read the article quickly and I see that the issue has been corrected in XP SP3. But I HAVE the darn SP3 installed on the laptop and still get the problem!</p>



<p>Anyway, since I was pressed for time (and this is usually a bad advisor), I connected through Remote Desktop once again and created a local admin account with a name and pwd that contained letters I could type at the login screen. The funny thing is that when I login to that account the keyboard layout is fine. It is only messed in the logon screen. Anyway that suited my purposes. The laptop was operational once again.</p>



<p>The trick worked fine and for the next couple of days at the event I had no trouble.</p>



<p>Then I get back to home base and since I had tougher problems to debug, I decided to file a support incident to Microsoft Hellas for the keyboard layout issue (since it was a known problem in a previous version of the OS). A very intelligent and kind guy calls me two days later and we start to resolve the problem. Guess what... As I was rubber-ducking him (explaining the situation to the guy) I figure out a pattern and I notice that the failing keys are those that are "mapped" to the numeric keypad. Laptops don't have a numpad, so they map it somewhere in the middle of the keyboard. Then for example, if you press NumLock, 'M' produces 0, 'J' produces 1 etc.</p>



<p>That was the source of the trouble! The logon screen thought that the numlock was ON. I pressed NumLock once and my keyboard was fine...</p>



<p>To restore the NumLock to NOT being on, we just did the reverse of what the following KB article describes: <a href="http://support.microsoft.com/kb/154529/EL/" target="_blank">How to enable the NUM LOCK key for the logon screen</a>. The MS guy filed the bug and the case was closed.</p>



<p>The trouble was definitely caused by Remote Desktop since it happened again the next time I Remote Desktop'd to the laptop but now I knew what to do :-)</p>



<p>Anyway, if you want a tiny bit of extra <em>security through obscurity</em> on your laptop then <span style="TEXT-DECORATION: underline">enable</span> NumLock on the logon screen, so most likely no 'friend' of yours can logon interactively to it while you are "away" from it. Trust me, you never know when this silly trick might prove useful...</p>



<p>So ladies and gents, the moral of this story: It saddens me to admit it but... computer technology is still soooooooo immature... So incomplete... So imperfect... So far from "<em>usable by the average user</em>". Maybe in about 10 years things will be much better.</p>



<p>Have fun!</p>



<p>Dimitris Staikos</p></div>
</content>


    </entry>
 
</feed><!-- ph=1 --><!-- nhm:dynamic-ssi -->
