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
/** | |
* Delete Slack files older than 30 days | |
*/ | |
component { | |
function run( token='', user='' ) { | |
if( !token.len() ) { | |
error( 'Need an API token provided. Edit this task or pass it as ":token=foobar".' ); | |
} | |
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> | |
function prettyPrintJSON (inputJSON) { | |
var engine = createObject("java","javax.script.ScriptEngineManager").init().getEngineByName("nashorn"); | |
engine.eval(" | |
function prettyPrintJSON (data) { | |
return JSON.stringify(JSON.parse(data), null, '\t'); | |
} | |
"); | |
return engine.invokeFunction("prettyPrintJSON", [inputJSON]); | |
} |
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> | |
myjson = '[{"json:order":"6","json:type":"boolean","name":"active","type":"any"},{"json:order":"5","json:type":"number","name":"distributorID","type":"any"},{"json:order":"4","json:type":"string","name":"familyName","type":"any"},{"json:order":"3","json:type":"string","name":"firstName","type":"any","json:column":"strFirstName"},{"json:order":"1","json:type":"number","name":"ID","type":"any"},{"json:order":"2","json:type":"string","name":"title","type":"any","json:serializable":"false"}]'; | |
myarray = deserializejson( myjson ); | |
writeDump(myarray); | |
myarray.sort(function(e1, e2){ | |
return e1["json:order"] - e2["json:order"]; | |
}); | |
writedump( myarray ); |
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
<p>Using closures, it is possible to create an "object-like" struct with cfml and not using any components. It allows you to do encapsulation, have methods, do chaining, etc. It's api is pretty much identical to an object, except that you use a function to create it (instead of new). ACF10+ and Lucee 4.5+</p> | |
<cfscript> | |
//this version encapsulates the value, you cannot update it from the outside | |
function make (required numeric input) { | |
var value = input; | |
var o = { | |
add: function (required numeric input) { | |
value += input; |
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> | |
q = queryNew("lower,UPPER,Mixed"); | |
cols = getMetadata(q).map(function(col){return col.name;}); | |
writeDump([cols, cols.toList()]); | |
</cfscript> |
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
/*** Source: http://fusiongrokker.com/post/deorm ***/ | |
public function deORM( obj = this, depth = 1, depthLimit = 10 ){ | |
var deWormed = {}; | |
if (depth >= depthLimit){ | |
return {}; | |
} | |
if (isSimpleValue( obj )){ | |
deWormed = obj; | |
} | |
else if (isObject( obj )){ |
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
language: java | |
sudo: required | |
jdk: | |
- oraclejdk8 | |
cache: | |
directories: | |
- $HOME/.CommandBox | |
env: | |
matrix: | |
- [email protected] |