Scott Hanselman

Hacking Diabetes

October 5, '12 Comments [41] Posted in Diabetes
Sponsored By

Photo by cogdogblog used under CCNOTE: The top part of this post is background and basics. If you are a diabetic who wants the advanced techniques, they are further down a bit.

Being a Type 1 diabetic sucks. But, if you know anyone who is diabetic then you likely already know that. Over the last twenty years I've tried  many different drugs, diets, techniques, and hacks all meant to keep me alive as long as possible. Diabetes is the leading cause of blindness, liver failure, kidney failure and a bunch of other stuff that also sucks. It would be really awesome to die of regular old age rather than some complication of diabetes.

Every few months a diabetic should get a blood test call an hA1c that is a measure of long term blood sugar control. A normal person's A1C is between 4% and 6% which roughly corresponds to a 3 month average blood sugar of between 70 and 120mg/dl, which is great. My A1c has been around 6.0 to 6.7 which is under the American Diabetes Association's recommendation for Type 1 diabetics of 7.0, but not as low as I'd like it.

Related Reading

I recently redoubled my efforts and lost about 30lbs, started working out more and removed more carbohydrates by implementing a relaxed paleo diet. This, combined with some medical equipment changes that I discuss below have resulted in my latest A1c - just in last week - of 5.7%. That means for the first time in nearly 20 years I have maintained near-normal blood sugar for at least 3 months.


A Type 1 diabetic doesn't produce any insulin, and insulin is required to process sugar and deliver it to the cells. Without insulin, you'd die rather quickly. There's no diet, no amount of yoga, green tea or black, herbs or spices that will keep a Type 1 diabetic alive and healthy. Type 1 diabetes is NOT Type 2 diabetes, so I'm not interested in your juicers, raw food diets or possible cures. I've been doing this with some success for the last two decades and I plan to continue - also with success - for the next two.

If you blood sugar gets too high you'll die slowly and rather uncomfortably. If your blood sugar gets too low you'll die rather quickly (or at the very least lose consciousness). The number one goal for a Type 1 Diabetic is to effectively manage insulin and blood sugar levels by simulating a working pancreas where there isn't one. You eat food and your blood sugar rises. You take insulin and your blood sugar lowers. You can prick your finger and check your blood sugar directly then perform some calculations and inject yourself with insulin. If everything works out well then your blood sugar is stable just like a "normal" non-diabetic.

Unfortunately it's never that easy, and in the case of Type 1 diabetes there's a number of factors that complicate things. Sometimes blood sugar rises on its own, sometimes due to illness, hormones, or any of a dozen other factors. The most difficult issue to deal with is that of lag time. When you check your blood sugar you're actually looking at the past. You're seeing your blood sugar in the past, sometimes 15-20 minutes ago. When you take insulin it won't start working for at least 30 minutes, often as long as 60 to 90 minutes. I talk about this in my post Diabetes: The Airplane Analogy. Try flying a plane where your altimeter shows you the past and altitude adjustments are all delayed. I would imagine it's not unlike trying to pilot the Mars Lander. Sadly, there is no such thing as "real time" when it comes to diabetes management.

Basic Management

Basic blood sugar management typically comes down to carb counting and insulin dosage. You'll learn from a Diabetes Educator that your body (everyone is different) will react to insulin in a certain way. You'll learn that, for example, your insulin to carbohydrate ratio might be 1U (1 unit of insulin) to 15g (grams) of carbohydrate. You'll read food labels and if there's a cookie with 30g of carbohydrates or sugars that you'll need to "cover" it with 2U of insulin.

That's the basics. Things quickly get complicated because not all sugars are alike. A cookie with 30g of carbs will "hit you" - or cause a blood sugar rise - much faster than an apple with 30g of carbs or mixed nuts with 30g of carbs. The speed at which carbs hit you is known as the glycemic index of the food. Fruit juices, starches, candy, all have high glycemic indexes.

Why should a diabetic care about how fast food raises their blood sugar? Because the faster your blood sugar moves the hard it is it control. If a cookie can raise blood sugar in 15 minutes but insulin won't start lowering it for an hour you can see how a daily rollercoaster of blood sugar spikes can get out of control.

A reasonably low carb diet makes Type 1 diabetes much easier to handle and manage. I avoid bread, sugar and anything "white." That means no white rice, no white bread, no white sugar. If I'm going to have bread, it'll be whole grain or sprouted wheat.

Portion Size and Cutting Carbs

