My Journey Through cf.Objective() 2009 (And My Raffle Winner!)

<!--- Get the min and max photo indexes. --->
<cfset intMinPhotoIndex = 57 />
<cfset intMaxPhotoIndex = 96 />
 
<!--- Build a query to get all digits. --->
<cfset strQuery = (
	"q=" &
	"0+OR+" &
	"1+OR+" &
	"2+OR+" &
	"3+OR+" &
	"4+OR+" &
	"5+OR+" &
	"6+OR+" &
	"7+OR+" &
	"8+OR+" &
	"9&" &
	"rpp=#RandRange( 10, 100 )#&" &
	"page=" & RandRange( 1, 5 )
	) />
 
<!--- Get statuses that have digits. --->
<cfhttp
	result="objGet"
	method="get"
	url="http://search.twitter.com/search.json?#strQuery#"
	useragent="bot.bennadel.com"
	/>
 
<!--- Desearilize the JSON response. --->
<cfset arrStatuses = DeserializeJSON( objGet.FileContent ).Results />
 
 
<!---
	Get a running total - we are going to grab every number
	out of the given result set.
--->
<cfset intTotal = 0 />
 
<!--- Loop over the results. --->
<cfloop
	index="objStatus"
	array="#arrStatuses#">
 
	<!--- Grab all numbers out of this status text. --->
	<cfset arrNumbers = REMatch( "\d{1,5}", objStatus.Text ) />
 
	<!---
		Sum the numbers and add them to our running total. Wrap
		this in a try/catch because it might have extended
		characters that could trip us up.
	--->
	<cftry>
		<cfset intTotal += ArraySum( arrNumbers ) />
 
		<cfcatch>
			<!--- Nothing to do here. --->
		</cfcatch>
	</cftry>
 
</cfloop>
 
 
<!---
	Now that we have our running total, let's use that to pick
	a random number between our photos (using MOD).
--->
<cfset intPhotoIndex = (
	intMinPhotoIndex +
	(intTotal MOD (intMaxPhotoIndex - intMinPhotoIndex + 1))
	) />
 
<!--- Output the link to the randomly selected photo. --->
<cfoutput>
 
	<p>
		And the winner is:
		<a
			href="http://www.bennadel.com?site-photo=#intPhotoIndex#"
			target="bennadel"
			>#intPhotoIndex#</a>
	</p>
 
</cfoutput>

For Cut-and-Paste