Skip to content

Instantly share code, notes, and snippets.

@cflove
cflove / gist:4716338
Created February 5, 2013 18:02
Amazon AWS API URL Signature creation with ColdFusion
<cffunction name="awsurl" returntype="string" access="public" output="No">
<cfargument name="Query" type="string" required="true" />
<cfargument name="AWSAccessKeyId" type="string" required="true" />
<cfargument name="SecretKey" type="string" required="true" />
<cfargument name="Host" type="string" default="ec2.amazonaws.com" />
<cfargument name="Methord" type="string" default="GET" />
<cfargument name="URI" type="string" default="/" />
<cfargument name="SignatureVersion" type="string" default="2" />
<cfargument name="Version" type="date" default="2012-04-01" />
<cfargument name="http" type="string" default="https" hint="https|http" />
@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 / SNS.cfm
Last active December 13, 2015 20:08
To accept AWS SNS calls originating from SES mail bounces and complains. http://cflove.org/2013/02/track-amazon-aws-ses-email-bounce-and-complains-with-coldfusion.cfm
<cfset sns = getHttpRequestData()>
<!---<cfif YesNoFormat(fromSNS(cgi.REMOTE_ADDR))>--->
<cfset sns = DeserializeJSON(sns.content)>
<!---- ****************************************************************** --->
<!---- if subsribe request, acccept it (remove after first use) --->
<!---- ****************************************************************** --->
<cfif StructKeyExists(sns,'SubscribeURL')>
<cfhttp charset="utf-8" method="get" resolveurl="no" url="#sns.SubscribeURL#">
</cfif>
@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 / 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" />
<cfset image = ImageRead(ExpandPath('images/2.jpg'))>
<cfset BufferedImage = ImageGetBufferedImage(image)>
<cfset minScale = 1>
<cfset maxScale = 50>
<cfset Gray8DetectHaarMultiScale = CreateObject('java', 'jjil.algorithm.Gray8DetectHaarMultiScale' )>
<cfset DetectHaar = Gray8DetectHaarMultiScale.init(
CreateObject('java', 'java.io.FileInputStream').init( ExpandPath('images/haar/HCSB.txt') ),
JavaCast('int',minScale),
JavaCast('int',maxScale) ) >
<cfset image = ImageRead(ExpandPath('images/2.jpg'))>
<cfset BufferedImage = ImageGetBufferedImage(image)>
<cfset minScale = 1>
<cfset maxScale = 50>
<cfset Gray8DetectHaarMultiScale = CreateObject('java', 'jjil.algorithm.Gray8DetectHaarMultiScale' )>
<cfset DetectHaar = Gray8DetectHaarMultiScale.init(
CreateObject('java', 'java.io.FileInputStream').init( ExpandPath('images/haar/HCSB.txt') ),
JavaCast('int',minScale),
JavaCast('int',maxScale) ) >
@cflove
cflove / ColdFusion_FaceDetection.cfm
Created May 19, 2013 15:49
Here is Railo code for Face Detection with Jviolajones Java library. Update CreateObject() function in line 1, copy jar files into your CF server or load it with JavaLoader if you are using Adobe ColdFusion. http://cflove.org/2013/05/face-detection-with-coldfusion-and-jviolajones.cfm
<cfset Detector = CreateObject('java', 'jviolajones.Detector',"#ExpandPath('jviolajones.jar')#,#ExpandPath('jdom.jar')#" ).init( ExpandPath('haarcascade_frontalface_alt.xml'))>
<cfset image = ImageRead(ExpandPath('images/2.jpg'))>
<cfset results = Detector.getFaces( ImageGetBufferedImage(image) ,
JavaCast('float',2) ,
JavaCast('float',1.25) ,
JavaCast('float',.05) ,
JavaCast('int',3) ,
JavaCast('boolean',true) ) >
@cflove
cflove / Face_Crop.cfm
Created May 20, 2013 15:31
Face Cropped Thumbnails with ColdFusion and jviolajones
<!---- ************************************************************* --->
<!--- Detect Faces --->
<!---- ************************************************************* --->
<cfset Detector = CreateObject('java', 'jviolajones.Detector',"#ExpandPath('jviolajones.jar')#,#ExpandPath('jdom.jar')#" ).init( ExpandPath('haarcascade_frontalface_alt2.xml'))>
<cfset image = ImageRead(ExpandPath('images/2.jpg'))>
<cfset results = Detector.getFaces( ImageGetBufferedImage(image) ,
JavaCast('float',2) ,
JavaCast('float',1.25) ,
JavaCast('float',.06) ,
@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>