This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"forEach,map,filter,reduce,reduceRight,every,some".split(",").forEach(function(p) { | |
NodeList.prototype[p] = HTMLCollection.prototype[p] = Array.prototype[p] | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function xpath(el) { | |
if (typeof el == "string") return document.evaluate(el, document, null, 0, null) | |
if (!el || el.nodeType != 1) return '' | |
if (el.id) return "//*[@id='" + el.id + "']" | |
var sames = [].filter.call(el.parentNode.children, function (x) { return x.tagName == el.tagName }) | |
return xpath(el.parentNode) + '/' + el.tagName.toLowerCase() + (sames.length > 1 ? '['+([].indexOf.call(sames, el)+1)+']' : '') | |
} | |
// Usage: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# Usage 1: | |
# optimize-images.sh /images/dir | |
# | |
# Usage 2: | |
# cd /images/dir | |
# optimize-images.sh | |
EXTENSIONS="jpe?g" |