Sunday, April 01, 2007

I was chatting with my pal Kelly at work last week about code snippets. This weekend, I had a pile of dirty dishes to clean, so I fired up my laptop and downloaded the archived DotNetRocks interview with Michael Palermo on code snippets. Before I knew it, the dishes were clean and I had refresher on code snippets!

I took a look at Palermo's site, www.gotcodesnippets.com. I was looking for some snippets I'd could install. I downloaded one that creates a property whose value is stored in the ASP.Net viewstate. I do that technique quite a bit, so it'll be fun to hit ctrl+k+x to run that snippet.

Next, I was interested in writing one by myself, just to see what it was like. I had downloaded the ternary code snippet, but I wasn't to warm and fuzzy about it. The snippet ought to have given me the opportunity to type in the variables using the special code snippet mode before reverting back to standard mode in Visual Studio. So, I grabbed their code, made a few changes and now creates a line of code with a ternary operator in it - just how I like. Here' the snippet that I dropped into my snippet folder.

Folder: \My Documents\Visual Studio 2005\Code Snippets\Visual C#\My Code Snippets

ternary.snippet XML File:

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
   <CodeSnippet Format="1.0.0">
      <Header>
         <Title>Ternary</Title>
         <Shortcut>ter</Shortcut>
         <Description>Custom code snippet for ternary operator</Description>
         <Author>andrewdothay</Author>
         <SnippetTypes>
            <SnippetType>Expansion</SnippetType>
         </SnippetTypes>
      </Header>
      <Snippet>
         <Declarations>
             <Literal>
                 <ID>result</ID>
                 <ToolTip>Replace with the field or property that will recieve the value</ToolTip>
                 <Default>result</Default>
             </Literal>
             <Literal>
                 <ID>expression</ID>
                 <ToolTip>Replace with the expression to compare</ToolTip>
                 <Default>expression</Default>
             </Literal>
             <Literal>
                 <ID>trueValue</ID>
                 <ToolTip>Replace with the value if the expression is true</ToolTip>
                 <Default>trueValue</Default>
             </Literal>
             <Literal>
                 <ID>falseValue</ID>
                 <ToolTip>Replace with the value if the expression is false</ToolTip>
                 <Default>falseValue</Default>
             </Literal>
         </Declarations>
         <Code Language="csharp">
            <![CDATA[ $result$ = ( $expression$ ) ? $trueValue$ : $falseValue$;$end$]]>
         </Code>
      </Snippet>
   </CodeSnippet>
</CodeSnippets>

This snippet uses four variables. The <Code> element contains placeholders for the line that will be emitted by the code snippet. The "$" symbol surrounds the variable so its easily identifiable by the snippet engine. When Visual Studio is in the special mode, I can tab between the variable fields to enter the value, then hit tab+tab to switch back to normal view after I've entered in the customizations. Sweet!

>>>>>>>>>>>>>>>>

I just found this four minute screencast on Channel 9 too! She does an excellent job of showing one up close.

Sunday, April 01, 2007 3:51:09 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 

I recently became aware of the "??" operator in C#. I guess it doesn't have a real name like the ternary operator that I've long been a fan of using. I'll call it the WTF operator until I learn a better (more popular) name. Let's take a look at the "What The #$@#%@#" operator in action:

public int PageTabId
{
   get { return Convert.ToInt32(Request.QueryString["PageTabId"] ?? "-1"); }
}

Per the MSDN reference, the WTF operator inspects the value on the left side of the "??". If it's null, the value on the right is returned. If its not null, the value on the left is returned. Its a lot like IsNull in T-SQL. The code example above is just a simple helper property for an ASP.Net page. The property looks for a querystring value. If its there, the value is cast as an integer and returned to the caller. If its not in the querystring, the default integer value of -1 is returned.

I've been using the ternary operator for a while. Here's the same property as above, but uses the ternary operator instead. Its more verbose than WTF, but still one line of code.

public int PageTabId
{
   get 
   { 
      return Request.QueryString["PageTabId"] != null 
         ? Convert.ToInt32( Request.QueryString["PageTabId"] ) : -1; 
   }
}

