Skip to content

Instantly share code, notes, and snippets.

View howellcc's full-sized avatar

Clint howellcc

  • 05:39 (UTC -05:00)
View GitHub Profile
@howellcc
howellcc / QueryToStruct-cfscript.cfm
Last active August 29, 2015 14:19
QueryToStruct translated to cfscript
//Credit: Ben Nadel: http://www.bennadel.com/blog/149-ask-ben-converting-a-query-to-a-struct.htm
private any function queryToStruct(required query query,boolean row=false ) {
local.struct = structNew();
if ( arguments.row ) {
local.fromIndex = arguments.row;
local.toIndex = arguments.row;
} else {
local.fromIndex = 1;
local.toIndex = arguments.query.recordcount;
}
@howellcc
howellcc / isDefined-vs-structKeyExists.cfm
Created June 5, 2015 12:31
isDefined vs structKeyExists Performance Comparison
<cfsetting showdebugoutput="false" >
<cfset varName = "testVar#randRange(1,100)#">
<cfset evaluate("url.#varName# = 42") />
<cfset iterations = 100000>
<!--- test when variable is Defined --->
<cfset tickBegin = getTickCount()>
<cfloop from="1" to="#iterations#" index="i">
@howellcc
howellcc / MuraPluginDisplayFallback.cfm
Last active September 18, 2015 17:34
[MuraCMS] - Public display of a plugin's display object with fallback.
<!--- In this example, MuraTweets is a plugin and TwitterTile is one of its display objects.
In my experience, this method of referencing the display will fail once in a blue moon. Usually
fixable by simply doing an application reload. This snippet supplies a fallback in case, for some
reason, the plugin isn't registered within the MuraScope. --->
<cftry>
#$.MuraTweets.TwitterTile($)#
<cfcatch type="any">
<cfset qryDisplayObjects = application.pluginManager.getDisplayObjectsBySiteID(siteID=$.event('siteID'))>
<cfquery name="muraTweetsTwitterTile" dbtype="query">
@howellcc
howellcc / CFMail-in-CFScript
Last active October 8, 2015 20:04
CFMail in cfscript
if(IsDefined("form.mailto") and isValid('email',form.mailTo)) {
mailSvc = new mail();
mailSvc.setTo(form.mailto)
.setFrom(form.mailFrom)
.setSubject(form.subject)
.setType("html");
/* add mailparams */
@howellcc
howellcc / dspEventDate
Created October 19, 2015 14:00
Displaying Mura Event Dates
<cffunction name="dspEventDate" output="true">
<cfargument type="any" name="contentBean" >
<cfset var l = {} />
<cfset l.displayStart = contentBean.getValue("displayStart") />
<cfset l.displayStop = contentBean.getValue("displayStop") />
<cfset l.displayInterval = contentBean.getValue("displayInterval") />
<cfset l.returnVar = "" />
<cfoutput>
@howellcc
howellcc / MuraCMS-email-address-protector.cfm
Created October 28, 2015 16:17
MuraCMS Email obfuscator: Place this code inside of the theme-level eventHandler.cfc
function onRenderEnd (required any $){
request.__muraresponse__ = hideEmails(request.__muraresponse__);
}
string function hideEmails(required string contentBlock){
local.emailRegEx = '[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}';
//first do the mailto links
local.mailToLinks = reMatchNoCase("mailto:#local.emailRegEx#", arguments.contentBlock);
for(local.mailToLink in local.mailToLinks){
@howellcc
howellcc / dspPluginDisplayObject.cfm
Last active January 18, 2017 16:44
MuraCMS: dspPluginDisplayObject: Function will return content of a plugin display object by name.
<!---
Add this function to contentRender.cfc - appReload required.
Then reference by using the following:
#$.getContentRenderer().dspPluginDisplayObject('{plugin title}', '{display Object Name}')#
--->
<cffunction name="dspPluginDisplayObject" >
<cfargument name="pluginTitle" type="string" required="true"/>
<cfargument name="displayObjectName" type="string" required="true" />
@howellcc
howellcc / [MuraCMS] Create Your Own Tracepoint.cfm
Created November 12, 2015 15:23
Snippet for creating your own trace points to show up in Mura's showTrace.
<cfset mytracepoint=$.initTracepoint("clever name for my tracepoint")>
<!--- All the things that I want to see how long they take --->
<cfset $.commitTracepoint(mytracepoint)>
@howellcc
howellcc / [MuraCMS] subpage display region output.cfm
Last active December 17, 2015 16:56
Output the 2nd display region on a sub-page from an interator.
<!--- This snippet will display whatever is in the 2nd display region on a sub-page that you're iterating through --->
<!--- In this example subPage is a child from an iterator. eg: subPage = iterator.next() --->
#$.dspObjects(2,subPage.getValue('contentHistID'))#