<?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" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">
    <title>Common Sense 4 Common People</title>
    
    <link rel="hub" href="http://hubbub.api.typepad.com/" />
    <link rel="alternate" type="text/html" href="http://www.commonsense4commonpeople.net/" />
    <id>tag:typepad.com,2003:weblog-541750</id>
    <updated>2009-11-25T08:16:44+02: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>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/CommonSense4CommonPeople" /><feedburner:info uri="commonsense4commonpeople" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry>
        <title>The Law of Late Projects</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CommonSense4CommonPeople/~3/FxEBwxBNMUc/the-law-of-late-projects.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2009/11/the-law-of-late-projects.html" thr:count="4" thr:updated="2009-12-01T06:09:07+02:00" />
        <id>tag:typepad.com,2003:post-6a00d8341d80a253ef012875d6d1bd970c</id>
        <published>2009-11-25T08:16:44+02:00</published>
        <updated>2009-11-25T08:16:44+02:00</updated>
        <summary>Very recently a good friend of mine, Prof.Vasilis Vassalos, made a comment on Facebook about Parkinson's law by referring to this article. Parkinson's law says that all work expands to fill all time available for its completion. This has be...</summary>
        <author>
            <name>Dimitris Staikos</name>
        </author>
        <category scheme="http://www.sixapart.com/ns/types#category" term="Business of Software" />
        <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">Very recently a good friend of mine, Prof.Vasilis Vassalos, made a comment on Facebook about Parkinson's law by referring to <a href="http://www.economist.com/businessfinance/management/displaystory.cfm?story_id=14116121" target="_blank">this article</a>. 
<p>Parkinson's law says that <em><strong>all work expands to fill all time available for its completion</strong></em>. 
<p>This has be proven statistically to be very true, so nobody can doubt it. However some of the consequences of this law often go unnoticed as the law's wording and meaning gets twisted and turned over to suit one's needs.</p>
<p />
<p />
</p>
<p>We all know that project estimation is akin to solving NP-complete problems. You only know the exact answer after you have finished all the work. There are many shortcuts around the problem, but the exact answer requires you do all the work, like in an NP-complete problem the exact answer can be found only by examining ALL combinations.</p>
<p>Now suppose you have a project to do, that *really* needs 5 calendar months to complete, working at the best of your abilities, no interruptions, etc. What Parkinson's law says is that if your manager gives you 6 months to complete it, then your work will 'somehow' expand and you will do 6 months instead of 5, still working at the best of your abilities. You might add a few extras here and there, some more performance testing, whatever, it doesn't matter what. The work will expand to 6 calendar months.</p>
<p>From your point of view, this extra month adds significant value to the end result. However from your manager's point of view it adds more COST than value. And your manager is trying to get everything done at both the absolutely minimum quality level acceptable by the client and at the absolutely minimum cost so that she can maximize <strong>profits</strong> for the company (and her fat bonus too).</p>
<p>But there are costs and costs. One cost your manager cares about is the actual grand total, but then there is another cost she cares about: unpaid overtime, or to put it diplomatically 'human capital utilization'.</p>
<p>The grand thinking of high-level managers is that when developers are working normal hours the company is losing money. It is clearly losing money because according to Parkinson's law it is clear that the developers are doing less actual work, expanding it to fill their day, up to 'normal working hours'.</p>
<p>If developers could be pushed to work 10 hours instead of 8 every day, then even though Parkinson's law <strong>still applies</strong>, they will get more work done every day. This means the company improves it's human capital utilization and thus saves costs.</p>
<p>Now let's get back to the project level. No one knows the time required, so the manager, the client and the development team negotiate and agree to an estimate. Let's say 12 months.</p>
<p>After 12 months the project is ready, up and running, and the development team is celebrating. The manager might be celebrating too, but at the back of her head one thing is clear. She overestimated the project and the project expanded to 12 months according to Parkinson's law. If it could be done in 12 months then it could easily be done in 11 months or even 10 months.</p>
<p>The manager clearly <strong>FAILED</strong> to minimize costs. The manager will now be perceived by her peers (and her boss) as being <strong>SOFT</strong> because she clearly <strong>didn't push the team hard enough</strong>.</p>
<p>The project succeeded but the manager FAILED!</p>
<p>Now comes the nice part... Suppose that a time traveler from the near future visited the manager at the negotiation phase and told her "<em>You can do it in 11 months</em>". The manager fancied this guess and in fact the project was successfully completed in 11 months. <strong>On Time</strong> again... <strong>Failure</strong> again... for our poor manager... If it was done in 11 months then it can clearly be done in 10, maybe even 9 months...</p>
<p>So you can now see the great corollary to Parkinson's law, which we could call "<strong><em>The Law of Late Projects</em></strong>":</p>
<blockquote><em><strong><span style="FONT-FAMILY: ; FONT-SIZE: 14px"><span style="FONT-FAMILY: ; FONT-SIZE: 15px">Management will always try to make a project late.</span></span></strong></em></blockquote>
<p>This is usually done by choosing a very optimistic deadline or, if the project seems to run smoothly, by introducing more work, changing the requirements, changing key people, replacing experienced team members with rookies, etc. You name it. As soon as a project appears to be on track the manager starts to panic; She is losing money for the company; She appears soft; She <strong>must</strong> <strong>ACT</strong>.</p>
<p>Have Fun!<br />Dimitris Staikos<br /></p>
<p />
<p />
<p /><xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/CommonSense4CommonPeople/~4/FxEBwxBNMUc" height="1" width="1" /></div></content>


    <feedburner:origLink>http://www.commonsense4commonpeople.net/2009/11/the-law-of-late-projects.html</feedburner:origLink></entry>
    <entry>
        <title>FireWire 1.6 Gbps and 3.2 Gbps announced by DAP Technology!</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CommonSense4CommonPeople/~3/22Jqh-lDoDE/firewire-16-gbps-and-32-gbps-announced-by-dap-technology.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2009/11/firewire-16-gbps-and-32-gbps-announced-by-dap-technology.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-6a00d8341d80a253ef012875cea7ea970c</id>
        <published>2009-11-24T05:48:05+02:00</published>
        <updated>2009-11-24T05:48:05+02:00</updated>
        <summary>Last week I told you about the forthcoming news on 1.6 Gbps and 3.2 Gbps FireWire. Now, here is the official press release from DAP Technology!!! Have fun! Dimitris Staikos</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">Last week I told you about <a href="http://www.commonsense4commonpeople.net/2009/11/firewire-moving-forward.html" target="_blank">the forthcoming news</a> on 1.6 Gbps and 3.2 Gbps FireWire.<p>



