Skip to content

Instantly share code, notes, and snippets.

Ben Nadel bennadel

Block or report user

Report or block bennadel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
bennadel / test.cfm
Created Aug 21, 2019
Calculating A Consistent Cache-Friendly Expiration Date For Signed-URLs In Lucee
View test.cfm
* I return the "monthly" bucket for the given date (defaults to now). This helps with
* expiration dates on signed-URLs that will be consumed as the origin of a CDN pull-
* through.
* @input I am the date being used to calculate the bucket.
public date function getMonthlyBucket( date input = now() )
bennadel / CachingCdnService.cfc
Created Aug 20, 2019
Performance Case Study: Caching Cryptographically Signed-URLs In Redis In Lucee
View CachingCdnService.cfc
accessors = true
output = false
hint = "I wrap the CDN Service and cache URL generation results."
// Define properties for dependency-injection (for Framework One).
property cdnService;
property jedisPool;
bennadel / snippet-1.cfm
Created Aug 17, 2019
Upgrading A Built-In Function To A First-Class Citizen In Lucee
View snippet-1.cfm
values = trim );
bennadel / MANIFEST.MF
Created Aug 16, 2019
Installing User Defined Functions (UDF) As An Extension For Built-In Functions (BIF) In Lucee
Manifest-Version: 1.0
id: "b6304293-81fa-4bcf-a6aa4bf9bd673697"
version: ""
name: "TruthyFalsy"
description: "Decision functions based on JavaScript's notion of Truthy and Falsy values."
category: "Decision Logic"
bennadel / test.cfm
Created Aug 14, 2019
Playing With The Zip Virtual File System (VFS) In Lucee
View test.cfm
// Let's check to make sure the Zip virtual file system is enabled before we attempt
// to use it to create a Zip archive file.
// --
// NOTE: I have this here simply as an exploration of the VFS metadata function.
if ( ! getVfsMetaData( "zip" ).enabled ) {
echo( "Zip VFS not enabled." );
bennadel / Application.cfc
Created Aug 13, 2019
Unexpected Variable Assignment Using Function LocalMode Modern With Nested Closures In Lucee
View Application.cfc
output = false
hint = "I define the application settings and event handlers."
{ = hash( getCurrentTemplatePath() );
// By using "modern" localmode, any unscoped variable assignment will be applied to
// current Function's local scope (never to the Variable's scope).
this.localmode = "modern";
bennadel / build.cfm
Last active Aug 10, 2019
Using Function LocalMode To Render Templates During Static Site Generation In Lucee
View build.cfm
(() => {
stopwatch variable = "local.timer" {
var data = new DataReader().parseJson( fileRead( "./data.json" ) );
// Define the directory into which we will be building the static site.
var exportPath = "./export/";
bennadel / template.cfm
Created Aug 8, 2019
Using Function LocalMode Modern To More-Safely Render ColdFusion Templates In Lucee
View template.cfm
// Assert the expected values.
// --
// NOTE: Using param in this case as an excuse to declare more variables.
name = "categorization"
type = "string"
default = "My Friends" // Will assign this value if not provided.
bennadel / test.cfm
Created Aug 6, 2019
Fixing ImageScaleToFit() Invalid Size Errors In Earlier Versions Of Lucee CFML
View test.cfm
img = imageNew(
source = "",
width = 16,
height = 2000,
canvasColor = "ff3366"
width = imageGetWidth( img );
bennadel / test.cfm
Created Aug 5, 2019
CachedWithin Function Memoization Can Be Applied To Closures In Lucee
View test.cfm
* I return a random integer between 1 and the given max value (inclusive).
* @maxValue I am the optional max value of the range.
public numeric function getRandomValue( numeric maxValue = 10 ) {
return( randRange( 1, maxValue ) );
You can’t perform that action at this time.