This file contains hidden or 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
<cfscript> | |
// Query to retrieve some data from the database | |
variables.myData = queryExecute( | |
sql = " | |
SELECT * | |
FROM myTable | |
LIMIT 10 | |
", | |
options = {datasource="#Application.myDSN#"} | |
); |
This file contains hidden or 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
<cfscript> | |
// If you don't set this then the searchParams structure will be uppercased when converted to JSON and cause ElasticSearch to error. | |
processingdirective preserveCase="true"; | |
public struct function elasticSearchSearch( required string serverURL, | |
required struct searchParams, | |
required string index, | |
required string type) { | |
// Post the search parameters to the ElasticSearch index and type | |
http method="post" url="#arguments.serverURL#/#arguments.index#/#arguments.type#/_search" result="searchResponse" { |
This file contains hidden or 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
<cfscript> | |
function convertSecondsToTimeString(seconds) { | |
local.hours = arguments.seconds \ 3600; | |
local.minutes = (arguments.seconds \ 60) mod 60; | |
local.seconds = (arguments.seconds) mod 60; | |
return numberformat(local.hours, "0") & ":" & numberformat(local.minutes, "00") & ":" & numberformat(local.seconds, "00"); | |
} | |
</cfscript> | |
<cfoutput> |
This file contains hidden or 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
<cfscript> | |
public any function getWeekOfMonth(date d='#Now()#', numeric minDaysInFirstWeek=1) { | |
var cal = CreateObject('java', 'java.util.GregorianCalendar').init( | |
JavaCast('int', Year(arguments.d)) | |
, JavaCast('int', Month(arguments.d)-1) | |
, JavaCast('int', Day(arguments.d)) | |
, JavaCast('int', Hour(arguments.d)) | |
, JavaCast('int', Minute(arguments.d)) | |
, JavaCast('int', Second(arguments.d)) | |
); |
This file contains hidden or 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
<cfscript> | |
public any function isoDateTimeFormat(date timestamp='#Now()#') { | |
var dt = DateConvert('local2utc', arguments.timestamp); | |
return DateFormat(dt, 'yyyy-mm-dd') & 'T' & TimeFormat(dt, 'HH:mm:ss.000') & 'Z'; | |
} | |
</cfscript> |
This file contains hidden or 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
<cfscript> | |
/* ************** Setting Cookie by cfscript in ColdFusion 10 *********** */ | |
//Type - 1 | |
variables.cookieTest = structNew(); | |
variables.cookieTest['value'] = "This is test Cokkie by me by using cfscript"; | |
variables.cookieTest['expires'] = "10"; | |
variables.cookieTest['secure'] = "yes"; | |
variables.cookieTest['domain'] = "cf10"; | |
cookie.myNewCookie = variables.cookieTest; |
This file contains hidden or 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
<!--- Get request from ColdFusion page contenxt. ---> | |
<cfset objRequest = GetPageContext().GetRequest() /> | |
<!--- Get requested URL from request object. ---> | |
<cfset strUrl = objRequest.GetRequestUrl().Append( | |
"?" & objRequest.GetQueryString() | |
).ToString() | |
/> |
This file contains hidden or 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
CREATE TABLE `comuni` ( | |
`id` smallint(4) NOT NULL, | |
`comune` varchar(48) NOT NULL DEFAULT '', | |
`prefisso` char(4) NOT NULL DEFAULT '', | |
`cap` char(5) NOT NULL DEFAULT '', | |
`codice_istat` char(6) NOT NULL DEFAULT '', | |
`codice_catasto` char(4) NOT NULL DEFAULT '', | |
`id_provincia` tinyint(3) NOT NULL, | |
`sigla` char(2) NOT NULL DEFAULT '', | |
`provincia` varchar(48) NOT NULL DEFAULT '', |
This file contains hidden or 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
<cfscript> | |
// Create an instance of the mail object | |
mail=new mail(); | |
// Set it's properties | |
mail.setSubject( "Sample Email" ); | |
mail.setTo( "[email protected]" ); | |
mail.setFrom( "[email protected]" ); | |
mail.setCC( "[email protected]" ); | |
mail.setBCC( "[email protected]" ); |
This file contains hidden or 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
<!--- place in /controllers folder---> | |
<cfcomponent extends="Controller"> | |
<cffunction name="getdemo" returntype="Query" access="private" > | |
<cfset var entries = model("entry").findAll(select="BODY,CATEGORYID,TITLE,dateCreated") /> | |
<cfreturn entries /> | |
</cffunction> | |
<cffunction name="init"> | |
<cfset filters(through="turnOffDebugging",only="processing")> |