October 4, 2012

Generating a powerset in ColdFusion

I recently needed to generate a powerset (a set of all subsets) of 3 HTML select boxes. The idea was that a user could choose 1-many options from each box, and they had to choose a value from all 3 boxes (none could be empty). Select #1 had 4 values Select #2 had 7 values Select #3 had 13 values Now, I needed to generate every possible permutation for these 3 select boxes based on the rules I defined above. ... Read more

September 30, 2012

Modifying FW/1 variables.framework properties

FW/1 gives you a nice, clean way to manage framework configuration properties. They’re all wrapped up inside Application.cfc in a structure called variables.framework, you can read more about them here under Configuring FW/1 Applications. Our applications often have a need to use different values for these properties, depending on which environment the application is running in (development, testing, staging, production etc). An example of this might be reloadApplicationOnEveryRequest, which we want as true in development, but false elsewhere else. ... Read more

September 27, 2012

Preventing FW/1 from reinitialising an app via the URL

One of the things that FW/1 allows you to do is configure a reload “key” and “password” which you can use to reinit your application via URL. So inside your Application.cfc you might have: variables.framework = { reload = 'reinit', password = "mysecretkey" … } So you can reinit your application (flush the application scope by re-running onApplicationStart()) by calling something like: http://www.example.com/?reinit=mysecretkey The “reload” and “password” properties can be changed to whatever you want for securities sake. ... Read more

September 26, 2012

Adding a mail server to a Railo instance

We turn off all GUI based administration consoles in our production environments, this includes Railo’s admin area. If you need to configure your Railo instance to include an SMTP server, you can add a line in WEB-INF/railo/railo-web.xml.cfm Open up that file (probably as sudo), look for the tag (which is empty by default) and insert the following: <server port="25" smtp="127.0.0.1" /> The “smtp” attribute should be the IP address of your SMTP server. ... Read more

September 20, 2012

Whitespace issues in cfscript based functions

Ok now we all know that ColdFusion is kind of lame when it comes to whitespace management, unless you specifically have “whitespace management” turned on for your server. I have a function that is used to build the href value of a hyperlink. Nothing special there. However when I viewed the source of the page I was a little surprised to see a mountain of whitespace coming back from the function. ... Read more

August 6, 2012

Turning off sessions for non-https traffic

Today I wanted to configure an application to only set secure cookies. Those are cookies that are only sent back to the server if over a secure (https) connection. The main reason for this is to prevent session hijacking, where a bad guy might sniff the cookie values which links a user to the session “state” on the server. If they managed to do that, (which they could if the session was started on an http:// connection, then if/when the user logged on and was transferred to https://) the bad guy would still have their cookie values and thus would be able to visit the website as the logged in user. ... Read more

March 17, 2012

Find and Replace with line breaks in Eclipse

Often with doing a find and replace you want to use line breaks in the find (or replace) criteria. Sometimes I’ll have a column of data from a csv that I want to modify…whatever. You can now check the “regular expressions” checkbox while doing a file search in Eclipse and specify “\R” to find or replace line breaks (platform independent). Eg replace line breaks with commas: Other interesting and useful options are: ... Read more

August 17, 2011

Customising search results from google cse

Google custom search engine (cse) is pretty cool, in fact it’s very cool. Within minutes you can have the ability to search your entire site all with a snippet of code! And for a nominal fee you can deliver these results without ads :) We use google cse for most of our sites but the other day we ran into a slight problem. The site in question has both public and private access, the public site is delivered over http and has plenty of indexable content. ... Read more

July 1, 2011

FarCry - grouping formtool category items

A new project we’re working has the need to categorise each new content object, for this we use the built in FarCry category/keyword formtool. By default the render type is a multi-select tree, I wanted a single select dropdown. Luckily formtools makes this oh so simple. <cfproperty name="catHTML" type="nstring" required="true" default="" ftSeq="2" ftwizardStep="Content" ftValidation="required" ftFieldset="General Details" ftLabel="Categories" ftType="Category" ftAlias="sections" ftRenderType="dropdown" ftSelectSize="1" ftSelectMultiple="false" ftAliasAsOptGroup="true"> Note that I’ve set the dropdown size to 1 and multiple select to false. ... Read more

June 30, 2011

FarCry Tip - remove install directory

After you install FarCry you must make sure to delete the “install” folder(s) that FarCry leaves behind. Otherwise it’s possible for anyone to access the installer wizard again from your production website, and as it’s the installer they don’t even need to be logged in to cause real havoc. Not good. By default, as of FarCry 6.1.x, there are 2 install folders to delete: farcry.core.webtop.install farcry.plugins.farcrycms.install

© Michael Sharman 2017