Skip to content

Instantly share code, notes, and snippets.

View CreativeNotice's full-sized avatar

Ryan Mueller CreativeNotice

View GitHub Profile
@CreativeNotice
CreativeNotice / Yammer_Tidy_2
Created April 13, 2012 15:22
Yammer Tidy 2
// ==UserScript==
// @name Tidy Yammer
// @version 1.2
// @include http*://*yammer.com/*
// ==/UserScript==
/*
* Original idea by dwnz http://userscripts.org/scripts/review/107377
* Updated 04/13/2012 by @CreativeNotice
@CreativeNotice
CreativeNotice / test-query-to-csv-func.cfm
Created May 23, 2012 13:58
CF method to convert a query to csv output.
<cfscript>
/**
* queryToCsv
* Allows us to pass in a query object and returns that data as a CSV.
* This is a refactor of Ben Nadel's method, http://www.bennadel.com/blog/1239-Updated-Converting-A-ColdFusion-Query-To-CSV-Using-QueryToCSV-.htm
* @param {Query} q {required} The cf query object to convert. E.g. pass in: qry.execute().getResult();
* @param {Boolean} hr {required} True if we should include a header row in our CSV, defaults to TRUE
* @param {String} d {required} Delimiter to use in CSV, defaults to a comma (,)
* @return {String} CSV content
*/
@CreativeNotice
CreativeNotice / gist:3440828
Created August 23, 2012 19:50
Function to check for struct key and value existence
public Boolean function structKeyHasValue( required struct s, required any o)
{
return ( structKeyExists(s,o) && len(s[o]) > 0);
}
@CreativeNotice
CreativeNotice / isKeyValueInArray
Created December 3, 2012 19:46
Testing if an Array of Structs contains a key / value pair.
/**
* isKeyValueInArray()
* @displayname Is Key In Array
* @hint Allows you to loop over array of structures and check if there's atleast one containing a key/value pair.
* @param Array arr Array of structures Required
* @param String key The key to look for.
* @param String value The value of the key to look for.
* @returnType Boolean
* @since 0.0.1
*/
@CreativeNotice
CreativeNotice / gist:5170596
Created March 15, 2013 15:18
Detailed Directory List Similar to CF's native DirectoryList but returns these additional pieces of info: datelastmodified, name, size, type, directory, hidden, pathname.
/**
* DetailedDirectoryList
* @displayname Detailed Directory List
* @hint Similar to CF's native DirectoryList but returns these additional pieces of info: datelastmodified, name, size, type, directory, hidden, pathname
* Inspired by code from Anuj Gakhar with modifications by Ed Martin. (http://www.anujgakhar.com/2007/11/08/java-version-of-cfdirectory-updated/)
* @author Ryan Mueller http://creativenotice.com, @CreativeNotice
* @param String path The system path for the directory to search. Required.
* @param Numeric count Number of results to return.
* @param Boolean recurse Should we recurse into child directories? Default = FALSE Required.
* @param String listInfo How should we respond? query or array are you options. Default = 'query' Required.
@CreativeNotice
CreativeNotice / pulsar.js
Last active December 26, 2015 11:29
Simple function to pulsate element using jQuery animate.
/**
* pulsar
* @description Will change the element's opacity in a recursing manner.
* @param {Object} elm A DOM or jQuery element object
* @param {Object} options Options to override defaults, see var settings for those available
* @return {Void}
*
* @see jQuery.animate http://api.jquery.com/animate/
*/
var pulsar = function( elm, options ) {
@CreativeNotice
CreativeNotice / provinces_hash.json
Created October 28, 2013 21:16 — forked from mshafrir/states_hash.json
North American Regions
{
"AB": "Alberta",
"BC": "British Columbia",
"MB": "Manitoba",
"NB": "New Brunswick",
"NL": "Newfoundland and Labrador",
"NS": "Nova Scotia",
"ON": "Ontario",
"PE": "Prince Edward Island",
"QC": "Quebec",
@CreativeNotice
CreativeNotice / xmlToStruct
Last active August 29, 2015 14:01
Allows you to convert a cfml xml document into a structure.
/**
* @author Raymond Camden
* @see http://www.raymondcamden.com/index.cfm/2012/1/4/Converting-XML-to-JSON--My-exploration-into-madness
* @updated Ryan Mueller
* @hint Fixes some issues with the original code, though I don't remember what they were ;-)
* @returntype Struct
*/
public function xmlToStruct(xml x) {
var s = {};
@CreativeNotice
CreativeNotice / QueryToArrayOfStructures
Last active August 29, 2015 14:07
An update to Nathan Dintenfass' function at http://www.cflib.org/udf/QueryToArrayOfStructures. I've removed pre CF9 support to save a couple lines.
private array function QueryToArrayOfStructures( required query theQuery ){
var theArray = [];
var cols = ListtoArray(theQuery.columnlist);
for( var row=1; row <= theQuery.recordcount; row=row+1 ){
var thisRow = {};
for( var col=1; col <= arraylen(cols); col=col+1 ){
thisRow[cols[col]] = theQuery[cols[col]][row];
}
arrayAppend(theArray, thisRow);
}
@CreativeNotice
CreativeNotice / gist:9ebe66692320d2c6d053
Created October 24, 2014 16:20
Format US phone number.
public string function formatPhoneNumber(string phone){
var clean_number = Right( ReReplaceNoCase(arguments.phone, "[^\d]", "", "ALL"), 10);
if( Len(clean_number) == 10){
return '('& Left(clean_number,3) &') '& Mid(clean_number,4,3) &'-'& Right(clean_number,4);
}else{
throw('Phone number is to short.', 'InvalidArgument');
}
};