Skip to content

Instantly share code, notes, and snippets.

James Moberg JamoCA

View GitHub Profile
@JamoCA
JamoCA / test-dates.cfm
Last active Jun 30, 2020
Test date strings for ColdFusion isDate() and date parsing functions.
View test-dates.cfm
<cfscript>
/* Test date strings for ColdFusion isDate() and date parsing functions. (20200630)
Using RSS Dates from http://rssdateformats.tumblr.com/ and
https://github.com/mjibson/goread/blob/0387db10bd9fd9ccd90d557fa30b6e494efa577a/goapp/utils.go#L129
*/
dates = ["now",
"12/31/292278993",
DateAdd("d", 1, "12/31/292278993"),
2000,
"1/1/22019",
@JamoCA
JamoCA / highlightChanges.htm
Last active Jun 18, 2020
Highlight the difference of two texts
View highlightChanges.htm
<!--- 20200618
Bug fix for https://stackoverflow.com/a/38037642/693068
--->
<style>
.highlighted {background-color:#39ff14;}
</style>
<script>
highlightChanges = function(str, compareStr){
var strlength = str.length > compareStr.length ? compareStr.length : str.length;
@JamoCA
JamoCA / JVM_Font_List.cfm
Last active Jun 17, 2020
Output JVM Only font list for use with ColdFusion CFDocument
View JVM_Font_List.cfm
<!--- 6/17/2020
Output JVM Only font list for use with ColdFusion CFDocument
GIST: https://gist.github.com/JamoCA/fd9c86736f7625a951b811e27f115d34
TryCFM: https://www.trycf.com/gist/fd9c86736f7625a951b811e27f115d34
--->
<cfset environ = createObject("java", "java.awt.GraphicsEnvironment").getLocalGraphicsEnvironment()>
<cfset allFamilies = environ.getAvailableFontFamilyNames()>
<cfdump var="#AllFamilies#" output="browser" format="Text">
@JamoCA
JamoCA / removeNonce.cfm
Last active Jun 5, 2020
Use ColdFusion & regex to remove "nonce" attributes from HTML
View removeNonce.cfm
<!--- 20200605 Use ColdFusion & regex to remove "nonce" attributes from HTML
TryCF: https://trycf.com/gist/fa176f86448b28bf4c48a60ca2a35d7d
--->
<CFSAVECONTENT VARIABLE="HTML">
<script nonce="dXpwbUZDZjVPQnN1dVhGS1kzS0M2dz09">alert('script with nonce');</script>
<script nonce="">alert('script with empty none');</script>
<script>alert('script without nonce');</script>
</CFSAVECONTENT>
@JamoCA
JamoCA / symbolsToASCII.cfm
Last active Jun 6, 2020
Coldfusion UDF to convert Unicode UTF-8 punctuation and symbols to ASCII7 punctuation for natural language processing (NLP).
View symbolsToASCII.cfm
<cfscript>
/* 20200604 Map Symbols & Punctuation to ASCII
Convert the Unicode punctuation and symbols to ASCII punctuation and symbols is imperative in Natural language processing (NLP) for preserving the original documents.
Based on mapping from Lexical Systems Group: https://lexsrv3.nlm.nih.gov/LexSysGroup/Projects/lvg/2013/docs/designDoc/UDF/unicode/NormOperations/mapSymbolToAscii.html
Blog: https://dev.to/gamesover/convert-symbols-punctuation-to-ascii-using-coldfusion-java-3l6a
TryCF: https://trycf.com/gist/6f35220d47caa7fdbf75eb884ff1cec7 */
string function symbolsToASCII(required string inputString){
var TempContent = javacast("string", arguments.inputString);
TempContent = TempContent.replaceAll("[\u00B4\u02B9\u02BC\u02C8\u0301\u2018\u2019\u201B\u2032\u2034\u2037]", chr(39)); /* apostrophe (') */
TempContent = TempContent.replaceAll("[\u00AB\u00BB\u02BA\u030B\u030E\u201C\u201D\u201E\u201F\u2033\u2036\u3003\u301D\u301E]", chr(34)); /* quotation mark (") */
@JamoCA
JamoCA / HTML-CSS-SVG-Demo.htm
Created May 14, 2020
Full Page HTML/CSS/SVG Demo to generate PDFs using CFDocument, CFHTMLTOPDF & WKHTMLTOPDF
View HTML-CSS-SVG-Demo.htm
<!-- Full Page HTML/CSS/SVG Demo to generate PDFs using CFDocument, CFHTMLTOPDF & WKHTMLTOPDF -->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>SVG Demo</title>
<style>
body {width:8.5in; height:11in; padding:0; margin:0;}
.logo1 {width:8in; height:8in; margin:auto;}
.logo1 img {width:100%; height:100%;}
@JamoCA
JamoCA / FileList_Manual.md
Last active Apr 21, 2020
FileList.exe Manual
View FileList_Manual.md

FileList.exe Manual (Version 4.1.1; released on 23 Jul 2018)

FileList is a command line utility providing a list of files of the selected path in the CSV format. The list includes the file name, the size, the file path, the last access and change date, date of creation etc. You can easily import all results to a spreadsheet or database. FileList runs on any current Windows operating system starting with Vista.

Online Manual: https://manuals.jam-software.com/filelist/EN/

Filter Lists as Needed: Filter the lists by various criteria like file name, file extension, time stamps, directory level, file size or file attributes.

Create File Lists on the Command Line: FileList can print or export lists of files of a folder or directory tree including metadata of the file.

@JamoCA
JamoCA / ColdFusion_QofQ_FirstLast_Bug.cfm
Last active Apr 8, 2020
Adobe ColdFusion 10, 11, 2016 & 2018 throws an error when access column names that use "first" or "last". (Railo & Lucee work.)
View ColdFusion_QofQ_FirstLast_Bug.cfm
<!--- 20200408 Query-of-Queries Column Name Test
Column names like "first" and "last" throw errors in Adobe ColdFusion 10, 11, 2016 & 2018, but work without
any errors in Railo or Lucee.
NOTE: Message on CFFiddle.org states "CFFiddle currently doesn't support some of the tags used in the cfm file like cfquery."
Blog: https://dev.to/gamesover/coldfusion-query-of-query-reserved-words-or-bug-4ppf
TryCF 10: https://trycf.com/editor/gist/4fbd1a8336c71f5f21e982ea2b10d448?engine=acf
TryCF 11: https://trycf.com/editor/gist/4fbd1a8336c71f5f21e982ea2b10d448?engine=acf11
TryCF 2016: https://trycf.com/editor/gist/4fbd1a8336c71f5f21e982ea2b10d448?engine=acf2016
TryCF 2018: https://trycf.com/editor/gist/4fbd1a8336c71f5f21e982ea2b10d448?engine=acf2018
TryCF Railo: https://trycf.com/editor/gist/4fbd1a8336c71f5f21e982ea2b10d448?engine=railo
@JamoCA
JamoCA / AmazonTrustServices.cfm
Last active Mar 24, 2020
Test to determine if your ColdFusion Application Server can connect to Amazon Trust Services certificates.
View AmazonTrustServices.cfm
<!--- 20200323 Test to determine if your ColdFusion Application Server can connect to Amazon Trust Services certificates.
BLOG: https://dev.to/gamesover/coldfusion-test-for-new-amazon-trust-services-certificates-1k6o
TryCF: https://www.trycf.com/gist/829e15110b1f8b81576e1782f760475d
Try this on your installation of ColdFusion. (Proof that it works in a separate test environment is not the same as it working in production.)
NOTE: Also try this at https://cffiddle.org/ (It works on TryCF, but I think it may be due to proxied requests.)
--->
<cfset AmazonTrustServices = [
{
"CN" = "Amazon Root CA 1",
"O" = "Amazon",
@JamoCA
JamoCA / ParseFullNameTests.txt
Created Mar 19, 2020
Array of names to test when parsing full names
View ParseFullNameTests.txt
tests = [
[
'James Norrington',
[
'firstname' = 'James',
'lastname' = 'Norrington'
]
],
[
You can’t perform that action at this time.