Proper Placement of the Increment Operator

I admit that there are certain nuances to programming that I’ve never fully been able to wrap my brain around. One in particular is the proper placement of the increment operator:

( for var i = 0; i < 10; i++ )

versus…

( for var i = 0; i < 10; ++i )

I was certainly aware that there’s a difference… but never fully comprehended what that difference was. And it never seemed to be a big deal, as placing the increment operator after the operand always seemed to work for me.

…until today, that is.

Read More»

Pardon Me, Do You Have the Time?

I’ve recently moved my sites over to a new VPS, with a new CF9 Professional install. This blog has been there for about a month now, and there’s been an issue that I never noticed until today.

There’s a new site that I’ve been working on, and is just about complete. One of the last things I wanted to add was a “dateLastUpdated” column into one of the database tables, which I did this morning. I’m passing ColdFusion’s #now()# value as the dateLastUpdated. I know that it’s generally considered better practice to use a database-specific variable (e.g. getDate() in SQL Server or CURRENT_TIMESTAMP in mySQL), but I didn’t want the column populated when the record was initially created, so I didn’t set it as a default value on the column. I’m using ColdFusion 9′s ORM integration, which I’m new to, so the path of least resistance was for me to just pass now() as the value. It’s not going to be a high-traffic site, so I wasn’t particularly worried about whatever performance implications might result from not “letting the database do the work”.

It should have been straightforward enough, but when I went to test, I noticed that the dateLastUpdated value was 12 hours in the future. I VPN’d into the VPS and verified the system time was correct (same as my local time here in AZ). I recalled that there was a DST bug in a previous JVM, but since the time difference was greater than an hour, I assumed this wasn’t a DST issue. After some googling, I found a post on the Adobe Forums, with a very helpful answer by Paul Hastings (of course… Paul’s very well known for his knowledge of all things i18n/timezone related, and deservedly so).

Read More»

jQuery Exercise: Tabbing in Textarea

The other day I came across a question on stackoverflow, where the developer wanted to allow his users to use the tab key in a <textarea>. Of course, the issue is that by default, when a form element has focus and the tab key is pressed, the next form element (either consecutively or via the tabindex attribute, if used) gets focus.

I thought that’d be an interesting quick exercise, so I set about writing some code. The good news is that I got it to work, and relatively quickly. The bad news is that by the time I did, somebody else had answered… and with a better answer than mine.

The “good” answer is to use an existing plugin, and Tab Override was suggested. Generally, as programmers, we try not to reinvent the wheel, so I voted that answer up. But now I’ve got some code sitting here doing absolutely nothing, so I thought, “hey… blog entry” :)

Read More»

Conference Recap: MAX and CF DevCamp Phoenix

Since my last entry had a hint of an, “Oh, God, oh, God, we’re all gonna die” overtone to it, I thought perhaps something more upbeat might be in order.

MAX

Last month (and I still can’t believe it’s been that long), I was in Los Angeles at Adobe MAX. For the second year in a row, I’ve had the honor of helping Ray Camden and Ezra Parker organize the ColdFusion Unconference. As I spent all of my time at the Unconference, this will be more of a recap of the Unconference rather than MAX itself.

First off, I’d be remiss if I didn’t thank Adobe for their support in helping make sure that all of the Unconferences ran as smoothly as possible. I’m sure that what with organizing MAX proper, their resources were stretched pretty thin to begin with. But we still got whatever we needed and that’s very much appreciated.

Read More»

On ColdFusion Builder vs CFEclipse and the Sky Falling

Maybe you’ve heard…

Adobe recently published a whitepaper (PDF) comparing ColdFusion Builder and CFEclipse (see Adam Lehman’s post here). Some people were, um… less than enthusiastic about this.

With the full disclaimer that I do not work for Adobe, nor was I even aware of the effort to put this paper together (I didn’t know about it until after it was published… right around the time many others first saw it), I’d like to offer up a response. My response is directed more towards the overall reaction to the paper than to the paper itself. The opinions expressed are mine entirely. And they’re just that. Opinions. Mine. OK, glad we’re clear on that.

Read More»

TextMate – My New IDE of Choice

A little less than a year ago I made the switch to OS X and treated myself to a Macbook Pro. Just recently, I started working with the TextMate IDE on a current contract.

My first impression was less than stellar. Visually, TextMate is pretty spartan. Applications on OS X are supposed to be pretty (see Coda). TextMate is most decidedly not pretty. But as I’m starting to learn, she’s got an amazing personality.

Sometimes it’s the little things that hook you in. For the longest time, I put off learning jQuery. Didn’t see the need. I’m pretty comfortable with JavaScript, and couldn’t justify investing the time to learn a new way to write what I already knew how to write. Then I learned about .toggle(). I was sold. I hopped into bed with jQuery and I’ve not looked back.

Today, I was introduced to TextMate’s equivalent of .toggle(). It may seem trivial, but it got me hooked, and hungry to learn more.

Read More»

jQuery – Ensuring Unique Usernames in Real Time

A question came up yesterday on the cf-talk mailing list. The question involved a user who is filling out a form and choosing a user name. The poster wanted to check in “real time” (after the blur event on the username input) that the name is unique.

As Steve “Cutter” Blades points out, this can be accomplished using Jörn Zaefferer’s Validation Plugin for jQuery. This plugin is essentially the defacto standard for doing validations via jQuery. It can be implemented very easily to do the most basic validations, but it can also be extended to do any number of complex validations.

That being said, I thought it still might be worthwhile to see a quick example of how to build out that specific functionality from scratch. How can we use jQuery to give a user real-time feedback as to whether or not a username is available? Start with the markup below:

Read More»

jQuery – A Traversal Quickie

Paraphrased from the jQuery mailing list:

I have a table with links inside of it. Each <tr> has a unique ID assigned to it. How can I get the ID of the <tr> that contains the link that was clicked?

The following code snippet was included:

<tr id="1">
	<td>Name</td>
	<td>E-Mail</td>
	<td><a href="#" class="accept">Accept</a></td>
</tr>

jQuery provides a number of DOM traversal methods. While the initial thought might be to go with parent(), that would get the <td> containing the link. You could double up on parent(), but that seems a bit kludgy (IMO).

Read More»

jQuery – What You Can do with the Data Method

A question came up yesterday on the jQuery mailing list where somebody wanted to effectively “embed” data into a link. They essentially wanted to call a function on click, but needed to pass arguments. Since jQuery is supposed to be unobtrusive (e.g. “Find Something, Do Something”), how can we tell jQuery that, when a specific link is clicked, there’s specific data associated with that link?

The jQuery data() method allows you to do just that.

Read More»

ColdFusion and jQuery – New tutorial(s) on LearnCF.com (Part 3)

The long-awaited and eagerly anticipated (by me) conclusion to my 3-part tutorial on learncf.com on using jQuery to return JSON data from a ColdFusion CFC.

The tutorial can be found here. When all is said and done, you’ll have built this page, and hopefully you’ll have a good (better?) understanding of how it all works.

As always, hit me up with questions or comments.

Page 2 of 612345...Last »
© Copyright Charlie Griefer