Scott Hanselman

Silverlight Video of John Lam on IronRuby at PADNUG

July 31, 2007 Comment on this post [20] Posted in Silverlight | Speaking
Sponsored By

image Here's the Video of John Lam talking about IronRuby at PADNUG last week. I recorded it on a Sony Wide-screen (I think HD) camera with a 60 gig hard drive. Now that I've been doing the Podcast thing I'm a freak about decent audio, so John is wearing a Bluetooth Microphone around his neck transmitting directly to the video camera.

I edited the 17 gig video in Sony Vegas Movie Studio Platinum - which I love DEEPLY. Then I ran the audio through a hiss filter and punched it up a smidge. Then I rendered as a WMV9 and used Expression Media Encoder to produce a Silverlight Project that is now sitting on my web server. The final file was about 300 megs and is about 80 minutes long.

GOOF UPDATE: Looks like there's 2 min of blackness at 58:44 that ends at 1:00:03. To be clear, nothing is missing. It appears I didn't drag two "Segments" close enough together in Sony Vegas. My bad, sorry. You'll want to skip over that part, otherwise I'll have to re-render the Whole Thing and finagle it back up to the Microsoft.com servers that I don't have access to. Live and learn.

GOOF UPDATE #2: My man on this inside, at least until September, Tim Heuer has saved the day and uploaded a re-rendered version of this video with the gaps removed. Thanks Tim!

I tried a little different technique with this video. I moved the camera the way I moved my eyes. Rather than just putting it on a tripod and attempting to interlace in Camtasia footage, I attempted to fill more documentary style with big zooms into the projected screen. I actually think it works pretty well. There's so many great presentations that happen in small groups like this (classrooms, lectures, whatever) and they often sound and look like CRAP. My goal is to experiment with audio and video styles that are the most effective - and that folks will actually SIT through. When this video is resized full screen it's pretty watch-able. I'm interested in your opinion and ideas so I can try more in this style and possibly get my new boss get loan me a camera. Hint hint, nudge nudge.

But enough about video editing, do check out the video. John talks about a number of interesting things from his OSCON presentation including side by side speed comparisons with IronRuby against Ruby proper as the new Ruby runtime that is many times faster than the old. He also shows where IronRuby isn't so fast and why there are places where it won't even be fast. It's all done in a very accessible way. It was one of the first talks in a long time that I didn't get even a little sleepy.

