Categories
Uncategorized

Leap year programming questions

I received two notes on this happy leap day that there was a problem someone was having in with accounting for leap years in their code.  Both were quickly solved.

The first was programming for a leap year that turned out to be a common problem.  The programmer was checking for leap year by dividing the year evenly by 4, and seeing an error when looking at historical transactions in 1900 and 2000.  Centennial leap years can only be evenly divided by 400.

The other was with the use of the ATL COleDateTime API related to handling leap years in Visual Studio and .NET Framework.  It turned out that the workaround referenced in this article on Connect solved the issue: http://connect.microsoft.com/VisualStudio/feedback/Workaround.aspx?FeedbackID=98949

Tags: leap year, Visual Studio.

Categories
Uncategorized

New York Times: The paperless office at home. In the end, it’s just more stuff.

Hannah Fairfield of the New York Times reports today on the effect of a family going paperless.



“Chris Uhlik’s children can be found in their home computer lab almost every morning. Nicole is writing a story about her two lizards. Tony is playing an interactive spelling game, while Andy is learning multiplication tables. Even 5-year-old Joceline is clicking away at a storybook game.


“Mr. Uhlik, an engineering director at Google, and his family live a practically paper-free life. The children are home-schooled on computers. Other sources of household paper — lists, letters, calendars — have become entirely digital.”


Although going paperless was the Uhliks choice, we see many families going paperless each day.  From online, web-based billing and payment systems, to mortgage statements and even weekly coupons from chain stores, we see more and more of our content coming online. Add to that the scanner we have at home (actually, three of them when you count the ones in the family room, kid’s computer and our home office), we’re finding ways to reduce clutter.

I prefer receiving the offending hard-copy items in electronic form, otherwise I face another problem: finding the time to scan all this paper with the paper-reducing technologies available to us.  I have a stack of stuff collecting to scan, and then you have to manage, back-up and store the digital files (not quite zero footprint). 

The Times article goes on to reports that…


“After rising steadily in the 1980s and ’90s, worldwide paper consumption per capita has plateaued in recent years. In the richest countries, consumption fell 6 percent from 2000 to 2005, from 531 to 502 pounds a person. The data bolsters the view of experts like Mr. Kahle who say paper is becoming passé.”


That may be so, but add to the plateau of content the proliferation of digital content that has been added.  Just because more bits arrive via the broadband service provider rather than the US Mail doesn’t mean that there is not an impact: see How much does spam weigh- (And what to do about it): as I noted, over the course of two weeks, we collected a little more than the reported national averages:



  • 36 pieces of mail, totaling 2 lb 6oz (or about 63 pounds a year), and
  • 80 pieces of junk mail, totaling 10 lb 6.6oz (a little more than 270 lbs per year)

Now that doesn’t sound like much, but in comparison let’s look what came in just to my personal email address at home: 232 pieces of junk mail. That’s 149 caught by my Outlook spam filter and 83 snagged by my Internet service provider. If that junk email were junk postal mail filling my post box, it would weigh close to 31 pounds. Over the course of a year, we’re looking at more than 6,000 junk emails, at a total weight of about 792 pounds.

Ouch.


“Paper is no longer the master copy; the digital version is,” says Brewster Kahle, the founder and director of the Internet Archive, a nonprofit digital library. “Paper has been dealt a complete deathblow. When was the last time you saw a telephone book?”


Au contraire.

You still see so much paper around the office in the form of hard-copy presentations; in contrast, good to see that the majority of white papers and reports I’ve read lately have been made of recycled digital bits rather than bits of recycled paper.  How many times have you heard a coworker lament about the so-called paperless office when faced with a mountain of documentation collected by the end of the work day?  And add to that the number of pages our kids print out when working on a school project, screen captures and artwork (“I love those Pokemon pictures you found on Live Search, CJ… all thirty of them on individual sheets.”).