You should rarely be eating a meal that is larger than your own fist. Better you eat 6 fist-sized meals than 3 giant plates a day. Reasonable portions avoid high sugar spikes.

Cutting carbs is surprisingly easy. I've done personal experiments with hamburgers, for example. A hamburger might require me to take 6U of insulin but that same hamburger minus the top bun was only 3U. It was still satisfying and yummy but that top bun was just empty carbs. That leaves more room for salad (with dressing on the side) which is a diabetic's "free food." You can eat raw veggies until you're bloated and in some cases take no insulin at all, while a Small French Fry could literally set you on a miserable rollercoaster of a day.

Fries and starches are simply off limits. If you eat them, you will pay the price. Pizza, potatoes, tubers of any kind are all effectively raw sugar. Same with all fruit juices and any HFCS (High Fructose Corn Syrup.) In fact, any "-ose" is ill-advised, including Fructose, Glucose and Dextrose.

The Poor Man's Pump

Not that many years ago insulin came in many speed variations. Some were long acting and some short. In recent years we've standardized on two kinds, very long acting where one shot lasts for 24 hours, and fast acting where one shot starts in about an hour and is gone in about four.

We need some insulin running in the background all the time just to stay stable. This is all the basal rate or background insulin. Then when we eat we need a bolus of insulin to "cover" a meal. Long acting insulin can act as the basal and short acting as the bolus.

For those that don't have an insulin pump (more on that later) a pump can be simulated by a long acting shot of an insulin like Lantis/Glargene once a day to act as a basal and then short acting insulins like Humalog/Novalog/Apidra for means. You can simulate about 80% of a pump with this "poor man's pump."

Insulin Pumps

Photo by cogdogblog used under CCIf you've got an insulin pump like I have then you actually have no long acting insulin in you. Instead you've literally got a pump and a tube dripping insulin into your body. I've worn one 24 hours a day, while asleep and awake for over a decade.

So where's the basal or background insulin coming from? The pump actually contains only short acting insulin but delivers it in extremely precise and tiny increments all the time. For example, I usually have my pump delivering 0.5U/hr all the time.

Note that none of this is automatic. Pumps are not automatic systems and will only do what you tell them, fortunately or unfortunately. If you're willing to put some thought and effort into it you can do some interesting things with pumps that you simply cannot do with MDI (Multiple Daily Injections.)

Square Wave Basal (Buffet Mode)

One of the things a pump can do that injections simply can't is basal adjustments. Once you've taken a long-acting insulin shot, it's in you and it's going to do its work for 24 hours. The only thing you can do with insulin in you already is add more food or more insulin.

With a pump, though, you can program a either a Square Wave Bolus or a temporary Basal. This can be useful when at an event where you'll be "grazing" and eating little bits over a long period, or in situations where you're eating foods that will take a long time to digest, like pizza.

Temporary basals are also useful for exercise and activity. You can temporarily lower your background insulin for a few hours while you're hiking, for example. Lowering your basal temporarily is your best way to avoid exercise-related lows.

Often Type 1's get into trouble exercising because they'll work out, burn a hundred calories, have a low blood sugar, then eat a few hundred calories thereby negating the original exercise. Lower your basal an hour or so before exercise and set a timer to keep it low for an hour or two. Better an exercise-induced high than an exercised-induced low.

Temporary Basals while crossing Time Zones

I do a lot of international travel and often cross a number of time zones in a single trip as a diabetic. Diabetics on pumps often have multiple basals rates programmed on a schedule and this can cause issues when going overseas.

For example, here's mine:

  • 3am - 0.75U/hr
  • 8am - 0.5U/hr
  • 6pm - 0.6U/hr
  • 12am - 0.5U/hr

The 3am to 8am boost there is to manage the blood sugar rise known as the "dawn phenomenon." It's your body trying to get you ready for the day. It's part of your circadian rhythm and it's great for you. It's lousy for me though as it means my blood sugar will just start rising unchecked starting at about 4am.

When travelling, though, what's dawn to me? ;) It takes about a day to adjust for every time zone crossed. So even though I was just in Europe for a week, my "dawn" was slowly moving from the west coast of the US over the Atlantic all week. I needed to be aware of this as I set my pump's clock.

If you change your pump's clock to the destination time zone on the first day, your basals won't reflect your physical reality. You'll get more insulin at 3am local time, for example, but you likely needed it 4 or 7 hour before.

