Documentation overload

Peanut allergies are really only a problem if you can open the package…  Oh wait, now I figured it out…

So I should probably take the jackhammer back to the tool rental place, I guess I won’t be needing it to eat my Kit Kat bar.

Sansa e250 database rebuild

For some reason, my Sandisk Sansa e250 MP3 player was stubbornly refusing to acknowledge the music that I was copying to it. I tried just about everything I could think of short of formatting the device to get it to see my folders in the Music folder. My device has the latest version 1 firmware upgrade, and I have tried to use both MSC and MTP mode to copy folders to the device, all to no avail.

Finally, I found out that I could force the device to do a database rebuild by doing the following steps, which should work on any Sansa e200 series MP3 player with the version 1 firmware:  (WARNING:  Please do not do this if you are worried about making your device inoperable.  There is always a risk that this will happen when you start futzing with the system files.)

  • Go into the Settings screen and scroll to USB mode, and set it to MSC
  • Connect the device to the computer
  • Once the device mounts as a drive on your computer, browse to the device, look for the System folder, and the Data folder in that folder
  • Delete the file called PP5000.DAT
  • Disconnect the device

Once you disconnect, the device will restart, and it should refresh the database. If you prefer MTP mode, make sure to go back into the settings to change it back.

Gmail phishing warning

I think that Google might have the Gmail phishing filter set just a tad too strong. I was in my Gmail account this morning and accidentally clicked on the very first message I got in the account, which is of course the introductory e-mail that describes how to switch your existing e-mail over to Gmail. Here is what I saw:

.NET Kombat (Format vs. ToString)

In converting some legacy VB6 code to VB.NET, I noticed that there was a lot of use of the Format function in the code to convert numbers to strings. This makes sense as Format was pretty much the only game in town in VB6.

However, in .NET, they introduced a handy-dandy .ToString() method that, on the surface, seems to do much the same thing as the Format function. I have been able to use them pretty much interchangeably with the desired results coming out every time.

I started to wonder which way was faster. Since I am a big proponent of empirical knowledge instead of just trying to get the theoretical story behind the two ways to do this, I rolled together this quick VB.NET console application:

Imports System.Text
 
Module Module1
 
    Sub Main()
 
        Dim i As Integer
        Dim r As Random = New Random()
        Dim t As Double
 
        System.Console.WriteLine("10,000,000 Formats")
        Dim sb1 As New stringbuilder
        t = Timer
        For i = 1 To 10000000
            sb1.Append(Format(r.NextDouble * 100.0, "###0.00 "))
        Next
        System.Console.WriteLine("Seconds elapsed: " + (Timer - t).ToString("#######0.00"))
        System.Console.WriteLine("Length of string builder: " + sb1.Length.ToString())
        System.Console.WriteLine()
 
        System.Console.WriteLine("10,000,000 ToStrings")
        Dim sb2 As New StringBuilder
        t = Timer
        For i = 1 To 10000000
            sb2.Append((r.NextDouble * 100.0).ToString("###0.00 "))
        Next
        System.Console.WriteLine("Seconds elapsed: " + (Timer - t).ToString("#######0.00"))
        System.Console.WriteLine("Length of string builder: " + sb2.Length.ToString())
        System.Console.WriteLine()
 
        System.Console.WriteLine("Press any key to end the program ")
        System.Console.ReadKey()
 
    End Sub
 
End Module

And here are the results:

As you can see, the ToString method is about 15% faster when doing 10 million calls with random numbers.

Oh, and by the way, Happy Pancake Day.

Weird Stuff Warehouse

A co-worker brought this link to my attention:

Silicon Valley’s Island of Misfit Tech

I can’t believe that, with all of the trips that I have made to the Bay Area, that I never heard of this place or stumbled upon it by accident. I so want to go there now to look for a copy of Microsoft Bob. Or maybe I should try to sell my copy of Microsoft Dogs.

UVa Online Judge runtime error

It has apparently been a long time since I had to do any kind of reading and writing from the console in C.

I was trying to work through the Minesweeper problem on the UVa Online Judge site, and my submissions kept failing with a “Runtime error”, with no explanation given as to the source of the problem. Of course, everything was working swimmingly when I was trying to run through the code as a command line application in Xcode on my Mac. Some investigation into this led me to pad my arrays and strings so that there was no chance of an array index going into areas they were not supposed to, but it was still failing.

I finally discovered the problem was that I had used an int variable in my code, but a %i instead of a %d in the scanf format string. As soon as I switched that over, the “Runtime error” went away. And I was able to move on to the “What do you mean ‘Wrong answer’???” part of my evening.

