Scott Cate's WebLog

You just don't know what
you don't know.

community

frenz

my book(s)

my products

Sys.StringBuilder.appendFormat(mask, args[])

image I'm speaking this week at TechEd New Zealand, and TechEd Australia.

As part of my talk, I show how Microsoft AJAX offers object oriented LIKE behavior. There are a ton of examples that I have build over the years on this subject, and the entire project is hosted on CodePlex.com/ScottCateAjax

SideLine: This demo is included in the CodePlex sample as Demo 6F and 6G

It's always funny how the most popular part of a session can not be predicted.

After hours and hours (days and months) of code that I've written and show, the most popular feedback that I've received on my talk was showing Sys.StringBuilder and prototyping it with an appendFormat method.

So it's worthy of a blog post.

Sys.StringBuilder.prototype.appendFormat = Sys$StringBuilder$appendFormat;

function Sys$StringBuilder$appendFormat(mask) {
    this.append(String.format.apply(null, arguments));
}

Now you can write code like ....

function BuildResults() {
    var sb = new Sys.StringBuilder();
    var mask = "Line number {0}<br />";
    for (var i = 0; i < 10; i++) {
        sb.appendFormat(mask, i);
    }

    var results = sb.toString();
}

.... and use StringBuilder.appendFormat()

What's interesting about this code, is the apply method called on  ....

    this.append(String.format.apply(null, arguments));

.... which pushes all the arguments passed into the appendFormat method, on to the String.format call.

Without the use of apply, you're forced to call the method with a hard coded set of parameters. Because the parameters are optional in JavaScript you might be tempted to use the following code ....

function Sys$StringBuilder$appendFormat(mask, arg0, arg1, arg2, arg3, arg4) {
    this.append(String.format(mask, arg0, arg1, arg2, arg3, arg4));
}

.... and only support a fixed number of arguments to your appendFormat() method.

Back in 2007, I wrote about this same subject with object inheritance. My goal was to inherit from the Sys.StringBuilder, to create my own string builder, which I then added the appendFormat method to. The natural problem with this approach is that you have to use something other than the built in Sys.StringBuilder.

http://weblogs.asp.net/scottcate/archive/2007/11/28/extending-sys-stringbuilder-with-an-appendformat-method.aspx

Zoomit.exe is fabulous

In all my presentations, I've added ZoomIt as a display tool.

After every session, inevitably I get people who ask about the tool.

It's amazingly simple, and it's free.

http://live.sysinternals.com (Bottom of page is ZoomIt.exe)

In a large room, even at 1024X768, folks still have a hard time seeing the screen.

If it were possible, I would run at 800X600 to make my screen as large as possible. Unfortunately that creates a whole other set of usability issues that begin to over rule the large fonts.

ZoomIt to the rescue.

CTRL+1 - Zoom in.

CTRL+2 Draw on the screen. While in draw mode you have a few colors for the pen.

  • g = Green
  • r = Red
  • b = Blue
  • y = Yellow
  • o = Orange

you can also free draw with the mouse, which is great as a new age replacement for the old school laser pointer. while drawing with the mouse, you can add a keyboard click to adjust the drawing.

  • shift + draw = draw a perfect line
  • tab + draw = draw and ellipse
  • ctrl + draw = draw a rectangle
  • shift + ctrl + draw = draw and arrow

