Wednesday, May 31, 2006

Javascript Debugging Hint

Often times I feel like I have to be a cross between Gil Grisom and Sherlock Holmes when I'm trying to debug a javascript error. So I get very excited when I find a tool or technique to help me. So far my favorite tool is the Venkman javascript debugger, despite rumors that it crashes on some machines.

The other day a co-worker mentioned that enabling the script debugging in Internet Explorer allowed Visual Studio to debug javascript in your site. You can do this by going into IE > Tools > Iternet Options > Advanced and unchecking the "Disable Script Debugging (Internet Explorer)" option. This was very exciting, a way to debug javascript directly in the IDE. It still didn't get rid of those cryptic IE errors, but at least you would break in the IDE. If you want to get better error messages, use Venkman.

Anyway, back to the task at hand. I noticed the other day that Visual Studio's CallStack window works while debugging javascript. Let's perform an exercise to see how useful this could be. Suppose you have a javascript function that is called from several different places. If that function threw an error, the call stack information could help determine what called it. Take a look at this simple page:


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Test Page</title>
<script type="text/javascript">
function runtest1()
{
test(true);
}
function runtest2()
{
test(false);
}
function test(x)
{
if(x == false)
throw("New Error");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button"
onclick="javascript:runtest1();runtest2();"
value="Push Me" />
</div>
</form>
</body>
</html>


When you click on the button, runtest1 will execute successfully and runtest2 will throw an error. Now pretend that you don't know exactly where the error was coming from. Take a look at the stack trace and see if you can figure it out.

Tuesday, May 30, 2006

I Love Lists

Everyone loves a list, right? Well, a lot of us do. We watch Letterman because his top ten lists are funny. We go Hanselman's website for his ultimate list of tools. We love to see what other people find important and compare their lists with our own. I find that lists are a great way to find out about tools and sites that I wouldn't have found otherwise.

For the most part, lists are cool. This is why Listible is cool. Listible is kind of like Digg and Del.icio.us got together and had a really cool baby, and named it Listible. Here's how it works. Basically, someone requests that a list be created to cover a topic. Then the public is free to add items to the list and tag them like in del.icio.us. But what makes this site special, is the public's ability to vote for an item thereby driving it up the list. The public sets the relevancy of all the items in the list. So when you view a list, you can be relatively confident that the best stuff is at the top.

You can even vote for the relevancy of the list itself, which will determine how that list ranks compared to other lists. However, I'm a little unclear about this. I can understand one site being a better .NET reference than another site. But, can you really say that a list of .NET reference sites is more important than a list of Wedding Planning sites? It seems to me that importance is in the eye of the beholder.

Thursday, May 25, 2006

IE/Clipboard Security Risk

Have you ever wondered what information a web server can glean from you when you visit a site? You can find out on the Project IP web site. I was really surprised at some of the stuff the site found about my pc and web session. Sure, I expected it to know my IP address, browser version, whether or not cookies were enabled, etc. However, I was surprised to find a list of all the plugins I have installed in my browser and the number of pages that I have viewed in my current web session.

But here's the real kicker, the last text item you copied onto your clipboard! Only works in Internet Explorer on the Windows platform. If you aren't using FireFox by now, maybe this will sway you. It reportedly works with varied success when IE is running in an emulator such as VMWare on another OS. Have you ever copied a password or credit card number or ssn and pasted it into anywhere? Hopefully, it wasn't right before you browsed a site that took advantage of this.

Luckily there is a fix:
Go to Tools > Internet Options > Security > Select a security zone > Custom Level > Scripting > Allow paste operations via script and set it to Disabled or Prompt.

Wednesday, May 24, 2006

Windows Shortcut Keys

I'm always looking for cool keyboard short cuts to help me be more productive in my applications. For example, Visual Studio has a gazillion shortcut keys that enables you to do just about anything without the mouse. I find that while I'm coding, the less time I use switching back and forth between the keyboard and the mouse the more I get done. But what if you aren't in your favorite development environment. Here is a great list of windows shortcut keys from CodingHorror.

If you wish to expand on this list, you might want to try Winkeys. Winkeys allows you to use the Windows key to create keyboard shortcuts for your favorite applications. Here is a list of the ones that I have added. For example, I use Windows + Shift + V to open Visual Studio 2005.

Monday, May 22, 2006

The Orange Movie project has just released their animated short, The Elephant's Dream. The project was sponsored by the Blender Foundation, an opensource community around the Blender 3D modeling, animation and rendering application. The Orange Movie Project's stated goals were to create an outstanding movie short, and to research efficient ways to increase quality of Open Source projects in general.

The short is nothing less than awesome. I've already downloaded it, you can get it and the project files that were used to make it on their web site. It makes me want to try my hand at 3d modeling and animation.

I had to download and install MPlayer to get it to play. MPlayer is currently a console application for Windows. However, there are frontends available for download. Here is one.

Thursday, May 18, 2006

Ba-donk-a-donk!


Now what I'm about to share with you is either a testament to marketing genius or my stupidity. But if loving this stuff is wrong, I don't want to be right. I came across this site by NAO Design, who describe themselves as, and I quote:

"...a multidisciplinary design firm with a focus on automotive design, architecture, pyrotechnics, lighting, furniture, electronics, signage, and web and graphic design, and often the fusion of several such diverse elements."

Wow, there's a mouthful. So what makes these guys so special? One word, "Badonkadonk". The Badonkadonk is a personal motorized, armored transport with head/tail lights, turn signals, accent and underbody lights, 400 watt premium sound with PA system, and... Oh yeah, and an optional pyrotechnic system that shoots flames out the top. This product became so popular(how?) that it garnered its own web site. I think the inception went a little like this:

Designer 1: I'll bet I can fit my fist in my mouth.
Designer 2: I'll bet I can sell a go-cart on Amazon for 20 grand.
Designer 1: How the hell are you going to do that?
Designer 2: Easy, I'll just armor plate it and throw in a stereo.
Designer 1: You know what would be cool? If it shot fire.
Designer 2: eh, eh... fire... sweeet.

SideNote: I can't not talk about the PneumatiPak 2, also found on the NAO Design website. Basically a pneumatic powered handheld cannon. So what makes this so much better that your average nail gun that you could pick at Homedepot? I swear I'm not making this up. "With a removable 1.5L liquid reservoir for shooting water, paint, beer, etc. New rotary reloading breech-loader mechanism allows for very rapid reloading of solid ammo, such as hotdogs, marshmallow, batteries, tampons, and carrots. With a maximum range of 100 yards." Priceless... Speechless...

Back to the Badonkadonk and why it inspired this blog. The Badonkadonk is cool, but I don't need all that stuff. Have you every used a piece of software that made you feel the same way? Have you every coded software that made you or the client feel that way? We sometimes have the tendancy to gravitate towards flashy things with lots of cool features that we never use because we don't need them. Gordon Moore recently noted that software has become so complex that it prevents the users from making effective use of the underlying power of their computer. It may be too late for a new years resolution, but the Badonkadonk and my Badonkadonk project, have me picking up and dusting of the old development ethos: "Keep it simple stupid."

Tuesday, May 16, 2006

Cool Atlas information from Jeff Prosise

Yesterday we had a very interesting lunch and learn session on the topic of Atlas. The speaker was Jeff Prosise, co-founder of Wintellect. Jeff was an excellent speaker. I learned a lot in the little time that we had. Here is a breakdown of Jeff's presentation.

1. Introductions
Jeff started out the presentation with a brief overview of Atlas. Atlas is Microsoft's upcoming AJAX framework. It is only compatible with ASP.NET, so you have to serve it from IIS. It is also only compatible with .NET 2.0 and higher. There will be no backwards compatibility with .NET 1.x. I was under the impression that Atlas was a mostly server side technology. However, using the XML scripting language, you can do just about everything on the client side.

2. Ajax support already built into ASP.NET
Jeff demonstrated that there is already support for AJAX built into ASP.NET 2.0. You just have to do a little bit of coding to get it to work. Basically you implement the ICallBackEventHandler interface on your page and then grab a reference to the javascript function that you wish to return to. Here is a page and the code-behind that demonstrates using AJAX in an ASP page.
ASPX:

<html>
<head>
<script language="javascript" type="text/javascript">
function MultiplyByTwo()
{
var tb = document.getElementById("txtNumber");
var value = tb.value;
CallServer(value, "");
}
function DisplayResult(rValue)
{
document.getElementById("lblResult").innerHTML = rValue;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="txtNumber" type="text"> * 2
<input onclick="MultiplyByTwo();" value="=" type="button">
<asp:label id="lblResult" runat="server">>
</asp:label></div>
</form>
</body>
</html>



Code-behind:
public partial class _Default : System.Web.UI.Page, ICallbackEventHandler
{

protected string returnValue;

protected void Page_Load(object sender, EventArgs e)
{
string cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "DisplayResult", "context");
string callbackScript = "function CallServer(arg, context){" + cbReference + ";}";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true);
}

#region ICallbackEventHandler Members

public string GetCallbackResult()
{
return returnValue;
}

public void RaiseCallbackEvent(string eventArgument)
{
if (!String.IsNullOrEmpty(eventArgument))
{
int arg = int.Parse(eventArgument);
arg *= 2;
this.returnValue = arg.ToString();
}
}

#endregion
}