I love writing WTF all over my code!

Sunday, April 01, 2007 3:29:02 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 

The wife coaches the Knowledge Bowl team at her highschool. She really digs the higher level stuff and enjoys teaching AP math and stats classes. She comes home just completely wiped out some days but I never seen her happier than when she's teaching. She worked at a couple of internet start ups back in the day (in Chicago), has a Masters degree, a whiz at Excel functions, punches you in the belly with SQL queries and knocks your block off with scripting. She never really dug it though (except for the cash). She started teaching a few years ago and never looked back. I'm really proud of her for finding a job she loves.

Last week, her Knowledge Bowl team won the 4A Washington state title!!! She swears she had nothing to do with it, and the kids are just fabulous. I can't tell you how many times my wife has dragged me to bars for trivia night. We used to be regulars at Beulahland for trivia night. Now she has a state title to defend next year. Go wife!!

events | fun
Sunday, April 01, 2007 3:02:09 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [1]  | 

I watched episodes #1 and #2 of the Developer, Meet Server series on Channel 9. Jason Olson is a phenomenal presenter. There are so many switches to flip in the Vista, Longhorn and WCF stack that it can make your head spin. Jason explains the technology really well so the act of shoving more knowledge in my head is less painless.

The first episode explained how Vista can take advantage of Transactional NTFS (TxF). The concept is really simple but the operating system has to make some incredible leaps to provide this feature. TxF provides full ACID support for writing files to disk. Jason mentions this scenario that benefits from TxF support in the video:

You write a large file to disk and write meta data of the file to SQL Server. This TxF technology can increase your confidence that the database and the document are always in sync.

We've database transactions for a while - seems odd that its taking so long to do this at a file level... easy for me to say I suppose. In the video it sounded like Jason and some pals wrote a managed wrapper that does deep dive into unmanaged code for us. He said that perhaps later on it'll be more tightly integrated into the platform if the community likes it.

The second episode elaborates on TxF by using WCF. A smart client app makes a transactional WCF call to the server. The server uses the TxF service to create a file on the server's hard drive. Later, the client issues a commit and the file is visible to Windows Explorer, you and me.

I wonder what happens to files that never get committed - ala a long running transaction. They have to be taking up file space. Jason says not even Windows Explorer knows about them, but they have to exist somewhere. What if they overflow? Is there a way to clean house? If the poop is invisible, does it still stink?

Sunday, April 01, 2007 2:27:05 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [1]  | 
 Monday, March 05, 2007

I was lucky to learn SQL early in my career. It was in a DB2 environment; in order to call the database, my assembly language program called out to a COBOL program to make the actual database query. Whoo-yah!! 

I transferred my skills to SQL 6.5, SQL 7 and SQL 2000 along the way and gotten pretty good at using the technology; I can hold my own with most database challenges. I've been a little pokey about learning the new features in SQL 2005 - the "use it until you run into a problem" worked well enough for the lightweight stuff I've been working on so far. I've set my sights on bringing my skills up to par with my understanding of the previous products. Geesh! I don't have a SQL Server category on my blog yet; I guess that sums up the past few years.

Today, I'm using a database with *many* stored procedures in it. I only want to view/peek inside my own. So, there's this great feature in SQL Server Management Studio to apply a filter. Once its set, only the stored prcedures matching the given criteria are visible. Right click on the Stored Procedures folder and select the "Filter" item in the context menu. Then, set your filter choices. It rocks!

Monday, March 05, 2007 10:28:20 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Thursday, February 15, 2007

I attended the Software Association of Oregon (SAO) event today. The Development Special Interest Group (DEV SIG) hosted a discussion about Microsoft CardSpace, the open source framework of OpenID, and basic identity management.

Stuart Celarier walked the audience through Kim Cameron's paper called The Laws of Identity that articulate seven desired aspects of a good identity system.

Microsoft CardSpace was formerly named "InfoCard". This is a joint effort to implement the identity metasystem defined by the laws of identity. CardSpace is the "identity selector" for Windows. It needs IE7 and Microsoft .Net Framework 3.0 to operate. It implements the WS-* specifications in this service.

