Simple Check Bot in Coldfusion

Today, I've been asked about how to do Image Captcha in CFMX7 by my ex-colleague. Well, I didn't see so far image manipulation in CFMX7 but most of CF developer use ImageCFC. Honestly, I don't want them to use ImageCFC for only captcha function because I don't think they can manipulate it very well. That's why I suggest them to create "simple maths calculation formula (4+5 = ?)". Because it's very simple to create and don't need to consider for browser compatible and other risks.

I need to put following coding into form.cfm.

view plain print about
1<!--- form.cfm --->
2<cfset firstnumber = randrange(1,9)>
3<cfset secondnumber = randrange(1,9)>
4<cfset session.result = firstnumber + secondnumber>
5<cfoutput>#firstnumber# + #secondnumber# = ?</cfoutput>
6<form method="post" action="check.cfm">
7 Enter result : <input name="txtvalue">
8 <input type="Submit">
9</form>

[More]

Coldfusion Flickr JSON

Last weekday, I've read Flickr API developers section. As we all know, there is already CFlickr which support us to integrate CF and Flickr for uploading photos, retrieving photos and so on. But, I'm getting sick of installing this CFlickr in my blog because I only need to display my photography in my blog and don't want to upload and edit anymore.

To display Flickr in our blog, we can also use with RSS feed. If we use RSS feed by retrieving data from Flickr, Flickr will product small images. I've already posted about it in my blog already. Simple Flickr Integration But I don't like those small thumbnail. What I gonna do if I want to display medium thumbail? Answer is very simple. "Use Flickr API"

Usage of Flickr API

view plain print about
1url : http://www.flickr.com/services/rest/
2<!---
3    I need to use this method.
4    Because it's only for display.
5--->

6method : flickr.photos.search
7<!---
8    There are 3 types of format.
9 1. REST (JSON)
10 2. XML-RPC
11 3. SOAP
12    But I only need to use JSON.
13 --->

14format : json
15<!---
16    I only retrieve data.
17    That's why nojsoncallback is 1 (Yes).
18--->

19nojsoncallback : 1
20<!--- Your API --->
21api_key : [YOUR_API_KEY]
22<!--- Your Flickr Account --->
23user_id : [YOUR_USER_ID]

[More]

Oracle For Loop and abort

In my current company, our Project Manager told our team just like if DB can handle data manipulation, let them do. Don't put load on Coldfusion for data manipulation. Regarding his guild-lines, we're about to create Stored Procedure, Functions and Views at Oracle. That's why I need to learn more Oracle's commands and functions. Meanwhile, I found Oracle for Loop and abort function. Usage is kinda simple and I'll compare it them with CFLoop.

Here is For Loop usage in Oracle

view plain print about
1FOR LCOUNT IN [start_count]..[end_count]
2LOOP
3    [PROCESS]
4END LOOP;

Here is example

view plain print about
1MYCOUNT := 'START :';
2FOR LCOUNT IN 1..7
3LOOP
4    MYCOUNT :=     MYCOUNT || '-' || LCOUNT;
5    IF LCOUNT = 7 THEN
6        GOTO STOP_PROCESS;
7    END IF;
8END LOOP;
9<<STOP_PROCESS>>
10NULL;

Above coding, we loop 1 to 7 and concatenate LCOUNT value into MYCOUNT. Within looping, stop looping if LCOUNT reach 7.

[More]

Simple Flickr Integration

Today, I've developed Simple Flickr Integration with Coldfusion. It's just simple and no thing to be surprised what I've done. As we all, Flickr support us to give API features for integrate with them. But, it's not right time for me to use this Flickr API because I don't want to upload any photo to Flickr via my blog or website because of bandwidth limitation at my hosting.

Here is coding which fetch photograph from Flickr.

view plain print about
1<!--- Get Flickr RSS --->
2<cfhttp url="[your_rss_feed_from_flickr]" method="GET"></cfhttp>
3<cfscript>
4    FlickrContent = trim(cfhttp.filecontent);
5    FlickrContent = XMLParse(FlickrContent);
6
</cfscript>
7<table border="0" width="100%" cellpadding="5" cellspacing="5">
8<tr>
9<cfloop from="1" to="#ArrayLen(FlickrContent.rss.channel.item)#" index="i">
10    <td align="center" style="border:1px ##999999 solid;">
11        <a href="#FlickrContent.rss.channel.item[i].link.xmlText#">
12            #FlickrContent.rss.channel.item[i].title.xmlText#
13        </a><BR><BR>
14        <a href="#FlickrContent.rss.channel.item[i].link.xmlText#">
15            <img src="#FlickrContent.rss.channel.item[i]['media:thumbnail'].xmlattributes.url#" border="0">
16        </a><BR><BR>
17        <small><strong>Uploaded on :</strong> #Dateformat(FlickrContent.rss.channel.item[i].pubDate.xmlText, "dd-mmm-yyyy")#</small>
18    </td>
19    <!--- I want to display only 5 photo per line --->
20    <cfif i MOD 5 EQ 0></tr><tr></cfif>
21</cfloop>
22</table>