And am I the only one using Outlook to manage my menagerie of digital statements, reports and documents from outside the home?  Yes, I save web pages and other online documents as XPS files to my computers, and I use Paperport to manage my digital collection of PDF files.  But I have a larger number of archived mails in my Inbox and saved mail storage by a factor of 100.  Companies creating these files make it easier to archive, by sending links to online pages that are archived for as long as I need to hang on to a page for tax purposes, rather than the year or two that many companies seem to support.  I also save digital copies of web files using IE’s Page -> Save As… Web Archive Single File .mht formatAnd heck, I even use my own blog to keep track of what I’ve recently read via my favourite, now-Yahoo!’s del.icio.us (I love Flickr, too ;).

So kudos to the credit card companies, online service providers and banks proving these statements, as well as the newspapers I read regularly more online than I do in print (although there is still an incredible cachet that surrounds the Sunday Paper – capitalized for reverence ;).  And thanks to magazines like Forbes, Fortune, BusinessWeek (and others I subscribe) for making their current issues and archives available. 

Want tips on how to reduce your junk mail? Visit the Privacy Rights Clearinghouse for info: http://www.privacyrights.org/fs/fs4-junk.htm

Also of interest…


The Paperless Home 

The Paperless Home


Paper Trail 

Paper Trail


 


Tags: environment, spam, paperless, home, scanners, New York Times.


Delicious Bookmark this on Delicious Bookmark and Share


Also available via http://bit.ly/ch7kHp

Categories
Uncategorized

Your questions: “when should I use Sleep and Hibernate modes on Windows?”

I get the question a lot on sleep vs. hibernate (and as noted in a recent post), and it came up today in a discussion. 

“I’m confused by the different selections I have in the Start menu… when should I use Sleep and Hibernate to turn off my computer?”

In Sleep (or standby), you’ll see that the computer is generally off, with a trickle of power keeping the computer’s memory powered.  When you use your PC throughout the day, but leave for extended periods (lunch, meetings, even overnight), Sleep is a good choice.  And (depending on your model) all it takes is a mouse movement or keyboard tap to wake the computer up. 

One of the reasons I also have a UPS on my main desktop at home is that I use Sleep most often, and if the computer loses power, the work you may have open but not yet saved will be lost.  And on our notebooks at home (and at the office) we use Sleep given that the computer’s battery acts like a mini UPS and generally has enough power to keep the memory alive. (Note that we generally keep the notebooks connected to a power supply as well.)

When I leave for the weekend, I often use Hibernate on my PCs at the office and at home.  In this state, the PC’s complete memory state (the contents of RAM) is saved by writing to the hard disc and the computer powers down.  When you turn the computer back on (recovering from hibernation) via the hibernation file, you start up where you left off.

This from TechNet:

When a PC starts up, Windows Vista performs many processing tasks in the background, returning control to the user much sooner than previous versions of Windows. Even this short wait happens less frequently than before, because instead of shutting down the computer to save power, users can use the new Sleep state, the default state for turning off computers running Windows Vista. Sleep combines the resume speed of Standby mode with the data protection and low power-consumption characteristics of Hibernate. When entering the Sleep state, Windows Vista records the contents of memory to the hard disk, just as it would with Hibernate. However, it also maintains the memory for a period of time, just as Windows XP maintains the memory in Standby mode. Windows Vista enters and recovers from Sleep state in seconds, and while the system sleeps, power consumption is extremely low.

The most significant benefit of Sleep is simplicity; users don’t have to choose between using Standby or Hibernate because Sleep offers the best of both.

As a follow up, here’s a little more information on Sleep and Hibernate modes in the OS, as the Productivity Portfolio weblog has a good post that describes the Windows XP power schemes.

More info:

Click here for more on fast sleep and resume in Windows Vista.

Click here to learn how to use your computer efficiently and to save energy by activating Sleep mode for your monitor.

Also see this Search on Live.com for more on sleep and hibernate in Microsoft Windows.

Tags: performance, tips, Windows Vista, notebook, hardware, hibernate, sleep, customer experience.

Categories
Uncategorized

Forget Y2K, DST and Time Zones: this weekend, it’s the Y2.038K bug

