"Please Prepay"

Yesterday’s post about The Speed of Trust hit me in a new way this morning when I was filling up with gas. The sign on the pump said, “Please Prepay.” Wow, does that slow things down, doesn’t it? Instead of simply filling up and walking in to pay, I have to walk in, walk out, fill up, and walk in again. That also has to create extra overhead for the workers if I overpay the first time in: they have to keep track of how much I gave them and then look it up when I come in for change. If I underpay then I suppose I don’t get a full gas tank and either have to fill up more often or go through further rigmarole to top off.

Yet one more way that the world is slowed down because of the number of people who aren’t trustworthy.

Posted in Business, Leadership | Leave a comment

The Speed of Trust: Chapter 1

I’m slowly picking my way through Stephen Covey’s book, The Speed of Trust. In chapter one Stephen makes a compelling argument that trust makes a very real difference in the amount of time and money required to get work done.

Corporate Application

Consider the example of Warren Buffet when acquiring McLane Distribution from Wal-Mart. Such a merger typically takes months, with several million dollars for accountants, auditors, and attorneys. The two parties in the case trusted one another; the deal was made with a two-hour meeting, and completed in less than a month. I find Warren Buffett’s words from his 2004 annual report to be very powerful: “We did no ‘due diligence.’ We knew everything would be exact as Wal-Mart said it would be – and it was.”

On the other hand, the incredible cost large companies face of implementing the Sarbanes-Oxley can be attributed to the distrust created by Enron and WorldCom.

Individual Application

The speed of trust is not just for the corporate world. The book suggests that the “office politics” that people hate are usually extra overhead created because people distrust one another.

When describing what trust is, as Covey sees it, he writes that trust is confidence; it’s the opposite of suspicion. When you trust someone, you have confidence in their integrity and abilities. When you distrust someone, you are suspicious of their integrity, agenda, capabilities or their track record. Working with someone you trust is often joyful and efficient; working with someone you distrust is draining, tedious and cumbersome.

My own example: consider even simply going on a camping and fishing trip with someone you have confidence in: you believe they are trustworthy to bring ample supplies; you have confidence in their abilities to be able to help efficiently with all the little duties needed to have a fun and successful trip. How much less would you enjoy a trip like that with someone who you didn’t have confidence in?

“Doug”

I thought it was a surprising coincidence that after reading this chapter I heard a couple more stories in a different context that related to this.

I heard second-hand the story of a successful businessman in the Fargo area. His family has owned a grain elevator for years in the past. When a farmer brings his grain in, an elevator worker scoops a handful of grain out to sample it for chaff and moisture content; the value of the grain depends on the sample. Elevator owners know that the shape they hold their hand in as they scoop up the grain makes a difference in the amount of chaff picked up. There’s a big temptation for owners to pick up as much chaff as they can, and thereby pay less for the grain. When this man’s father taught him to do it, he said, “You hold your hand like this, to get the best possible price for the farmer. The reason, Doug, is that our customers must trust us.”

Later in this man’s life, when his software business was growing but still struggling, this life-lesson of trust was tested. The company had shipped out software with a major bug. The timing couldn’t have been worse: the nation-wide (world-wide?) convention was imminent.

Of course the buzz of the convention was angry customers complaining about the issue. Doug took a huge risk, putting the company on the line. During a talk of the convention he said, “We messed up. We’re working hard to fix it. We know this is costing you money. I can’t make any promises, but send us a bill for the expense we’ve cost you.” This was very risky because the company at this time wasn’t flush with cash. But suddenly so much of the trust (confidence) that had been lost in this company was turned around. The tone of conversations at the convention changed dramatically.

Here’s where the speed of trust hits hard: Out of the hundreds of customers that were invited to send bills, only two did. I suppose this indicates that the customers weren’t as concerned about the money loss as they were the lack of confidence they had in the company, and when Doug acknowledged the mix-up and was willing to go to such lengths to make it right, the trust and confidence was restored.

Looking forward to the rest of the book

