Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@wellercs
wellercs / cfhttp_caller.cfm
Created January 15, 2013 01:53
test cfhttp encoding in url
<cfparam name="url.scope" default="">
<cfhttp url="http://#cgi.http_host#/sandbox/receiver.cfm?scope=#url.scope#" method="post" resolveurl="no">
<cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded" />
</cfhttp>
<cfdump var="#cfhttp#">
@wellercs
wellercs / js_DataErrorMessage
Created July 27, 2012 23:16
Validate client-side with dataset property
<html>
<head>
<title>Data Error Message Sandbox</title>
<script type="text/javascript">
function checkForm() {
var myformelement = document.getElementById('myformelement');
var usermessage = document.getElementById('usermessage');
if (myformelement.value == "") {
try {
alert(myformelement.dataset.errorMessage);
@wellercs
wellercs / tsql_GetFirstItemFromListUsingSubstringAndCharIndex
Created July 27, 2012 23:11
t-sql get first item from list using substring and charindex
DECLARE @InvalidList varchar(50)
DECLARE @ValidList varchar(50)
SET @InvalidList = 'Item1-Item2-Item3'
SET @ValidList = 'Item1 > Item2 > Item3'
SELECT
CASE
WHEN CHARINDEX('>',@InvalidList) = 0 THEN @InvalidList
ELSE LTRIM(RTRIM(REPLACE(SUBSTRING(@InvalidList,1,CHARINDEX('>',@InvalidList)),'>','')))
END
@wellercs
wellercs / tsql_FindFirstCharacterWithCharIndex
Created July 27, 2012 23:07
Searching on first character with CHARINDEX
DECLARE @AlphaNumChars varchar(50)
SET @AlphaNumChars = 'a,1,m,s'
SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE CHARINDEX(LEFT(TABLE_NAME,1),@AlphaNumChars) > 0
@wellercs
wellercs / tsql_DisplayDateTimeAndTimePeriod
Created July 27, 2012 23:04
t-sql display date, time, time period
SELECT
GETDATE() AS this_date_time
, CONVERT(VARCHAR, GETDATE(), 101) AS this_date
, RIGHT(CONVERT(VARCHAR, GETDATE(), 100),7) AS this_time
, ( CONVERT(VARCHAR, GETDATE(), 101) + ' ' + RIGHT(CONVERT(VARCHAR, GETDATE(), 100),7) ) AS this_date_time
@wellercs
wellercs / cf_IsNullFormat
Created July 27, 2012 23:01
Easy method for setting cfqueryparam null attribute
<cfcomponent name="utilities" output="false" hint="I provide various utility functionality">
<cffunction name="init" access="public" returntype="any" output="false" hint="Initializes the Service">
<cfreturn this />
</cffunction>
<cffunction name="isNullFormat" access="remote" returntype="any" output="false" hint="I return whether something is null">
<cfargument name="input" type="any" required="true" />
<cfset var inputdatatype = "">
<cftry>
@wellercs
wellercs / cf_QueryOfQueriesDivideByZeroNotThrowingError
Created July 27, 2012 22:56
CF query of queries divide by zero not throwing error
<cfquery name="qryTest" datasource="dsnCommon">
SELECT 0 AS col1, 0 AS col2
</cfquery>
<cfquery name="qqTest" dbtype="query">
SELECT (col1 / col2) AS col3
FROM qryTest
</cfquery>
<cfdump var="#qqTest#">