Our New Arrival!

Our little girl, Meagan Amelia Schofield, finally got here on August 18, 2008 at 3:07 pm. She was 6 lbs. 7 oz., 19 inches and just cute as a button. Being biased towards my own children makes a difference. Here, judge for yourself:

Meagan Amelia Schofield

Kelsea and Andrue just can't get enough of her... until she starts crying or makes funny noises in her diaper.

Kelsea, Andrue and Meagan Schofield

Mommy is doing fine. In fact, everything went so well that the doctors let them go home from the hospital after only 24 hours (we're usually there at least 48). Also, I'm sorry I don't have pictures of Mommy yet. Being a proud new papa in a semi-wakeful-delirium for 36 hours makes you a little cookoo. We'll post more picture later.

Thanks for visiting! Leave a comment and say Hi!

MySQL is Looking Pretty Cool

OK. You may think I'm crazy, but, I just started working with MySQL for the first time. That's right. I've never used MySQL until now. However, to compensate, I've been using PostgreSQL and SQL Server for the past 7 or 8 years. Now, I played with MySQL while I was attending USU but never got into it too much because, back then, it wouldn't even enforce primary and foreign keys. Thus, frankly, I brushed it off.

Also, when developing web sites, I've had several opportunities to work with MySQL but because SQL Server was available, and I was already familiar with it, I used it instead.

Anyway, I have to admit MySQL is awesome. It's come a long way since I last worked with it in college. One thing I really like: its so darn easy to backup and restore a DB. Plus, it's fast, it's reliable, and, best of all, it's open source and free. I highly recommend it.

CSS Ordering and Multiple Classes

I've recently needed to assign more than one CSS class to an html element. I didn't know this was possible until I tried it (I know a lot about CSS, just not everything).

You assign more than one class to an element by adding each class separated by a space to the class attribute of the element:

class="cssclassa cssclassb"

This works in both FF 2 and IE 6 & 7. I'm quite sure it works with everything else (someone can prove me wrong if they wish).

Afterwards, I wondered which CSS class will take precedence when more than one class assigns a different value to the same CSS property. So, I setup some CSS styles as follows:

<style type="text/css">
   .cssbgA {background-color:black;}
   .csscolorA {color:yellow;}
   .cssbgB {background-color:green;}
</style>

And setup a html element:

<p class="cssbgA csscolorA cssbgB">Here is some paragraph text.</p>

The browser output looks like this:

Output for <p>

If I rearrange the classes to:

<p class="cssbgB cssbgA csscolorA">Here is some paragraph text.</p>

The output is the same:

New output for <p>

Hmmm, nothing changed. So, I played with it for a minute or two and found that the display will change when the order of the classes is changed in the CSS itself; not the class attribute of the html element! So, if I change the CSS to:

<style type="text/css">
   .csscolorA {color:yellow;}
   .cssbgB {background-color:green;}
   .cssbgA {background-color:black;}
</style>

The output changes to:

The output has changed!

It seems the last class rendered by the browser takes precedence over previous classes.

Interesting. I guess I could have looked this up in the W3C specs. But I'm too lazy, this was much more fun, and I don't have time to run through their docs.

Lawed into Lawlessness

I hate the title "Lawmaker." The word connotes that there is a reason to continue to make laws. To which I disagree. There is no reason for continuing to "make" new laws but every need to revise or revoke old ones. We've assumed lawmakers know what they're doing because we put them there based on their "desire" to serve and how many babies they're holding in their TV ads. Representative Chris Cannon in his recent re-election bid implemented this pathetic "I love babies, so vote for me" scheme in his TV ads. He and others must think we're stupid. Which is one likely reason he lost to Jason Chaffetz.

Contrary to popular belief, you will never know how well a lawmaker performs their responsibilities until its too late. They're already there. And since most average citizens won't take action until a law directly affects personal economies or properties, they put the issue on the back burner and go on with life. Damn that's frustrating.

Every year media reports highlight the numerous changes or additions to laws within Utah. This year there were 300 or so new laws enacted by our Legislature. Thankfully, a lot of those new laws were actually changes to old laws. Hmmm... progress.

Sometimes I ask myself, "How many more laws are necessary?" If legislators continue to make laws to enact consequences on lawbreakers, when does it become so burdensome that the populous must fight back? We could be "lawed into lawlessness."

Now, not all laws provide punishments, some provide additional rights to citizens (either by revoking or adjusting old laws or, rarely, new laws). I'm thinking those type of laws are not very common. But then I'm no law expert...

Just a random thought.

Learning New Code

I love a new challenge and my new job is just that. I'm very comfortable with ColdFusion and consider myself an advanced CF developer, although my advanced certification happened in 2004. While I've done plenty of it, I'm not so well versed in AJAX, script.aculo.us, RIA, etc., which is what my new job does a lot of.

Its out of my comfort zone, but that's what makes it cool.

Using cflogin Properly

So, I've just been implementing cflogin on one of my web sites. With 5+ years experience in ColdFusion this may seem odd, but, in my defense, my team implemented a little more comprehensive security and authentication system which did not use cflogin.

Thus, I had a hard time finding a problem with my cflogin code, which is in my Application.cfc:

<cfset var qrylogin = "" />

   <cflogin>
      <cfif IsDefined("form.username")>
         <cfquery name="qrylogin" datasource="#application.dsn#">
            SELECT * FROM lwm_user
               WHERE username = <cfqueryparam value="#form.username#" cfsqltype="cf_sql_varchar" />
                  AND password = <cfqueryparam value="#Hash(form.password)#" cfsqltype="cf_sql_varchar" />;
         </cfquery>
         
         <cfif qrylogin.RecordCount EQ 1>
            <cfloginuser name="#form.username#" password="#form.password#" roles="#qrylogin.role_list#" />
            <cflocation url="#cgi.http_referer#" addtoken="false" />         
         </cfif>
      </cfif>
      

         <cfinclude template="/CStores/content/includes/login.cfm" />
         <cfoutput>#getSimpleFooter()#</cfoutput><cfabort>

   </cflogin>

I quickly found that this code would not work properly. I was expecting to use getAuthUser() and isUserLoggedIn() but found they contained [empty string] values.

I began to search beyond my bubble and looked into Ray Camden's Lighthouse code and found the solution:

<cfset var qrylogin = "" />
   <cfset var showLogin = true />
   
   <!--- Check to see if they are logged in. CMS --->
   <cflogin>
      <cfif IsDefined("form.username")>
         <cfquery name="qrylogin" datasource="#application.dsn#">
            SELECT * FROM lwm_user
               WHERE username = <cfqueryparam value="#form.username#" cfsqltype="cf_sql_varchar" />
                  AND password = <cfqueryparam value="#Hash(form.password)#" cfsqltype="cf_sql_varchar" />;
         </cfquery>
         
         <cfif qrylogin.RecordCount EQ 1>
            <cfloginuser name="#form.username#" password="#form.password#" roles="#qrylogin.role_list#" />
            <cfset showLogin = false />
         </cfif>
      </cfif>
      
      <cfif showLogin>
         <cfinclude template="/CStores/content/includes/login.cfm" />
         <cfoutput>#getSimpleFooter()#</cfoutput><cfabort>
      </cfif>
   </cflogin>
   
   <cfinclude template="#arguments.targetPage#">

The difference is I got rid of the cflocation after validation and added the showLogin variable to include the login form if needed. This worked perfectly. Some thoughts:

1) I'm assuming that the </cflogin> tag needs to be completely parsed in order for the login to complete. Because I relocated before the </cflogin>, nothing was happening.

