Closures in ColdFusion: Structures/Collections

Railo 4 supports closures (a.k.a. anonymous functions) in ColdFusion.

I’ve been playing with the different ways of using them in the various apps I am building at Straker Translations.

Today there was a need to loop over the keys of a structure (a.k.a. associative arrays) and add the value of all the keys.

The usual idiom of regular ColdFusion code would be to use <cfloop> to go over all the keys and do the addition.

With Railo closures it is much simpler. Here is the code:

It is simple and elegant. Makes the code much more succinct and powerful.

Alfred, Search Railo Wiki Using Google Please

Looks like the Railo team have been slowly migrating documentation on the various tags across from the old wiki to Github wiki. If you are like me, and like to refer to documentation every now and then, it is a bit pain to search for a particular function or tag in the Github wiki.

Google and Alfred come to rescue.

Suppose you want to see documentation on the cfcontent tag, first you get Google to do the hard work for you by entring the following in the search bar of your browser:

http://www.google.com/search?q=cfcontent&as_sitesearch=github.com%2Fgetrailo%2Frailo%2Fwiki%2F&q=cfcontent+site:github.com%2Fgetrailo%2Frailo%2Fwiki%2F

As you can see you can specify the URL to search (which is the Railo Github wiki) and query as ‘cfcontent’.

As you want to search for different terms you can substitute ‘cfcontent’ with the name of the ColdFusion function/tag you want more information on.

But it soon gets a pain in the neck as you have manually hack the URL each time.

That is where Alfred comes in very handy.

Create a Custom Search (in Preferences > Web Search). Use the following URL, and test.

http://google.com/search?q={query}&as_sitesearch=github.com%2Fgetrailo%2Frailo%2Fwiki%2F

Give the keyword ‘railo’ or whatever suits your fancy.

Custom Railo Wiki Search

To make this even better, you can use use the “I’m Feeling Lucky” functionality of Google Search to directly take you to the first page of the search results. You can create another custom search in Alfred using the following URL.http://www.google.com/search?btnI=I%27m+Feeling+Lucky&ie=UTF-8&oe=UTF-8&q={query}&as_sitesearch=github.com%2Fgetrailo%2Frailo%2Fwiki%2F

Now, whenever you launch Alfred, and use the keyword ‘railo’ or whatever you set up, you can type the name of the ColdFusion tag/function after they keyword, and it will open up the search results from Railo Github wiki in your browser!

If you use another program like Alfred, the same URLs can be used in the format that suits those programs.

Sublimate – Open in Sublime Text 2

Subliminate - Open Files/Folders in Sublime Text 2 using Path FinderIntroducing Sublimate — a Mac-only application to open files/folders in Sublime Text 2 by selecting them in Path Finder.

Think of Sublimate as “Open in Sublime Text 2” command that works in Path Finder.

You can select a single folder or a single file, or multiple folders and/or multiple files. Sublimate handles them all by opening them in Sublime Text 2.

Instructions

  • Download Sublimate or clone the Git repository (https://github.com/indynagpal/sublimate).
  • Copy Sublimate.app to a folder of you choice (e.g., /Applications)
  • Browse to the folder in Path Finder, and drag the Sublimate application to the Toolbar on top.
  • To open a folder/file in Sublime Text 2, select it in Path Finder and click the Sublimate button in the toolbar.

Using Sublime Text 2 with ColdFusion

I’ve been using Sublime Text 2 over the past few days. Since it is fairly compatible with TextMate syntax and language files, I’ve ported the snippets from the ColdFusion TextMate bundle (CFTextMate) to Sublime Text 2. I’ve also added a bunch of snippets that I use myself and find handy.

The plugin and install instructions are available at:

https://github.com/indynagpal/coldfusion-sublime-text-2

 

In addition, I’ve also customized the Merbivore Soft color scheme that I use. So working with it feels as nice as the editor itself.

Edit: Please use https://github.com/SublimeText/ColdFusion for the community-developed package.