Skip to content

Instantly share code, notes, and snippets.

View evagoras's full-sized avatar

Evagoras Charalambous evagoras

View GitHub Profile
@elpete
elpete / .travis.yml
Last active April 29, 2018 02:06
Multi-engine CI for Travis with CommandBox 3.1.0
language: java
sudo: required
jdk:
- oraclejdk8
cache:
directories:
- $HOME/.CommandBox
env:
matrix:
- [email protected]
@chippinkston
chippinkston / deORM
Last active May 23, 2017 19:41
Adam Tuttle's deORM
/*** 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 )){
anonymous
anonymous / trycf-gist.cfm
Created April 27, 2017 11:16
TryCF Gist
<cfscript>
q = queryNew("lower,UPPER,Mixed");
cols = getMetadata(q).map(function(col){return col.name;});
writeDump([cols, cols.toList()]);
</cfscript>
anonymous
anonymous / trycf-gist.cfm
Created April 27, 2017 14:11
TryCF Gist
<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;
anonymous
anonymous / trycf-gist.cfm
Created April 28, 2017 21:32
TryCF Gist
<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 );
anonymous
anonymous / trycf-gist.cfm
Created May 1, 2017 17:59
TryCF Gist
<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]);
}
@bdw429s
bdw429s / slackFileDelete.cfc
Last active May 22, 2018 11:01
This is a CommandBox Task Runner that will delete file from your Slack team that are older than 30 days. Please see the first comment for usage instructions.
/**
* 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".' );
}