Bluemini.comBluemini.com

Mark Drew

Importing JSON into a Meteor Mongo Database

posted: 19 May 2015

Meteor is a great way to develop fast real-time appliations using JavaScript on both the client and server side. When you are developing these applications it's easy to create new collections of information by adding items doing the following script either in the client or server:

Collection.insert({key:value});

But this is obviously not the most effective way to add lots data!

MongoDB has a tool called mongoimport which you can use to import data straight into a MongoDB instance itself, but that tool doesn't come with Meteor. What to do???

The answer is actually rather simple, all you have to do is install MongoDB but you don't need to run an instance of it, as you are already doing that with your Meteor installation.
Once you have it installed check in the <MongoDB Install Path>/bin and you should see the mongoimport executable. Now, to import some json you need to tell it the host and database of the Meteor instance of MongoBD:

mongoimport -h localhost:3001 --db meteor --collection tweets --type json --file exampletweets.json --jsonArray

That is a long command so let's break it down:
mongoimport is obvisouly the command.
-h is the host and port
--db is the database, in this case it's meteor
--collection is the collection we are going to be importing into
--type is the format of the file we will be importing, in this case a json file of tweets
--jsonArray MongoDB has a strange idea of what a json format is, if you omit this it will want a file in the format:

{key:value} {key:value} {key:value}

Which I am sure you can tell is not JSON formatted. So if you want proper JSON format like:

[ {key:value}, {key:value}, {key:value} ]

You need to add the --jsonArray so that MongoDB accepts it as plain JSON.

 

On a side note here, if you want to find out what host and port your Meteor instance of MongoDB is running on you just have to do:

meteor mongo

And you should get a response like:

MongoDB shell version: 2.6.7 connecting to: 127.0.0.1:3001/meteor meteor:PRIMARY>

Hope that helps!

 

Quick tip: How to run a web server using the curre

posted: 17 May 2015

A lot of times you want to run a simple web server from the current path. Whether it be to see how javascript behaves or if you have linked things right in an html file. A quick tip is to install an npm package called http-server (the clue is in the name!) 

Installation is pretty simple, by the usual npm route:

npm install http-server -g

And then you just have to go to the folder you want to serve files from and do:

node bin/http-server

or the following just worked for me:

http-server

Hope that helps!

CMD: One year on

posted: 01 Apr 2015

Hello Internet

I know it has become a bit of a tradition for me to announce things on the 1st of April. This year it will be slightly different. It will be a good news post. 

I started CMD one year ago today and have to say that it has been one of the most fun years I have had. 

On a personal level, I got married, bought a house and had an awesome honeymoon in Cancun. 

On a professional level, CMD has thrived in the year, we have manged to pay wages, sponsor conferences and even had some awesome swag produced. 

We have had some great clients, we also some interesting products in development and we will be attending  dev.objective() in May which I hope to meet up with faces old and new. 

I am totally looking forward to the next year! 

Cheers!

 

 

Say Hello To Lucee

posted: 29 Jan 2015

Say hello to

More info over at the CMD blog

... 0 ...

posted: 29 Jan 2015

So soon! You can almost hear it.

Are you ready?

... 2 ...

posted: 27 Jan 2015

... coming soon ...

Quick Linux Port Redirect Tip

posted: 20 Aug 2014

A lot of the time when I am deploying applications on Railo, you get the installer, and install a version of tomcat (for example) and then setup Railo and then finally install Apache or NGinx.

This has been working well for a while but what if you dont want that extra webserver layer? There are times where I don't see the point of setting up Apache since all it will be doing (in my case) is proxying from port 80 to port 8080.

There are a couple of things you can do:

  1. Try and change the port in tomcat by editing server.xml
  2. Use iptables to redirect the port without having to install anything else!

 

