Wednesday, June 08, 2011

Binding an Enum to a DataSource

I had some code for an ASP.Net Webforms app where I need to present to the user a list of options that were define as Enum.  I want to populate a combobox with the enumerated type values and do it from code automatically.  This is the Enum in question

enum PrintColorSchema {
Default = 0,
FullColor = 1,
GrayScale = 2,
BlackAndWhite = 3,
}


To make things more interesting, I wanted to exclude the first item in the list, “Default”.  One way to do this would be to manually populate a select list with the values from the Enum.  While that would work for this Enum, I wanted to find a way where I didn’t have to hard code the values.

I added a DropDownList control to the page and in the code behind, I added the following code:

ColorSchema.DataSource = 
Enum.GetValues(typeof(PrintColorSchema))
.Cast<PrintColorSchema>()
.Select(en => new
{
Value = en,
Text = Wordify(en.ToString())
}).Where (en => en.Value != PrintColorSchema.Default);

ColorSchema.DataTextField = "Text";
ColorSchema.DataValueField = "Value";
ColorSchema.DataBind();

What we are using is a bit of LINQ to convert the Enum to an IEnumerable collection of an anonymous class. That class has two members, Value and Text. Value is set to the enumerated type and Text is set to prettified version of the enumerated type. That function looks like this:

public static string Wordify(string pascalCaseString)
{
System.Text.RegularExpressions.Regex r =
new System.Text.RegularExpressions.Regex("(?<=[a-z])(?[A-Z])|(?<=.)(?[A-Z])(?=[a-z])");
return r.Replace(pascalCaseString, " ${x}");
}

The code

Enum.GetValues(typeof(PrintColorSchema))

converts the Enum to an array of constants. The next part

.Cast<PrintColorSchema>()

returns an IEnumerable collecttion from the array. The code

.Select(en => new
{
Value = en,
Text = Wordify(en.ToString())
})

returns a new IEnumerable<> collection of an anonymouse type. That type has the enumeration element as the Value and that element converted to a string as the Text. Since the elements were in "PascalCase", a simple RegEx function was used to split the text into multiple words, The final Where operator is used to filter out the first item from the list.

The HTML that gets rendered:

<select id="ColorSchema" name="ColorSchema"> 
<option selected value="FullColor">Full Color</option>
<option value="GrayScale">Gray Scale</option>
<option value="BlackAndWhite">Black And White</option>
</select>

Which renders like this



For this Enum, all the code was overkill, adding three <option> elements to the <select> control would have been less work.  Where this is handy is when you have Enum types with many elements or when the Enum type changes.  If the Enum type changes, no modification to your code is needed to update the combo box.  One less place in the code to fail.  And that is a good thing.

Tuesday, May 03, 2011

There was a Time Warner Cable Disconnect Technician in my yard this morning.

I had an interesting conversation this morning with a Time Warner Cable (TWC) Disconnect Technician.  I went out to get my paper and he had the cable junction box open.  He was clipping the wires going my house and my neighbor’s house.  We had both switched to Verizon FiOS TV and were no longer paying for any TWC services.

He came over to me and asked if he could ask a few questions.  I wasn’t sure what to expect, but he was very friendly.  He is a Disconnect Technician. He was driving all over town, clipping the cable wires to houses that had switched from TWC to FiOS.  Since FiOS TV went live in Bethlehem last month, TWC was bleeding customers all over town.  He didn’t give me any numbers, but he said a lot of people had already switched and TWC management are pretty upset.

He is also a disgruntled ex-employee of TWC.  At one point he was a TWC employee with the full benefits, at some point they terminated his position and hired him back as a contractor to TWC.  He was not happy about the change from being an employee to being a contractor.  He wasn’t the only employee that they did this to, it must have been a cost cutting move on TWC’s part.

He asked me about the services that I was getting and how much I was paying. Oddly enough, he though I was getting the TV channels through a dish.  He literally didn’t know that FiOS TV was a Verizon package of channels.  He said that he was thinking of getting FiOS service for himself.

He did say a few times that the local TWC management were upset over the subscribers losses to Verizon.  They don’t have much to offer existing subscribers who want to switch.  They can’t compete on the technology side, but they can compete on the cost.  Raising their rates a month before FiOS TV rolled into town, was not one of their smarter moves.

When I went to the local TWC office to cancel my service and return the equipment, the staff there made no attempt to keep me as a customer.  They asked where I was moving to, and they were surprised when I said I wasn’t moving.  But they did not ask why I was dropping the service or ask if there was anything that they could do to get me to stay with TWC.   It would have been a pointless effort, I was already on FiOS TV and there was nothing that TWC could offer to get me to switch back.  Still, it’s general business sense to keep your existing customers.

Tuesday, April 05, 2011

One week with FiOS TV

It’s been a week since I switched from Time Warner Cable to Verizon FiOS TV.  After years of having only one choice in my town for cable TV, Verizon just started offering FiOS TV. While I appreciate the quality of support that I had received from TWC, I was ready to switch providers.  I’m getting better technology at lower price from VZ.

I already had FiOS Internet, bundled with the Verizon Phone service.  I had TWC digital cable with a single Set Top Box (STB) and a CableCARD for my TiVo HD.  I was able to get their digital lineup on two TV sets, and a limited selection of their lineup on the analog channels on two more sets.  I love my TiVo and had two Series 2 boxes on the analog cable, and a TiVo HD connected to the digital cable.  The combined total of FiOS Internet, TiVo subscriptions, phone, and cable, came to around $200 a month.  My FiOS Internet connection speeds where set to 20 MB/s down, and 5 MB/s up.

I upgraded to the FiOS Extreme Triple Play package.  This gave me a selection of channels a little better than the selection that I had TWC digital cable.  I also gained a faster Internet connection, rated at 25MB/s in both directions.  Over the last week, I did spot tests at different times and I was getting results like this:

If you use any online service for printing digital pictures, you’ll appreciate that upload speed.  On the days where I need to work from home, the connection to my office network is fast enough that I feel like I am at the office.

Since FiOS TV is digital only, I retired my Series 2 TiVo units.  They had been in use since 2005, it was time to say good bye.  TiVo customer support was nice enough to transfer my TiVo HD to the cheaper rate that I was paying on the Series 2. I ended up getting the Verizon multiroom DVR with three set top boxes.  Each STB would be able to access the shows recorded on the DVR.  That wiped out the loss of the Series 2 boxes.  For the TiVo HD, I got a CableCARD so it could get the FiOS TV Channels.

Installation was pretty straight forward.  The installer was friendly and professional and had done a lot of FiOS TV installations.  The CableCARD installation was new to him, and we’ll get to that in a minute.  Since I had had FiOS Internet for the last 5 years, most of the installation prep work was already done.  He just had to check all the coax cable connections.and hook up the new hardware.

Time Warner had done a pretty good job with the coax wiring over the years.  The installer only had to do a couple of things with the coax wiring, mainly removing the splitters from the the two TV sets that had the Series 2 boxes.

The first thing that was installed was the FiOS router.  He installed an Actiontec MI24WR (Rev F).  This router took the Ethernet cable coming in from the Verizon ONT and provided the FiOS Internet over WiFi and through the Ethernet jacks.  It provided CATV and TC/IP to the DVR and STBs over the coax cable.

While this appears to be a decent enough router, my existing Netgear WNDR3700 router has better hardware for WiFi.  After the installer got the Actiontec working, I hooked my router to the Actiontec.  I had to make some minor changes to the Netgear to let it coexist with the Actiontec, then I logged into the Actiontec and turned off it’s WiFi radio.

It takes a while for the DVR and STBs to come online.  While we were waiting, we tackled my TiVo HD.  This was installer’s first experience with a CableCARD, so he let me help him out. But first, I need to explain something about using a CableCARD with Time Warner.

