Skip to content

Instantly share code, notes, and snippets.

View mjclemente's full-sized avatar

Matthew J. Clemente mjclemente

View GitHub Profile
component hint="wrapper for Salesforce REST 2.0 API" {
pageEncoding "utf-8";
/**
Copyright (C) 2012 Daniel Watt
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
@mjclemente
mjclemente / date.cfc
Created March 7, 2020 11:30
Get File Creation Date with Java and ColdFusion
// Sourced from https://stackoverflow.com/a/41191422
// Get file attributes using NIO
var nioPath = createObject("java", "java.nio.file.Paths").get( filePath, [] );
var nioAttributes = createObject("java", "java.nio.file.attribute.BasicFileAttributes");
var nioFiles = createObject("java", "java.nio.file.Files");
var fileAttr = nioFiles.readAttributes(nioPath, nioAttributes.getClass(), []);
writeDump( var='#parseDateTime(fileAttr.creationTime().toString())#', abort='true' );
@mjclemente
mjclemente / singleLine.cfm
Created October 10, 2019 20:00 — forked from JamoCA/singleLine.cfm
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"));
}
@mjclemente
mjclemente / syntax.css
Last active June 27, 2019 10:38 — forked from edwardhotchkiss/syntax.css
Solarized Light Pygments CSS / Jekyll
.highlight {
background-color: #efefef;
border: 1px solid #ddd;
-moz-box-shadow: 1px 1px rgba(0,0,0,0.1);
-webkit-box-shadow: 1px 1px rgba(0,0,0,0.1);
box-shadow: 1px 1px rgba(0,0,0,0.1);
overflow: hidden;
}
@mjclemente
mjclemente / create-docker-servers-doctl.sh
Last active March 19, 2021 15:30
Create Docker Hosts on DigitalOcean with doctl
#!/bin/bash
#For more details, see: https://blog.mattclemente.com/2019/03/04/script-docker-host-creation-digitalocean-doctl.html
DO_DROPLET_NAME=docker-node
DO_SIZE=s-1vcpu-1gb
DO_REGION=nyc1
DO_SSH_IDS=$(doctl compute ssh-key list --no-header --format ID)
DO_TAGS=demotag
DO_DROPLET_COUNT=3
@mjclemente
mjclemente / task.cfc
Created January 17, 2019 20:04 — forked from bdw429s/task.cfc
CommandBox Task Runner to download packages from RiaForge
/**
* Scrape all the binaries from RiaForge
*/
component {
property name="progressableDownloader" inject="ProgressableDownloader";
property name="progressBar" inject="ProgressBar";
function run() {
directoryCreate( resolvePath( 'downloads' ), true, true );
var projects = deserializeJSON( fileRead( 'http://riaforge.org/index.cfm?event=json.projects' ) );
@mjclemente
mjclemente / create-digitalocean-servers.sh
Last active March 24, 2021 10:16
Create Docker Hosts on DigitalOcean with Docker Machine
#!/bin/bash
#Based on: https://github.com/BretFisher/dogvscat/blob/master/create-servers.sh
#For more details, see: https://blog.mattclemente.com/2018/07/15/create-docker-nodes-on-digitalocean-with-shell-script.html
#Approach without Docker Machine: https://gist.github.com/mjclemente/ada1a591bce5f4fedcd6d6d992d95705
args=(
--driver=digitalocean
--digitalocean-access-token="${DO_TOKEN}"
@mjclemente
mjclemente / acf-bug-check.md
Last active February 22, 2018 20:34
PUT/PATCH request body being lost on Windows Server, IIS 8... but not with built-in web server

When I run the following with ColdFusion's built-in web server, the content of the request shows the request body

When I run it on a Windows Server, running IIS 8, the request body is empty. That is, the body of the PUT or PATCH request is lost. POSTs are handled without issue.

Also, it doesn't matter if the PUT/PATCH originates from ColdFusion or from an external source, like Postman; the result is the same.

In both cases, I'm running ACF 11.

Content of index.cfm


@mjclemente
mjclemente / isEmailDomainValid.cfm
Last active January 30, 2018 21:35 — forked from JamoCA/isEmailDomainValid.cfm
ColdFusion UDF to validate if an email address' MX record exists.
<!--- NOTE: This technique is not 100% accurate because some DNS servers don't allow MX queries or may be slow to respond,
but this will identify addresses that are potentially bad or suspicious. --->
<!--- some elements are incorporated from @pfreitag's post here: https://www.petefreitag.com/item/487.cfm --->
<cfscript>
public boolean function isEmailDomainValid( required string email, string dnsServer = '8.8.8.8', numeric timeout = 2000, numeric retries = 1 ){
var mxRecords = [];
var emailDomain = email.listLast( '@' ).trim();
if ( !isValid( 'email', email ) )
return false;
@mjclemente
mjclemente / parseArn.cfc
Last active January 11, 2018 22:49
Parses an Amazon Resource Name (ARN) and returns its component parts as an object.
/**
* @hint Parses an Amazon Resource Name (ARN) and returns its component parts as an object.
* This follows the general format of ARNs outlined by Amazon (http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html), but does not fully account for all possible formats
* Derived from https://gist.github.com/gene1wood/5299969edc4ef21d8efcfea52158dd40
*/
public struct function parseArn( required string arn ) {
var elements = arn.listToArray( ':', true );
var result = {
'original' : arn,
'arn' : elements[1],