Smith goes Open Source

8 May 2007 22:25 (EST)
On 7th May 2007 youngculture AG decided to open source its ColdFusion Server "Smith".

Smith is an open source, cross-platform ColdFusion® engine, written entirely in Java. Running on top of Java Runtime Environment and Java Servlet Container, it can be virtually deployed on any operating system and work with any web server. Smith represents lightweight, yet reliable alternative to the existing ColdFusion® servers.


This is definitely one of the best news for CF community this year along with recent news about Adobe Flex soon to be open source and forthcoming release of Adobe ColdFusion 8.

OpenID CFC: Consumer v.0.2

8 May 2007 01:39 (EST)
New version (0.2) of consumer library for OpenID auth framework has been released tonight. This version has completely new structure, more transparent and easy to understand logic. Both 'smart' and 'dumb' modes are supported, few internal comments added.

Null Character

6 May 2007 01:22 (EST)
It looks like ColdFusion interpret the null character as an empty string instead of a valid character.

What would you see by running the following code? Length of "test" string will be 6, instead of 7.
<cfset test = "123" & Chr(0) & "abc" />
<cfoutput>#Len(test)#</cfoutput>

So basically you are loosing null character. This might not be a problem in most of the cases, but becomes quite important issue for a specific tasks as encryption and decryption where you have to control all ASCII characters.

In order to solve the problem and get correct results you should use URLDecode("%00") function instead of Chr(0), like in this example below:
<cfset test = "123" & URLDecode("%00") & "abc" />
<cfoutput>#Len(test)#</cfoutput>

The length is 7 now!

How to compact MS Access database

16 April 2007 15:20 (EST)
This example works only if MS Access is installed on web server (but such case is not advised for security reasons):

<cfscript>
   caller.error = 0;
   if (not isDefined("attributes.database"))
      caller.error = caller.error + 1;
   else {
      if (not FileExists(attributes.database))
         caller.error = caller.error + 2;
      path = GetDirectoryFromPath(attributes.database);
      success = 0;
      while (success eq 0) {
         attributes.tempdatabase= path & randrange(1000,9999) & ".mdb";
         if (not FileExists(attributes.tempdatabase))
         success = 1;
      }
   }
   if (isDefined("attributes.backup"))
      if (FileExists(attributes.backupdatabase))
         caller.error = caller.error + 4;
</cfscript>

<cfif not caller.error>

   <cfif isDefined("attributes.backupdatabase")>
      <cffile action="copy" source="#attributes.database#" destination="#attributes.backupdatabase#" />
   </cfif>

   <cftry>
      <cfobject type="com" action="connect" name="objaccess" class="Access.Application" />
      <cfcatch type="Any">
         <cfset request.comerror = cfcatch.message />
         <cfset caller.error = 10 />
         <cfobject type="com" action="create" name="objaccess" class="Access.Application" />
      </cfcatch>
   </cftry>

   <cftry>
      <cfscript>
         objDBEngine = objaccess.DBEngine;
         temp = objDBEngine.CompactDatabase("#attributes.database#","#attributes.tempdatabase#");
      </cfscript>
      <cfcatch type="any">
         <cfset request.comerror = cfcatch.message />
         <cfif cfcatch.message is "">
            <cfset request.comerror = cfcatch.detail />
         </cfif>
         <cfset caller.error = 10 />
      </cfcatch>
   </cftry>

   <cfif FileExists(attributes.tempdatabase)>
      <cffile action="delete" file="#attributes.database#" />
      <cffile action="rename" source="#attributes.tempdatabase#" destination="#attributes.database#" />
   </cfif>

</cfif>

And make sure that database is not locked with CF server.

ColdFusion 8 "Scorpio" Beta

11 April 2007 12:45 (EST)
Applications for the Scorpio Beta are now being accepted.
Please visit Adobe Prerelease Program and click on "Join Adobe Prerelease Program Now".

ABN Validation

10 April 2007 17:48 (EST)
Australian Business Number (ABN) validation function, based on ABN format description from Australian Taxation Office (ATO):

<cffunction name="isValidABN" returntype="boolean" access="public" output="false">
   <cfargument name="ABN" type="string" required="true" />

   <cfset var aWeight = listtoarray("10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19") />
   <cfset var sABN = "" />
   <cfset var i = 0 />
   <cfset var hashSum = 0 />

   <cfset sABN = rereplace(arguments.ABN,"[^\d]","","all") />

   <cfif len(sABN) eq 11>
      <cfloop index="i" from="1" to="11">
         <cfset hashSum = hashSum + aWeight[i]*(mid(sABN,i,1)-iif(i eq 1,de(1),de(0))) />
      </cfloop>
      <cfif hashSum mod 89 eq 0>
         <cfreturn true />
      </cfif>
   </cfif>

   <cfreturn false />

</cffunction>

Melbourne CFUG

6 April 2007 20:17 (EST)
When: 19 April 2007 @ 7:00pm

Location: NGA.net, Level 2, 17 Raglan St, South Melbourne (map)

Agenda:

1) WebDU Overview.
We'll cover what happened at WebDU, what was interesting, what was not, as well as all the interesting goings on at all the keynotes.

2) Annual CFUG General Meeting
Here is you chance to have you say about the CFUG.
What do you want to hear about? What don't you want to hear about?
We'll cover some of the general organisational changes that went on, as well as all the interesting stuff that we have planned for the future.

RSVP: mark DOT mandel AT gmail DOT com

See the CFUG Melbourne Calendar at:
http://www.cfcentral.com.au/Events/index.cfm

UTF8 sorting order with MySQL

20 March 2007 13:00 (EST)
By default MySQL sorts UTF8 fields using following order:
  1. Numbers,
  2. English characters, and than
  3. Non-English characters.
But if you need to display fields with non-English characters before anything else, you can use following SQL statement:

SELECT name, IF(name REGEXP '^[a-zA-Z0-9]', 0, 1) AS sort FROM test ORDER BY sort DESC, name

T-SQL field formatting

18 March 2007 21:41 (EST)
Here is a tip on number formatting with T-SQL.

For example, you have a numeric field called ProductNumber and want to have it as six-char string with leading zeros.

SELECT RIGHT(REPLICATE('0',5)+CONVERT(VARCHAR,ProductNumber),6) FROM Products

Remove HTML from a string

8 March 2007 11:17 (EST)
REReplaceNoCase(string,"<[^>]*>","","ALL")
Pages previous   next
1 2 3 4 5