Now, here is the <a href="http://www.daptechnology.com/index.php?id=169" target="_blank">official press release</a> from DAP Technology!!!<p>



Have fun!<br />Dimitris Staikos</p><p /></p><xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/CommonSense4CommonPeople/~4/22Jqh-lDoDE" height="1" width="1" /></div></content>


    <feedburner:origLink>http://www.commonsense4commonpeople.net/2009/11/firewire-16-gbps-and-32-gbps-announced-by-dap-technology.html</feedburner:origLink></entry>
    <entry>
        <title>FireWire moving forward</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CommonSense4CommonPeople/~3/WUZy5jxu3_c/firewire-moving-forward.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2009/11/firewire-moving-forward.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-6a00d8341d80a253ef012875b29b5e970c</id>
        <published>2009-11-18T19:34:58+02:00</published>
        <updated>2009-11-18T19:34:58+02:00</updated>
        <summary>Two weeks ago I visited the Vision Show 2009 exhibition in Stuttgart, Germany. Two very important things happened there with regards to FireWire (IEEE 1394) technology. DAP Technology made a demo of their S1600/S3200 solution. That's 1.6Gbps and 3.2Gbps respectively....</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>Two weeks ago I visited the <a href="http://www.messe-stuttgart.de/cms/index.php?id=46112&amp;L=1">Vision Show 2009 exhibition in Stuttgart</a>, Germany.</p>







<p>Two very important things happened there with regards to FireWire (IEEE 1394) technology.</p>







<ol>







<li><a href="http://www.daptechnology.com/">DAP Technology</a> made a demo of their S1600/S3200 solution. That's 1.6Gbps and 3.2Gbps respectively. It worked fine over 10m standard FireWire cables.<br />The demo was semi-public and DAP will make a relevant press release within the next days.</li>
<li>Two companies demonstrated their S800-over-Coax cable solutions, using the S800 coax transceivers of <a href="http://www.eqcologic.com/home.html">Eqcologic</a>.</li>
</ol>







