Skip to content

Instantly share code, notes, and snippets.

View mstrickland22's full-sized avatar

mstrickland22

View GitHub Profile
@mstrickland22
mstrickland22 / Javascript utility funcs
Created September 25, 2012 14:21 — forked from davidvanvickle/Javascript utility funcs
Javascript utility funcs
/* Javascript utility funcs */
function valueInArray (val,arr) {
for (var i = 0; i < arr.length; i++) {
if (val==arr[i]) {
return true;
}
}
return false;
@mstrickland22
mstrickland22 / gist:3782269
Created September 25, 2012 14:29
JavaScript: Pub/Sub with JQuery
// Works in modern browsers + IE9, but Modernizr has a polyfill baked in for function.bind
var o = $( {} )
$.subscribe = o.on.bind(o)
$.unsubscribe = o.off.bind(o)
$.publish = o.trigger.bind(o)
@mstrickland22
mstrickland22 / jquery.pub-sub.js
Created September 25, 2012 14:35
JavaScript: Sexy Pub/Sub
(function ($) {
var o = $({})
$.each({
on: 'subscribe'
, trigger: 'publish'
, off: 'unsubscribe'
}, function (key, api) {
$[api] = function () {
@mstrickland22
mstrickland22 / jquery-plugin-amd.js
Created September 25, 2012 19:03
JavaScript: AMD jQuery Plugin Wrapper
// Uses AMD or browser globals to create a jQuery plugin.
// It does not try to register in a CommonJS environment since
// jQuery is not likely to run in those environments.
// See jqueryPluginCommonJs.js for that version.
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
@mstrickland22
mstrickland22 / gist:3796740
Created September 27, 2012 22:07
JavaScript - matchesSelector
matchesSelector = (function (doc) {
return doc.matchesSelector ||
doc.webkitMatchesSelector ||
doc.mozMatchesSelector ||
doc.oMatchesSelector ||
doc.msMatchesSelector
}(document.documentElement))
@mstrickland22
mstrickland22 / index.html
Created September 29, 2012 06:21
html5 boilerplate
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" contents="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title></title>
<!-- Application styles -->