Moved to AWS

10 years a go I worked on a site for a local company. This month I officially am off that project. With that the server that the site was hosted on and this one as well will be going away.

With that I opted to move to Amazon Web Services EC2 server to host my blog and a couple of the other sites that I work on.

I am currently working on writing up the procedures I used to get every thing up and running on AWS. I am sure there are a few write ups on how to set up Apache + Railo + MySql on AWS but I hope to come from a plain ubuntu install to everything working together.

I also plan to being to post more with most of it being on the Jquery/Railo ORM side of things as I being working on a new project.

Sorting methods in your components

Working on a project where I need to compare the functions in one components to insure that they were present in another and the logical way to accomplish this was to get my methods sorted into alphabetical order.

It's not much code and pretty self explanatory as to what its doing so I am not going to explain it line by line. Feel free to ask questions if you have any.

view plain print about
1<cfsilent>
2<cffile action="read" file="physical/path/to/your/component" variable="cfc">
3<cfscript>
4    function getMethods() {
5        regex = '<cffunction((\s+\w+(\s*=\s*?:".*?"|.*?|[^">
\s]+)?)+\s*|\s*)/?>
(.*?)</cffunction>';
6        start = 1;
7        length = len(cfc);
8        methods = structNew();
9        do {
10            method = {};    
11            matches = REFind(regex,cfc,start,"true");
12            if(matches.pos[1]+matches.len[1] NEQ 0) {
13                name = getName(mid(cfc, matches.pos[2], matches.len[2]));
14                method[name] = mid(cfc, matches.pos[1], matches.len[1]);
15                structAppend(methods,method);
16                start = matches.pos[1]+matches.len[1];
17            } else {
18             start = length;    
19            }
20        }
21        while (start NEQ length);
22    return methods;
23    }
24    function getName(s) {
25        var i = 1;
26        for(i=1;i<=listLen(s," "); i++) {
27            if(find("name",listGetAt(s,i," "))) {
28                name = listGetAt(s,i," ");
29            }
30        }
31        name = replace(name,"name=""","");
32        name = replace(name,"""","");
33        return name;
34    }
35</cfscript>
36<cfset methods = getMethods(cfc)>
37<cfset sorted = structSort(methods,'textnocase','asc')>
38</cfsilent>
39<cfoutput>
40<cfloop array="#sorted#" index="function">
41#methods[function]#
42</cfloop>
43</cfoutput>

run the code above and view the source to view the results. May look at making this a Coldfusion Builder Extension at some point.

Using SQLite with Railo

I was starting a small project that requires the use of SQLite, and the number of resources for where to put everything and how to connect up railo and the SQLite jar.

First thing you need to do is head off to www.zentus.com/sqlitejdbc and download the latest SQLite jar. After you download the jar file to put it into the lib dir of your rail/resin install. For other server engines (Tomcat/glassfish) where you put the jar file may vary.

Restart Railo so the changes take effect.

Once that is in place log into your Railo web admin and select datasources. Scroll down to the section where you create the data sourece and enter the name for your datasource and select JDBC - Other for the type.

[More]

Endless scrolling with jQuery and Coldfusion using ORM

Been on Facebook, Twitter or any number of sites that loads data as you scroll? I would bet that most of you have. lets show you how to set up your site to load data inline while the user scrolls down the page.

The first steps is to get the initial set of data and a record count for the entire dataset that is going to be loaded up. This is pretty much standard Coldfusion nothing fancy.

view plain print about
1<cfset numRecords = ormExecuteQuery("select count(*) as total from entries")>
2 <invalidTag>
3    //Will discuss the script section below.
4 </script>
5 <cfoutput>
6    <cfset entries = entityload("entries",{},{maxResults=10,offset=0})>
7        <div id="entries">
8            <cfloop array="#entries#" index="e">
9            <div class="entry">
10                <h3 class="title"><a href="#e.getUrl()#">#e.getTitle()#</a></h3>
11                <div class="content">#e.getContent()#</div>
12            </div>
13            </cfloop>
14        </div>
15 </cfoutput>

[More]

Using parameters with ormExecuteQuery and Railo

Though the new ORM functions in Railo are great there is often times you need just a little more than matching one or two columns exactly when you're getting data. When you reach this point it's time to bring in ormExecuteQuery as a method of gaining that little bit more of control over getting your data. Though there is more to ormExecuteQuery but I want to discuss how to use the conditional parameters of your where clause.

Though you could just insert the parameters directly into your query, we all know that that is not safe and is how SQL Injection attacks occur. In fact I am not even going to show that as we don't even want you to think about doing it that way, and since cfqueryparam cannot be used here we need to find another way to keep our system secure but get the data we need.

[More]