<p>They are both great news for FireWire, because they show that FireWire is still moving forward.</p>







<p>Have Fun!<br />Dimitris<br /></p>







<p /><xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/CommonSense4CommonPeople/~4/WUZy5jxu3_c" height="1" width="1" /></div></content>


    <feedburner:origLink>http://www.commonsense4commonpeople.net/2009/11/firewire-moving-forward.html</feedburner:origLink></entry>
    <entry>
        <title>Rules of program optimization</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CommonSense4CommonPeople/~3/23Pau6RVD9g/rules-of-program-optimization.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2009/11/rules-of-program-optimization.html" thr:count="2" thr:updated="2009-11-17T17:43:26+02:00" />
        <id>tag:typepad.com,2003:post-6a00d8341d80a253ef0128759f2827970c</id>
        <published>2009-11-15T17:15:29+02:00</published>
        <updated>2009-11-15T17:15:29+02:00</updated>
        <summary>I recently watched a recorded presentation of Prof.Diomidis Spinellis, author of a couple of world famous books on programming, like "Code Quality". At some point Mr.Spinellis discussed the issue of program optimization and mentioned some famous quotes related to 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>I recently watched a recorded presentation of Prof.Diomidis Spinellis, author of a couple of world famous books on programming, like "Code Quality". At some point Mr.Spinellis discussed the issue of program optimization and mentioned some famous quotes related to this issue, quotes that were also listed in his "Code Quality" book:<ul>



<li>







The First Rule of Program Optimization: Don't do it.</li>
<li>







The Second Rule of Program Optimization (for experts only): Don't do it yet.</li>
</ul>



<p>These come from M.A.Jackson. It is hard to exaggerate how much I agree.<p>I would like to add my own rules to the list :-) Maybe others have said similar words, but now I copy from my own brain:<ul>



<li>The 3rd Rule of Program Optimization: Make sense of it in the real world first.</li>
<li>The 4th Rule of Program Optimization: Measure it and justify it before you commit to it.</li>
</ul>



