Skip to content

Instantly share code, notes, and snippets.

@coldfumonkeh
coldfumonkeh / isWithinWebroot.cfm
Last active December 16, 2015 20:39
A quick function to check if a provided file / folder is within the ColdFusion webroot.
<cfscript>
/**
* Returns true if the specified path is within the webroot of the calling server / template.
* It does not check for the existence of the file / directory in the provided path.
*
* @param path A full path to the file / location to query.
* @return Returns a boolean value
* @author Matt Gifford (me@mattgifford.co.uk)
* @version 1.0.0
* @date 1st May 2013
@coldfumonkeh
coldfumonkeh / twitterdateformat.cfm
Created December 19, 2012 22:40
Handling Twitter's "interesting" date format in ColdFusion
<cffunction name="parseTwitterDateFormat" output="false" returntype="String" hint="I return the date in a useable date format.">
<cfargument name="twitterDate" required="true" type="string" hint="The Twitter date." />
<cfset var formatter = CreateObject("java", "java.text.SimpleDateFormat").init("EEE MMM d kk:mm:ss Z yyyy") />
<cfset formatter.setLenient(true) />
<cfreturn formatter.parse(arguments.twitterDate) />
</cffunction>
@coldfumonkeh
coldfumonkeh / gist:4068955
Created November 13, 2012 22:47
ColdFusion Can't assign requested address
The web site you are accessing has experienced an unexpected error.
Please contact the website administrator.
The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request
Can't assign requested address
ColdFusion cannot determine the line of the template that caused this error. This is often caused by an error in the exception handling subsystem.
Resources:
@coldfumonkeh
coldfumonkeh / errorexample.json
Created October 30, 2012 12:20
Twitter API error response example
{"errors":[{"message":"Sorry, that page does not exist","code":34}]}
@coldfumonkeh
coldfumonkeh / gist:3931411
Created October 22, 2012 13:03
Use the ESAPI canonicalize security function in ColdFusion 8 and 9
<cfset strText = 'Hello, world. This is the &lt;strong&gt;greatest&lt;/strong&gt; example in the world.' />
<!--- Instantiate the ESAPI object. --->
<cfset objESAPI = createObject("java","org.owasp.esapi.ESAPI") />
<!--- Assign the Encoder class to a new variable. --->
<cfset objEncoder = objESAPI.encoder() />
<!--- Canonicalize the provided string. --->
<cfset strClean = objEncoder.canonicalize(strText, false, false) />
@coldfumonkeh
coldfumonkeh / canonicalize_demo.text
Created October 22, 2012 10:15
Use the ESAPI canonicalize security function in ColdFusion 8.01 and 9
<cfset strText = 'Hello, world. This is the &lt;strong&gt;greatest&lt;/strong&gt; example in the world.' />
<!--- Instantiate the ESAPI object. --->
<cfset objESAPI = createObject("java","org.owasp.esapi.ESAPI") />
<!--- Assign the Encoder class to a new variable. --->
<cfset objEncoder = objESAPI.encoder() />
<!--- Canonicalize the provided string. --->
<cfset strClean = objEncoder.canonicalize(strText, false, false) />
@coldfumonkeh
coldfumonkeh / gist:3879844
Created October 12, 2012 15:39
cfmlus_link display using template method
<?php show_cfmlus_link(); ?>
@coldfumonkeh
coldfumonkeh / gist:3879833
Created October 12, 2012 15:37
cfmlus_link shortcode with attributes
[cfmlus_link title="Any other title here" class="my_link_class"]
@coldfumonkeh
coldfumonkeh / gist:3879807
Created October 12, 2012 15:34
cfml.us rendered short code
Short URL: <a href="http://cfml.us/Mf" class="">http://cfml.us/Mf</a>
@coldfumonkeh
coldfumonkeh / gist:3879792
Created October 12, 2012 15:32
cfmlus link shortcode
[cfmlus_link]