Skip to content

Instantly share code, notes, and snippets.

@huguogang
huguogang / gist:4991655
Created February 20, 2013 00:35
JSONP in Coldfusion
<!--- if present, indicates this is a JSONP crosssite invocation --->
<cfparam name="callback" type="string" default="">
<cfparam name="jsonp" type="string" default="">
<!--- your code, variable "result" will be the json data for caller --->
<cfif callback NEQ ''>
<!--- JSONP --->
<cfoutput>#callback#(#serializeJSON(result)#);</cfoutput>
<cfelseif jsonp NEQ ''>
@huguogang
huguogang / SQL
Created March 22, 2012 17:00
SQL Server Performance DMV Sample Queries
-----------------------------------------------------------------------
-- Collection of queries that helps in performance tuning
--grant permission to user
GRANT VIEW SERVER STATE TO [user_name]
------------ based on http://msdn.microsoft.com/en-us/magazine/cc135978.aspx
---------- Uncover hidden data to optimize application performance -----------------------
-- * Number of missing indexes
<cffunction name="createExcelObj" access="public" returntype="any" output="false" >
<cfset var oExcel = "">
<CFOBJECT ACTION="CREATE" CLASS="Excel.Application" NAME="oExcel" TYPE="COM">
<cfscript>
//remove all interactions
oExcel.AlertBeforeOverwriting = false;
oExcel.AskToUpdateLinks = false;
oExcel.PromptForSummaryInfo = false;
oExcel.Visible = false;
oExcel.DisplayAlerts = false;
buttonMode = true;
useHandCursor = true;
GRANT EXECUTE ON ConcateAll To my_user
CREATE AGGREGATE dbo.ConcatAll(@input NVARCHAR(4000))
RETURNS NVARCHAR(4000)
EXTERNAL NAME SQLCLR.ConcatAll
CREATE ASSEMBLY [SQLCLR]
FROM 'c:\temp\SQLCLR.dll'
GO
IF EXISTS (SELECT * FROM sys.assembly_modules WHERE assembly_class='ConcateAll')
BEGIN
DROP AGGREGATE dbo.ConcateAll
END
IF EXISTS (SELECT * FROM sys.assemblies WHERE name='SQLCLR')
BEGIN
DROP ASSEMBLY [SQLCLR]
END
sp_configure 'clr enabled', 1
GO
RECONFIGURE
GO
<script src="http://gist.github.com/467670.js?file=gistfile1.sql"></script>