Time Warner Cable uses a technology called Switched Digital Video (SDV) to be able to provide their channel lineup with their existing bandwidth.  Usually when you have cable TV, all of the channels that you can get are sent over the cable line at the same time.  Your TV or STB knows what frequency each channel is on and when you change the channel, the appropriate frequency is selected.  Nothing new here, it’s been that way in form or another since the days of Uncle Milty.

With SDV, only the channels being watched in your general neighborhood are going over the wire.  When you change the channel, the STB requests to have that channel provided.  If that channel is already being sent your street or apartment building, then you get the current frequency of that channel.  Otherwise the local office enables that channel and tells the STB what frequency it’s on.

A TiVo box has no idea how SDV works.  So the TiVo people and the CableCARD people came up with a device called the tuning adapter. It sits between the TiVo and the cable and TiVo knows how to talk to the tuning adapter.  When you change the channel on the TiVo, it sends a message to the tuning adapter, which in turn does the SDV dance with the office, and the end result is that you get your channel.  When it works, it’s fast and transparent to the end user.  My experience with the tuning adapter was that every few months or so, it would lose the ability to get the channels and you would have to reboot it.  This functionality isn’t unique to the TiVo, the TWC DVR and STB just have it built in.

FiOS TV does not use SDV, so I didn’t have to deal with any tuning adapter nonsense.  We pulled the TWC cable card out, unplugged the tuning adapter, and plugged in the VZ supplied CableCARD.  TiVo is very helpful with CableCARDs.  When you insert new one it, TiVo automatically displays the information that installer needs to get the card activated.  With TWC, the installer had to call in the information from the card.  It took a few tries to get it working.  With FiOS, the installer had an app that he installed on my PC and he was able to activate the card easily.

The TiVo immediately saw that the card was activated, and we went through it’s guided setup to tell it that it had a new cable provider.  For some off reason, Verizon had not notified TiVo that my zipcode was covered by FiOS.  I had called TiVo a few days before the install, and they provided me with a list of zipcodes that would work.  I entered in the closest one in, and my TiVo was now in FiOS country.

After telling it that it was now on FiOS TV, the TiVo connected to it’s mothership and downloaded the new lineup and channel guide information.  It then migrated over the season passes from the old TWC channel numbers to the channel numbers used for the same stations on FiOS TV.  I was amazed how well that worked.

We have been using the FiOS TV for a week now and we are very happy with it.  The picture quality appears to be noticeably better than TWC.   Verizon does not apply any additional compression to the programming, and it looks like Time Warner Cable does.

The FiOS DVR is very good.  Very easy to use and works great from the STBs.  On a scaled from 1 to 10, where the basic TWC HD DVR is a 1 and the TiVo HD is a 10, I would rate the FiOS DVR a solid 7.  If you never used a TiVo before, you would be very happy with just the FiOS DVR.  While you can’t pick a show to record from the STB, there are mobile apps iPhone, iPad, Android, and the web, that let you easily program the DVR.  The DVR has a 500GB drive, big enough to record 50 to 70 hours of HD programming or 200 hours of SD programming.  That’s about 3 times more storage than I have with the TiVo HD.

The software running on the DVR and STBs is much nicer than the software running on the TWC STB box.  It’s much snappier to navigate and is just better to use.

There are few drawbacks.  I lost BBC America HD, I’m going to miss that channel.  FiOS TV does have the SD channels, so I still get to see the shows.  It just wont be in HD.  I know, a “First World Problem”, but I did want to be fair.  It sounds like they are planning on adding BBCA HD, but I have no idea when.

If the hardware fails, I have to call and have a replacement shipped to my home,  As of right now, there is no local store for getting replacement hardware.  And any TV set that you want to watch FiOS TV with is going to need a CableCARD or cable box.  The days of just plugging the coax into the back of the TV and letting the TV tune the channels are over.

I was a loyal Time Warner Cable customer for close to 20 years.  Their service was professional and they did the best they could with dealing with SDV issues.  And they had no way of matching the Internet speeds that I have had with FiOS.  Verizon has the advantage with the newer technology.  With the cancelling the two TiVo subscriptions and consolidating the cable, phone, and Internet, I will save about $40 to $50 a month.  Since I’m getting more features for less money, I’ll count that as a double win.

Thursday, February 17, 2011

Initial impressions of the Netgear WNDR3700

I recently upgraded my home network with a new router.  I have Linksys WRT54GS router, running a custom firmware called DD-WRT.  DD-WRT provides a lot of extra functionality that wasn’t available with the stock firmware.  It’s the closest thing to a free lunch that you can get, computer-wise.

I’ve had the WRT54GS for a couple of years and it was starting to show it’s age.  I needed to reboot it about once a week or so, or I would lose network connections.  It also predated the 802.11n protocol, and my iPad and one of my laptops support N.  I also wanted a router that supported gigabit speed LAN ports.  So I’ve been in the market for a while now.

Last year, Netgear released a few new N ready routers.  The WNR3700L was designed to be used with custom firmwares.  Netgear even created a website, MyOpenRouter, to support the enthusiasts.  It has a fast processor (480mfz), gigabit ports, and supported G & N on the 2.4ghz band.  I came this close to buying one.

Then I read up on the next size up router from Netgear, the WNDR3700.  This is a dual band router.  You can configure B/G/N on the 2.4ghz band, and A/N on the 5 ghz band. You can keep the N devices at the less crowded 5ghz, and leave the G devices at 2.4ghz,  It also has a faster (680mhz) processor.  This router was listed as a powerful router on the DD-WRT site.  So I spent the extra money and bought that one instead.

The first thing I learned was that I bought a WNDR3700v2, the 2nd generation model.  DD-WRT was not supported for this model.  It turns out that Netgear based their firmware on the OpenWRT project, so out of the box it came with nearly every feature that I wanted.  It had support for updating my DynDNS account, static IP addresses, IPv6, guest networks, a shared USB drive, DLNA, etc.

It doesn’t have everything that DD-WRT has.  It doesn’t have a VPN server.  With DD-WRT, you can run PPTP and OpenVPN servers.  I use PPTP for a few reasons.  The main one was to be able to get a secure connection to my home network so that I could open a remote desktop session to my home PC.  I could also use the VPN connection to access sites that would be normally blocked by the network that I was connected to.  The WiFi network at my local car dealer blocks all of the social networking sites.  When I’m waiting for my car, I would open a VPN connection so that I could check Facebook and Youtube.

Using a VPN also provides a level of security when you are on an unsecured WiFi network.  By encrypting your traffic, your are less likely to have someone capture your data.  The pptp protocol is not completely secure, OpenVPN has better security.  Apple, in it’s infinite wisdom, does not provide OpenVPN support on iOS.  I could open a PPTP VPN connection from my iPad, but there’s no way to get OpenVPN to work. Well, there is a 3rd party OpenVPN client for jailbroken devices, but I’m not going down that route.  At any rate, PPTP is still more secure than unencrypted traffic.

So the WNDR3700 was pretty close to being good enough with the OEM firmware.  Since the WRT54GS was running a PPTP server just fine, I decided to keep it around and use it just as an access point.  That’s part of the joy of DD-WRT, it’s vary easy to customize a router for special needs.  On the DD-WRT site, there are pretty clear instructions for turning a router into wireless access point.  This is all I needed to do:

  1. Change the IP address of the old router.  Since the WRT54GS would be wired to the WNDR3700, they couldn’t have the same IP address.  I changed the WRT54GS from 192.168.1.1 to 192.168.1.2.
  2. Configured the DHCP server on WNDR3700 to use the range 192.168.1.5 to 192.168.1.254 for handing out IP addresses.  This would make sure that nothing else would get the 192.168.1.2 address.
  3. On the WRT54GS, set the WAN type to disabled and disabled the DHCP and DNSmasq services.
  4. Set the WAN port on the WRT54GS to be a LAN port.
  5. Configured the WNDR3700 to forward the PPTP port, 1723, to the IP address now reserved to the WRT54GS.  Any request for a PPTP connection from the outside would now get redirected from the WNDR3700 to the WRT54GS.

