# Sunday, October 29, 2006


For the last client I worked for, we extensively modified a MochiKit port of a well-known 'Lightbox' implementation so that it would utilize IFrames - the users of the application loved it because they were used to primitive JavaScript alert and confirm boxes, and since a modal dialog was still the appropriate thing to do, it worked well.

A short time later, I found ThickBox - seems to be a much better implementation of this now-common technique, and I thought it might prove useful to have a MochiKit version of it in case I decide I want to use it (it is built on jQuery, which I don't personally use or care for, notwithstanding the library having a few useful constructs that I would like to see ported over to MochiKit).

In porting this script, I tried not to 'improve' it at all; i.e. I left nearly everything as-is with regards to naming conventions, use of certain constructs that I would like to improve, etc. and leave it up to you, if you choose to download it, to make any changes you see fit. Of course, any bugs you find would be great to know about, as well as ideas for enhancements, etc. and I will probably update this when I get time, because I would like to do things much differently (maybe I am smoking crack, but this whole idea of connecting to things based on the value of the 'class' attribute of a tag just seems stupid to me...).

My port of ThickBox isn't perfect and I did it as quickly as I could because I wanted to get it into the hands of those smarter than I - that means you. There are places in the code that are inconsistent and I will be working on that, but for now it does the job and should be a good starting point for those that find this useful.

Download ThickBox for MochiKit.

Kick It on DotNetKicks.com

posted on Sunday, October 29, 2006 11:02:53 AM (Mountain Standard Time, UTC-07:00)  #    Comments [2]
# Wednesday, September 13, 2006

It seems that Ajax.NET Pro has finally been open-sourced, and with a great license. I have been waiting for this to happen for a very long time now; Michael has released source code before, but it was just a snapshot of a specific version and you couldn’t really do anything with it according to the license he released it under. It seems that things are finally changing for the better with this library, this is a step in the right direction. Of course, as soon as Atlas is finally released, will it matter?
Kick It on DotNetKicks.com

posted on Wednesday, September 13, 2006 10:05:06 AM (Mountain Daylight Time, UTC-06:00)  #    Comments [1]
# Tuesday, August 15, 2006

A few years ago, for a short time, I worked at Neumont University (was "Northface University" until a certain company had issues with the name) with one Jonathan Ellis; a few months after he left NU, he told me about his new job at Berkeley Data Systems: they have a great product/service called Mozy which provides a really simple-to-use application that does backups of the data on your Windows machine. In the past I would back-up my data to DVDs and CDs, and while I still do that from time to time, the main problem is location – I store these discs in the same location as the computer that contains the data, so that if my house went up in flames or was broken into, I could still lose my data. Obviously, offsite storage is the answer, but what am I going to do? Run some discs over to my in-laws? It would work, but that is not the most convenient option, and what if the data changes on a fairly regular basis?

You may already know that offsite backup solutions have been around for a long time, and this is an established means for solving the “problem” of how to handle data backups, but Mozy is much cheaper than any other similar service available. In fact, if you don’t mind them emailing you once a month or so with some targeted advertising (i.e. ‘spam’ – but this is actually worthwhile spam), you can get 2GB of free backup storage space. Now, 2GB isn’t much if you are interested in backing up images, video, music, etc., but if you have a lot of source code or Word documents, etc. it may be adequate – and they will give you an extra 256MB for every user you refer, once that user has completed their first backup. If you don’t mind paying a little bit of money, you can upgrade to 30GB for $4.95 a month. Compare that to other services – you will be amazed at what a great deal Mozy represents; here is their (humorous) list of alternatives to using it:

  • Burn a new CD or DVD every Sunday night and store them at your brother-in-law's office.
  • Pay $200/year for an online backup service that uses old, mediocre software.
  • Buy a $200 external hard drive and hope your office doesn't burn down.
  • Do nothing and don't worry about backup. (We suggest closing your eyes, plugging your ears and repeating "I'm in my happy place, I'm in my happy place.")
  • Run a cron job of rsync, gzip and mcrypt piped over ssh to your friend's server over his DSL line.

Obviously, this is a slightly biased list, but there is truth to it nonetheless. A few things to note: their backup of your data is secure – SSL over the wire and then the data itself is encrypted using a key you provide or you can trust their use of the 448–bit power of the Blowfish algorithm; the backup is differential, so you don’t have to worry about large, time-consuming backups (except for the first time or any subsequent points in time where you decide to backup new, large files or sets thereof); Mozy does in-place upgrades to its software, automagically notifying you when they are needed; the application is small and uses a small amount of memory (usually around 12MB of my RAM).

I have been using Mozy for over a year now, if I remember correctly, and I have loved it. I have never needed (thankfully) to perform a restore on any files, so I can’t speak to how easy that is, but from all appearances, it doesn’t look like rocket science. The peace of mind I have from using it has been worth every piece of email I have ever received from Mozy. Give it a try and see if you don’t discover the same.

For some captioned screenshots of various aspects of the Mozy experience, expand this section:

Mozy runs in the system tray, and a tool tip tells you when the last backup occurred:

System Tray Tooltip

The context menu is fairly simple:

System Tray Menu

Choosing Status from said context menu gives you the following:

Status Dialog

If you choose Configure from either the context menu of the system tray item or the above status dialog:

LoadingConfig

If you know that you want to backup all files of a few certain types, the Backup Sets feature is nice:

BackupSetsTab

If the Backup Sets feature is too high-level for you, the File System tab lets you get as granular as you want:

FileSystemTab

There are three types of backups: manual (see the earlier Status dialog), automatic (checks CPU usage stats as well as idle time), and scheduled. You can specify that you want to be alerted if a backup has not occurred in n days.

ScheduleTab

The options are pretty self-explanatory:

OptionsTab

Want to know specific details about a given backup incident? This History is also available via a button on the Status dialog.

HistoryTab

Kick It on DotNetKicks.com

posted on Tuesday, August 15, 2006 8:51:47 AM (Mountain Daylight Time, UTC-06:00)  #    Comments [0]
# Friday, August 04, 2006

I have had my head buried in things at work so much that apparently I missed this Fjax thing; I came across it via this great post which derides it.

I couldn't agree more with Simon's assessment of the situation; just as he does, I plead with you to 'just say no' to this ridiculousness. What drives people to this? I wish I could have been there at the genesis of the idea so I could have tried my best quash it. Of course, some other idiot would have undoubtedly come up with it eventually.

While Simon (and many others) like the idea of using Flash for client-side storage, I don't know if I can agree with that either. Using Flash for much of anything other than animations like those found at HomestarRunner.com just seems wrong to me. :P

 

Kick It on DotNetKicks.com

posted on Friday, August 04, 2006 4:06:05 PM (Mountain Daylight Time, UTC-06:00)  #    Comments [0]

As much as it seems unwise to do so, I have started working on a JSON parser for .NET - why? Good question. Well, I have long used a certain library for doing "AJAX" with ASP.NET, and I don't much care for the way it handles some things with regards to dealing with client-side objects (i.e. JavaScript objects). Yes, there are other JSON-to-.NET libraries around, but what fun is that?

So, I am going to try to get something like this to work for myself. All I need to do is get a JSON string like "[1,2,3]" to convert to an integer array, right? Right! Not to mention getting any other JSON string to convert to an equivalent .NET type on the server, but that will be cake. ;) So, first thing I did was take the open-source and librerally-licensed JSON syntax checker implemented in C and convert it to C# (got the main file, JSON_checker.c done, haven't got to the UTF stuff yet). I ran it against all of the supplied tests (and a few of my own) and things are looking good (i.e. all the tests passed). This thing is implemented with a finite state machine - and it is hella-fast.

