Scott Hanselman

ASP.NET MVC Design Gallery

January 5, '09 Comments [13] Posted in ASP.NET | ASP.NET MVC
Sponsored By

My teammate Stephen Walther launched the ASP.NET MVC Design Gallery a few weeks back. This stemmed from an idea ScottGu had to let the community change the default templates that ship with ASP.NET MVC. I was supposed to work on this but headed to Africa for the holidays so Stephen helped me out and took over the project and did a better job than I would have!

You can vote on the designs that you like and that you don't like. You also can contribute new designs of your own.

image

After you download a design from the gallery, you can use the design by following these steps:

1) Copy the files from DesignTemplateCS or DesignTemplateVB folder into your project (use DesignTemplateCS for C# projects and DesignTemplateVB for VB.NET projects)

2) Do a search and replace the string [YourProjectName]. Replace [YourProjectName] with the actual name of your project as displayed in the Solution Explorer window.

This last step is necessary to get the namespaces right. Most of the templates use helper methods to render the menu items so that the selected menu item is correctly displayed.

Microsoft also is hosting a design competition to encourage members of the community to submit new designs. Submit a new design before January 31, 2009. ScottGu will be selecting the best three designs and announcing them on his blog. Learn more about the ASP.NET MVC Design Competition and submit your designs before January 31st.

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

South Africa 2008: NewsFlash - Turns out eating less and moving more causes weight loss

January 3, '09 Comments [36] Posted in Africa | Musings
Sponsored By

image0-1When I left for South Africa I was 193lbs/87kg, my heaviest ever on a 6 foot/1.8 meter medium frame. This was shocking to me because I could totally see 200lbs coming. It was right there ahead of me. As a Type 1 Diabetic getting fat(ter) is deeply uncool. You can literally be a Type 1 (insulin dependant) and Type 2 (insulin resistant) diabetic at the same time. This would mean I'd need to take MORE insulin to do the SAME amount of work. I'd already started seeing this recently as my total daily insulin dosage, usually under 30U (Units) was creeping up to 40U.

Then we headed to Africa for our semi-yearly sojourn. Fast forward roughly a month and I'm 176lbs/79.8kg. That's 17 pounds, or as a newly svelt person me likes to say "I lost, like, 20 pounds!" The trick will be to keep it off, but here's what I think worked (as I lose nearly 20 pounds on EVERY trip to Africa, and nearly every trip overseas. The tragedy here is the re-gaining and re-losing of that same 20 pounds.)

These are totally obvious observations/tips, but I'm a little dense, so I'm writing them down.

That picture to the right is me when I was thinner. I'm also the short one in the picture.

Don't Eat a Serving Larger than Your Fist

I didn't consciously do this, it just happened. As my wife and I discussed in our recent podcast, folks just show up to visit and food is divided appropriately. This is not to say that I wanted for food in any way. I didn't. It's that my hosts in South Africa gave us a reasonable amount of food, not an American Amount of Food.

This just happened to be about the size of one's fist. Kind of unrelated, I mentioned this to the boy's doctor since the older boy wasn't eating that much and he said that most kids will naturally eat what they need to, no more and no less, and that amount was often about the size of his fist. We'd been wasting a lot of food as I was giving him a plate full of food as big as his head! So, it's a fist-sized serving for me.

Eat Breakfast

I am notorious for eating one giant 1pm meal, ahem, then a giant 6pm meal, then a small (read: almost giant) midnight meal. This didn't fly in South Africa, as there was a lovely light breakfast at 7am, lunch at 1pm, and a dinner around 6pm. Each was appropriately proportioned, especially lunch which went on the assumption that you ate breakfast.

I realized that I've been eaten Epic Lunches to stave off death by starvation from skipping breakfast entirely. While eating breakfast does make my diabetes a little more tricky to manage as it adds a new variable, breakfast does support the next tip...

Eat Only Enough to Get You To the Next Meal

