Skip to content

Instantly share code, notes, and snippets.

CREATE OR REPLACE FUNCTION isNull(value_to_check ANYELEMENT, replacement_value ANYELEMENT)
RETURN COALESCE(value_to_check, replacement_value);
<cfexecute name="aws" arguments="configure set aws_access_key_id xxx"></cfexecute>
<cfexecute name="aws" arguments="configure set aws_secret_access_key xxx"></cfexecute>
<cfexecute name="aws" arguments="configure set region us-east-1"></cfexecute>
<cfexecute name="aws" arguments="configure set output json"></cfexecute>
cflove / CreateFavIcon.cfm
Last active November 8, 2023 05:59
create a favicon.icon file with coldfusion
<cffunction name="createFavicon" access="public" returntype="void">
<cfargument name="letter" type="string" required="true">
<cfargument name="saveLocation" type="string" required="true">
<!--- Set image dimensions (16x16 pixels) --->
<cfset width = 16>
<cfset height = 16>
<!--- Create a buffered image with transparency --->
<cfset BufferedImage = createObject("java", "java.awt.image.BufferedImage")>
cflove / gist:5255391
Last active June 27, 2022 16:38
Import ColdFusion schedules from a server
<cfset sf = createobject('Java','coldfusion.server.ServiceFactory')>
<cfset tasks = sf.CronService.listAll()/>
<cfloop from="1" to="#arraylen(tasks)#" index="i">
<cfset here.task = tasks[i]>
action = "update"
task = "#here.task.task#"
cflove / spreadsheet.cfm
Created March 11, 2015 03:37
Custom Tag to Read Excel file with Railo and return a query. This read character data and formula, not binary objects.
<cfparam name="attributes.src" default="0">
<cfparam name="attributes.query" default="q">
<cfswitch expression="#thisTag.ExecutionMode#">
<cfcase value="start">
<cfset inputStream = CreateObject("java", "").init(JavaCast("string", attributes.src )) />
<cfset XSSFWorkbook = CreateObject("java", "org.apache.poi.xssf.usermodel.XSSFWorkbook").init(inputStream) />
<cfset DataFormatter = CreateObject("java", "") />
<cfset Evaluator = CreateObject("java", "org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator").init(XSSFWorkbook) />
cflove / mail.cfm
Last active February 23, 2021 05:20
ColdFusion custom mail tag to use Amazon SES API SendRawEmail call. This is will create Multipart email message and pass into SES API. Mailparam tag can be use to attach file and create custom x-headers slimier to cfmailparam tag.
<cfparam name="attributes.type" default="html">
<cfswitch expression="#thisTag.ExecutionMode#">
<cfcase value="start">
<!--- *************************************************** --->
<!--- Basic Errors --->
<!--- *************************************************** --->
cflove / ups.cfc
Last active December 2, 2020 18:32
Creating a UPS Shipping Label with UPS API & ColdFusion
<cfcomponent displayname="USP">
<!--- ********************************************************************************************** --->
<!--- Hint: Before start, add correct default values for arguments currently marked with xxxxxxxxxxx --->
<!--- ********************************************************************************************** --->
<cffunction name = "init" access= "Public" output = "No" returntype= "Any">
<!--- UPS Access Settings --->
<cfargument name="License" type="string" required="No" default="xxxxxxxxxxx" hint="UPS License Key" />
<cfargument name="Account" type="string" required="No" default="xxxxxxxxxxx" hint="UPS Account ID" />
cflove / winSCP.cfm
Last active September 24, 2020 02:15
ColdFusion custom tag to work with WinSCP / sftp. This use external files and write hostkey and script file in the same dir location of the custom tag template. Change default attributes. This need WinSCP installed in the server.
<cf_WinSCP action ="listdir"
username =""
password =""
host =""
name ="qryDirectory"
directory ="" />
<cf_WinSCP action="exists"
username =""
cflove / ColdFusion_MongoDB.cfm
Last active January 9, 2020 23:12
Experiment talking to MongoDB java driver directly in ColdFusion
<cfset Mongo = CreateObject("java","com.mongodb.MongoClient")>
<cffunction name="m" returntype="any">
<cfargument name="value" type="any">
<cfif IsJSON(arguments.value)>
<cfset local.retrun = CreateObject("java","com.mongodb.util.JSON").parse(arguments.value)>
<cfset local.retrun = CreateObject("java","com.mongodb.util.JSON").parse( SerializeJSON(arguments.value) )>
<cfreturn local.retrun>
cflove / usps_tracking.cfc
Last active May 16, 2018 16:29
USPS Tracking with ColdFusion
<cfcomponent displayname ="unit" output="no">
<!--- ************************************************************************************ --->
<!--- Get local.tracking --->
<!--- ************************************************************************************ --->
<cffunction name="tracking" access="remote" returntype="any" output="no">
<cfargument name="trackingID" required="yes" type="string">
<cfargument name="UserID" default="">
<cfargument name="Password" default="">
<cfargument name="ShowDetail" default="Yes">