I've found that for simplicity's sake I set my basals while travelling to two 12-hour values, night and day. For example, on this trip I set to 0.6U/hr during the day and 0.5U/hr during the night. This allowed me to see when the dawn rise was happening and deal with it using a bolus, rather than risking a nasty and unexpected low at a seemingly random time. Use temporary basals to smooth things out. I'll set 4 and 6 hour temporary basals as well to "tap it down" or "float up."

Super BolusPhoto by kirinqueen used under CC

One of the most advanced and most powerful techniques is the Super Bolus. I tend to be a little prejudiced against CDEs (Certified Diabetes Educators) (sorry, friends!) unless they are diabetic themselves. No amount of education can match 24 hours a day, 7 days a week for 20 years. The Super Bolus is one of those techniques that we find after hard work and 3am suffering.

Since even fast-acting insulin often isn't fast enough you'll sometimes want a way to give yourself more insulin now without an unexpected low in 2 to 4 hours.

What you can do is turn off your pump effectively by setting a temporary basal of 0U/hr, and then give yourself the saved amount on top of your planned bolus.

Here's an example. You want to have some ice cream. You take 5U of insulin, your basal is 0.5U/hr. You eat the ice cream and have a bad high sugar in an hour and then a nasty low 3 hours out. The insulin didn't move fast enough to cover the ice cream, and when it did finally start working it took you low because your basal was ongoing.

Instead, you could take 6.5U of insulin and set a 3 hour temporary basal of 0U/hr. You have taken the 1.5U that would have been spread out over 3 hours and instead stacked it on top of the big bolus. The net amount of insulin is the same! You're just clipping that big high and bypassing that nasty low.

You'll need to find numbers that work for you, but the Super Bolus is a powerful technique for avoiding highs and still being able to eat some carbs.

Off-Label Drugs

There are a number of interesting new drugs out for diabetics that aren't super common but if you're interested in hacking your diabetes and you have a willing endocrinologist they could help you.

Symlin is a brand name synthetic amylin and replaces another missing hormone in Type 1 diabetics. Symlin is another shot you would have to take in addition to insulin. We tend to digest food really quickly and that causes nasty post-prandial (after eating) blood sugar spikes. Symlin will slow your digested to that of a normal person and clip those high sugars and allow your insulin to work. Talk to your doctor because it's serious stuff and not to be trifled with. Symlin induced low blood sugars can be really challenging to pull up out of. If you can get past the first two to four weeks of nausea it can be a powerful tool. I took Symlin for a number of years but now I only use it for a few large meals a year like Thanksgiving and Christmas.

Victoza is a new drug for Type 2 diabetics and is explicitly not recommended for Type 1s. However, if your doctor feels it would help you as a Type 1 it can be given "off label." It is a GLP1 inhibitor that also slows absorption of food and its movement through the gut. Finding the right dose can be a challenge, but since Victoza is a daily injectable you can adjust the dose one day at a time.

UPDATE/Correction from Karmel: "Minor point, but Victoza and Bydureon are GLP1 (with a P for glucagon-like peptide) agonists (that is, analogs)-- they mimic the action of GLP1, not inhibit it. Some T2 drugs with similar effects like Januvia are DPP-4 inhibitors, where DPP-4 inhibits GLP1, making a DPP-4 inhibitor a positive regulator of GLP1. But GLP1 we want"

Bydureon has a similar effect to that of Victoza except you take it once a week. It's also a Type 2 drug that is off label for Type 1s. It takes about a month to build up in the system before you see its effects and it can also cause significant nausea.

Order of Food

What a silly heading, but yes, the order you eat can affect your blood sugar. If you drink juice and eat bread before eating a chicken breast your blood sugar will rise faster than if you eat the chicken breast first. If you have a meal with fat in it then eating the fatty part of the meal will slow down whatever comes next. While cheese isn't really good for you, you can slow down the food that comes after it by eating cheese before crackers and an apple, for example.

Lowering A1C by Sleeping

Here's another trick that was so fundamental to getting my A1c down. You're asleep for 6 to 10 hour a day. Nearly a third of your life you're asleep. This is the perfect time to have great blood sugar. There are few feelings worse as a diabetic than waking up after a long night only to discover that you've had high blood sugar all night long. You've been marinating in your own sugar and you didn't even know. What a horrible feeling.

I try not to eat after 8pm so that I have from 8pm until I go to sleep to even out my numbers. You want your numbers to be either normal or heading clearly towards normal as you go to sleep. Just as they say for a good marriage you should never go to bed angry. I say for good A1c results you should never go to bed with bad blood sugar. Even if your numbers are garbage all your waking hours at least try to get them smooth and low as you sleep. Avoid doing anything to move them around after dinner. Eat your dinner, get back to normal, then have a basal rate you can count on and set it for as long as you can.