OSIS - Open Source Identity System: This is an open source group that's involved in the identity space.

Stuart also showed a demo of a system he's been working on. It logs a user into Wachovia banking site using CardSpace.  Scott Kveton of JANRAIN presented OpenID to the SAO DEV SIG group. OpenID hopes to solve the problem of having too many usernames and passwords.

  • Single Signon for the web
  • Simple, light-weight
  • Easy to use, easy to deploy
  • Open development process
  • Decentralized

Your OpenID is a URL: http://kveton.myopenid.com/

  • OpenID comes from the blogosphere
  • Biggest problem with identity; namespace
  • OpenID solves this by using DNS
  • Your identity is a destination
  • You have a unique endpoint on the web

Scott Kveton explained how sites enabled with OpenID enable users to authenticate. Visitors type in their OpenID, and the browser redirects to your OpenID provider. The visitor makes the appropriate decision and the browser redirects back the website.

Scott's site is http://scott.kveton.com

Last week Bill Gates announced support for OpenID. AOL announced support for OpenID this morning. More companies are about to make similar announcments. Here's some interesting stats on adoption:

  • 12-15 million users with OpenIDs.
  • 1000+ OpenID enabled sites
  • 10-15 new OpenID enabled sites each day
  • 7% grown each week with new sites

Kveton also brought up "Microformats" - a way to describe data in an HTML format (contact info, social network, calendar). These can be embedded on pages. There are some interesting ways to use OpenID with these technologies:

  • OpenID + iCal
  • OpenID + hCards
  • OpenID + Social Networking (XFN, FOAP or FOAF?)
  • OpenId + Reputation (jyte.com)

OpenID Predictions from Kveton:

  • 7500 sites supporting OpenID
  • 100 million users with OpenID
  • Big players adopt OpenID

OpenID.net has a ton of info.

Scott Hanselman explained how he enabled OpenID on his blog. Hte added two HTML <link> tags to his website. Simon Willison has an OpenID enabled blog. A visitor can click Sign in with OpenID. The OpenID logo lives inside the textbox. Scott entered his OpenID in the textbox on Simon's site. Using a web service, Simon's blog discovered Hanselman's OpenID provider, then it redirected the browser to Scott's OpenID provider.

Scott's website indicates the OpenID provider is www.myopenid.com

The OpenID provider prompts Scott to authenticate. After a successful login, the browser redirects back to Simon's page and recogizes Scott Hanselman. This is how Simon doesn't need to keep track of usernames and passwords for his blog; a huge benefit.

Stuart helped explain the difference between self-insued cards and managed cards: Business Cards from Kinko's versus a card issued from Visa.

Scott Hanselman displayed a different identity selector using Firefox on Windows. The page contains an HTML <object> tag of type "application/x-informationCard". It wasn't as pretty as the CardSpace in IE7 and .Net 3.0, but it had the same behavior.

There was some last minute discusson on "I-Name", an XRI technology (extensible resource identifier). It sounds like its still being baked.

2idi relays comments on Scott's blog. They will issue an I-Name. =kveton is Scott's I-Name. They have an DNS resolver where visitors may enter xri://=scott.hanselman/photo to redirect to his Flickr account.

Thursday, February 15, 2007 4:47:54 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Monday, February 12, 2007

I had listened to all of my normal podcasts last week and over the weekend. So, on the bus ride to work this morning, I downloaded and listened to a couple of random podcasts on my Treo.

Tech Nation Daily had an interesting two minute interview:

Dr. Moira Gunn talks to Beverly Davis, Professor in the School of Technology at Purdue University about Technoism, the need for technological emersion centers.

The interview revealed an interesting statistic: a distribution of households in the United States with Internet access at home:

  • White Households: 46.1%
  • Hispanic Households: 23.6%
  • Black Households: 23.5%

There's an awful lot of potential still out there along with a number of challenges. I wonder what these numbers will be like when I'm 80.

Monday, February 12, 2007 6:59:18 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Sunday, February 04, 2007