<p>Programmers often set sail to optimize a piece of code, just because it is plain for all to see that this piece of code CAN be optimized. However, you should do some serious thinking first to see whether it makes sense to optimize this piece of code. How often is it run, under which paths, how long does it take to execute, etc. For example don't optimize code to turn a 0.1 msec into a 0.01 msec if that runs once every minute.</p><p>Does it make sense to optimize a process that is executed once a day, if that process takes 10min, 20min, 120min, 360min? Would it make sense to optimize the 10min to 1min (10/1 improvement), the 120min to 30min (4/1 improvement) or the 360min to 120min (3/1)?</p><p>You definitely can't tell the answer by looking at the numbers. Maybe the 360min procedure runs at the end of the day, after all employees are gone, so no one benefits from the improved performance, but then the backups can be scheduled earlier. Or the 120min process runs over lunch break, so having it finished before people return from lunch does not make that much of a difference.</p><p>That's the meaning of the 3rd rule, don't look at the code searching for optimizations, look at the real world for optimizations.</p><p>The 4th rule is a bit drastic. After you decided to optimize the code, do some measurements. Careful measurements of the old implementation, careful measurements of the new implementation. If the improvement is NOT worth the while, then you might as well scrap the optimization. Throw it away. You thought you had good reason, you made extensive changes but didn't get the improvement you expected; no hurt feelings, just dump it.</p><p>Code complexity and maintainability are far more critically important than a minor performance optimization. KISS should be the topmost priority, not writing code that makes programmers feel good about themselves ;-)</p><p>Have Fun!</p><p>Dimitrios Staikos</p><p /><p /><p /><p /></p></p></p><xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/CommonSense4CommonPeople/~4/23Pau6RVD9g" height="1" width="1" /></div></content>


    <feedburner:origLink>http://www.commonsense4commonpeople.net/2009/11/rules-of-program-optimization.html</feedburner:origLink></entry>
    <entry>
        <title>The Internet says...</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CommonSense4CommonPeople/~3/dXcAQJjRAD4/the-internet-says.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2009/11/the-internet-says.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-6a00d8341d80a253ef0120a6a5adff970c</id>
        <published>2009-11-03T22:53:33+02:00</published>
        <updated>2009-11-03T22:53:33+02:00</updated>
        <summary>Today I was walking the streets of downtown Stuttgart in Germany and of all things possible, I was looking for a post office. I was given some directions by some friendly local, but I still couldn't find it. So I...</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>Today I was walking the streets of downtown Stuttgart in Germany and of all things possible, I was looking for a post office. I was given some directions by some friendly local, but I still couldn't find it. So I asked another passerby for assistance.</p><p>He didn't know, but he immediately popped out his cell phone and told me "Let me check on the Internet". I don't know why, but I felt that this event transitioned me into a whole new era. Most likely because it was the first time in my life that a completely random passerby would access the Internet in order to offer me the assistance I was looking for.</p><p>What amazed me even more was the way he formulated his reply soon after:</p><p>"<strong><em>The Internet says</em></strong> it's on Marienstrasse 19".</p><p>Have Fun!<br />Dimitris Staikos</p><p>PS: Beware of what the Internet says... The post office wasn't there ;-)</p><xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/CommonSense4CommonPeople/~4/dXcAQJjRAD4" height="1" width="1" /></div></content>


    <feedburner:origLink>http://www.commonsense4commonpeople.net/2009/11/the-internet-says.html</feedburner:origLink></entry>
    <entry>
        <title>Microsoft update KB967723 installation error</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CommonSense4CommonPeople/~3/FZTxMXHG04Q/microsoft-update-kb967723-installation-error.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2009/10/microsoft-update-kb967723-installation-error.html" thr:count="10" thr:updated="2010-01-30T02:47:20+02:00" />
        <id>tag:typepad.com,2003:post-6a00d8341d80a253ef0120a6203ccd970c</id>
        <published>2009-10-07T18:01:26+03:00</published>
        <updated>2009-10-07T18:01:26+03:00</updated>
        <summary>For days now Vista has been bugging me about an update that just would not install (KB967723). Even if I would shutdown the machine, it would just try and fail. And not simply fail... but give me an amazing error...</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">For days now Vista has been bugging me about an update that just would not install (KB967723).<br />Even if I would shutdown the machine, it would just try and fail.<br />And not simply fail... but give me an amazing error code (80070490) which to cut a long story short meant that some internal database of updates was corrupt and I had to repair installation from the Vista CD. What???? Over my dead body!<br /><br />Can you see the big picture here? I was minding my own business and one more Digital Misfortune came my way uninvited. But don't get me wrong here. If there is ONE technological feat that I admire in this world that is Microsoft Update. I just can believe such a thing is working. One major screw up (or security breach) and millions of computers can become unusable; just the security requirements of this blew my mind away... So I forgive them some glitches.<br /><br />Anyway, since I had to debug this issue, I thought I might as well write a couple of lines about it, so that other poor souls like me might get a better chance when searching for an answer.<br /><br />By searching the net and reading other posts I found some people mentioning that in similar situations they downloaded the standalone installer for the update and surprisingly enough it installed without problems.<br />Now that should ring some bells...<br />It is a seemingly non-rational action but it often has results.<br />So I downloaded the <a href="http://www.microsoft.com/downloads/details.aspx?familyid=b2930ff1-5f0a-4a5d-bf2a-9fb76dd8da63&amp;displaylang=en" target="_blank">standalone installer for KB967723</a> and bingo! It installed and problem solved :-)<br />Isn't digital life so sweet?<br /><br />Have Fun!<br />Dimitris Staikos<xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/CommonSense4CommonPeople/~4/FZTxMXHG04Q" height="1" width="1" /></div></content>


    <feedburner:origLink>http://www.commonsense4commonpeople.net/2009/10/microsoft-update-kb967723-installation-error.html</feedburner:origLink></entry>
    <entry>
        <title>DELAY command implemented as batch file</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CommonSense4CommonPeople/~3/dmiwWPff00o/delay-command-implemented-as-batch-file.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2009/10/delay-command-implemented-as-batch-file.html" thr:count="1" thr:updated="2009-10-12T15:19:02+03:00" />
        <id>tag:typepad.com,2003:post-6a00d8341d80a253ef0120a612375e970c</id>
        <published>2009-10-04T19:55:22+03:00</published>
        <updated>2009-10-04T19:55:22+03:00</updated>
        <summary>Hi I always had a strange fascination about batch files in Windows. I like automation, but for some reason I don't like using an elephant gun (Perl, Powershell) to shoot a mosquito. Plus I like the automation stuff to work...</summary>
        <author>
            <name>Dimitris Staikos</name>
        </author>
        <category scheme="http://www.sixapart.com/ns/types#category" term="Programming" />
        <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<p>I always had a strange fascination about batch files in Windows. I like automation, but for some reason I don't like using an elephant gun (Perl, Powershell) to shoot a mosquito. Plus I like the automation stuff to work on any PC, without having to install anything new. The Windows shell commands look totally crippled, but there is more to it than meets the eye.<p>















