Skip to content

Instantly share code, notes, and snippets.

@jsteinshouer
jsteinshouer / CFLint.cfc
Created December 28, 2017 17:24
Example Running CFLint with CommandBox Task Runner
/**
*
* CommandBox Task for running cflint
*
* build/tasks/CFLint.cfc
*/
component output="false" accessors="true" {
/*
* Constructor
@jsteinshouer
jsteinshouer / svn-lint.php
Created December 1, 2017 18:21 — forked from omnicolor/svn-lint.php
Pre-commit SVN hook that runs lint
#!/usr/local/bin/php
<?php
/**
* Pre-commit Subversion script.
*
* @author Omni Adams <omni@digitaldarkness.com>
*/
/**
@jsteinshouer
jsteinshouer / Application.cfc
Created June 26, 2017 21:21 — forked from elpete/Application.cfc
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"
};
@jsteinshouer
jsteinshouer / Mura6.2_setup.boxr
Last active May 17, 2017 17:55
CommandBox script to setup a Mura6.2 development server
# Need latest CommandBox 3.6
# install cfconfig
install commandbox-cfconfig
# install Mura 6.2
install id=https://github.com/blueriver/MuraCMS/archive/6.2.zip
# install git+https://github.com/blueriver/MuraCMS.git#6.2
# Move contents to root folder since they get installed in MuraCMS directory
@jsteinshouer
jsteinshouer / Mura7_setup.boxr
Last active May 10, 2018 18:37
CommandBox script to run a Mura 7 site with an embedded H2 database
# Need latest CommandBox 3.6
# install cfconfig
install commandbox-cfconfig --force
# install mura 7
install muracms
# start server
server start cfengine=lucee@5 rewritesEnable=true openBrowser=false
# setup datasource
@jsteinshouer
jsteinshouer / MultiRecordSetQuery.cfc
Last active November 20, 2020 18:18
Execute queries that return multiple result sets
component output="false" singleton="true" {
/**
*
* Constructor
*
*/
public any function init() {
var serviceFactory = createObject("java", "coldfusion.server.ServiceFactory");
@jsteinshouer
jsteinshouer / MyHandler.cfc
Created November 8, 2016 18:12
Run Coldbox events outside of a Coldbox request
component extends="coldbox.system.EventHandler" {
function myEvent(event,rc,prc,widget=false) {
prc.message = "Test from Coldbox event";
if (arguments.widget) {
return renderView("main/myView");
}
event.setView("main/myView");
@jsteinshouer
jsteinshouer / datepicker-today.js
Created July 21, 2016 22:15
Override Today button in Jquery UI Datepicker
$.datepicker._gotoToday = function(id) {
var target = $(id);
var inst = this._getInst(target[0]);
var date = new Date();
this._setDate(inst,date);
this._hideDatepicker();
}
@jsteinshouer
jsteinshouer / Coldbox.cfc
Created July 13, 2016 17:48
Load custom config setting from JSON file
void function afterConfigurationLoad(event,interceptData,buffer){
//writeDump(controller.getConfigSettings())
var basePath = getDirectoryFromPath(getCurrentTemplatePath());
/* Check for custom configuration file. This should be ignrored */
if (fileExists("#basePath#/CustomConfig.json.cfm")) {
var settingsJSON = fileRead("#basePath#/CustomConfig.json.cfm");
@jsteinshouer
jsteinshouer / snake_to_camel.cfm
Created May 19, 2016 19:39
Snake to Camel Case Utility
<cfparam name="form.snake_case" default="">
<cfparam name="form.camel_case" default="">
<cfparam name="form.upper_camel_case" default="">
<cfscript>
if (len(form.snake_case)) {
form.camel_case = REReplace(form.snake_case, "_([a-zA-Z])", "\u\1", "all");
form.upper_camel_case = REReplace(form.camel_case, "\b([a-zA-Z]+)", "\u\1", "all");
}