This weekend will mark another interesting milestone in Time and Date, oone that actually doesn’t occur for thirty more years, in 2038.  

Also known as the ‘Friday the 13th’ bug, the 2038 issue is due to the way 32-bit systems note time in seconds rather than by an actual coded date.  The full impact will be felt on January 19, 2038, when systems many not work accurately, or even crash.  The initial wave of the challenge would likely impact customers in the financial sector, particularly those with (pardon the pun) an interest in long term products (mortgages, investments, bonds) with maturity dates post Jan 19, 2038.  But those with longer maturity instruments would’ve seen an impact years ago.

As this involves dates and times, Wyn asked today about this impact, as this smacked of an issue similar to what we saw last year with the various DST and time zone changes around the world… 


“I have not found too much on this and I am not sure if anything is know or being done to avoid the problem…”


Good question.  I asked several of our product groups if any of our products will be impacted by the date.

A nod of thanks to Geoff for noting this MSDN article from way back in 1998, “All Ready for 2000 and the Euro? What About 2038?” (September 7, 1998).  If Y2K did anything for the industry, it was to spur an analysis of any date and time issues that could impact the operating system and software products…



First it was Y2K. Then the Euro conversion. And now, as if the Y2K and Euro problems weren’t bad enough, there’s the year 2038 bug. Dr. GUI got a letter from Mahmoud Saleh alerting him (reminding him, actually) of a similar problem that will face C and C++ programmers in coming years: we can call it the Y2.038K bug.

The problem stems from the common definition of the time_t as an integer containing the number of seconds since midnight, January 1, 1970. Most C/C++ runtime libraries define time_t as a long int. On most systems, long int is 32 bits, which means that we’ve got a range of 2^31-1 (2,147,483,647) seconds—until sometime on January 18, 2038. (Assuming Dr. GUI’s Windows CE Palm-size PC has it right, that’s a Monday. Figures.) When the clock rolls over, it’ll be back to the ’70s for everyone. Get your leisure suits ready ‘cuz you’ll be catching Boogie Fever and Nixon will be President again. Four more years indeed!

Anything that uses time_t is also in trouble. That includes the time_b structure (not commonly used, anyway) and, very unfortunately, the MFC CTime class. Code that uses time_t, directly or indirectly, will need to be changed sometime before you start dealing with dates after 1/18/2038. (Note that if your program deals with, say, 40-year bonds, you’re in trouble today.)


As Geoff pointed out, SYSTEMTIME has no problems and can go until the year 30,827, and FILETIME, a 64-bit integer (two DWORDs representing LOW and HIGH values) since January 1, 1601 (Julian).  It too can represent a 30,000 (or 60,000 unsigned) year interval.  From the MSDN article:


…the Win32 SYSTEMTIME structure… stores the year part of the date as a 16-bit integer, and the Win32 FILETIME structure, which stores the date as the number of 100-nanosecond intervals since 1601. The problem is that neither of these structures have many supporting functions.

Better yet is to use the automation DATE object. DATE is typedef’ed as double, so there are 53 bits of precision—enough for your program’s lifetime. The whole part of the double number represents the number of days since midnight, December 30, 1899. (Negative numbers are before 12/30/1899.) The absolute value of the fractional part represents the time in the day: midnight is zero, noon is 0.5, etc. You can convert the automation DATE objects to other formats with various variant API functions.


Overall, the advice is that if you have custom applications you might want to check to see if they are using C/C++ time_t, which will run out in 2038.  Just as I noted previously on how Windows handles historical events, you might want to check any custom or ‘home-grown’ line of business applications that use time_t.  Looking quickly at Windows, the core OS appears to run just fine with dates far into the future. 

I will have to check one of my old Apple systems at home running (quite reliably, I might add) System 9, which according to Apple, is good up until February 6, 2040; the current Mac OS up until 29,940… Windows will be accurate for an additional 887 years after the latest Mac release fails, but I’m sure Apple will have an update long before 29,940 rolls around. 😉 

