Skip to content

Instantly share code, notes, and snippets.

@abramadams
abramadams / structPassByValueOfReference.cfm
Last active January 1, 2016 23:28
Here's a demonstration of how ColdFusion doesn't actually pass things by reference. (derived from http://cfmlblog.adamcameron.me/2012/08/complex-data-types-in-cf-and-how-theyre.html)
<cfscript>
st1 = {
one = "Tahi",
two = "Rua",
three = "Toru",
four = "Wha"
};
st2 = f(st1);
<cfscript>
arrayTest = [['a','b','c'],['d','e','f']];
writeDump(arrayTest);
// same as
arrayTest2 = arrayNew(2);
arrayTest2[1][1] = 'a';
arrayTest2[1][2] = 'b';
arrayTest2[1][3] = 'c';
arrayTest2[2][1] = 'd';
arrayTest2[2][2] = 'e';
<cfscript>
/* Put this in the Setup Tab */
myTable = queryNew("fruit,color","Integer,Varchar",[ ["apples","green"], ["banannas","yellow"], ["grapes","purple"] ]);
/****************************/
/* Put this in the Default Tab */
writeDump(myTable);
local.svc = new query(
sql = "SELECT * FROM myTable",
@abramadams
abramadams / jvm.config
Created July 11, 2014 19:40
Generic JVM config for CF9 on Linux
#
# VM configuration
#
# Where to find JVM, if {java.home}/jre exists then that JVM is used
# if not then it must be the path to the JRE itself
java.home=/opt/coldfusion9/runtime/jre/
#
# If no java.home is specified a VM is located by looking in these places in this
# order:
#
@abramadams
abramadams / Application.cfc
Created July 18, 2014 19:19
Simple CF-ORM one-to-one example
component {
this.name = hash(getCurrentTemplatePath());
this.sessionManagement = true;
this.sessionTimeout = CreateTimeSpan(0, 1, 0, 0);
this.ormenabled = true;
this.mappings['/'] = expandPath('.');
this.datasource = 'sandbox';
this.ormsettings = {
@abramadams
abramadams / gist:dba95cc6009fc3bd6468
Last active August 29, 2015 14:09
ISO Date/Time To CF Date/Time Regex
<cfscript>
date = '2014-12-14T08:28:52.796Z';
convertedDate = date.ReplaceFirst(
"^.*?(\d{4})-?(\d{2})-?(\d{2})T([\d:]+).*$",
"$1-$2-$3 $4"
);
writeDump( [ date, convertedDate ] );
"use strict"
LIVERELOAD_PORT = 35728
lrSnippet = require("connect-livereload")(port: LIVERELOAD_PORT)
# var conf = require('./conf.'+process.env.NODE_ENV);
mountFolder = (connect, dir) ->
connect.static require("path").resolve(dir)
# # Globbing
<cfscript>
writeOutput( abs( -300 ) );
</cfscript>
<select id="minutes">
<cfoutput>
<cfloop from="1" to="60" index="m">
<option>#numberFormat(m,'00')#</option>
</cfloop>
</cfoutput>
</select>