Strip trailing, or repeated, delimiters in a CF list

Found a helpful trick at –
if you want to clean up a list in ColdFusion, take advantage of the fact that CF list functions ignore empty elements. ListChangeDelims() consequently strips off that last “element”.

var cleanList = ListChangeDelims(DirtyList, ",", ",");

For example, I often need this when building an url or file path, especially when a base path is configurable and may or may not have a trailing slash, and depending how the dynamic path is built, it may or not end up with another trailing slash. E.g.,

var pathSeparator = createObject("java","").separator;
var path = ListChangeDelims(listAppend(getConfigBean().getProperty('path_base_directory'), "subdir", pathSeparator), pathSeparator, pathSeparator);

Accessing i18n message in Grails service

Seems (to me) like an obvious need – referencing a translatable message in a service in a Grails app. But you can’t just use g:message – well, I’ve seen some workarounds that let you access the g namespace, but that doesn’t really seem advisable. I just want message handling. I found several references to the […]

Grails beforeUpdate filter fails without

Ok, I know I’m missing something here, but I don’t know what it is. At any rate, trial and error has taught me that my beforeUpdate (and probably beforeInsert too, just haven’t tested that yet) prevent the update (or insert?) from completing, unless I add some extra code to “jiggle” it. Sounds crazy, right? But […]

Reserved words in Grails?

So, I found this list of reserved words in Groovy, but a few times I’ve run into others that seem to be problematic. Not sure if they are actually “reserved”, or where the conflict is for each, but I know I had problems… alternate – so, I had a domain Course, and another domain CourseAlternate […]

Use “name” to add an “id” attribute to g:form (in Grails)

If you want to use the simple syntax <g:form action=’myaction’ />, adding id=”x” will result in a form post to /myaction/x – to get a post to /myaction with a form id attribute of “x”, use the name attribtue instead, as <g:form action=’dologin’ name=’x’ />, per this thread: Alternately, you can use the syntax […]

Pick Link Source in context menu

To add this functionality to Windows, use this awesome extension:

In Rails, html_safe is an adjective, not a verb

Note that in Rails, string.html_safe means that string is known to be safe html, and should not be escaped; otherwise, all strings are escaped by default (for output). It does not mean that string should be escaped to become safe!

Comparing strings to potentially null values in Rails

I’m fairly new to Rails, and Ruby, for that matter, and not yet sure of some basic things. I’ve read a bunch about how to test for (and not test for) nil or empty, and also about how to avoid that need – for instance, see this very useful post on┬á But, I can’t seem […]

Copy command line output to Windows Clipboard directly

Thanks to this article, I found a great, easy way to get command line output into the clipboard. Why? For instance, today I wanted to include a list of files in an email, and I didn’t want to type them or manually copy and paste each file name from file explorer. I could have piped […]

Simple backup logging script for frequently changing sql objects

People talk plenty about data backup, audit trails, etc., and of course that is super-important. But one thing I’ve found is that I sometimes need an easy – or at least, relatively easy – way to either roll back or just view previous versions of sql objects such as stored procedures, functions, and views. Now, […]