This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
ClassViewer.cfc | |
@hint An almost pure CFML implementation of ClassViewer.class (see http://adamcameroncoldfusion.blogspot.co.uk/2012/08/classviewerjava.html). | |
@description | |
*/ | |
component { | |
// these are just for formatting the output | |
variables._NL = createObject("java", "java.lang.System").getProperty("line.separator"); | |
variables._INDENT = " "; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfset CRLF = chr(13) & chr(10)> | |
<cfsavecontent variable="rendered"> | |
<cfsetting enablecfoutputonly="true"> | |
<cfoutput> | |
<style> | |
<!--- these are inline because I actually need the styles, not a CSS link due to a vagary of the blog ---> | |
<cfinclude template="./styles.css"> | |
</style> | |
</cfoutput> | |
<cfoutput><table border="0" cellpadding="0" cellspacing="0" valign="top"></cfoutput> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component { | |
param name="server.hitId" default=0; | |
server.hitId++; | |
testScopes("in pseudoconstructor before application name is set", "pseudoconstructor"); | |
this.name = "scopeAvailability"; | |
this.sessionManagement = true; | |
testScopes("in pseudoconstructor after application name is set", "pseudoconstructor"); | |
function onApplicationStart(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
// data to test with | |
st = { | |
top1 = "top1 value", | |
top2 = { | |
middle = { | |
bottom1 = [1,2,3], | |
bottom2 = {}, | |
bottom3 = "bottom3 value" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component { | |
this.name = "testPseudoConstructor"; | |
this.applicationTimeout = createTimeSpan(0,0,1,0); | |
this.sessionManagement = true; | |
this.sessionTimeout = createTimeSpan(0,0,0,30); | |
if (CGI.server_name == "localhost"){ | |
this.datasource = "dsn1"; | |
}else if (CGI.server_name == "testing.local"){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfoutput> | |
#expandPath(".")#<br /> <!--- for me outputs D:\websites\www.scribble.local\junk ---> | |
#expandPath("/")#<br /> <!--- for me outputs d:\websites\www.scribble.local\. Note the difference in capitalisation of the drive letter ---> | |
</cfoutput> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
@hint Converts a number from one arbitrary base to another arbitrary base. Is not restricted to bases that Java and CF natively support in their equivalent built-in functions. The internal maths are restricted to the bounds of java.math.BigInteger though. | |
@number The number to convert. | |
@fromBase The base to convert from. Can either be one of BIN, DEC, HEX, BASE36, BASE62 or an 'alphabet' or characters that represent the digits. EG: OCTAL would be 01234567. | |
@toBase The base to convert to. Has same value rules as fromBase. | |
*/ | |
string function baseMToBaseN(required string number, required string fromBase, required string toBase){ | |
if (fromBase == toBase){ // ie: there's nothing to do | |
return number; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// testing | |
test.description = "A fairly easy to visually-test example"; | |
test.number = 255; | |
test._baseFrom = "dec"; | |
test._baseTo = "bin"; | |
test._result = baseMToBaseN(test.number, test._baseFrom, test._baseTo); | |
writeDump(test); | |
test.description = "Another one"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dateNow = createObject("java", "java.sql.Date").init(dateDiff("s", createDate(1970,1,1), now())*1000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
/** | |
@hint creates a function which will wrap passed-in text with the specified tag. Any addition arguments passed to this function will be treated as attribute/value pairs of the tag | |
@tag The tag to wrap the function's text in | |
*/ | |
string function renderWith(required string tag){ | |
var theTag = ""; | |
var attributes = ""; | |
var attribute = ""; | |