</p>















<p /><p /><p /></p></p>Here is a batch file that implements a DELAY command using only basic primitives that are installed on any Windows machine.<br />The idea for it got started by a post I read that suggested that you could implement a DELAY command by pinging the local host with the -w parameter. The idea suggested was something like:<p><span style="font-family: Courier;">ping 127.0.0.1 -n 10 -w 1000</span><p>-n determines the number of pings, -w the timeout in msec for the pings.<p>However -w will determine the timeout only when there is no response to the ping. If there is a response, then the ping command does not waste time and move to the next repetition.<br />So clearly this is not an accurate way to create a delay and you can test this with a trivial batch file as I will explain below.<p>What the batch file does is not that important (you can write a delay command in Win32 in about 3 lines of code), but the reason for this post is mainly to showcase several batch file techniques.<p>Specifically:<ul>















<li>How to extract a substring from the value of an environment variable.</li>
<li>How to do math in a batch file.</li>
<li>How to invoke a subroutine inside a batch file</li>
</ul>















<p>Here is how these tricks work:</p>















<ul>















<li><strong>%envvar:~X,Y%</strong> retrieves a substring of length Y from %envvar% starting from position X (zero-based).</li>
<li>"<strong>set /A</strong>" can do integer math in the shell.<br />For example if you type "<strong>set /A 201*3</strong>" the shell will output 603. A quick integer replacement for your beloved calc.exe.<br />"<strong>set /A envvar=<em>math_expression</em></strong>" will do the math and store the result in the specified environment variable. Don't forget that environment variables appearing in the expression have to be included inside %%.</li>
<li>A batch file "subroutine" starts with a label declaration and "returns" with a <strong>GOTO :EOF </strong>statement. You call the subroutine by typing <strong>CALL :MYROUTINE</strong> <br />Executing GOTO :EOF in the "main" execution flow is just a cool way to exit the batch file.</li>
</ul>















<p>Given the above goodies you can easily implement for/while loops in a batch file.</p>















<p>You should keep in mind one particularly nasty habit of the windows shell that has to do with environment variable expansion. The shell will expand an environment variable when it READS the command, NOT when it executes it.</p>















<p>This means that in the following block:</p>















<p> <span style="font-family: Courier;">set VAR=before<br /> if "%VAR%" == "before" (<br />  set VAR=after<br />  if <span style="color: #ff0000">"%VAR%" == "after"</span> @echo Sorry, but echo will not be executed<br /> )</span><br /></p>















<p>the highlighted comparison will FAIL, because the whole if-block is read in one move and expanded before it gets executed, so the comparison will actually look like <span style="color: #ff0000"><span style="font-family: Courier;">if "before" == "after"</span></span>.</p>















<p>You can start CMD.EXE with the /V switch to enable delayed expansion, but I didn't want my DELAY batch file to depend on switches.</p>















<p>So, in my batch file I will also use PING in order to introduce a small delay and not go into a tight loop.</p>















<p>Here is what the code looks like:</p>















