Skip to content

Instantly share code, notes, and snippets.

View remy's full-sized avatar
🐹
Always hacking

Remy Sharp remy

🐹
Always hacking
View GitHub Profile
@remy
remy / html5-data.js
Created April 10, 2010 15:45 — forked from fearphage/html5-data.js
data-* support
(function () {
var forEach = [].forEach,
regex = /^data-(.+)/,
dashChar = /\-([a-z])/ig,
el = document.createElement('div'),
mutationSupported = false,
match
;
function detectMutation() {
@remy
remy / gist:360018
Created April 8, 2010 12:07 — forked from padolsey/gist:360015
Get element from mouse position
var x,y;
document.onmousemove = function(e){
e = e || window.event;
x = e.clientX;
y = e.clientY;
};
function elementAtMousePosition() {
return document.elementFromPoint(x,y);
@remy
remy / gist:333954
Created March 16, 2010 13:21 — forked from madrobby/gist:333764
Beautiful one line array shuffle
// pure JS
function shuffle(array) {
return array.sort(function(){
return .5 - Math.random();
});
}
// with Prototype.js you can do
function shuffle(array){
return array.sortBy(Math.random);
@remy
remy / gist:296785
Created February 6, 2010 16:12 — forked from kangax/gist:296114
// original (http://html5shiv.googlecode.com/svn/trunk/html5.js)
(function(){if(!/*@cc_on!@*/0)return;var e = "abbr,article,aside,audio,canvas,datalist,details,figure,figcaption,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,summary,time,video".split(','),i=e.length;while(i--){document.createElement(e[i])}})()
// @rem version - 68 characters less, and much more maintainable than @pornelski - how do you like /them/ apples? :-)
// that said - change @pornelski's version so it uses spaces and it's easy maintainable, and still the shortest. /hattip to @pornelski
/*@cc_on(function(e){for(;e[0];document.createElement(e.pop())){}})('abbr article aside audio canvas details figure footer header hgroup mark menu meter nav output progress section time video'.split(' '))@*/
// Attempt to make a drop-and-forget bunch of scripts that mimick some missing html5 goodies automatically
// Example:
// $(document).ready(function() {
// ProvideHtml5.autofocus()
// ProvideHtml5.datepicker()
// ProvideHtml5.forcenumber()
// })
var ProvideHtml5 = {
autofocus = function() {
// Attempt to make a drop-and-forget bunch of scripts that mimick some missing html5 goodies automatically
// Example:
// $(document).ready(function() {
// ProvideHtml5.autofocus()
// ProvideHtml5.datepicker()
// ProvideHtml5.forcenumber()
// })
var ProvideHtml5 = {
autofocus = function() {
/*!
* jQuery ie6ize: Emulate IE-6 rendering - 11/13/2009
* http://mankzblog.wordpress.com/2009/11/13/ie6-frame-to-battle-chrome-frame/
*
* Created by Mats Bryntse
*
* Plugin-ified by "Cowboy" Ben Alman
* http://benalman.com/
*/