So, as it states on that site, the checker "could be adapted to produce a very fast JSON parser." Indeed. Using the state transition table and lots of stepping through the code and stepping through my brain, I have come up with a few ways (all of which need more work) of how I would create .NET objects from JSON using this tool. I am really having to reach back to my CS education to think about what data structures would be most appropriate for use in the process. Matching the json objects to their .NET counterparts is hopefully as simple as looking at the expected type and using reflection to instantiate it with the JSON data.

Well, anyway - who knows what will happen? My brain has been so fried lately that I don't know if I am heading down a dead-end or not. I want to create a simple, fairly bare-bones AJAX lib for use with ASP.NET that is built on top of MochiKit, since it is the best JavaScript library around. As much as I don't want to, I know someday I may need to learn Atlas, but I would rather not - it seems like it is going to be a pain in the rear. I am sure I will change my mind; after all, if Microsoft serves it to us on a platter, it must be good . . . right? :P Probably good like using DataSets as business objects...

Have you seen Script#, "a project for enabling script authoring via C#?!?!" Help me live, you have to be kidding me! I know it is hard to have code strewn across .js files, .aspx files, and .aspx.cs files, but I *really* don't like the idea of having all of my code in C# and have it magically converted to JavaScript. I mean, yeah, I suppose it is kind of cool in a weird, freaky geeky way, but I don't think I want to write code like that. Maybe I will sing a different tune a year or two from now, but something about it just seems . . . wrong. I am sure it is just me, I mean, Nikhil is a smart guy, much smarter than I, right? I'm pretty sure of it...99% at least.