<p><span style="font-family: Courier;">@echo off<br />setlocal<br />if "%1" == "" goto :EOF<br /><br />SET lastrecordedtime=%time:~6,2%%time:~9,2%<br />SET elapsedtime=0<br /><br />:LOOP<br /></span><span style="color: #60bf00; font-family: Courier"><span style="color: #407f00">rem Generate a small delay so we don't busy LOOP</span></span><span style="font-family: Courier;"><br />ping 127.10.20.30 -n 1 &gt;nul<br /><br /></span><span style="color: #407f00"><span style="font-family: Courier;">rem Pickup the current time</span></span><span style="font-family: Courier;"><br />SET currenttime=%time:~6,2%%time:~9,2%<br /><br /></span><span style="color: #407f00; font-family: Courier">rem This happens sometimes and the calculations go wrong</span><span style="font-family: Courier;"><br />if "%currenttime%" EQU "%lastrecordedtime%" goto :LOOP<br /><br /></span><span style="font-family: Courier;"><span style="color: #407f00">rem Use GOTOs so as not to have trouble with delayed environment expansion<br />rem Since the strings are zero-prefixed the string comparisons are equivalent </span></span><span style="color: #407f00; font-family: Courier">to numeric comparisons</span><span style="font-family: Courier;"><br />if "%currenttime%" GTR "%lastrecordedtime%" (<br />CALL :TIMEINCREASED<br />) ELSE (<br />CALL :TIMEWRAPPED<br />)<br /><br /></span><span style="color: #407f00"><span style="font-family: Courier;">rem Elapsed time might be greater than the requested so remaining time becomes negative</span></span><span style="font-family: Courier;"><br />SET /a remainingtime=%1*100 - %elapsedtime%<br />if "%remainingtime%" == "0" goto :EOF<br />if "%remainingtime:~0,1%" == "-" goto :EOF<br /><br />CALL :UNPATCHOCTAL<br /><br />SET lastrecordedtime=%currenttime%<br />goto LOOP<br /><br />:TIMEINCREASED<br /> CALL :PATCHOCTAL<br /> SET /a elapsedtime=%elapsedtime% + %currenttime% - %lastrecordedtime%<br /> goto :EOF<br /><br />:TIMEWRAPPED<br /> CALL :PATCHOCTAL<br /> SET /a elapsedtime=%elapsedtime% + %currenttime% + 6000 - %lastrecordedtime%<br /> goto :EOF<br /><br />:PATCHOCTAL<br /> </span><span style="color: #407f00; font-family: Courier">rem Remove leading zero so as to avoid feeding invalid octals to set /a<br /> rem There might be as much as three "disturbing" zeros.</span><span style="font-family: Courier;"><br /> set saved_currenttime=%currenttime%<br /> set saved_lastrecordedtime=%lastrecordedtime%<br /> if "%currenttime:~0,1%" == "0" set currenttime=%currenttime:~1,3%<br /> if "%currenttime:~0,1%" == "0" set currenttime=%currenttime:~1,3%<br /> if "%currenttime:~0,1%" == "0" set currenttime=%currenttime:~1,3%<br /> if "%lastrecordedtime:~0,1%" == "0" set lastrecordedtime=%lastrecordedtime:~1,3%<br /> if "%lastrecordedtime:~0,1%" == "0" set lastrecordedtime=%lastrecordedtime:~1,3%<br /> if "%lastrecordedtime:~0,1%" == "0" set lastrecordedtime=%lastrecordedtime:~1,3%<br /> goto :EOF<br /><br />:UNPATCHOCTAL<br /> </span><span style="color: #407f00"><span style="font-family: Courier;">rem Return the original string values so that string comparisons work ok</span></span><span style="font-family: Courier;"><br /> set currenttime=%saved_currenttime%<br /> set lastrecordedtime=%saved_lastrecordedtime%<br /> goto :EOF<br /></span></p>















<p>I extracted both the seconds value and the hundreds of a second value, because my initial version would not be very accurate for small delay values (1-5 sec). Since both strings are zero prefixed I can directly concatenate them to generate the effect of (sec*100 + hundreds_of_sec).<br />The batch file takes the number of seconds as a parameter, but it is trivial to change it so that it accepts the hundreds of a second.<br /></p>















<p>Unfortunately this BATCH file takes a little CPU time (3-5% on my PC) so it might not be convenient for some purposes. Maybe someone will come up with a better way to introduced a guaranteed-small delay, instead of pinging the local host.</p>















<p>Oh, and in case you didn't know, the whole 127.x.x.x range is considered a loopback address, so you don't have to type 127.0.0.1 every time. Type something else and look cool to your astounded friends :-P</p>