(Interesting factoid that stuck in my mind: in the H. G. Wells classic novella, The Time Machine, the hero of the story travels to the year 802,701 A.D.  I’m hopeful in that future, the downfall of mankind will have nothing to do with the failure of the modern OS to cope with dates past the 301st century.)

For more information, please see these articles courtesy of a quick MSDN search

Tags: Apple, Microsoft, Vista, Windows, Time, 2038.

Categories
Uncategorized

Windows Vista RC1 brings improved performance, but consider spring cleaning your PC

(Note: info on the release version of Windows Vista Service Pack 1 is available here. This article discusses whether or not you should install a service pack directly from the Microsoft Download Center or wait for installation via Microsoft Windows Update.)


OK, lots of feedback (generally positive) from folks on my post from yesterday, Windows Vista Service Pack 1 RC Refresh is publicly available. Should you install it- Depends.  I guess that yesterday’s game in Green Bay had folks in a bad mood…


One of the reasons to install RC1 will be the improved performance.  I’ve found this first hand, particularly when using Vista Sleep (S3 mode) and Hibernate (S4).  With RC1, I have moved to use Sleep (S3) almost exclusively for my office workstations and notebooks, as well as for machines at home. 


One of the biggest complaints I’ve heard from customers is the amount of time it takes to recover from S4 and even from S3 in Vista RTM.  This combined with some overall sluggishness in machine performance which people found with Vista that they didn’t see on their trusty Windows XP SP2 system (particularly in upgrade scenarios).


Writer James Fallows posted this week that Kenneth Rhee is apparently considering a move back to the Mac after moving to Vista, due in part to a slow recovery from hibernation:


…Just the other day I had my MacBook Pro packed for a trip, and I had to do something quick at the last minute before we departed, and I turned on my hibernated (not sleep mode) Thinkpad check on one email quickly.

Believe or not it took the Vista laptop 5 minutes to wake up and restore for me to get the work. My MacBook Pro boots cold much faster than this! In the meantime, my wife was waiting for me to come down from my study and getting anxious

Ouch.


Serendipitously enough, we were looking at this very customer scenario this week at the office, following a fresh install of the latest Vista service pack, SP1.  The biggest challenge we’ve had on my son’s notebook is the amount of additional software installed by the manufacturer.  In Max’s his view (and mine) the additional applications and add-ons seem to hit the performance of the new desktop replacement machine, making it “really slow” in his words. 


I have found (as have many others) that uninstalling various pre-installed software can improve performance.  In more drastic situations, reinstalling the OS with a clean boot makes for an improved customer experience (assuming that the OEM makes it easy for you to find all the needed drivers, add-on software and utilities). 


Here’s the cautionary note: Before you take such a drastic measure as the latter, I first recommend that you delete what appears to be add-on software that loads on boots and items you don’t need that are littering your Windows Vista taskbar.  You can accomplish this by uninstalling software using the Programs and Features control panel in Windows Vista, or by using the uninstaller included with the application or service.


So I took the management challenge after my boss waded through a clean install on his new notebook, and reinstalled the Vista OS complete with the new service pack on to a stock Dell Inspiron 600m laptop (nothing special, two year old machine).  Again, make sure that you have all the basic drivers for your machine saved on a CD or USB memory stick, just in case.  Kudos to Dell and HP for making this a painless process on their customer service web sites.


My unscientific findings: with a clean install on an old laptop, it takes only 20 seconds to recover from Hibernate, and less than five seconds to recover from Sleep.  A DVD inserted in the drive is playing in less than 20 seconds. 


And this post by Megan McArdle at The Atlantic, who uses a Mac “because The Atlantic uses Macs.”



I appear to be the only person in the known universe who did not have a problem with Vista. My Sony Vista laptop was fast, woke up out of sleep mode just fine, and if I had any complaint it was with the crap Sony loaded on it, not the OS itself. Vista itself was lovely, though I turned off the damn security alerts.


Here’s more info on improving PC performance by removing pre-installed items:



Tags: performance, tips, Windows Vista, notebook, hardware, Dell, HP, customer experience.


Delicious Bookmark this on Delicious Bookmark and Share