Tasty! Sometimes you do something so delicious that you just have to link to it from your other blog.

fun
Sunday, February 04, 2007 8:55:11 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Monday, January 15, 2007

This link went around the office a few days ago about the rendering engine used to display HTML email messages in Outlook 2007. Evidently, the folks from Campaign Monitor are not impressed.

The issue is that Outlook 2007 uses Word to render the HTML email messages instead of Internet Explorer. This leads to some limitations on the HTML and CSS that authors can use in their message.

Zeyad Rajabi and Erika Ehrili wrote this document to help folks understand the rendering capabilities of the Outlook 2007 email client. Its well done and easy to understand.

It looks like a fair number of people are in a tizzy over this. If you make a large percentage of your revenue by designing complex email templates for your marketing clients, you're probably interested in how the email renders in the reader's email client program. Just thinking about the number of email client programs is startling. That's a lot of testing to do before you send out your mass e-mail message. Plus, you have to comply with the federal anti-spam laws. I suppose the marketing folks deserve a little bit of a hassle for all of their networking events and schmooze fests... :-)

I like a pretty e-mail as much as the next person, provided that its relevant to my interests. I don't like the crippling affects that I see when one is forwarded to me by the original recipient. It seems to me that the message needs to be short, with a clear call to action, and trackable. I'm fine with a details link to a web page.

These are some of the choice excerpts from the comments on the Campaign Monitor page:


jaw - floor.... Where is the frick'n sense in this? Is it 'cuz they didn't employ people who can understand CSS?? WTF??!!


Hey there... I guess this is attrubuted to Vista's. IE has been split from the windows shell thus meaning that if IE is not installed on the computer Internet Explorer cannot render the HTML. See when you are in XP if you type in a url in Explorer it will go to the page "inplace" however if you open up Vista and try to put in the URL windows will open up your default browser to open the page. :)


I like it. I've gotten emails from clients using the background images just b/c they look "pretty" and it ends up destroying the message formatting when I try to reply. Also, it's less junk taking up bandwidth. If you need graphical pretty things sent to specific people, find another way.


Hate to be a spoiler, but I long for the days when my email didn't look like a webpage.

Email should be fast and efficient.

Graphical email is not.


I'm no fan of using the Word rendering engine, but the real problem lies in the overuse of HTML mail. Anyone who doesn't use Outlook already has problems similar to the ones this switch will cause, and there are only two ways to ensure perfect rendering; Use plain text for emails, and use PDFs for pizazz.


I'm almost positive it has to do with the whole Anti-Trust issue. The answer that would make the most sense to me would be the word rendering engine is part of Office. IE is not and therefore instigate the issue that people are being forced to upgrade and use IE versus alternatives. I think its a step in the right direction but i believe that it has hindered the users experiance because of it. Only time will tell if they stick to their guns and give some resolution on it.


I think this is a great move. I'm sick and tired of html email and hopefully this will reduce the number of people that think its cool to put html, background images, and all that other crap in an email.


Currently using Vista and Office 2007 and I do not see these problems problems. I even make HTML based newsletters an I have do do not changes to the way i create them. It looks like FUD to me.


stop crying... BUY A MAC!!!


Hey, maybe now we can get email back to what it's supposed to be. Text-based. HTML email has always been problematic and you've never been really sure about what the other person would see depending on their email client.


Let's talk a little bit about spamminess, and why HTML might not be the way to go in email.

We run SpamAssassin, a requirement when each email account averages 150+ spam messages per day.

HTML is already suspicious and gets -10 -- -40 if HTML only. Since -50 is quarantine, your beautifully crafted HTML only message is precariously close to deletion already.


Monday, January 15, 2007 12:23:33 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Sunday, January 14, 2007

I had a need for a client services teammate to get their hands dirty with some XML. In this project, an XML file defines the hierarchy of pages in a web site. With a massive redesign under way, the team needed someone with familiarity of the existing pages to make the changes. With the hopes of giving my non-developer teammate a slick application to help them rearrange some angle brackets, I took a look at Xml Notepad 2007 and WCMHelp's XmlPad.