or

You Will Eat Again, In Your Life, You Know

My brother, the Ironman competitor and firefighter, taught me this not-obvious-to-me tip. He says that folks who aren't eating often enough eat like it's the last time they will ever eat. Rather, try eating with the knowledge that you will eat again in a few hours. If you realize that this meal only needs to get you to the next meal. This is the single most powerful dieting tip I've got.

Reset Your Full Indicator

My wife calls overeating "Pushing Through" as in "Oh, I pushed through with that last bite." Not recognizing what full feels like is a big problem for me. Basically you can reset your internal gas tank indicator by just thinking about it. "Am I full?" "Do I really need that next bite?" This has caused me to eat about 1/3 less without actually feeling any less full. Actually, I feel less bloated after meals.

Aside: I actually have personal data (and charts!) that reflects this - while I was in South Africa my daily insulin usage (and hence, carb intake) went from 30-40U a day to 20U. Basically I used 33% to 50% less insulin per day.

Move More

I didn't visit the South Africa that a lot of people do. In my South Africa not everyone has a car. In mine you can easily fit 9 people into a VW Golf. Either way, I walked a lot. If there's no car available and you want to go to the mall that's 3km away, you walk. This, along with sweltering heat and a lot of water, is another nice way to lose weight.

This year I've started working out, six days a week, for eat least an hour. I'm alternating cardio and anaerobic exercise. I'm finding that if I time my workouts with the length of certain television shows, I can make it through without going insane. That means, 40 minutes of cardio while I watch, say, Heroes. Then 22 minutes of weights as I watch Arrested Development. I'm actually watching more TV (and enjoying it) but I don't have to feel bad since I'm moving.

Drink Water

Yes I know if you drink WAY too much water you can mess up your salt/electrolyte balance, but a few liters a day are what I've found is the right amount for me to lose weight. I can't overstate how water intake directly affects weight loss. It's really amazing. Everyone I know with 6-pack abs carries a water bottle around with them. While I was in Africa I really upped my water intake because of the heat, to the point where drinking water at every turn was second nature.

What are your weight loss tips, Dear Reader?

Technorati Tags: ,

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

Back to Basics: Explore the Edge Cases or Date Math will Get You

January 3, '09 Comments [21] Posted in Back to Basics
Sponsored By

Disclaimer: I don't work for the Zune team and I don't know anyone on the team. I think that Z2K9 was a bummer, but I don't have any inside knowledge. Everything here came from the public interweb.

Dates will get you every time. Further more, it's all about Edge Cases. This is one of the things you'll think about when doing Test Driven Development and it's one of the things that everyone learns in Computer Science 101. You really have to hit those edge cases, be they dates, or number overflows, or buffer overflows.

The news reports:

"A bug in the internal clock driver related to the way the device handles a leap year affected Zune users," said the company in a statement. "That being the case, the issue should be resolved over the next 24 hours as the time change moves to January 1, 2009."

Disclaimer*2: I have no idea if the following is 100% true, only that it seems quite plausible. I present it for educational purposes, nothing else. It's very interesting. Again, I'm just a caveman.

