Skip to content

Instantly share code, notes, and snippets.

View JamoCA's full-sized avatar

James Moberg JamoCA

View GitHub Profile
@JamoCA
JamoCA / enableWKHTMLTOPDFForms_udf.cfm
Last active October 8, 2024 18:32
enableWKHTMLTOPDFForms - ColdFusion UDF to modify WKHTMLTOPDF binary file so that editable fields can be accessed when using Adobe Acrobat.
<!--- enableWKHTMLTOPDFForms 2024-10-07
ColdFusion/CFML UDF to modify WKHTMLTOPDF binary file so that editable fields can be accessed when using Adobe Acrobat.
GIST: https://gist.github.com/JamoCA/607e2b1b28f2a55006ba9bdf26d4df9b
BLOG: https://dev.to/gamesover/hack-wkhtmltopdf-pdf-to-enable-adobe-acrobat-field-editing-2f6
TWEET: https://x.com/gamesover/status/1843460127757873524
LinkedIn: https://www.linkedin.com/posts/jamesmoberg_hack-wkhtmltopdf-pdf-to-enable-adobe-acrobat-activity-7249486444040175616-jWXh
--->
<cfscript>
public boolean function enableWKHTMLTOPDFForms(required string pdfIn, string pdfOut="", boolean onlyWKFiles=true) hint="Modify a WKHTMLTOPDF binary file so editable fields can be accessed when using Adobe Acrobat." {
local.pdfData = fileread(arguments.pdfIn, "utf-8");
@JamoCA
JamoCA / HeatColor.cfm
Last active September 30, 2024 12:11
ColdFusion HeatColor UDF Demo
<!DOCTYPE html>
<html lang="en"><head>
<meta charset="utf-8">
<title>ColdFusion HeatColor UDF Demo</title>
<link rel="STYLESHEET" href="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.32.0/css/theme.blue.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.32.0/js/jquery.tablesorter.min.js"></script>
<script>
$(function(){
$('#myTable').tablesorter();
@JamoCA
JamoCA / HeatColor.html
Created September 25, 2024 19:39
jQuery HeatColor Documentation saved from Archive.org and updated with CDN paths and repository links
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- saved from url=(0098)https://web.archive.org/web/20160708172357/http://www.jnathanson.com/blog/client/jquery/heatcolor/ -->
<html data-lt-installed="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.32.0/js/jquery.tablesorter.min.js" type="text/javascript"></script>
<script src="https://raw.github.com/joshuanathanson/jquery-heatcolor/refs/heads/master/jquery.heatcolor.0.0.1.js" type="text/javascript"></script>
<style>
body {font-family:"Trebuchet", "Lucida Sans", Courier; font-size:12px;}
@JamoCA
JamoCA / createShadowDom.cfm
Last active September 18, 2024 22:28
createShadowHtml UDF - Using ColdFusion to generate HTML to create & populate a shadow DOM. #cfml
<!--- createShadowHtml UDF - Using ColdFusion to generate HTML to create & populate a shadow DOM.
NOTE: This approach requires using absolute HREF/SRC references for links and static resources.
GIST: https://gist.github.com/JamoCA/0774f707e8b18b61bc95b5f2c39b1f9f
BLOG: https://dev.to/gamesover/embed-a-full-html-document-inline-using-shadow-dom-5d5d
TWEET: https://x.com/gamesover/status/1836493265186754801
--->
<cfscript>
string function createShadowHtml(required string html, string id="", boolean enableLinks=true, string placeholder="Previewable content will be displayed here...") hint="I generate a shadow DOM on-the-fly to preview HTML/CSS (No JS)" {
local.newLine = createobject("java", "java.lang.System").getProperty("line.separator");
local.id = (isvalid("variablename", arguments.id)) ? arguments.id : "shadow" & randrange(10000,99999,"SHA1PRNG");
@JamoCA
JamoCA / streamFind.cfm
Last active September 13, 2024 00:13
streamFind UDF (2015-06-09) Searches the output buffer to determine if a string exists. Works w/Adobe ColdFusion, Railo & Lucee. #cfml
<!--- streamFind UDF (2015-06-09) Searches the output buffer to determine if a string exists. Works w/Adobe ColdFusion, Railo & Lucee CFML.
GIST: https://gist.github.com/JamoCA/3f5f041f2ca5bc0a5358597a5d78c91f
BLOG: https://groups.google.com/g/railo/c/Q4KV0yT7oGk/m/hgLXXMOWtBgJ
TWEET: https://x.com/gamesover/status/1834384722614780095
INSPIRATION: Michael Offner/Railo back in 2012. https://groups.google.com/g/railo/c/Q4KV0yT7oGk/m/hgLXXMOWtBgJ
--->
<cfscript>
boolean function streamFind(required string str, boolean caseSensitive=false) output=true hint="I search the output buffer to determine if a string exists" {
if (arguments.caseSensitive){
return (listfindnocase("railo,lucee", server.ColdFusion.ProductName)) ? getPageContext().getOut().getString().indexOf(arguments.str) neq -1 : getPageContext().getCFOutput().getBuffer().toString().indexOf(arguments.str) neq -1;
@JamoCA
JamoCA / miller-tsv.cfm
Last active September 5, 2024 22:07
Transforming TSV data using ColdFusion & Miller (Commandline FTW!) #cfml
<!--- Transforming TSV data using ColdFusion & Miller (cfml) - 2024-09-05
Gist: https://gist.github.com/JamoCA/94f614fa1b2d881f26f26f9926a9b1fa
Blog: https://dev.to/gamesover/transforming-tsv-data-using-coldfusion-miller-command-line-ftw-3kd
Tweet: https://x.com/gamesover/status/1831816238089302139
Miller: https://github.com/johnkerl/miller
--->
<cfscript>
public void function fixTSVPostalCode(string filename, string fileDir) hint="I perform an inline update to a TSV file and set ZIP+4 to ZIP" {
local.dh = datetimeformat(now(),'yyyymmddHHnnsslll');
@JamoCA
JamoCA / language-detect-compare.cfm
Last active September 5, 2024 00:04
Comparing Language Detection Libraries (& API) Using Java/ColdFusion/CFML.
<!--- Language Detect Comparison 2024-09-04
Gist: https://gist.github.com/JamoCA/b883fbddf0303df8f4b0d597cfc2ae25
Blog: https://dev.to/gamesover/comparing-language-detection-libraries-api-using-javacoldfusioncfml-gkf
Tweet: https://x.com/gamesover/status/1831483382687265201
--->
<cfscript>
tests = [
["type": "English", "text": "A great way to learn Spanish vocabulary is by reading texts, stories or articles that are completely in the language. That is why we have written are own short reading passages in Spanish about different topics."]
,["type": "Greek", "text": "Βίβλος γενέσεως Ἰησοῦ Χριστοῦ υἱοῦ Δαυεὶδ υἱοῦ Ἀβραάμ."]
@JamoCA
JamoCA / convertExcelFile.cfm
Last active August 30, 2024 18:46
convertExcelFile: ColdFusion UDF to convert an Excel file (XLS/XLSX) to CSV/TSV/XML/JSON/SQL/HTML/MHT/DOC/PDF using TotalExcelConverter (command line)
<!---
2024-07-02 convertExcelFile: ColdFusion UDF to convert an Excel file (XLS/XLSX)
to CSV/TSV/XML/JSON/SQL/HTML/MHT/DOC/PDF using TotalExcelConverter (command line)
For use with Windows; Requires https://www.coolutils.com/CommandLine/TotalExcelConverter
Blog: https://dev.to/gamesover/importing-data-from-a-pre-95-excel-2-worksheet-xls-file-56md
Tweet: https://x.com/gamesover/status/1829591479100342454
--->
<cfscript>
public struct function convertExcelFile(
@JamoCA
JamoCA / TempCache.cfm
Last active October 10, 2025 22:37
ColdFusion UDF to temporarily cache data and return a UUID. Good for verifying form posts (ie, like CSRF) or building magic link passwordless logins for monolith web application.
<!--- tempCache UDF (2019-11-22) By SunStar Media
ColdFusion UDF to temporarily cache data and return a UUID. Used for verifying form posts (ie, like CSRF) or building magic
link passwordless logins for monolith web application.
GIST: https://gist.github.com/JamoCA/fd43c189379196b6a52884affea3ad51
Twitter/X: https://x.com/gamesover/status/1803866104491839620
Blog: https://www.mycfml.com/articles/tempcache-udf/
--->
<cfscript>
public any function tempCache(
any inputObject,
@JamoCA
JamoCA / coldfusion-cfml-markdown-test.md
Last active June 3, 2024 18:26
ColdFusion / CFML / CFScript Code Block Syntax Markdown Test

ColdFusion / CFML / CFScript Code Block Syntax Markdown Test

GitHub uses Linguist to perform language detection and to select third-party grammars for syntax highlighting. You can find out which keywords are valid in the languages YAML file.

CFML tag syntax using cfm

```cfm
<!--- CFML goes here --->
```