If you have trouble viewing the Silverlight Version of the Video, you can get the WMV directly from download.microsoft.com (which is cool considering I don't work there yet, eh?)

So, again, that's:

Video doesn't work? Remember that Silverlight is NOT released, so things aren't necessarily 100%. If you are having trouble viewing this video, do me a favor. Go to a command-line and run MSINFO32.EXE.

You'll find it in one of two places - either in c:\windows\system32 or c:\Program Files\Common Files\Microsoft Shared\MSInfo

Export the results to a text file via the File | Export option (the command line switches don't always work.) It WILL take a long time. Relax. Then, zip it up and send it to me. My email is my first name at my last name .com if you know what I mean. I'll forward it along.

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

Expression Media Encoder - Preview Update for Silverlight RC

July 31, 2007 Comment on this post [2] Posted in Silverlight
Sponsored By

Microsoft Expression Media Encoder Preview I'm using the Expression Media Encoder right now to prepare the video of John Lam that I recorded during his recent visit to Portland. If you work with video and you haven't tried this app, do check it out. It does one thing and one thing only - it preps video for presentation, presumably via Silverlight.

As of today, make sure you get both packages:

Even though I use Sony Vegas for my video editing (Note to self, get boss to buy me a copy, as I'm on my 4th 30-day trial) the A/B Compare stuff in Media Encoder are reason enough to use it.

Open Media Encoder and drag/drop a video into it. Hit A/B Compare and now drag a small bit in the timeline to select a range of time, perhaps 30 seconds, then press Build Preview. Notice that the preview screen will split with a yellow line. If you double click on the line it will toggle between horizontal and vertical. After the Compare is rendered, hit play and drag the yellow line back and forth to compare the before and after. Love that crap.

Lam Silverlight After you've found a nice compression ratio that fits your needs, click on the Output Properties dealie in the upper right corner.  Click "custom" in the Thumbnail section and select a frame for use as your thumbnail.

Under Job Output, select a template. The template will say "Silverlight RC." 

ODD: for some strange reason, my favorite template called "Clean" wasn't updated for the Silverlight RC. You can go edit the templates yourself from the C:\program Files\Microsoft expression\Media Encoder 1.0\Templates\en. I'll probably go update "Clean" later, unless the guy who did "Clean" reads this blog and hears my plea. It was an awesome template.

A folder will be created with everything you need to upload. Put it all up on your site and you're all set. You can also edit the template's startPlayer.js and put your file in the  mediaUrl spot as seen below. 

function get_mediainfo(mediainfoIndex) {
    switch (mediainfoIndex) {        

        case 0:
            return  { "mediaUrl": "JohnLamIronRuby.wmv",
                      "placeholderImage": "",
                      "chapters": [               
                                  ] };                                                                
                          
        default:
             throw Error.invalidOperation("No such mediainfo");
     }
}

I should have this video up soon.

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

Progress Bars in PowerShell

July 31, 2007 Comment on this post [5] Posted in PowerShell
Sponsored By

PowerShell has a thousand nice features, but one of the nicer ones that I end up using all the time is the built in Write-Progress cmdlet. Shady the Intern came by today with a PowerShell script that printed dots to report progress, like:

Doing some stuff........................

I recommend he switch to Write-Progress. A nice feature of Write-Progress that I don't see used enough is the assigning of IDs to Activities, and then referencing those IDs as ParentIDs when writing out the progress of a Child Activity.

for ($i = 1; $i -le 10; $i++) 
{
  write-progress -id 1 -activity "Doing some stuff" -status "whatever" -percentComplete ($i*10);
   sleep 1; 
   for ($j = 1; $j -le 10; $j++)
   {
      write-progress -id 2 -parentId 1 -activity "Doing some child stuff" -status "yay" -percentComplete ($j*10)
      sleep 0.75
   }
}

PowerShell Progress

Here's a trivial example. Two for loops, each sleeping for a bit. The second for is a child of the first. Notice that ID of first loop is -activity 1 and the second references that activity via -parentActivity. This really adds, in my opinion, to the fit and finish of any script.

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

Paper - Managing Large Scale System Deployment and Configuration with Windows PowerShell

July 30, 2007 Comment on this post [11] Posted in PowerShell
Sponsored By

Hanselman - Managing System Deployment with PowerShell.pdf - Adobe ReaderLiterally 1 million years ago, as I remember it (actually around November of 2006) I wrote a paper on our Financial Services solution that uses PowerShell to manage deployment.

There were a few Channel 9 Videos on the subject and a whole category on PowerShell was born on my blog. I even did a few presentations on the topic.

The paper was/is like 28 pages long and I wanted to get it out ASAP. I gave it to Dino at Microsoft and he was trying to get it to a guy at TechNet, and I wasn't supposed to blog it or release it or anything until they had their exclusive.

Fast forward to darn-near August 2007. My last day at Corillian is Thursday and my first day at Microsoft is in Sept...so, here's me releasing the paper myself and phooey on all those folks who were taking so long to publish it. It's too late for Corillian to fire me and (maybe) too late for Microsoft to un-hire me.*

Thanks to the Corillian Team who work on this project and who did all the hard work I take credit for. Thanks again to Geoffrey Bard for the Signing PowerShell Scripts section.

* Just kidding, of course I asked first. Seriously, you know me so well.

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

Unit Testing Silverlight with Selenium

July 30, 2007 Comment on this post [9] Posted in Programming | Silverlight | Tools
Sponsored By

Selenium is a web testing tool that runs directly in the browser. That means it's all JavaScript. It'll run on the Three Major OSes and on the Three Major Browsers (and others!), so that's cool. There's even a recorder/playback IDE called Selenium IDE that takes the form of a Firefox plugin.

One of the things that's particularly interesting about Selenium is that it uses HTML Tables as its input Domain Specific Language. Go ahead and read that sentence again just to drink it in.

For example, if you had a page called "/default.html" and on that page there was a button called "myButton" here's the code to open the page and click that button. 

<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">SeleniumTest</td></tr>
</thead><tbody>
<tr>
    <td>open</td>
    <td>/Default.html</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>myButton</td>
    <td></td>
</tr>
</tbody></table>

This would be a "test" page and you'll also need a master "Suite" that would contain many tests. A Suite is just a table of tests:

<table>
<tr><td><b>Suite Of Tests</b></td></tr>
<tr><td>
<
a href="./SeleniumTest.html">Test Suite</a>
</
td></tr> </table>

Because of cross-site scripting issues, you have to install Selenium (just download the zip and upload the contents to your website) on your server and visit the pages from there. For example, here's the Selenium Test Runner on my server here at Hanselman.com.

As Selenium is all JavaScript, I thought it'd be nice to make sure it can test Silverlight applications. I can see how a testing framework that could easily interact with Silverlight would be a useful thing, so I set off to prove the concept.

First, I made a super-simple XAML of a TextBlock and a Circle:

<Canvas
    xmlns="http://schemas.microsoft.com/client/2007"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ButtonSharp="clr-namespace:ButtonSharp;assembly=ClientBin/ButtonSharp.dll"
    x:Class="ButtonSharp.Page;assembly=ClientBin/ButtonSharp.dll"
    Width="320" Height="240"
    Background="White"
    x:Name="rootCanvas"
    >
    <Ellipse Fill="#FFFFFFFF" Stroke="#FF000000" x:Name="Circle" 
Width="169" Height="169" Canvas.Left="81" Canvas.Top="32"/> <TextBlock x:Name="MyText" Text="Hello World from my Script Tag"/> </Canvas>

In the code-behind I made a few Scriptable methods. By marking them Scriptable, they are made available to the "outside world" - in this case, JavaScript.

[Scriptable]
    public partial class Page: Canvas
    {
        public Page()
        {
            Loaded += new EventHandler(Page_Loaded);
        }

        TextBlock tb = null;
        Ellipse el = null;

        void Page_Loaded(object o, EventArgs e)
        {
            WebApplication.Current.RegisterScriptableObject("scott", this);
            tb = (TextBlock)this.FindName("MyText");
            el = (Ellipse)this.FindName("Circle");
        }

        [Scriptable]
        public void SetCircleColor()
        {
            tb.Text = "Hello from C#";
            el.Fill = new SolidColorBrush(Color.FromRgb(0xFF, 0x00, 0x00));

        }

        [Scriptable]
        public string GetCircleColor()
        {
            SolidColorBrush b = el.Fill as SolidColorBrush;
            return b.Color.ToString();
        }
}

The code does two useful things. First, it registers the class with the WebApplication via RegisterScriptableObject and names it "scott."  You'll see later where we refer to "scott" in JavaScript and you'll know we mean this class. Second, it finds the TextBlock and the Ellipse and squirrels them away for later use.

Back over on the outside, in the HTML page's JavaScript, I make two silly functions:

<script type="text/javascript">
    function changeColor()
    {
        var control = document.getElementById("SilverlightControl");
        control.Content.scott.SetCircleColor();
    }
    function getColor()
    {
        var control = document.getElementById("SilverlightControl");
        thing = control.Content.scott.GetCircleColor();
        alert(thing);
    }
</script>

Notice where we call the two managed C# methods via our "scott" object. Then I add two regular HTML buttons:

<input type="button" name="changeColor" value="Change Color" onclick="changeColor()"/>
<input type="button" name="checkColor" value="Check Color" onclick="getColor()"/>

You click one button and it calls changeColor which should make make the Circle red, and the other will ask the Circle what color it is and display the result in a JavaScript alert. You're welcome to run this little thing here if you like.

Note that you WILL need the Silverlight 1.1 Alpha Refresh first.

Now I make a Selenium Test like this. You can also use the Selenium IDE to record, write manually, step through and save tests if you're not into the whole Notepad thing.

<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">SeleniumTest</td></tr>
</thead><tbody>
<tr>
    <td>open</td>
    <td>http://www.hanselman.com/silverlight/seleniumtest/ButtonSharp/Default.html</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>changeColor</td>
    <td></td>
</tr>
<tr>
    <td>click</td>
    <td>checkColor</td>
    <td></td>
</tr>
<tr>
    <td>assertAlert</td>
    <td>#FFFF0000</td>
    <td></td>
</tr>
</tbody></table>

The Selenium Reference is excellent and contains all the commands you can use. Remember, each command is one line in  test table like:

command target value

And there's many you can use. You can also make your own by making a file called user-extensions.js, and there's lots of details on the Selenium site. You can also use actual JavaScript in the targets and values if you include 'javascript{ }' in the parameter.

I'm sure that if I knew JavaScript better I could better access the Silverlight object and test all kinds of things. I'll leave this exercise to the Smarter Than I Reader.

You can pass parameters to the Selenium Test Reader like the test file via ?test= etc. If you want to run my Silverlight App inside the Selenium Test Runner in your own browser, just go here. Do note the format of the URL. You can also just visit the runner and enter the URLs yourself. You can have as many tests as you like in the suite.

NOTE: When you startup the runner, change these settings for a more dramatic experience. Turn the speed down to Slow with the slider, and click Highlight elements Then click either of the Green Play Buttons.

Selenium Functional Test Runner v0.8.2 [1727] - Mozilla Firefox

It'd be interesting what kinds of community extensions to Silverlight could be created for Selenium to make it even easier. I also wonder how well Watir or Watin can interact with Silverlight.

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.