Launched Just Rite Acoustics, Inc. Web Site

Another ColdFusion web site was launched for Just Rite Acoustics, Inc. located at www.justriteacoustics.com. In addition to acoustical ceilings, Just Rite offers "pre-manufactured acoustical wall panels, site-built acoustical wall systems, access floors and a specialty division that concentrates on difficult and unusual projects."

The site was originally built using tables and several images for the layout where most of the text was actually embedded into image slices. As you'll see, that has all changed. I've reconstructed the site using CSS, XHTML and of course Adobe® ColdFusion®.

In addition, we've added a fully customized back-end for the client to add or modify services, projects and even office locations.

A huge "Thank you!" goes out to Todd Sharp for his work on cfImageCropper which definitely came in handy on this project.

Congratulations Just Rite Acoustics on your web site facelift!

www.justriteacoustics.com
Developer: Stephen Withington

My Experience at cf.Objective() 2009: Day 1

I arrived just in time for Blue River's presentation on Mura CMS - an open source ColdFusion CMS (formerly known as Sava) at the Twin Cities ColdFusion User Group meeting. There was a little time in the beginning to enjoy some pizza and soda while catching up with some old friends and meeting many others for the first time. The Mura presentation definitely piqued my interest and I will have to set aside some time to learn more about it after the conference. Did I mention Mura CMS is 100% free and 100% open source? If you've ever desired a CMS that can accommodate your custom design, then you might want to give Mura a good look.

Immediately following the CFUG meeting, I moved on over the the opening night reception (also sponsored by Blue River/Mura CMS). It was great to finally meet so many people I've been in contact with via twitter, blogs, email, phone, etc. It's funny, but it seems like half the crowd is a who's who among ColdFusion bloggers: Ben Nadel, Sean Corfield, Marc Esher, Dan Vega, Phil Nacelli, Dan Wilson, Adam Haskell, Jason Dean, Peter Bell, Mark Drew, Terry Ryan and several others. In addition to the bloggers, I've also met many other interesting ColdFusion developers. It's so cool to hear how other people are using ColdFusion and about the projects they're working on.

I'm looking forward to meeting many more people over the next few days here at cf.Objective() 2009 and hope to be able to blog about some of sessions I'll be attending. Stay tuned!

My cf.Objective() 2009 Schedule

Luckily (for me anyway), last week a tweet from Adam Lehman (aka @adrocknaphobia and Product Manager for Adobe ® ColdFusion®) popped up on twitter that caught my eye:

So needless to say, I truly want to shout out a big "Thank You!" to Adam Lehman and Adobe for not wasting an extremely valuable ticket to cf.Objective() 2009!

Inspired by Oguz Demirkapi's recent post, I thought I'd also publish the sessions I'm planning on attending.

Wednesday, May 13th

  • 5:30 pm: Twin Cities ColdFusion User Group Presentation on Mura CMS
  • 7:00 pm: Opening Night Reception Sponsored by Mura CMS (Blue River)

Thursday, May 14th

  • 9:00 am: Adobe Keynote
  • 10:15 am: Introduction to OO Modeling and Design - Brian Kotek
  • 11:30 am: Taking Code Reuse to a Higher Level - Jeff Chastian
  • 1:45 pm: Building and Object Oriented Model - Bob Silverberg
  • 3:00 pm: Writing Testable Code: Real-World TDD - Marc Esher
  • 4:15 pm: still deciding between Atomic Reactor - Mark Drew, or RAD OO in Code - Peter Bell
  • 9:00 pm: Star Trek Group Trip at IMAX Theater in Apple Valley, MN

Friday, May 15th

  • 9:00 am: Mach-II 1.8 "Simplicity" - Features that make your applications easier and quicker to develop - Peter J. Farrell
  • 10:15 am: Build a ColdFusion-powered AIR application - Dan Wilson
  • 11:30 am: Building Applications for the Desktop - Samer Sadek
  • 1:45 pm: Object Relational Mapping with ColdFusion - Jason Delmore
  • 3:00 pm: ColdSpring, better living through configuration - Mark Drew
  • 4:30 pm: Mark Drew and Chris Scott's mystery science 3000 ColdSpring session
  • 7:00 pm: BOF: Peter Bell - Requirements and Estimating
  • 8:00 pm: BOF: Russ Johnson - Source Code Control with Git

