The popular open-source contract for web professionals by Stuff & Nonsense
- Originally published: 23rd December 2008
- Revised date: March 15th 2016
- Original post
SAVEIFS=$IFS | |
IFS=$(echo -en "\n\b") | |
# set me | |
FILES=/Volumes/DATA/Drive/*/ | |
for f in $FILES | |
do | |
chflags nohidden "$f" | |
done | |
# restore $IFS | |
IFS=$SAVEIFS |
if (!Array.from) { | |
console.log('adding polyfill for "Array.from"'); | |
Array.from = (function () { | |
var toStr = Object.prototype.toString; | |
var isCallable = function (fn) { | |
return typeof fn === 'function' || toStr.call(fn) === '[object Function]'; | |
}; | |
var toInteger = function (value) { | |
var number = Number(value); | |
if (isNaN(number)) { return 0; } |
Object.prototype.data = function (prop, val) { | |
var _return, | |
notIE = ( this.dataset !== undefined ); | |
return ( notIE )? // not IE | |
( typeof val === "undefined" ) ? // get data value | |
this.dataset[prop] : this.dataset[prop] = val | |
: // is IE | |
( typeof val === "undefined" ) ? // get data value | |
this.getAttribute('data-' + prop) : this.setAttribute('data-' + prop, val); |
/** | |
* Add dataset support to elements | |
* No globals, no overriding prototype with non-standard methods, | |
* handles CamelCase properly, attempts to use standard | |
* Object.defineProperty() (and Function bind()) methods, | |
* falls back to native implementation when existing | |
* Inspired by http://code.eligrey.com/html5/dataset/ | |
* (via https://github.com/adalgiso/html5-dataset/blob/master/html5-dataset.js ) | |
* Depends on Function.bind and Object.defineProperty/Object.getOwnPropertyDescriptor (polyfills below) | |
* All code below is Licensed under the X11/MIT License |
#301 Redirects for .htaccess | |
#Redirect a single page: | |
Redirect 301 /pagename.php http://www.domain.com/pagename.html | |
#Redirect an entire site: | |
Redirect 301 / http://www.domain.com/ | |
#Redirect an entire site to a sub folder | |
Redirect 301 / http://www.domain.com/subfolder/ |
/* | |
* Observer.js | |
* | |
* SYNTAX: | |
* const EventHandler = new MessageBus( context ); | |
* --- | |
* context: identifier for the event handler | |
* --- | |
* USAGE: | |
* var handler = new MessageBus( document ); |
(function(globals){ | |
// module name | |
const MODULE_NAME = 'moduleName'; | |
// define your functions here | |
const functions = { | |
fn1: alert, | |
fn2: console.log | |
}; | |
const PubSub = (() => { | |
const topics = {}; | |
const hOP = topics.hasOwnProperty; | |
return { | |
subscribe(topic, listener) { | |
// Create the topic's object if not yet created | |
if(!hOP.call(topics, topic)) topics[topic] = []; | |
// Add the listener to queue |
/* | |
* Array.shuffle | |
* | |
* Usage: | |
* const arr1 = [1, 2, 3, 4, 5]; | |
* const arr2 = Array.shuffle(arr1); | |
* const arr3 = arr1.shuffle(); | |
* | |
* @TODO: | |
* - Add callback functionality to Array.prototype.shuffle |