Utility Function: ListRemoveDuplicates()

I often use lists behind the scenes, and if I'm looping through and processing stuff, I had to reprocess something if its been duplicated in the list.


<cffunction name="ListRemoveDuplicates" access="public" returntype="string" output="false">
    <cfargument name="lsList" type="string" required="false" default="">
    <cfargument name="delimiters" type="string" required="false" default=",">

    <cfset var lsNewList = "">

    <cfloop list="#arguments.lsList#" index="listItem" delimiters="#arguments.delimiters#">
        <cfif NOT listFind(lsNewList, listItem, arguments.delimiters)>
            <cfset lsNewList = listAppend(lsNewList, listItem, arguments.delimiters)>
        </cfif>
    </cfloop>

    <cfreturn lsNewList>
</cffunction>

This should probably be ListRemoveDups() as is more fitting for CF, but I prefer the longer name

 

Utility Function: GetCurrentDirectory()

This one is really short... I use code like this all over the place, and its always cumbersome to do the nested function call every time.


<cffunction name="GetCurrentDirectory" output="false" access="public" returntype="string">
    <cfreturn GetDirectoryFromPath(GetBaseTemplatePath()) />
</cffunction>

 

Utility Function: DateBetween()

I get so tired of doing date comparisons to see if a date is between two other dates. Its not hard, but I always feel like it should be a method.


<cffunction name="DateBetween" output="false" access="public" returntype="boolean">
    <cfargument name="testDate" type="date" required="true" />
    <cfargument name="lowDate" type="date" required="true" />
    <cfargument name="highDate" type="date" required="true" />
    <cfargument name="inclusive" type="boolean" required="false" default="true" />
    
    <cfif arguments.inclusive>
        <cfreturn (lowDate lte testDate AND testDate lte highDate) />
    <cfelse>
        <cfreturn (lowDate lt testDate AND testDate lt highDate) />
    </cfif>
</cffunction>

 

Yet Another Program I Can't Live Without

I admit it: I can't live without Agent Ransack. This little tool is 100 times better then using the standard windows search, its fast, it accepts regular expressions, and it can do searches into the content of files. I use it daily at work and at home.

 

Javascript Maintainablity Lecture by Chris Heilmann

A very nice video of a presentation on Javascript maintainability. It taught me a couple of things, including the use of a configuration object to define IDs and other text in a single location that makes changing the code easier.


Presentation: Chris Heilmann: Maintainable JavaScript, part 1 from Bachelor-ict.nl on Vimeo.


Presentation: Christian Heilmann: Maintainable JavaScript, part 2 from Bachelor-ict.nl on Vimeo.

 

Google Chrome Themes

Just a week or two back I was bemoaning the fact that Google's Chrome browser clashed with my shiny black Zune desktop theme, and now I can fix that too:

http://www.itsalee.com/download-google-chrome-themes-skins-fre

Has several skins and instructions on their installation. Look at the links off that post too, as there are 4 or more posts with skins. Right now I'm rocking a nice dark grey theme that looks just pretty with Zune.

 

More Entries

Jon Hartmann, July 2011

I'm Jon Hartmann and I'm a Javascript fanatic, UX/UI evangelist and former ColdFusion master. I blog about mysterious error messages, user interface design questions, and all things baffling and irksome about programming for the web.

Learn more about me on LinkedIn.