3. Framework
When a page containing atlas controls is requested, Atlas sends a copy of its framework down to the client machine. The framework is written completely in javascript. Since most browsers cache javascript, the framework should only be downloaded once, instead of everytime you hit page with an Atlas control. Jeff also mentioned that the release version will contain a browser abstraction layer. This layer will be responsible for making sure your code runs correctly no matter what browser it is displayed in.

4. Clientside Focus
For the clientside, Jeff focused on Atlas' XML scripting language. Most of the examples used very little server side code. The framework parsed the script and generated the necessary javascript to perform the actions. Here is an example of some XML script that displays a panel when you click on a button.

<script type="text/xml-script">
<button id="showButton">
<click>
<setProperty target="panel" property="visible" value="true" />
</click>
</button>
</script>


5. Serverside Focus
For the serverside, Jeff showed off some "Extender" controls. Most noteable the MSN Earth control that hits the same servers as Windows Live Local. There isn't a lot of documentation out there for these, but they seem really cool.

WinFX SDK killed my download

I am extremely keen on XML technologies. I don't claim to be an expert, but I think that they are pretty cool. Recently I have become more and more interested in the prospect of using Flash like technologies to boost the user experience on my web sites. My search led me to XAML. XAML is cool. I haven't actually written anything in XAML, but the demo's on the web are sweet.

