Sunday, June 10, 2007
by Nik Kalyani
Sunday, June 10, 2007 4:25:29 PM (Pacific Standard Time, UTC-08:00)

I recently re-paved my Media Center computer because I was getting occasional lock-ups for no discernible reason. It was a good time to do some media management and get more organized and also document the hardware configuration (since it's a DIY system, it's nice to have this handy for when there are problems).

  • Antec NSK2400 Case

  • ASUS M2A-VM Motherboard


  • Athlon 64 X2 Dual Core 3800+ CPU

  • 2GB DDR2 800 RAM
  • Two Adaptec AVC-3610 Dual analog tuners

  • Hauppauge WinTV HVR-980 Digital Tuner
  • Four SATA2 500GB internal disks
  • Two 2TB Buffalo Terastations
  • Windows Vista Media Center

I have two of the 500GB disks setup in a RAID1 configuration and they are used for the system files and recording television. The other two contain mostly ripped DVD's that I don't care too much about (kids shows, How To videos, music videos etc.) The Terastations contain my ripped DVD's and about 70GB of music. They are on the same gigabit network as the media center PC which makes the DVD's play almost instantly.

I will need to add more storage soon, as I have ripped about 420 English DVD's and have another 60 to go. I haven't yet started to rip my Bollywood DVD's (about 300) as the movies tend to be longer and require more disk space than my wallet can presently bear.

#    Comments [0] - Trackback    

by Nik Kalyani
Sunday, June 10, 2007 11:52:44 AM (Pacific Standard Time, UTC-08:00)

Last week was a big one for DotNetNuke with two major announcements:

Visual Studio Magazine Editor's Choice Award for 2007

This was a pleasant surprise, especially considering that last year's winner was SharePoint and this year's other winners are Microsoft Expression Blend and Microsoft Expression Silverlight. You can read all about it here.

OpenForce '07 Conference

I am very excited about the DotNetNuke OpenForce '07 Conference for three reasons:

  • It's the first major mainstream event for DotNetNuke, highlighting how far the project has come and how much it has grown;
  • It's co-located with the DevConnections conference which is one of the premier conferences for Microsoft technology professionals; and
  • It's in Vegas!!!!

I will be presenting one session and participating in one panel discussion. My session is:

DotNetNuke Modules: Beyond the Browser
DotNetNuke modules are generally designed to function with a web browser as a client. In this session you will learn how to extend your module beyond the browser and onto the desktop. We will review how to use the “Widget Toolkit” to create Vista Sidebar Gadgets and widgets for various other platforms that act as clients for DotNetNuke modules. You will learn how these same techniques can be used to quickly extend DotNetNuke to mobile clients.

The panel I will participate in is:

DotNetNuke – The Road Ahead
In this panel discussion, the four co-founders of DotNetNuke Corporation will share their vision for the company and the DotNetNuke Open Source project. The resources, approach and business model required to manage and grow a large Open Source project such as DotNetNuke are substantially different than those required for a commercial software company. Get an inside look at how DotNetNuke Corp. is addressing today’s challenges while preparing for the future.

I hope to meet many from the DotNetNuke community at the conference.

by Nik Kalyani
Sunday, June 10, 2007 11:25:34 AM (Pacific Standard Time, UTC-08:00)

When importing photos from a digital camera or phone, the Windows import wizard allows me to give all the files a more descriptive name than "DSC10011.jpg." The problem I run into all the time is that I don't import photos more than once a week and this makes a common filename prefix pretty useless since the imported sets may contain multiple events.

Although it has bugged me to no end, until today I left this at the default and organized files manually into more descriptive folder names. Today I decided to fix this annoyance. I briefly checked out BatchPhoto and a couple of other utilities and concluded that they were all overkill. So I wrote a quick console app to take care of this problem.

FileNamer (not feeling very creative today, hence the lame name) is a very simple app that will accept one parameter -- a local or UNC path. It will then recurse every folder at that path and rename most photo and movie files (*.jpg;*.jpeg;*.mpg;*.mpeg;*.avi;*.wmv;*.mov) with the same name as the parent folder followed by a numeric serial number. If your photos are in C:\Docs\Picnic, the photos in this folder would be renamed to Picnic 0000.jpg, Picnic 0001.jpg etc.

The program has very limited error handling and I have no idea what happens when there are more than 10,000 files present (you should not have that many files in the same folder anyway). You will need .Net 2.0 to run the app. No installation is needed -- just copy FileNamer.exe to a location of your choice, fire up a command window and type:

FileNamer <path to rename>

The zip has the source which you can ignore if you don't intend to modify. Use the program at your own risk and be sure to test it with some junk files first.

 

FileNamer Source.zip (5.43 KB)
#    Comments [0] - Trackback    

 Tuesday, June 05, 2007
by Nik Kalyani
Tuesday, June 05, 2007 8:52:46 AM (Pacific Standard Time, UTC-08:00)

When opening an HTML file that sits on your desktop, IE will throw a security warning which you must click before the page is rendered. This is annoying, especially when the file is your own creation and there is no security risk. You can suppress the security warning by adding the "Mark Of The Web" (MOTW) to the top of your HTML document:

<!-- saved from url=(0014)about:internet -->

After adding this, you can launch the HTML file locally without any annoying warnings.

 Thursday, February 08, 2007