and a few others ....

  • e = erase the screen - all drawings go away
  • ctrl + z = undo last draw
  • t = Type on the screen. (Thanks Rob @ RobBagby.com for that tip)
  • up|down arrow keys change the pen size (larger or smaller for drawing and typing

Note to presenters (ReadMe.txt) ....

I've been using ZoomIt for about 6 months now, and I think I'm just getting to the point where I'm really good at using the utility, and not more confusing my audience with the zooming and drawing.

You can get zoom and draw happy to a point where I think it might actually take away from the effect.

I think "Less is More" wins here. If you have a really important presentation I wouldn't use ZoomIt unless you have had ample time to practice with it - maybe a few dry runs with the tool on your presentation.

NBC Silverlight Install End User Experience

imageI fired up my iMac this morning and ran over to www.NBCOlympics.com full of excitement to see the video experience that I've heard Microsoft and NBC talking about for the past few months.

I've never installed Silverlight on a Mac before, and I was intentionally not installing anything, so I could get a feel for the end user experience.

At the last minute, I decided to do a lazy mans recording with my Sony pocket cam, just pointed at the screen, so the clarity isn't that great, but you get the idea, and the experience I was trying to capture.

Check out the video, which I've uploaded to my Flickr account. The whole process was less than 90 seconds, which is great, because Flickr video maximum time in 90 seconds. Lucky me.

Once the vide player / Silverlight engine was installed, I was amazed at the clarity of the streaming video. it's amazing. In fact the streaming video footage, it better quality than the commercials I saw, which were all pretty grainy. Probably due to the way they were originally encoded.

I'm excited to watch the Olympics online this year, because I'll get to watch what I want, when I want, with much MUCH more coverage. I won't be locked into what scheduled in TV guide.

I wonder if the Archives will stay online after the Olympics are over?

iPhone Community Feedback on UserVoice.com
image

A few days ago, I created a UserVoice.com website for iPhone to keep track of bugs, features, and application ideas that I have specific to the iPhone. I really want love my iPhone, but currently am having a really hard time with it.

Others have started using the site as well, and it's created quite a few questions inside my daily community.

Will Apple see these?

If they do, will Apple care, or do they already know all this?

To me, not having quick dial by name is so frustrating, and tops my list. With my Samsung BlackJackII, I use the keypad and just start dialing a name, and the matches are shown in a list to choose from. Dialing by name couldn't be faster. J-A, and I already have all the phone numbers for Jamie that I need. Fast and Easy.

With iPhone, you first have to click home, then phone, then contacts, then get your tiny finger into the search bar, then start typing. Man, I could have been done with my phone call already. And making calls while driving is much MUCH more difficult. Interestingly enough, not a lot of people agree with me :( as you can see by the list on the top right, "dial by name" is one of the features that I think is most lacking, but it only has one vote, and the vote is mine.

So this got me thinking. Why don't people agree with me? Maybe they do, but I put a bad title on it. Maybe it should be "Dial by name from they number/alpha phone keypad, so I don't crash my car". Maybe I need to market and campaign for users to vote on Dial By Name and this will get Apple's attention. Maybe not enough people have visited http://iPhone.UserVoice.com account to get an accurate count of what people think. Or, maybe my 2400 contacts and I are a minority, and this isn't really a big deal to the iPhone population.

Is it cool for an End User to start their own support site, for a product that they want to make better?

The thing that makes UserVoice.com so great is the voting. You don't need an account to vote, you can do it anonymously. You can also add suggestions, bugs, and feature requests without an account. There are features you may want to sign up for (free) like email notifications if others comment on your item, or the item get's fixed.

TechEd Orlando :: Compiler Tricks

Here is the download project for my Compiler Tricks talk at TechEd Orlando, 2008.

The talk focuses on what the C# 3.x compiler does with new syntax, and how you can use most of the 3.x syntax, when targeting a 2.0 build. This doesn't mean you can use the 3.x code samples with Visual Studio 2005, because you need the 3.x compiler to actually compile the syntax targeted to a 2.0 build.

This single slide pretty much sums up what the talk focuses on, and the downloadable project is pretty simple to walk through as well.

[Click here or the the slide image to download ScottCateCompilerTricks.zip ]

image

San Diego ASP.NET SIG User Group

Here is the code sample I used last night to show off and talk about the ASP.NET AJAX Functionality that is built into ASP.NET 3.5.

This project has been built over the years with samples that I've created for conferences, and users groups around the world.

If you were in San Diego for the user group, or are just interested in checking out tons of examples, this is a small 2.5 meg download. The project has been upgraded to use Visual Studio 2008. A Visual Studio 2005 example of (not all but most of) this code is available on CodePlex.com/ScottCateAjax.

One thing about the setup, is (as you can see in the below image) the site navigation, uses the IE Search Toolbar. I really should update this, but as it stands, you have to enable the search bar ins most IE instances. Check out Tools|Options|Advanced, and then make sure "Enable websites to use the search pane*" is checked.

image

[ Click here or the image to download http://www.Scottcate.com/AJAX2008.zip (2.5Meg) ]

image

Running Baby Smash Offline

Last night Cameron and I posted about BabySmash, and how much fun we were having with it. This morning I was trying to show some folks the app, but I was offline.

Knowing how the technology works, I was able to find the local storage, and still run the last version of the program. I thought this may be helpful for others to see, so I screen cast it, while I was opening the file to show.

The file structure will be different for XP vs. Vista (this is Vista) but somewhere in your profile you'll find Apps\2.0\ .......

Enjoy the 90 second screen cast.

I was in a hurry to post this, so I didn't do the pan/zoom but I think it's good enough to get the point across.

image

Posted: Jun 13 2008, 10:01 AM by scott cate | with 3 comment(s)
Filed under:
Cameron loves BabySmash!

My son Cameron is 2.5 years old, and loves to play on the keyboard. He knows his alphabet, and numbers, both written and in sign language. Sitting in front of the computer for him is very exciting because he watches mommy and daddy play with the letter toy quite a bit.

Last week (maybe two weeks ago) Scott Hanselman started a fun project called BabySmash, that simply plays a sound and displays a character or shape on the screen when a key is pressed on the keyboard. if the keystroke is a letter or number, then the corresponding character is display, along with a sound bite. Other keys show random shapes. All display figures change background, border colors, and screen location, so repeatedly pressing the letter "C" produces a nice effect.

I'm sure there is a wish list of features for this application, but al the things I could think of were for me, not Cameron - and the app is written for Cameron - who really enjoys it.

Here is a 90 Second video showing Cameron and BabySmash.

image

Working with Fiddler on LocalHost

Developing ASP.NET AJAX (or any AJAX really) is tremendously easier if you can watch the traffic going across the wire. There are a lot of ways to accomplish this, but I think Fiddler is the most popular Windows application for ASP.NET developers. Sure there is Firebug, and probably a million others, but this post is about Fiddler).

Over the last few years, I've had a hard time getting Fiddler to work on local host. Actually until recently, it's just never worked.

Rumors online said to use http://127.0.0.1, instead of http://localhost and it'll work. Maybe for you, but not for me.

Then last month while speaking at Orlando ASPConnections, I was demoing some AJAX calls on stage, and an audience member told me that Fiddler will work on 127.0.0.1 with a trailing . on the IP address. So the address ends up like ...

Or

With a port number (if you're on Cassini).

Fiddler picks up this traffic and you're back in control of sniffing your own traffic.

Hope this helps others that didn't know the little nugget.

Screen Calls on your Cell Phone

This is not a paid advertisement. I'm just a happy customer.

Wow - this is great. I'm really busy, and shouldn't be spending time writing this, but it's just to cool to not pass along. As you probably know, cell phone service does not offer caller ID. If you think you have caller ID, what you really have is "Address Book Lookup".

When I call your cell from my office, and I'm not already in your phone book, you just see (480) 424-6952 on your screen, and have no idea who it is. If you're on a land line, you'll also see "myKB.com, Inc." on the screen.

I'm not into caller ID to know the difference, but I'm sure there is some technological short coming to why the name portion of caller ID is not included on cellular service.

Enter CallWave.com

CallWave is a replacement for your voice mail system, that I've written about before. It's an amazing service that emails your voice mail, as MP3 attachments. They also text you a dictated version of the voice mail, which they call a "Gist". The SMS text is never accurate to the word, but you can always get the idea of the voice mail - as well as the gist of the message - hence the name.

In the Email, and the SMS, the name portion of the caller ID is included as well, which is a nice feature.

And now - something that I've never been able to do before is possible because of CallWave.com.

Call Screening.

What do I do with these unknown number and blocked number calls? I send them to my CallWave.com voice mail. The CallWave server, speed dials me back, and while the caller is listening to my "Please leave me a message" - I have time to answer the call back from CallWave.

Then I hear the message you're leaving, while you're leaving it, and if I press 1 at anytime, we're connected.

HOW COOL IS THAT?

Here's the down side. CallWave.com is no longer free - but with all this functionality I'm still a big fan.

More Posts Next page »