Skip to content

Instantly share code, notes, and snippets.

View mjclemente's full-sized avatar

Matthew J. Clemente mjclemente

View GitHub Profile
@bdw429s
bdw429s / task.cfc
Last active February 23, 2022 22:50
Scan a folder of jars recursively for CVE-2021-44228 vulnerability
/**
* Scan all jars in folder recursivley for log4j vuln
*/
component {
property name="progressableDownloader" inject="ProgressableDownloader";
property name="progressBar" inject="ProgressBar";
/**
* @scanPath absolute or relative path to folder to look for jars
*/
@bdw429s
bdw429s / task.cfc
Created October 6, 2021 03:32
CommandBox Task Runner for creating Screenshot of website with Microsoft's Playwright lib
component {
function run( webURL='https://www.ortussolutions.com' ) {
if( !directoryExists( resolvePath( 'lib' ) ) ) {
command( 'install "jar:https://search.maven.org/remotecontent?filepath=com/microsoft/playwright/playwright/1.15.2/playwright-1.15.2.jar"' ).run();
command( 'install "jar:https://search.maven.org/remotecontent?filepath=com/microsoft/playwright/driver-bundle/1.15.2/driver-bundle-1.15.2.jar"' ).run();
command( 'install "jar:https://search.maven.org/remotecontent?filepath=com/microsoft/playwright/driver/1.15.2/driver-1.15.2.jar"' ).run();
command( 'install "jar:https://search.maven.org/remotecontent?filepath=org/netbeans/external/com-google-gson/RELEASE113/com-google-gson-RELEASE113.jar"' ).run();
}
@JamoCA
JamoCA / symbolsToASCII.cfm
Last active November 15, 2023 20:58
Coldfusion UDF to convert Unicode UTF-8 punctuation and symbols to ASCII7 punctuation for natural language processing (NLP).
<cfscript>
/* 20200604 Map Symbols & Punctuation to ASCII
Convert the Unicode punctuation and symbols to ASCII punctuation and symbols is imperative in Natural language processing (NLP) for preserving the original documents.
Based on mapping from Lexical Systems Group: https://lexsrv3.nlm.nih.gov/LexSysGroup/Projects/lvg/2013/docs/designDoc/UDF/unicode/NormOperations/mapSymbolToAscii.html
Blog: https://dev.to/gamesover/convert-symbols-punctuation-to-ascii-using-coldfusion-java-3l6a
TryCF: https://trycf.com/gist/6f35220d47caa7fdbf75eb884ff1cec7 */
string function symbolsToASCII(required string inputString){
var TempContent = javacast("string", arguments.inputString);
TempContent = TempContent.replaceAll("[\u00B4\u02B9\u02BC\u02C8\u0301\u2018\u2019\u201B\u2032\u2034\u2037]", chr(39)); /* apostrophe (') */
TempContent = TempContent.replaceAll("[\u00AB\u00BB\u02BA\u030B\u030E\u201C\u201D\u201E\u201F\u2033\u2036\u3003\u301D\u301E]", chr(34)); /* quotation mark (") */
@bennadel
bennadel / RetryProxy.cfc
Created July 28, 2017 22:16
Creating A Generic Proxy For Retry Semantics In ColdFusion
component
output = false
hint = "I provide automatic retry functionality around the target component."
{
/**
* I initialize the retry proxy with the given target component. Retries will
* only be applied to "transient" errors. And, since the proxy doesn't know which
* errors are transient / retriable, it must check with the isTransientError()
* function.
@BretFisher
BretFisher / docker-for-mac.md
Last active September 18, 2024 18:51
Getting a Shell in the Docker Desktop Mac VM

2021 Update: Easiest option is Justin's repo and image

Just run this from your Mac terminal and it'll drop you in a container with full permissions on the Docker VM. This also works for Docker for Windows for getting in Moby Linux VM (doesn't work for Windows Containers).

docker run -it --rm --privileged --pid=host justincormack/nsenter1

more info: https://github.com/justincormack/nsenter1


@BretFisher
BretFisher / present.zsh-theme
Last active June 17, 2024 07:01
oh-my-zsh theme for presentations (hides prompt features based on path)
# problem: when presenting, I want to obscure
# my prompt to act like it's at root of file system
# and be very basic with no git info, etc.
# solution: this theme lets you set a ENV to the path
# of your presentation, which will help remove unneeded prompt
# features while in that path
# oh-my-zsh theme for presenting demos
# based off the default rubbyrussell theme
@JamoCA
JamoCA / singleLine.cfm
Created November 29, 2016 17:01
ColdFusion UDF to trim, strip multiple spaces and remove undesireable space characters (non-breaking space, tab, line feed, carriage return)
function singleLine(s){
s = replacelist(s, "#chr(9)#,#chr(10)#,#chr(12)#,#chr(13)#,#chr(160)#", " , , , , ");
return trim(reReplace(s, "[[:space:]]{2,}", " ", "all"));
}
@gene1wood
gene1wood / parse_arn.py
Last active April 25, 2023 17:58
Parse an AWS ARN (Amazon Resource Name) into it's constituent elements
def parse_arn(arn):
# http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html
elements = arn.split(':')
result = {'arn': elements[0],
'partition': elements[1],
'service': elements[2],
'region': elements[3],
'account': elements[4]
}
if len(elements) == 7:
@ghidinelli
ghidinelli / gist:e01b83b6a2e628c17cd5
Created September 13, 2015 23:20
getRemoteAddress() for ColdFusion with or without common load balancers/firewalls
<cffunction name="getRemoteAddress" output="false" access="public" returntype="string" hint="Identify the remote user IP address">
<cfset var pc = getHTTPRequestData().headers />
<cfset var arrIP = "" />
<cfif structKeyExists(pc, "X-Forwarded-For") AND len(pc["X-Forwarded-For"])>
<!--- the x-forwarded-for header sometimes includes values that are too long like "172.27.156.64, 67.98.222.16". The regexp picks out just the matches. http://support.f5.com/kb/en-us/solutions/public/12000/200/sol12264.html --->
<cfset arrIP = reMatch('\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b', pc["X-Forwarded-For"]) />
<cfif arrayLen(arrIP)>
<cfreturn arrIP[1] />
<cfelse>
@kevindb
kevindb / compressHtml
Last active February 16, 2017 22:52
ColdFusion Compress HTML
/**
* @hint Removes whitespace from HTML code
Originally authored by Jordan Clark (JordanClark@telus.net)
*/
public string function compressHtml(
required string html,
numeric level = 2
){
local.response = this.trim(arguments.html);