14 Jan 2012
A case of revealing double-speak..
The leader of Iran, Mahmoud Ahmadinejad, is currently on a South American tour and getting a lot of support from the socialist/communist Central American leaders there. Not really a surprise. His choice of destinations (Cuba, Venezuela) are well know adversaries of the United States, making him very welcome.
There was one interesting comment during the visits from that infamous Anti-American leader of Venezuela, Hugh Chavez. Remember him? He was the one constantly threatening an oil embargo against the US. He was also the man who stood at the speaker’s podium in the General Assembly of the United Nations, after then U.S. President George W. Bush finished his speech, declaring that the assembly had just finished hearing from the “great satan” himself (referring to Bush, of course). It was extraordinarily overdramatic, indeed.
This week, the same Chavez said the following (quoted from MSNBC here)..
So there you have it. Obviously, Chavez has a double-standard like anyone totally consumed with power and fame, and lines up with typical US-bashers who will say anything to whip up anti-American emotions. So much for his argument of George W Bush being the great satan.
Thanks, Chavez. It’s about time you started speaking the truth.
12 Jan 2012
Folder Manifest 1.0.4.0 Released
This has some small enhancements, including options to include time and size, and optionally change the column separation from spaces to tabs, so the result can be copied directly to an Excel spreadsheet.
See the download page for the current version.
23 Dec 2011
Bulk File Rename v1.0.0.0
Bulk File Rename is a simple windows form application, which allows complex file renaming within a folder, for all or a selected subset of the files. It supports remove, find/replace, prefix, suffix (root or extension), or “insert at” adjustments, and even supports wild cards and character remapping. See the help screen for examples. It works in Windows XP/Vista/7.
This little utility has saved me from a lot of grief over the years. I originally wrote it in Visual Studio 6 around 2004, and have now migrated it to C#.
Visit the project page for more details.
12 Dec 2011
Task Manager: wherefore art thou?
I’ve observed a stange behavior in Windows XP with the Task Manager, which apparently is also rearing its ugly head in Windows 7. The symptoms appear sometime after a few defaults are changed, and a few reboots and application installations or uninstallations occur– just like in XP.
After opening Task Manager, the options menu has the following options, with those selected by default marked with an asterisk.
- Always On Top (*)
- Minimize on Use (*)
- Hide When Minimized
Most users don’t use this tool, other than accidentally discovering it in the task bar’s context menu, and marveling at the pretty graph that rolls by in the performance tab. Sometimes, it is to purposely kill off some stuck process (as instructed by the web help page that Google found for them).
As a developer, I like having Always on Top set to off, and Hide When Minimized set to on. With the latter, the CPU usage is visible in the tray when Task Manager is minimized. This way, I get to look at the pretty graph while testing my application, and have a quick way to open the Task Manager by double-clicking it. Seriously, it is a quick way to monitor memory consumption patterns when processing large amounts of data.
After these modified settings have been in effect for some time, the lower one (Hide When Minimized) “kind of” stops working. This setting will remove the Task Manager from the task bar itself, and leave only graph in the tray. When it “kind of” stops working, it removes it from both the task bar and the tray. A clue that this will happen is the tray icon does not appear when Task Manager is launched with these settings.
The only way I have found to reset them is to do the following:
- With Task Manager open, change the option settings back to their defaults.
- Close Task Manager (don’t minimize it).
- Wait about 1-2 seconds
- Relaunch Task Manager
- Change the settings on options back to the custom setting (Always on top set to off, Hide When Minimized to on).
- Close Task Manager
- Wait about 1-2 seconds
- Relaunch Task Manager
YMMV, but this is what it took for mine to begin working again as desired. I have no clue what caused it to break in the first place. It’s just weird.
05 Dec 2011
Shakespeare was a Million Monkeys’ Uncle?
I received a wonderful email a few weeks ago about the Shakespeare Million Monkeys problem. This problem is actually a statistical challenge embraced by the computing community, and solved with advanced computing techniques like parallelism. The problem is described well in this Wikipedia article:
Infinite Monkey Theorem (Wikipedia),
Weasel Program, a similar concept (Wikipedia)
There is also some additional information on the results of various attempts to automate the solution. They are quite fascinating and worth reading for any software developer.
A few million monkeys randomly re-create the works of Shakespeare (Jessie Anderson–uses Hadoop)
Solving The Shakespeare Million Monkeys Problem In Realtime With Parallelism And SignalR
There is even a Google open-source project for this: http://code.google.com/p/million-monkeys-project/
Basically, the theory says that if an infinite number of monkeys type an infinite number of keys on keyboards, they will eventually write Shakespeare. The odds are astronomically small, but still possible. It is an extension of the Weasel program, which uses a similar concept with the simple goal of generating only one phrase from a Shakespeare novel: “Methinks it is like a weasel”
My focus here is not on the technical nature of the problem, but what is revealed about human thinking by the decisions made in the various software applications written to test the theory. Why? Because somehow the theme of a pure statistical probability is altered as the application developers impose what they interpret as the basic rules of evolution to guide the monkeys.. at least, in code.
All of the examples I have seen for these applications start with creating one or more monkeys who type keys randomly. This follows the theorem, as long as we don’t ask who made the typewriter and left it there. (Yes, yes, it’s the software guys.. I know).
So these monkeys who have been randomly typing away on their keyboards, reproduce other monkeys who also type, and the cycle endlessly repeats to create massive amounts of monkeys typing random keys. This also follows the guidelines of the theorem and evolution, and evolution implies that the monkeys reproduced (the next generation) also inherit traits from the parents, and even some mutations can occur. In software, it can be as simple as giving each random number generator (i.e. each monkey) a different seed, however slightly altered from the original. If you write an algorithm to randomly mate two monkeys, a hybrid seed could be calculated from the mating, with the occasional unexpected seed value to represent a mutation.
So at this point, the monkeys are staying within the boundaries of evolution. If you grant them an unlimited lifespan, they can continue to type forever alongside the multitude of generations of their offspring, allowing for a great variety of comparison among the generations to see if certain mutations or genetic lines are increasing the quality of work toward the desired Shakespearian result.
And that would be a great test of the theorem. But whether it is motivated by lack of resources (or a lack of patience) to let the virtual monkeys continue on for a potentially infinite amount of time, or a desire to test how the result can be driven, some unnatural algorithm to enforce a form of selection or filtering is applied. The algorithm is designed to either prevent the reproduction of those monkeys not producing desired patterns, or blatantly kill them off. The end goal of this reduction is to improve the output of the remaining monkeys, so that progressive generations have a better chance to produce outputs closer and closer to the desired result.
And how is the decision made to determine which monkeys are allowed to reproduce (or even live)? If the spirit of the statistical theorem were being followed, we would have to choose numerous random ways of determining the monkeys to bless or curse with a virtual fate. We could write an algorithm to simulate disease and accidents, with both leading to injuries and fatalities among the monkeys–even accounting for mutations/adaptions resulting from the accidents among the survivors. These mutations themselves could also be represented as beneficial or detrimental.
To keep the code from becoming overly complex, we would disregard things like geographic relocation and separation of groups of monkeys, sporadic reunions of individual monkeys within groups after time has passed (intercultural interaction), and other things that living creatures experience that mold their thinking. The random occurrences of life or death due to random circumstance would be the sole cardinal rule to prevent prejudicial influence on the reproduction of the monkeys. A storm could kill a monkey with no talent, or the next monkey Einstein (or, more topical to the discussion, the next monkey Ralph Waldo Emerson). No one could know who would be affected.
But the filter chosen for the selection process is anything but random. It does follow one rule of evolution, in that there is a penalty/reward altering the behavior of the next generation of monkeys. The penalty is the monkey dies, or isn’t allowed to reproduce. The reward is the monkey creates offspring, which inherits its traits. But the ultimate determining factor used for determining this penalty or reward scenario is quite amusing: How close is your output to Shakespeare?
If the pure random output was simply tested against the Shakespearian phrase or work, the theorem is being tested. But if a decision is made on how (or whether) a new monkey is created, demoted or promoted based on that test result, the end result is being prejudiced. Ironically, that type of filtering is actually creating an answer, instead of an answer naturally evolving.
To better understand this statement, imagine if the monkeys type randomly through the generations and, despite random storms, diseases, wars, personal tragedies, criminal acts, etc, one monkey in the vast array of generations reproduces a work of Shakespeare. That is truly astonishing. Shakespeare was only a measuring stick at interim points in the generations and at the end of the test: it had no influence on the monkeys. A monkey producing a Shakespearian output in this scenario was due to pure chance, and is de facto (i.e. concerning fact). It evolved despite all the circumstances thrown against it. De Facto is the expected result of the theorem.
When the works of Shakespeare are used to test the output, for the purpose of altering future generations in some way to direct them to better Shakespeare-like results, the method of selection becomes de jure (i.e. concerning law). It is in this scenario that Shakespeare is a million monkeys’ uncle: his works are reflected in his virtual offspring, because he is enforcing his standard at every stage of reproductive events.
One thing that is important to keep in mind: in both scenarios, the monkeys are not aware of why they are being killed off or not reproducing. They just keep moving on, typing regardless of the circumstance. The question is whether the great Shakespeare God (in the virtual sense) is intervening in their destiny, or if that Shakespeare output is truly the logical conclusion of random circumstance.
I guess that is up to the monkeys to decide for themselves… and that would be the really interesting algorithm.
Follow-up: I received feedback from several people that the exercise of the theorem is to see if an application can “teach” the monkeys how to progressively get better at writing Shakespeare, until they are writing actual Shakespeare. And a baseline of a Shakespearean final product is needed to do so. I am aware of that.
My commentary here is to point out the “thinking”, so maybe I should point out mine. It is a dangerous thing to mix the terms evolution, monkeys and math together. It introduces the risk of prejudicing a reader’s concept with their preconceived ideas of evolution and monkeys into your theorem. Personally, I question the motive of choosing the word monkey as the symbol, and the word evolution as the process, therefore implying that the math-based theorem is somehow trying to prove evolution. Is it a wrong perception.. of course, but it takes reading the whole article in detail (requiring a technical background to understand the process) to realize that it is not a true evolutionary methodology.
This is where sticking with weasels, or even using dogs or goldfish, works better for the theorem. Each of these are just being taught tricks to produce a desired outcome, and no inference to (de facto) evolution is implied.
21 Oct 2011
The greatest business leader of our time..
Recently, I found myself mourning the loss of Steve Jobs, as millions of other people were. Unquestionably, he is one of the greatest influential business leaders of all time. He’s in a class with such influential leaders as Henry Ford (automobile), J. Paul Getty (oil), Cyrus Vanderbilt (railroads), J. P. Morgan (Steel), and others who didn’t invent their industry, but found a way to make it work directly for individual people in a way never before seen. He has an indelible place in history and, for the current generations, in our minds.
Probably the best tribute I experienced was something Tom Brokaw said on NBC’s Today show the day after Steve’s death. Tom talked about how he was a big fan of jukeboxes as he was growing up, and how the iPod had brought the jukebox back to him. What Steve Jobs’ had led Apple to do affected Tom Brokaw personally. I loved the smile on Tom Brokaw’s face as he told that story: it was genuine and heart-felt.
I have also been seeing the expected cartoons about Steve Jobs encountering St. Peter at the Pearly Gates, and God himself, and offering to show them how they can improve things there. While reading the tributes and quotes to Steve Jobs, something struck me in the oft-quoted extract of Steve’s 2005 commencement speech at Stanford University.
“Your time is limited, so don’t waste it living someone else’s life. Don’t be trapped by dogma – which is living with the results of other people’s thinking. Don’t let the noise of others’ opinions drown out your own inner voice. And, most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary.”
Knowing Steve Job’s beliefs in Buddhism, and to some extent the occult, my heart sank even lower when I read this. It was clear that, barring any last minute radical change in Steve Job’s beliefs, he had likely become a victim of a warning given by Jesus himself in the book of Mark.
“For what shall it profit a man, if he should gain the whole world and lose his own soul.”
Here’s the reason my heart is heavy. The world will remember Steve Jobs in a big way, and so will I. When I compare the parables in the New Testament about the servants and the talents, Steve Jobs was a 10-talent investment who gave back at least 10 talents more. To this, the master would say “well done, thou faithful servant.” Steve Jobs was entrusted with a lot of skills, talents and resources, and he maximized them all. While the world marvels at Steve Jobs, I am sure God himself was pleased to see His own creation serve others through business and charity, and prosper so well–making a great life out of what he was given. He loved Steve Jobs as much as any other person on this planet.
It is just sad to think that someone so talented, who had accomplished so much, would possibly end his life on Earth only to have a fate of being separated from God eternally: a fate that even God himself has stated he does not wish on anyone. But that is the way it works. Only the saving grace of Jesus Christ can bridge the gap between God in heaven and ourselves. All personal and professional success, and regret about our mistakes and transgressions, have no impact on that gap–only Jesus can eliminate the sin that separates us from God, before we draw our last breath and that separation must become eternal.
I truly hope Steve Jobs changed his beliefs in the last hours or days of his life, and was able to accept Jesus’ personal offer of forgiveness and salvation. But if not… it would be far from the first or last time it has happened. And, it would be another reminder of our personal priorities: something God puts in front of us from time to time in our lives.
“Seek first the Kingdom of the Lord, and all these things shall be added unto you.” says the Lord. Everything else is secondary.
21 Sep 2011
The relations between controls and idle states in a Windows Form
I recently wrote a code conversion project, with a simple windows form to review and adjust the results. It had a list view container on the left to enumerate the scripts, and two text boxes on the right for the selected script in the list: the top for the original script, and the bottom for the result of the programmatic conversion. The conversion was 100% correct in about 95% of the scripts, so the human element was needed to catch exceptions that the code converter missed and make adjustments.
I added code in the instantiation method to populate the listview control from its database source. To save the user unnecessary mouse movement and clicks, I then added code to iterate through each script on the first pass, and convert the script. This saved the user a few button presses to convert and save, where no script adjustment was needed–the vast majority of cases. The user, while reviewing scripts, could also reconvert the script with a button press to reset to the original content if any change needed to be reset.
I wrote the load and update methods for the scripts to operate on the currently selected item in the ListView. So the code to pre-populate the script conversions used the .selected property to select the script to operate on, then called the Load/Convert/Update methods to do the work. These db-layer methods used the table identity value, stored in the .Tag property of the item. Afterwards, the .selected property was set back to false before the next iteration.
The code worked fine when the user would click on an item in the list view, but the initial population would throw an error saying “index out of range”. I discovered the problem when I single-stepped the code in the pre-population. While the .selected property of the item was set to true, the .SelectedItems and .SelectedIndices properties both still showed a count of zero on the next instruction.
I began to recognize that I had a state problem with the ListView object. While the property is set to true, these other properties are not updated until the method completes, and the windows form thread bubbles its way out of your method through the various wrappers, and returns to an idle state. The problem is similar to the orphaned tray icon problem (see Preventing the orphaned system tray icon in a Windows App). So to use the ListView as the indexer in my loop, I needed to implement an idle state, and move the work into a timer event. An example of the code is here.
One other approach is to write the GetScript() and UpdateScript() methods for the individual scripts to take the identity value as a parameter. This would facilitate both a straight index from a loop, and a selected ListViewItem (i.e. passing the stored identity from the .Tag property, etc). If you plan on doing bulk actions on your items in the ListView manifest, this is a better approach. But if you are inheriting code that just needs to have bulk actions added where previously only actions on selected items occurred, and the code is highly intertwined, this is a way of using the existing windows control’s selection work when using iteration.
21 Sep 2011
Dead yeast make no bubbles.
The last several batches of beer I made had problems with carbonation after bottling, and the problem was eluding me. I had a conversation with a fellow home brewer at work who helped me determine the cause: yeast dying before the bottling process was complete.
The problem started when my yeast starters were creating very active fermentation, reducing the fermentation time and increasing the alcohol content. I also compounded the problem by waiting 1 or 2 days longer than I should have to bottle, after the fermentation was complete (i.e. over 1 minute between bubble bursts.
So in my last batch of beer (Stout), I tried something different: I saved some of the yeast I was pitching in a sanitized container, and stored it in my fridge. As I was siphoning the wort into the bottling bucket, I added the stored yeast and the fermenting sugars to the wort. It worked. Only 5 days into conditioning, the bottles were producing the usual 1-2 inch head I expect.
Lesson learned: the very by-product produced by yeast (alcohol) as it consumes its food (sugar) is toxic to the yeast itself. So carefully watch for the time when the bubbling cycles go below 1 minute. That means your yeast is gasping, and it needs new food to continue its life.
14 Aug 2011
The mysterious mutating power properties .. SOLVED !
Back in 2009, I wrote a post related to issues of mutating power settings in Windows XP Media Center (I’ve got the Power! … but not over power properties?!). Since then I have seen the problem also on Windows XP Professional, and on multiple manufacturers laptops (HP, Gateway and Dell). After digging a little further, it seems the problem is related to using a laptop as a host for RDC connections for multiple user accounts, which exposes a design strategy in Windows XP that conflicts with this use.
The power properties are strange. Instead of being stored at the local machine level in the registry, they are stored at the user level. There is a setting for the default user, and an override for each user account (which initially is only the same as the default). That means that user A can choose to enable hibernation, while user B can choose not to. That’s a strange design choice to me. I can only assume that a user case was drawn up that most laptops are “personal”, only one user account exists for it, and it’s predominant use will be on demand use (i.e. not continuously available). So the default was designed around this case.
Since I use at least two laptops with multiple user accounts in a continously-on mode, and have them sitting under a desktop with the lid always closed, the default Microsoft chose is what is causing me continuing problems. I can set the proper power properties while I am logged on but, without changing the global user defaults, the next user will inherit wrong settings.
Knowing this now, the best way to establish the power scheme on a freshly-paved laptop to be used in this mode is…
- Setup the laptop with a new power scheme definition designed for its operation, and set that new power scheme as the active power scheme.
- Open RegEdit, and export this branch to a file: HKEY_CURRENT_USER\Control Panel\PowerCfg
- In the file just created, change all references of HKEY_CURRENT_USER\ ..to.. HKEY_USERS\.DEFAULT\
- Import this file into the registry.
This will set the default to the proper value, and every user who initially logs on from this point forward will inherit those default setting into their account.
Still, this does not solve the problem of a user logging on, changing their settings, and causing the laptop to initiate sleep, standby or hibernation; thereby taking the laptop offline. One way that can be addressed is with permissions on the registry branch. Still, most people aren’t that interested in power settings, especially when they login to a computer they don’t see or manage.
FWIW: If you’d like to reset the power settings to a fixed profile every time a user logs on, you can set this batch script to execute at logon. It will create a schema for the power settings, program the settings, and make that schema the active one. It will at least undo any tinkering done by a user the next time they log off.
@echo off REM REM This script sets the power properties to prevent standby or REM hibernation while the computer is running on AC power. REM It creates a power scheme called AlwaysOn-RDC-Multiser, and REM sets the system to use this power scheme. REM REM This script is intended for laptops or even desktops, which REM are always running and are used as dev "slop-boxes" to test REM prototype code or are doing heavy-duty R&D work in a "not REM ready for production" capacity. It prevents the computer from REM going into standby, sleep or hibernation, regardless of the REM user's preference. REM REM ** This script needs to be run as a startup script REM ** when a user logs in. To do this: REM 1) Start / Run REM 2) gpedit.msc REM 3) Drill down to Local Computer Policy / REM Computer Configuration /Windows Settings / REM Scripts (Startup / Shutdown) REM 4) In right panel, double-click Startup. REM 5) Click the Add button. REM 6) In the Script Name, enter the full path for this file. REM 7) Leave the Script Parameters blank and click OK. REM powercfg.exe /C "AlwaysOn-RDC-Multiser" powercfg.exe /H ON REM ** CORE SETTINGS ** powercfg.exe /X "AlwaysOn-RDC-Multiser" /monitor-timeout-ac 0 powercfg.exe /X "AlwaysOn-RDC-Multiser" /disk-timeout-ac 0 powercfg.exe /X "AlwaysOn-RDC-Multiser" /standby-timeout-ac 0 powercfg.exe /X "AlwaysOn-RDC-Multiser" /hibernate-timeout-ac 0 powercfg.exe /X "AlwaysOn-RDC-Multiser" /processor-throttle-ac NONE REM ** CORE SETTINGS ** powercfg.exe /X "AlwaysOn-RDC-Multiser" /monitor-timeout-dc 10 powercfg.exe /X "AlwaysOn-RDC-Multiser" /disk-timeout-dc 10 powercfg.exe /X "AlwaysOn-RDC-Multiser" /standby-timeout-dc 0 powercfg.exe /X "AlwaysOn-RDC-Multiser" /hibernate-timeout-dc 0 powercfg.exe /X "AlwaysOn-RDC-Multiser" /processor-throttle-dc NONE powercfg.exe /G ON /OPTION BATTERYICON powercfg.exe /G ON /OPTION MULTIBATTERY powercfg.exe /G OFF /OPTION RESUMEPASSWORD powercfg.exe /G ON /OPTION WAKEONRING powercfg.exe /G ON /OPTION VIDEODIM powercfg.exe /S "AlwaysOn-RDC-Multiser"
07 Aug 2011
Finally, Internet-based irrigation control for the tech-savvy homeowner
So that you know up front: I have neither purchased nor ordered the device yet. I’m not promoting it. I am just publishing this because so many people I talked to over the past few years really wanted what this device does and, like me, couldn’t find anything like it.
I’ve been repairing my 5-year old Irrigation system recently, and I am revisiting an idea to control and monitor the irrigation system via the internet. The first time I did my research, I could only find controller systems in the $300+ range that could do this, and they were mostly designed for commerial use instead of residential use. Even worse, they wanted a monthly subscription fee, because the device would only interface through a server provided by the seller.
Enter 2011, and I am revisiting the issue as I do my repairs and maintenance. After digging a bit through the forums, I found a link to Irrigation Caddy, and it is exactly what I am looking for. It is a self-contained controller with a 10/100/1000Base-T interface (i.e. hard-wired Ethernet). It has the zone controller connections for the solenoids, and a built-in web server for configuring the device. And the cost… a really cool $129.95.
So this device is half the price of the cheapest typical commercial units, and requires no monthly fees. To connect this to a wireless router, since I have no way to get an ethernet cable to it, it only needs a cheap bridge to add wireless to it. This is a great solution for people who manage their network routers themselves, and want to interface their irrigation system control to it.
The company now also mentions an iPhone app written by a third party, which can control the application as well. See thier blog for details.
I don’t know whether the device is capable of detecting and reporting a faulty zone controller (I would think it does). The S1 version of this device ($149.95 instead of the $129.95 for the base model) also includes support for a rain sensor, which signals the controller to cancel the watering action when it has detected an adequate amount of rainfall. This is a requirement in a number of places, including the area of Florida I live in (managed by the St. John’s Water Management District).
I am excited and pleased to see that someone finally built an irrigation controller for DIY’ers.

