Skip to content

Instantly share code, notes, and snippets.

View JamoCA's full-sized avatar

James Moberg JamoCA

View GitHub Profile
@JamoCA
JamoCA / makeLastModifiedDate.cfm
Created December 30, 2024 19:02
Generates an RFC9110 8.8.2 compliant Last-Modified date string for use in an HTTP header using ColdFusion / CFML.
<cfscript>
public string function makeLastModifiedDate(date date=now(), boolean isLocal=true) hint="Generates an RFC9110 8.8.2 compliant Last_Modified date string for use in an HTTP header" {
local.d = (arguments.isLocal) ? dateConvert('local2Utc',now()) : arguments.date;
return datetimeformat(local.d, "ddd, d mmm yyyy hh:nn:ss") & " GMT";
}
</cfscript>
@JamoCA
JamoCA / unicode-strings-for-unit-test.txt
Created December 18, 2024 22:55
Unicode strings for Junicode Unit Testing
𝐂𝐚𝐥𝐥𝐞 𝐁𝐥𝐚𝐧𝐜𝐨𝐬, 𝐂𝐨𝐬𝐭𝐚 𝐑𝐢𝐜𝐚
𝕮𝖆𝖑𝖑𝖊 𝕭𝖑𝖆𝖓𝖈𝖔𝖘
辻󠄁直𣘺
E�l�e�c�t�r�o�n�i�c
readme ∕ .txt
I like 🍕
cámara
caméra
愛忍和
1300395 陆小姐,你好!现在方便接电话吗
@JamoCA
JamoCA / sumologic-fastly-cdn-log.txt
Created December 13, 2024 17:34
Fastly configuration to collect CDN request logs for Sumo Logic (2021-12-13)
{
"service_id":"%{req.service_id}V",
"service_version":"%{fastly_info.version}V",
"time_start":"%{begin:%Y-%m-%dT%H:%M:%S%Z}t",
"time_end":"%{end:%Y-%m-%dT%H:%M:%S%Z}t",
"time_elapsed":%{time.elapsed.usec}V,
"client_ip":"%{req.http.Fastly-Client-IP}V",
"request":"%{req.request}V",
"protocol":"%{req.proto}V",
"host":"%{req.http.Fastly-Orig-Host}V",
@JamoCA
JamoCA / sumologic-fastly-waf-log.txt
Created December 13, 2024 16:52
Fastly configuration to collect WAF request logs for Sumo Logic (2021-12-13)
{
"service_id":"%{req.service_id}V",
"service_version":"%{fastly_info.version}V",
"time_start":"%{begin:%Y-%m-%dT%H:%M:%S%Z}t",
"time_end":"%{end:%Y-%m-%dT%H:%M:%S%Z}t",
"time_elapsed":%{time.elapsed.usec}V,
"client_ip":"%{req.http.Fastly-Client-IP}V",
"request":"%{req.request}V",
"protocol":"%{req.proto}V",
"host":"%{req.http.Fastly-Orig-Host}V",
@JamoCA
JamoCA / sanitizeDash.cfm
Created December 6, 2024 16:41
Convert all Windows-1252 & unicode dashes in a string to a specified character (default=ASCII 45 dash) using ColdFusion/CFML
<cfscript>
/* sanitizeDash - Converts all Windows-1252 & unicode dashes in a string to a specified character (default=ASCII 45 dash)
2024-12-06
Author: James Moberg http://sunstarmedia.com @sunstarmedia
GIST: https://gist.github.com/JamoCA/da8d38a409d41fd4b7abccd782124775
*/
string function sanitizeDash(inputString="", numeric dashAscii=45) hint="I normalize all Windows-1252 & unicode dashes in a string to a specified character" {
return javacast("string", arguments.inputString).replaceAll("#chr(45)#|#chr(150)#|#chr(151)#|#chr(173)#|#chr(8208)#|#chr(8209)#|#chr(8210)#|#chr(8211)#|#chr(8212)#|#chr(8213)#|#chr(8722)#|#chr(11799)#|#chr(11834)#|#chr(11835)#|#chr(65112)#|#chr(65123)#", chr(arguments.dashAscii));
@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