Skip to content

Instantly share code, notes, and snippets.

@adamcameron
adamcameron / createODBCdate.cfm
Created January 30, 2014 19:30
Demonstrating various values fetched from createOdbcDate()
<cfset date=createODBCdate(createDatetime(2000,1,2,3,4,5,6,"UTC"))>
<cfoutput>
raw output: #date#<br>
toString() method: #date.toString()#<br>
<cfdump var="#date#" label="Dump">
Force to string: #date & ""#<br>
Railo version: #server.railo.version#
</cfoutput>
@adamcameron
adamcameron / chartInDocument.cfm
Created February 6, 2014 15:19
<cfchart> in <cfdocument>
<cfchart name="chart" format="png">
<cfchartseries type="Bar">
<cfchartdata item="one" value="1">
<cfchartdata item="two" value="2">
<cfchartdata item="three" value="3">
<cfchartdata item="four" value="4">
</cfchartseries>
</cfchart>
<cfset pdfFile = expandPath("./test.pdf")>
@adamcameron
adamcameron / Struct.cfc
Last active August 29, 2015 13:56
Tests for Railo (and eventually ColdFusion 11) struct class member functions
// Struct.cfc
component {
pageEncoding "utf-8"; // there's a ß, further down
function run(){
describe("append() tests", function(){
it("appends two empty structs", function(){
var initialStruct = {};
initialStruct.append({});
@adamcameron
adamcameron / dumpWeirdness.cfm
Last active August 29, 2015 13:57
This dump does not output on cflive.net. It's something to do with the ' in the label. This is a pared down repro case from a more complex real-world situation
<cfdump var="x" label="'">
@adamcameron
adamcameron / Application.cfc
Created March 8, 2014 22:10
CF8 version of <cfchart> / ZingCharts demo
<!--- Application.cfc --->
<cfcomponent></cfcomponent>
@adamcameron
adamcameron / TestExecutionSequence.cfc
Created March 11, 2014 15:43
Demonstrating execution sequence from testbox call
// TestExecutionSequence.cfc
component extends="testbox.system.testing.BaseSpec" {
function beforeAll(){
writeOutput("top of beforeAll()<br>");
writeOutput("bottom of beforeAll()<br>");
}
function run(){
writeOutput("top of run()<br>");
@adamcameron
adamcameron / forLoop.cfm
Created March 26, 2014 13:27
Showing difference in behaviour between for-in loops with queries and arrays
numbers = queryNew("id,en,mi", "int,varchar,varchar",[
[1,"one","tahi"],
[2,"two","rua"],
[3,"three","toru"],
[4,"four","wha"]
])
for(number in numbers){
number.en = number.en.toUpperCase()
}
@adamcameron
adamcameron / scopingIssue.cfm
Last active August 29, 2015 13:57
Demonstrating bug in Railo
<cfscript>
numbers = [1,2,3,4]
iterations = 0
numbers.each(function(v,i){
iterations++ //unscoped
echo("#iterations#<br>")
});
echo("<hr>")
iterations = 0
@adamcameron
adamcameron / comma.cfm
Created April 1, 2014 10:54
Demo for Zack
<cfscript>
foo,bar= "moo";
writedump(variables);
<cfscript>
@adamcameron
adamcameron / forTryCf.cfm
Created April 4, 2014 10:10
Doesn't run on CF10
<cfscript>
URL.test=1;
test++;
writeDump({url=url.test,variables=variables.test});
</cfscript>