Scott Hanselman

Quotes of the Day - March, 31, 2005

April 01, 2005 Comment on this post [2] Posted in Musings
Sponsored By

"Sure, our software interoperates. It interoperates the same way the U.S. does in Iraq."

"Dude, you're playing Jenga with our Object Model."

"I don't like the whole [ServiceContract] attribute. It's too loose. How about ServiceEdict? ServiceFatwa? ServiceDogma?"

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

Brainstorming Hardware Projects

March 31, 2005 Comment on this post [14] Posted in Web Services
Sponsored By

I'm looking to do some hardware/gadget related projects and articles in .NET.

Brainstorm with me...

  • An X10 clickable floorplan of your home for use as a 10ft interface in Windows Media Center
  • A USB video monitor window for watching the front door or babies. Pop it up when movement is detected? Perhaps use Windows Image Acquisition.
  • An interface and charting/graphing application for my Blood Sugar meter. Perhaps set it up for any medical device with values over time.
  • Live GPS tracking that reports my position to a blog as I move.
  • Lego Mindstorm Robot with .NET?
  • Hook up to the monitor port of a car (the one the auto techs use) and dump the collected internal logs.
  • An Outlook Calendar Provider that shows a new Calendar with blood sugar (or blood pressure, etc) data pulled from a device and stored in another file.
  • A UPnP client in .NET
  • Something with a .NET CPU - Ideas?
  • Report Continuous Integration build status to a SPOT Watch
  • Something with the Windows Fingerprint Reader?
  • Get a CueCat or BarCode Scanner to catalog all my books using Amazon.com Web Services.

More ideas?

 

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

Internationalization Support in Windows XP

March 31, 2005 Comment on this post [5] Posted in Musings | Tools
Sponsored By

A good reminder from Michael Kaplan on international support in Windows.

One of the first things I do when I install any english version if Windows is to head to Control Panel|Regional and Language Options and tick these two checkboxes. It's a great way to get right of those pesky black squares.

Michael reminds folks that:

"Every version of Windows 2000, Windows XP Home, Windows XP Professional, and Windows Server 2003 contains all of the international support"

I've got lots of friends who's parent or parent would really prefer to surf and email in their native language, and they don't realize their language may be a checkbox or font away.

That said, here's Google in Zulu: http://www.google.com/intl/zu/

P.S. Some folks don't realize that the reason folks says "i18n" is because there's eighteen letters between the i and n in internationalization. ;)

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

TechEd Video #3 - Drink the TechEd KoolAid

March 30, 2005 Comment on this post [8] Posted in Movies | TechEd | Javascript | Speaking
Sponsored By

Rory and I love Microsoft. Rory drank the Kool Aid, but I'm not so sure. Maybe with the help of Dan Fernandez, Becky Dias, Simon Guest, Shy Cohen, Richard Turner, Rory's Girlfriend and Jay Roxe.

Please spread it around and Trackback/Pingback it. If you can't view it below, you can download it here.

Remember, if you're blogging TechEd this year, make sure to register your blog at TechEd Bloggers.NET and get your content aggregated!


play video stop video indicatorhandleamount downloaded toggle sound launch in external player
Launch the streaming media file

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

Zipping/Compressing ViewState in ASP.NET

March 30, 2005 Comment on this post [7] Posted in ASP.NET | DasBlog | ViewState | HttpModule | Bugs
Sponsored By

Here's an interesting, odd, but obvious idea. If you're not able to use HttpCompression like the Blowery HttpCompression module that we use with dasBlog due to the pile of bugs in older versions of IE around compression, you can "zip" up the ViewState on fat (usually DataGrid related bloat).

This is some VB code that Vlad Olifier did, that he said I could post on my blog. It's also a new submission at GotDotnet. To use it, you just derive your ASP.NET page class from it.

Using Zipped ViewState:

Public Class CompressPage
  Inherits PageViewStateZip

Just deriving from System.Web.UI.Page as usual:

Public Class RegularPage
  Inherits System.Web.UI.Page

The "trick" is pretty simple. There are little-known virtuals in Page that you can override - specifically LoadPageStateFromPersistanceMedium (where that persistance medium is a hidden input box) and SavePageStateToPersistenceMedium.

When it's time to load view state, we pull it out of the form and un-base64 the string into a byte array, un-zip the bytes, then deserialize the ViewState. When it's time to save, reverse the process - Serialize, zip, store. There's some overhead, certainly. The amount of compression is usually about 50%, but your mileage may vary (YMMV).

The real decision flow is this:

  • Can you use HttpCompression (via XCompress or an HttpModule)?
    • If so, use it.
  • Can't? (Bugs, SSL, Compatibility, bosses, don't want to take the perf hit, etc)
    • Got Fat ViewState on a few pages?
      • Use Zipped ViewState on a few pages as needed.
Imports System.IO
Imports Zip = ICSharpCode.SharpZipLib.Zip.Compression
 
Public Class PageViewStateZip : Inherits System.Web.UI.Page
  Protected Overrides Function LoadPageStateFromPersistenceMedium() As Object
    Dim vState As String = Me.Request.Form("__VSTATE")
    Dim bytes As Byte() = System.Convert.FromBase64String(vState)
    bytes = vioZip.Decompress(bytes)
    Dim format As New LosFormatter
    Return format.Deserialize(System.Convert.ToBase64String(bytes))
  End Function
 
  Protected Overrides Sub SavePageStateToPersistenceMedium(ByVal viewState As Object)
    Dim format As New LosFormatter
    Dim writer As New StringWriter
    format.Serialize(writer, viewState)
    Dim viewStateStr As String = writer.ToString()
    Dim bytes As Byte() = System.Convert.FromBase64String(viewStateStr)
    bytes = vioZip.Compress(bytes)
    Dim vStateStr As String = System.Convert.ToBase64String(bytes)
    RegisterHiddenField("__VSTATE", vStateStr)
  End Sub
End Class

Note that this sample uses SharpZipLib from ICSharpCode, but I assume you could use others, and I'd probably use System.IO.Compression if I was using .NET 2.0. The buffer sizes are hard-coded, but the only one that really matters it the one in Compress(). Again, salt to taste.

Imports System.IO
Imports Zip = ICSharpCode.SharpZipLib.Zip.Compression
'//--Download ICSharpCode.SharpZipLib from
'//--http://www.icsharpcode.net/OpenSource/SharpZipLib/Download.aspx
 
Public Class vioZip
  Shared Function Compress(ByVal bytes() As Byte) As Byte()
    Dim memory As New MemoryStream
    Dim stream = New Zip.Streams.DeflaterOutputStream(memory, _
                 New Zip.Deflater(Zip.Deflater.BEST_COMPRESSION), 131072)
    stream.Write(bytes, 0, bytes.Length)
    stream.Close()
    Return memory.ToArray()
  End Function
 
  Shared Function Decompress(ByVal bytes() As Byte) As Byte()
    Dim stream = New Zip.Streams.InflaterInputStream(New MemoryStream(bytes))
    Dim memory As New MemoryStream
    Dim writeData(4096) As Byte
    Dim size As Integer
    While True
      size = stream.Read(writeData, 0, writeData.Length)
      If size > 0 Then memory.Write(writeData, 0, size) Else Exit While
    End While
    stream.Close()
    Return memory.ToArray()
  End Function
End Class

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.