Xml Notepad 2007

The bits can be downloaded here and this document a nice explanation of the author's intent.

Xml Notepad 2007

The left window shows the tree. The red dots are attributes and the folder icons are elements. The right window shows the values of the attributes. There's an XSL tab for viewing transformations. You can point the application at an XSLT file and see the output too.

The part I like the best about this is application is its simplicity. I need my teammate to look at each node and make a determination. They might need to move it anywhere in the hierarchy. There are four buttons on the right side of the toolbar expressly for this purpose. If they feel a little more ambitious, they can click and drag the node to the new location in the left window.

WMHelp XMLPad 3

You can get the bits here. This application feels a little more powerful than the first application. It can create schemas and validate against them in a more flexible manner than XML Notepad.

WMHelp XMLPad

The attribute names and values appear in the lower left window of this application. There are different views of the XML available too. The picture above shows the source view. There are three other views (Grid, Table and Preview) in the bottom of the right window.

This application doesn't show the simple set of buttons in the toolbar for moving nodes, although they can be dragged around in the tree. I find that dragging can be a little unpredictable with a large node set. With all the on-the-spot decision making going on, I felt that the simple XML Notepad program was better suited for the specific task and user. However, if I'm the one doing XML work, I would probably choose XMLPad if VS.Net 2005 didn't do the trick for some reason.

At some point, I'd like to checkout XMLSpy. I've heard great things about it for years. I chose to examine these two because they were free and this was a one time gig. If I end up doing lots of work with my angle bracket hammer, then I probably will put in a request for the XMLSpy license.

Sunday, January 14, 2007 8:47:19 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [1]  | 
 Tuesday, January 02, 2007

Thanks Jim! Here I am wasting time on my first day back at work after the holiday break, and apparently, you are too. Here are 5 things you don't know about me.

  1. I played varsity basketball my freshman year in highschool, much to the delight of the upperclassmen, and I was the MVP my senior year.
  2. As a future software developer, I earned my obligatory black belt during college by training in Ryukyu Kempo karate with Bill Burch, good friends with George Dillman. I met some of the best friends I ever had.
  3. At my first 4-H show, I received a red ribbon for my two chickens. I think I was eight.
  4. I visited the Blue Hole in Belize with the charming woman I would later marry. We met about 50 sharks, between 6 to 10 feet in length, as they came out of the deep blue center to greet us at a depth of 140ft along the rim. She squeezed my hand very tightly and I knew it was love from then on.
  5. During the glorious late '90s I bought a red 1994 Corvette when I had absolutely no business doing so. My wife says she dated me in spite of that car. Boy, that car was sweet.

Here are my five victims of this game: Kelly, ScottHappy SteveLee, and Dave.

Tuesday, January 02, 2007 10:37:16 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Sunday, December 31, 2006

I just made my first trip to Costco Wholesale Corporation yesterday with The Wife. She's been going with her lady friends for quite a while and I've managed to dodge the bullet up until yesterday.

It was an enjoyable outing and my buddy Marc turned me on to the deal for a hotdog or polish sausage and a soda pop for $1.50 after making your purchases. Quite a deal! They even have these little boxes with a crank on one side. You hold your dog on the other side, turn the crank and either onions or relish come out the other side! Brilliant!!

So, I was meandering down an isle of wholesale goods with other shoppers when I laid eyes on the Rogaine.

Now, I've always said that when it comes time, I'll give it the ol' buzz cut instead of the comb-over, swirl over, or other means of denial. But this was Costco Wholesale Corporation and it was cheap! Like $10.00 cheap! Why pass up an opportunity for imortality?!?!

So on a lark, I was about to chuck a box in the cart until The Wife reads the side of the package and says "This isn't for you, dear." Turns out this Rogaine is for balding around the crown of your noggin' and not for the exceedingly high forehead, like mine. Alas, it'll be the clippers for me before too long. I wonder if I'd make a good Mr. Clean head like Doug Purdy or King Kong Bundy? It's not too smooth, but I do have a lot of "character" bumps.

Sunday, December 31, 2006 3:36:16 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  |