Thursday, December 20, 2012

How Many Squares? The Definitive Answer

This appears on Facebook frequently: How many squares to you see in this picture?

The definitive answer: 40. Here's the proof:

Count 'em: 40 squares.

Saturday, December 15, 2012

Schedules and Power Savings

I recently became aware of just how much of my monthly electric bill is due to having 3 computers running 24/7. (I was using AEP Ohio's online consumption calculator to figure out how much it was going to cost me to keep my Christmas lights on for an extra hour each evening: $0.75 for the month of December.) The natural conclusion is to turn off computers when they're not in use. Well, duh.

But what does it mean for a computer to be "in use"? For me, in addition to the obvious it includes the wee hours of the morning when I have my updates and virus scans scheduled to run. In my ideal world, my computer would behave as shown in this table:

DayTime RangePower SettingRationale
All00:00-06:35Stay onBackups, updates, and virus scans are running
M-F06:35-17:00Hibernate after 10 minutesI'm at work so I don't need to use my computer, but I may want to use it for a few minutes before I dash out the door to work so I don't want it to just shut down; hibernate after 10 minutes is about right
M-F17:00-00:00Sleep after 20 minutesI may or may not be home but I want my computer to sleep when I'm not sitting in front of it
S-S06:35-00:00Sleep after 20 minutesDitto

Being the geek that I am, I started trying to figure out how to set up my computer to automatically follow these rules. Recent versions of Windows have configurable power profiles that let you specify a period of inactivity before the computer hibernates or sleeps (as you choose). Unfortunately, these profiles don't allow you to set a schedule for when a low power mode is permissible and when it's not. You can create a power profile that hibernates the computer after 10 minutes of inactivity, but when you activate that profile the computer will always hibernate after 10 minutes regardless of the day or time of day. This obviously won't work for my updating-in-the-wee-small-hours scenario.

My computer's BIOS has a "power-on-schedule" feature. Surely that ought to be of some use. And recent versions of Windows also allow you to create scheduled tasks that will run whenever you program them to. These features, combined with Windows' powercfg.exe utility, provide the solution. powercfg.exe lets you change to a different power profile from the command line (every computer geek's best friend).

For the 00:00-06:00 time range I just use the "Always On" power profile that Windows provides by default. For the other time ranges I created two new power profiles, one named "WeekDays" and the other named "WeekEnds", and configured them appropriately.

I then created three new scheduled tasks (Control Panel -> Scheduled Tasks). One I named "Always On", the second "WeekDays", and the third "WeekEnds". Here's the WeekDays schedule:

The final piece of the puzzle is configuring the BIOS to start up my computer at 17:00 weekdays. If your computer doesn't have this BIOS feature you could create another scheduled task to run powercfg at 17:00 to switch to the "Always On" power profile. To make this one work, since your computer is likely powered off (hibernating) at 17:00, you would check the "Wake the computer to run this task" checkbox on the Settings tab.

Here's to effortlessly reducing the electric bill!

Update [2012-12-17]: The command shown on the Task tab above won't work on Windows XP. Instead you need to run the powercfg.exe command inside a cmd.exe shell. The proper command text to put into the Run field would be:
C:\WINDOWS\SYSTEM32\cmd.exe /c C:\WINDOWS\SYSTEM32\powercfg.exe /s "WeekDays"

Friday, June 15, 2012

Sinking Feeling #12

I love my Android phone (it's an HTC Aria). I replaced both my plain old cell phone and my PalmPilot with this one slim device a year and a half ago and haven't looked back. It's like carrying a small computer around with me all the time that also happens to serve as a phone. Hmmm... no, it's not like that at all; that is exactly what it is. It's a very small computer for which there are thousands of different apps (many of them free!) you can install on it to customize its behavior and extend its capabilities to exactly suit your needs. Of course, if you use a smart phone yourself you already know this. Right? If you don't, then I have one question for you: why are you using a smart phone?

That sinking feeling when...
What with all this benefit I'm getting from my Android phone, there is also a huge risk: losing it. On more than one occasion I've experienced that awful emotion that I call Sinking Feeling #12, the sudden realization that I've misplaced my phone. After losing it (and thankfully finding it) a couple of times I decided to see if there was some help the phone itself could give me. Truth be told, with all the thousands of apps out there, the question isn't really "if" there's a solution but rather "how many are there and how do I go about choosing the best?"

I chose a free app called Lost Phone. After you've installed and configured it, it provides a few very nice capabilities, all commanded remotely by sending a text message to your phone. You can remotely set the ring mode to normal and increase the ringer volume to max; useful for those times where you're sure the phone is somewhere nearby but just hiding under or behind something, and probably with the ringer set to silent. Like like that time it fell out of your coat pocket while you were getting up out of your seat at the end of the movie. (Or are you one of those inconsiderate slobs people who forget to set their phones to silent before the movie begins?)

Then there are the times when it really is lost, like when you left it lying on the table at the restaurant and another customer picked it up, deciding that yippee hooray he had just acquired a new phone. For these situations you can send a different message to your phone that locks it, requiring you to enter your password to unlock it. When it's locked it doesn't operate, but instead simply shows a message stating that the phone is stolen and would you kindly call one of these people at one of these numbers to arrange its return. Also, if a new SIM card is installed your phone will begin sending text messages to a list of phone numbers that you have configured in. These text messages will have the phone number of the new SIM card, helping you track down the new "owner" of your phone, and allowing you to still control it remotely even though its phone number has changed (which I think is very cool). Of course, whoever takes your phone might connect a cable to it and do a factory reset, which will wipe our your Lost Phone app. But it will also wipe out all your very valuable personal data. Because of this, the lock feature of Lost Phone is probably more useful for protecting your data than for getting your phone back. But you never know.

A third option is to send a message that causes the phone to start sending text messages containing its GPS coordinates. Very handy if you've left the phone in a place where there is nobody to hear it ring. (That little trail down to the river, that runs off the main hiking trail, where you laid your phone down to tie your shoe. Remember?)

Lost Phone is not the only app of its kind. It's not even the only free app of its kind; a really quick search on the Google Play store turned up at least 3 freebies. I've not checked, but I would be surprised if they don't also exist for the iPhone.

I've crossed #12 off my list of Sinking Feelings. You should, too.

Thursday, June 14, 2012

Microsoft's 10 Pound Sledgehammer

Last night while I was sleeping, Microsoft hit my computer with a sledgehammer. Well no, not in the literal sense. But figuratively that's what they did.

I sat down at my computer this morning to check email, and found it hung up somewhere in the shutting-down part of a reboot. Since it was pretty obvious the process was going nowhere, I hit the power switch to cycle power and waited for the computer to boot. Once it was up and I could log in, a somewhat familiar status message greeted me in the system tray:

It was familiar because this is not the first time that Microsoft has taken their sledgehammer to my computer in the middle of the night. The first time that happened I opened the Automatic Updates settings and changed the setting to "Notify me but don't automatically download or install them". It had been "Download updates for me, but let me choose when to install them". "Silly Microsoft," I remember thinking back then, "they must not be interpreting those sentences the same way I am." So, I figured taking one step further away from the "Microsoft has total control" end of the spectrum might be enough to take the sledgehammer out of their hands.

It wasn't.

And now I was angry. Angry that despite my due diligence to prohibit Microsoft from rebooting my computer, Microsoft went ahead and did it anyway. A little bit of searching on Google revealed that I am not the only angry one.

So what's the big deal with this, anyway? Why am I so steamed that Microsoft just reaches into my home and reboots my computer without my knowledge or permission? There are a few specific reasons, but they all boil down to this: it's my computer and I get to decide when and how I use it.

I leave my computer on all the time. It performs its backups in the wee small hours of the morning. Sometimes I leave tests running for days at a time (I write software for a living and as a hobby). And sometimes I simply get up from my computer and go to bed without closing files or programs. Hey, my computer is powered by a UPS that gives me plenty of time to shut things down if power goes out. And I am fastidious about what software gets installed and/or allowed to remain on my computer, so I don't worry about virus and other nasties causing it to crash. It doesn't crash. (I hear you Linux-oids snickering out there. Don't laugh; Windows XP can be very stable if you take care of it, and you can make Linux quite wobbly if you don't know what you're doing.)

My expectation is that, unless I explicitly shut my computer down, it is going to stay running. And Microsoft's sledgehammer shatters that expectation.

Okay, so here's what is really going on. It seems that the Windows Update service really is obeying the instructions given to it in the Automatic Updates settings panel. It really is waiting to get my okay to install updates and potentially reboot. But when the Windows Update service itself needs to be updated, that is another matter entirely, and the service doesn't follow the Automatic Updates settings. My Google searching turned up one idea for solving this problem. There are probably more, but I haven't found them yet. I haven't tried this idea yet, but when I do I'll write about it here. The potential solution involves making changes to group policy; go read about it at Tech-Reveal.