Jun 13 2021

CKEditor – FontAwesome tags removed

 

add to config.js, upload and refresh (clear cache using ctrl+F5)
config.protectedSource.push( /<i class[\s\S]*?\>/g );
config.protectedSource.push( /<\/i>/g );

source: https://ckeditor.com/old/forums/CKEditor/FontAwesome-tags-removed-when-switching-between-Source-and-Wysiwyg

 

 


Jun 10 2021

ASP: web config http to https redirection


                <clear />
                <rule name="Redirect to https" stopProcessing="true">
                    <match url=".*" />
                    <conditions>
                        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
                </rule>

source: https://stackoverflow.com/questions/9823010/how-to-force-https-using-a-web-config-file


Apr 17 2021

MSSQL – CASE WHEN IN WHERE

select * from tbl_events_dates
where
1 =

(
 CASE WHEN
 tbl_events_dates.dateStart < CAST(cast(year(GETDATE()) as varchar)+'-09-01' AS datetime)
 THEN
 CASE WHEN
 tbl_events_dates.dateStart >= CAST(cast(year(DATEADD(year,-1,GETDATE())) as varchar)+'-09-01' AS datetime)
and
tbl_events_dates.dateStart <CAST(cast(year(GETDATE()) as varchar)+'-09-01' AS datetime)
 THEN 1 else 0 end
 ELSE
 CASE WHEN
 tbl_events_dates.dateStart <=CAST(cast(year(GETDATE()) as varchar)+'-09-01' AS datetime)
and
tbl_events_dates.dateStart >= CAST(cast(year(DATEADD(year,1,GETDATE())) as varchar)+'-09-01' AS datetime)
 THEN 1 else 0 end
END
)

Apr 9 2021

Coldfusion – queryOfQueries union – not elegant but effective :)


<cfset Local.currencies = arrayNew(1)>
 <cfset arrayAppend(Local.currencies, 'EUR')>
 <cfset arrayAppend(Local.currencies, 'HRK')>
 <cfset arrayAppend(Local.currencies, 'BGN')>
 <cfset arrayAppend(Local.currencies, 'RON')>

 <cfset currencyList = structNew()>

 <cfloop from="1" to="#arrayLen(Local.currencies)#" index="a">

 <cfset local.currency = structNew()>

 <cfset local.currency.currency = Local.currencies[a]>

 <cfset arguments.currency = Local.currencies[a]>

 <cfset local.currency.query = get_paiment_report_Query(argumentCollection = arguments)>

 <cfset currencyList[local.currency.currency] =  local.currency>

 </cfloop>

 <cfquery name="q_payments" dbtype="query" result="queryResult">

 <cfset var count = 0>

 <cfloop collection="#currencyList#" item="key"  >

 <cfif currencyList[key].query.recordcount neq 0>

 <cfset count = count+1>

 <cfif count gt 1 >

 UNION

 </cfif>

 SELECT * FROM currencyList.#key#.query

 </cfif>

 </cfloop>

 </cfquery>

Apr 9 2021

ColdFusion – queryOfqueries union – elegant

private any function combineQuery(qA, qB) {
 var qry1Result = arguments.qA;
 var qry2Result = arguments.qB;
 var qoqResult = '';

// create new query object
 var qoq = new Query();

// set attribute of new query object to be a query result with arbortrary name

qoq.setAttributes(QoQsrcTableA = qry1Result);
 qoq.setAttributes(QoQsrcTableB = qry2Result);

// use previously set attribute as table name for QoQ andset dbtype = query
 qoqResult = qoq.execute(sql="select * from QoQsrcTableA union select * from QoQsrcTableB", dbtype="query");

// return result
 return qoqResult.getResult();

}

source: https://coldfusion.adobe.com/2017/10/unioning-queries-using-query-of-query/


Mar 9 2021

MSSQL – get the first and the last date of the month

SELECT DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0) AS StartOfMonthDate
SELECT EOMONTH(getdate()) AS EndOfMonthDate 

Feb 17 2021

ColdFusion – get file name before cffile upload

<cffunction name="getClientFileName" returntype="string" output="false" hint="">
	<cfargument name="fieldName" required="true" type="string" hint="Name of the Form field" />

	<cfset var tmpPartsArray = Form.getPartsArray() />

	<cfif IsDefined("tmpPartsArray")>
		<cfloop array="#tmpPartsArray#" index="local.tmpPart">
			<cfif local.tmpPart.isFile() AND local.tmpPart.getName() EQ arguments.fieldName>
				<cfreturn local.tmpPart.getFileName() />
			</cfif>
		</cfloop>
	</cfif>

	<cfreturn "" />
</cffunction>

source: http://www.stillnetstudios.com/get-filename-before-calling-cffile/


Feb 8 2021

MSSQL – ORDER BY date with past dates after upcoming dates


SELECT *
FROM tableName
ORDER BY (CASE WHEN dateColumn < GETDATE()
              THEN 1
              ELSE 0
         END) DESC, dateColumn ASC




source: https://stackoverflow.com/questions/12365246/order-by-date-with-past-dates-after-upcoming-dates

 


Jun 16 2020

Excel – compare two or more columns

=IF(AND(B78=P78;C78=Q78;D78=R78;E78=S78;F78=T78);"DA";"NE")

… and dragg…

https://www.ablebits.com/office-addins-blog/2015/08/26/excel-compare-two-columns-matches-differences/

https://support.microsoft.com/en-us/office/using-if-with-and-or-and-not-functions-d895f58c-b36c-419e-b1f2-5c193a236d97?ui=en-us&rs=en-us&ad=us


May 19 2020

Coldfusion – get PDF page count


<cfpdf action="getInfo" source ="test.pdf" name="PDFInfo">
<cfset pageCount = "#PDFInfo.TotalPages#" >