Kick It on DotNetKicks.com

posted on Friday, August 04, 2006 12:50:33 AM (Mountain Daylight Time, UTC-06:00)  #    Comments [1]
# Sunday, April 30, 2006

In case you don't know about him, Stephen Colbert is the funniest guy around. He has a show (The Colbert Report (pronounced 'the coal-bear re-poor' - both t's are silent)) that parodies conservative talk shows such as The O'Reilly Factor, with Colbert playing an overt egomaniac who relies more on his gut feeling than rational thought. It is somewhat difficult for me to explain exactly why this show is so hilarious, which is why you had better sample it for yourself.

So, I just watched a re-broadcast of yesterday's annual White House Correspondents' Dinner event on C-Span, at which Stephen Colbert was the final guest speaker. Let's just say that he rocked. His sarcastic wit was in rare form as he skewered President Bush and various other people and institutions. Unfortunately, it has been reported that not everyone thought he was so funny; with Colbert's comments hitting so close to home, maybe Bush should find some the humility needed to examine his actions and those of his administration a little more closely (not that he would listen now).

Tonight the real Stephen Colbert (as opposed to the Stephen Colbert character he plays on The Colbert Report) will be featured on 60 Minutes. Also, if you find the samples of the show funny, and don't get Comedy Central on your TV, think about purchasing 16 episodes for the low price of $9.99 from iTunes (16 episodes, which is a full month's worth). That is how I get my Colbert fix, and I highly recommend it.

[UPDATE: Here is a full transcript of what was, essentially, a roast of Bush by Colbert.]

Kick It on DotNetKicks.com

posted on Sunday, April 30, 2006 2:35:18 PM (Mountain Daylight Time, UTC-06:00)  #    Comments [0]
# Saturday, January 14, 2006

I use SourceGear's Vault for source control (v2.0.6 - I do not have the money to upgrade nor feel I would get much by doing so) and don't care much for the diff/merge tool that came with it (nor is the newer version any better), so I use the free and open source KDiff3 instead.

In order to integrate the two, open the Vault client application, select the Options item in the Tools menu, change the program in both the diff and merge sections so that it points to the KDiff3.exe file, and use the following arguments strings:

For Diff:
 "%LEFT_PATH%" --fname "%LEFT_LABEL%" "%RIGHT_PATH%" --fname "%RIGHT_LABEL%"

For Merge:
 "%BASELINE_PATH%" "%OTHER_PATH%" --fname "%OTHER_LABEL%" "%WORKING_PATH%" --fname "%WORKING_LABEL%" -o "%DEST_PATH%" --fname "%DEST_LABEL%"

Note that you must include a space character at the beginning of each of these argument lists - maybe there is a good reason SourceGear designed things this way, but off of the top of my head I can't think of a good reason; it merely causes frustration if you forget.

I hope this is useful to someone, I have to have this information each time I run Vault somewhere new, and I get tired of losing it (not that it is all that hard to figure out, I simply want to save some time and reduce the tedium of the task).

[UPDATE: Added label information in the argument lists]

Kick It on DotNetKicks.com

posted on Saturday, January 14, 2006 11:11:30 PM (Mountain Standard Time, UTC-07:00)  #    Comments [1]
# Friday, January 06, 2006


I was recently working on a project where we needed to queue ajax calls on the client, and when I went looking for a JavaScript queue, was only able to find one that used certain JavaScript Array object functionality (shift() and unshift()) that does not work in IE 5.0, which we needed to support (argh). I only needed minimal functionality for that project, but I figured I might use this on my own so I came home and wrote this:


