Scott Hanselman

Memories of Zimbabwe - You can't afford to go home

April 05, 2008 Comment on this post [32] Posted in Africa
Sponsored By

800px-Dol_zimbabwe My wife and I have been married going on eight years. We try to go to Africa every two years as she's from Zimbabwe originally. We wanted to go to Zim last year, but ended up going to Tanzania instead as we were taking our (at the time) one year old, and my sister-in-law works for the Rwandan War Crimes Tribunal there. Zim didn't seem like a good first trip for the baby.

I remember when we went to Zim for the first time in 2001. I was meeting my then fiancée's family for the first time and was deep in lobola negotiations with her father. The exchange rate was US$1 to Z$55, and it was about Z$50 to ride in a combi (minibus/taxi).

My wife remembered at the time how she could go downtown and buy gum for a single Zim penny. Once, my sister-in-law got into huge trouble as a child when she asked a visiting relative for a penny.

When we returned two years later, the exchange rate was US$1 to $Z50,000. Mo's father passed away while we were there and it was surreal to spend a solid hour counting out $Z2,000,000 for his casket in Z$100 bills in the midst of our grief.

zim100kTake a good look at the Zim $50 note in the picture above. It had an expiration date.

Today, whatever Zim currency you have in your pocket loses value of Z$70 a minute just sitting there.

In January of 2008 the exchange rate was US$1 to Z$1,900,000 (1.9M). On March 1st, it was US$1 to $Z 24 million. Today, just two weeks later it's US$1 to Z$70 million. Arguably, Iraq has a significantly better economy than Zimbabwe as Zim's current inflation rate is in excess of 100,000%.  (Some figures point to it being around 164,000%, others closer to 200,000%.)

This Z$100,000 Bearer Cheque is not only two years expired, but were it not, it'd be worth 14/10,000ths of a US dollar, but that worth would last only a few hours.

f9e06f45-c479-4084-be83-68eb5c6da48d_mnThe gift that I gave my father-in-law to buy cows with would today be worth over $Z140,000,000,000, or 140 billion Zim dollars.

If these numbers seem overwhelming, they are. Recently the new Z$50 million dollar note came out, and it will by three loaves of bread (assuming you can find bread) a Z$16M each.

I can't tell you how painful it is to watch a country you love collapse from the outside when we have family there, but it's nothing considering what it's like on the inside. We talk to family there each week and each week the stories get worse.

I could tell you what it used to be like. I could tell you about the time we went to Chipangali Zoo with my mother-in-law and a mini-bus full of 6th graders. I could tell you about the two classrooms and bathroom (real flush toilets!) that we worked to get built.

P0004995 CIMG1645

I could tell you about the time we went to Victoria Falls and slept a hundred yards from an elephant watering hole. I could tell you about the time we went ekhaya to my wife's ancestral home to bury her father.

P0005136 P0005132

I could tell you about the time I found a goat in the my morning bathtub, then it disappeared, only to reappear on my breakfast plate the next morning. I could tell you about freaking out abantu abamnyama nxa ikhiwa likhuluma isiNdebele.

CIMG1653 Cropped CIMG1362

But, those days are gone and we have only pictures and memories. The Zim that we knew is gone and it's unclear what is coming. God help the people of Zimbabwe and our family overseas.

For updated news about the Zimbabwean elections, see the BBC Zimbabwe section or check Google News on Zimbabwe.

Related Links

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Hanselminutes Podcast 107 - Digital Photography Explained (for Geeks) with Aaron Hockley

April 04, 2008 Comment on this post [22] Posted in Podcast
Sponsored By

My one-hundred-and-seventh podcast is up. In this episode I sit down with my Twitter-Friend Aaron Hockley and he helps me understand my new Nikon D40. Aaron is turning pro as a photographer, but he's also a programmer, so I figured it'd take a true geek to explain aperture and F-Stop to me. I was right!

Links from the Show

Subscribe: Subscribe to Hanselminutes Subscribe to my Podcast in iTunes

If you have trouble downloading, or your download is slow, do try the torrent with µtorrent or another BitTorrent Downloader.

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.

Check out their UI Suite of controls for ASP.NET. It's very hardcore stuff. One of the things I appreciate about Telerik is their commitment to completeness. For example, they have a page about their Right-to-Left support while some vendors have zero support, or don't bother testing. They also are committed to XHTML compliance and publish their roadmap. It's nice when your controls vendor is very transparent.

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?

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

How do Extension Methods work and why was a new CLR not required?

April 04, 2008 Comment on this post [23] Posted in Learning .NET | Programming
Sponsored By

Someone said recently that they thought extensions methods required a new CLR.

