Skip to content

Instantly share code, notes, and snippets.

@adamcameron
adamcameron / adobeBugRss.cfm
Created October 3, 2012 09:15
RSS Feed for 50-most recent ColdFusion Bugs
<cfsetting showdebugoutput="false">
<cfcontent type="application/rss+xml">
<cfcache action="cache" stripwhitespace="true" timeout="#createTimespan(0,3,0,0)#">
<cfsilent>
<cfscript>
product = 1149;
versions = {
"10.0.0" = 7770,
"9.0.1" = 9288,
"9.0.0" = 9289,
@adamcameron
adamcameron / snarfblat.cfm
Created October 3, 2012 21:42
Demonstrating what I think you're talking about..?
<cffunction name="f">
<cfset var q = false>
<cfquery name="q" datasource="bugNotifier">
SELECT *
FROM user
</cfquery>
<cfreturn q>
</cffunction>
<cfdump var="#f()#">
@adamcameron
adamcameron / argumentCollectionBug.cfm
Created October 5, 2012 12:26
This demonstrates a bug in CF9+'s implementation of argumentCollections, as well as some weirdness with structCount()
<cfscript>
function baseline(){
var localData = {};
localData.copiedBefore = structCopy(arguments);
dummyTest(argumentcollection=arguments);
localData.copiedAfter = structCopy(arguments);
localData.copiedBefore.d = 4;
localData.copiedAfter.d = 4;
// in the file system
theApp
service
component_to_call.cfc
mem
pages
handlers
calling.cfc
@adamcameron
adamcameron / slashes.cfm
Created December 29, 2012 11:56
Code demonstrating slashes in <cfgrid> data is fine
<cfscript>
colours = deserializeJson('{"COLUMNS":["ID","MAORI","ENGLISH"],"DATA":[[1,"mangu","black"],[2,"whero","red"],[3,"ma","white"]]}', false);
// add a row with a slash
queryAddRow(colours);
querySetCell(colours, "id", 4);
querySetCell(colours, "maori", "kiko\rangi");
querySetCell(colours, "english", "bl\ue");
</cfscript>
@adamcameron
adamcameron / comparator.cfm
Last active December 10, 2015 08:28
Test rig for timing various string comparison methods
<cfscript>
param name="URL.method" default="compare";
param name="URL.lenDiff" type="boolean" default=false;
param name="URL.equal" type="boolean" default=false;
param name="URL.reset" type="boolean" default=false;
</cfscript>
<cfapplication name="comparator_#URL.method#_#URL.lenDiff#_#url.equal#" sessionmanagement="true">
<cfscript>
param name="session.cumulative" default={count=0, total=0, mean=0};
if (URL.reset){
@adamcameron
adamcameron / Coldbox.cfc
Created December 30, 2012 18:06
Coldbox.cfc for Brad / Coldbox forum bods
component{
public void function configure(){
variables.coldbox = {
appName = application.applicationName, // I'm not over the moon about this break of encapsulation, but equally I want to be as DRY as possible. I dunno why I need to specify this (again)
appHomeUrl = "http://#CGI.http_host##CGI.script_name#",
defaultEvent = "bug.main",
// TODO: get rid once I understand what's going on
HandlersIndexAutoReload = true,
@adamcameron
adamcameron / createString.cfm
Created December 31, 2012 16:13
Sample code for blofg article: creating a large string, and recording some performance metrics
<cfscript>
param name="URL.magnitude" default=0;
param name="URL.method" default="string";
param name="URL.reset" type="boolean" default=false;
</cfscript>
<cfapplication name="createString_#URL.method#_#URL.magnitude#" sessionmanagement="true">
<cfscript>
param name="session.cumulative" default={count=0, total=0, mean=0};
if (URL.reset){
session.cumulative = {count=0, total=0, mean=0};
@adamcameron
adamcameron / listOperationsWithEmptyDelimiters.cfm
Created December 31, 2012 17:40
Code that uses an empty list delimiter on various list operations to see what happens
<cfset list = "1234567890">
<cfoutput>
<table border="1">
<thead>
<tr><th>operation</th><th>result</th></tr>
</thead>
<tbody>
<tr><td>list</td><td>#list#</td></tr>
@adamcameron
adamcameron / double.cfm
Created January 15, 2013 08:37
Some code to look at how much accuracy a double has
<cfscript>
struct function compareStringToNumeric(string s){
var result = {
asString = s,
asNumber = val(s)
};
result.equal = !compare(result.asString, result.asNumber);
return result;
}