Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Tierney CFJSGeek

View GitHub Profile
@CFJSGeek
CFJSGeek / gist:5625001
Last active Dec 17, 2015
SQL: Insert if not updated #snippet
View gist:5625001
UPDATE Table1
SET (...)
WHERE Column1='SomeValue'
IF @@ROWCOUNT=0
INSERT INTO Table1
VALUES (...)
@CFJSGeek
CFJSGeek / sortObj.js
Last active Jul 22, 2020
JS: Sort a JavaScript object by key in alphabetical order case insensitive. Thanks to Arne Martin Aurlien and Ivan Krechetov for inspiration. #snippet
View sortObj.js
/**
* Sort JavaScript Object
* CF Webtools : Chris Tierney
* obj = object to sort
* order = 'asc' or 'desc'
*/
function sortObj( obj, order ) {
"use strict";
var key,
@CFJSGeek
CFJSGeek / Application Scope Dump.cfm
Created May 2, 2013
CF: Application Scope Dump #snippet
View Application Scope Dump.cfm
<cfset pageclass = "allapps">
<cfsetting requesttimeout="1000">
<br>
<cfparam name="url.sessdump" default="false">
<cfset Cfapp_list = createObject("java","coldfusion.runtime.ApplicationScopeTracker")>
<!--- <cfdump var="#CFAPP_list#"> --->
<cfset appIterator = CFAPP_list.getApplicationKeys() />
<cfset oSession = createObject("java","coldfusion.runtime.SessionTracker")>
@CFJSGeek
CFJSGeek / ColdFusionPowerShellSettings.ps1
Created May 1, 2013
Settings for ColdFusion Server to be started in the Windows PowerShell with custom sizes and colors
View ColdFusionPowerShellSettings.ps1
$pshost = get-host
$pswindow = $pshost.ui.rawui
$newsize = $pswindow.buffersize
$newsize.height = 3000
$newsize.width = 87
$pswindow.buffersize = $newsize
$newsize = $pswindow.windowsize
$newsize.height = 19
@CFJSGeek
CFJSGeek / Preferences.sublime-settings.json
Last active Dec 16, 2015
CFG: Sample Sublime Text 2 settings files that I use
View Preferences.sublime-settings.json
{
"color_scheme": "Packages/User/Espresso Soda.tmTheme",
"highlight_line": true,
"ignored_packages":
[
"Vintage"
],
"line_padding_bottom": 1,
"line_padding_top": 1,
"soda_classic_tabs": true,
@CFJSGeek
CFJSGeek / Application.cfc
Last active Mar 31, 2017
CF: Using "Access-Control-Allow-Origin" header in ColdFusion CFScript #snippet
View Application.cfc
component {
boolean function onRequestStart( required string targetPage ) {
var headers = getHttpRequestData().headers;
var origin = '';
var PC = getpagecontext().getresponse();
// Find the Origin of the request
if( structKeyExists( headers, 'Origin' ) ) {
@CFJSGeek
CFJSGeek / jQuerySelfInvokingAnonymousFunctionTemplate.js
Last active Dec 15, 2015
JS: jQuery Self-Invoking Anonymous Function Template #snippet
View jQuerySelfInvokingAnonymousFunctionTemplate.js
/*global $:false, jQuery:false */
(function($) {
"use strict";
$(document).ready(function() {
/* js code here */
});
})(jQuery);
@CFJSGeek
CFJSGeek / DI1Application.cfc
Last active Dec 15, 2015
CF: Application.cfc Example With DI/1 #snippet
View DI1Application.cfc
component {
this.name = hash( getCurrentTemplatePath() );
// Do not use datasource attribute in cfquery
this.datasource = "myDSN";
this.sessionManagement = true;
/**
* /model/beans/ contains transient CFC's
* All others are singleton CFC's
@CFJSGeek
CFJSGeek / GoogleCDNjQuery.htm
Last active Dec 15, 2015
JS: Google CDN hosted jQuery Base and jQuery UI with local backup #snippet
View GoogleCDNjQuery.htm
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/overcast/jquery-ui.min.css">
<!--- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline --->
<!--- Load the full jQuery version (ex 1.9.1 not 1.9) so it cached --->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
window.jQuery || document.write('<script src="/js/jquery-1.9.1.min.js"><\/script>');
</script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
@CFJSGeek
CFJSGeek / ComplexIdentityID.sql
Last active Dec 14, 2015
TSQL: Return Identity ID using complex UPDATE / INSERT statements #snippet
View ComplexIdentityID.sql
DECLARE @T TABLE (
cartID INT NOT NULL
)
UPDATE
UserCart
SET
dateModified = GETDATE(),
isGift = 1
OUTPUT
You can’t perform that action at this time.