Always be on the lookout for equipment that might allow you to better manage your blood sugar. Sometimes this is covered by insurance, sometimes it's not. It never hurts to ask your insurance company or your doctor.

I've used a Medtronic insulin pump with an integrated CGM for years. It's a good integrated system but the CGM has as considerable lag time showing my blood sugar about 20 minutes in the past. I have also been unimpressed with my OneTouch Mini blood sugar meter. I grow tired of calibrating and coding the meters and I also feel they aren't nearly as accurate as one needs for tight control.

This year I moved from my Medtronic Paradigm Continuous Glucose Meter (CGM) to a Dexcom Seven CGM. I also switched from a OneTouch Mini to a OneTouch Verio.

The OneTouch Verio is a near codeless meter from OneTouch. That means I can just plug in a strip without entering any codes or calibrations. It is rechargeable with a standard mini-USB adapter and it even as a lighted sensor area so you can check your numbers at the movies. (This is a bigger deal than you might realize.)

The Verio, in my opinion, skews high in its readings. When compared to the OneTouch Mini the Verio values are consistently 20mg/dl higher. This is actually a good thing because when calibrated with the Dexcom CGM it nudges me towards an even lower blood sugar goal.

The Dexcom Seven CGM is the single greatest piece of new technology I've ever experience since I was diagnosed at age 20. It's so profoundly amazing and so utterly indispensible I truly can't imagine life without it. It reduced the lag time for my readings from 20 minutes to less than 5. It's far more accurate than the Medtronic and the sensors can stay in for a week or more. It doesn't provide as much historical data as the Medtronic but the accuracy of the Dexcom is a thing to behold. I'm looking forward to the new Animas Vibe with the Dexcom integrated and plan on switching the nanosecond it comes out. Even though the Dexco is yet another thing to carry and keep charged I credit this CGM with helping me get the best A1c test results of my diabetic life thus far.

As with all random blog posts your read on the internet, remember this. I'm not a doctor. I'm just a random dude you don't know. Try all this at your own risk and under your doctor's supervision.

If you'd like to make a tax-deductible donation to the American Diabetes Association and be a part of Team Hanselman, you can donate securely here It is appreciated!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Why does TypeScript have to be the answer to anything?

October 2, '12 Comments [99] Posted in Javascript | Open Source
Sponsored By

vs-refactorDISCLAIMER: I don't work on TypeScript. I am not involved with that team and this is all my own opinion and conjecture.

UPDATE: After this post I sat down with Anders in Denmark at the GOTO 2012 Conference sin Aarhus and asked him bunch of questions about TypeScript. That recorded audio podcast is now available.

TypeScript was announced and folks are saying "TypeScript is clearly Microsoft's answer to Google's Dart" or "So TypeScript is Microsoft's answer to CoffeeScript."

I was chatting with Jez Humble today about the intense interest and some little gnashing of teeth around TypeScript and he offered this little gem of a quote:

It's disappointing when smart people display a profound ignorance of computing history. - Jez Humble

TypeScript has been out a day. It's way early to see if it has legs, but it seems initially promising.

TypeScript and Dart

People have compared TypeScript to Dart. That's comparing apples to carburetors. TypeScript builds on JavaScript so there's no JS interop issues. Dart is a native virtual machine written from scratch. Dart interops with JavaScript...but it's not JS. It doesn't even use the JavaScript number type for example.

TypeScript and CoffeeScript

I'm a huge CoffeeScript fan although it is a different language with a syntax of its own to learn. What I like about TypeScript - so far - is that TypeScript’s static typing could enable better tooling with warning squiggles, easy statement completion, plus smart refactoring. You also get easy navigation around code, as well as find references, rename, and more. You don’t currently get that in CoffeeScript.

So what is TypeScript?

TypeScript is a superset of JavaScript and you write it like you write JavaScript which I like. Any existing JavaScript is already TypeScript. One argument has been made that TypeScript is for people who don't want to learn JavaScript. I don't buy that. As Ward Bell said in an email:

TypeScript is not a crutch any more than JSLint is a crutch. It doesn’t hide JavaScript (as CoffeeScript tends to do). - Ward Bell

I think Ward says it well. Folks rail against static typing but they don't complain about JSLint. TypeScript offers optional type annotations - it's hardly a perversion of JavaScript.