Extension methods are a new feature in .NET 3.5 (C#3/VB9) that let you appear to "spot weld" new methods on to existing classes. If you think that the "string" object needs a new method, you can just add it and call it on instance variables.

Here's an example. Note that the IntHelper35 class below defines a new method for integers called DoubleThenAdd. Now, I can do things like 2.DoubleThenAdd(2). See how the method directly "hangs off" of the integer 2? It's the "this" keyword appearing before the first parameter that makes this magic work. But is it really magic? Did it require a change to the CLR, or just a really smart compiler?

Let's do some experimenting and see if we can figure it out for ourselves.

using System;
namespace Foo
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(2.DoubleThenAdd(3));
Console.WriteLine(IntHelper20.DoubleThenAdd(2, 3));
Console.ReadLine();
}
}

public static class IntHelper20
{
public static int DoubleThenAdd(int myInt, int x)
{
return myInt + (2 * x);
}
}

public static class IntHelper35
{
public static int DoubleThenAdd(this int myInt, int x)
{
return myInt + (2 * x);
}
}
}

I've also added an IntHelper20 class with an identical method but WITHOUT the "this" keyboard. It's a standard static method, and I call it in the standard way. Now, let's compile it, then disassemble it with Reflector and take a look at the IL (Intermediate Language).

.method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
.maxstack 8
L_0000: nop
L_0001: ldc.i4.2
L_0002: ldc.i4.3
L_0003: call int32 ConsoleApplication8.IntHelper35::DoubleThenAdd(int32, int32)
L_0008: call void [mscorlib]System.Console::WriteLine(int32)
L_000d: nop
L_000e: ldc.i4.2
L_000f: ldc.i4.3
L_0010: call int32 ConsoleApplication8.IntHelper20::DoubleThenAdd(int32, int32)
L_0015: call void [mscorlib]System.Console::WriteLine(int32)
L_001a: nop
L_001b: call string [mscorlib]System.Console::ReadLine()
L_0020: pop
L_0021: ret
}

Interestingly, both method calls look the same. They look like static method calls with two integer parameters. From looking at this part of the IL, you can't actually tell which one is an extension method. We know the first one, IntHelper35, is, but from this snippet of IL, we can't tell.

Can Reflector tell the difference if we ask it to decompile to C# or VB (rather than IL)?

private static void Main(string[] args)
{
Console.WriteLine(2.DoubleThenAdd(3));
Console.WriteLine(IntHelper20.DoubleThenAdd(2, 3));
Console.ReadLine();
}

Interestingly, it knows the difference. How? Here's the decompilation of the IntHelper35 class itself:

.method public hidebysig static int32 DoubleThenAdd(int32 myInt, int32 x) cil managed
{
.custom instance void [System.Core]System.Runtime.CompilerServices.ExtensionAttribute::.ctor()
.maxstack 3
.locals init (
[0] int32 CS$1$0000)
L_0000: nop
L_0001: ldarg.0
L_0002: ldc.i4.2
L_0003: ldarg.1
L_0004: mul
L_0005: add
L_0006: stloc.0
L_0007: br.s L_0009
L_0009: ldloc.0
L_000a: ret
}

The only difference between the two methods is the CompilerServices.ExtensionAttribute. This attribute is added because of the "this" keyword, and it looks like it's what Reflector is using to correctly identify the extension method.

Extension methods are a really nice syntactic sugar. They're not really added to the class, as we can see, but the compiler makes it feel like they are.

Slightly Related Aside about Object Oriented "C"

This reminded me of what we called "object oriented C" in college. I found a great example on Phil Bolthole's site.

Basically you make a struct to represent your member variables, and then you create a number of methods where the first parameter is the struct. For example:

#include "FooOBJ.h" 
void diddle(){
FooOBJ fobj;

fobj=newFooOBJ(); /* create a new object of type "FooOBJ" */

/* Perform member functions on FooOBJ.
* If you try these functions on a different type of object,
* you will get a compile-time error
*/
setFooNumber(fobj, 1);
setFooString(fobj, "somestring");
dumpFooState(fobj);

deleteFooOBJ(fobj);
}

int main(){
diddle();
return 0;
}

In this C example, if you mentally move the first parameter to the left side and add a ".", like fobj.dumpFooState() it's almost like C++. Then, you ask yourself, "gosh, wouldn't it be nice if a compiler did this for me?"

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

How to set an IIS Application or AppPool to use ASP.NET 3.5 rather than 2.0

April 01, 2008 Comment on this post [42] Posted in ASP.NET | IIS | LINQ
Sponsored By

A question that comes up a lot is this: How do I tell my IIS Application or Virtual Directory to use ASP.NET 3.5 rather than ASP.NET 2.0?

Folks often go into the IIS6 or IIS7 manager and setup an AppPool and see a properties dialog like this, and when the pull down the option, they often expect to see .NET 3.0 and .NET 3.5 in the list and it's not there, and they freak out, rightfully so.

