Skip to content

Instantly share code, notes, and snippets.

@elpete
elpete / Model.cfc
Created December 7, 2016 13:33
ACF blows up on name attributes combined with docblock name
/**
* @name Model
* @author Someone Else
*/
component name="Model" {
// This syntax blows up in ACF 2016 (maybe earlier as well).
// Only use one "name" attribute
}
@elpete
elpete / Application.cfc
Created November 29, 2016 15:39
In-memory database for testing
component displayname="Application" {
// Set up an in-memory testing datasource
// You may need to install the H2 driver (or Apache Derby, or whatever)
this.datasources[ "testing" ] = {
class: 'org.h2.Driver',
connectionString: 'jdbc:h2:mem:testing;MODE=MySQL',
username = "sa"
};
@elpete
elpete / box.json
Created October 25, 2016 23:19
ForgeBox deploys in one command
{
"scripts":{
"postVersion":"package set location='user/repo#v`package version`'",
"onRelease":"publish",
"postPublish":"!git push && !git push --tags"
},
}
@elpete
elpete / Factory.cfc
Last active October 7, 2016 02:19
cbmodelfactory
component {
variables.factoryDefinitions = {};
public Factory function init() {
return this;
}
public Factory function define( required string model, required struct defaultAttributes ) {
factoryDefinitions[ model ] = defaultAttributes;
@elpete
elpete / ModuleConfig.cfc
Last active October 7, 2016 16:20
Add a ColdBox `applicationHelper` from a module
component {
function configure() {}
function onLoad() {
var helpers = controller.getSetting( "applicationHelper" );
arrayAppend(
helpers,
"#moduleMapping#/models/ModuleApplicationHelper.cfm"
);
@elpete
elpete / Main.cfc
Created September 21, 2016 19:51
Overriding the HTML title in ColdBox (without using cfhtmlhead)
component {
function index( event, rc, prc ) {
prc.title = "This is the updated title";
}
}
@elpete
elpete / nest.cfm
Created August 26, 2016 14:46 — forked from anonymous/trycf-gist.cfm
Convert Flat to Nested Data Structure
<cfscript>
function groupBy( collection, callback ) {
var grouping = {};
for ( var item in collection ) {
var key = callback( item );
if ( ! grouping.keyExists( key ) ) {
grouping[ key ] = [];
}
grouping[ key ].append( item );
@elpete
elpete / DumpCfmlSettings.py
Created June 28, 2016 20:11
Dump out Sublime Text CFML Plugin settings
import sublime, sublime_plugin, json
import CFML
class DumpCfmlSettings(sublime_plugin.WindowCommand):
def run(self):
projects = list(CFML.src.cfcs.cfcs.projects.keys())
self.window.show_quick_panel(projects, lambda i: self.types(projects[i]))
def types(self, project):
dumpTypes = ["Variable Names", "Indexed Files"]
@elpete
elpete / RequestContextDecorator.cfc
Created May 26, 2016 17:31
Simple Request Context Decorator to spoof the HTTP method with hidden _method fields.
component extends='coldbox.system.web.context.RequestContextDecorator' {
string function getHTTPMethod() {
return getRequestContext().getValue('_method', cgi.REQUEST_METHOD);
}
}
@elpete
elpete / build.xml
Created May 11, 2016 20:34
CFML CI Build file
<?xml version="1.0" encoding="utf-8"?>
<project basedir="." default="test" name="CFML CI">
<!--
The CFML CI template project.
For integration instructions, see the Github project page:
https://github.com/coldfumonkeh/cfml-ci
-->