dans.blog


The miscellaneous ramblings and thoughts of Dan G. Switzer, II

Hackers Replace Al-Jazeera Web Site With American Flag

Hackers on Thursday replaced the English-language Web site for Arab satellite television network Al-Jazeera with a U.S. flag and the message "Let Freedom Ring."


UDF: component() for CFMX

Have you ever had the need to invoke an instance of a componet based upon it's relative path? I know I have, so I threw this little UDF together.

To invoke a component, you simply call the component() function using either the standard dot notation or you can specify either a relative or absolute path to the CFC. I tried to make the "type" argument somewhat intelligent and it'll probably work correctly 99% of the time for you, but if you want to be absolutely sure you get the expected behavior, specify the type argument for the function.

/****************************************************************
UDF: component(path, type)
Author: Dan G. Switzer, II
Date: 5/26/2004

Arguments:
path - the path to the component. can be standard
dot notation, relative path or absolute path
type - the type of path specified. "component" uses
the standard CF dot notation. "relative" uses
a relative path the the CFC (including file
extension.) "absolute" indicates your using
the direct OS path to the CFC. By default
this tag will either be set to "component"
(if no dots or no slashes and dots are found)
or it'll be set to "relative". As a shortcut,
you can use just the first letter of the type.
(i.e. "c" for "component, etc.)
Notes:
This is based upon some code that has floated around the
different CF lists.
****************************************************************/

function component(path){
    var sPath=Arguments.path;var oProxy="";var oFile="";var sType="";var sProxyPath = "";
    if( arrayLen(Arguments) gt 1 ) sType = lCase(Arguments[2]);

    // determine a default type
    if( len(sType) eq 0 ){
        if( (sPath DOES NOT CONTAIN ".") OR ((sPath CONTAINS ".") AND (sPath DOES NOT CONTAIN "/") AND (sPath DOES NOT CONTAIN "\")) ) sType = "component";
        else sType = "relative";
    }

    // create the component
    switch( left(sType,1) ){
        case "c":
            return createObject("component", sPath);
        break;

        default:
            if( left(sType, 1) neq "a" ) sPath = expandPath(sPath);
            // updated to work w/CFMX v6.1 and v6.0
            // if this code breaks, MACR has either moved the TemplateProxy
            // again or simply prevented it from being publically accessed
            if( left(server.coldFusion.productVersion, 3) eq "6,0") sProxyPath = "coldfusion.runtime.TemplateProxy";
            else sProxyPath = "coldfusion.runtime.TemplateProxyFactory";
            try {
                oProxy = createObject("java", sProxyPath);
                oFile = createObject("java", "java.io.File");
                oFile.init(sPath);
                return oProxy.resolveFile(getPageContext(), oFile);
            }
            catch(Any exception){
                writeOutput("An error occured initializing the component #arguments.path#.");
                return;
            }
        break;
    }
}

more…


UDF: xslt() for CFMX

I wrote this CFMX-based UDF a while ago, and I thought I'd share it. One of my big gripes about the xslTransform() function in CFMX is that it doesn't support passing parameters to the transformation engine.

Passing parameters can be extremely useful, as it'll allow you to do some conditional operations on in your XSL sheets based upon values determined by the ColdFusion.

In a nutshell, this UDF accomplish this by parsing the XSL stylesheet and looking for instances of the <xsl:param> tag name attributes that match the key in the structure you passed in. Once it's looped through the entire "Params" structure, it'll use the modified XSL stylesheet to do the transformation. Basically, it just temporarily hard codes those values in the param for you.

more…


IE and funkiness w/innerHTML property

Today I noticed a strange thing with Internet Explorer v6.x. It appears when using the innerHTML property to read the contents of an element, it must be doing some parsing to the entire DOM tree that the current element resides in. Here's how I noticed the problem.

First, it appeared that the larger the DOM tree was, the longer it took to recieve the value for an element. In my test loop, it took an average of 4 seconds to parse a table by looping through all the rows in the table retrieving the value of firstChild property for each cell. The speed increased dramatically to the range of about 36 seconds by just invoking the innerHMTL property instead of firstChild property.

Second, I noticed it would get faster as I removed elements from the table I was parsing. If I removed each row after processing the contents, it would get faster and faster as less elements where found in the DOM branch. I found this extremely odd and the combination of both points leads me to believe that retrieving the value of the innerHTML property of an element does more than just reads the value.

more…


"Where is Raed?" I Say "Where is Salam Pax?"

Many of you may have seen this link already, it's been floating around the net, if not I recommend checking out Salam Pax's blog at http://dearraed.blogspot.com/.

I've been following his blog for about a week. According to his blog, he's a young man living in downtown Baghdad. It's interesting reading a viewpoint which is coming from someone who's in Iraq. Essentially I get the feeling that the Iraq people are just plain scared—they'd prefer to stay anonymous to avoid standing out. It seems standing out just gets you in trouble.

Is this blog legit? I can't say, that's up for you to decide.


Blog May Be Erraditic...

If my blog is temporarily down (you get an error or anything else strange happens,) don't fear—I'm probably just updating the code. I'll be working to add more features and tighten up the code. I wrote this blog software *very* quickly.


Let Your Voices Be Heard!

You should now be able to leave comments on my blogs. I still have some things to work out and if you have any problems posting your thoughts, please send me e-mail.


War on Iraq: Video of POWs

Ok, so I've been watching tons of CNN over the past couple of days. You've got to take everything you see with a grain of salt and try to read between all the lines of propaganda. Regardless of who's news your watching, your watching the news that's going to be skewed to the view of the people producing the content—it's just human nature and it's to be expected.

One of the biggest news items over the past couple of days has been the news about the video that Aljazeera has been broadcasting. Normally I can't stomach watching human suffering—especially when it comes to death, but I've had the odd feeling I needed to see the video to really understand a few things.

Finally last night, I was able to track down the footage that Aljazeera's been showing. I'm posting the links below, but they contain extremely graphic images, so I'm warning you now. However, I also think it's important to view this information in order to better understand what's going on in Iraq.

more…


Welcome to my blog!

Well, it may be a little too little a little too late, but I've decided to start my own blog.

Currently, I'm not using any software, so I'll probably be updating the site to provide more standard blogging features—like the ability to comment, etc. Until then, I'll just be posting little tidbits and stuff.