<p>Finally I should say that I tested the batch file (and it works of course) on Vista and XP.<br /></p>















<p>If you want to test the accuracy of the batch file, then type another batch file as shown below and check things out for yourself:<p>







<span style="font-family: Courier;">@echo off<br />echo Delaying for %1 seconds<br />echo %time:~6,2%:%time:~9,2%<br />call delay.bat %1<br />echo %time:~6,2%:%time:~9,2%</span><br /><p>Have Fun!<br />Dimitris Staikos</p><p /><p /><p /><p /><p /><p /><p /><p /></p></p></p></p></p></p></p><xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/CommonSense4CommonPeople/~4/dmiwWPff00o" height="1" width="1" /></div></content>


    <feedburner:origLink>http://www.commonsense4commonpeople.net/2009/10/delay-command-implemented-as-batch-file.html</feedburner:origLink></entry>
    <entry>
        <title>Too much power management can kill you</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CommonSense4CommonPeople/~3/lj7Ijxwoil4/too-much-power-management-can-kill-you.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2009/09/too-much-power-management-can-kill-you.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-6a00d8341d80a253ef0120a579ee04970b</id>
        <published>2009-09-17T18:36:32+03:00</published>
        <updated>2009-09-17T18:36:32+03:00</updated>
        <summary>QUIZ You can tell that something is wrong when: Something that usually takes half an hour is not finished after 5 hours OR Yet another piece of technology is functioning in unintended ways. A couple of days ago I read...</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>QUIZ<br />You can tell that something is wrong when:</p>



<ol>



<li>Something that usually takes half an hour is not finished after 5 hours OR</li>
<li>Yet another piece of technology is functioning in unintended ways.</li>
</ol>



<p>A couple of days ago I read a tip about <a href="http://searchservervirtualization.techtarget.com/tip/0,289483,sid94_gci1365989_mem1,00.html?track=NL-1429&amp;ad=725111&amp;asrc=EM_NLN_9223648&amp;uid=8528673" target="_blank">4 mistakes that can kill VM performance</a>.<br />#4 was: <em>The default power option of Windows Server 2008 upon installation is set to "Balanced"</em>.<br />Sure as hell it was set to Balanced, so I corrected that one.<br />But tonight something else happened that was related to power management.<br />A backup to network folder was taking far too long.<br />How nice... One more problem to solve...<br />I check the network utilization and see that it was 100%.<br />Now that's a bit unusual... Just a bit...<br />I take a better look and what do I see?<br />Link Speed 10Mbps!!!!!<br />Excuse me??? Where did that come from?<br />To cut a long story short, the Intel network adapters came with a default setting that made them reduce the link speed if the machine is idle. The machine was certainly not idle, but still the link speed was reduced... go figure.<br />I deactivated the setting and got back my 1Gbps with a healthy 30% utilization and my backup was finished in the next 10 minutes.<p>That's why I say too much power management will kill you...<p>Have Fun!<br />Dimitris Staikos<br /></p></p></p><xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/CommonSense4CommonPeople/~4/lj7Ijxwoil4" height="1" width="1" /></div></content>


    <feedburner:origLink>http://www.commonsense4commonpeople.net/2009/09/too-much-power-management-can-kill-you.html</feedburner:origLink></entry>
    <entry>
        <title>Updating WDF on Vista checked build</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CommonSense4CommonPeople/~3/DigRuv26Vz4/updating-wdf-on-vista-checked-build.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2009/09/updating-wdf-on-vista-checked-build.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-6a00d8341d80a253ef0120a5748dca970b</id>
        <published>2009-09-16T18:07:30+03:00</published>
        <updated>2009-09-17T18:38:04+03:00</updated>
        <summary>I had some trouble today with the Windows 7 WDK when I tried to install a driver on the checked build of Windows Vista x86. Actually I found the answer after searching around a little bit, but since all the...</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>I had some trouble today with the Windows 7 WDK when I tried to install a driver on the checked build of Windows Vista x86. Actually I found the answer after searching around a little bit, but since all the information was scattered around, I thought it might be nice to put it all together under one roof.</p><p>Here are the basic facts:</p><ul>

