Skip to content

Instantly share code, notes, and snippets.

@cflove
cflove / gist:5255391
Last active June 27, 2022 16:38
Import ColdFusion schedules from a server
View gist:5255391
<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.
View spreadsheet.cfm
<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.
View mail.cfm
<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
View ups.cfc
<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.
View winSCP.cfm
<!---
<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
View ColdFusion_MongoDB.cfm
<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
View usps_tracking.cfc
<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">
View List of self closing ColdFusion Tags
cfabort
cfajaximport
cfajaxproxy
cfapplet
cfapplication
cfargument
cfassociate
cfauthenticate
cfcalendar
cfchartdata
@cflove
cflove / httpGet.cfm
Last active April 25, 2017 13:01
Get large file over HTTP. CFHTTP in some cases seems not to respect timeout attribute values and time out prematurely. CFHTTP collect the file into the memory and write to the hard drive at the end. That enables large files to create an OutOfMemoryError error. This should solve both of those options.
View httpGet.cfm
<cffunction name="httpget" access="private" returnType="any" output="No">
<cfargument name ="source" type="string" required="true"/>
<cfargument name ="destination" type="string" required="true"/>
<cfargument name ="ConnectTimeout" type="numeric" required="false" default="10" hint="Time Out in Seconds"/>
<cfargument name ="ReadTimeout" type="numeric" required="false" default="60" hint="Time Out in Seconds" />
<cfargument name ="dimensions" type="numeric" required="false" default="255"/>
<cfset local.urlconnection = createObject("java", "java.net.URL").init(arguments.source)>
<cfset local.connection = local.urlconnection.openConnection() />
<cfset local.connection.setConnectTimeout(javaCast("int",arguments.ConnectTimeout*1000)) />
@cflove
cflove / gist:4716338
Created February 5, 2013 18:02
Amazon AWS API URL Signature creation with ColdFusion
View gist:4716338
<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" />