Skip to content

Instantly share code, notes, and snippets.

View JamoCA's full-sized avatar

James Moberg JamoCA

View GitHub Profile
@JamoCA
JamoCA / is-ip-within-cidr-range.cfm
Last active December 5, 2024 16:55
Using IPAddress Java Library with ColdFusion to determine if a given address range contains a given IP address. Supports IPv4 & IPv6. cfml
<cfscript>
/* isIpInCIDRRange (Determine if the given address range contains the given IP address. Supports IPv4 & IPv6.)
2024-12-05
Requires IPAddress java library from https://github.com/seancfoley/IPAddress
Author: James Moberg http://sunstarmedia.com @sunstarmedia
GIST: https://gist.github.com/JamoCA/6cee1fae80e25a83be13a840621d1b9d
Blog: https://dev.to/gamesover/testing-if-ip-is-within-a-cidr-range-29jb
X/Twitter: https://x.com/gamesover/status/1864714591646945491
LinkedIn: https://www.linkedin.com/posts/jamesmoberg_heres-how-we-are-testing-if-an-ip-address-activity-7270480668407537665-XUlP
@JamoCA
JamoCA / mssql-column-search-across-all-databases.sql
Created November 20, 2024 18:01
Microsoft SQL query to search across all databases and identify all tables with columns matching a string.
-- 2024-11-20
-- Searches across all databases on a MSSQL server to identify all tables with columns matching a string.
-- modified from https://thedbahub.com/searching-for-a-specific-table-column-across-all-databases-in-sql-server/
DECLARE @DatabaseName NVARCHAR(255)
DECLARE @Query NVARCHAR(MAX)
DECLARE @ColumnName NVARCHAR(255) = 'IPAddress' -- Column name you're looking for
-- Table to store results
CREATE TABLE #Results (DatabaseName NVARCHAR(255), SchemaName NVARCHAR(255), TableName NVARCHAR(255), ColumnName NVARCHAR(255), DataType VARCHAR(255), ColumnLength INT)
@JamoCA
JamoCA / ipAddress-ip4-ipv5-binary-coldfusion.cfm
Last active November 19, 2024 20:05
Using IPAddress Java Library with ColdFusion to Standardize IPv4 & IPv6 Addresses / cfml
<cfscript>
/* ipAddressStringToBinary & ipAddressBinaryToString
2024-11-19
Requires IPAddress java library from https://github.com/seancfoley/IPAddress
Author: James Moberg http://sunstarmedia.com @sunstarmedia
GIST: https://gist.github.com/JamoCA/0e638da6927d341ed61e411f5789b4ec
Blog: https://dev.to/gamesover/using-ipaddress-java-library-with-coldfusion-to-standardize-ipv4-ipv6-addresses-bcn
X/Twitter: https://x.com/gamesover/status/1858964208043651497
LinkedIn: https://www.linkedin.com/posts/jamesmoberg_coldfusion-cfml-activity-7264730444338737152-e8ce
@JamoCA
JamoCA / makeTelLink-udf.cfm
Last active November 15, 2024 17:33
phoneFormat & makeTelLink ColdFusion UDFs - Use to generate cosmetically formatted phone numbers and auto-generate TEL links (with support for extensions).
@JamoCA
JamoCA / getLastWorkWeekInMonth.cfm
Last active November 7, 2024 17:57
getLastWorkWeekInMonth ColdFusion UDF - Returns the date for the start of the last full work week (M-F) in a given month. #CFML
<cfscript>
/**
* getLastWorkWeekInMonth: Returns the date for the start of the last full work week (M-F) in a given month.
*
* @param Month A number representing the month (default = current month)
* @param Year A number representing the year (default = current year)
* @param includeWeekend A boolean flag to indicate whether to require the weekend as part of the decision
* @return Returns a date representing the start of the week.
* @author James Moberg http://sunstarmedia.com, @sunstarmedia
* @version 1, November 7, 2024
<cfscript>
/*
* getQRSVG UDF
* @displayname getQRSVG
* @Dependency Requires Zint executable from https://zint.org.uk/
* @Dependency_Documentation https://zint.org.uk/manual/chapter/4
* @author James Moberg http://sunstarmedia.com, @sunstarmedia
* @version 1
* @lastUpdate 2025-03-13
* @gist https://gist.github.com/JamoCA/fbbd2599102216448ada8e9f85d40b9c
@JamoCA
JamoCA / structToTable.cfm
Last active February 17, 2025 17:51
ColdFusion UDF that accept a struct with simple key-value pairs to generate legacy-valid, email-friendly html table and text-only key-value output
<cfscript>
/**
* structToTable UDF
* @displayname structToTable
* @author James Moberg http://sunstarmedia.com, @sunstarmedia
* @version 1
* @lastUpdate 10/28/2024 15:58
* @gist https://gist.github.com/JamoCA/bc5c58e829e191947f2e34289fd98a5a
* @blog https://dev.to/gamesover/structtotable-generate-htmltext-output-for-displayemail-1mk4
* @twitter https://x.com/gamesover/status/1851046259387469955
@JamoCA
JamoCA / variable-collection-for-unit-test-debugging.cfm
Created October 16, 2024 23:29
Example of defining a default set of variables, setting default values & identifying actual values for debugging or unit tests.
<!--- 2024-10-16
Example of defining a default set of ColdFusion scoped variables, setting default values & identifying actual values for debugging or unit tests.
Tweet: https://x.com/gamesover/status/1846590541833855413
--->
<cfscript>
// Define default scoped variables;
variable_config = [
["id": "attributes.promotionID", "value": ""]
,["id": "attributes.options", "value": ""]
@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();