From what I can see after using TypeScript for a few days is this. It gives you type checking, explicit interfaces and easier module exports. In fact, it's a little like getting some of tomorrow's ECMAScript 6 early in a way that's compatible with today's JavaScript. ES6 won't be out for at least a year but we can play with some of those features today.

Things that I like about TypeScript:

  • It's Open Source and under the Apache 2.0 license
  • You can install the tools easily with
    • npm install typescript -g
  • You can git the source
    • git clone 
  • You can play with it online at

Things I don't like about TypeScript (these are mostly implementation things)

  • No splitscreen editor like Visual Studio's existing CoffeeScript editor
    • UPDATE: While this isn't "official" support, Mads has updated Web Essentials 2012 with a splitscreen editor. The two teams are going to work together on a more official solution.
  • Doesn't generate .js on save, requires a build.
  • You have to add a BeforeBuild target to your ASP.NET application's CSPROJ:
<Target Name="BeforeBuild">
<Exec Command="&quot;$(PROGRAMFILES)\Microsoft SDKs\TypeScript\\tsc&quot; @(TypeScriptCompile ->'&quot;%(fullpath)&quot;', ' ')" />

I will continue to use TypeScript and evaluate it, but I think the fact that it's open source, it creates JavaScript and it feels comfortable to me as a C# programmer means it will fill a useful niche.

This quote from Luke Hoban, co-creator of TypeScript really hits the spot.

"CoffeeScript is to Ruby as TypeScript is to Java/C#/C++." - Luke Hoban

If you love Ruby, you'll enjoy CoffeeScript as it makes the JavaScript more like the Ruby. The same is true with TypeScript. It brings useful features into JavaScript in an ultimately compatible and syntax-friendly way using language constructs you're comfortable with.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Making a switchable Desktop and Mobile site with ASP.NET MVC 4 and jQuery Mobile

October 1, '12 Comments [27] Posted in ASP.NET | ASP.NET MVC | Javascript | Mobile
Sponsored By

I really enjoy working on and thinking about mobile websites. There's something about making an experience great on a pocket supercomputer phone that is so much more satisfying than a desktop. I actually got this blog looking nice on mobile devices back in 2006 when nobody was mobile except doctors and, well, all of us techies here on the blogs.

I've talked about the importance of a good mobile site before in posts like Create a great mobile experience for your website today. Please. However, some folks had asked me if I'd do a post on how to do a combination Desktop and Mobile site using ASP.NET MVC similar to the examples I used in my talks in Russia on mobile earlier this year. (There's video of those ASP.NET mobile presentations available)

When you start Visual Studio 2012 and go File | New ASP.NET MVC 4 app, there's an Internet Application template and a Mobile template. One gets you a standard desktop site - although with responsive design elements so it works on small screens - and the other gets you a jQuery Mobile application meant primarily for phones and tablets. Let's make one that switches between both.

We will do a small site in ASP.NET MVC for the Desktop, do some quick DB access, add jQuery Mobile and a View Switcher switch back and forth. I'll be using the Electric Mobile Studio from Electric Plum to simulate an iPhone. You can get a 7 day trial or you can get the Lite version of the Electric Plum Mobile Simulator with WebMatrix 2.

Quick CRUD Example

First, a model for DVDs.

public class DVD
public int ID { get; set; }
public string Title { get; set; }
public int Year { get; set; }
public Rating rating { get; set; }

public enum Rating
G, PG, PG13, R

Next, I scaffold out the Index, Create, Edit, Delete, etc. Unfortunately scaffolding doesn't do Enums (I'm sad) for my Movie Ratings so I add EditorFor() calls to my Create and Edits, and update my Index.

<div class="editor-label">
@Html.LabelFor(model => model.rating)
<div class="editor-field">
@Html.EditorFor(model => model.rating)
@Html.ValidationMessageFor(model => model.rating)

Shared/EditorTemplates/Rating.cshtmlI could have used DropDownList I suppose, but I have always found that helper confusing. Instead, I'll create a Rating.cshtml that makes a dropdown. I could change this at some future point to be fancier and not even use a DropDown.

Aside: How do you guys usually handle Enums? I've seen it done a few ways. I'd like this to be more generic, but here's what I did for the Rating editor Template. Note the nullable ? as it has to work for both Create and Delete

@model MyApp.Models.Rating?
@using MyApp.Models

