Random things #7

Written on 2 December 2014, 10:55pm

Tagged with: , , ,

1. Custom templates for request debug output

Use case: you want to temporarily enable debug output in a production environment (ex – to determine the cause of a specific performance problem), but you obviously don’t want the users to see the debug information.
Solutions:
– restrict debug output to your IP only (if you know exactly who is behind your IP), but it will still introduce a performance problem (the IP has to be checked for every request)
– create a custom debug template (*) – example logging.cfm instead of classic.cfm and log all the details you need instead of outputting
– create an empty debug template (silent.cfm), then create a component with a main logging method based on the classic.cfm debug template. Call this main method onRequestEnd to log all the needed details.

(*) A custom debug template can be created and placed in the WEB-INF/debug ColdFusion folder. The classic.cfm template can be used as starting point.
More info: http://www.bennadel.com/blog/116-finding-template-execution-stack-in-coldfusion.htm

2. When a ColdFusion template cannot be found

Use onMissingTemplate and return a 404 HTTP error code. Let the web server handle the error:

<cffunction name="onMissingTemplate">
    <cfargument name="targetPage" type="string" required="true"/>
    <cfheader statuscode="404" statustext="Not Found">
</cffunction>

(more…)

ColdFusion 10 cache bug

Written on 14 October 2014, 02:10pm

Tagged with: ,

After upgrading to ColdFusion 10 I noticed that the error timeToLive can't be negative is thrown for each query that was cached for more than 15 days.
This bug is already reported in the Adobe’s Bugbase: Error when using CFQUERY’s cachedWithin with value > 15 days
A quick workaround is to cache the query for less than 15 days; like that:

<cfquery name="myQuery" datasource="#dsn#" 
cachedwithin="#CreateTimeSpan(15,0,0,0)#">

Starting to understand the frustration of the people commenting on the last ColdFusion 11 update: blogs.coldfusion.com

… the current state of affairs is not good enough anymore in 2014. To be honest it already wasn’t good enough anymore in 2011 or 2012. You need to get your processes under control. … If your build and test process for CF is too cumbersome to do faster releases, it seriously needs to change or you’ll end up like the dinosaurs a few 100 million years ago — you’re trying to compete with modern web technology stacks/frameworks there and there should be an update every 4-6 weeks.

Update: a few hours after I wrote this, the status of the bug changed to ‘Fixed’ – as the CF 10 Update 14 was released.

Random links #4

Written on 23 September 2014, 04:42pm

Tagged with: , , , ,

1. 5 Unix Commands I wish Iā€™d discovered earlier. Ok, mainly talking about xxd

2. The Birthday problem: in a class of 30 students, probability that today is an anniversary: 8%. Probability that 2 students have the same birthday: 70% http://en.wikipedia.org/wiki/Birthday_attack

3. ColdFusion Developers, switch to Sublime Text! I already did it, years ago.

4. Top 9 IT security certifications. In case you need one.

5. He was asked to crack a program as part of a job interview. Twice šŸ™‚

6. He quit his job. It was the biggest mistake ever

Assorted pills
Photo: istockphoto