Yummy Mail! MailSlurper Released!

Posted: 2nd September 2010 by Adam Presley in Development, Java
Tags: , , ,

That’s right, I said it. MailSlurper, the mostly useless mail SMTP server has been released! Not only does it slurp your mail into oblivion, but you can see those doomed emails in an administrative interface now. Woo hoo! Check out the How To guide and download it today!!

My Resume on ColdFusion + FW/1 + CouchDB

Posted: 31st August 2010 by Adam Presley in ColdFusion, Development
Tags: , ,

The last few days I decided I wanted to play around with Apache’s CouchDB, one of the more popular database engines in the No-SQL movement. For those who have never heard of it CouchDB is a database engine written in Erlang, and is an Apache Foundation project. One of the neatest things about CouchDB is that the API is based entirely on RESTful JSON services, so all command to it are HTTP commands like PUT, GET, POST, and DELETE. All data is stored as JSON objects known as “documents”. When you have a chance take a look at it.

For me the project I always fall back to when I want to try something new is my Resume project. I’ve kept my resume online for several years now. My first version of it was to proof-of-concept my PHP framework, and this worked well for a long time. I then modified it to work with ColdFusion, Groovy, and Hibernate with MySQL as the persistence layer. That was fun too. Now I set out to redo this in ColdFusion with CouchDB as the persistence layer.

The result is a ColdFusion application using Sean Corfield’s excellent FW/1 framework, my CouchDB4CF Java facade, and Apache CouchDB. Check it out at http://resume.adampresley.com. I’ll post more soon about how it is built.

My friend, Mr. Steve Good, approached me about a problem he was having where he needed to add a namespace to an HTML tag at runtime. Essentially he was parsing some dynamic HTML and wished to inject an additional namespace into the HTML declaration. Regular expressions to the rescue! The first test I ran was with a blank <HTML> tag. For this example I will be injecting the SVG, or Scalable Vector Graphics namespace. To accomplish this in ColdFusion we simply are using the replaceAll method against the String class in Java.

1
2
3
<cfset old = "<html>" />
<cfset new = old.replaceAll("(?i)(?<=<html)(.*?)>", "$1 xmlns:svg=""http://www.w3.org/2000/svg"">") />
<cfdump var="#new#" />

When you run that you will get something that looks like this.

The next task was to ensure that if the HTML tag already had a namespace our regex won’t erase it, but will instead append the new namespace to it. Let’s see that code.

1
2
3
<cfset old = "<html xmlns=""http://www.w3.org/1999/xhtml"">" />
<cfset new = old.replaceAll("(?i)(?<=<html)(.*?)>", "$1 xmlns:svg=""http://www.w3.org/2000/svg"">") />
<cfdump var="#new#" />

Yup, as we can see by the above screenshot it seems to work! I love me some regular expressions. Happy coding!

Here is a quick way to change the default author name when using JavaDoc comments in your Eclipse projects. Simply edit your eclipse.ini file found in the root directory where you placed Eclipse. I have Eclipse at /opt/eclipse, so my path would be /opt/eclipse/eclipse.ini. Once editing this file add the following line and save.

-Duser.name=Adam Presley

After saving restart Eclipse and when you do a JavaDoc comment and use the author attribute by typing @author and pressing enter on the autocomplete you will see something like this:

1
2
3
4
5
/**
 * Alert some message!
 * @author Adam Presley
 */
function alertSomething(msg) { alert(msg); }

Simple yet useful. Happy coding!

Finally, as requested, my code and slides for my Dallas TechFest 2010 presentation are available for download. If you missed it I presented on taking an existing ColdFusion application (could be anything, PHP, JSP, Groovy + Grails) and incrementally spicing it up with jQuery. Click here to download the code and instructions on getting setup!

Merging Two ColdFusion Structs

Posted: 3rd August 2010 by Adam Presley in ColdFusion, Development
Tags: ,

Here’s a quick little tidbit. My coworker Steve Good asked me if I knew of a quick way to merge two ColdFusion structures together, kind of like how jQuery has the $.extend() method. Well there is in fact a way to do this! And it’s super easy.

Let’s say you have structure one that has two keys, firstName and lastName.

<cfset struct1 = { firstName = "Adam", lastName = "Presley" } />

And now we have structure two that has two keys, firstName and age.

<cfset struct2 = { firstName = "Michael", age = 33 } />

Using a nifty ColdFusion method we can mash the two together in a single line of code.

<cfset structAppend(struct1, struct2) /> <!--- <cfset struct1.putAll(struct2) /> --->

Woah, that was easy! The end result will be a structure that would look like this.

<cfset struct1 = { firstName = "Michael", lastName = "Presley", age = 33 } />

Notice the commented out version. That is the underlying method to do the same thing as StructAppend. The benefit? Nothing I can think of. :)

Enjoy, and happy coding!

Dallas TechFest 2010

Posted: 31st July 2010 by Adam Presley in General, White and Nerdy
Tags: , ,

Yesterday I had the pleasure of attending and speaking at Dallas TechFest 2010. I presented on taking an existing ColdFusion application and spicing it up incrementally using jQuery, the hottest JavaScript library around.

The micro-conference; I suppose you can call it that, was a lot of fun. I attended some pretty good sessions, including MySQL optimization, Event Gateway programming in ColdFusion, and an introduction to Grails and CouchDB. I must say that CouchDB is particularly interesting, and may find its way into one of my projects in the near future.

That aside here are the couple of measly photos I took at the conference.

Adobe Community Professional Pins Are In!

Posted: 26th July 2010 by Adam Presley in General
Tags: ,

Sweeeet. I got home and on my keyboard is sitting a letter from Liz Frederick at Adobe. I open it up and discover that my nifty magnetic ACP pin is in there, as well as stickers! I love stickers!