After making those changes, I wired the routers together,  I opened a VPN connection to my office PC and RDP’ed into it.  From my office PC, I opened a VPN connection to my home network to verify that the PPTP server was accessible,  It worked the first time.  That’s rare for me, but I’ll take that for a dollar.

I’ve been using this router for a week and it has been rock solid.  There are a few quirks, the UPnP had some issues with Windows Home Server, but that was easy to work around. The wireless range is much better than what I had with the Linksys.  I probably would have been good with the single band WNR3700L, but I am happy with it’s dual band big brother.

Tuesday, February 15, 2011

How I patched a Dell workstation with a firmware update from HP

About 18 months ago, I got a Dell Precision T5500 workstation.  A decent PC with a Xeon quad core processor which has bee a pretty decent box for doing development with.

About a month ago, it started acting very flakey.  I would be doing my work and the display would go all wonky on me.  I would see crawling vertical lines going down the display.  After a minute or two, the colors would get very dark and the computer would stop responding.

A reboot would restore the machine.  There were no warning signs, nothing in the event logs.  One minute it was running, the next it was locked up.  This would happen about once a day or so.  Not enough to keep me from using the machine, but enough to warrant getting it fixed.

We have Dell Priority support, which we hoped would help resolve this problem.  We bought this machine with Vista and it had the free upgrade to Windows 7.  We had bough a bunch of these machines, another one was having a strange crashing problem as well.  Because I had installed 64 bit Windows 7 on it, Dell said it was not supported. 

That annoyed our IT manager.  He then engaged Dell support to fight the good fight.  He called BS on that one and their response was for him to uninstall the current video driver and install the latest Dell approved driver.  While he was doing that, I stated doing my own research.  They had a Plan B, but that involved swapping drives without machine and wouldn’t have actually resolved anything.  We hoped to avoid Plan B.

This T550 came with an NVIDIA Quadro NVS 295 video card.  It’s a basic workstation card with enough horsepower to drive 2 displays.  I had kept the driver updates current with whatever Windows Update suggested for it.

We downloaded the files from Dell, and ripped out the current driver.  The Dell drivers refused to install, claiming that there were no supported devices installed.  The IT guy had downloaded the recommended driver, which supports a motley crew of NVidia cards.  He found a NVS 295 specific driver on the Dell site and started downloading that.  Peachy.  While he was fighting with my machine, I had found some clues in the NVIDIA forums.

I was not alone.  Other Dell owners had reported similar problems with that video card.  This post has a screen shot that was similar to what I was seeing.  Another post described applying a NVS 295 firmware update from HP’s web site.  This was posted by several Dell users as working.  Since it's on the Internet, it must be true.  The IT guy didn't want to flash the Dell with the HP supplied file, but I convinced him by using the following three arguments.

  1. It's a video card BIOS firmware, not for the motherboard.
  2. If we brick it, Dell has to replace it as it will no longer be a software problem.
  3. You can't beat the entertainment value of flashing Dell supplied hardware with HP supplied updates and having it work.

So I downloaded the firmware from a HP page labeled as “NVIDIA Quadro NVS 295 Video BIOS (ROM) and Flash Utilities”,  and the latest driver from NVIDIA.  The Dell NVS 295 driver download completed first and we ran that.  It would not install because it couldn't find the video card.  We then ran the HP flash updater, which immediately recognized the missing NVS card and happily flashed the BIOS.  After rebooting, we ran the NVidia supplied drivers and they installed without incident.

It’s now been a couple of weeks and my T550 has been running non-stop without any failures.  While I don’t understand why HP is only known place in the Googleverse that has a NVIDIA firmware update, I’m just glad that someone released it.

Updated: 2/6/2012
I recently had a comment on this post that I did not publish.  That person posted anonymously and put his email address in the post.  I don’t think he wanted his email address published (and you’ll see why), but I will include rest of the post:

I have the same problem, and I am unable to track down that flash utility! HP apparently doesn't support it anymore. Would you by any chance have it still and possibly throw it up and media fire or some other site for me to download?

The link I had listed no longer goes to the correct page.  HP updated the article and broke the link.  That’s how the Internet works folks, nothing is truly static.  That’s why we have search pages.  That HP link takes you to a page that has a search box.  If you type in “”Quadro NVS 295” in the search box and press the submit button, it comes back with a list of pages.  At this time, the top page on the list is the current page for the firmware download.  Since HP can and will change the link, I’m not going to make any effort to keep my page in synch with HP.

Since HP holds the copyright to that download and is still supporting, I don’t think it’s 100% kosher to put that file up on a file sharing site.  If HP abandoned it, then I can see a reason for making the file available.  But there’s no need when you can easily download it from HP.  It took less than 5 seconds to find the updated page.

One final point. About 7 months after writing that post, the problem came back.  In all likelihood, a Windows update has a conflict with the card and/or the drivers.  Since the machine was still under warranty, I had Dell send out a replacement card.  It failed right after booting up with the same problem. I was done with that card.  I ripped the card out and replaced it with a higher end card.

Friday, February 04, 2011

Reflections on Red Gate and their decision to charge for .NET Reflector

The chattering classes in the .NET world have been buzzing about Red Gate’s decision to start charging for the .NET Reflector utility in March.  I’m been amazed by the hostility and venom sent their way.  Lots of nasty things being written in a forum provided by Red Gate.

Earlier in the week, Red Gate posted a open letter to the .NET Community that the next version of .NET Reflector would cost $35.  Previous versions had been free (with an enhanced version available for an additional cost).  You can’t use the free one indefinitely, there is a time bomb in program that forces you to upgrade every 6 months.  If you don’t upgrade, the program deletes itself from your machine.

The time bomb predates Red Gate’s purchase of Reflector, the original author, Lutz Roeder, implemented that to force everyone to use the latest version.  It’s annoying, but it kept him from having to support multiple versions out in the field.

When Red Gate bought Reflector from Roeder in 2008, he posted the following on his blog:

Red Gate will continue to provide the free community version and is looking for your feedback and ideas for future versions.

There is nothing in that statement that says that Red Gate has to continue to make new versions available for free.  It was never an open source project, and there is no reason to expect Red Gate to make it one.  I think they tried to make the business model work, but did not see enough revenue from the paid version to cover the free versions.  That is unfortunate, but that’s just how it goes sometimes.

The tone that some people are using on the Red Gate forum was pretty raw.  When you see topics like “Red Gate, you have destroyed your reputation” or “Your parents should be really ashamed!”.  It wasn’t all negative, there are a lot of thoughtful comments, but I was surprised by the dumb and nasty.  I don’t think Red Gate was prepared for the response that they received.  They probably should have provided more lead time to their announcement.

I think that Red Gate should put out one more release of the free version of Reflector, version 6.  This final free release would have the time bomb feature removed.  No support at all from Red Gate would be available.

I would also like to see other licensing options.  I would like to see a site or company license that would let any number of developers within the company use Reflector.  LINQPad is another great .NET development tool and Reflector could use a similar licensing model.  There is a free version and a paid version.  The paid version has more features and you can license it by user, group of users, or all users within a company.  If Red Gate could offer that, I would have a much easier time getting my company to buy it.

It’s a great tool and the price is appropriate.

Sunday, January 23, 2011

Price Chopper's RoboDeli is great idea, but flawed

I just did some Sunday shopping at a local Price Chopper supermarket.  It was pretty busy and there was a long line at the deli counter.  With in the last few months, they implemented a computerized ticket system.  Instead of grabbing a ticket and waiting for a number to be called, you pushed a button on a touch screen and a numbered ticket was printed out for you.  On a large TV screen above the deli, the ticket numbers currently being served and tickets to be served were listed, along with their approximate wait times.

Knowing the wait time is handy, it gives you a better idea of how long you will be waiting before you be served..  They also have a touch screen set up to allow you to place your order and come back later to get it.  Since the wait time was up to 20 minutes, I decided to give the "RoboDeli" a shot.

