Fresh Mangoes?

2014 September 16
No Comments

My previous host has had issues with their server and I felt it was time to move on. So I'm on a new host with a fresh MangoBlog install. New posts are inevitable, but the good stuff from my [old] blog will be migrated soon. Hopefully, this crash and re-incarnation hasn't been a thorn to anyone.

MSSQL money datatype and <cfqueryparam/>

2011 April 07
No Comments

This is just a quick post about the <cfqueryparam/> and cf_sql_type to use with when working with Microsoft SQL Server (MSSQL) money datatype.  While working on a recent project the client specified the db schema and I had to work with a predefined schema. I typically don't use the money datatype, when designing a db schema, preferring instead to use decimal(8,2) for fields where I'm storing monetary data.   As we began loading data into a table with money as the datatype, we noticed that amounts like 129.99 were being rounded up to 130.  The ColdFusion 9 reference for  <cfqueryparam/> does not mention the money datatype, but recommends using cf_sql_money for the double datatype.  The ColdFusion 8 reference suggests using the cf_sql_decimal type when storing data to decimal, money, smallmoney mssql datatypes.  I followed the suggestion in the CF8 reference, but ran into the rounding error.  Finally, I was hipped to the correct cf_sql_type to use by my good friend Matt Quackenbush.  He's experienced the same issue in the past and informed me that the solution is to use cf_sql_float.

An Asynchronous AOP Advice Example

2009 November 27
No Comments
Over the past year, I have dabbled more and more with leveraging AOP in my applications,primarily for logging and caching. Recently, I needed to analyze a system for performance and determined that for some operations, there were several points where third party integrations are managed. These points slowed the request lifecyle dramatically and were targeted to be re-written using cfthread. I love a good refactoring challenge as much as the next guy, but I also love a good abstraction. Thus, the AsynchronousAroundAdvice was born.

read more...

Enabling SSL Connections for Apache Virtual Hosts on OS X 10.5

2009 February 26
No Comments
tags: Apache · OS X

Today, I was able to get https working for localhost connections after following these step by step instructions for creating and signing a cert and updating httpd.conf and httpd-ssl.conf on Mac OS X Hints. Problem is, I need https for vhosts. When trying to connect to a local vhost over https, I encountered the following error: Error code: ssl_error_rx_record_too_long). Much more googling turned up the answer. You need to turn the SSLEngine On for vhosts. Thanks to the Ubuntu forums for that gem. Here's an example vhost that uses SSL.

<VirtualHost 127.0.0.1:443>
DocumentRoot "/Users/paul/Sites/myproject"
ServerName myproject.fancybread.local
SSLEngine On
SSLCertificateFile "/Users/paul/certs/localhost/newcert.pem"
SSLCertificateKeyFile "/Users/paul/certs/localhost/localhost.nopass.key"

DirectoryIndex index.cfm
<Directory "/Users/paul/Sites/myproject">
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Wiring the Coldbox Logger Plugin To An AOP Logging Advice

2009 January 13
No Comments

Logging is one of the classic cross-cutting concerns one hears about when discussing Aspect Oriented Programming (AOP). Other common aspects are caching, security and data transformation. Over the past year, I've begun to apply AOP with ColdSpring to my application design. I was completely confused about just what was going on with AOP, when I first looked at it, then, by degrees, I came to realize that it is actually pretty simple if you can focus on the basics without trying to absorb all the terms associated with AOP. With the release of ColdSpring 1.2, Brian Kotek wrote an excellent quickstart guide, that I recommend (especially for the AOP tutorial which I borrow heavily from for this example). I'll briefly describe how I wrapped my head around the concept.

read more...

Customizing the ColdBox Logger Plugin with Method Injection

2009 January 09
No Comments

I've started using Coldbox recently and really like the tooling it provides. I don't always have access to the ColdFusion logs for apps on shared servers and although I have worked with log4j, I didn't like property file configuration. The simplicity of the ColdBox logger is great, but I wanted to be able to set log levels and work with the standard debug(), info(), warn(), error() and fatal() methods. One way to achieve this is to mixin the desired behaviour. Another ColdBox plugin, methodInjector, allowed me to do just that.

read more...

Working With Transfer ORM - Transfer Transaction Advice

2008 November 28
No Comments

Maintaining referential integrity in your database is a good thing. Any decent RDBMS will include ACID (Atomicity, Consistency, Isolation, Durability) transaction support for ensuring consistency and recoverability of your database. With the Transfer ORM Transaction object, one can apply transactions easily to a Service or Gateway. Here's how one can use it to wrap all "save" and "delete" methods for a Service.

read more...

A Simple onMissingTemplate Example

2008 November 24
No Comments

For the migration to Mango Blog, I wanted to preserve my previous RSS feed location (/rss.cfm). The new location is feeds/rss.cfm. With the availability of onMissingTemplate event handler for ColdFusion 8, making sure my RSS didn't break was a snap. Here's the snippet of code I added to Application.cfc.

<cffunction name="onMissingTemplate" returntype="void">
   <cfargument name="thePage" type="string" required="true">
   <cfif arguments.thePage is "/blog/rss.cfm">
      <cflocation url="/blog/feeds/rss.cfm" addtoken="false" />
   </cfif>
</cffunction>

Not the most elegant solution I've ever developed, but it keeps the RSS feed alive until I decide how I want to manage it the future...

Transient Creation Performance - ColdSpring and TransientFactory

2008 November 11
No Comments
In my last post, I demonstrated the generic factory I use to create Transient objects in my Coldfusion apps. Jaime Metcher asked in a comment whether the Transient Factory is faster than CS when instantiating transient objects. I had no hard data to answer Jaime's question, so I took the opportunity to set up jMeter on my new dev machine and run through some load tests to find out.

read more...

A Coldfusion Transient Factory Example

2008 November 07
No Comments
When learning how to apply object oriented principles to ColdFusion development, one will assuredly encounter the subject of design patterns. Singleton, Factory, Strategy and Bridge are just some of the patterns that describe solutions to common problems in programming. For this example, I'll demonstrate a variation on the Factory Pattern for transient objects. What is a factory? At it's simplest, a factory encapsulates the creation of objects to provide a consistent api for clients. What is a transient object? A typical OO ColdFusion application will incorporate a combination of Singletons (one instance per application - often instantiated at application startup) and Transients (a per request object that is not maintained in a persistent scope).

read more...