<select id="@ViewData.TemplateInfo.GetFullHtmlFieldId("")" name="@ViewData.TemplateInfo.GetFullHtmlFieldName("")">
@foreach (int rating in Enum.GetValues(typeof(Rating))) {
var name = Enum.GetName(typeof(Rating), rating);
<option value="@name" selected="@(Model.HasValue ? (int)Model == rating : false)">@name</option>

OK, so there's a basic Desktop CRUD app.

Editing a DVD List of DVDs

Making it Mobile

iPhone in the Visual Studio browser menuAs I mentioned, you've probably noticed when making an ASP.NET MVC application that you can choose a Mobile template with jQuery Mobile along with the standard responsive "desktop" Internet Application. However, there isn't a switchable template. That is, one that is the regular template on Desktops but switches to jQuery Mobile (or KendoUI, or whatever makes you happy) on mobile devices.

Using NuGet, install the jQuery.Mobile.MVC package. You can either right click on References, select Manage NuGet Packages, or you can use the Package Manager Console and type:

install-package jQuery.Mobile.MVC

This package will automatically bring in jQuery Mobile as well as:

  • A ViewSwitcher partial view and supporting Controller
    • This is what lets us switch manually between Desktop and Mobile
  • A basic _Layout.Mobile.cshtml and supporting stylesheet
  • A BundleMobileConfig.cs used with ASP.NET Optimization (the bundler for CSS and JS)

NOTE: There's nothing jQuery Mobile specific about the ViewSwitcher or the techniques here. You can happily change this package for any other popular mobile framework.

We start by adding the new Bundles in the Global.asax:

BundleMobileConfig.RegisterBundles(BundleTable.Bundles); // <-- ADD THIS ONE

Since I installed the Electric Plum iPhone simulator, I'll select it from my browser dropdown in Visual Studio and run my app and navigate to /DVD.

The system sees that I'm on a mobile device and rather than using _Layout.cshtml it uses

This doesn't really look nice for a few reasons. First, I don't like the default style. Just go into _Layout.Mobile.cshtml and change the data-theme attribute to a value that makes you happy. I changed it from theme a to theme b.

Basic App in an iPhoneSame baisic app with a light background

Second, while I'm using the _Layout.Mobile.cshtml I'm still using the desktop Index.cshtml which looks lousy when displayed in the mobile layout. Remember that I only have an single Index.cshtml. If I had an the system would use that page instead when rendering on a mobile device.

I can make an Index.Mobile.cshtml with simpler markup, change the table into an unordered list and add some jQuery Mobile specific attributes like this:

@model IEnumerable<MvcApplication2.Models.DVD>
ViewBag.Title = "My DVDs";
<ul data-role="listview" data-filter="true" >
@foreach (var item in Model) {
<a href="@Url.Action("Details", new { item.ID })">
<h2>@Html.DisplayFor(modelItem => item.Title)</h2>
<p>@Html.DisplayFor(modelItem => item.Year) - @Html.DisplayFor(modelItem => item.rating)</p>

Note the data-role and very basic elements like <ul>, <li>, <h2< and <p>. I also added the client side data-filter attribute to get some nice client-side searching. Hit refresh and now it's starting to look like a real mobile site.

See the ViewSwitcher at the top there? That's a partial view called _ViewSwitcher.cshtml.

A lovely jQuery Mobile example list of DVDs

By default it will let you switch back and forth between Desktop and Mobile but only on mobile devices. Why? Check out the first line of code:

@if (Request.Browser.IsMobileDevice && Request.HttpMethod == "GET")
<div class="view-switcher ui-bar-a">
@if (ViewContext.HttpContext.GetOverriddenBrowser().IsMobileDevice)
@: Displaying mobile view
@Html.ActionLink("Desktop view", "SwitchView", "ViewSwitcher", new { mobile = false, returnUrl = Request.Url.PathAndQuery }, new { rel = "external" })
@: Displaying desktop view
@Html.ActionLink("Mobile view", "SwitchView", "ViewSwitcher", new { mobile = true, returnUrl = Request.Url.PathAndQuery }, new { rel = "external" })

That first line checks if it's a mobile device making the request. Just surround that with /* comments */ and you'll be able to view and debug mobile layouts with your desktop browser without faking User Agents.

So far we've been talking about "mobile" and creating files with "mobile" in their file names and it's all been magic. Turns out we have lots of control over these things. Perhaps we want more than but also, perhaps, Index.iPhone.cshtml and Index.WP7.cshtml.

Create lines like these in your Global.asax:

DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("WP7") {
ContextCondition = ctx => ctx.GetOverriddenUserAgent().Contains("Windows Phone OS")
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("iPhone") {
ContextCondition = ctx => ctx.GetOverriddenUserAgent().Contains("iPhone")

You can affect the DisplayMode collection (of which "mobile" is one) by inserting in your own. Here I'm making two more specific mobile ones but you don't need to do mobile things to change DisplayModes.  A DisplayMode could be right to left for RTL languages, or "gold" and "bronze" for customers or whatever makes you happy, based on the ContextCondition you evaluate on each request.

There's lots of choices and you've got the flexibility to do things however you like. I'll show an example of a totally offline iPhone site using cache.manifest in a future post.

Related Links

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

How to create a DVD on Windows 8 even though Windows DVD Maker is gone - DVDStyler

September 30, '12 Comments [84] Posted in Tools | Win8
Sponsored By

DVDStyler standard NTSC options of 720x480I make a lot of DVDs. I make them for weddings for family and for funerals and memorials. I make trip DVDs and memory DVDs and all sorts of stuff.

Why don't you put all that stuff online, Scott? Why don't you put it on Facebook/YouTube/Vimeo/Whatever? There's a couple reasons. First, believe it or not, there's a lot of people in the world who don't have high-speed internet. We've got lots of relatives overseas who don't have a laptop at home nor do they have any internet in their home. Here in the US we've got lots of older relatives who don't have computers, or perhaps they only have an iPad and a link to a YouTube video doesn't have the sense of meaning or permanence that a DVD does.

Random Aside: It's a shame that today's young people won't realize how much effort it took to create a mix tape for someone. Rearranging MP3s and emailing a list isn't the same as waiting for specific songs to get played on the radio and pressing Record within the first two notes.

Perhaps making DVDs is a lost art and I'm an old fogey. Or perhaps DVDs are today's mix tapes.

Regardless, I recently installed Windows 8 on my home machines and my laptop. Around the same time my Uncle Ronald - the closet person I've ever had to a grandfather - passed away. I immediately got to work creating a DVD for his memorial service. I had 30 minutes of audio of Uncle Ronnie that I recorded for a never-aired podcast. I had hundreds of photos over 90+ years of his life, 8mm and Super8 film reels as far back as the 50s, combined with digital video going all the way back to 1998 from my own collection. I was looking forward to burning many DVD copies and mailing it to interested relatives as well as playing the DVD at the memorial.

I spent many hours putting together a tribute video. I used Movie Maker as I have for many of my projects. I also have Adobe Premiere but for putting together family videos there's little easier than Movie Maker. I did my editing and went to Save Movie to export my movie as a WMV to import into Windows DVD Maker. But there was no DVD option. Confused, I searched the start menu for Windows DVD Maker. I'd used it just a week before...before I upgraded my Windows 7 to Windows 8.

Windows DVD Maker was gone. It's not in Windows 8. :(

I was pretty bummed as I needed to make DVDs for the memorial event and I kind of needed them immediately. There's lots of different third party DVD creation software packages but I've always personally felt that media players and media creation software from 3rd parties (Roxio, CyberLink, etc) have always been rather garish in their user interface style. They never LOOK like they belong in Windows. There's always bright red window chrome, the same airbrushed happy clipart families in splash screens.

I just want to import a video file into a simple app and create a DVD. Preferably for free.

Save as DVD from within Windows Movie MakerI evaluated a number of DVD creation suites over a number of hours and decided on the open source DVDStyler (NOTE: this is a link to the Adware-Free Portable Edition!). I like DVDStyler because it's extremely spartan in its user interface but extremely capable. One could believe it was included with Windows and it is an excellent complement to Windows Live Movie Maker. For me, installing DVDStyler makes up for DVD Maker being gone on Windows 8.

IMPORTANT NOTE/WARNING: While it is an open source GPL'ed project, in order to support itself DVDStyler does install some toolbar software and will change your browser home page and install additional software if you just "next, next, next, finish" through their installation process. When installing free software please ALWAYS be aware of what you're saying YES to. Be sure to use the Custom installation option and select (or deselect) the options that are right for you. While I found these changes surprising and an annoyance, I feel the value provided by this free software to be worth the annoyance of these other applets. I removed them later via Uninstall Programs as well as by manually removing extensions in Firefox and IE.

When you save your movie from Windows Live Movie maker, you might want to make a Custom Production Setting. I created one and called it DVD and set it to 720x480. You might change this if you are creating PAL (720x576) or NTSC DVDs. It's up to you. The point is that Windows Live Movie Maker has no standard DVD movie creation option anymore but you can create any custom setting you'd like.

Creating a Custom DVD Setting in Windows Live Movie Maker

In DVDStyler I use similar settings. Be sure to select 16x9 if most of your source material is widescreen and most of your destination TVs are also widescreen. I usually use DVD-5 (4.7 gigabytes) but occasionally I'll use a dual-layer DVD-9 (8.5 gigabytes) and a high bitrate if there is a lot of action on the screen.

You can burn the DVD directly or, if you want more control, create an ISO file and use another tool like ImgBurn to burn or create multiple copies.

Burn image from DVDStyler

I'm glad to have found a reasonable, simple and free option for creating DVDs on Window 8 in DVDStyler.

Sponsor: Be part of GENERATION APP. Your Idea. Your App. 30 Days. Begin your 30-day journey to create a Windows Store style app and talk 1-on-1 with a Windows 8 app development pro. Get started today.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

A Bug Report is a Gift

September 24, '12 Comments [36] Posted in Bugs | Musings
Sponsored By

There were lots of reactions to my blog post Everything's broken and nobody's upset. Some folks immediately got the Louis CK "Everything's Amazing and Nobody's Happy" reference. Some folks thought it was a poorly worded rant. Some folks (from various companies) thought I was throwing developers under the bus, accusing them of not caring. Others saw a meta-goal and started a larger discussion about software quality.

The questions I asked were these...but the most significant one was added a few hours later, suggested by a reader.

  • Is this a speed problem? Are we feeling we have to develop too fast and loose?
  • Is it a quality issue? Have we forgotten the art and science of Software QA?
  • Is it a people problem? Are folks just not passionate about their software enough to fix it?
  • It is a communication problem? Is it easy for users to report errors and annoyances?

After the post I went back and tried to file bug reports for all the issues I bumped into. For products where I couldn't find an easy bug reporting site I used Twitter. Google and Microsoft were universally pleasant when I reported the bugs and seemed sincerely interested in helping.

Is it easy for your users to report a bug? Does you app automatically report crashes? Is your site friendly? Are you support people friendly and engaged? Are your bug support forums filled with reports but no company representatives? Do you use GetSatisfaction or UserVoice?

Anatomy of a Good Bug Report

Ideally the "best" bugs are those that can be reproduced given enough context. You can save developer time and trouble by giving them as many details as you can. Developers can save everyone time with bug reporting tools that collect that information for users.

Mozilla Crash Reporter

For example, on Windows if you run "msinfo32.exe" you can get a complete snapshot of your system.

Send a Frown and Send a Smile

I am a big fan of the "Send a Frown" way of getting bugs.

Firefox made me sad because...

The Office 2013 Previews even have hotkeys for this!

Office 2013 Send a Frown

Sending feedback is even better with screenshots.

Give Feedback with Screenshot in Office 2013

The help menu for Skype includes a Give Feedback menu as well as "Skype Status."

Give Feedback menu in Skype

As a user, if you can include information like:

  • What were you doing? What were you trying to do?
  • Advanced folks: What weird add-ins/extensions or hacks are you using that you haven't mentioned but you really should? *cough* Adblock *cough*
  • Can you make it happen every time?
  • Can you include a screenshot? Bonus points for a screencast!

This is a lot to ask of a user!

Some examples of where to file bugs

Here's some sites you can use to report bugs in certain applications. Note that some are fancy, some spartan, some just forums, some actual bug tracking software, made for and used by developers.

Or, the ultimate place to file bugs for your favorite software, as my friend Anil points out:

How hard does the user have to work to file a bug? It's OUR bug but the user not only hit the bug but also has to work to report it!

Every click or manual step that our users have to invest in our bug is a click too many. A bug is the pain that hurts the user and keeps hurting as they report it! A good bug report is a gift that keeps on giving and we should treat it as such.

I'd love a world where all crashes are automatically reported and there's a "Send a Frown/Smile" button on everyone's computer that offers to record a short screencast with just a single "record/stop" button.

What product do you think has the best bug filing experience? Sound off in the comments!

This week's sponsor: Be part of GENERATION APP. Your Idea. Your App. 30 Days. Begin your 30-day journey to create a Windows Store style app and talk 1-on-1 with a Windows 8 app development pro. Get started today.

Related Posts in this Three Part series on Software Quality

  1. Everything's broken and nobody's upset
  2. A Bug Report is a Gift
  3. Help your users record and report bugs with the Problem Steps Recorder

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.