Covey talks about how earning and keeping trust sometimes has to be a deliberate effort; you don’t get it by default. People with whom you don’t often interact, by default will doubt you. Covey talks about proactively establishing and increasing trust. I’m excited to learn what he has to say about doing that; hopefully the techniques aren’t ways to fake trustworthiness, but simply ways to express whether you are trustworthy or not. I’m excited about how the ideas in this book might improve relationships in every area of my life.

Link to The Speed of Trust on Amazon.

Posted in Business, Leadership | 2 Comments

Force a SQL Restore

Really tired of having to google this and piece it together every time I want it, so I’m posting it here.

alter database DbName
    set single_user
    with rollback immediate
go

restore database DbName
    from disk = 'path/to/backup.bak'
    with file = 1, replace

Notables:

  • Works best to run against the master database.
  • The file = 1 part may need to be changed if there are multiple backups in the file and the one you want isn’t the first one.
Posted in CodeMinder, SQL | Leave a comment

User Experience: Find the Send Button

I typically use Gmail; I do have a Hotmail account and needed to use that for something the other day. I typed up my new message, and had to hunt for the Send button. It took about 5-10 seconds.

image

I found the obscurity of the Send button annoying. “There’s got to be a better way to do that,” thought I. Pull up Gmail – no problem finding it. A much smarter UX design. A breath of fresh air, even.

image

Microsoft seems to really struggle with getting good UX, and it kills me. It’s like being a Minnesota Vikings fan – I really want them to do well, but even when they’ve got something good going, and put together a really awesome thing, they always seem to snatch defeat from the jaws of victory. My wife doesn’t use a Windows Phone because of some very specific UX decisions Microsoft made poorly (see “aside” below). I suspect the reason Microsoft can’t get UX right has to do with this image being a little too true: http://www.bonkersworld.net/organizational-charts/

A culture of militant fragmentation manifests itself in their products; their UI’s come out fragmented rather than cohesive. It’s hard to sort out political power plays from earnest pursuit of excellence, so stuff that really should get done gets blocked. And it’s been going on for a loooong time (eg, how far buried ClearType was in Windows XP).

I know there are folks within Microsoft trying to change this. Here’s wishing for the best to them and to the Vikings.

Aside: the Windows Phone UX disaster was that to save a phone number on a new contact, you had to first click “Ok” for the phone number, then click “Save” on the contact. The second step shouldn’t have ever been there. Steve Jobs would have found it before the phone ever released, fired the person who put it in there, and it never would have seen the light of day. Thankfully Microsoft fixed this UX travesty in Mango, but they created an Apple fan in my wife – she returned her Windows Phone and loves her iPhone now.

Posted in General PC Usage, UX | 3 Comments

NDesk.Options

Parsing command-line arguments can be deceptively tricky. Often it starts as something very simple to do manually, but as more arguments and formats and flexibility are desired, the effort required to do it well can explode.

So there are several nuget packages for libraries to help with this. I chose NDesk.Options and I liked it. Here’s what your command-line argument code might look if you used this library.

public class MyProgramSettings {

    public string InputFile { get; set; }
    public string ErrorFile { get; set; }
    public string OutputFile { get; set; }
    public bool ShowStackTrace { get; set; }

}

public static Main(string[] args) {
    var settings = new MyProgramSettings();
    var showHelp = false;

    var parser = new NDesk.Options.OptionSet() {
        { "h|?|help",  "Show available options",       v => showHelp = true },
        { "i=|input",  "The name of the input file.",  v => settings.InputFile = v },
        { "e=|error",  "The name file to log errors.", v => settings.ErrorFile = v },
        { "o=|output", "The name of the output file.", v => settings.OutputFile = v },
        { "s|stack ",  "Show stack traces.",           v => settings.ShowStackTrace = true }
    };

    parser.Parse(args);
    if(showHelp) {
        parser.WriteOptionDescriptions(Console.Out);
    }
}
Posted in Programming | Leave a comment

Write MSMQ Messages from PowerShell

This PowerShell script sends a message to an MSMQ. I did it this particular way because NServiceBus can consume messages sent like this.

[Reflection.Assembly]::LoadWithPartialName("System.Messaging");

