Skip to content

Instantly share code, notes, and snippets.

@jbuda
jbuda / gist:5196046
Created March 19, 2013 13:21
ColdBox datasource settings
<YourSettings>
<Setting name="TransferSettings.datasourcePath" value="/config/datasource.xml.cfm" />
<Setting name="TransferSettings.configPath" value="/config/transfer.xml.cfm" />
<Setting name="TransferSettings.definitionPath" value="/config/definitions" />
</YourSettings>
@jbuda
jbuda / gist:5196038
Created March 19, 2013 13:19
ColdBox datasource
<datasource xmlns:xsi="xsd/datasource.xsd">
<name>YOURDSN</name>
<username></username>
<password></password>
</datasource>
@jbuda
jbuda / gist:5195980
Created March 19, 2013 13:11
Find and Replace on Database - MySQL
BEGIN
/*
PARAMETERS EXPECTED
- IN p_db VARCHAR
- IN p_from VARCHAR
- IN p_to VARCHAR
*/
DECLARE l_end INT DEFAULT 0;
@jbuda
jbuda / gist:5195899
Created March 19, 2013 12:58
CouchDB mod rewrite
# ignore following directories
RewriteRule ^(assets|views|controllers|layouts|services)(/.*)?$ - [NC,L]
# attempt redirect of the short url
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_URI} !index.cfm
RewriteRule ^(.*)$ index.cfm?go=main.redirect&s=$1 [L]
@jbuda
jbuda / gist:5195880
Created March 19, 2013 12:56
Application.cfc for CouchDB
this.default = structNew();
this.default.url = '__APPLICATION-URL__';
this.default.dbhost = '__COUCHDB-HOST__';
this.default.port = '__COUCHDB-PORT__';
this.default.dsn = '__MYSQL-DSN__';
this.default.dbtype = '__DBTYPE__';
this.default.db = '__COUCHDB-DATABASE__';
@jbuda
jbuda / gist:5195861
Created March 19, 2013 12:53
CF resize and save image
<cfdirectory action="list" directory="#expandPath('/imgs')#" name="imgs" filter="*.jpg" />
<cfoutput query="imgs">
<cfimage source="#directory#/#name#" name="img" />
<cfset ImageGrayscale(img) />
<cfset imageScaleTofit(img,200,'') />
<cfimage source="#img#" action="write" destination="#expandPath('/finalimages/')##listFirst(name,'_')#.jpg" overwrite="no" />
<cfflush>
#name# done <br/>
</cfoutput>
@jbuda
jbuda / gist:5195846
Created March 19, 2013 12:52
CF loop through PDF and find images
<cfdirectory action="list" directory="#expandPath('/temp')#" name="pdfs" filter="*.pdf" />
<cfoutput query="pdfs">
<cftry>
<cfpdf action="extractimage"
source="#directory#/#name#"
destination="#expandpath('/imgs')#"
format="jpg"
imageprefix="#listFirst(name,'.')#_"
pages="1"
@jbuda
jbuda / gist:5195839
Created March 19, 2013 12:50
CF file download via FTP
<cfsetting requestTimeOut="100000" />
<cfoutput query="pdfsToDownload">
<cfftp action="getFile"
server="__server__"
username="__username__"
password="__password__"
localfile="#expandPath('\temp\')##listLast(file,'/')#"
remoteFile="__remotefile__" />
</cfoutput>
@jbuda
jbuda / gist:5195810
Created March 19, 2013 12:47
Pre-populating MuraCMS form field within the ContentRenderer.cfc
<cffunction name="dspObjects" access="public" output="false" returntype="string">
<cfargument name="columnID" required="yes" type="numeric" default="1">
<cfargument name="ContentHistID" required="yes" type="string" default="#event.getValue('contentBean').getcontenthistid()#">
<cfset var rsObjects="">
<!--- get the string from super --->
<cfset var theRegion=trim(super.dspObjects(arguments.columnID,arguments.ContentHistID)) />
<!--- using the returned string look for any form to pre-polulate --->
<cfset bodystr = theRegion />
<cfset bodystrRes = refindnocase(">form.*?(name)*<",bodystr,1,true) />
@jbuda
jbuda / gist:5195801
Created March 19, 2013 12:45
HTML simple form
<form name="testForm" action="" method="post">
<label>Favourite language: </label><input type="text" name="technology" id="technology" />
</form>