Skip to content

Instantly share code, notes, and snippets.

CREATE OR REPLACE FUNCTION isNull(value_to_check ANYELEMENT, replacement_value ANYELEMENT)
RETURNS ANYELEMENT AS $$
BEGIN
RETURN COALESCE(value_to_check, replacement_value);
END;
$$ LANGUAGE plpgsql IMMUTABLE;
<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
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
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]>
<cfoutput>
<pre>
&lt;cfschedule
action = "update"
task = "#here.task.task#"
@cflove
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", "java.io.FileInputStream").init(JavaCast("string", attributes.src )) />
<cfset XSSFWorkbook = CreateObject("java", "org.apache.poi.xssf.usermodel.XSSFWorkbook").init(inputStream) />
<cfset DataFormatter = CreateObject("java", "org.apache.poi.ss.usermodel.DataFormatter") />
<cfset Evaluator = CreateObject("java", "org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator").init(XSSFWorkbook) />
@cflove
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">
</cfcase>
<cfdefaultcase>
<!--- *************************************************** --->
<!--- Basic Errors --->
<!--- *************************************************** --->
@cflove
cflove / ups.cfc
Last active December 2, 2020 18:32
Creating a UPS Shipping Label with UPS API & ColdFusion http://cflove.org/2010/12/ups-shipping-label-with-coldfusion.cfm
<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
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
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)>
<cfelse>
<cfset local.retrun = CreateObject("java","com.mongodb.util.JSON").parse( SerializeJSON(arguments.value) )>
</cfif>
<cfreturn local.retrun>
@cflove
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">