$queueName = '.\Private$\your.queue.name';
$queue = new-object System.Messaging.MessageQueue $queueName;
$utf8 = new-object System.Text.UTF8Encoding;

$tran = new-object System.Messaging.MessageQueueTransaction;
$tran.Begin();

$msgContent = '<?xml version="1.0" ?>
    <Messages xmlns="your-xml-namespace">
        <IWebApplicationStartupCompleting>
        </IWebApplicationStartupCompleting>
    </Messages>';
$msgBytes = $utf8.GetBytes($msgContent);

$msgStream = new-object System.IO.MemoryStream;
$msgStream.Write($msgBytes, 0, $msgBytes.Length);

$msg = new-object System.Messaging.Message;
$msg.BodyStream = $msgStream;
$queue.Send($msg, $tran);

$tran.Commit();
Posted in CodeMinder, MSMQ, PowerShell, Programming | 1 Comment

Read MSMQ Messages from PowerShell

This script dumps the contents of an MSMQ to the console. This one dumps the Journal contents of a private queue; of course you’ll have to adjust that line for your queue.

[Reflection.Assembly]::LoadWithPartialName("System.Messaging")

$queueName = '.\Private$\your.queue.name\Journal$';
$queue = new-object System.Messaging.MessageQueue $queueName;
$utf8 = new-object System.Text.UTF8Encoding;

$msgs = $queue.GetAllMessages();
$msgs | %{
    write-host $_.Id;
    write-host $utf8.GetString($_.BodyStream.ToArray());
};

 

Posted in CodeMinder, MSMQ, PowerShell, Programming | Leave a comment

JavaScript: this and that.

This is a brief description of a technique recommend by Douglas Crockford, probably in Act III of his JavaScript video series.

Code that looks right, but is wrong:

clip_image002

There are a few workarounds; the one Douglas Crockford recommends is to create a new variable (conventionally named “that”) referenced by the inner function.

clip_image004

The “that” convention is fitting because you’re saying, “It’s not the close-by this, it’s that ‘this’ from over there.” Kinda cute.

Incidentally, CoffeeScript has a construct to compensate for the confusing (although very logical) behavior of this in JavaScript. I like CoffeeScript; been playing with it in a side project and hope to use it for a Javascript-heavy green-field project soon.

Bottom Line: with JavaScript, when you have a function defined inside of another function, “this” in the inner function might not be what you expect.

Posted in JavaScript, Programming | Leave a comment

DuckDuckGo FTW

On a trial basis I’ve been using DuckDuckGo instead of Google for searches. You can even set Chrome up to use DuckDuckGo for queries typed into its “omnibar.” Today DuckDuckGo earned this blog post from me.

I wanted to know how to get the list of parameters for a stored procedure programmatically. I typed in my search terms and here’s ddg’s response. What blew me away was that it pulled the exact answer to my question from stack overflow and put it at the top of the result list:

image

Cool. I could say it saved me a bunch of time, but it prompted me to write this blog post, so that’s not true this time.  :)

Posted in General PC Usage | Leave a comment

Don’t use BR for vertical spacing

clip_image002

Use CSS instead. When <br> is used for vertical spacing it drives me crazy. Among my coworkers it is widely known that I don’t approve of <br> abuse. One recently wrote in a source control commit comment, “Removed some nasty <br> tags to keep Jason from going postal on someone.” And I appreciated that.

Why use CSS instead of <br> tags?

  1. It’s a stylistic concern, not a content concern, and so it belongs in the CSS with all the other stylistic concerns.
  2. It’s easier to adjust and fine tune the vertical space in a CSS my adjusting the margins or paddings in em’s instead of full lines.
  3. This one’s a little subtle, but very clear when you run into it: In the case of conditional content, where you may not know exactly what comes before or after the block you’re working on, the fact that CSS margins overlap turns out to be The Right Thing.

In summary:

clip_image002[5]

(This was an example of #3. Everything looked fine as long as both the MultiView and the Panel were visible, but when one of them was not visible [due to security or whatever] then the vertical spacing was a visual train wreck.)

Posted in HTML, Programming | Leave a comment