ColdFusion: compare local files with remote FTP files

Written on 10 October 2011, 04:59pm

Tagged with: ,

What do you do when you discover that the production version of an application is not the same as the development version? (ignore the bigger problems of application development workflow)
You identify the files in question, yes. And what do you identity them when the application contains thousands of source files?
Of course, you make a script.


<cfsetting requesttimeout="300" showdebugoutput="no" />
<cfset initialDir = ExpandPath( '../' )> 
<!--- script is in a sub-folder of the app --->
<cfset total = 0> <!--- total changed files --->
<cfset subTotal = 0> <!--- actual changed files, see below --->
<cfset localRoot = "C:\your\local\app\root" />
<cfset remoteRoot = "/your/remote/root" />
<cfset tmpFile = "/this/is/just/a/temp/file" />

<cfset tick = GetTickCount()>


<!--- get list of ALL local files, recursively --->
<cfdirectory action="list" 
    directory="#initialDir#" 
    name="localQuery" 
    recurse="true"/>

<!--- make the FTP connection --->
<cfftp connection = "ftpConnection" 
    username = "*********"
    password = "*********"
    server = "********"    
    port="****"
    action = "open" 
    stopOnError = "Yes"> 
<cfif cfftp.succeeded EQ false>
    ERROR - FTP open connection failed!
    <cfabort>
</cfif>

<!--- call the recursive function for the first time --->
<cfset compareFiles(remoteRoot) />

<!--- close the FTP connection --->
<cfftp connection = "ftpConnection"
    action = "close"
    stopOnError = "Yes">
<cfif cfftp.succeeded EQ false>
    ERROR - FTP close connection failed!<cfabort>
</cfif>

<cfset tock = GetTickCount()>
<cfset time = round((tock-tick)/1000)>
<cfoutput><hr />#subTotal#/#total# files, #time# seconds</cfoutput>

This is the skeleton. The business logic happens in the function below:
(more…)

Google Maps: radius search in Oracle

Written on 21 April 2011, 12:11pm

Tagged with: , ,

Recently I had to implement a ColdFusion + Oracle application using Google Maps. One of the requirements was search by distance (or radius search) for some items, already geocoded.
The items are stored in T_ITEM, with the columns:
ITEM_ID
COORDX --latitude
COORDY --longitude

The latitude and longitude are already calculated, and stored in database as VARCHAR.
The task was to create some sort of function to accept:
-latitude
-longitude
-radius
and to return the items from T_ITEM located within radius kilometers from the given coordinates.

In implementing this task, I started with (more…)

6 useful Oracle commands

Written on 26 March 2011, 12:43pm

Tagged with: , ,

This is more of a reference post to store some useful Oracle features. Or a cheat sheet if you wish 🙂

1. How to find the maximum column size in a table


select
       max(vsize(mycol))
from
       mytable;

2. How to paginate in Oracle using rownum

Method 1:


select * from 
( 
       select rownum r, a.* from 
       (
             YOUR_QUERY
       ) a 
       where rownum <= 10
) 
where r >= 1;

Method 2: (more…)