<li>Vista SP2 comes with WDF version 1.7 while the Win7 WDK has version 1.9.</li>
<li>When installing the driver on the checked build of an OS you must supply the checked build of the WDF coinstallers.</li>
<li>The checked build of the coinstaller is named WdfCoInstaller01009_chk.dll but you have to rename it to WdfCoInstaller01009.dll in your installation package.</li>
<li>The checked WDF coinstallers are not capable of updating Windows Vista.</li>
<li>This means that they cannot upgrade the installed WDF version.</li>
<li>This translates to this error message, if you attempt to install the driver:<br />Error 776: The client of a component requested an 

operation which is not valid given the state of the component instance.</li>
<li>And this means that you have to upgrade Vista WDF manually, reboot and then install your driver (still the installation package must include the checked coinstaller).</li>
</ul>

<p>Here is how to do it in a nutshell:</p><ol>

<li>Open the checked coinstaller DLL in Visual Studio or any other tool capable of exporting resources.</li>
<li>Export the WDFCAB_RESOURCE from RCDATA resources and save the file as a .cab file.</li>
<li>Open the cab and extract the .EXE with the long name (Microsoft Kernel-Mode Driver Framework Install-v1.9-Win2k-WinXP-Win2k3.exe).</li>
<li>Open an elevated command prompt and navigate in that directory. Step 5 will NOT work on a non elevated command prompt, although it requests UAC elevation.</li>
<li>Execute: <span style="font-size: 9px; font-family: Courier;">"Microsoft Kernel-Mode Driver Framework Install-v1.9-Win2k-WinXP-Win2k3.exe" /X</span></li>
<li>A bunch of files are exported, among which are wdf01000.sys and wdfldr.sys.</li>
<li>Now you must manually override these .sys files on the target system running on the checked build. This means you have to bypass SFP (System File Protection).</li>
<li>Copy the existing files as a backup measure.</li>
<li>Change the security of these two files so that (a) your account appears as the owner and (b) give your account Full Control (you have to do that explicitly - ownership is not enough).</li>
<li>Override the two files with the checked versions of WDF 1.9.</li>
<li>Pray and reboot :-)</li>
<li>After rebooting install your driver.</li>
</ol>

<p>Have fun :-)<br />Dimitris Staikos</p><xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/CommonSense4CommonPeople/~4/DigRuv26Vz4" height="1" width="1" /></div></content>


    <feedburner:origLink>http://www.commonsense4commonpeople.net/2009/09/updating-wdf-on-vista-checked-build.html</feedburner:origLink></entry>
    <entry>
        <title>Visual Studio Debugging Tip</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/CommonSense4CommonPeople/~3/2SGrhZIuKZ8/visual-studio-debugging-tip.html" />
        <link rel="replies" type="text/html" href="http://www.commonsense4commonpeople.net/2009/09/visual-studio-debugging-tip.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-6a00d8341d80a253ef0120a5c9ae99970c</id>
        <published>2009-09-16T06:56:17+03:00</published>
        <updated>2009-09-16T06:56:17+03:00</updated>
        <summary>More than words can say... ntStatus is declared as DWORD or anything equivalent to unsigned long. Works both for Visual Studio 2008 and Visual Studio 2005. Fare well Error Lookup ;-) Have Fun! Dimitris Staikos</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">More than words can say...<br /><br /><a href="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef0120a5c9ac6d970c-pi" style="display: inline;"><img alt="Watch1" border="0" class="at-xid-6a00d8341d80a253ef0120a5c9ac6d970c image-full " src="http://bruteforce.typepad.com/.a/6a00d8341d80a253ef0120a5c9ac6d970c-800wi" title="Watch1" /></a> <br />ntStatus is declared as DWORD or anything equivalent to unsigned long.<br />Works both for Visual Studio 2008 and Visual Studio 2005.<br />Fare well Error Lookup ;-)<br /><br />Have Fun!<br />Dimitris Staikos<xhtml:img xmlns:xhtml="http://www.w3.org/1999/xhtml" src="http://feeds.feedburner.com/~r/CommonSense4CommonPeople/~4/2SGrhZIuKZ8" height="1" width="1" /></div></content>


    <feedburner:origLink>http://www.commonsense4commonpeople.net/2009/09/visual-studio-debugging-tip.html</feedburner:origLink></entry>
 
</feed><!-- ph=1 --><!-- nhm:dynamic-ssi -->