Oh, and Happy Data Privacy Day everyone.

Easy way to format the time difference between two dates

In converting my VB6 code over to VB.NET, I was looking for an easy way to take the different between two DateTime items and display in hours and minutes.  The TimeSpan gives a nice structure to dive into the difference and see exactly the interval, but I was hoping to find a way to output this in the same way that you can use the ToShortTimeString method of DateTime.

As it turns out, I found a posting by Jay Barlow that mentions converting the time different to a date time, and then using a custom format string to do the work so that I wouldn’t have to.  Here is my new VB.NET code, where rec is a class that includes the start and end date and duration is a string that holds the information to be displayed:

If rec.endDate IsNot Nothing Then
    Dim ts As TimeSpan = CDate(rec.endDate).Subtract(rec.startDate)
    Dim dt As DateTime = DateTime.MinValue.Add(ts)
    duration = "Event duration: " + dt.ToString("H:mm")
End If

Oh, and one more thing. Am I the only one in the world that thinks that iPad is the worst product name in history? Sure, it is so close to iPod so as to create brand recognition and draw comparisons, but I would just wonder what kind of names were shot down, and if any of them did not begin with the letter i.

By the way, Happy (Belated) Australia Day.

My Tracks Android app review

I saw a news blurb a while back about this new app from the Google folks called My Tracks. I downloaded it to my Droid right away, but really didn’t try it out until today.

So I decided to try and use the application while walking one of my dogs. The navigation around the application is pretty simple, and the track recording seemed to work very well. After I got back from the walk, I was able to see the path that I walked along with a bunch of statistics about it.

The program has upload options to send to Google Docs and Google Maps, so I tried them both at first. This first upload did complete to my Google Docs, but I did have a bit of trouble when it tried to upload the track to Google Maps. The first few times I tried it, I got some miscellaneous errors, such as an authentication error and other nondescript messages. Finally it did go through, and the track then was showing up on the My Maps page of Google Maps.

Even though this app is in the early stages of development, I think it rates quite well. I would give it a 4 star rating, if only because I had some trouble getting the Google Maps upload working.

If you can find it in your heart to help out a fellow nerd, please help out Shawn Powers, he is having a tough go of it. Here are the details:

Urgent: Help Shawn Powers & Family

Oh, and I hope everyone out there had a good Martin Luther King Day.

VB.NET radio button groups act differently than VB6 radio button groups

The few dozen remaining WinForms developers left on this planet may have noticed that, for some reason, a group box with radio buttons in it as designed in the Visual Studio 2008 environment will have the first radio button of the first group box automatically selected when the form comes up, even though all of the radio buttons have their Checked property set to false in the design environment.  It never used to do this in VB6, as when you ran the application, the group of radio buttons would have no members selected.

The problem manifests itself when you are trying to perform additional tasks in the CheckedChanged event of the radio buttons when the user selects one of the radio buttons, since the first radio button is being automatically selected.

I asked this question on Stack Overflow, and got a couple of replies. The one that I finally used to solve the problem was to set the Checked property of the radio buttons to false in the form’s Shown event, which I had never used before. By doing this, the first radio button was no longer automatically showing up checked.

One other thing that I had to do in addition was to cast the sender into a RadioButton and look at the Checked property of the clicked radio button in the CheckedChanged event, as that event is fired for radio buttons both being turned on and also turned off.

Oh, and happy National English Toffee Day!

Nerdski

I have always enjoyed alpine skiing ever since the first time that I went to the local ski area in Ohio. I don’t make it to Brandywine much any more because I have been skiing in the West many times over the years, and once you go there, it is hard to go back to the little ski bumps. (Even though I live closer to the Ohio bunny slopes now than I ever have.)

A few Christmases ago, my wife bought me a deck of playing cards called Ski USA, A Bird’s-Eye View of 52 of the Best Ski Mountains, with each of the 52 cards having a trail map and vital statistics for 52 different American ski resorts. In this new decade, I have made a resolution to try and make a go of visiting the rest of the 52 resorts depicted on the playing cards that I have not been to yet.

I put together a Google Earth KML file with the 52 resorts on it, if you want to use it to track your own progress.

Ski USA KML file (Google Earth)

BTW, if you are interested in buying the deck of cards, here is a link to it on Amazon’s web site:

Ski USA Playing Card Deck

I am thinking of heading to New England in the winter/early spring time frame, if anyone has any suggestions about which of the resorts to visit, please let me know.

Oh, and Happy New Year everyone!