Skip to content

Instantly share code, notes, and snippets.

View kevindb's full-sized avatar

Kevin Morris kevindb

View GitHub Profile

Keybase proof

I hereby claim:

  • I am kevindb on github.
  • I am kevinmorris (https://keybase.io/kevinmorris) on keybase.
  • I have a public key whose fingerprint is 96E4 7994 CC82 38DB 8D67 050A F496 D958 F98A E40C

To claim this, I am signing this object:

/* --------------------------------------------------------------------------------------- ----
Blog Entry:
Handling Remote API Errors With Application.cfc's OnError() Event Method
Author:
Ben Nadel / Kinky Solutions
Link:
http://www.bennadel.com/index.cfm?event=blog.view&id=1567
public string function getGuid(){
return insert("-", createUUID(),23);
}
public boolean function getIsGuid(
required string guid
){
return isValid("regex", arguments.guid,"^[a-fA-F\d]{8}-([a-fA-F\d]{4}-){3}[a-fA-F\d]{12}$");
}
@kevindb
kevindb / gist:ad533e1464389b18aff8
Created August 6, 2014 17:43
CF arrayStructKeyToList
public string function arrayStructKeyToList(
required array arr,
required string key
){
local.response = "";
if(len(arguments.key) gt 0){
for(local.elem in arguments.arr){
if(structKeyExists(local.elem, arguments.key)){
@kevindb
kevindb / jquery.ajaxSelect.js
Last active August 29, 2015 14:06
jquery.ajaxSelect.js
(function( $ ) {
// Plugin definition
$.fn.ajaxSelect = function(settings) {
// Extend this object from Deferred, allowing for promises
var defer = $.extend(this, $.Deferred());
// Extend our default options with those provided.
// Note that the first argument to extend is an empty
// object – this is to keep from overriding our "defaults" object
@kevindb
kevindb / queryToArray
Created March 23, 2015 12:11
ColdFusion Query Transformation
/**
* @hint Returns reasonable array of objects from a cfquery
*/
public function queryToArray(
required query query,
string excludeColumns = ""
){
if (server.coldfusion.productName == "ColdFusion Server") {
local.columns = arguments.query.getMetaData().getColumnLabels();
@kevindb
kevindb / compressHtml
Last active February 16, 2017 22:52
ColdFusion Compress HTML
/**
* @hint Removes whitespace from HTML code
Originally authored by Jordan Clark ([email protected])
*/
public string function compressHtml(
required string html,
numeric level = 2
){
local.response = this.trim(arguments.html);
@kevindb
kevindb / sparseColumns.sql
Last active February 19, 2021 22:49
Find candidates for sparse columns in SQL Server
SET nocount ON;
IF Object_id('tempdb..#SPARCEPERCENTAGE') IS NOT NULL
BEGIN
DROP TABLE #sparcepercentage
END;
IF Object_id('tempdb..#TMP') IS NOT NULL
BEGIN
DROP TABLE #tmp
@kevindb
kevindb / TrimAllColumns.sql
Last active August 29, 2015 14:18
Trims leading and trailing whitespace from every column in a SQL Server table
SET NOCOUNT ON;
DECLARE @TABLE VARCHAR(100),
@SQL VARCHAR(MAX);
SET @TABLE = '';
SELECT @SQL = COALESCE(@SQL, '')
+ CAST( 'UPDATE ' + @TABLE + ' ' +
'SET [' + C.COLUMN_NAME + '] = LTRIM(RTRIM(' + C.COLUMN_NAME + ')) ' +
@kevindb
kevindb / NullifyColumns.sql
Last active August 29, 2015 14:18
Sets empty string columns to NULL in a SQL Server table
SET NOCOUNT ON;
DECLARE @TABLE VARCHAR(100),
@SQL VARCHAR(MAX);
SET @TABLE = '';
SELECT @SQL = COALESCE(@SQL, '')
+ CAST( 'UPDATE ' + @TABLE + ' ' +
'SET [' + C.COLUMN_NAME + '] = NULL ' +