Saturday, May 16th

  • 9:00 am: Leveraging Enterprise Open-Source Java in ColdFusion - Brian Kotek
  • 10:15 am: Web Application Project Management - Jeff Chastian
  • 11:30 am: Advanced ORM in ColdFusion 9 - Terry Ryan - Adobe
  • 1:45 pm: Behavior-Driven Development with cfSpec - Sean Corfield
  • 3:00 pm: Code Reviews and Mentoring - Adam Haskell
  • 4:10 pm: Closing Remarks

Looking forward to meeting many of you there! Please be sure to find me, if I don't find you first. Peace.

Using ColdFusion to Find a Mysterious String That When Hashed Returns Itself

After surfing around the web this morning, I was stopped by Elliott Kember's "The Kember Identity." Elliott is on a quest to find the 32-character hexadecimal string that when hashed, will return itself. He has even named this string the "Kember Identity Hash" and desperately wants to find out what it is ... assuming it even exists.

I noticed a few scripts had been posted for Ruby, Python, Java and PHP, but didn't see any ColdFusion code yet. So I whipped up a version and sent it off to him. I'm sure he'll get it up there, but I thought I would also post it here as well.


<!---
    Page:        getKemberIdentity.cfm
    Author:        Stephen J. Withington, Jr. (stephenwithington.com)
    Version:    20090501.00
    Purpose:    Challenge to find a string that when hashed, will return itself.
                See http://www.elliottkember.com/kember_identity.html for more information.
--->

<cfsetting requesttimeout="360" />

<cffunction name="getKemberIdentity" access="public" output="false" returntype="string"
            hint="I try to find a string that when hashed, will return itself.">

    <cfargument name="timesToTry" type="numeric" required="true" />
    <cfset var kemberResult = "" />
    <cfset var theRandomString = "" />
    <cfset var theHashedString = "" />
    <cfset var theIndex = "" />
    <cfloop index="theIndex" from="1" to="#val(arguments.timesToTry)#" step="1">
        <cfset theRandomString = RandomizeString() />    
        <cfset theHashedString = hash(theRandomString, "MD5", "UTF-8") />
        <cfif theHashedString eq theRandomString>
            <cfset kemberResult = "We found a winner: #theRandomString# = #theHashedString# = JACKPOT!!!!" />
            <cfreturn kemberResult />
        <cfelseif theIndex eq timesToTry>
            <cfset kemberResult = "." />
        </cfif>
    </cfloop>
    <cfreturn kemberResult />
</cffunction>

<cffunction name="RandomizeString" access="public" output="false" returntype="string"
            hint="pass me a string and desired length and I'll randomize it for you.">

    <cfargument name="theString" type="string" required="false" default="0123456789ABCDEF" />
    <cfargument name="theLength" type="numeric" required="false" default="32" />
    <cfset var randomizedString = "" />
    <cfset var theIndex = "" />
    <cfloop index="theIndex" from="1" to="#val(arguments.theLength)#" step="1">
        <cfset randomizedString = randomizedString & mid(arguments.theString, rand()*len(arguments.theString)+1, 1) />
    </cfloop>
    <cfreturn randomizedString />
</cffunction>

<cfoutput>#getKemberIdentity(100000)#</cfoutput>

So what do you think? Do you think this mystery string actually exists? Want to help find out?

Launched A ColdFusion + ActionScript + Flash Site: OurGreenIsBlue.com

OurGreenIsBlue.com was developed as one part of a larger initiative for Aqua-Aerobic Systems, Inc. located in Rockford, Illinois. The initiative focuses on going "blue" instead of the typical "green" since their primary business centers around "providing sustainable, innovative wastewater treatment solutions." In fact visit the site, "join their cause" and they will donate $1 to the WateReuse Foundation!

The site is powered by Adobe® ColdFusion® along with Adobe® Flash®, ActionScript 3.0 and Microsoft® SQL Server. The eye-catching design and interface was created by Gordon B.

http://www.ourgreenisblue.com/index.cfm
Designer: Gordon B.| Developer: Stephen Withington

Using ColdFusion's onRequestStart Method Adds Whitespace to Templates

After banging my head against my desk (which is glass by the way!) I finally figured out how to resolve an issue that may affect others out there using the ColdFusion onRequestStart method in their Application.cfc.

What Happened?
I was attempting to build a dynamic page that returned only text so that I could consume it in Flash using some ActionScript magic. After getting some errors from Flash, I decided to check the ColdFusion template I was trying to access. On the surface, everything looked fine. However, once I did a "View Source", I noticed that the ColdFusion page had some extra whitespace and carriage returns in it. This is not good, because ActionScript wants to read the entire document, whitespace and all!