2) While placing the login code and query in the Application.cfc is convenient, I'm not sure if this is the proper place for it. I guess, I could move it into a component which just makes it a little more modular. However, this location is great especially for this application where authentication is required anywhere in the system. Need to figure out a way to implement it in only certain places of the site.

3) I'm thinking we could have used this in my previous project. It's so easy to implement. But why make it easy when you can do it yourself?! Duh.

Basic Report Building

We're revamping a report building feature for one of our products. It was interesting to see the similarities between all of the necessary reports:

1) DATA: The information for which you wish to analyze. For our system, its the number of applications submitted for services.

2) DATE RANGE: Filtering based on when the applications are submitted (for our system). Generically, the date range of when the process occurred to produce the data your querying.

3) BREAKDOWN: The interval at which to tally subtotals. For example, we wanted to see the number of appplications submitted monthly (or yearly, or weekly, or daily, quarterly, etc.)

I realized this pattern was similar across all of the reports we wanted to generate. This made the queries so much easier to consolidate and reuse. Hopefully, it will make the reports section of our product so much more valuable and usable. Its too bad I probably won't get see the finished project.

Referencing XML Attributes in ColdFusion

I was having a little problem with referencing some XML attributes in a ColdFusion XML object. Essentially, I couldn't reference them even though they were defined. My original code was:

