Ben Folds Five Reunion

NYMEX Crude Oil Pod

Its been a while since I had a new post. Mainly because I've been working on an awesome Flex application for the Fleet Leasing Company where I work.

About 3 months ago I got a Yahoo Widget that reads the NYMEX for Light Sweet Crude and posts the price to my desktop ever 20 minutes or so. The owner of my company comes over a couple times a week and checks it out. Today he asked me to create one for our client website. So the cfc I made now drives the pod. Here is the code:

The CFC
<cfcomponent>
   <cffunction name="getOilPrice" access="public" returntype="string">
      <cfargument name="firstCatch" type="string" default="#HTMLEditFormat('<span class="tbl_num">')#">
<cfargument name="lastCatch" type="string" default="#HTMLEditFormat('</span>')#">
      <cfargument name="crudeURL" type="string" default="http://www.bloomberg.com/markets/commodities/energyprices.html">
<cfhttp url="#arguments.crudeURL#" resolveurl="Yes" throwOnError="Yes"/>
         <cfset nymex = #CFHTTP.FileContent#>
<cfset firstDmp = '#mid(nymex, 1, val(find(arguments.firstCatch, nymex, 0) + val(len(arguments.firstCatch)-1)))#'>
         <cfset leftNYMEX = ReplaceNoCase(nymex, firstDmp, '')>
<cfset secondDmp = '#mid(leftNYMEX, 1, val(find('.', leftNYMEX, 0) + 2))#'>
<cfset newNYMEX = secondDmp>
      <cfreturn newNYMEX>
   </cffunction>
</cfcomponent>
The Pod
<cfsetting enablecfoutputonly='true'>
<cfprocessingdirective pageencoding='utf-8'>
<!---
Name : NYMEX Crude Oil Price
Author : PodGenerator (based on archives.cfm by Raymond Camden)
--->


<cfmodule template='../../tags/podlayout.cfm' title='NYMEX Crude Oil Price'>
<!---
Your Pod text goes here -
Remember it has to be in cfoutput
tags or it will not be displayed
--->
<cfinvoke component="components.nymex" method="getOilPrice" returnvariable="newNYMEX">
   <cfinvokeargument name="firstCatch" value='<span class="tbl_num">'>
<cfinvokeargument name="lastCatch" value='</span>'>
<cfinvokeargument name="crudeURL" value="http://www.bloomberg.com/markets/commodities/energyprices.html">
</cfinvoke>
<cfoutput>
<div align="center">NYMEx Crude Oil Price as of:</div>
<div align="center">#dateFormat(now(), 'mmm/dd/yy')# #timeFormat(now(), 'HH:MM')#</div>
<div align="center">#dollarFormat(newNYMEX)#</div>
</cfoutput>      
</cfmodule>
<cfsetting enablecfoutputonly='false'/>

Feel free to use it, but don't be like Ray Horn and not pay homage to my greatness.

Created by Christopher Walker - www.SharedDynamics.com

SQL Injection attacks

First thing to say about this subject is this: If you aren't using stored procedures and scoping your variables with cfprocparam or cfqueryparam (if you use a plain ol' query) then you are moments away from a SQL injection attack and a potential total loss of data.

[More]

Sender Policy Framework

Do you manage the mail server for your organization and are you constantly asked questions about emails that appear to originate from authentic members of your org praising the benefits of Viagra?  If so,

[More]

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.9. Contact Blog Owner