So off I went, trying <cfsetting enablecfoutputonly="true">. That didn't do a thing! So I threw another CF bomb at it by wrapping everything in <cfprocessingdirective suppresswhitespace="true"></cfprocessingdirective>. Nothing. I know, you're thinking <cfsilent> aren't you? It was already there my friends, and nada. I'm telling you I removed every extra space in that template's code and didn't get any closer to getting rid of the extra space.

And that's when it hit me ... check the Application.cfc and see if there's anything in there that might be generating it. So off I went again, going through each line of code in my Application.cfc. I decided to start commenting out some of the methods to see what, if any, impact it might have on the template. When I worked my way down to onRequestStart() and commented it out ... everything worked as it should! Well, that's great! BUT ... I still wanted to use my onRequestStart() code.

So to start with, let's take a look at some generic onRequestStart code:


    <cffunction name="onRequestStart">
    
        <cfargument name="request" required="true" />
    
        <!--- re-start application from URL with ?init --->
        <cfif isDefined("url.init")>
            <cfset onApplicationStart() />
        </cfif>

    </cffunction>

In order to still use the onRequestStart method, it turns out all I have to do is remove any and all white space and carriage returns in the onRequestStart method. So the revised code would look something like this:

<cffunction name="onRequestStart" access="public" output="true" hint="Fires when prior to page processing."><cfargument name="request" required="true" /><!--- re-start application from URL with ?init ---><cfif isDefined("url.init")><cfset onApplicationStart() /></cfif></cffunction>

Hopefully this saves someone else from a sore forehead.

Avoid Errors From Declaring Routines in Multiple Templates With CFSaveContent

So, you've got a function that you use in more than one place in your application. In fact, you might even need to use it in more than one place on your page. For example, you have a function you apply to your navigational elements to highlight them if the link matches the current page. Problem is, you've got separate files for each navigational area; one for the sub-nav, one for the primary nav, one for the footer, etc. The "easy" solution obviously would be to just include it once and be done ... but then you start testing things and such eventually you wish there were a way to have it included on each external file, but not generate the error message: "Routines cannot be declared more than once."

Well, did you know that you can wrap your nifty little function in a CFSaveContent block? By doing so, you create a variable that can be tested for and if it doesn't exist, create it on the fly. Pretty cool, eh?

Oh ... you want to see what I'm talking about? Ok.

Let's continue with the original example I gave above. Here's a simple function that checks the URL against a navigational link and if a match is found, the function returns a special CSS class. If no match is found, it returns an empty string.


<!--- navon.cfm --->
<cfscript>
function navon(s) {
    var l = "";
    var i = "";
    for(i=1; i LTE listLen(s);i=i+1) {
        l = listGetAt(s, i);
        if(findnocase(l,cgi.script_name)) return " class=""nav_on""";
    }
    return "";
}
</cfscript>

Let's assume you maintain a separate file/template for your primary navigation and another for any sub-navigation. So maybe your primary navigation file looks something like this:


<!--- navPrimary.cfm --->
<cfinclude template="navon.cfm" />
<div id="topNav">
    <ul>
        <cfoutput>
            <li><a href="index.cfm"#navon('index.cfm')#>Home</a></li>
            <li><a href="/about/"#navon('/about/')#>About</a></li>
            <li><a href="/contact/"#navon('/contact/')#>Contact</a></li>
            <li><a href="/etc/"#navon('/etc/')#>Etc.</a></li>
        </cfoutput>
    </ul>
</div>

Here's a sample sub-nav:


<!--- navSub.cfm --->
<cfinclude template="navon.cfm" />
<div id="topNav">
    <ul>
        <cfoutput>
            <li><a href="/contact/index.cfm"#navon('/contact/index.cfm')#>Contact Main</a></li>
            <li><a href="/contact/form/"#navon('/contact/form/')#>Info Req. Form</a></li>
            <li><a href="/contact/directions/"#navon('/contact/directions/')#>Directions</a></li>
        </cfoutput>
    </ul>
</div>

Now, if we were to execute the following code:


<!--- index.cfm --->
<style type="text/css">
a {
    color: #0000FF;
}
a.nav_on {
    color: #CC0000;
}
</style>
<cfinclude template="navPrimary.cfm" />
<cfinclude template="navSub.cfm" />

You should see an error message similar to the following:

All we have to do is wrap the function in a warm blanket of CFSaveContent like so:


