Skip to content

Instantly share code, notes, and snippets.

@bgaze
bgaze / gulp-pipable.js
Last active March 17, 2019 18:36
Gulp pipable function template
// Install and import through2
// npm install --save-dev through2
const through = require('through2');
// Declare the function
var myfn = function () {
return through.obj(function (input, encoding, callback) {
// Get current stream content.
let content = String(input.contents);
@bgaze
bgaze / umd-pattern.js
Created March 17, 2019 18:55
Javascript Universal Module Definition pattern
(function (root, factory) {
if (typeof define === "function" && define.amd) {
define(["jquery"], function (jQuery) {
return (root.myfn = factory(jQuery));
});
} else if (typeof module === "object" && module.exports) {
module.exports = (root.myfn = factory(require("jquery")));
} else {
root.myfn = factory(root.jQuery);
}
@bgaze
bgaze / bash-aliases
Last active March 15, 2021 06:02
A collection of console dev helpers
################################################################################
# INSTALLATION #
# #
# Simply save this file somewhere on your computer then import it into #
# your "~/.bashrc" file : #
# #
# if [ -f ~/path/to/bash-aliases ]; then #
# . ~/path/to/bash-aliases #
# fi #
# #
@bgaze
bgaze / vanilla-js-window-size.js
Last active September 2, 2019 10:47 — forked from joshcarr/window-height-width.js
[Vanilla JS] Get window dimensions
const windowSize = () => {
let body = document.getElementsByTagName('body')[0];
return {
width: window.innerWidth || document.documentElement.clientWidth || body.clientWidth,
height: window.innerHeight || document.documentElement.clientHeight || body.clientHeight
};
};