This file contains hidden or 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> | |
// Column name example: col_1, col_10, col_6, etc. | |
var qryColumnOrder = myQuery.columnList | |
.listToArray() | |
.sort((a, b) => { | |
// Extract the numeric part from the string | |
var numA = numberFormat(a.reReplace("\D", "", "all"), "0000"); | |
var numB = numberFormat(b.reReplace("\D", "", "all"), "0000"); | |
// Extract the text part from the string |
This file contains hidden or 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
/* | |
Example argument structure | |
worksheets = [ | |
{ | |
name: [sheet_name], | |
data: [query], | |
includeColumnNames: [true|false], | |
columnFormat: [struct], | |
columnCellStyle: [array_of_structs] | |
} |
This file contains hidden or 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> | |
/** | |
* @hint Converts pages of a binary PDF document into binary JPG images. | |
* @pdfFile.hint A binary representation of the file to be converted. | |
*/ | |
public array function pdfToImage(binary pdfFile) { | |
var result = []; | |
// Collection for async processes | |
var futures = []; |
This file contains hidden or 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> | |
// Because of https://tracker.adobe.com/#/view/CF-4199995, | |
// I've come across a few scenarios where dollarFormat() and numberFormat() will not round up when expected/desired. | |
// Looking at how Java handles BigDecimals and rounding them, it seems my expectations are debatable. | |
// But I need to round up from 3+ decimal places so I expect "62.275" to become "6.28". | |
// The above example works in dollarFormat() but not numberFormat(). The ticket has other failing examples. | |
public string function roundedDollarFormat( | |
required numeric amount, |
This file contains hidden or 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> | |
array function shadeColors(string color, numeric percent, numeric iteration) { | |
var result = []; | |
var currentcolor = arguments.color; | |
for (var i = 0; i < arguments.iteration; i++) { | |
var R = inputBaseN(currentcolor.mid(1, 2), 16); | |
var G = inputBaseN(currentcolor.mid(3, 2), 16); | |
var B = inputBaseN(currentcolor.mid(5, 2), 16); | |
R = formatBaseN(R * (100 + percent) / 100, 10); |
This file contains hidden or 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> | |
string function randomAlphaNumericString(required numeric length) { | |
var alphaNum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; | |
var SecureRandom = new java("java.security.SecureRandom"); // Note: CF2018 syntax | |
var rng = SecureRandom.getInstanceStrong(); | |
var result = ""; | |
for (var i = 0; i < arguments.length; i++) { | |
result &= alphaNum.charAt( rng.nextInt(alphaNum.len()) ); |
This file contains hidden or 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> | |
example = ["a", "b", "c", "a", 1, 2, 1]; | |
HashSet = createObject("java", "java.util.HashSet"); | |
Arrays = createObject("java", "java.util.Arrays"); | |
result = HashSet.init(Arrays.asList(example)).toArray(); | |
writeDump(result); |
This file contains hidden or 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
print( ['a', 'at', 'cat', 'scat', 'catch'].find { it ==~ '.+at' } ) |
This file contains hidden or 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
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="false"> | |
<Context path="" docBase="C:\websites\coldfusion2016\wwwroot" workDir="C:\ColdFusion2016\cfusion\runtime\conf\Catalina\localhost\tmp"> | |
<Resources> | |
<PreResources className="org.apache.catalina.webresources.DirResourceSet" base="C:\ColdFusion2016\cfusion\wwwroot\CFIDE" webAppMount="/CFIDE" /> | |
<PreResources className="org.apache.catalina.webresources.DirResourceSet" base="C:\ColdFusion2016\cfusion\wwwroot\WEB-INF" webAppMount="/WEB-INF" /> | |
</Resources> | |
</Context> | |
</Host> |
This file contains hidden or 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> | |
array function nextIds(required array ids, required numeric id, numeric count = 0) { | |
var idPos = arguments.ids.find(arguments.id); | |
return arguments.ids.filter(function(item, index) { | |
return idPos && index != idPos && index <= idPos + count; | |
}); | |
} | |
writeDump( nextIds([7141, 6881, 5821, 8001, 7904, 6601, 7961, 6021, 4721], 7141, 3) ); |
NewerOlder