CodeStuff (RSS)

Bits and bobs related to my work...

Digging Ruby

Ever since the IronRuby Alpha has been released I am trying to get on speed with Ruby. This is the language I choose to learn as my next language. I found some really nice material that will help me to make this journey a breeze:

  • Try Ruby is an interactive ruby command line in your browser. This is especially really nice when you cannot actually install the ruby environment. It has some interactive tutorials as well.
     

    http://tryruby.hobix.com/

  • Following the link at the bottom of the interactive ruby command line I did found Why's (Poignant) Guide to Ruby. This book continues to amaze me, although I did not read it yet completely. It is the most  bizarre Ruby language tutorial I saw in my whole adult life. I did learn programming Basic form an equally bizarre book.

    http://poignantguide.net/ruby/

  • Learn to Program is the next Ruby tutorial I like a lot. This one is aimed to teach the next generation of programmers, so it starts with explanations of a string and integer or a float. This way you can do teach this language to your kids, while you learn along the way. I think this can double the fun!

    http://pine.fm/LearnToProgram/

 

Technorati tags: Ruby, Learning Ruby

 

OSX's Expose on Vista

Simon created My Expose utility for Vista. My Expose is the OS X's Expose implementation using DWM and Windows SDK.

My Exposé : A Mac OS X Exposé implementation for Windows VISTA from Simon on (dot) NET.

Media Transfer Protocol sample code.

Media Transfer Protocol a.k.a MTP is a Microsoft technology for transferring media files from your PC to your portable media player. I have a Zen Vision:M and I am very interested learning what this SDK can do for me :) There is a site called opensource.creative.com and it has a series of articles with very useful MTP related articles:

Getting the Microsoft Windows Media Format 9.5 SDK Working
MTP Device Enumeration in Windows
MTP File Transfer in Windows
Obtaining DRM Transfer Certificates

Debugging Client side script errors

I had a difficult problem with broadcasting powerpoint presentation. The tool I want to use can be found in the Windows Media Encoder 9 SDK - which is by the way a very cool SDK if you need to automate your encoder related tasks. In this SDK, you will find the samples\vb\ppt sample, what is a little powerpoint add-in for doing broadcast from your Powerpoint with slides, video an audio. It can take about 10 users if you direct your users to connect directly to the Encoder and many more if the Encoder is using a Windows Media Server to distribute audio and video. The client side is webpage hosting the media player for video playback and using some scripts to pull out the slides and html from the stream. Now, when I am doing the broadcast on some clients I can see the video and hear the audio, but could not see the slides at all. The Encoder puts the html, image into the stream - I double checked these with taking a netmon capture and identifying the embedded data.


I am suspecting that the browser is not handling the scripts well, or maybe the script is broken somehow. I do not know anything about scripting and JScript, so I am right now collecting information about debugging client side scripts. I though it would be usefull to publish some links here as well:

This is it for so far, if I figured out the problem I will update this article.

Creating UI widgets with the Expression line

Came acroos two nice tutorials demonstrating how to create nice UI widgets with the Expression tools Sparkle and Acryllic:

Creating a Glass Button - PART ONE
Making a gel style button with Acryllic.

Unusual software bugs

Have you ever heard about Heisenbug, Mandelbug or Schroedinbug. I must confess I never did but it is always good to learn something new everyday:

A Schroedinbug is a bug that manifests itself apparently only after the software is used in an unusual way or seemingly at the point in time that a programmer reading the source code notices that the program should never have worked in the first place, at which point the program stops working entirely until the mysteriously now non-functioning code is repaired.

More unusual software bugs on wikipedia.

Deblector, a marriage of Reflector and a debugger.

Felice Pollano has put together a very interesting tool, what is basically a debugger and a reflector - thus the name Deblector. This tool is using Lutz Roeder's Reflector to generate source code using reflection while you are debugging. This can be very handy when you does not have the source code or debug symbols or you just want to figure it out really quick what is happening under the hood. I think I need to give this tool a closer look soon... will post my experiences! 

Check the latest release of Deblector.

Stupid Error : RunTime Check Failure #0 - The value of ESP

I just spent the last hour with this and I have no clue how would I found out this alone. I am trying to figure out the maximum keyframe space of a wmv file and for this I am using the Windows Media Format SDK and the wmvprop sample. At some point of the execution I would make a call for each video stream to find out this property by calling:

hr = pVideoMediaProps->GetMaxKeyFrameSpacing(&pllKeyFrameTime);

When I was stepping through my code and arrived to the call above I received the following error:

Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call.  This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.

I must tell you this error message is dead scary, because I am not a COM guru, nor a C++ one. So I spent an hour trying to figure it out and changed all the calling convetions in my call, but no joy! Then I called for help. Another 20 minutes 2 people staring at the screen then my collegue Kalman suggested to comment out my code and see if that works. It worked! Then we know that I am crappy coder :) Another session of blank staring for 2 mins then I saw this piece: like couple of lines earlier:

hr = pConfig->QueryInterface(IID_IWMStreamConfig, (void **) &pVideoMediaProps);

and the definition of my variable like 30 lines earlier:

IWMVideoMediaProps *pVideoMediaProps = NULL;

so that tells me basically that I screwed this up by querying for one interface and supplying another interface to QueryInterface. So tho correct the error it should be queried like this:

hr = pConfig->QueryInterface(IID_IWMVideoMediaProps, (void **) &pVideoMediaProps);

Honestly, I do not understand what happens under the hood - I really would like too, so someone smart please explain it to me - and why this error message shown, but I thought that I would try to save some time to other people with this. I really hope that this will be handy for someone sometimes :)

Another interesting twist was that after looking at the documentation I learned that:  

Remarks

This method retrieves the value set by SetMaxKeyFrameSpacing, or the default value for the key frame spacing, during the encoding process only. If called for a file that is open in the reader, the method always returns zero.

For more information, see the Remarks for SetMaxKeyFrameSpacing.

And I had a reader open and I received 0 as a result when I ignored this error! The moral of the story? COM rulez! Pay respect to it and documentation is your friend!

Consolas Font Pack for Microsoft Visual Studio 2005

Is now available for download from here.

Brief Description

Optimized for Microsoft ClearType
The Microsoft Consolas Font Family is a set of highly legible fonts designed for ClearType. It is intended for use in programming environments and other circumstances where a monospaced font is specified. This installation package will set the default font for Visual Studio to Consolas.