Skip to content

Instantly share code, notes, and snippets.

@alexbaulch
alexbaulch / clearfix.scss
Last active August 29, 2015 14:06
Sass clearfix mixin
@mixin clearfix {
&:after {
clear:both;
content:"";
display:table;
}
}
@alexbaulch
alexbaulch / debounce.js
Last active December 12, 2017 15:42
Vanilla JS Debounce CommonJS Module
/**
@module debounce
@param {function} func the function to be debounced
@param {int} wait the time to wait after event has stopped firing
@param {boolean} immediate whether to run the function immediately or wait for the timeout
*/
module.exports = function(func, wait, immediate) {
// create var to store the timeout in
var timeout;
@alexbaulch
alexbaulch / umd.js
Last active August 29, 2015 14:05
AMDify and CommonJSify your jQuery plugin! After spending ages trying to get a decent way to use jQuery plugins with Broswerify or RequireJS I found the following in Addy Osmani's UMD repo (https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js), completely hijacked, none of my own thinking or doing here but needed a way of finding thi…
// Uses CommonJS, AMD or browser globals to create a jQuery plugin.
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS
factory(require('jquery'));
} else {