Skip to content

Instantly share code, notes, and snippets.

@jsteinshouer
jsteinshouer / Mura7_setup.boxr
Last active May 10, 2018
CommandBox script to run a Mura 7 site with an embedded H2 database
View Mura7_setup.boxr
# 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 Nov 20, 2020
Execute queries that return multiple result sets
View MultiRecordSetQuery.cfc
component output="false" singleton="true" {
/**
*
* Constructor
*
*/
public any function init() {
var serviceFactory = createObject("java", "coldfusion.server.ServiceFactory");
@jsteinshouer
jsteinshouer / MyHandler.cfc
Created Nov 8, 2016
Run Coldbox events outside of a Coldbox request
View MyHandler.cfc
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 Jul 21, 2016
Override Today button in Jquery UI Datepicker
View datepicker-today.js
$.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 Jul 13, 2016
Load custom config setting from JSON file
View Coldbox.cfc
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
Snake to Camel Case Utility
View snake_to_camel.cfm
<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");
}
@jsteinshouer
jsteinshouer / download_csv.cfm
Last active Apr 22, 2016
CSV Download Example
View download_csv.cfm
<cfset csv = io.queryToCSV(query=qMyQuery,fields="field1,field2,field3,...")>
<cfheader name="Content-disposition" value="attachment;filename=MyCSVFile.csv">
<cfcontent type="text/csv">
<cfoutput>#csv#</cfoutput>
@jsteinshouer
jsteinshouer / contentRenderer.cfc
Created Jun 1, 2015
Mura method for getting a feed based on restrict groups
View contentRenderer.cfc
<cffunction name="getFeedByRestrictGroups" output="false">
<cfargument name="restrictGroups" required="true">
<cfargument name="maxItems" default="20">
<!--- Get the feed object by name --->
<cfset var feed = $.getBean("feed")>
<cfset var item = "">
<cfset feed
.setSortBy("OrderNo")
@jsteinshouer
jsteinshouer / rerelaceNoCaseExample.cfm
Created Jan 20, 2014
Coldfusion rereplace example to remove iframes
View rerelaceNoCaseExample.cfm
<cfsetting showdebugoutput="false">
<!--- Here is some html content with iframes --->
<cfset sOriginalContent = "
<h3>Title Here</h3>
<pHere is a paragraph</p>
<iframe width=""560"" height=""315"" src=""//www.youtube.com/embed/B7UmUX68KtE"" frameborder=""0"" allowfullscreen></iframe>
<p>another paragraph</p>