Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Tierney CFJSGeek

View GitHub Profile
@CFJSGeek
CFJSGeek / hideFileInput.htm
Created Aug 26, 2015
Use an element to get a file dialog and upload instead of a file input element
View hideFileInput.htm
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<body>
<style>
input {
@CFJSGeek
CFJSGeek / S3BucketPolicy.js
Created Aug 18, 2015
Amazon Web Services (AWS) S3 bucket policy to enforce encryption, SSL and IP access.
View S3BucketPolicy.js
{
"Version": "2012-10-17",
"Id": "BucketPolicy1",
"Statement": [
{
"Sid": "DenyUnEncryptedObjectUploads",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::myBucket/*",
@CFJSGeek
CFJSGeek / rebuildAllIndexes05-08.sql
Created Sep 9, 2015
Rebuild all indexes for a database on MS SQL 2005-2008
View rebuildAllIndexes05-08.sql
-- credit: http://blog.sqlauthority.com/2009/01/30/sql-server-2008-2005-rebuild-every-index-of-all-tables-of-database-rebuild-index-with-fillfactor/
DECLARE @TableName VARCHAR(255)
DECLARE @sql NVARCHAR(500)
DECLARE @fillfactor INT
SET @fillfactor = 80
DECLARE TableCursor CURSOR FOR
SELECT OBJECT_SCHEMA_NAME([object_id])+'.'+name AS TableName
FROM sys.tables
OPEN TableCursor
@CFJSGeek
CFJSGeek / queryToArray.cfc
Last active Sep 10, 2015
ColdFusion 10+ Query to Array of Stucts
View queryToArray.cfc
// convert a query to an array of structs
// credit: http://www.bennadel.com/blog/2367-coldfusion-10---looping-over-queries-using-a-for-in-loop-in-cfscript.htm
function queryToArray( required query query ){
var queryAsArray = [];
for (var row in query){
arrayAppend( queryAsArray, row );
}
return(queryAsArray);
}
@CFJSGeek
CFJSGeek / .htaccess
Created Sep 24, 2015
Require https for a specific domain, ignoring other domains that might use the same code base
View .htaccess
RewriteEngine on
RewriteBase /
#----- REQUIRE HTTPS for www.mysite.com -----
RewriteCond %{HTTP_HOST} ^www\.mysite\.com [NC]
RewriteCond %{HTTPS} !on
RewriteRule ^/?(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R]
@CFJSGeek
CFJSGeek / jQueryAnimateDone.js
Created Sep 30, 2015
wait for all jQuery animations to complete then make the newly expanded section can be seen in the viewport
View jQueryAnimateDone.js
$container = $('myElem');
$(":animated").promise().done( function() {
if( $container[0].getBoundingClientRect().top < 50 ) {
$('html,body').animate({scrollTop: $container.offset().top}, 800);
};
});
@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
@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 / 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 / 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);
You can’t perform that action at this time.