image

Here's an explanation of why this is confusing, and hopefully by the end, it won't be confusing anymore.

Marketing

This is where marketing and reality part ways. I didn't initially like the naming, because I assumed that each major version of the Framework meant a new CLR, but it's growing on me as I understand it more. I get now why they named them this way. Additional fundamentally new functionality has to be named something.

image

.NET 2.0

The meat of .NET is in %windir%\Microsoft.NET\Framework\v2.0.50727. That's where, along with the GAC (Global Assembly Cache) all the libraries and compilers you know and love live. When folks ask "where is .NET" I usually start here.

image

.NET 3.0

The addition of .NET 3.0 didn't mean new compilers or a new CLR. Instead, it's three major new libraries: WCF (Windows Communication Foundation née Indigo), WPF (Windows Presentation Foundation née Avalon) and Windows Workflow or WF.

image

Bottom line: Installing .NET 3.0 doesn't fundamentally change your system in any way you should fear. Your 2.0 apps still run on a system with 3.0 installed. They are 2.0 apps using the 2.0 compilers and 2.0 CLR.

imageTry this. If you go into Visual Studio and File | New | Project (or Web Site), take note of the drop down in the upper right corner.

Select ".NET Framework 3.0" and make a new "WCF Service" take a look at the web.config. Note that it's pretty conventional, and should look like a typical .NET 2.0 ASP.NET application with a few additional.

