Skip to content

Instantly share code, notes, and snippets.

@jeffcoughlin
jeffcoughlin / gist:30d5f2826b12fb40089c235f6f706c47
Created June 2, 2021 21:01
Array to list without empty values
<cfscript>
aData = [3,1,"","",3,4,"",""];
aData = arrayFilter(aData, function(item) {
return item != "";
});
writeOutput(arrayToList(aData));
</cfscript>
@jeffcoughlin
jeffcoughlin / gist:636335576815833cbdf2ec35d251f893
Created January 27, 2017 06:26
wkhtml2pdf example for CF on Windows
<cfscript>
var aOptions = [
'--load-error-handling "ignore"',
'--margin-top "20mm"',
'--margin-bottom "15mm"',
'--page-size "Letter"',
'--header-html "#uriWithoutFile#/header_all.cfm"',
'--header-spacing "5"',
'--footer-html "#uriWithoutFile#/footer_all.cfm"',
'--footer-spacing "3"',
<!--- instantiate cfsolrlib --->
<cfset application.fapi.getContentType("configSolrServer").setupSolrLibrary() />
<cfset tickBegin = getTickCount() />
<cfset oSolrProContentType = application.fapi.getContentType("solrProContentType") />
<cfset stContentType.contentType = "TYPENAME" />
<cfset batchSize = 2000 />
<cflog application="true" file="aaa_farcrySolrPro" type="information" text="A_1. procTime: #getTickCount()-tickBegin# Date: #dateFormat(now(),"yyyy-mm-dd")# #timeFormat(now(),"hh:mm:ss")#" />
<cfset aItemsToDeleteTemp = [{"id"="apples"},{"id"="oranges"},{"id"="bananas"},{"id"="pears"},{"id"="kiwi"},{"id"=["peach"]}] />
<cfset aItemsInDB = [{"id"="apples"},{"id"="oranges"},{"id"="bananas"},{"id"="peach"}] />
<!--- Find the difference --->
<cfset aItemsToDeleteTemp.removeAll(aItemsInDB) />
<!--- Convert the remaining array of structs to a simple array --->
<cfset aItemsToDelete = [] />
<cfset aLen = arrayLen(aItemsToDeleteTemp) />
<cfloop from="1" to="#aLen#" index="r">
<cfif isArray(aItemsToDeleteTemp[r]["id"]) is true>