Skip to content

Instantly share code, notes, and snippets.

View garystorey's full-sized avatar
:octocat:

Gary Storey garystorey

:octocat:
View GitHub Profile
@garystorey
garystorey / switch.js
Last active August 29, 2015 14:04
Switch replacement using object literals
function foo ( arg ) {
var bar = {
'test1': function () {
return 1;
},
'test2': function () {
return 2;
},
'test3': function () {
return 3;
@garystorey
garystorey / jqueryplugin.js
Last active August 29, 2015 14:03
Boilerplate jQuery Plugin - replace "Constructor" with constructor function name and replace "pluginName" with name of plugin
(function($, document, window, undefined) {
'use strict';
var Constructor = function( elm, options, id ) {
this.el = elm;
this.$el = $(elm);
this.init( options );
};
Constructor.prototype = {
# NPM CheatSheet.
# Super easy intall: npm comes with node now.
# To create your own npm package: https://www.npmjs.org/doc/misc/npm-developers.html
# More: https://www.npmjs.org/doc/
# 1. NPM Command Lines.
# Local mode is the default.
# Use --global or -g on any command to operate in global mode instead.
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
var s = document.createElement('link');
s.rel='stylesheet';
s.type='text/css';
s.href="http://stevenf.com/pages/shutup/shutup-latest.css";
document.body.appendChild(s);
void(0);
html {
font-size: 62.5%; /* 1 */
}
/*
html {
font-size: 62.5%;
}
body {
@garystorey
garystorey / youtube.js
Created November 1, 2013 17:45
read youtube playlist
var playListURL = 'http://gdata.youtube.com/feeds/api/playlists/PLauc615WzcQMaiQYhTLDKPh1pII5p-vU2?v=2&alt=json&callback=?';
var videoURL= 'http://www.youtube.com/watch?v=';
$.getJSON(playListURL, function(data) {
console.log(data);
var list_data="";
$.each(data.feed.entry, function(i, item) {
var feedTitle = item.title.$t;
var feedURL = item.link[1].href;
var fragments = feedURL.split("/");
var videoID = fragments[fragments.length - 2];
@garystorey
garystorey / thirdparty.js
Created October 28, 2013 21:35
Load 3rd party scripts async copied from https://gist.github.com/zenorocha/5161860
(function() {
var script,
scripts = document.getElementsByTagName('script')[0];
function load(url) {
script = document.createElement('script');
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);
@garystorey
garystorey / onoff.js
Created October 10, 2013 18:09
based on John Resig's event
function on(obj, type, fn) {
if (obj.attachEvent) {
obj['e'+type+fn] = fn;
obj[type+fn] = function(){ obj['e'+type+fn]( window.event ); };
obj.attachEvent( 'on'+type, obj[type+fn] );
} else {
obj.addEventListener( type, fn, false );
}
}
function off(obj, type, fn) {
@garystorey
garystorey / bootstrapsharepoint.less
Created October 10, 2013 15:52
Sharepoint 2010 updates for Bootstrap 3
/****************************************************************************
*
* This LESS file contains fixes to make Bootstrap 3 play nicely with
* SharePoint 2010 Publishing pages. It mainly switches SP2010's UI
* elements back to the "content-box" box-model.
*
* It also incorporates the CSS portions of Kyle Schaeffer's fixes for
* scrolling on SP2010. The JS part is called from the master page.
*
****************************************************************************/