The RoboDeli worked, but it was an exercise in frustration to use.  The touch screen was the main culprit, but the software design had a few flaws too.  The touch screen was just bad.  It was very difficult for it to register a button press and when it did pickup a button press, it would often get the wrong button.

I just wanted to get some ham.  While I was able to easily select "ham", I had to scroll through several pages of items to get the one I wanted.  Those buttons were large and while it took a while to get it to read my finger press, it got the right selection.

Next came the weight and thickness.  Those buttons were smaller and it took much longer to get the right selection to register.  I then added the ham to the order and went to complete the order.

It asked if I wanted to get a text message on my phone when the order was ready.  That's a brilliant idea, but they really messed up on the implementation.  To enter in the phone number, you were presented with a numeric keypad on the screen, plus skip, completed, and clear buttons.

The number buttons were small and close together.  I don't know if it's supposed to remind you of a phone, but it only used a small portion of the display.  Every time I pressed the "5" key, it would register as "2".  The really annoying part was that it had no concept of a backspace button.  The clear button would clear all of the numbers, forcing you to start from the beginning.

After several failed attempts, my 10 year old daughter took time off from texting all of her friends to take pity on me and enter the number in herself.  She had less luck than I did.  We finally gave up and pressed the skip key to send the order to the deli.

At that point, it went back to it's home screen.  No order number or any other way of identifying my order.  When they processed my order, it would be placed in a cold case next to the deli.  It would have an order number on it, but you wouldn't know what that order was.  You just have to remember what you ordered and grab the right one.  And also to remember to periodically check back to see if it was ready.  You also had to know where the pickup would be, that was not clearly identified.

It took about 4 minutes for me to place the order.  That's a long to order a 1/2 lb of ham.  Of that time, 2.5 minutes were occupied with my failed attempt to enter in my phone number. It would take longer for 10 people to enter in their orders in total (without picking them up), than it would for 10 people to wait at the counter and actually get their order.