A Zune Fan poked around in the source code from the vendor (Freescale Semiconductor) that made the real time clock in the Zune (The vendor's source for rtc.c is here) and with the benefit of hindsight, noted that there's the opportunity to get stuck in an infinite loop.

The Zune 30 shows the date and time, as do many devices, as the number of days and seconds since January 1st, 1980 at midnight.

year = ORIGINYEAR; /* = 1980 */

while (days > 365)
{
if (IsLeapYear(year))
{
if (days > 366)
{
days -= 366;
year += 1;
}
}
else
{
days -= 365;
year += 1;
}
}

The days variable is read out of the memory location managed by the Real Time Clock (RTC). When the value of days == 366, you break out of the inner loop, but you can never get out of the outer loop.

A number of folks have blogged about the bug, their analysis and how they'd fix it. Programming Phases has a good post and folks have twittered suggestions). The basic problem is that since there are 366 days remaining when the calculations are reached for the year 2008, there will never be another subtraction to bring the total below 365, so the loop continues. The value of days is stuck at 366. It IS a leap year, but days is not > 366, so the loop continues.

In working with banking software for years, I can tell you that dates'll get you. When dealing with dates and date math you can't underestimate the value of really good code coverage. Also, even if you have 100% coverage, as I learned in my interview with Quetzal Bradley, 100% coverage just tells you a line of code DID run, it doesn't tell you that it ran correctly.

I noticed also when I visited my Live home page on Dec-31 that it said today was Jan-1, likely a Time Zone glitch. However, when I clicked the date, I was taken to a page with historical facts about Dec-31. ;)

jan1

dec31

Dates, especially when TimeZones are added in, are notoriously hard.

To this day there are a half-dozen bugs in DasBlog where we have a devil of a time with Time Zones. Omar spent weeks fighting with them before he just gave up. We have to reconcile the local time of the visitor, the time on the server, and GMT time (the time we store everything in). It usually works, but when the Server isn't on GMT we get into all sorts of trouble. We also have problems with clients that call the XML-RPC APIs, some of which use UTC (GMT) time and some use local time. Other than keeping an internal table to wrong-headed clients, there are no good solutions.

In 2007 CNN talked to a Major General about a bug in some F-22's that caused them to malfunction when going across the international dateline. The Unofficial Apple Weblog had an interesting post on Apple Date/Time bugs through the years. If you're interested in working with and maintaining legacy code, I recommend Michael Feathers' Working Effectively with Legacy Code.

As a random slightly-related aside, I was over at Hollywood Video buying a used copy of Mirror's Edge yesterday and some folks were talking about the Zune problem. The manager said, wow, I'm running the music in here on a Zune right now, and produced his brown 30G Zune from behind the counter. He either hadn't turned it on today fresh or the clock was wrong so he was able to weather the whole day without an incident. He seemed pretty pleased about his "survival."

I wonder how many other less widespread devices are running this real time clock and if any of them had trouble as well.

Do you have any personal Date/Time stories, Dear Reader? Please share in the comments!

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

South Africa 2008 - Avoiding or Minimizing Jet Lag

January 2, '09 Comments [17] Posted in Africa
Sponsored By

We're back and we've got a little problem. Part of the family has jet lag and part doesn't. It doesn't matter who does or doesn't ;) but some of us have figured out a few basic tricks when crossing more than 4 time zones. They work for us, but YMMV (Your Mileage May Vary).

In this case, we were travelling from GMT-8 to GMT+2, so that's 10 time zones. Right now it's 9:05pm where I am, and it's 7:05am tomorrow morning in South Africa.

It's not really possible to completely AVOID Jet Lag. It is JET-lag, and not bicycle-lag or walking-to-fast-lag. The human body just wasn't meant to cross an ocean in a few hours. It's supposed to take a few months or not happen at all. ;)

