This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="calculateUpcCheckDigit" output="no" returnType="string"> | |
<cfargument name="upc" required="true" type="string"> | |
<cfset oddnums = 0> | |
<cfset evennums = 0> | |
<cfloop from="1" to="#len(upc)#" index="x"> | |
<cfif x mod 2 neq 0> | |
<cfset oddnums = oddnums + mid(upc, x, 1)> | |
</cfif> | |
</cfloop> | |
<cfloop from="1" to="#len(upc)#" index="x"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="QueryToStructLowerCase" access="public" returntype="any" output="false" | |
hint="Converts an entire query or the given record to a struct. This might return a structure (single record) or an array of structures."> | |
<cfargument name="Query" type="query" required="true" /> | |
<cfargument name="Row" type="numeric" required="false" default="0" /> | |
<!--- Thanks to: http://www.bennadel.com/index.cfm?event=blog.view&id=149 ---> | |
<cfscript> | |
var local.local = StructNew(); | |
if (ARGUMENTS.Row){ | |
local.local.FromIndex = ARGUMENTS.Row; | |
local.local.ToIndex = ARGUMENTS.Row; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfif structkeyexists(GetHttpRequestData().headers,"X-Forwarded-For")> | |
<!--- ipaddress if user is behind load balancer ---> | |
<cfset my_ip = #GetHttpRequestData().headers['X-Forwarded-For']#> | |
<cfset my_ip = trim(listgetat(my_ip,1))> | |
<cfelse> | |
<!--- ipaddress if user is not behind load balancer ---> | |
<cfset my_ip = cgi.remote_addr> | |
</cfif> | |
<cfoutput> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- | |
convert comma separated values (CSV) to tab-separated values (TSV) | |
while preserving commas in qualified strings | |
---> | |
<cffunction name="CSVtoTSV" output="no"> | |
<cfargument name="csv" required="yes" type="string"> | |
<cfset csv = replace(csv, ',', ', ', 'all')> <!--- make sure to trim() values when you use them later ---> |