Here is my photography on Flickr

Cusor loop and for loop in Oracle

Today I've wrote new complex stored procedure in Oracle for HL7 interface. As I mention in above post, I'm very new to Oracle and haven't known yet all of Oracle's functions and commands. But I need to create new Oracle stored procedure for existing project. When I creating Stored Procedure, I've found two different looping of Cursor. There are Open Cursor and For Loop cursor. Both of them are equal to retrieve data from table but different performance.

As far as I know, Open cursor stands for limited data amount handling and will get slow when large data amount in it. For loop cursor can handle large data amount.

[More]

CFHttp for Adobe Coldfusion and Railo Coldfusion

I got a problem to test web-spider created by Raymond in my blog yesterday. Even I put the right files and the right coding into my blog, I couldn't test and run this file. I don't know why and I don't want to bother to him anymore. That's why I kept troubleshooting for it by myself. Few minutes later, I just found it's because of Railo.

In Adobe Coldfusion, we need to write the following code if we want to get content from the website inside in CFScript.

view plain print about
1<cfscript>
2    function getContent(url)
3        {
4            var h = new com.adobe.coldfusion.http();
5            h.setURL(url);
6            h.setMethod("get");
7            h.setResolveURL(true);
8            variables.queue = [];
9            var result = h.send().getPrefix();
10            var content = result.filecontent;
11            return content;
12        }
13
</cfscript>

In Railo, it's quite different. We need to write the following code if we want to get content from the website inside in CFScript.

view plain print about
1<cfscript>
2    getInfo = new HTTP(url='http://www.ppshein.net');
3
    Results = getInfo.send();
4    myStructure = DeSerializeJSON(Results.getPrefix().filecontent);
5</cfscript>

That's the first one I know different between Railo and Adobe. I think there might have a few different functions and tags between them. I can't convince why Railo don't want to develop the same function structure and calling style like Adobe Coldfusion. I think they're trying to make simple than Adobe Coldfusion.

[More]

Adobe Coldfusion 9 exam is out

Adobe Coldfusion 9 exam is out on 5th Nov 2010. That's why I need to upgrade Coldfusion 8 certification to 9 soon. If not, my Coldfusion 8 certificate will be expired soon. I got there are different between Coldfusion 8 and Coldfusion 9 about Topic Area.

Topic area of Adobe Coldfusion 8

1. Programming Fundamentals

2. Working with the Application framework

3. Handling exceptions

4. Interacting with databases

5. Working with XML

6. Reusing code

7. Managing client state

8. Interacting with remote systems

9. Managing files

10. Tuning application performance

11. Delivering and presenting information

Adobe ColdFusion 8 Developer Certification Examination Specification

[More]

Create Function in Oracle with Cursor Loop

In these days, I'm on HL7 project and need to create functions and store procedures in Oracle for message sending. In our HL7 standard, all of transaction will be manipulated by Oracle and don't make busy to Coldfusion due to we use less coding inside in CFML file and hope Oracle can manipulate the large data amount than CFML.

Honestly, I'm very new to Oracle and still need self-learning Oracle's functions and commands for developing Functions and Store Procedures.

First of all, I've recently finished reading Cursor Loop in Oracle. Because I need to concatenate the data come from table.

[More]

REMatch in Coldfusion save my time

As we all know, there are a lot of functions in Coldfusion and I can't know all of them when I need to use. That's why I print out all of Coldfusion functions lists and put it on my wall. Even I did it already, I missed to use some core functions to put my projects. REMatch is one of them.

The usage of REMatch is to compare two strings and return the match string both of them as array. Adobe recommend that when we're gonna use REMatch, try it with regular expression and which will be powerful.

Before I didn't know REMatch function, I've created ListGetDifferent function by myself for searching the same value and the different value between two lists.

http://www.ppshein.net/index.cfm/2010/9/9/compare-list-in-coldfusion

Once I know REMatch, I feel I don't need to use my own UDF anymore when I need to compare two string but NOT list.

[More]

CreateUUID make our system to getting slow

In these days, our system is getting slow and sometimes it hangs even there are not much that data in our database. That's why I kept troubleshooting which bugs made it to getting slow. Obviously, everything seemed fine in my codes and I strongly believed that it might not be because of my codes. But I found I put a lot of CreateUUID() in my codes for getting random value.

view plain print about
1<cfset randomCount = CreateUUID()>

So I googled about CreateUUID() in Adobe. Oddly, Adobe mention like that Calling the createUUID function multiple times under load in Macromedia ColdFusion MX and higher can cause the Windows system clock to accelerate.

Regarding Adobe announcements, I need to change the way of getting random value

view plain print about
1<cfset randomCount = RandRange(1, 1000)>

instead of

view plain print about
1<cfset randomCount = CreateUUID()>

Top of Page