What's that you're saying? Why haven't I written anything in XAML yet. I'll tell you why. Because it took almost 4 freak'n hours to get the stuff installed and return my machine to working order, that's why! I don't that kind time. Sure I love watching paint dry as much as the next guy, but seriously! James Robertson has any excellent Squidoo lense for XAML that includes a section on what you need to download and the installation order. Here's a break down of the installation steps and how long it took for each one.

1. WinFX Runtime Components - couple of minutes: This is all you need to view XAML files on your machine. But if your like me, and want to actually write an application you'll need the...

2. WinFX SDK - 3+ hours: Holy creeping downloads Batman! Its a good thing my hard drive had an extra gig of free space. I kid you not, 1.2 gigs. Maybe I should have limited what I wanted to install, but it all looked so delicious. This is why they shouldn't let me eat at buffets. The only thing that I turned off in the install was the 64-bit processor support and Monad (more on that later).

3. Optional Development Tools - 30 minutes: The install took longer than the download.

At this point I am already frustrated with the SDK install, but I made it through and thought that a reboot was in order. You don't have to reboot, I'm just weird. Anyway, I tried to open up a Powershell instance after the reboot and recieved an error. That's odd. Powershell was working before. Wait a minute, where's my powershell install directory?!!! I guess when I told the SDK not to install Monad (because I already had Powershell installed), THE SDK UNISTALLED POWERSHELL!!! I don't even know how. Monad installs under a completely different directory. So that led me to...

4. Microsoft Powershell RC1 - 5-10 minutes: PowerShell rules! Reinstalling sucks!

Alright now its time for a "hello world" application. Wish me luck.

Welcome to my blog

One of my new job "requirements" is to blog to an internal blog. But I thought that some of my more technical and less jobby posts should be shared with the rest of the world. And since I am so cheap, I started this blog for free.

A little about me. I'm an Advanced Software Engineer working with C# and creating mostly web applications. I love xml technologies and am trying to give up the mouse while I'm programming. This is turning out to be very difficult when working on web apps. So expect to see more blogs in those arenas.