Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Nadel bennadel

View GitHub Profile
@bennadel
bennadel / test.cfm
Created Jun 23, 2021
Generating Color Swatches With GraphicsMagick And Lucee CFML 5.3.7.47
View test.cfm
<cfscript>
hexValues = [ "E63946", "F1FAEE", "A8DADC", "457B9D", "1D3557", "001219" ];
swatches = hexValues.map(
( hexValue ) => {
var imageFile = "./images/#hexValue#.png";
gm([
@bennadel
bennadel / test.cfm
Created Jun 17, 2021
Managing And Reporting Errors During Parallel Array Iteration In Lucee CFML 5.3.7.47
View test.cfm
<cfscript>
// Let's download these images in parallel.
imageUrls = [
"https://picsum.photos/500/300",
"https://picsum.photos/501/301",
"https://picsum.photos/502/302",
"https://picsum-BAD-DNS.photos/503/303", // This will fail (invalid domain name).
"https://picsum.photos/504/304",
"https://picsum.photos/505/305",
@bennadel
bennadel / child.cfm
Created Jun 16, 2021
Strange Variable-Name Error When Writing To Base Tag In Adobe ColdFusion 2018
View child.cfm
<cfscript>
parentTag = getBaseTagData( "cf_parent" );
variableName = "$$entity:h1:small-title";
parentTag[ variableName ] = true;
writeDump( parentTag );
</cfscript>
@bennadel
bennadel / example1.cfm
Created Jun 15, 2021
Adobe ColdFusion 2018 Compatible Version Of My ColdFusion Custom Tag DSL For HTML Emails
View example1.cfm
<!--- Import custom tag libraries. --->
<cfimport prefix="core" taglib="./core/" />
<cfimport prefix="html" taglib="./core/html/" />
<cfimport prefix="imageGrid" taglib="./customized/image-grid/" />
<cfimport prefix="customized" taglib="./customized/" />
<!--- // ------------------------------------------------------------------------- // --->
<!--- // ------------------------------------------------------------------------- // --->
<core:Email
@bennadel
bennadel / LaunchDarklyRestGateway.cfc
Created Jun 13, 2021
Using The LaunchDarkly REST API To Update Rule Configuration In Lucee CFML 5.3.7.47
View LaunchDarklyRestGateway.cfc
component
output = false
hint = "I provide low-level semantic abstractions over LaunchDarkly's HTTP REST API."
{
/**
* I initialize the LaunchDarkly REST API with the given access token.
*/
public void function init(
required string accessToken,
@bennadel
bennadel / example-1.cfm
Created Jun 8, 2021
Managing Lists Of IDs Using HTML FORM Posts In Lucee CFML 5.3.7.47
View example-1.cfm
<cfoutput>
<form method="post" action="#cgi.script_name#">
<!---
These form fields will be submitted to the server as individual fields.
However, since they all have the SAME NAME, the ColdFusion server will
automatically collapse them down into a single, comma-delimited list.
--
NOTE: There is an Application.cfc setting to change the default behavior from
a LIST to an ARRAY (sameFormFieldsAsArray); but, I have not tried this.
@bennadel
bennadel / RandomValue.cfc
Created Jun 4, 2021
Changing Function Argument Defaults At Runtime In Lucee CFML 5.3.7.47
View RandomValue.cfc
component
output = false
hint = "I provide random integers between a given set of values."
{
/**
* I initialize the randomizer with the given min/max range.
*/
public void function init(
numeric minValue = 1,
@bennadel
bennadel / logs.txt
Created Jun 1, 2021
Migrating Password Hashing Algorithms In Lucee CFML 5.3.7.47
View logs.txt
[INFO] Could not verifying BCrypt hash, moving onto older hash.
[INFO] Older, insecure MD5 hash [d49a5b5dff1f7dfcc2fd3d0b85dcd0a3] verified for user.
[INFO] Storing hash [$2b$10$VxeTfuPjf3JjfTnw5GK75uhtS5jlP2m8O/.TFwZKpMseRy55dKnJ6] for user [ben@bennadel.com]
@bennadel
bennadel / Password.cfc
Created May 29, 2021
Using Password4j And The BCrypt, SCrypt, And Argon2 Password Hashing Algorithms In Lucee CFML 5.3.7.47
View Password.cfc
/**
* I provide a Lucee CFML wrapper around the Password4j Java library.
*
* GitHub: https://github.com/Password4j/password4j
* Maven: https://mvnrepository.com/artifact/com.password4j/password4j
*/
component
output = false
hint = "I provide password hashing and verification functions (using Password4j)."
{
@bennadel
bennadel / snippet-1.conf
Last active May 27, 2021
Including Tracing Headers In Nginx 1.18.0 Access Logs Using Custom Formatting
View snippet-1.conf
log_format combined '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';