Thursday, June 06, 2002

kwfu: ['MX','marketing','sales']

Great presentation on the MX vision from Jeremy Allaire now online:

http://www.macromedia.com/software/mx/presentation/

Wednesday, June 05, 2002

kwfu: ['wait','sleep','delay']

Some tricks for getting a page to delay execution for a while on the server side while consuming minimum system resources. As opposed to looping infinitely which will cause processor peaks.

Force a lock contention and trap the resulting error - This one seems to be the best for versions prior to CFMX.

<cfset sleep = 2>
<cfset start = getTickCount()>
<cftry>
<cflock name="foo" timeout="#sleep#" type="ReadOnly">
<cflock name="foo" timeout="#sleep#" type="Exclusive">
<!---waiting... for 20 seconds--->
</cflock>
</cflock>
<cfcatch></cfcatch>
</cftry>
<cfset time = getTickCount() - start>
<cfoutput>#time#</cfoutput>

Use cfexecute to invoke a process that either runs continuously, or doesn't stop for a while, and doesn't consume many system resources. This could also be done with cfftp, cfhttp, or a bunch of other external calls that are likely to take a while.

<cfset start = getTickCount()>
<cfexecute name="c:\cfusion\bin\cfstat.exe" timeout="2"/>
<cfset timer = getTickCount() - start>
<cfoutput>#timer#</cfoutput>

or

<cfset start = getTickCount()>
<cfset args = arrayNew(1)>
<cfset args[1] = '-n'>
<cfset args[2] = '1000'>
<cfset args[3] = 'localhost'>
<cftry>
<cfexecute name="c:\winnt\system32\ping.exe" arguments="#args#" timeout="5"/>
<cfcatch></cfcatch></cftry>
<cfset timer = getTickCount() - start>
<cfoutput>#timer#</cfoutput>

If you're running cfmx I'd recommend this.

<cfscript>
function sleep(timeMillis) {
var thread = createObject("java", "java.lang.Thread");
thread.sleep(timeMillis);
}
</cfscript>

Sunday, June 02, 2002

kwfu: ('custom tag','images','File upload')
Decided to post this custom tag I wrote a while ago. It reads the information from an image file and retrieves info such as file size in bytes, height, width, and some other file format specific info. Works for a range of file types such as tiff, gif, jpeg, ras, bmp, and png.

Download

Instructions:
1. Download file
2. Extract to directory under the webroot
3. Browse to index.cfm in the imgsize directory.