Re: CFB creating a bunch of files in my project

Pretty old CFBuilder bug, still giving me a headache:
https://bugbase.adobe.com/index.cfm?event=bug&id=3328850

Straight to the point: how to solve it?

Open file config.ini from folder:
"C:\Users\{username}\Adobe ColdFusion Builder 2.0.1 Configuration\configuration\"

See eclipse.p2.data.area= line?

Replace it with:
eclipse.p2.data.area=@config.dir/../p2

Atlassian is hiring

Want to move to Sydney and work for best Australian tech start-up? Check this out!

Had a chance to talk with some fellow developers and team Atlassian at Popup Hiring Tour in Melbourne.

Few notes:
- Atlassian is currently recruiting 150 jobs (with relocation package available)
- Head office is in Sydney with 500 staff, other offices in Europe and US
- Java, Python and Scala are core development tools
- 60-70 core developers for JIRA with extra on come-and-go basis
- every 3-6 months you can rotate to a different project
- serving ~50K instances of JIRA
- moving to the cloud (AWS)
- strong QA to prevent possible problems
- UX is taking into account recently

Unfortunately I was one of the last to come and first to go due to other commitments, so... share and add what I have missed.

Lookbehind regex in ColdFusion

You can't use lookbehind with CF's regex engine!

WTF?!

OK, let's use Java:

newString = createObject("java", "java.util.regex.Pattern").compile("(?<=ColdFusion )suxx").matcher("ColdFusion suxx!").replaceAll("is cool");

Use the Force, Luke

Small note on use of indexes in MySQL:

I had quite simple table with about 20 columns and 5 indexes, doing SELECT query on 5 columns, all included in one index.

An average query time was not that bad at around 500 ms, taking into consideration of 1.5M rows and medium MySQL instance config.

During this round of queries optimisations, which I usually do every few months, I've made a small change by forcing use of one particular index and average speed of query went down to 15-30 ms.

SELECT ColumnA, ColumnB
FROM TableZ
USE INDEX (MyIndexX)
WHERE ... some filtering

Therefore sometimes it is worth to force index, rather than rely on MySQL to do so.

printStackTrace

Small function to dump stack trace in ColdFusion:

printStackTrace = function(
	boolean isStop = false
) {

	local.st = [];
	local.j = CreateObject("java","java.lang.Thread").currentThread().getStackTrace();
	for (local.i=1; local.i lte ArrayLen(local.j); local.i++) {
		local.f = local.j[local.i].getFileName();
		if (not isNull(local.f) and REFindNoCase("\.cf[cm]$", local.f)) {
			local.l = local.j[local.i].getLineNumber();
			local.rdr = createObject("java", "java.io.LineNumberReader").init(createObject("java", "java.io.BufferedReader").init(createObject("java", "java.io.FileReader").init(javaCast("string", local.f))));
			local.line = "";
			while (not isNull(local.line)) {
				local.line = local.rdr.readLine();
				if (local.rdr.getLineNumber() eq local.l) {
					ArrayAppend(local.st, {
						"Template" = local.f & " (" & local.l & ")",
						"Code" = local.line
					});
					break;
				}
			}
			local.rdr.close();
		}
	}

	if (arguments.isStop) {
		writeDump(local.st);
		abort;
	} else {
		return local.st;
	}

};

Typeless ColdFusion

ColdFusion is a typeless environment, meaning that you do not explicitly set a variable's datatype.

<cfoutput>#isBoolean(100)#</cfoutput>? YES!
<cfoutput>#isBoolean("100")#</cfoutput>? YES!
<cfoutput>#isBoolean("One Hundred")#</cfoutput>? NO!
So, be careful what you wish for with ColdFusion!

ColdFusion Technical Lead

Our company, Onthehouse Holdings, is hiring ColdFusion Technical Lead in Melbourne.

Check out job ad for more details,
http://www.seek.com.au/job/24987221

CFHTTP bug?

Can someone confirm that CF 8/9 throws an error (java.lang.ArrayIndexOutOfBoundsException) on simple CFHTTP call?

<cfhttp method="get" url="http://brad.livejournal.com/" />

StackTrace is following:

java.lang.ArrayIndexOutOfBoundsException: 22

HTTPClient.Codecs.base64Decode(Codecs.java:262)
HTTPClient.VerifyMD5.verifyHash(ContentMD5Module.java:155)
HTTPClient.MD5InputStream.real_close(MD5InputStream.java:141)
HTTPClient.MD5InputStream.read(MD5InputStream.java:93)
java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
java.io.BufferedInputStream.read(BufferedInputStream.java:317)
coldfusion.tagext.net.HttpTag.getUrlContents(HttpTag.java:1890)
coldfusion.tagext.net.HttpTag.connHelper(HttpTag.java:938)
coldfusion.tagext.net.HttpTag.doEndTag(HttpTag.java:1075)
cftest2ecfm1416521183.runPage(..\path\to\test.cfm:1)
coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:196)
coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:483)
coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:282)
coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
coldfusion.filter.PathFilter.invoke(PathFilter.java:86)
coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)
coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:74)
coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
coldfusion.CfmServlet.service(CfmServlet.java:198)
coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
com.seefusion.Filter.doFilter(Filter.java:49)
com.seefusion.SeeFusion.doFilter(SeeFusion.java:1500)
jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
jrun.servlet.FilterChain.service(FilterChain.java:101)
jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)
jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203)
jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)
jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)
jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)


Apparently following call works well:

<cfhttp method="get" url="http://www.livejournal.com/" />

Any thoughts on this?

New security hotfixes for ColdFusion

Adobe has released security bulletin to address critical vulnerabilities for ColdFusion 8, 8.0.1 and 9 (Windows, Mac and Unix). The vulnerabilities could lead to cross-site scripting and information disclosure. Update now!

Image Resize Bug

It looks like ColdFusion (version 8.0.1 at least) has a problem resizing images with certain aspect ratio. Look at the code below:

<cfset img = ImageNew("",336,448) />
<cfset ImageResize(img,150,"") />
<cfoutput>#img.width#px</cfoutput>

What should is display? 150px? Nope, it shows 149px. Any ideas how to fix this?