Now, as a diabetic, I have to pay more attention to Time Zones than most travelers, but this is all pretty standard jet-lag stuff but a little attention to detail and being willing to mess with oneself psychologically can cut your jet-lag recovery time in half or better.

  • Ahead of Time: Try to work out lots, especially cardio, in the days before your trip. I'm not sure why this works, maybe circulation, maybe it makes you tired, but it helps.
  • Water: Drink ridiculous amounts of water. I try to do at least two liters a day while travelling and I keep drinking two liters a day when I'm recovering from the flight. (Really, just drink lots of water all the time)
  • Take Advantage of the Flight Time: Our total door-to-door travel time was just over 26 hours. That's 26 hours that you COULD be getting acclimated to the destination time. I move my watch, and consciously try to move my brain to the destination time as soon as I sit down in my chair. That means literally saying to yourself, "OK, it's 7am. What would I be doing at 7am?" and trying to do it. You might find yourself needing to walk briskly around the plane when everyone else is sleeping, but it's worth it. There's many travel hours that you can be using to get ready for destination time.
  • Don't sleep when the Clock says it's Day: Lots of folks say that "your body knows what it needs." I believe this is nonsense when travelling. I think that jet-lag is the one time when your body has NO idea what it needs. You need to override your body's ignorance with your brain. If you get in to Europe at 2pm and you are exhausted, really, wait until at least 8pm or preferably later to sleep, otherwise you're screwed. I've watched people wandering around at 2am, ready for dinner, because they've slept their "8" in the middle of the day on destination time.
  • Be aware of travel direction: I find that travelling West is really easy. Travelling East is the killer. An excellent explanation from Wikipedia:
  • There seems to be some evidence that traveling west to east is the more disruptive. This may be because most people have a circadian period which is a bit longer than 24 hours, making it easier to stay up later than to get up earlier.

    It may also be that flights to the east are more likely to require people to stay awake more than one full night in order to adjust to the local time zone. For example, comparing a typical schedule for a traveler flying to the East vs a traveler flying to the West:

    • Westward from London to Los Angeles, VIA BA0279, Jan 29, 2008. Time zone difference 8 hours.
    • Westward Biological clock Los Angeles local
      Departure JAN 29 - 10:05 JAN 29 - 02:05
      Arrival JAN 29 - 21:10 JAN 29 - 13:10
      Bedtime JAN 30 - 06:00 JAN 29 - 22:00
    • Eastward from Los Angeles to London, VIA BA0278, Jan 29, 2008.
    • Eastward Biological clock London local
      Departure JAN 29 - 15:59 JAN 29 - 23:59
      Arrival JAN 30 - 02:05 JAN 30 - 10:05
      Bedtime JAN 30 - 14:00 JAN 30 - 22:00

    The first scenario is equivalent to staying up all night and going to bed at 6am the next day — 9 hours later than usual. But the second scenario (eastward) is equivalent to staying up all night and going to bed at 2pm the next day — 12 hours after the time one would otherwise have gone to bed.

  • Use Daylight: This one is the most important. When you arrive, either home or away, be outside as long and as often as possible. We used this on the children. The more sun you get (don't get burned) the more your brain will be reminded that it's daytime and you should be awake. This works even if it's snowy or gray. Just get outside!

What works for you, Dear Reader, when trying to minimize jet-lag?

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

Hanselminutes Podcast 144 - Week Three in South Africa - Ntombenhle

January 2, '09 Comments [12] Posted in Africa | Podcast | Programming
Sponsored By

My one-hundred-and-forty-fourth podcast is up. Scott's on holiday in South Africa with his family this month. Rather than doing repeats or "best of" shows, Scott's doing man-on-the-street interviews and uploading them over cell phone. In this episode, Scott talks to his Wife, Ntombenhle, an MBA and Homemaker from Zimbabwe.

Subscribe: Subscribe to Hanselminutes Subscribe to my Podcast in iTunes

Do also remember the complete archives are always up and they have PDF Transcripts, a little known feature that show up a few weeks after each show.

Telerik is our sponsor for this show!

Building quality software is never easy. It requires skills and imagination. We cannot promise to improve your skills, but when it comes to User Interface, we can provide the building blocks to take your application a step closer to your imagination. Explore the leading UI suites for ASP.NET and Windows Forms. Enjoy the versatility of our new-generation Reporting Tool. Dive into our online community. Visit www.telerik.com.

As I've said before this show comes to you with the audio expertise and stewardship of Carl Franklin. The name comes from Travis Illig, but the goal of the show is simple. Avoid wasting the listener's time. (and make the commute less boring)

Enjoy. Who knows what'll happen in the next show?

Technorati Tags: Africa,South Africa,Ndebele,Zimbabwe,Zulu

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.