What they are trying to do is a great idea, they just dropped the ball on how they implemented it.  Something that is supposed to save you time should not take longer and annoy you in the process.  This is what they need to do to fix it:

  1. Display a large sign over the screen that would list the steps needed to place the order and where to pick up the order.  While you can display that information on the screen, this way it's always available for the user.
  2. Get a more responsive and accurate touch screen.  This isn't esoteric technology.  Your self serve checkout registers have much better accuracy and response on their touch screens.  You should be at least at that level of accuracy for the RoboDeli.
  3. Page Up and Page Down types of buttons are keyboard/mouse navigation tools.  With touch screens, you scroll through lists by dragging the list with your finger.  The system feels like it was designed to be used with a mouse, not a finger.  Find the person who designed this system and give him an iPad and show him how touch screen applications really work. 
  4. Use the entire screen for input.  A larger phone number pad would have been better.  It doesn't cost anything extra to use more of the screen.
  5. Add a backspace key. Not being able to the delete just a single character is just mind boggling bad.
  6. Display the order number so the user can remember what order to pick up.
  7. Have an option to print the order ticket.  With the information of what the customer just ordered, you can suggest complimentary items to go with that order and provide coupons on the ticket itself.  "Buying a lot of cold cuts? Here's a coupon for mustard."  Every point of interaction with a customer is a chance to sell him something.  The store already has a machine that prints out coupons when you swipe your AdvantEdge card, so you already have the ability to do this.
  8. Have a mag strip reader to be able to read the AdvantEdge card (Price Chopper's loyalty card) and be able to print the customer's name on his order.  If you could add a mobile number to the AdvantEdge card account, that would be even easier for text notifications.

Monday, January 10, 2011

A Random Vegas Observation

I like walking the strip in Vegas at night, it makes for great entertainment.  I just love watching everything going on.  I’m not into gambling, so I just walk around and take pictures of the bright lights.  One of the seedier parts of the Vegas Strip Life are the “Porn Slappers”.  If you have never been to Las Vegas, Porn Slappers are people who stand on the sidewalk and hand out “business cards” for “contractors in the adult service industry”.  Prostitution is illegal in Clark County, this is one of the ways that they advertise their services.

They are not allowed to come up to you and harass you (that right is reserved for Crossgates Kiosk employees), so they need to do something to get you attention.  They slap the cards in their hand to get your attention.  Thus, the “Porn Slapper” name.  The more likely they think you would be interested, the more slaps you hear.  Welcome to Las Vegas!

The streets are just littered with cards with pictures of half-naked women, sporting what appears to be non-factory equipment. I’ve been to Las Vegas for work a few times, but it’s not a place I would bring my kids to see.  I don’t want to have to explain to an 8 year old what an “escort” is.

While I have never seen anyone take one of the cards, they must be effective.  The Porn Slappers are all over the strip.  While I tune them out as background noise, I have seen quite a few people take offense to them.  They are harmless, but it’s not what you expect to see back home.

I was walking down by Planet Hollywood and I found myself instep with a retired couple from Milwaukee.  They were on vacation and this was their first trip to Vegas.  They were a little unnerved by the Porn Slappers, so I decided to help them out a bit  We chatted a bit and I explained what the Porn Slappers were. I told them that I usually say gibberish to the Porn Slappers, it confuses them and throws them off their game a bit.

So we walked one, and whenever a Porn Slapper came close, I would go into “Denny Crane” mode.  I would just say random things like:

  • I’m looking for a one-armed man
  • Are you my mummy?
  • Denny Crane, Denny Crane
  • Tippecanoe and Tyler too
  • Vote for me and shoes for all
  • Member, FDIC

Pretty much just random sayings, whatever floated out the archives. And the Porn Slappers would just back away from us.  Mr and Mrs Milwaukee were greatly entertained and I had a chuckle or too.  Cheap fun on the strip.

Wednesday, January 05, 2011

Scrolling a ListView’s EditItemTemplate with some help from jQuery

I’ve been using ASP.Net’s ListView control and I cam across a little quirk while setting up the editing bits.  I have an EditItemTemplate defined that has some input controls and a couple of nested ListViews.  It’s a nice way of defining a hierarchal editing view.  If you haven’t used a ListView before, Scott Mitchell have a great tutorial.

My ItemTemplate displays the data for each line of data and has a couple of buttons, one to edit the item, the other to delete it.  When you click the edit button, you get a page refresh and ASP.NET renders the EditItemTemplate with the editing controls and the user can edit the item and save the changes.
The problem was when you needed to scroll down the page to make the EditItemTemplate visible in the browser.  If the height of the ListView was greater than the visible height of the browser, the user would have to scroll down the page to get to the first input control.  I ended up using a bit of jQuery to scroll the edit area into view for the user. 
This is an edited down version of the EditItemTemplate for a ListView that I’m currently working on:
<EditItemTemplate>
    <div style="padding: 0 0 10px 0;" class="MyEditItemTemplate">
        <b>Calendar Name:</b>
        <asp:TextBox ID="txtCalendarName" runat="server" 
            Text='<%# Bind("CalendarName") %>'></asp:TextBox>
        <asp:ImageButton ID="imgbUpdateCalendar" runat="server" 
            ToolTip="Update Calendar" AlternateText="Update Calendar" 
            CommandName="Update" 
            ImageUrl="~/Images/accept.png" />&nbsp;
        <asp:ImageButton ID="imgbCancelUpdate" runat="server" 
            ToolTip="Cancel" AlternateText="Cancel" 
            CausesValidation="false" CommandName="Cancel" 
            ImageUrl="~/Images/cancel.png" />
        <br />
        <div style="padding: 5px 0 0 40px;">
            <div style="border: 1px black solid">
                <asp:ListView ID="ListViewChildCalendars" 
                    runat="server" DataSourceID="odsChildCalendar"
                    DataKeyNames="RecordID" 
                    InsertItemPosition="FirstItem" 
                    OnItemInserting="ListViewChildCalendars_ItemInserting">
                    <LayoutTemplate>
                        <span class="SubListViewHeader"><strong>Associated Calendars</strong></span>
                        <blockquote>
                            <asp:PlaceHolder runat="server" 
                            ID="itemPlaceholder"></asp:PlaceHolder>
                        </blockquote>
                    </LayoutTemplate>
                    <ItemSeparatorTemplate>
                        <hr />
                    </ItemSeparatorTemplate>
                    <ItemTemplate>
                        <%# Eval("CalendarName") %>&nbsp;
                        <asp:ImageButton ID="imgbDeleteCalendar" 
                            runat="server" 
                            AlternateText="Remove Calendar from Group" 
                            ToolTip="Remove Calendar from Group" 
                            OnClientClick="return DeleteConfirmation('C', this.name);" 
                            CommandName="Delete" 
                            ImageUrl="~/Images/delete.png" />
                    </ItemTemplate>
                    <InsertItemTemplate>
                        <div>
                            <b>Calendar Name: </b>
                            <asp:DropDownList ID="ddlChildCalendars" 
                                runat="server" DataSourceID="odsCalendarList"
                                DataTextField="CalendarName" 
                                DataValueField="RecordID">
                            </asp:DropDownList>
                            &nbsp;
                            <asp:ImageButton ID="imgbAddChildCalendar" 
                                runat="server" 
                                ToolTip="Associate Calendar with Group" 
                                AlternateText="Associate Calendar with Group" 
                                CommandName="Insert" 
                                ImageUrl="~/Images/accept.png" />
                        </div>
                    </InsertItemTemplate>
                    <EmptyDataTemplate>
                        <span class="SubListViewHeader"><strong>Associated Calendars</strong></span>
                        <blockquote>
                            This list is empty</blockquote>
                    </EmptyDataTemplate>
                </asp:ListView>
            </div>
        </div>
        <asp:ImageButton ID="UsedForScrolling" runat="server" 
            ImageUrl="~/Images/0.gif" CssClass="UsedForScrolling"/>
    </div>
    <br />
</EditItemTemplate>


This EditItemTemplate has a nest ListView to associate other items to item currently being edited.  It’s basically a pick list populated from a drop down list.  Since each selection from the list generated a page refresh, it is important to keep the EditItemTemplate displayed on the page.

All of the controls in the EditeItemTemplate are wrapped inside a <div>, with the CSS class name set to “MyEditItemTemplate”.  Defining a CSS class is great for styling, it also makes it very easy to locate controls using jQuery. Also notice the last control in the template, the ImageButton with the ID of “UsedForScrolling”.  It uses an image of an invisible GIF file.  It’s a 1x1 image, with the single pixel set to the transparent color.  The browser will render it (briefly), but it wont be visible.  You can download the GIF from invisible GIF file link.  I had obtained it from a page by Nick Webb.

You can use the HTML input control instead of an ImageButton, it will not matter too much.  You want to avoid using a control that will render on the screen as a visible item, like a text input control or a check box.  While the code will hide the control after the page has loaded, there would be a flash as the control is rendered, and then removed from the page,  With the invisible GIF, you avoid the brief flash on the page.

This is how we scroll the edit template so that it’s entirely in view:


  1. Check for the existence of the invisible button.  It’s only visible when you are editing an item in the ListView.
  2. Set the focus to that button.  While it will render as a transparent image, it can still receive the focus.  This will force the browser to scroll the page (if necessary) so that the focused input control is in view.
  3. Set the focus to the first input control in the EditItemLayout.
  4. Hide the transparent input button.  While you can’t see it, you don’t want the user to be able to select it.

We implement this with some jQuery code that will do all 4 four steps.  I put the code in a javascript function that I named “ScrollIntoView()” and called that function from the jQuery ready event.


$(function () {
ScrollIntoView();
});

function ScrollIntoView()
{
    var TempInputControlForScrolling = $(".UsedForScrolling:input:visible:first");
    var FirstEditControl = $(".MyEditItemTemplate input:text:visible:first");

if (TempInputControlForScrolling.length)
{
TempInputControlForScrolling.focus();
FirstEditControl.focus();
TempInputControlForScrolling.hide();
}
else {
$("input:text:visible:first").focus();
}
}


The first line in ScrollIntoView() uses a jQuery Selector to match the first visible input control with a CSS class of “UsedForScrolling”.  The next line matches the first visible text input control that is a child of the control with the CSS class of “MyEditItemTemplate”.

If we found an input control, then the length property of the TempInputControlForScrolling variable will be greater than 0.  If no match had been made, the length will be 0.  With the match, we set the focus to the invisible GIF input button, then set it to the first text edit control, then finally hide the invisible button.  If the .UsedForScrolling selector did not match any controls, which will happen when you are not editing an item in the ListView, then the first text input control on the page will get the focus.

Sunday, January 02, 2011

Cable TV Competition coming to Bethlehem? (FiOS TV vs Time Warner Cable)

On January 12th, 2011, the town of Bethlehem (NY) will be holding a monthly town meeting.  One of the topics on the agenda is to have a public hearing to allow the public to voice their opinion on whether or not to allow Verizon to provide FiOS TV.  This would be a competing cable TV service, going up against Time Warner Cable (the current provider).

This should be interesting for a few reasons.  For the last few years,Verizon has provided FiOS Internet service in parts of Bethlehem.  I’m in one of those parts and have had FiOS since it became available.  Verizon started laying down cable through out the entire town for FiOS, but abandoned that task when the economy tanked in 2008.  I heard a rumor that Time Warner was able to put pressure to block additional FiOS deployment, but I haven’t seen any proof of that.

To be able to offer TV to the town, Verizon will have to lay down fiber through out the rest of the town.  Or at the very least, cover the same area served by Time Warner Cable.  That’s a significant expense for Verizon and will take some time to rollout.

This should make Time Warner Cable very nervous.  I know a fair number of people who get the “All The Best” package from Time Warner Cable, with TV, Internet, and telephone service all bundled together,  When Verizon wired up my neighborhood with FiOS, almost no one wanted to switch from Time Warner Cable’s package to some mixture of Time Warner Cable and Verizon.  Verizon did not have FiOS TV, their equivalent to the Time Warner Cable bundle was FiOS  Internet, Verizon phone, and DirectTV satellite TV.  So most people stayed with Time Warner Cable.  The convenience of a single bill trumped the faster broadband speeds offered by FiOS.

If people have the option for a true all in one plan from Verizon, then they a competitive choice to over Time Warner’s plan.  Especially if Verizon offers a discounted rate for the first year or two.  Many people who signed up for “All The Best” were given a discounted rate for the first year (possibly two).  That rate jumped up quite a bit after the discount period was over.  If Verizon has a cheap enough rate, people will be inclined to switch.  Verizon also calls their package “Triple Play” and their introductory offer is $89.99 a month.  That beats Time Warner’s introductory rate of $99 a month.

I’m customer of both companies.  I have Verizon phone and FiOS Internet, and I have Time Warner Cable TV service.  If FiOS TV becomes available, I’m going to consider switching to it.  I spent some time talking to FiOS TV sales agents and it sounds like they offer strong competition to Time Warner Cable.

Verizon has a multi-room DVR called the Home Media DVR.  This is an upgrade from their standard HD DVR.  If you have multiple TV sets with cable, one set will have the Home Media DVR and the rest just need to have set top box (STB).  Each STB can watch shows recorded on the DVR.  I was told by the sales agent that multiple recorded shows can be watched at the same time, from different STBs.  I asked a couple of sales agents how many show could be watch simultaneously and they said it depended on the number of set top boxes.  I don’t think that is true, I think the limit is 2 STBs watching from one DVR based on materials published on the Verizon web site.

The Home Media DVR can record 85 hours of SD and 20 hours of HD content.  If you need more space, you can move shows from the DVR to a PC and back again.  You can also send your own video and music content from a PC down to the DVR,  This uses a feature called the Media Manager.  There have been sneak peeks posted online for the next version of the FiOS TV software that looks pretty cool.  It looks like the next version gets the following:

  • Support for an external ESATA hard drive so you can record more shows at once.
  • The program guide uses the 16x9 screen on HD TV Sets
  • An undelete button (sorry, I can do that now with my TiVo).
  • DVD style chaptering on recordings.

This version (IMG 1,9) is not out yet, but since it would take time to rollout FiOS TV in this town, it should be out by the time we could use it.  Some more information can be found here.

If you use a TiVo with a CableCard to get Time Warner Cable, there are a couple of benefits that you would get by switching to FiOS TV.  First off, no Switched Digital Video (SDV), which means no tuning adapter will be required.  I posted about the annoyances of SDV a while back.

The other TiVo benefit is that FiOS TV does not blindly set the CCI flag to the “Copy Once” setting that Time Warner Cable uses.  “Copy Once” means that you can record the show to your TiVo, but you can’t transfer the show from the TiVo to your PC or another TiVo.  Verizon FiOS TV does not have this limitation.

There might be some drawbacks to switching from Time Warner Cable to FiOS TV.  First off, you’ll need a STB or DVR for any TV that you want to watch cable on.  Time Warner Cable still offers the analog channels.  You can still watch most of the channels on a SD TV just by plugging the coax cable in the back of the TV.  You can’t do that with FiOS, and to be fair, you need a STB for every TV that has the Time Warner Cable digital channels.

Will we get the local sports with FiOS TV?  With Time Warner Cable, we get the local Syracuse and Siena games as part of the standard cable package.  It’s not clear if we would get that with FiOS TV.  We also get a local Time Warner news channel, YNN.  I could not get a straight answer from the sales agents if FiOS TV offered something similar.

There is also the question of support.  Time Warner Cable has local offices and branch locations in this area.  If a remote or DVR fails, you can drive to the mall or TWC office and get it replaced.  Will Verizon have locations in this area?  They don’t have any now, but a quick peek at the online store locator does show many locations across the state.  They also have online forums for support. 

Time Warner Cable has great live technical support via Twitter.  Does Verizon match that?  They both offer “live chat” support, but the Time Warner Cable Twitter support is manned by experts and they know more about the system than the live chat people.

Time Warner Cable does offer a multi-room DVR, but only as part of their Signature Home package.  That is their high end offering, $199 a month in NYC.  That’s more than I want to pay and I don’t want to switch from FiOS Internet back to RoadRunner.  I’m looking forward to hearing more about FiOS TV.

Wednesday, December 01, 2010

One final migration from Vista to Windows 7

Over Thanksgiving weekend, I upgraded our last Vista PC to Windows 7. We have a family PC, that we all share.  It’s nothing too fancy, a three year old Dell Inspiron 530.  It came with Windows Vista Home Edition preinstalled.  A Core 2 4300, running at 1.8 Ghz and 2GB of RAM. 

We use it mainly for web browsing, word processing, and email.  The kids use it for games, mainly web based games.  My oldest likes to play “The Sims 3” on it.  Something in how “The Sims 3” was installed just killed the performance of the machine, even when the games wasn’t running.  There was an app that checks for updates for “The Sims 3” and that just took forever to run.

Over the Thanksgiving break, I decided to clean up the machine and bring back the performance.  I wanted to repave the machine with Windows 7.  I had a spare Windows 7 Ultimate disk (overkill, but I had it available) and I was not afraid to use it.  It wasn’t that Vista was horrible, but Windows 7 is better.

I decided to install on a new hard drive and keep the existing hard drive around, just in case something went seriously wrong.  I have Windows Home Server, in the shape of an HP MediaSmart EX495, so I could restore the machine back to yesterday’s backup.  While I could have done that, it’s still easier having access to the old drive in case I needed to get something off of it.

The first step was to inventory the installed hardware and software on the machine.  The hardware was pretty easy, it’s basically a stock Dell box.  I had added a Microsoft webcam and a Logitech mouse, but the rest was stock Dell.

The software was a little trickier.  We have four users on this machine.  Myself, my wife Anne, and my daughters: Kathryn and Laura.  The ladies all had local email accounts set up with Thunderbird, I needed to migrate that over.  They all have iPod Nanos and I needed to get their iTunes data across.  Plus all of their documents.

I couldn’t find the serial number for “The Sims 3”, so I copied it from the registry.  With 32 bit editions of Windows, the serial number is the default value stored in the following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Electronic Arts\Sims\The Sims 3\ergc

For 64 bit Windows, look in:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Electronic Arts\Sims\The Sims 3\ergc

After storing the serial number, I then went into iTunes and deauthorized the computer.  We use a single AppleID account for all of our iTunes purchases and we have it on a few PC’s.  Apple only allows 5 PC’s to be used with any account.  When you reformat or decommision a PC, you want to make sure that it’s no longer authorized to your Apple account.  If you forget this step, you can deauthorize all of your PC’s.  You would the have to authorize each PC again and Apple only lets you do this once a year.

By installing the OS on a new drive and keeping the old OS on a mounted drive, it would make it easier to bring over files and folders.  I had a spare 250 GB Maxtor drive that used to be part of a RAID 5 array in my home development machine.  I had three identical drives in the array and I replaced them with “normal” drives after I got the MediaSmart server.  Being able to do bare metal restores from the server trumped the protection that I was getting from RAID 5.

So I installed the drive and Vista saw the drive and I did a quick format of the drive.  I then rebooted the Dell and switched the boot order of the drives so that it would see the Maxtor drive first.  I then booted from the Windows 7 disk.

Now Microsoft has come a long way with OS installs.  Windows 7 installs fairly quickly and without bothering you too much.  But for some reason, it wouldn’t see the Maxtor drive.  It came up fine in the BIOS and Vista had no problem with it.  It was just invisible to Windows 7.  I spent a few hours playing with cables and boot order and BIOS tinkering to no avail.

It was now Saturday, the day after Black Friday.  Probably the best weekend of the year to buy electronic stuff.  The local BestBuy had Western Digital Caviar Black 1 TB drives on sale for the ridiculous price of $59.99.  For $60 I could get a faster drive with four times the capacity of the drive that came with the machine.  I went down and bought two of them.  I would use one in the Family PC and the other would go in my development machine or into the MediaSmart server. 

I installed that drive in and Windows 7 saw it without any problems.  The installer did it’s thing and 20 minutes later, I was running the 64bit edition of Windows 7.  It had installed drivers for all of the onboard hardware and even the web cam..  Being a freshly paved Windows install, Windows Update needed to be run.  Installing the updates took longer than installing the OS, but that’s normal.  I did pick a new name for the PC.  I wanted to make sure that this machine appeared as a new machine to the rest of the network.  Life is much easier that way.

Now that OS was up and running, it was time to bring over the software.  First up, create the users.  You need to login as each user at least once to get the the folders all set up.

The first app was email.  We use Thunderbird as the desktop client.  My wife uses a verizon.net account on this machine and the girls use our personal domain GMail accounts.  With the girls, I just had to fire up Thunderbird and add their email accounts.  Their GMail accounts are set to use IMAP with all of their mail stored in the Google Cloud.  Their existing email and settings came over automagically.  With Anne’s email, the messages were stored locally.  So I configured Anne’s email settings and then closed down Thunderbird.  I then copied the contents of her Thunderbird profile folder from the old hard drive to the appropriate location on the new drive.  The profile folder will have a random name and will be located in the “%APPDATA%\Thunderbird\profiles” folder.

Next up was iTunes. To keep things easy to manage, we try to keep all of our music files in a “C:\mp3” folder.  So I copied that folder from the old drive to the new drive.  Apple also likes to place files in the “%HOMEPATH%\My Music\iTunes” folder.  I installed iTunes and then copied that folder for each account.  I then started up iTunes and authorized the PC.

I then copied over the documents for each user, plus some shared folders.  I then installed “The Sims 3” and the serial number worked.  The installer made an updater app start with Windows,but I ran MSConfig and fixed that.  To keep the saved games, I had copied over a few folders from ”%HOMEPATH%\Documents\Electronic Arts\The Sims 3” and all was good.

Next, I installed the usual suspects. Microsoft Office, then Microsoft Security Essentials, then the Windows Home Server client.  The WHS client allows quick access to the server, plus enables the nightly backups.  I switched to Microsoft Security Essentials last year and I have been very pleased with it.  I can’t imagine dealing with the bloated offerings from Symantec or Mcafee these days.  MSE does the job and doesn’t bog down the machine like the big boys too.

That being said, I consider the PC’s antivirus solution to just be a part of the protection. Even with daily updates, a 0-day attack could still get your machine.  With the Windows Home Server, I can easily do a bare metal restore of the OS.

After getting everything back up and running, I added another 2 GB of RAM to the system.  It was cheap and with fast user switching, the more memory the better.  I still need to install a few utilities here and there, but for the most part the machine is back in service.  It’s much snappier.  Between removing 3 years of accumulated crap and Windows 7 being faster than Vista, it’s like having a new machine.

Sunday, October 17, 2010

How TweeVo survived the OAuthcalypse

Last month, I spent a few evenings adding OAuth support to Brian Peek's TweeVo application.  TweeVo is a little WPF based application that runs in the background and logs what your TiVo has recorded to a specified Twitter account.  I’ve been running it on and off as @AnotherTiVo. Brian keeps a Twitter list of known TweeVo accounts as tweevousers.

It's a good learning tool for showing how to query a web server and how to post to Twitter using the Twitter API, all wrapped up as a WPF application.  What it does is very clever and Brian did a nice article about it on the Coding4Fun site.

The web server is the built in HTTP server that runs on the TiVo box.  You can use that web server to get a list of everything that has been recorded by your TiVo.  Brian wrote a nice, clean application that would query the selected TiVo units on your home network.  TweeVo polls each unit and checks the "Now Playing" list to see what shows were recorded since the last check by TweeVo.  It then posts the name of the show, plus a http://www.zap2it.com/ link to the specified Twitter account.  The Zap2It link will list some information about the show, plus a link to tell your TiVo to record that show.

The original version of TweeVo posted to Twitter using the username and password for the account.  This was called Basic Authentication or just Basic Auth. The user’s credentials were stored in a config file by TweeVo and they were encrypted so nothing else could read it.  Brian released it a while back and and it was a lot of fun for the people who used it.  Then came the OAuthcalypse.

Twitter supported two forms of authentication, Basic Auth and OAuth.  Twitter announced in the Spring that support for Basic Auth was being phased out and everyone using the Twitter API needed to implement OAuth.

With OAuth, the application requesting Twitter access with the application key.  To get the application key, you would request one for your application from Twitter.  If they approves your request, you would get a consumerKey and a consumerSecret.The user would be presented with a web dialog asking if they wanted to allow access to their account to the application and they would be prompted for their user name and password. 

If they allowed it, Twitter would send back an access token and application would use that token and their own api key to access the Twitter API.  The web dialog would redirect back to the calling web application and life was good for the user.

That’s an over simplification of the process, but it describes the basic mechanism for allowing an web application to post to your Twitter timeline.  There are a few advantages to using OAuth.  Since the application uses an access token, you could change your password without having to update the application.  Plus you could revoke the access token at any time from your Twitter web page.

For desktop application, it was a little trickier.  You still needed to present the web dialog from Twitter to request access.  Since you couldn’t get back to desktop application from a web page, the user would be presented with a PIN from the web dialog.  He would then manually type the PIN into an entry field provided by the desktop application.  The app would then request the access token from Twitter by providing the application key and the PIN.

While this mechanism keeps the user’s credentials away from the application, it’s annoying to use.  Plus you have now introduced a point of failure where the user types in the PIN.  A more streamlined approach called XAuth was made available by Twitter for desktop applications.

XAuth works by consolidating a few of the steps.  The user provides the user name and password to the application.  The application then requests the access token by passing the credentials and the application key.  This skips over the access request dialog and sends back the access token.  For the end user, this is a much simpler. 

The original shutoff date for Basic Auth was June 30th, 2010.  This date became commonly known as the OAuthcalypse.  Due to heavy Twitter usage around World Cup activity, the Twitter team pushed the OAuthcalypse date to August.  On August 16th, Basic Auth usage would start get rate limited and a final shutoff occurred on August 30th.

The OAuthcalypse basically prevented TweeVo from posting to Twitter.  Brian was a little busy in September and I offered to help add OAuth/XAuth support to TweeVo.  I did some reading and played around with some .NET implementations of XAuth.

We implemented XAuth with TweeVo and tested it in late September.  Much of the XAuth code was based on code that been posted in a set of blog posts by Shannon Whitely.  I made a few changes to Shannon’s code, but the his implementation was sound and it saved me quite a bit of time.  That allowed me to spend more time reworking the TweeVo code to use XAuth and do more testing.  If you were using TweeVo 1.0, now is the time to get version 1.1.

Tuesday, September 28, 2010

Care and feeding of your wireless router

This morning I went to check my email from my iPad and had a unpleasant surprise.  No Internet.  I have the Wi-Fi only version of the iPad and it usually has a nice solid connection to my wireless router.  On the iPad, I fired up the Settings app and sure enough, under “Wi-Fi”, it displayed not connected. I tapped “Wi-Fi” and let it scan for networks.  No sign of mine.  I tried my iPod Touch, same thing.

That pretty much rules out the iPad as being the problem, time to move up the chain of command.  My router is an ancient (by home router standards) Linksys, the WRT54GS.  It’s your basic work horse router with 802.11b (11 Mbit/s) and 802.11g (54 Mbit/s) support.  I run a 3rd party firmware on it called DD-WRT.  DD-WRT greatly enhances the functionality of the router and lets you do a lot of cool things.  It’s about 99.9% cool and 0.1% flakey.  The flakey bit means that I need to reboot it every now and then.  I don’t know if it’s a memory leak, or something is getting confused, but a reboot every once in a while clears the cobwebs out.

From my PC with a wired connection to the router, I was able to access both the Internet and the administrative web pages on the router.  So the router wasn’t completely borked, just the wireless part.  From the admin pages on the router, I could get the router to do a wireless scan.  That’s where the router goes looking to see what other wireless hotspots are nearby.  This is very useful for picking the right channel

With 802.11b and 802.11g, the router uses a narrow range of frequencies at 2.4ghz.  In the US, this range is divided up into 11 channels.  It’s kind of fuzzy how they divided the channels, they all overlap the next channel on each side.  So you really want to think of it as 3 channels, 1, 6, and 11.  Since channel 1 only bleeds up with channel 2, and channel 11 only bleeds down with 10, you really want to use channel 1 or 11 if you can.  Most routers default to channel 6, in a crowded neighborhood so you should see less traffic on 1 or 11 than on 6.

So I unplugged the router and waited about 20 seconds.  It came back up and my PC could hit the Internet.  But still no Wi-Fi.  Since a power cycle didn’t fix it, I moved up to the nuclear option: the 30/30/30 reset.  The 30/30/30 reset is the best way to clear out all of the router settings to the firmware default values.  When you upgrade the firmware on the router, you should do the 30/30/30 before you flash the router and one more time again after you have flashed the router to the new firmware.

There are 3 steps to the 30/30/30 reset:

  1. Press and hold the reset button on the router and wait 30 seconds.
  2. While keeping the reset button pressed, unplug the power from the router and wait 30 more seconds
  3. Plug the power back in while keeping the reset button pressed and wait for another 30 seconds.

Before you do the reset, you’ll want to write down any custom settings that you have performed. I use the following features added by DD-WRT:

  1. Configured the http://www.dyndns.com/ client.  This assigns the current IP address of the router to domain name provided by DynDNS.  When my ISP changes the IP address assigned to the router, DD-WRT passes the new IP address to DynDNS and they update the record for that domain name.  This makes it easy to use my VPN to connect to my home network.
  2. Configured the VPN server.  DD-WRT provides both PPTP and OpenVPN.  PPTP is simpler the configure and works for me, so that’s what I use. I’ll use the VPN if I’m a location that blocks sites that I want to access from my iPad.  I can also use the VPN if I need to open a Remote Desktop (RDP) connection to my home PC.
  3. Changed the default login account on the router.  Most routers let you change just the admin password, DD-WRT lets you change the login name as well.
  4. Set the router to use OpenDNS.  This isn’t a DD-WRT feature, most routers will let you set the DNS servers.  I use OpenDNS for their fast DNS servers and for their content filtering.
  5. Sell the router to reboot itself once a week.  In a perfect world, your computer would never need to be rebooted. In this world, it doesn’t hurt for the router to get rebooted automatically once a week.  Mine is set to reboot ever Wednesday at 5:30am.  Not much is going on at that hour.
  6. Enable UPnP.  I missed that one at first.  Windows Home Server uses UPnP to punch a secure hole through your firewall to allow remote access to your network through Windows Home Server.  I have a HP Media Smart Server and I will access my home network from work by going through it’s Remote Access.

After the reset, I set the Wi-Fi settings and after a few seconds, my iPad was back on the Internet.  Since I had already reset the settings, I decided to update the DD-WRT version on my router.  The DD-WRT web site has an interactive Router Database, where you can pick your router and it will tell you which versions of DD-WRT will work with your router.  It’s pretty handy, there are multiple versions of DD-WRT available, and different builds of each versions.

Unless you have a large pile of routers to play with, you really want to use the suggested version of DD-WRT.  If you install the wrong version or get an unstable development build, you could brick the router.  I grabbed the standard set and installed it without blowing anything up.  Then I put back my custom settings.

So now I have full Wi-Fi back, but I don’t know why it failed.  It was working the evening before, but stopped sometime last night.  MY WRT45GS is about 4 years old and has been on 24/7 the entire time.  It could be just wearing out.  My iPad supports 802.11n, it may be time to upgrade to a newer router.  The Buffalo Technology Nfiniti Wireless-N High Power Router (WZR-HP-G300NH) works very well with DD-WRT and the people at SmallNetBuilder like itJeff Atwood just picked one up too, and he’s programmer with the hardware tweak bit set to on.  It would also be nice to have a router that supports gigabit speed WAN connections for the small set of the devices that I own that support gigabit. 

The Nfiniti is a single band router, everything is broadcast over the 2.4ghz range.  I may look at a dual band router, like the Netgear WNR3500L.  With a dual band router, you can have 802.11g devices on the 2.4ghz band and the 802.11n devices on the 5ghz band.  As far as I can tell, my iPad supports 802.11a/b/g/n on either band. It may be worth it to get the heavy duty Netgear router over the Buffalo one.

Some additional notes:
Resetting the router evidently disabled my Windows Home Server’s Remote Access functionality.  I was able to repair that by performing the following steps:

  1. Launch the Windows Home Console
  2. Click on “Settings”
  3. Click on “Remote Access”
  4. Click on the “Repair…” button.  This launched the “Repairing Remote Access Configuration” wizard. Which told me that UPnP was not enabled on the router. Sure enough, I went into the UPnP page (under NAT / QoS) in dd-qrt and saw that UPnP was not enabled.  I enabled UPnP, rebooted the router, and let the wizard repair the Remote Access settings. 

The fun part was that I did this from my office PC.  I created opened a VPN connection to my router and changed the UPnP settings remotely.

Monday, September 20, 2010

There was a problem sending the command to the program

I hate error messages like that. It’s both detailed and vague at the same. What command was being sent and what was the problem? Let me back up a few steps. A family member bought a new PC running Windows 7, for his home office. He works from home and accesses his work email account through Internet Explorer.  His email based on Domino Web Access, which I’m assuming is the web bit for Lotus Notes email.

When ever he was sent a document like an Excel file or Word file as an email attachment, he was unable to open the file.  He would double-click on the icon for the file, and Domino web page would spit out “There was a problem sending the command to the program”.  He has Office 2007 installed and we verified that it was working just fine.

If he tried to save the file from Domino, he would get prompted for a folder to store the file and he would try to save it is his documents folder. It went through the motions of saving the file.  No error messages, but the file wasn’t there. I repeat, there was no error message. I took a peek at the file system and found the file in an odd location. All the files that he had been trying to launch were in “c:\users\hisname\AppData\Local\Temp\Low\Domino Web Access\80\”. The “Low” part of the folder name tells us that Internet Explorer was redirected by Windows.

Starting with Vista, IE 7 runs with “low” privileges. The temporary files, cookies, and history folders are now in “low privilege” folders. Access to protected locations (root folder, documents, “my programs”, etc) is redirected by the operating system to the %LocalAppData%\Temp\Low folder. The folder virtualization that Vista/Win7 uses is pretty transparent the application. Unless the application checks for the file after it writes it (or knows about folder virtualization), it will not know that the file is in a different location. That explains why the files were not in the right location, but we still needed to figure out why they couldn’t be launched by the browser.

After a bit of searching, I figured out the problem. He just needed to add the webmail server site as a “Trusted Site” in the Internet Explorer security options. With Windows 7, he needed to do the following steps in Internet Explorer 8:

  1. From “Tools” menu, select “Internet Options”.
  2. On the “Security” tab, click “Trusted site” in the “Select a zone to view or change security settings.” panel.
  3. Click the “Sites” button.
  4. Under the “Add this website to the zone:”, enter the URL for the web mail site and click the “Add” button.
  5. If the URL starts with HTTP instead of HTTPS, make sure that the “Require server verification (https:) for all sites in this zone.” check box is cleared.
  6. Press the “Close” button.
  7. Press the “OK” button.

That will tell Internet Explorer that it’s safe to launch binary applications from the web mail application. It’s sounds annoying, but it’s just Microsoft trying to keep rogue web sites from running nasty programs.

Friday, September 17, 2010

All about “F# and You”

Last night at our monthly Tech Valley .NET User Group (TVUG) meeting, we had Rick Minerich come in and do a presentation on F#.  It was a very good presentation.  Rick was enthusiastic and knows F# cold.  One of the cool things that he showed in his presentation were examples in both F# and C#.  It looked like you could replace every 5-10 lines of C# code with F# code.

F# isn’t for everyone, but if you are doing serious number crunching and want to process data in parallel, then you seriously want to look at using F#.  It’s a full fledged member of Visual Studio 2010, it’s not just something bolted on to the architecture.

With F#, asynchronous programming is much simpler.  This useful for performing operations that require asynchronous I/O.  A common example would be collecting data from multiple, non-related web pages.  With F#’s asynchronous workflows, you define a set of operations to be performed in parallel.  The following example from MSDN shows one way that you can implement this.

open System.Net
open Microsoft.FSharp.Control.WebExtensions

let urlList = [ "Microsoft.com", "http://www.microsoft.com/"
"MSDN", "http://msdn.microsoft.com/"
"Bing", "http://www.bing.com"
]

let fetchAsync(name, url:string) =
async {
try
let uri = new System.Uri(url)
let webClient = new WebClient()
let! html = webClient.AsyncDownloadString(uri)
printfn "Read %d characters for %s" html.Length name
with
| ex -> printfn "%s" (ex.Message);
}

let runAll() =
urlList
|> Seq.map fetchAsync
|> Async.Parallel
|> Async.RunSynchronously
|> ignore

runAll()

This code will process each URL in urlList in parallel, and will wait until each sequence has been processed before continuing.  The wait state management and thread housekeeping are handled by F#, the programmer doesn’t have to worry about that at all.


If you want to know more about F#, Rick is a great source.  In addition to his web site, you can find him on Twitter as @Rickasaurus.