<cfloop from="1" to="#ArrayLen(xmlObj.XmlRoot.XmlChildren)#" index="r">
<cfset elemAtt = xmlObej.XmlRoot.XmlChildren[r].xmlAttributes />
<cfset attName = elemAtt.name />
....
</cfloop>

When processing, ColdFusion kept returning "variable 'name' is not defined in elemAtt." So I proceeded to insert dumps, isdefineds, etc. to verify that it was there; and it was! So, after 20 or 30 minutes of working on this, it came to mind to copy the struct and then reference it. Like this:

<cfloop from="1" to="#ArrayLen(xmlObj.XmlRoot.XmlChildren)#" index="r">
<cfset elem = Duplicate(xmlObj.XmlRoot.XmlChildren[r].xmlAttributes) />
<cfset attName = elemAtt.name />
....
</cfloop>

This worked perfectly. Not sure why I couldn't reference it without the duplicate. It obviously had something to do with the attributes within the XML Object not really being a struct. But using the duplicate function, it copies the attribute struct as a struct (if that makes sense) and then it can be referenced normally.

I'll have to investigate the reasoning later.

Difficult Decision for the Better

I just resigned as Chief Technical Officer and Director of Product Development for Dynamic Screening Solutions, Inc. It was a very difficult decision but in the end I believe it will be for the best.

I learned about a ColdFusion opportunity just a few weeks ago. It was a ColdFusion development job for a new startup company based in Salt Lake City called Mondo Power, Inc. While I can't disclose much information about what they do, I will say that I was impressed with the team, their ideas, and outlook. I met with them personally, listened to what they're doing and where they plan to go, and decided that I wanted to get involved.

So, what will happen to DSS? I think they'll continue on with their current contracts and do just fine. Their biggest challenge: focusing on new development for new products. If they don't overcome this weakness, DSS will remain a stale company with little growth.

There seems to be this idea roaming from upper management that I'm irreplaceable. Well, they've got to find someone to succeed me whether that person replaces me or not. My successor will bring new ideas, skills, and abilities to the table that I didn't have. They'll be able to look at things very differently (which is a good thing). They can ask the questions I didn't know to ask. They may or may not have my people skills, technical skills, or competencies, but a good skilled developer can get the job done.

While I'm saddened about leaving DSS, I look forward to this new challenge. I will always appreciate the friendships I've made at DSS.

Follow-up: ColdFusion System Properties...

In my blog post about ColdFusion System Properties I explain a way to gather information about your server using the java.lang.System classes. Well, after a little hunting you can grab most of this information easier by using the ColdFusion server variables. For example, dumping the server.coldfusion variable returns the following structure:

server.coldfusion variables

And the server.os variable returns this structure:

server.os variables.

Just what I needed and I didn't have to use Java. Which is faster and less lines of code.

More Entries

Contact Chris SchofieldBlogCFC was created by Raymond Camden. This blog is running version 5.9.001.