by Nik Kalyani
Thursday, February 08, 2007 6:49:51 PM (Pacific Standard Time, UTC-08:00)

As AJAX and Javascript widgets get more popular, it is not unusual to see Javascript from multiple parties running on the same page. This greatly increases the chances of collisions in variable and function names. For instance, two unrelated scripts might define the function “modifySomething()”. In this case, the last definition of “modifySomething()” on the page will be the one called. This is an invitation to disaster.

One way to prevent this is to practice defensive Javascript coding through the use of namespaces. In .Net and Java, the use of namespaces clearly delineates classes and prevents collisions. While Javascript does not have a built-in mechanism for using namespaces, it is relatively easy to implement them. In fact, just about every library such as Dojo Toolkit, Yahoo UI and ASP.Net AJAX provides a mechanism for registering and using namespaces in Javascript. This is fine if you are using one of the libraries, but if you are not, then how do you go about creating namespaces in your Javascript code. Read on.

Let’s create a simple “Cube” class with properties of Width, Height, Depth and methods grow() and shrink(). This class must reside in the “Speerio.Web.Solids” namespace.

If we try something like this: 

Speerio.Web.Solids.Cube = function(width, height, depth)
{
      this.width = width;
      this.height = height;
      this.depth = depth;
}

…we get an error. This is because Javascript expects to find an object “Speerio”, with a child object “Web”, which has a child object “Solids”. To make this work, we will first need to define a way to tell Javascript that the “Speerio.Web.Solids” hierarchy exists. We can do this by creating a function to create the hierarchy like this:

function $register(ns)
{
    var segs = ns.split(".");
    var namespace = window;
    for(var s = 0; s < segs.length; s++)
    {
        var seg = segs[s];
        if (typeof(namespace[seg]) == "undefined")
            namespace[seg] = new Object();
            
        namespace = namespace[seg];
    }
}

This function adds our namespace as a hierarchy of objects that are children of the top-level “window” object. It only works if the object has not already been defined, so it’s OK to register the same or similar namespaces multiple times. Now, it’s a simple matter of calling the function:

$register(“Speerio.Web.Solids”);

Once the namespace is registered, we can use it in our code as we would any other object. Since we are talking about defensive coding, let’s go further and define the “Cube” class.

Speerio.Web.Solids.Cube = function(width, height, depth)
{
       this.__width = width;
       this.__height = height;
       this.__depth = depth;
}
 
Speerio.Web.Solids.Cube.prototype =
{
       shrink : $Speerio_Web_Solids_Cube_Shrink,
       grow : $Speerio_Web_Solids_Cube_Grow,
       getWidth : $Speerio_Web_Solids_Cube_GetWidth,
       setWidth : $Speerio_Web_Solids_Cube_SetWidth
}

We start by defining the Cube class whose constructor takes three parameters — width, height and depth. In the definition of the class, these parameters are used to initialize properties __width, __height and __depth respectively. Why the underscores you ask? Mainly to discourage them from being directly modified. Javascript does not provide a set/get mechanism so to protect properties from being set directly, a small layer of obfuscation is necessary. It is not fool-proof…anyone studying your code will see this right away. However, it should be obvious that the intent is to protect the integrity of the data and prevent it from being modified directly.

Next, we define the various methods for the Cube class. For each method, the “public” method name is clear and simple. The actual method that does the work has a longer name. I used the following convention:

  • prefix all class methods with $
  • append the namespace and class name, replacing periods with underscores
  • append the name of the method, prefixed with “Get” or “Set” if the method is intended to be a property getter/setter

Now, we can define the actual methods:

function $Speerio_Web_Solids_Cube_Shrink()
{
    if ((this.__width > 1) && (this.__height > 1) && (this.__depth > 1))
    {
        this.__width--;
        this.__height--;
        this.__depth--;
    }
}
 
function $Speerio_Web_Solids_Cube_Grow()
{
    this.__width++;
    this.__height++;
    this.__depth++;
}
 
function $Speerio_Web_Solids_Cube_GetWidth()
{
    return(this.__width);
}
 
function $Speerio_Web_Solids_Cube_SetWidth(w)
{
    if (w > 0)
       this.__width = w;
}

And finally, some code to test the class:

var cube = new Speerio.Web.Solids.Cube(10, 10, 10);
cube.grow();
cube.grow();
cube.shrink();
alert("The cube width should be 11; the actual value is " + cube.getWidth());
cube.setWidth(100);
alert("The cube width should be 100; the actual value is " + cube.getWidth());

The above namespace-based class definition protects your code when it is running on a page where code from other parties is also executing. In addition the code is readable and likely easy to manage, even if months have elapsed since you last took a look at it. There may be a small performance hit the first time the script file is downloaded to the user’s browser due to the verbosity, but I’ll take verbose code that works over concise code that breaks the page any day.

#    Comments [2] - Trackback    

RSS feed
Search and Links
Bling

View Nik Kalyani's profile on LinkedIn

Contact me: nik*kalyani.com (replace "*")

TechBubble
www.flickr.com
This is a Flickr badge showing public photos from techbubble. Make your own badge here.
Statistics
Total Posts: 214
This Year: 32
This Month: 0
This Week: 0
Comments: 238
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008
Nik Kalyani
Sign In
All Content © 2008, Nik Kalyani