<cfsavecontent variable="request.navScript">
    <cfscript>
    function navon(s) {
        var l = "";
        var i = "";
        for(i=1; i LTE listLen(s);i=i+1) {
            l = listGetAt(s, i);
            if(findnocase(l,cgi.script_name)) return " class=""nav_on""";
        }
        return "";
    }
    
</cfscript>
</cfsavecontent>

Then on each of the nav files, wrap the CFInclude block with a CFIF like so:


<cfif not isDefined("request.navScript")>
    <cfinclude template="navon.cfm" />
</cfif>

Now if you try to pull up the index.cfm page created earlier, you should see something like this:

Now you can dynamically check to see if the function already exists ... and if it doesn't, create it.

Cheers!

Use ColdFusion's CFFeed to Display Your Twitter Tweets (and more!) on Your Blog in 30 Seconds

As Twitter's popularity continues to increase, users and consumers of the information being broadcast are looking for quick and easy ways to integrate some of the information into their own content. So I whipped up this short, but sweet, example of how easy it is to repurpose content from Twitter using just a dash of ColdFusion.

First things first though, what makes consuming information from Twitter so easy is their search functionality. Check it out at http://search.twitter.com. By following the instructions there, you will see that anything you search for can be "burned" via RSS. After your search, following the link "Feed for this query" and viola! Instant RSS feed you can now consume. How sweet it is.

What's really cool is that if you search for let's say "stevewithington" you can see not only my posts, but also any responses too. If you only want to see tweets "from" me for example, then you simply put "from:" in front of your search criteria such as "from:stevewithington."

For sake of simplicity, I'm going to just follow the "Feed for this query" link and continue on.

If you're using ColdFusion 8, then all you have to do is use CFFeed to consume the feed. Here's a sample line of code:


<cfset feedurl="http://search.twitter.com/search.atom?q=from%3Astevewithington" />
<cffeed
    source="#feedurl#"
    properties="feedmeta"
    query="feeditems" />

If you're curious as to what the feed contains, you can always use CFDump to find out:


<cfdump var="#feeditems#" label="feedItems" />

Using the above line of code, you should see something similar to the following:

As you'll see, CFFeed creates a very nice query object containing quite a bit of information for you. One field of interest at this point is the "CONTENT" field which contains HTML-formatted code for each tweet. If you prefer a "text-only" version of the tweet, then simply use the "TITLE" field. So, to show how easy this is, let's just loop over the feed items and output the "CONTENT."


<ol>
<cfoutput query="feeditems">
    <li>#content#</li>
</cfoutput>
</ol>

Running the above line of code, you should see something like this:

I know, I know, you're probably thinking, "there's got to be more to it, right?" Well, there is if you want there to be! Using CFDump, you saw all kinds of information you can repurpose to your heart's desire. Think up new ways to use Twitter and with ColdFusion's CFFeed you can create new ways to consume it's easy-to-integrate-and-embed information.

Another ColdFusion Site is Launched for Mendelssohn Performing Arts Center

Mendelssohn Performing Arts Center's web site has officially been redesigned and re-launched. The Mendelssohn Performing Arts Center "provides quality music for people of the Rockford area through live performances by local and world renowned artists."

Using the power of Adobe® ColdFusion® along with CSS, XHTML and Microsoft® SQL Server, I was able to bring Jaci M.'s sophisticated design to life.

The site features a fully integrated secure shopping cart with payment processing via PayPal. The "all-in-one" customized cart solution accommodates tickets, subscriptions and dues. The site also features a comprehensive back-end to allow for easy maintenance of concerts, venues, subscription packages, performing artist dues and more.

http://www.precisiongovernors.com
Designer: Jaci M. | Developer: Stephen Withington

Launched ColdFusion-Powered Web Site for PG Engineered Control Solutions

This morning, I launched another ColdFusion web site for PG Engineered Control Solutions (a.k.a. PrecisionGovernors.com), who "has a long history of innovative system implementations for electromechanical, electrohydrolic and engine management."

As usual, I built the site from the ground up using Adobe® ColdFusion® along with CSS, XHTML and of course Microsoft® SQL Server. Some of the more "static" areas of the site were optimized for use with Adobe® Contribute® CS4.

Many thanks to Greg L. for the squeaky clean design!

http://www.precisiongovernors.com
Designer: Greg L. | Developer: Stephen Withington

More Entries

© 2009, Stephen J. Withington, Jr.  |  BlogCFC was created by Raymond Camden – Version 5.9.004

Creative Commons License  |  This work is licensed under a Creative Commons Attribution 3.0 Unported License.