<cfwhat>

Thursday, September 24, 2009

Web Standards Curriculum

A great online course from Opera covering HTML, CSS, JavaScript and Web Standards.

Monday, September 21, 2009

Useful regular expressions

Strip all HTML tags
REReplace(content,"<[^>]*>","","all")

Strip high ASCII characters (ASCII 128 and above)
REReplace(content,"[^\x00-\x7F]","","all")

Encode all ampersands that are not already encoded
REReplaceNoCase(content, "&(?!amp;)", "&", "all")

Encode all ampersands that are not part of entities
(eg. ignore &nbsp;)
REReplace(arguments.content, "&(?!##?\w+;)", "&", "all")

Validate a list of numbers
REReplace(content,"[^0-9,]","","all")

Strip new lines, carriage returns and tabs
REReplace(content,"[\n\r\t]","","all")

Wednesday, October 29, 2008

ColdFusion performance tuning articles

Coldfusion MX Tuning links by Simon Whatley
Really Fixing Applications - Are We Inside Out? from Alagad
ColdFusion Performance and Troubleshooting Guide (book)
Performance tuning for ColdFusion applications (Adobe)

Thursday, February 21, 2008

Software QA and Testing Resource Center

While I was looking for software to do web application load testing I came across the Software QA and Testing Resource Center. The site has lots of useful information and links, including a good list of Load and Performance Test Tools.

I ended up choosing WebLoad.

Sunday, March 25, 2007

ColdFusion and MSDE 2000 on XP with SP2

I set up a new PC for development at home this weekend and I ran into a (common) problem trying to get ColdFusion to work with MS SQL Server 2000 (MSDE) on XP with SP2. It took me ages but eventually I got it working. The solution was to uninstall the copy of MSDE that I originally put on and do a fresh install using SQL Server SP4 for MSDE. The setup required some parameters, eg.:
setup.exe SAPWD="your_sa_password" DISABLENETWORKPROTOCOLS=0 /L*v C:\MSDELog.log

If you can't get that to run at the command line (I couldn't) then set up a shortcut to setup.exe and put it in the target field.

Tuesday, January 23, 2007

New toy

I got a shiny new iPod shuffle a couple of weeks ago. What's the first thing I use it for? Listening to the ColdFusion Weekly podcast on the way to work of course!

Friday, November 24, 2006

Reading Excel spreadsheet files with ColdFusion

A new project I started working on requires the ability to read values from an Excel file using ColdFusion. The last time I looked into doing this (a long time ago) the answer was to use COM. Sometime soon we will be moving our production server from Windows to Solaris so that's not a great solution. After a bit of searching I came across the Apache Jakarta POI project, a Java API to access Microsoft format files. A little bit more searching revealed that ColdFusion already has this installed. After some trial and error and help from Dave Ross' blog and the API docs I got it to work.

Here's some example code to read a spreadsheet and dump it into an HTML table.


<!--- Get the file --->
<cfset FileIn = createObject("java","java.io.FileInputStream").init("#ExpandPath('myfile.xls')#")/>
<cfset fs = createObject("java","org.apache.poi.poifs.filesystem.POIFSFileSystem").init(FileIn)/>
<cfset workbook = createObject("java","org.apache.poi.hssf.usermodel.HSSFWorkbook").init(fs)/>
<!--- Get the first sheet --->
<cfset sheet = workbook.getSheetAt(0)/>
<!--- Get an iterator to loop over each row in the sheet --->
<cfset rows = sheet.rowIterator()>
<table border="1">
<!--- Process each row --->
<cfloop condition="#rows.hasNext()#">
<tr>
<!--- Get next row --->
<cfset row = rows.next()>
<!--- Get an iterator to loop over each cell in the row --->
<cfset cells = row.cellIterator()>
<!--- Process each cell --->
<cfloop condition="#cells.hasNext()#">
<!--- Get next cell --->
<cfset cell = cells.next()>
<!--- Get the cell value's format --->
<cfset CellType = cell.getCellType()>
<!--- Get the cell value --->
<cfset CellValue = "">
<cfswitch expression="#CellType#">
<cfcase value="1,3">
<cfset CellValue = cell.getStringCellValue()>
</cfcase>
<cfcase value="0">
<cfset CellValue = cell.getNumericCellValue()>
</cfcase>
</cfswitch>
<cfoutput><td>#CellValue# </td></cfoutput>
</cfloop>
</tr>
</cfloop>
</table>
<cfset FileIn.close()>