Skip to content

Instantly share code, notes, and snippets.

View DeveloperOfficeCom's full-sized avatar

DeveveloperOffice.com DeveloperOfficeCom

View GitHub Profile
@DeveloperOfficeCom
DeveloperOfficeCom / stringtruncate.cfm
Created July 19, 2025 22:25
ColdFusion implementation of intelligent string truncation - Smart truncation with word boundaries, custom suffixes, and multiple truncation positions (start, middle, end)
<!---
STRINGTRUNCATE Function
Description: Intelligently truncates a string to a specified length while preserving word boundaries.
Can add ellipsis or custom suffix, and optionally truncate from different positions (start, middle, end).
Parameters:
- text: The text to truncate (required)
- maxLength: Maximum length of the result including suffix (required)
- suffix: String to append when truncated (optional, default: "...")
@DeveloperOfficeCom
DeveloperOfficeCom / setoperations.cfm
Created July 19, 2025 20:00
ColdFusion implementation of set operations utility - Provides union, intersection, difference, and other mathematical set operations on arrays
ColdFusion implementation of set operations utility - Provides union, intersection, difference, and other mathematical set operations on arrays
<!---
SETOPERATIONS Function
Description: Provides utility methods for performing mathematical set operations on arrays without
needing to create set objects. Includes union, intersection, difference, and other common set operations
that work directly with arrays.
Parameters: None - returns an object with set operation methods
@DeveloperOfficeCom
DeveloperOfficeCom / stringslug.cfm
Created July 19, 2025 20:00
ColdFusion implementation of string slug generator - Creates URL-safe slugs from text with support for accented characters, custom separators, and max length
ColdFusion implementation of string slug generator - Creates URL-safe slugs from text with support for accented characters, custom separators, and max length
<!---
STRINGSLUG Function
Description: Generates a URL-safe slug from a string by converting to lowercase, replacing spaces
with hyphens, removing special characters, and handling accented characters. Similar to slug
generation in Django or other web frameworks.
Parameters:
@DeveloperOfficeCom
DeveloperOfficeCom / uniqueSet.cfm
Created July 19, 2025 14:56
UniqueSet function for ColdFusion/Lucee - Set data structure for unique values with set operations
<!---
UNIQUESET Function
Description: Creates a set data structure that stores only unique values, similar to Python's set()
or JavaScript's Set(). Automatically prevents duplicates and provides set operations like union,
intersection, and difference.
Parameters:
- initialData: Optional data to initialize the set (array, string, or delimited list) (optional)
- delimiter: If initialData is a string, the delimiter to split on (optional, default: ",")
@DeveloperOfficeCom
DeveloperOfficeCom / fileNameSplit.cfm
Created July 19, 2025 14:14
FileNameSplit function for ColdFusion/Lucee - Split filename into base and extension
<!---
FILENAMESPLIT Function
Description: Splits a filename into base name and extension. The extension is everything from the
last dot to the end, including the dot. Special cases like hidden files (.bashrc) are handled correctly.
Parameters:
- path: The file path or filename to split (required)
Returns: Array with two elements [basename, extension]
@DeveloperOfficeCom
DeveloperOfficeCom / orderedstruct.cfm
Created July 19, 2025 13:28
OrderedStruct function for ColdFusion/Lucee - Struct that maintains key insertion order
<!---
ORDEREDSTRUCT Function
Description: Creates a struct that maintains the insertion order of keys, similar to Python's OrderedDict.
Regular ColdFusion structs don't guarantee key order, but this function preserves the order in which
keys were added for predictable iteration and JSON serialization.
Parameters:
- initialData: Optional struct to pre-populate the ordered struct (optional)
@DeveloperOfficeCom
DeveloperOfficeCom / defaultdict.cfm
Created July 19, 2025 13:09
DefaultDict function for ColdFusion/Lucee - Struct with automatic default values
<!---
DEFAULTDICT Function
Description: Creates a struct wrapper that returns a default value for non-existent keys, similar to
Python's collections.defaultdict. When accessing a key that doesn't exist, it automatically creates
that key with the default value and returns it.
Parameters:
- defaultValue: The default value to return/set for missing keys (required)
- initialData: Optional struct to pre-populate the defaultdict (optional)
@DeveloperOfficeCom
DeveloperOfficeCom / pathexists.cfm
Created July 19, 2025 11:26
PathExists function for ColdFusion/Lucee - Check if path exists as file or directory
<!---
PATHEXISTS Function
Description: Checks if a path exists (either as a file or directory), similar to Python's os.path.exists(). This is a convenience function that combines fileExists() and directoryExists() into a single check.
Parameters:
- path: The path to check (required)
Returns: Boolean - true if the path exists as either a file or directory, false otherwise
@DeveloperOfficeCom
DeveloperOfficeCom / setdefault.cfm
Created July 19, 2025 11:02
SetDefault function for ColdFusion/Lucee - Set struct value only if key doesn't exist
<!---
SETDEFAULT Function
Description: Sets a key to a default value if the key doesn't exist in the struct, similar to Python's dict.setdefault(). If the key already exists, returns the existing value without modification. If the key doesn't exist, sets it to the default value and returns that value.
Parameters:
- struct: The struct to check and potentially modify (required, modified in place)
- key: The key to check/set (required)
- defaultValue: Value to set if key doesn't exist (required)
@DeveloperOfficeCom
DeveloperOfficeCom / pop.cfm
Created July 19, 2025 02:25
Pop function for ColdFusion/Lucee - Remove and return struct value with default
<!---
POP Function
Description: Removes a key from a struct and returns its value, similar to Python's dict.pop(). If the key doesn't exist, returns the default value or throws an error if no default is provided.
Parameters:
- struct: The struct to remove the key from (required, modified in place)
- key: The key to remove (required)
- defaultValue: Value to return if key doesn't exist (optional)