Skip to content

Instantly share code, notes, and snippets.

View boughtonp's full-sized avatar

Peter Boughton boughtonp

View GitHub Profile
@boughtonp
boughtonp / Usage Example for isSameInstance custom assertion
Last active August 29, 2015 13:57
Workaround for incorrect assertSame / assertNotSame functionality in Testbox - for official fix see https://ortussolutions.atlassian.net/browse/TESTBOX-76
addAssertions( new path.to.below.Component() );
$assert.isSameInstance( ObjA , ObjB );
@boughtonp
boughtonp / gist:9705827
Created March 22, 2014 11:39
StructToQueryString
<cffunction name="StructToQueryString" returntype="String" output=false access="public"
hint="Converts a struct into a url-encoded querystring."
>
<cfargument name="Data" type="Struct" required=true />
<cfset var QS = '' />
<cfif NOT StructCount(Arguments.Data)><cfreturn '' /></cfif>
<cfloop item="local.Key" collection=#Arguments.Data#>
@boughtonp
boughtonp / Application.cfc
Last active August 29, 2015 13:58
Using JSoup on CF10 with input from CFHTTP
component
{
This.Name = "jsoup_with_cfhttp";
This.JavaSettings = { LoadPaths:["./jsoup-1.7.2.jar"] };
}
@boughtonp
boughtonp / gist:dcd50e8e654c705df6c8
Created April 30, 2014 18:53
QueryStringToStruct
<cffunction name="QueryStringToStruct" returntype="struct" output=false access="public"
hint="Converts a querystring into a struct of name value pairs."
>
<cfargument name="QS" type="string" required=true />
<cfargument name="Decode" type="Boolean" default=true />
<cfargument name="Delimiter" type="String" default=","
hint="Used to delimit values provided from multiple keys of same name."
/>
<cfset var Results = StructNew() />
<cfsetting showdebugoutput=false />
<cfset ascii32to126 = "!""##$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~">
<cfcontent reset type="text/plain">
<cfoutput>
Unmodified:
#ascii32to126#
encodeForJavaScript:
#encodeForJavaScript(ascii32to126)#
@boughtonp
boughtonp / NameCase.cfm
Created June 1, 2014 15:40
NameCase - Capitalise first letter of each word, with exceptions (McIntire,Mackie,O'Connor)
<cffunction name="NameCase" returntype="String" output=false access="public"
hint="Capitalise first letter of each word, with exceptions (McIntire,Mackie,O'Connor)"
>
<cfargument name="Text" type="String" required=true />
<cfscript>
// Uppercase first letter of every word, except special cases...
var Name = rereplace
( lcase(Arguments.Text)
, "\b(?!(?:a[lp]|dell[ae]|de[rl]?|d[ai]|l[eo']|of|the|v[oa]n)\b)\w+"
<cfset qry=query(a:["susi's"])>
<cfset SampleText="Susi's">
<cfset i = 0/>
<cftry>
<cfset TestCase[++i].Label = "no attr,no func" />
<cfcomponent output="false">
<cffunction name="init">
<cfargument name="InputFile" type="String" />
<cfset Variables.SourceFile = Arguments.InputFile />
<cfset Variables.ContentXml = XmlParse( "zip://" & Variables.SourceFile & "!content.xml" ) />
<cfset Variables.MetaXml = XmlParse( "zip://" & Variables.SourceFile & "!meta.xml" ) />
variable [PLUS] doesn't exist
at railo.runtime.type.scope.UndefinedImpl.get(UndefinedImpl.java:256):256
at templates.error.error_cfm$cf.call(<webroot>\WEB-INF\railo\context\templates\error\error.cfm:15):15
at railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:727):727
at railo.runtime.PageContextImpl.handlePageException(PageContextImpl.java:1789):1789
at railo.runtime.listener.ModernAppListener.onError(ModernAppListener.java:370):370
at railo.runtime.PageContextImpl.execute(PageContextImpl.java:1981):1981
at railo.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:282):282
at railo.loader.servlet.CFMLServlet.service(CFMLServlet.java:32):32
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820):820
<cfsilent>
<cfapplication name="Test_StringConcat" />
<cfif NOT StructKeyExists(application,'counter')>
<cfset application.counter = 0 />
<cfset application.m0_total = 0 />
<cfset application.m1_total = 0 />
<cfset application.m2_total = 0 />
<cfset application.m3_total = 0 />
</cfif>