This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
// 2023-01-15 CUID for Java vs CF-CUID2 Benchmarks | |
// CUID1: 435,595 ops/sec (clcxncf7wvwy56062pd6o10xs) | |
// CUID2: 130,682 ops/sec (q2qimk6q6cifa0oyq3ygz316) | |
// CUID.isValid: 1,898,025 ops/sec (YES) | |
// CF-CUID2: 5,001 ops/sec (nxvr6js43lh8rtwuuv259dvi) | |
cuid = createobject("java", "io.github.thibaultmeyer.cuid.CUID"); | |
// Dependency: https://github.com/thibaultmeyer/cuid-java | |
// JAR: https://search.maven.org/artifact/io.github.thibaultmeyer/cuid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
/* 20221222 mergeQbSqlBindings UDF | |
by James Moberg / SunStar Media. | |
Tested w/MSSQL. To be used with QB parameterized SQL string & binding array to generate reusable SQL. | |
NOTE: Using Query Builder (QB) does not required ColdBox or CommandBox. | |
GIST: https://gist.github.com/JamoCA/bb681afd2eb1a0d6d380f3b714ccc138 | |
TWEET: https://twitter.com/gamesover/status/1606008360976781312 | |
GITHUB: https://github.com/coldbox-modules/qb | |
DOCS: https://qb.ortusbooks.com/query-builder/building-queries/parameters-and-bindings | |
USAGE: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- 20221222 Testing CFML Replace Regex Limits | |
Blog: https://dev.to/gamesover/use-java-replaceall-instead-of-coldfusion-rereplacenocase-ee4 | |
Bug: https://tracker.adobe.com/#/view/CF-4165797 | |
Bug: https://tracker.adobe.com/#/view/CF-3928688 | |
YMMV based on CF version, JVM and regex used, but using native replaceAll() seems to be more reliable & faster | |
when performing lots of replacements. | |
When using ACF2016, we encountered intermittent, unpreventable/uncatchable hard ColdFusion errors. (Using CFTRY/CATCH | |
wouldn't do anything and we had to refer to log files to identify the errors.) | |
CF2016/18 seems to have a maximum 1587 character limit with this regex. CF2021 is higher. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- 20221208 Caching repetitive UDF access to request scope using argument stringified+hashed key #ColdFusion #cfml | |
By James Moberg / SunStar Media | |
GIST: https://gist.github.com/JamoCA/62f8535cfcf5dacd4e7f5ea678038330 | |
TWEET: https://twitter.com/gamesover/status/1600908166426136576 | |
BLOG: https://dev.to/gamesover/caching-repetitive-udf-access-to-request-scope-using-argument-stringifiedhashed-key-4fd6 | |
---> | |
<cfscript> | |
string function slowFunction(required a, b="100", c="abc", d=[], e={}) hint="I perform a repetitive function with a cacheable result" { | |
// generate a unique key based on stringified+hashed arguments passed to UDF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
/** | |
* Converts your date into a time string the aheres to the ISO 8601 standard (for use with some API calls). | |
* v1.0 by Ben Nadel | |
* https://cflib.org/udf/getIsoTimeString | |
* @param datetime A date/time object (Required) | |
* @param convertToUTC Whether to convert to UTC before formatting (default true) (Optional) | |
* @return A date string as per ISO format | |
* @author Ben Nadel (ben@bennadel.com) | |
* @version 1.0, August 1, 2013 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- 20221202 A ColdFusion function w/return type of "boolean" won't return boolean unless you explicitly & manually cast it. | |
- James Moberg - SunStar Media | |
Gist: https://gist.github.com/JamoCA/56a6e1f32a353b23c13e71b028c7551f | |
Tweet: https://twitter.com/gamesover/status/1598770171057168384 | |
If not explicitly cast, Lucee & Adobe may return a "Double", "Integer", or "String" datatype. | |
Adobe 2018-2021 sometimes returns a "CFBoolean" type & CF2016 only returns "String". | |
I'm suprised that Adobe doesn't auto-trim values before evaluating. (The isValid("email") BIF auto-trims before validating.) | |
Probably "not a bug", but I'd prefer that functions with a return type of "boolean" return an typed boolean value and not | |
some value that can be coerced-to-boolean. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- 20221202 Comparing Performance of ColdFusion isValid("regex") vs reFind() vs Cached Java Pattern #cfml | |
By James Moberg - SunStar Media | |
Gist: https://gist.github.com/JamoCA/e8c2ab5815bb26db58ff4024a86c533c | |
Tweet: https://twitter.com/gamesover/status/1598741050608480256 | |
Blog: https://dev.to/gamesover/coldfusion-isvalidregex-vs-refind-vs-java-regex-pattern-2ee1 | |
---> | |
<cfscript> | |
request.tldRegexList = "aaa|aarp|abarth|abb|abbott|abbvie|abc|able|abogado|abudhabi|ac|academy|accenture|accountant|accountants|aco|actor|ad|ads|adult|ae|aeg|aero|aetna|af|afl|africa|ag|agakhan|agency|ai|aig|airbus|airforce|airtel|akdn|al|alfaromeo|alibaba|alipay|allfinanz|allstate|ally|alsace|alstom|am|amazon|americanexpress|americanfamily|amex|amfam|amica|amsterdam|analytics|android|anquan|anz|ao|aol|apartments|app|apple|aq|aquarelle|ar|arab|aramco|archi|army|arpa|art|arte|as|asda|asia|associates|at|athleta|attorney|au|auction|audi|audible|audio|auspost|author|auto|autos|avianca|aw|aws|ax|axa|az|azure|ba|baby|baidu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- 2022118 Comparison of ListFindNoCase versus ListFind w/lcased values or pre-optimized values | |
Tweet: https://twitter.com/gamesover/status/1593692201363521536 | |
----> | |
<cfscript> | |
a = "A,B,c,d,E,f,g,H,I,J,l,m,n,O,p,Q,R,S,t,u,v"; | |
s = "S"; | |
iterations = 1000000; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- CF-4202730: In a query, when you select names with order, the order is incorrect in the result. | |
AKA "Query-of-query has incorrect letter sorting" | |
https://tracker.adobe.com/#/view/CF-4202730 (my comments are here) | |
Workaround posted: 11/1/2022 | |
ColdFusion 2021u5 indicates that this CFML bug is fixed, but it doesn't appear to be. (And you can't perform a QoQ using CFFiddle.org) | |
I'd love to be able to use "ORDER BY LOWER(myColumn) ASC", but I don't believe that it's supported by java QoQ | |
even though it's supported by MSSQL. | |
---> | |
<h1>CF-4202730: In a query, when you select names with order, the order is incorrect in the result.</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
/* 20221028 getCFHtmlHead - Retrieves (and optionally clears) the CFHTMLHead buffer | |
Reason: Adobe ColdFusion 2021 now clears the internal head buffer after CFContent. Not sure if a bug, | |
but definitely different & undocumented. | |
20230615 Updated to support Lucee 5/6. | |
Mostly from https://pastebin.com/f2560e44d (CF7 CFML from 10/8/2009) | |
Gist: https://gist.github.com/JamoCA/dda46141cd11517320bdd380bf38f91c | |
Blog: https://dev.to/gamesover/change-to-coldfusion-2021-cfhtmlhead-cfcontent-1fj8 | |
Tweet: https://twitter.com/gamesover/status/1586795471019745280 | |
BugTracker: https://tracker.adobe.com/#/view/CF-4215634 |