Basically, remember Framework version != CLR Version. If you configured an IIS Application to use .NET 2.0, you're talking about the 2.0 CLR. WCF Applications use the .NET 2.0 CLR with the new 3.0 WCF libraries.

  • .NET Framework 1.x = CLR 1.x
  • .NET Framework 2.0 = CLR 2.0
  • .NET Framework 3.0 = CLR 2.0
  • .NET Framework 3.5 = CLR 2.0 + (C# 3.0 | VB9)

You can also use the new 3.5 compilers and the 3.0 libraries, of course as well. Each subsumes the previous as seen in Tim Sneath's fine stacked diagram above.

image

In your new app's web.config, there's a <system.serviceModel> section that is WCF specific, but otherwise the web.config looks pretty 2.0 typical.

.NET 3.5

The marketing term ".NET Framework 3.5" refers to a few things. First, LINQ, which is huge, and includes new language compilers for C# and VB. Second, the REST support added to Windows Communication Foundation, as well as, third, the fact that ASP.NET AJAX is included, rather than a separate download as it was before in ASP.NET 2.0.

There's a few other things in .NET 3.5, like SP1 of .NET 2.0 to fix bugs, but one way to get an idea of what's been added in .NET 3.5 is to look in c:\windows\assembly. Here's just the 3.5 versioned assemblies in the GAC (Global Assembly Cache).

image

Also, looking in %windir%\Microsoft.NET\Framework\v3.5 we can see the new compilers, MSBuild Target files, etc.

image 

So, getting to answering the original question, try this experiment.

Go into Visual Studio and make a .NET 2.0 Web Site. Once it's loaded up, note your web.config. Next, right-click on the project and select Properties. Under Build, select 3.5 Framework.

image

Now, load up your web.config and notice the changes that just occurred. There's some new handlers that are added to support Ajax and some new ASP.NET Features, but the really important stuff is the <system.codedom> and the newly added assemblies in the assemblies section.

    <compilation debug="false">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
warningLevel="4">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
warningLevel="4">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="OptionInfer" value="true"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>

There's the magic. Well, not really magic, and there's nothing hidden. This where your web site is told what version of the compiler to use, and the new supporting libraries.

This is where you tell ASP.NET to use .NET 3.5, not in IIS. IIS AppPools know about CLR versions, not Framework and compiler versions, those are set by the application.

Now, this is just my opinion, but I like to name my AppPools in IIS like this...

image

...which looks the way my brain thinks it is even though it's not reality. I keep my 1.1, 2.0 and 3.5 applications all running under the same instance of IIS, but each in their own AppPool. Note again, the there's nothing keeping me from having 3.5 apps under my 2.0 AppPool, I just keep them tidy on my own.

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

10 Guerilla Airline Travel Tips for the Geek-Minded Person

April 01, 2008 Comment on this post [26] Posted in Musings
Sponsored By

Photo by Joshua DavisThere's a million sites with a million travel tips, so I won't even try to imply that I know what the Rick Steves of the world have worked so hard to figure out.

However, I do fly around a lot and I have for many years. I'm a geek, I like tools and I solve problems in my own niche way. It's not the way others might do it, but it seems to be working pretty well.

I just narrowly avoided a REALLY bad situation in Chicago (ORD) a few minutes ago where six flights to New York's LGA airport had cascading delays. My 3pm flight was now at 6pm which would have had me arriving into New York at 9pm! Considering I have a 9am talk, that could be disastrous. Here's how I saved my butt.

#1 Take Action at the first sign of trouble

Always have the # of the airline (or their preferred line). Nothing wastes time like digging for stuff. Use a service like tripit.com to keep all your travel details in one place. For example, today I called United from my phone the second I saw the delay appear on the board.  I also go in line at Customer Service, but I had a person on the phone well before the line moved.

#2 Know the schedule

Don't just know the schedule for your airline, or for your flight. Know and print out ALL the flights going to your destination the day you're traveling. This provides you power as you'll know what parallel flights are leaving before the other travelers, even before the flight personnel. I use http://mobile.flightstats.com/go/Mobile from my phone to stay on top of flights while on the go.

Knowing other airlines' schedule is useful because when mechanical difficulty cancels a flight you can insist that Airline #1 move you to Airline #2 if it's totally clear that there's no other way to get you to your destination on #1. Last flight I was on United had a mechanical difficulty and completely canceled my flight. The whole plane got in line to get on the next flights out, but this was the last flight of the day out of that city for that airline. I knew there was a Delta flight in an hour, so I took off for the Delta desk while calling United at the same time. I told them what flight I was on and that I wanted to be moved to Delta. I was kind, but firm, and only 1 hour late coming home. As I was boarding the Delta flight, I saw that United was passing out hotel vouchers for the folks on the first flight.

#3 Make their job easy

Speak their language and tell them what they can do to get you out of their hair. Refer to flights by number when calling reservations, it saves huge amounts of time. For example, today I called United and I said:

"Hi, I'm on delayed United 686 to LGA from Chicago. Can you get me on standby on United 680?"

Simple and sweet. I noted that UA680 was the FIRST of the 6 flights delayed and the next one to leave. I made a simple, clear request that was easy to grant. I told them where I was, what happened, and what I needed all in one breath. You want to ask questions where the easiest answer is "sure!"

#4 Never give up a guaranteed seat for a chance at a seat.

That said, always get on cascading standby. Make sure to ask them if your reservation will move from flight to flight if you don't get on standby. You'd be surprised how many reservations go missing or float around in the system. Always make sure you have your ACTUAL guaranteed ticketed seat for some flight later in the day in case the earlier standby's don't work out.

#5 Never check luggage

I did two weeks in Malaysia once with only carry on. Seriously, checking your bags not only slows you down physically but it also limits your options. When you talk to Customer Services, the FIRST thing they'll ask is "did you check bags." Your bags can't move as fast as you can.

#6 Be absolutely pleasant at every point

I can't stress this enough. Never raise your voice or demand anything. Be nice to people. Nothing you need to go (unless it's a child's health) to is important enough have a complete freak-out in public at the Airport. I've seen personally a half dozen different incidents where Airport Police have taken people away and charged them for disorderly conduct. More importantly, very rarely will you be talking to the person who screwed up your travel. They are just doing their job.

Try to be inclusive, using terms like "we," like "what can we do to fix this?" If the person seems to have a power trip, try using "you" sentences that inflate their sense of power. "Can you help me make this right?"

Today I said to an agent, "If you get me on this flight, you'll only need 2 more miracles for sainthood!" This got me an immediate smile and a pleasant transaction.

#7 Keep ahead of the wave

When disaster strikes, you have 15 minutes before the masses figure it out. Folks will queue at the drop of a hat, but savvy travelers will leap into action and start a multi-pronged approach. Call your assistant, spouse,  boss, travel agent, get on the phone, go to the departure boards. Always have at least two options. Even try going to the next gate, preferably a near-empty one with an agent behind it. Anyone at any terminal can usually fix your issue while the rest wait in a queue.

#8 Setup SMS Alerts on your airline

The best way to know what's happening before the public is via SMS Alerts. Corporate will often send gate changes before they are announced on the flight. This can save you time while trying to find the monitors upon leaving the plane. You can also setup notifications for delays. More information is better.

#9 Always wear a jacket or sport coat.

Don't look like a schlub. Have a nice pair of shoes. Shave. Well-dressed, kind, professional people get upgrades. I started wearing nice Cole Haan shoes and a sport coat when I travel and I've been consistently upgraded about 1/5th of the time. I'm convinced being fresh and clean and pleasant is the reason.

#10 Use your miles for upgrades

I don't have status on any airline, just a bunch of miles all over. Never enough for a free flight, so I never even try to use my miles for free flights . I always use them for upgrades and I offer to use them at the point where I'm talking to a customer service representative. Often, if you are pleasant beforehand, they'll just upgrade you without deducting the miles. Worst case, you get upgraded and use your miles. Best case, you're just upgraded.

Eek, they've called my boarding group, so I'm off! Bye!

Technorati Tags: ,,

Photo by Joshua Davis

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 bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

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