This is now an actual repo:
This file contains hidden or 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 elem(selector){ return document.querySelectorAll(selector); } | |
Object.defineProperties(NodeList.prototype, { | |
'each': { | |
value: function(fn){ | |
var self = this; | |
Array.prototype.slice.call(this, 0).forEach(function (){ | |
fn.apply(arguments[0], arguments); | |
}); | |
return self; | |
} |
This file contains hidden or 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
var Transition = (function (){ | |
var transitionEvent = (function whichTransitionEvent(){ | |
var t, el = document.createElement("fakeelement") | |
,transitions = { | |
"WebkitTransition": "webkitTransitionEnd", | |
"MozTransition": "transitionend", | |
"OTransition": "oTransitionEnd", | |
"transition": "transitionend" | |
}; | |
This file contains hidden or 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
var Animation = (function (){ | |
var animationEvent = (function whichAnimationEvent(){ | |
var t, el = document.createElement("fakeelement") | |
,animation = null | |
,animations = { | |
"WebkitAnimation": "webkitAnimationEnd", | |
"MozAnimation": "animationend", | |
"OAnimation": "oAnimationEnd", | |
"animation": "animationend" | |
}; |
This file contains hidden or 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
var Keyframe = (function (){ | |
var keyframePrefix = (function getKeyframePrefix(){ | |
var t, el = document.createElement("fakeelement") | |
,animations = { | |
"animation": "", | |
"OAnimation": "-o-", | |
"msAnimation": "-ms-", | |
"MozAnimation": "-moz-", | |
"WebkitAnimation": "-webkit-" | |
}; |
This file contains hidden or 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
var CSSRule = (function (){ | |
var prefix = (function getPropertiesPrefix(){ | |
var t, el = document.createElement("fakeelement") | |
,animations = { | |
"animation": "", | |
"OAnimation": "-o-", | |
"msAnimation": "-ms-", | |
"MozAnimation": "-moz-", | |
"WebkitAnimation": "-webkit-" | |
}; |
This file contains hidden or 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(){ | |
Object.defineProperties(document, { | |
"on": { | |
value: function(evName, callback, useCapture){ | |
return addEvent.call(this, evName, callback, useCapture); | |
} | |
} | |
}); | |
Object.defineProperties(window, { | |
"on": { |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
.images { | |
-webkit-column-count: 3; /* Chrome, Safari, Opera */ | |
-moz-column-count: 3; /* Firefox */ | |
column-count: 3; | |
} | |
.images img { width: 100%; } |
This file contains hidden or 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 MyConstructor(options){ | |
options = options || {}; | |
// Default properties: | |
options.__proto__ = { | |
threshold: 3, | |
quality: 1 | |
etc: "whatever" | |
}; | |
// Use case: |
This file contains hidden or 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
// Recursive Binary Search | |
// Array must be sorted in ascending order | |
Array.prototype.binarySearch = function(num, from, to) { | |
to = to || this.length-1; | |
from = from || 0; | |
if(!num || from > to) return null; | |
var index = Math.floor((to-from) / 2) + from; | |
if(num < this[index]) return this.binarySearch(num, from, index-1); |
OlderNewer