Recently I got into a Yak Shaving situation where having changed the port of Tomcat to port 80, meant that I need to change the user that Tomcat was going under (and I didn't want to do that!) so meant I had to do a bunch of other stuff and essentially meant that the only way out would be to install a web server. Which seemed overkill for the app (well, service) I wanted to deploy.

IPTABLES to the rescue!

After a quick trawl around the internet I found the solution, which was just to put some redirects in iptables.

sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080

sudo iptables -t nat -I OUTPUT -p tcp --dport 80 -j REDIRECT --to-ports 8080

This achieves the goal I was looking for without the need to configure yet another service (that will need restarting when we do other changes etc)

What do you think? Useful?

Introducing my new company: CMD

posted: 01 Apr 2014

Hello Internet! It gives me great pleasure to announce the start of my new company: CMD

I have been thinking for a long time about the current consultancy market and a segments that I wanted to aim for in with this venture and I am proud to announce the opening of CMD.

CMD is a company that is focused in three areas:

Develop • Deploy • Deliver

CMD helps businesses develop great web and mobile applications using the best of breed technologies. We also focus on the deployment of these applications, be it in the cloud, in locally hosted environments or in other hosting environments to enable the smooth delivery of services and great a great experience for your clients.

The other side of the company is dedicated to developing some best of breed solutions for the developer market. As cryptic as that is at the moment; I hope in the next few months I can share with you some of the great things we are cooking up!

If you would like to find out more, have an idea for a project in which we can help why not head over to  http://charliemikedelta.com and contact us?

Running MongoDB from Sublime Text 2

posted: 08 Nov 2013

For last night's presentation at the CFUG about MongoDB I was running the demos right from Sublime Text 2. This was mainly to be able to increase the font but I was asked how I did it. (I generally use either the mongo shell or RoboMongo which is awesome!)

Here you can see how it was running: 

The way I pulled this off was to create my own Build System called MongoDB:

Now that you have a blank Build system, all you need to do is enter the following:

Of course, replace the path to mongoDB with whatever the path to your installation of mongoDB is! And finally all you have to do is hit the cmd+B buttion and it will then send the path to the current file to mongo. 

I got this working for Sublime Text 2 but in Sublime Text 3 it didn't work as expect the code is not exactly the same. You have to change the build script to the code below:

I can send commands to MongoDB too but it doesn't display anything in the Results pane which is a shame. So if you get it working in Sublime Text 3 let me know! 

 

cf.Objective() Sessions and voting

posted: 08 Nov 2013

Quick Quick! Go over to the cf.Objective() Trello board and vote for some of the session there! There are some awesome topics that are going through for next year's conference and you only have till the 11th to vote what will make the cut! 

I doubt my presentations will make it, but make sure you vote for some excellent talks covering a range of topics (not just CFML!) 

Do it or be a equilateral triangle!

 

https://trello.com/b/4M6JSoyL/cf-objective-call-for-speakers-2014

Presenting MongoDB at the UCFUG

posted: 08 Nov 2013

It was my pleasure to be able to present to the largest turnout at the UKCFUG that we have had for a long time last night! 

Along with Grant Shephert from Mura we did a Google on Air to present MongoDB and "What is new in Mura 6.1", alas due to technical issues Grant couldn't join the Hangout and thus his portion of the video is missing but at least you can see my presentation for MongoDB

Enjoy!

Announcing AOP/1

posted: 27 Jun 2013

I am happy to announce that today I got the AOP/1 framework to Alpha state (Version 0.1)! The AOP/1 framework was inspired from talking to a client that was using DI/1 and I was describing how good it would be to have the ability to intercept methods, as you can with ColdSpring's AOP, but with less definitions (BTW, I know that ColdSpring 2 has radically trimmed down the syntax, which is awesome!). The main issue I have had with ColdSpring's implementation is that it is a great concept but very difficult to describe using the vocabulary (Advisor, Advice, AfterReturningAdvice,NamedMethodPointcutAdvisor,ProxyFactoryBean to name a few) to people.

Another side of it was that I wanted a much simpler way to do this, without having to always resort to looking stuff up in the manual. So I give you AOP/1!

Let's take a simple example. Using AOP/1 is very similar to working with Inject One ( see: Getting Started with Inject One ), since it is just an extension of DI/1, you would first, define your bean factory:

So far all the configuration is identical to DI/1. Let's take a concrete example. Let's say we have a service that reverses a string. This would be defined under /services/Reverse.cfc :

All pretty simple so far! Let's go and get it a full example of using it:

This would output:

!olleH

Everything is fine so far, but what if we want to intercept these calls? Well that is where AOP/1 does the hard work for you. All you have to define is a CFC (in your services if you like, or manually passing all the settings you want) with one or more of the following methods: before, after, around and onerror. In this case we have a before method defined in our BeforeInterceptor.cfc:

Now all we need to do is as above, but just add the fact that we are intercepting:

And that is it! Now all the method calls to the ReverseService will first call the BeforeInterceptor.before() method. So if we now call continue as before and do:

We would now get:

!olleHerofeb

I hope this is a useful framework for people out there, and it allows them to do much more de-coupled development! I would also really like to thank Sean Corfield for allowing this project to under the framework-one family banner!

You can Fork it, Clone it or Download it over at Github

cf.Objective() 2013: Top 10 Railo Features Present

posted: 18 May 2013

Before I forget, I thought I would point you to the code that I used to do my Top 10 Railo features presentation. 

The presentation was actually written using the features and hence there are no slides as such, since it's a living presentation/document that I might add more features of bug fixes to. Hence it's also under version control over in GitHub! 

Go check out the code yourself: https://github.com/cybersonic/railo-top10-features and let me know what you think. 

 

Give Me 5... Please?

posted: 18 Feb 2013

 

On April 6th, I shall be running the Tough 5 in Greenwich Park. This will be a challenge for me, an ex smoker and overweight developer with a penchant for drinking Jack Daniels, as the run is not just nice and level, it is up and down the undulating hills of the park! Should be fun! 

Of course, this is the bit where you expect me to put up a link to my justgiving page or some other charity, but I don't want to do that.

I know a great diversity of people and I am sure you all know a worthy cause, so here is the deal: Just give five of something to the group/charity/community/product of your choice. That's it.  Be it $5, £5, 5 minutes, or 5 hours, it doesn't matter. Just make sure you do it before Saturday April 6th.

Oh, and why not let me know what you did, either privately or by commenting below! 

 

Passing events back to your view in Eclipse

posted: 24 Oct 2012

This is going to be a bit of a technical post, and it's to do with views in Eclipse. I tried to find this all over the place but in the end it was bits and pieces from different posts that actually gave me the answer, which is kinda odd.

So, here’s the problem. You are writing a plugin for Eclipse. You have a view, say a TreeViewer in there that is going to be populated with some content. You do the following:

All is great, we have a content provider which basically allows you to find children and parents in your Tree, and the LabelProvider which displays the right image and label for each item.

The content provider is notified when you change anything in the tree, but how about the other way?

So say I have a background process that updates MyDataStore? How do you then tell the tree to refresh?

This is something that has been bugging me for a long while and today I come up with a quick solution, which I hope works.

First off, we want to somehow subscribe to any changes that MyDataStore might recieve. To do that you can make MyDataStore Observable.

Now whenever MyDataStore is changed (for example, when someone calls the updateMeSomehow() method) you should also add the following calls within the method:

Now in your View, you can add a new observer, that will now have the update() methop triggered whenever something changes in myDataStore!

Now that’s not the end of it. If you were to call (as you would presume) myTreeViewer.refresh() you will get a org.eclipse.swt.SWTException: Invalid thread access error. That is because the TreeView is running in a UI thread, and the thread that updated your DataStore is probably in a different thread (usually). So what you need to do is go back to the Display thread and do the update asynchronously.

I know there are few people out there doing this, but hopefully this will help you, since I couldn’t find this answer that easily (in completeness).

Running Railo from any directory

posted: 11 Sep 2012

Today on the Railo mailing list someone asked if there was a way to start railo from any directory and use that directory as the web root. A fair enough question and it got me intrigued.

So after a bit of research I come up with the following, of course this works for OS X, change the relevant bits to suit your OS (hey, send me how to do it and I shall update the post)

First off, I downloaded Railo Express (3.3.4.003) and saved it to:

/Applications/railo_runner

Then I copied the ./start and renamed it to ./railo_runner

I added the path to ~/.bash_profile by adding:

export RAILO_RUNNER=/Applications/railo_runner/
export PATH=$PATH:$RAILO_RUNNER

so now, to change the railo_runner script. Mine looks like this:

#!/bin/bash
CURRPATH=$(pwd)
cd $(dirname $0)
java -DSTOP.PORT=8887 -DSTOP.KEY=railo -jar -Xms256M  -Xmx512M lib/start.jar -Drespath=$CURRPATH

The only thing I added was the current path and added it as a System property with the -D flag, as you can see by the -Drespath=$CURRPATH. All is good so far, now to tell Jetty to do something with it!

In the /Applications/railo_runner/contexts/railo.xml I changed the system property that is used for the resourceRoot:

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"><Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="contextPath">/</Set>
<!--
  <Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/webroot/</Set>
-->

   <Set name="resourceBase"><SystemProperty name="respath" default="./webroot/"/></Set>
  <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
</Configure>

Now I can do the following:
Earth:~ markdrew$ cd ~/Sites/
Earth:Sites markdrew$ mkdir demo_site1
Earth:Sites markdrew$ cd demo_site1
Earth:demo_site1 markdrew$ railo_runner

And voila! It creates the WEB-INF and you are good to go by http://localhost:8888!

The Evolution of the Railo Company

posted: 22 May 2012

Today I shared some important news about the Railo company and how we are setting up the future. 

You can read the post over in the Railo blog: http://blog.getrailo.com/post.cfm/railo-at-cf-objective-the-evolution-of-railo

In essence we have set it up so we can say to all CFML developers:

CFML is HERE TO STAY
We are MARKETING it
We are SUPPORTING it
We are DEVELOPING it
For the next 10 years and foreseeable future

Viva la Railo-vucion!

Setting the priority of network connections in OS

posted: 01 May 2012

I have recently moved home and I am of course, without cable internet for a while whilst they install it (don't get me started on that yet!). So that I can have a bit of internet, I am using my iPhone tethering feature, but I also want to connect to the house wifi (so I can share printers and what have you). 

The problem comes in that whenever I connect to the wifi (that has no connection to the internet) my computer then ignores my phone (as it should) and therefore I don't have internet connection! 

There is a simple way to change this in OS X: Go to the Apple Menu Item -> System Preferences -> Network

 

Then click on the little gear item below the list of services and select "Set Service Order..."

And finally you can drag up (or down) the priority of the services! 

Railo Book Competition: The Winners!

posted: 29 Feb 2012

A couple of weeks ago I run a competition to win my Railo 3 Beginner's Guide book. So now is the time to announce the winners! 

In first place is Ben B. who wins a signed copy of the book for his myth "The cost for creating a cfc object is minimal and has no real cost."

In joint second place, winning an electronic copy of the book are:
Ray V. with his myth "Is there really a cookie called CFMagic?"
and
Steven R. with his myth "ColdFusion will always timeout to the value I provide in the ColdFusion Adminsitrator."

In third place, winning a mention in my presentation is Brendan with his myth "cfml produced html is full of whitespace"

Congratulations to you all! I shall get the presentation updated for cf.Objective

I have also put the code up on how I run the code and presentation on github, so you can check out the CFML Mythbusters presentation for yourself!

CFML Mythbusters competition: Choosing the winners

posted: 02 Feb 2012

A couple of weeks ago, I posted about running a competition to be in my CFML Mythbusters competition, well the competition is now over and it's time to choose the winners

Before choosing them, I thought I would post the code I am using to choose them and the process, so to be nice and transparent.

First off, everyone could post multiple times and this went into a Google Docs spreadsheet, so they could have multiple entries. Since I could see how many entries there were, for example 1-20, this is easy.

I decided to create an array (because they are much sexier than lists), each position with the number of the entry. Then randomise those positions and then simply choose positions 1,2,3 and 4 from their positions in their array

So here is the code (not including the form, since I am pretty sure you know how to make a form.):

<cfscript>
         aEntries = [];
         loop from="#FORM.from#" to="#FORM.to#" index="e"{
            ArrayAppend(aEntries,e);
         }
            
         collection = CreateObject("java", "java.util.Collections");
         collection.shuffle(aEntries);
      </cfscript>
      <cfoutput>
      <ol>
         <li>First Place: #aEntries[1]#</li>
         <li>Second Places: #aEntries[2]# and #aEntries[3]#</li>
         <li>Third Place: #aEntries[4]#</li>
      </ol>
      </cfoutput>

Did you spot the Java class? Yep! The java.util.Collections class is really handy for manipulating Arrays in different ways, and of course, since (in Railo at least) an Array can be used by the Collections it is perfect.

So what do you think? Is this a fair way to select some random people?

Just for fun: What if your IDE had Achievements?

posted: 19 Jan 2012

Following on from a post that Visual Studio has an Achievements Plugin (very funny if you play on the XBox, Steam or PS3) I was just thinking what Achievements  could we unlock if we had a plugin for CFEclipse (or CFBuilder) whilst coding CFML?

I love some of the ones mentioned here:  http://blog.whiletrue.com/2011/01/what-if-visual-studio-had-achievements/

As a starter for 10, here would be the ones I would add (and any sugestions welcome!) 

 

  • Big Boy Pants: Finally created a CFC
  • If you build it, they will come: Created a build.xml ant file
  • Sign o' the Times: renamed an Application.cfm to Application.cfc
  • So Close!: Created a CFC with more than 20 functions
  • Confusious Say!: Created a function with more than 10 arguments
  • "Where? What??": Have an include with lots of variables that come from "nowhere" (are set in the caller)

What would you add that is CFML specific? 

 

 

 

Competition: CFML Mythbusters! Win my book!

posted: 16 Jan 2012

I shall be presenting the topic "CFML Mythbusters" at a couple of conferences this year so far (cf.Objective and OpenCF Summit)!
So that you just don't have to hear about my chosen "myths" I thought I would open it up as a competition to all the readers of my blog! 

I shall be answering a lot of questions already, but would like to get some reader suggestions, for example, here are just some of the few I have (sent in by some very honorable people I have to say!):

  • “CFScript is always faster! ?Even when using for loops!” - Alfred Einstein
  • “Inline IF’s are much better than <CFIF>. I will stake my stake on it” - Abraham Van Helsing
  • “Is isDefined() bad?” - Abe Simpson
  • “<cfoutput>#Item#</cfoutput> is the only way to go” - Mohandas Gandhi
to give you some ideas!

Of course, it wouldn't be any kind of competition if you didn't win anything! So what's the prize I hear you ask?

  1. First place gets a physical, signed copy of my book, Railo 3: Beginners Guide, their question answered in the presentation (obiously) and my blog, the question dedicated to them and a big shout out when I cover their question EACH time I present it. WOW!
  2. Two second places also get their question answered in the presentation, another shout out, and an electronic version of Railo 3: Beginners Guide
  3. The third place ALSO gets their question answered in the presentation and this blog, and a shout out

I shall be drawing the results at the end of January 2012 so get your thinking hats on and then submit your Myths to be Busted!

Railo 3: Beginner's Guide out now!

posted: 03 Jan 2012

Happy New Year dear readers of my little blog! Just before the break for the holidays I was informed by the awesome guys and gals at Packt Publishing that my book "Railo 3: Beginner's Guide" was finally out!

It wasn't enough that they told me it was out, they even sent me a few paper versions of the book, which I shall of course treasure as my first work in print!

Anyway, the book that is over 300 pages long (actually 364), has 10 chock-a-block chapters filled with Railo Server Goodness:

  • Chapter 1: Introducing Railo Server
  • Chapter 2: Installing Railo Server
  • Chapter 3: CFML Language
  • Chapter 4: Railo Server Administration
  • Chapter 5: Developing Applications with Railo Server
  • Chapter 6: Advanced CFML Functionality
  • Chapter 7: Multimedia and AJAX
  • Chapter 8: Resources and Mappings
  • Chapter 9: Extending Railo Server
  • Chapter 10: Creating a Video-sharing Application

 

Of course, if just reading that list is not enough, why not check out the FULL listing or even download a Sample Chapter?

But instead of just skimming over the top, why not get a full copy if the book? You can get it HERE from the Packt Publishing website! It comes in many flavours, including Paper,PDF, ePub and Mobi downloads and also on PacktLib

If you do get a copy, let me know what you think! I am currently thinking of the next book too!

Enabling Personal Hotspot on your iPhone

posted: 15 Nov 2011

If you have been having problems finding your Personal Hotspot Wifi from your iPhone after the slew of updates recently, here is how I managed to fix it.

Ok, so let's be clear, this is not about finding how to enable it, or if your cellular carrier allows you to use it, but rather, that you used to be able to find your phone in the list of Wifi hotspots, and now when you switch it on, you can't find it.

Not all the steps are necessary, but they worked for me:

  • Rename your phone to something without spaces or strange characters: Settings - General - About - Name
  • Reset your network settings (your phone will reboot): Settings - General - Reset - Reset Network Settings
  • Restart your Personal Hotspot from Network (not from the main screen): Settings - General - Network - Personal Hotspot

I hope this helps!

Accessing complex web services with Railo

posted: 14 Nov 2011

There are a number of times when a webservice returns some very complicated data, or inversely it requires some even more complicated parameters to be sent. In the past I have spent hours trying to figure out how to send the right parameters to remote method calls, but instead of wasting a long time using either Adobe ColdFusion's or Railo Server's Axis adaptors, I go straight to the source, and in this post, I shall show you how to do it. 

To start off, I am just going to use a simple web service I have created, but you can do this for even more complex services and get an idea what they return. 

This is the webservice I am going to be calling:

<cfcomponent output="false">
      <cffunction name="getTime" returntype="String" access="remote" output="false">
         <cfreturn Now()>
      </cffunction>
   </cfcomponent>

Ok, not the most complicated, but I just want to use it so that we all know how to do the process. 

Next, I use a tool that comes with axis called WSDL2Java (both ACF and Railo use this in the background when making webservice calls. In CF they are called stubs), to do this I create a Java Project in Eclipse.

Then I create a lib folder, into which I copy ALL the .jar files that come with Railo Server (all the files in , for example /Railo-Express/lib/ext/). Now you won't need ALL of them but it's easier than trying to find out which ones you need. 

Next, by right clicking on your project > Properties > Java Build Path > Libraries I add all the .jar files that I copied over and click OK 

Awesome, now we are ready to use the WSDL2Java function, create a new run configuration under the "Java Application" section , give it a name and then set the main class to be "org.apache.axis.wsdl.WSDL2Java"

Then in the arguments section, add the WSDL url (in my case http://dev.local:8888/RemoteService.cfc?wsdl):

Now you can click "Apply" and then "Run"

If you now click Refresh on your project you will see a new folder has been added to the root: 

We can now move that folder to the "src" folder in our project to get it to compile:

Now for the real "Java Bit". I tend to write it first in Java to test the service, so create a new class in the src folder of your project, I called in Runner and make sure you tick the create "public static void main(String[] args)" checkbox, you should get some code like:

public class Runner {

   /**
    * @param args
    */
   public static void main(String[] args) {
      // TODO Auto-generated method stub
   }
}

Great, now let's use the ServiceLocator to get our webservice and call methods on it:

public static void main(String[] args) throws RemoteException, ServiceException {
   Remoteservice_wrapServiceLocator ws = new Remoteservice_wrapServiceLocator();
   String timeItem = ws.getRemoteServiceCfc().getTime();
   System.out.println(timeItem);
}

If we run this now we get the time returned from the webservice! But we are not finished yet. You want to use these stubs from your CFML code right?

First thing to do is wrap all this up as a JAR file, luckily this is pretty easy, just right click on the project and select Export... > Java > JAR file, and then select where you want to save it, I am saving it into my /Railo-Express/lib/ as a file called DemoWebService.jar.

Now to restart Railo so that the new jar gets picked up. 

Ok, let's use this in Railo, in this example, I just used the CreateObject() function with the third param that defines which jar to use:

<cfscript>
      ws = CreateObject("java", "local.dev.RemoteService_cfc.Remoteservice_wrapServiceLocator", "/Applications/railo-express/lib/DemoWebService.jar");
      timeItem = ws.getRemoteServiceCfc().getTime();
      WriteOutput(timeItem);
</cfscript>

And there you go, you have called the method easily.

This is a simple example, but if you can do it from Java you can do it from CFML. If there are complex objects to pass, you can just create an instance of that object and pass it to the webservice too. 

CFCamp: JQuery Mobile and Phone Gap

posted: 28 Oct 2011

CFCamp this year was again, a great event! Some awesome presentations from everyone that presentend!

I did promise to post my JQuery Mobile and PhoneGap presentation as soon as, so here you go!

Had a total blast today, I highly recommend this condensed conference! It's a total brain filler!

CFCamp 2011! Be there or be a Pretzel!

posted: 26 Sep 2011

 

Munich! City of Oktober fest and Pretzels! The big soft ones with butter inside. What could be more delicious than that? I tell you what is... CFCAMP 2011 is! 

That's right ladies and gentle-folks, after a three year hiatus, there is going to be a stomping and knowledge-infusing conference in Munich this year, filled to the gills with awesome presenters and me! 

For a measly €90  a ticket (going up to €119 in October, so get them whilst they are fresh!), your mind can be blown by the likes of Charlie Arehart (he of the inside secrets into ColdFusion 10!), Luis Majano (he of the mobile knowledge), Gary Gilbert exposing his JQuery to the public, Bilal Soylu will also be locking down your apps, and of course Andy Allan and myself, giving it all from our presenter's pulpit. 

Sure you can't miss this?!

Head over to http://www.cfcamp.org/anmeldung.cfm to get your tickets (yep, it's in German, just use Chrome and translate it, you are a clever person right?)

 

 

Checking the memory of your applications in Railo

posted: 22 Aug 2011

If you have ever wondered how your memory is being used in a Railo Server application, why not get the latest development release of Railo Server: 3.3.0.026 rc (you know that you can do this from the server administrator right?).

Just go to http://yourdomain/railo-context/admin/server.cfm and log in, then you can click on the "update" button, set the updates to "Development", update and then click the "execute button below to get the latest update.

Once you have done that, in the Railo Server Administrator screen, you will see info about your installation and scrolling down you will get a nice graphic on how your memory is being used, like the example below:

Yet another handy feature of Railo Server! Nice!

What's your opinion? How long should comments be a

posted: 12 Aug 2011

As an "owner" of a blog, that has (at last count) 590 posts dating back over seven years, I noticed that I start getting a lot of comment spam. 

I have been asking myself, how long should I allow comments on blog posts? I mean, I am sure I posted something in 2006 that might be relevant again, but maybe just contact me? Since I doubt someone is going through my archives (unless they got there via Google of course) and even then, since this is a technology blog, I am sure there are a lot of things that are now out of date. 

So the question is, should I turn off comments on blog posts that are older than X time? and what should that X be?

Over to you!

 

CFLOOP Rant.

posted: 04 Aug 2011

<rant>

I have to get this off my chest: the tag cfloop *REALLY* annoys me.

Not in all it's manifestations mind you, just in one of them, and that is... cfloop array. Why you might ask?
Well, if you want to loop an array you can do:

<cfloop array="#MyArray#" index="a">
      <cfdump var="#a#">
   </cfloop>

What "a" is in the index, is the actual item in the array. I think this is totally wrong to the point that if I had hair I would pull it out.
When the array attribute was introduced, I really think the developers had a brain fart.
They could have so easily used another attribute, maybe one that is already there. The attribute of "item" for example! I mean, it was there loitering in the tag lib, being used for collections, such as:

<cfloop array="#MyArray#" item="a">
      <cfdump var="#a#">
   </cfloop>

Now THAT makes sense! But why all the whining you might ask? Well, let's consider if you want to actually get the index of the array, what do you have to do? Oh yeah... set up another damn variable:

<cfset counter = 1>
   <cfloop array="#MyArray#" index="a">
      <cfdump var="#a#">
      <cfset counter++>
   </cfloop>

Wouldn't it have made a LOT more sense to do the following?:

<cfloop array="#MyArray#" item="a" index="counter">
      <cfdump var="#a#"> The actual item
      <cfdump var="#counter#"> The index of the item
   </cfloop>

See? now "a" can be the *ITEM* in the array and "counter" can be the *index* of the array.

</rant>

Side rant: Why name it "collection" when we could have named it "struct"? <cfloop struct="#myStruct#" item="st">
      
   </cfloop>

How I got started in ColdFusion

posted: 01 Aug 2011

Steve Bryant came up with the excellent idea of August 1st being designated How I Got Started In ColdFusion Day, for which ColdFusion users tell their origin story, So here goes mine!

Back in the mists of time, I had started a company called Creative Overload. We were mainly doing flat HTML websites, but specialised in VRML sites, and had done some interesting work for Brixton Academy and Virgin Radio at the time. Sadly, I saw myself as not experienced enough to be running such a company and left it in the capable hands of my then co-directors and left to find a new job somewhere else.

The job that I ended up taking was of Lead Web Developer at an ISP/Web Agency called NETTEC PLC. It was here (and over the many years I worked there) that I managed to work with many clients that were absolutely amazing. But I digress...

In the first few months that I was at Nettec Plc, we started working on a large Intershop site, the first CD's, Videos and games website in the UK with full transaction capabilities, and awesome side project of the Kingfisher Group, which at the time owned Wollies and other stores, but it was not for this project I used ColdFusion, it was actually an insurance company down the road that were looking to make choosing a policy much easier.

I don't recall from where it come, but I had a version of ColdFusion Studio installed on my machine and it had an awesome little wizzard attached to create a master detail page. And within a few hours and their database I had manged to do just that! I was amazed! I mean, I had been working with Perl so far and here was something that made sense, didn't need so many strange characters and just fit!

At Nettec we then did a lot of projects with ColdFusion, even being one of the main Allaire and then Macromedia partners in the UK, I even moved on to be a Spectra Specialist (for my sins) which I did all the way up to 2004/5

There you have it. How I got started with ColdFusion

Railo for Beginners: My First Book!

posted: 26 Jul 2011

I got got confirmation from Packt Publishing that the RAW (read as it's written) version of the Railo for Beginners book has been released!

I have been writing this book for a while with the help of Gert Franz (Railo Technologies), Andrea Campolonghi and Paul Klinkenberg (Railo Volunteers). And of course a bunch of people that have been reviewing the book for me.

It's my first book so it has been a pretty long labour, especially since I publicly admit I coudl barely write an essay! But the prodding and cajoling by the editors to get me to finish each chapter has definately helped!

The book covers a lot of the aspects of Railo Server and I am hoping that by having this book out there more people will be interested in CFML and of course, Railo Server!

To quote the back cover:

Railo Server is one of the quickest ways to start developing complex web applications online. Widely considered as the fastest CFML (ColdFusion Markup Language) engine, Railo allows you to create dynamic web pages that can change depending on user input, database lookups, or even the time of day.

Railo 3 Beginner’s Guide will show you how to get up and running with Railo, as well as developing your web applications with the greatest of ease. You will learn how to install Railo and the basics of CFML to allow you to gradually build up your knowledge, and your dynamic web applications, as the book progresses.

Using Packt’s Beginner’s Guide approach, this book will guide you, with step-by-step instructions, through installing the Railo Server on various environments. You will learn how to use caches, resources, Event Gateways and special scripting functions that will allow you to create webpages with limitless functionality. You will even explore methods of extending Railo by adding your own tags to the server and building custom extensions. Railo 3 Beginner’s Guide is a must for anyone getting to grips with Railo Server.

What you will learn from this book :

  • Step-by-step instructions for developing web sites with CFML
  • Learn about all the resource types available and how to handle them
  • Easy to follow steps to optimise your application for high traffic
  • Create dynamic applications with the in-built Hibernate ORM
  • Secure your server by setting up access restrictions and passwords
  • Convert and display multimedia within your webpages
  • Create your own extensions for custom functionality

You can buy the eBook with all the currently published chapters as well as the full paper version when it's released from PacktPub Directly

My WebDU 2011 review and all that jazz!

posted: 18 Apr 2011

It has been my pleasure to be attending the WebDU Conference in Sydney this week. And what an awesome week it was!

WebDU is a great conference that has now been going on for about 9 years organised by the Daemon(ites) from Daemon Internet Consultants and I think it is THE Web Conference to go to on this side of the world.

The Location
WebDU was held at the lovely Four Points by Sheraton hotel right by Darling Harbour in Sydney. The rooms were nicely presented and fairly comfortable. Having said that, they were OK, not amazing in anyway, but hell, what are you doing in your room at a conference??.


Before the conference started, the hotel already provides free wifi in the lobby, but strangely not in the rooms, so I had to get a USB to Ethernet connector for my MacBook Air (forgot about that one, DOH!) and a steep AU$25 per day if you wanted to get a connection going in your room.
Aside from that, the massive main room and location of the conference itself was fantastic.
One of the main topics of complaint in most conferences is the food, but I have to say that WebDU cannot be faulted, even including a "hangover breakfast" on the second day (hamburgers and redbull). Attention to detail goes a long way indeed!

Keynotes, Sessions and Round Table

The first day keynote was a range of presentations showing the power of the Flash platform (I missed the name of the guys that presented it, sorry, I blame the Jet-Lag rather than my senility) in games as well as mobile development. Terry Ryan and Greg Rewis were unable to make the conference due to United Airlines cancelling a flight (#unitedfail) but Paul Burnett took over duties of MC.

For the first day I didn't manage to catch many sessions as I was busy preparing (or more like, localising) my presentation for later that day but I managed to catch a few sessions on the second day:

Keynote: Focus: It's hard, because... hey look at that over there!
The keynote was run by Mick Liubinskas from Pollenizer. Which was a great motivational presentation about focusing your attention and feature sets of your application or business. Too many things can distract you, including yourself and instead of just getting your project/business/enterprise out of the door, you can fail to focus on what is important.

Photoshop for Developers: From Fumbler to Master
This interesting session by Mike McHugh was a bit of a variety, since he demoed the new Photoshop API that allows external devices such iPads and iPhones (and other mobile devices) to connect and share with a running instance of Photoshop so you can run your own programs, share images and control palettes if you need to. The rest of the session focused on some really good tips for common tasks and he showed the *right* or rather the easiest way to accomplish them.

10 ways to fail at Agile
I loved this session by Sandy Mamoli. It started out with 10 topics, but of course, it had to be reduced in "features" due to time constraints, a perfect example of the pragmatic approach of Agile methodology.

Zero to App in 60 Seconds: jQuery Mobile & Phonegap
Paul Burnett Showed off some of the awesome features of the upcoming Dreamweaver 5.5 to develop mobile applications with PhoneGap and JQuery Mobile. Despite the title, it took slightly longer to build the Android application (because of compile times), so I think he should have gone with compiling the application to iOS instead!

Slowly I turned: Coding Location-Based Services Another awesome mobile presentation on using location based services using Flex and other technologies, most awesomely presented by Andrew Muller. Lots of ideas come out of this which I shall blog a bit later, but this was a must-have presentation if you are into location based services!

Roundtable
As the closing section there was a round table presented by Robin Hilliard, Tim Buntel, Sandy Mamoli, Dale Rankine and Renaun Erickson, some interesting questions including the infamous "innovation (full stop)" question.

Ballon
Interestingly over the course of the conference, the back channel chat (i.e. twitter feeds) was managed and displayed using an application called Balloon which allowed Geoff Bowers (the organiser of WebDU) to display all the relevant twitter feeds, display questionnaires and highlight specific tweets up on the main screens. Very impressive!


Geoff Bowers really knows how to treat the delegates as well as the speakers of he conference, and the speaker after-party was most awesome on the Saturday night (thanks for the invite!)
I think this conference was most awesome, and I look forward to next time, which I hopefully will be able to attend again! Thanks again to all the team and all the pople I met over in Sydney!

Using GeoLocation in a Web Browser

posted: 17 Apr 2011

Having had an awesome time at WebDU, a couple of sessions had information about PhoneGap, JQuery Mobile and more importantly geolocation available in HTML 5 applications.

Some of the confusion arose from what the difference is between PhoneGap and JQuery Mobile provide.
Essentially, PhoneGap provides a common interface into the various API's provided on different movile devices. API's such as the Accelerometer, Camera, Compass, Geolocation, Contacts, Media and Notificaiton.
JQuery Mobile provides an API to develop a common UI that works across different devices as well as common ways for re-skinning and handling events within that UI.

A question come up about how to do GeoLocation within these devices and I pointed out that you can indeed do geolocation, and not only within a mobile device, but you can also do it using the HTML5 API's on desktop browsers.
This is actually really easy with the navigator.geolocation object in JavaScript.
To check whether you can actually use it all you have to do is check if this object exists in the DOM, with code like:

if (navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(success, error);   
      }

Now, if you run this code from some function, you will need to pass in two functions that will recieve the current position, or throw an error if there has been some problem getting the current location. The expanded code is shown below:

function getLocation(){
            if (navigator.geolocation) {
             navigator.geolocation.getCurrentPosition(success, error);
            } else {
               document.getElementById("output").innerHTML = "Your browser doesn't handle the GeoLocation API. Use Safari, Firefox 4 or Chrome";
            }
         }


         function success(loc){
            strout = "";
            for(l in loc.coords){
               strout += l +" = " +loc.coords[l] + "<br>";
            }
            strout += '<img src="http://maps.google.com/maps/api/staticmap?center='+loc.coords.latitude+','+ loc.coords.longitude +'&zoom=15&size=400x400&sensor=false">';
            document.getElementById("output").innerHTML = strout;
         }

         function error(err){
            document.getElementById("output").innerHTML = err.message;
         }

And that is it. No external libraries or PhoneGap API's. Just a standard browser call.
The navigator.geolocation.getCurrentPosotion() function will call the success(loc) function passing in a GeoPosition object that you can get the coordinates from. It also includes a few other handy properties such as longitude, lattitude, accuracy and heading if you are moving.
Check out a demo of the above code. There are no other libraries or includes so you can just view the source to see how it works.

Denny Valliant Joins Railo!

posted: 01 Apr 2011

It has been two years today that I have been working at Railo Technologies and it gives me great pleasure to announce that Denny Valliant (@denstar) has just joined the team!

Denny is a great addition as he has been working with various packagers for Railo, and of course, he is the Lead Developer for the CFEclipse project!
How about that for a great combination eh?!
Welcome on board Denny! Hold on tight! It's gonna be a hell of a ride!
Check out the official announcement over that the Railo Blog

Railo Tip: Getting information about built in Tags

posted: 31 Mar 2011

I am not sure people out there know this but Railo has four awesome functions that I use all the time, they are :

  • getFunctionList
  • getTagList
  • getFunctionData
  • getTagData

getFunctionList* and getTagList
These two functions will return a structure with all the functions or tags that are currently installed on the Railo server. For example, getFunctionList will return:

And getTagList will return:

getTagData and getFunctionData
Of course, this information in itself isn't amazing, since how do you know the arguments for each? This is where the getTagData and getFunctionData come in useful. For Example, if you want to get all the properties of say, the function ImageFilter (I created the FilterExplorer using this function), all you have to do is:

<cfdump var="#getFunctionData("imageFilter")#">

And you will get a nice struct with all the info:

The function getTagData is slightly different, in that you have to split out the namespace when calling it, so you have to call it as follows:

<cfdump var="#getTagData("cf", "dump")#">

Which gets you all the attributes and documentation for the tag:

Simply using those tags, I have started a little project using CloudBees, ColdBox and of course Railo, that I shall show off a bit later.

* getFunctionList is also available in CF9

Running Railo in CloudBees

posted: 30 Mar 2011

A while ago I was playing with the Stax.net deployment system, since then they have been bought by CloudBees, a Platforma as a Service for Java Web Apps and I wanted to see how easy it was to run Railo on it.

One of the advantages of running Railo in CloudBees (apart from scaling and versioning) is the ability to deploy incremental changes, rather than having to deploy the whole WAR as you have to do with AWS's BeanStalk. In this post I shall go through how to get a sample application running.

Requirements
Before we get started we need to do the following:

Once you have setup the CloudBees SDK as they have mentioned, you need to setup your API and Secret Keys, to do this you can go get your keys from your account page, and add them to the file that should have been created (if you are using OSX or a Linux OS ) in:

~/.bees/bees.conifg

Now that we have all that installed, let's go create a simple app through the CloudBees web interface, I have named my application "railo" (surprise, surprise!).
Once it has been created, click on the configure button so that you can get the ID of the application, in my case it is "markdrew/railo".

Now we have that application, we can go and download it, go to the folder you want to download the application to in the command line/terminal and type the following:

> mkdir markdrew_railo
> cd markdrew_railo
> bees getapp -a markdrew/railo


That was easy, if you setup your API and Secret keys you should get some XML and some other commands appearing and it should all be downloaded. Let's run it before adding Railo to the mix:

> bees run


After a few seconds you can head to http://localhost:8080/ and get something that looks like the following:

Now to add Railo to our application. You can stop the application by pressing Ctrl + C, and then rename the railo-3.2.2.000.war to railo-3.2.2.000.zip and uncompress it:

> mv railo-3.2.2.000.war railo-3.2.2.000.zip
> unzip -d railo railo-3.2.2.000.zip


Now that we have unzipped the WAR file into the railo directory we can copy the contents from the railo/ directory to the markdrew_railo/webapp directory.

> cp -r railo/ markdrew_railo/webapp/

To test this, we can run the "bees run" command again and after a while you can test your application at http://localhost:8080/, you should get the Railo start page! Awesome!
Stop the application using Ctrl + C and let's clean out some files that are left over that we don't need:

> rm -r webapp/WEB-INF/classes/
> rm webapp/index.jsp

Now that we have cleaned it up and tested it , let's go ahead and deploy it. This is as simple as typing:

> bees deploy

The upload will take a while since it will upload something like 55Mb as our initial upload. Once this is done you should be able to check out your application live at the url defined in your configuration, mine is: http://railo.markdrew.cloudbees.net/

Let's change the default homepage, so that we can see how much it has to upload next time. Change the contents of index.cfm to just display the current time:

<!DOCTYPE html>
<html>
<head>
<title>Changed!</title>
</head>
<body id="documentation" class="twoCol">
   <cfoutput>
      #Now()#
   </cfoutput>
</body>
</html>


This time when we run the "bees deploy" command you should see that it has very quickly uploaded the changes and they should be live, without having to re-deploy the whole thing! Awesome! This is a massive advantage over AWS Beanstalk, that where small changes would require of a total re-deploy of your application.

Ternary Operations and CFML

posted: 24 Mar 2011

I have been doing a lot of JavaScript development recently and finally got my head round Ternary operations. Something that Railo Server has had for a while and I think was introduced to Adobe CF8 a while ago too. I just never got round to making it part of my standard coding practices, so I thought I would share.

If you have been doing this for a while, no need to point and laugh at me, but if you haven't, let me explain.

In your code you get to points where you have some code that looks like this:
<cfif MyVar EQ "something">
   <cfset myResult = 1>
<cfelse>
   <cfset myResult = 0>
</cfif>

When I see that, I tend to think, what is the fastest way to do this? What makes more sense? In the code above, in *theory* the variable myResult will always be created, but since it is always created, why have the cfelse statement?

I started coding in this manner subsequently:
<cfset myResult = 0>

   <cfif MyVar EQ "something">
      <cfset myResult = 1>
   </cfif>

This way the myResult variable is always set to a "default" and only modified if the statement becomes true. For some reason this makes me feel happier and that the code is more robust (and of course, there is less of it).

With a ternary operation, you can even reduce ALL that code (omg! 4 lines of code!) into a single line:
<cfset myResult = MyVar EQ "something" ? 1 : 0>

The code above now is all in one line. The whole logic relating to the myResult variable is neatly encompassed in one line. Suddenly I feel so much happier.

Exploring Railo's ImageFilter Functionality

posted: 21 Mar 2011

One of the new functions that will be introduced in Railo 3.3 is the ImageFilter() function. This is one hell of a function with a LOT of parameters, so I thought rather than create some massive documentation index for it, I would make something a little but more fun; so introducing The Image Filter Explorer!

This small application allows you to explore the different filters you can use against an image, and see the result, along with a code sample of how to do that particular function.

You can check it out here: http://www.markdrew.co.uk/filterexplorer/

CFEclipse 1.4.4 is out!

posted: 31 Dec 2010

The CFEclipse Team, lead by the awesome Den have managed to get another release of CFEclipse out!

Check out the "What's new" page for the new features in 1.4.4

Remember, you can always update CFEclipse from your Software update in Eclipse with the update site of http://www.cfeclipse.org/update/

If you have any issues, why not join the CFEclipse google group, this is where a bunch of friendly people will be able to help you! http://groups.google.com/group/cfeclipse-users

Enjoy!

cf.Objective() 2011 Call for Speakers!

posted: 08 Dec 2010

cf.Objective() 2011 is just round the corner and they are looking for you! Yes you! to make it the best ever conference!

All you have to do is get some ideas for presentations as well as vote for your favourite presentations that have already been submitted.

Remember! Vote Early! Vote Often!

Make your Vote count at the cf.Objective() Call for Speakers!

Get the Lead Dev of CFEclipse to CFOpenSummit!

posted: 01 Dec 2010

It has been a while since I went to a conference and saw a CFEclipse presentation. In previous years it has been me presenting on this but since Denny has taken over the development and I have joined Railo time has been short to add to the project and therefore present on the topic.

So we are starting a donation fund for Denny to attend http://www.opencfsummit.org/! It will be an amazing conference and I think the missing piece of the puzzle is the current Developer of CFEclipse presenting! So head over to http://cfeclipse.org/index.cfm/blog/dengocon/ and show your support!

Go on, you know it makes sense.

CFObjective, CodeWars and Velociraptors

posted: 18 Nov 2010

Last night at CFObjective ANZ, Gert Franz and I were invited to the CodeWar hosted by Robin from RocketBoots. I have to say it was a great event at the European Beer Cafe in Melbourne, and the Railo "Flower Power" team managed, somehow, even with jetlag and lots of beers, to win (pure luck I have to say!).

The CodeWar is a series of challenges where teams went against each other to complete a range of coding challanges in 20 minute rounds.

One of the rounds, in which we didn't compete, was the ability to find out which Velociraptors would survive if they were tied to a pole and were trying to mate. The awesome description of the challenge was:

VELOCIRAPTORS run Amok A large arena (1 square km) has 24 Vulcan Velociraptors, each chained to a post.
Each is severely afflicted with Pon farr.
Which is the lonely Velociraptor that is destined to die? and which is the lucky Velociraptor that will make a spectator outside the arena very unhappy?

Since we weren't involved in that challenge, I really wanted to give the solution a go, so here is my solution.

First of we have a list of Velociraptors:

[
   ['Alice',51.5,940.5,945.5],
   ['Arthur',73.5,769.5,803.5],
   ['Bertha',112,593,844],
   ['Bessie',62,852,769],
   ['Charles',37,224,144],
   ['Clara',70,168,832],
   ['Edward',171.5,120.5,535.5],
   ['Elizabeth',83,199,235],
   ['Emma',67.5,298.5,576.5],
   ['Ethel',27,417,449],
   ['Florence',47.5,369.5,386.5],
   ['Frank',118.5,825.5,185.5],
   ['Fred',31.5,920.5,875.5],
   ['George',52.5,109.5,106.5],
   ['Harry',97,210,701],
   ['Helen',41,194,85],
   ['Henry',127,473,603],
   ['Joseph',144,490,211],
   ['Marie',157,742,541],
   ['Minnie',17,402,431],
   ['Robert',66.5,398.5,784.5],
   ['Ruth',130.5,656.5,282.5],
   ['Thomas',64,140,894],
   ['Walter',39.5,468.5,868.5]
]

The above is an array of arrays, with each individual array standing for a velociraptor, with it's name, radius of his chain, and their x and y location on the map. So that we can see where they all are and their reach, I decided to use the HTML5 Canvass tag. Here is the simple page with the canvass:

<!DOCTYPE html>
   <html lang="en">
   <head>
      <title>The Lonely Raptors</title>
   </head>
   <body>
      <canvas id="myRaptors" width="1000" height="1000"><p>Your browser doesn't support canvas.</p></canvas>
   </body>
   </html>

Next I, did a function that allowed me to display each of the velociraptors as a circle:

var drawingCanvas = document.getElementById('myRaptors');
      if(drawingCanvas.getContext) {
       var context = drawingCanvas.getContext('2d');
      }
      function drawCircle(context, radius, x, y, name){
            context.strokeStyle = "#000000"; //Set the stroke
            context.fillStyle = "#" + (x*8).toString(16); //set a random colour for each circle
            context.globalAlpha = 0.5; //make it nicely transparent
            //Draw the circle
            context.beginPath();
            context.arc(x,y,radius,0,Math.PI*2,true);
            context.closePath();
            context.stroke();
            context.fill();

            //reset the colour and the transparency and then fill in the name
            context.globalAlpha = 1;      
            context.textAlign = "center";
            context.textBaseline = "middle";      
            context.fillStyle = "#000000";
            context.fillText(name, x, y);
      }

Then I loaded the velociraptor array and called the function to draw a circle:

<cfscript>
      raptors = Evaluate(FileRead("Velociraptors.txt"));
      for(r in raptors){
         WriteOutput("drawCircle(context, #r[2]#, #r[3]#, #r[4]#, '#r[1]#');");
      }
   </cfscript>

And finally, this is the result:

So we can see that the Velociraptor that will die of lonelyness is Robert as he has no overlap with any other 'raptor and that Edward will be having a tasty treat in the form of a visitor outside the enclosure!
You have to love HTML5 for being able to do these things so easily!

Relax with CouchDB: Presentation to the UKCFUG

posted: 08 Oct 2010

Yesterday I presented the NoSQL and CouchDB to the UK CFUG. I think it went down well and there were lots of questions and interest in the subject of Not Only SQL and how they can be used with your applications.

As promised, you can download the presentation with links and code samples here

You can also view the presentation over at Slide Six

Note: I shall be posting the Acrobat Connect recording URL later today (once I get it!)

Common Development Patterns: Settings per Environm

posted: 30 Sep 2010

I am thinking of doing a range of blog posts related to common development patterns that I have seen implemented. These are not exactly Design Patterns, but practices that I see and have implemented myself.

To kick of this series, I thought I would talk about your application's settings depending on environment. As a background I was working on a Galleon application that in development runs on Apache with MySQL and in Staging/Live it runs on IIS and MS SQL. Generally you want to keep your environments the same of course, but the main changes were simply table names, emails and URLs so all the code was fine.

One of the things that annoyed me was that before I could check in my code to SVN, I would have to change the settings.ini.cfm file, putting all the live settings in there.

Since Galleon is not built on any framework, I decided to just easily plug in a config detector, so I could use a different settings file, settings.local.ini.cfm and not have to to change the main config.

I did this simply where the settings file is included so for Galleon I put this in the code:

<cfset var settingsFile ="settings.ini.cfm">
<cfif CGI.SERVER_NAME EQ "galleon.local">
         <cfset settingsFile ="settings.local.ini.cfm">      
</cfif>

(I have removed a lot of other code round it to make it simple)

This is a simple replacement, that is based on the CGI_SERVER_NAME

You could of course get a bit fancier, depending on the name of the physical machine, but you have to drop into Java and get the actual machine's host (rather than what I have placed in the URL, since you might be replicating the live site with an entry in your hosts file):

<cfset thishost = createObject( 'java', 'java.net.InetAddress' ).getLocalHost().getHostName()>
   <cfset var settingsFile ="settings.ini.cfm">
   <cfif thishost EQ "markdrew.local">
            <cfset settingsFile ="settings.local.ini.cfm">      
   </cfif>

If you are using ColdBox, you can just add the EnvironmentControl interceptor in your config/coldbox.xml.cfm:

<Interceptor class="coldbox.system.interceptors.environmentControl">
<Property name='configFile'>config/environments.xml.cfm</Property>
<Property name='fireOnInit'>false</Property>
</Interceptor>

And in your config/environments.xml.cfm you can override any settings just by adding them to the correct section:

<environment name="development-mark" urls="unused" hosts="markdrew">
      <!-- where email bounces should go to -->
      <Setting name="BounceEmail" value="mark@localhost" />
      <Setting name="DevelopmentEmail" value="mark@localhost" />
      <Setting name="BugEmails" value="mark@localhost" />
   </environment>

If you are using ColdSpring for your configuration, you might want to do a couple of things, first thing you can do is simply call in a different coldspring.xml.cfm file when you create your bean factory, but to do this you would have to copy all your beans. The easiest way is to have the root coldspring.xml.cfm file have any settings that you want in a (configBean for example) and then include your main coldspring file.

So, wherever we are loading Coldspring up we can put an environment logic:

<cfset application.cs = CreateObject("component", "coldspring.beans.DefaultXMLBeanFactory")>
   <cfif CGI.SERVER_NAME EQ "galleon.local">
      <cfset application.cs.loadBeansFromXmlFile("/config/coldspring.markdrew.xml.cfm")>
   <cfelse>
      <cfset application.cs.loadBeansFromXmlFile("/config/coldspring.xml.cfm")>
   </cfif>

In the coldspring.xml.cfm file we would have:

<beans>
      <bean id="Config" class="my.app.ConfigBean">
         <property name="project"><value>Project</value></property>
         <property name="dsn"><value>projectDatabase</value></property>
         <property name="adminEmail"><value>admin@somedomain.com</value></property>
         <property name="mode"><value>production</value></property>
      </bean>
      <import resource="/config/SharedColdSpring.xml" />
   </beans>

This would setup the Config bean that is passed to other objects and fill it with values that are required and then include the SharedColdSpring.xml that doesn't really need any changing per environment

In my coldspring.markdrew.xml.cfm I would have the same but with my settings:

<beans default-autowire="byName">
      <bean id="Config" class="my.app.ConfigBean">
         <property name="project"><value>Project</value></property>
         <property name="dsn"><value>devDB</value></property>
         <property name="adminEmail"><value>mark@localhost</value></property>
         <property name="mode"><value>development</value></property>
      </bean>
      <import resource="/ws/config/SharedColdSpring.xml" />
   </beans>

I hope this gives you some ideas on how to remove some effort from your work day!

CouchDB Cache Extension (Beta) for Railo

posted: 30 Sep 2010

I have spent a while working on this extension and after a hiatus of client work I managed to get it all uploaded and documented onto the Railo Wiki.

CouchDB is a noSQL database that allows you to store complex documents and get them by key (and revision), it is very performant and easy to replicate which makes it a great alternative as a distributed caching system, hence we created the CouchDB Cache Extension!

It is fairly simple to install, you just have to add the preview extension provider (http://preview.getrailo.org/ExtensionProvider.cfc) to the list of your Railo Extension Providers and then under your Extensions/Applications section you should now see the CouchDB Cache extension, just install that, create a Cache Connection and start using it for your Objects, Templates, Queries etc!

There are more detailed installation instructions over at the Wiki, why not check it out? http://wiki.getrailo.com/wiki/extensions:couchdb

My Desktop

posted: 18 Aug 2010

Following on from Andy Jarrett's post, since he is going to show his, I am going to show my desktop.

What's yours like?

Railo ORM and Magic Functions

posted: 06 Aug 2010

Background: I am writing a little app to help us here at Railo with some of our contacts, nothing over the top or anything and wanted to take Sean Corfield's FW/1 for a spin.

As I am developing, I went the most direct route, I just did some queries in the service layer so my code looks like:

<cffunction name="list" output="false"> <cfset var clients = 0> <cfquery name="clients" datasource="#variables.dsn#"> SELECT * FROM contact; </cfquery> <cfreturn clients> </cffunction> <cffunction name="view" output="false"> <cfargument name="clientid"> <cfset var qclient = 0> <cfquery name="qclient" datasource="#variables.dsn#"> SELECT * FROM contact WHERE id = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.clientid#">; </cfquery> <cfreturn qclient> </cffunction>

OK, nothing world shattering, so I wanted to start using the ORM features of Railo (join the pre-release group to test them out!). I changed my code to look like:

<cffunction name="list" output="false"> <cfset var clients = 0> <cfquery name="clients" dbtype="orm"> FROM contact </cfquery> <cfreturn clients> </cffunction> <cffunction name="view" output="false"> <cfargument name="id"> <cfreturn entityLoad("contact",arguments.id,true)> </cffunction>

I then defined my "contact" (I can show the code but it's hardly rocket science) and then when I reloaded I got the error:

Component [contact] has no acessible Member with name [ID]

Of course! My view code looks like:

<input type="hidden" name="id" value="#rc.data.id#">


I could change all my calls to fields to

<input type="hidden" name="id" value="#rc.data.getid()#">


but why bother? I just went to the Railo Admin -> Archives & Resources: Component -> Magic Functions and enabled them, now all my view code works just as expected and I didn't have to change my view code.

 

 

Railo at CFUNITED!

posted: 27 Jul 2010

On the final CFUnited, Railo will be there in force!

You can come visit us at our stand to find out the awesome consulting services we provide as well as, of course, our most awesome Open Source CFML Engine! (yes! I used "awesome" twice!)

There might even be some delicious Swiss chocolate there too!

Apart from the stand, you can also check out our team's presentations

Sean Corfield will be talking about:

And you can also catch Gert Franz's topic:

Since most of us will be en-route to the conference tomorrow, why not email us today if you have any queries ahead of time?

See you all there! I am sure it's going to be awesome!

Presenting at cf.Objective (ANZ)

posted: 25 Jul 2010

I am really happy to say that I shall be presenting at cf.Objective (ANZ) this year! I had a great time last year in Melbourne and glad that this year I won't just be manning the Railo stand (do come and say hello!) but I shall also be doing a presentation on CouchDB 

 

CouchDB is a "noSQL" database that is rather exciting in how it works as well as a highly performant document database.

 

IF you manage to make it, make sure you either come to my session or at least pop by and say hello to the Railo team!