///////////////////////////////////////////////////////////////////////
/////////////////////////////// Queue /////////////////////////////////
///////////////////////////////////////////////////////////////////////
// This Queue works in older browsers where the shift() and unshift()
// methods of the later versions of the Array object, which are often
// used in other queue implementations, don't work.
function Queue()
{
    this.dequeue = Queue_Dequeue;
    this.enqueue = Queue_Enqueue;
    this.clear = Queue_Clear;
    this.count = Queue_Count;
    this.contains = Queue_Contains;
    this.peek = Queue_Peek;
    this.toArray = Queue_ToArray;
    this.m_Queue = new Array();
}
function Queue_Enqueue(value)
{
    if (value != null)
    {
        this.m_Queue[this.count()] = value;
    }
    else
    {

        throw new Error("Cannot place null value into Queue");
    }
}
function Queue_Dequeue()
{
    var objectAtFront = this.m_Queue[0];
    var temporaryQueueArray = new Array();
    for(var index = 0; index < this.count() - 1; index++)
    {
        temporaryQueueArray[index] = this.m_Queue[index + 1];
    }
    this.m_Queue = temporaryQueueArray;
    return objectAtFront;
}
function Queue_Peek()
{
    var objectAtFront = this.m_Queue[0];
    return objectAtFront;
}
function Queue_Contains(value)
{
    var currentIndex = 0;
    var quantityToInspect = this.count();
    while (quantityToInspect-- > 0)
    {
        if(value == this.m_Queue[currentIndex])
        {
            return true;
        }
        currentIndex = (currentIndex + 1) % this.count();
    }
    return false;
}
function Queue_Clear()
{
    this.m_Queue = new Array();
}
function Queue_ToArray()
{
    return this.m_Queue;
}
function Queue_Count()
{
    return this.m_Queue.length;
}



I haven't yet used it myself in anything, other than basic testing, but it does the basics and maybe someone can find use for it. It isn't rocket science, but in a pinch it sure beats spending the time to write your own (especially if supporting older browsers is important to you).

 

Kick It on DotNetKicks.com

posted on Friday, January 06, 2006 12:08:36 AM (Mountain Standard Time, UTC-07:00)  #    Comments [2]
# Tuesday, December 27, 2005


For those that use Paul Wilson's O/R mapper, here are some additional templates for generating a framework around that tool. While Paul Welter provides templates for this purpose, I don't particularly care for the pattern used in his generated classes (follows the 'Active Record' design pattern, AFAIK).

I personally don't like having business objects that 'know' anything about the concept of persistence (saving, retrieving, etc.); while this is a relatively common way of doing things (I did the same thing in the past), it doesn't work for me any longer simply because of my current personal opinions as it pertains to application architecture. Granted, 'it depends' on the application - I simply don't find myself ever needing to write an application using that pattern. :P

There is a readme.txt file that contains more than enough verbosity on what these do/don't do. However, here are some big ones:

  1. These have been verified to work in the following versions of CodeSmith (i.e. I have tried them in these versions, they may also work in others as well, YMMV):
       v2.6 (the 'free' version)
       v3.1.6
  2. These generate C# code.
  3. These have been used against SQL Server 2000 (theoretically, they work against any that CodeSmith and WilsonORMapper support)
  4. They currently target v1.1 of the .NET Framework (though they work against 2.0 as well, they simply don't support generics (yet)).

I hope someone finds these useful.

Thanks.

Kick It on DotNetKicks.com

posted on Tuesday, December 27, 2005 11:47:38 PM (Mountain Standard Time, UTC-07:00)  #    Comments [2]
# Monday, November 21, 2005

Most of the time, I am happy writing ASP.NET applications; I have been doing web development for almost 5 years, beginning with 'classic' ASP. As time goes on, I find myself writing more and more software for myself and this tends to be of the WinForms variety. Currently I am developing some software to help manage the seemingly unmanageable quantities of digital pictures that my wife and I have amassed over the last 5 years. I am still in the architecting phase of the project, but when I go to design the UI, I want to use something that will make it look slick (read: make it look familiar so that my wife will feel comfortable using it).

Via a post by Jay Kimble, I found out about a free (even for commercial use!) toolkit that provides some slick UI controls for WinForms applications (targeted at Visual Studio 2005 and 2.0 of the .NET Framework); it is called The Krypton Toolkit, and I plan on seeing how I can fit it into the aforementioned application's client piece. You can download this toolkit from Component Factory's website.

Kick It on DotNetKicks.com

posted on Monday, November 21, 2005 10:01:55 PM (Mountain Standard Time, UTC-07:00)  #    Comments [0]