Wednesday, January 26, 2011

Coldbox Plugin - FormatUtils - useful UDF's by me and others (some inspired by RoR)

Over the years, I have used and created many UDF's in my applications. So when I decided to start using ColdBox, I wanted to start grouping them into plugins. One of the first ones, is my FormatUtils Plugin that has several functions that allow you to work with strings. Below is a list of functions included, credits and what they return.

Before we begin let's assume we assigned the Plugin to rc.FormatUtils in our handler as follows:

  • brFormat(theString)
    Converts every carriage return and/or line feed into a compliant line break <br />

    Example
    Will return:
    Hello World<br />How Are You?
  • pFormat(theString)
    Creates compliant paragraphs and line breaks from carriage returns and/or line feeds, I created this because ColdFusion's built-in paragraphFormat() does not close out paragraphs.

    Example
    Will return:
    <p>Hello World</p></p>How Are You?<br />I am good</p>
  • formatPhone(phone,mask)
    Original Author: Derrick Rapley
    This I grabbed from cflib.org and it has come pretty handy. Basically you can pass a string and a mask and it will return it back in the format you requested.

    Example
    Will return:
    Line 1: (305) 555-1234
    Line 2: 3055551234
  • abbreviate(string,len,append)
    Original Author: Gyrus
    Also from cflib.org and it has come pretty handy. Basically you can pass a string a length and it will truncated to your specified lenght without breaking a word.

    Example
    Will return:
    Line 1: A string like this can go ...
    Line 2: A string like this can go fo
  • urlCrypt(mode,string,closer,key)
    This one I actually have to thank my local CFUG for. In one of our little quizes we use to do before the meeting, a question was asked how to encrypt a string that can be safely passed as a URL and the answer was 2 undocummented functions cfusion_encrypt and cfusion_decrypt. I also saw another way using a mixture of toBase64() and toBinary() in case these functions would no longer work (the alternate method is commented out).

    Example
    Will return:
    Line 1: 1911204E0D130415540F001C6B081C4D10364E241B081E17081D0224453E02142014CB3
    Line 2: the name for me is Giancarlo Gomez
  • pluralize() - singularize() and $singularizeOrPluralize
    The credit to this one goes to 2 other frameworks. The first is of course Ruby on Rails. I went to a presentation to learn more about this language and I fell in love. A simple function called pluralize was introduced to me and I though it was great. Basically pass it a word and a number and get back the plural version of it. So at first I wanted to create it from scratch but I decided to do a little bith of research and found out CF Wheels already had almost the equivalent, so I started from there. The only thing I added which they did not have is for an alternate plural or singular word if one was not found in the predefined rules.

    Example
    Will return:
    20 houses

To close out you should know that it is not necessary to have Coldbox to use this, simply use the CFC as any other and you can take advantage of all these functions.

I created a new git repo where I will begin to add all my code to share. Click on the following link to see this CFC on gitHub:
FormatUtils.cfc on gitHub

Saturday, December 18, 2010

Auquafold's Aqua Data Studio

Well I have made the decision to start working with mySQL just to learn it and have other options than just Microsoft SQL. With that being said one thing that I disliked when working on my Mac is not having a solution (that I liked) to work with MSSQL and I would normally fire up my VM and do what I have to in Microsoft's SQL Studio. I guess saying dislike is even strong because most of the time I needed my VM up as I was developing on it cause of IIS to match the production servers. Regardless, there were times when I would just need to connect to troubleshoot something on prod and having to bring up my VM would be a pain especially cause I have it in an external drive that sits at my desk in my office.

So what is all this dialog have to do with Aqua Data Studio ... well whether you're on a mac, pc, linux or solaris. This tool allows you to connect to a large number of databases. I tried it a long time ago, when it was free and once they went to a paid model I really didn't consider them again. But time has passed and I've been yearning for a great solution and I have to say this does deliver exactly what I want. There is so much that it offers and I think it is best if you just go to their site and check it out.

http://www.aquafold.com/

Their commercial licensing options start at $399 but if you are a student or work on Open Source Projects they will give you a license which I think it is great. Go ahead and check it out!

Head JS and HTML5 Boilerplate

Today I ran into 2 cool links either from another post or video as I was surfing the web earlier today and thought I would share with those that might read this.

The first one is HTML5 Boilerplate.

This appears to be a base template for HTML/CSS/JS which is fast, robust and future-proof. It is not a framework and I honestly have not tried it myself but will definitely look into later this week as I am taking the weekend for my family .... right after this post :-).

To find out more go to http://html5boilerplate.com/

And the second one is head.js which is a 2.3kb script that claims to speed up, simplify and modernize your site. Again, I have not been able to fully test it or read too much about it but it seems cool from the get go. I use prototype and scriptaculous so I will like to see how this works in loading and executing.

To find out more go to http://headjs.com/

Feel free to comment below especially if you have ever used any of these.

Thursday, December 02, 2010

Are Stock Templates Good or Bad for Web Designers?

This morning I read this great article by Brandon Jones that I would love to share with you ....

For years I though the template design business was like a sore on my side but now I truly accept it for how it can help me in my day to day business.

My first template purchase was for the blog I set up for my wife and I for our baby, http://baby.fusedevelopments.com, which was not only easy to implement but very well designed and the supporting files were very well organized (which I loved).

So go read it .... click on the link below ...

http://webdesign.tutsplus.com/articles/general/are-stock-templates-good-or-bad-for-web-designers/

I purchased my template at : http://themeforest.net/