Click to search Andy Jarrett.co.uk RSS feed

Loading Twitter

Using RegEx to cut down on code

I sometimes forget how useful/powerful RegEx can be. Take the following bit of CFIF logic

[sourcecode language="plain"] <cfset username = trim(form.uname) /> <cfif len(username) LT 4> <cfset errorMsg = "Your username is too short" /> <cfelseif NOT reFindNoCase("[\w]", username, 1, "false")> <cfset errorMsg = "Your username is too short" /> </cfif> [/sourcecode]

A quick regex guide: the "\w" reference stands for "word character", which translates to [A-Za-z0-9_] n.b.the underscore as well

You can actually add on to the regex and at the same time cut down a lot of the logic by doing the following:

[sourcecode language="plain" gutter="true" toolbar="true" wraplines="true"] <cfif NOT refindnocase("[\w]{4,}", username, 1, "false")> <cfset errorMsg = "Usernames must be 4 characters in length and contain [A-Za-z 0-9 _" /> </cfif> [/sourcecode]

The key is "{4,}". Using the curly braces to specify a specific amount of repetition of "word characters" and is equivilant to "len(username) LT 4"

Comments Comments (2) | Print Print | Send Send | 410 Views

My blog has moved

Please update your bookmarks and feeds for my site.

I now have a Mango Blog at:

http://www.andyjarrett.com/blog

Feed URL: http://feeds.feedburner.com/andyjarrett

Comments Comments (0) | Print Print | Send Send | 1261 Views

Another Linux Railo MySQL install guide (no Apache)

This was meant to be a guide about setting up your server with Linux, Railo, Apache, and MySQL but I've dropped Apache. Why? Well its an overhead I don't need. Resin functions perfectly well as a HTTP server and it does all I need. Why add another bit of software to fail? .... simplify :) In the long run I might change but for now I'd rather save the resources.

So ... where did this guide come from considering there are quite a few guides for this setup? Well for one reason or another I just didn't get on with them and by the end something went wrong which was mainly because I am Mac boy more than a Linux guy and sometimes I just missed the points here and there. The aim of my guide is to be clear and simple. So with a fresh Ubuntu install i'm planning on gettingt Railo running via Resin so I can call http://www.mysite.com/index.cfm

I won't lie, to make this post I have "borrowed" from other sources out there which I will try and link to at the end.

Im running Ubuntu 8.10 (Intrepid) without a graphical interface.

Note: If you are doing this on a clean, new server then before you even read on check out Slicehost.com documentation about setting up a Ubuntu server. These guides are the best and clearest I've seen online to date and cover everything you need!!!!

  1. http://articles.slicehost.com/2008/11/28/ubuntu-intrepid-setup-page-1
  2. http://articles.slicehost.com/2008/11/28/ubuntu-intrepid-setup-page-2

On to Railo

[More]

Comments Comments (3) | Print Print | Send Send | 2777 Views

Im on Railo!

Well I've taken the plunge and moving all my personal projects over to Railo. And so the far the move has been pretty straight forward. Im still playing around with my JVM settings as my VPS has only 256mb memory, so I am just trying to get everything just right.

Though saying that I might just push up to 512mb depending on how adding the next couple of sites being loading on goes.

Comments Comments (1) | Print Print | Send Send | 1030 Views

Railo 3.1, with new UK CEO and install guides

In case you've missed the blogs, tweets, and other general chatter, Railo 3.1 (open source) is released to the public. Check it out at getrailo.org/.

Also, in a dubious April 1st post Mark Drew has joined the team at their UK office in London as CEO!! (Congrats Mark!!)

Also the Railo Blog has a post linking to Installation guides. Obviously I haven't checked them all but Luis Majano's (of ColdBox) does have an excellent Railo (Resin) Apache and Mac OS X guide

Comments Comments (1) | Print Print | Send Send | 1157 Views

Scotch Railo on the rocks

The last session of yesterday which I didn't get a chance to blog about, due to discovering the free <cf_beer>, was Railo on the Rocks.

Gert spent the first part of session detailing what Railo is and how its changing from the 1.1 beta to the 2.0 version due to a change in the underlying architecture. He then went on to explain some of the key differences with the Railo administration functions, and how it offers more control to the overall server admin, which then cascades down into individual admin account per web context (domain/web site).

Next was resources. Resources at the heart are mappings with one key differnce the mapping no longing has to be a physical drive. You could apply a mapping to an FTP account even a zip file. With an FTP account mapped you can then use cffile action="write" to upload file specifying the destination as your mapping! No need to go near the dreaded <cfftp>

I'm now waiting for part two today.

Comments Comments (0) | Print Print | Send Send | 1661 Views

Railo blog now online

The Railo Blog is now online. Gert Franz from Railo has now added a BlogCFC so you can catch up on all the happenings with this CFML engine.

The first couple of posts have already been good with the team going over Mark Drew's post and Vince Bonfanti's proposal about comparing CMFL engines.

Check it out at www.railo.ch/blog/

Comments Comments (0) | Print Print | Send Send | 3558 Views

Railo groups

I can't seem to find any reference on the site (it's probably right in front of my face and I can't see it) but incase you don't know Railo also has a Yahoo groups list which I think is the officail(ish) list.

You can join at http://tech.groups.yahoo.com/group/railo_talk/

Comments Comments (0) | Print Print | Send Send | 2077 Views

Getting Railo installed and started on your Mac

Woohoo, this has been fun. As most of you know i'm a total Mac newbie. So not having everything done and wrapped in .exe files has been hard to process this year. Don't get me wrong. Installing and uninstalling apps on a Mac couldn't be easier and anyone who has made the switch can testify to that. But when it comes to servers its just never seems as straight forwads as a Windows experience. So after a couple of hours of reading and understanding command lines and arguments etc i've finally managed to get Railo installed without emailing anyone and screaming helppppp! which for me is a first. (Hat tip here for Mark Drew who has been on the other end of most of my screams and always helped me)

These were instructions oringinally for the *nix platform (which is what Mac is in essence), so if you are having trouble getting off the ground with Ubuntu etc. you can use these steps as well.

So back to installing Railo on your Mac (in as easy as I could make it steps). You should know that we are going to use the application server that comes with Railo called Resin.

[More]

Comments Comments (1) | Print Print | Send Send | 2895 Views

ColdFusion on Railo

As you know from a previous post, i've been looking at the possibilities of setting up a cheap CF enviroment. What I didn't mention is Railo. I remember hearing about this probably a year plus ago, and Gert Franz (Railo core developer) reminded me on the HoF again.

Well what can i say. Its shocked me a little. I've been using the Railix version which "is a fully installed and configured version that can be used instantly. This version contains a fully functional Java Server (Jetty). You can use Railo without having installed any Webservers. " To set this up all i had to do was unzip the downloaded file to c:\railo\ and run start.bat. From there it was all ready to go at http://127.0.0.1:8888/.

[More]

Comments Comments (1) | Print Print | Send Send | 2072 Views

Previous Entries

BlogCFC by Raymond Camden + Twitter @AndyJ + ColdFusion jobs + Contact Me + Snippets/Downloads + RSS .