Monthly Archives: March 2006

March 31, 2006
How to find the size of a directory?

Here is an article from coldfusion cookbook.

select sum(size) as size from cfDir

#numberFormat(sizeMB,”,.99″)#
Note the ‘recurse’ option, this will get the size of the current and all sub-directories. If you only need the size of the current directory, change recurse to false.

March 29, 2006
How do I make sure a string is safe to use with JavaScript?

An article from coldfusion cookbook using jSStringFormat():
“If you are dynamically populating a JavaScript variable, you may find that your code breaks with “unterminated string constant” or similar error messages. This is probably a case of your JavaScript variables containing characters that are considers to be “special” characters by JavaScript. You will need to “escape” these [...]

March 16, 2006
cfstoredproc vs cfquery

There are of course pros and cons to using each method to perform CRUD operations on a database.
cfstoredproc Pros:

With stored procedures you can control security in the database as well as the web pages.
Transactions are handled at the database level, stored procedures are ideal here.
Stored procedures provide greater performance, because the execution plan for the [...]

March 15, 2006
new ‘result’ attribute in MX7 cfstoredproc

In CFMX7 Macromedia introduced a new (and optional) attribute to the cfstoredproc tag called “result” which specifies a name for the structure in which cfstoredproc returns the statusCode and ExecutionTime variables. If set, this value replaces cfstoredproc as the prefix to use when accessing those variables.
The result attribute provides a way for stored procedures that [...]

March 14, 2006
Double-checked locking

Mark Kruger has a nice article (with mention from Sean Corfield) on APPLICATION variable locking.
Sean basically added that in the initial example (BAD code) if 2 users hit the <cfif> condition at the same time, only one will have a lock on the code while the other will wait.
The problem lies in the fact that [...]