Skip to content

Instantly share code, notes, and snippets.

👮
this is the police

Mike Taylor miketaylr

👮
this is the police
Block or report user

Report or block miketaylr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View HTML5 input attribute core tests
attrTests: {
testAccept: function(_el) {
return !!(_el.accept === '') && !!(_el.accept !== 'undefined');
},
testAutocomplete: function(_el){
return !!(_el.autocomplete === '') && !!(_el.autocomplete !== 'undefined');
},
testAutofocus: function(_el){
View zIndex-bookmarklet.js
// find all elements with a z-index and indicate what they are.
function contrast(color){ return '#' +
(Number('0x'+color.substr(1)).toString(10) > 0xffffff/2 ? '000000' : 'ffffff');
}
jQuery('*')
.filter(function(){ return $(this).css('zIndex') !== 'auto'; })
.each(function(){
View Rails checkbox validation with jQuery validate plugin
//The jQuery validate plugin validates on the name attribute,
//which is problematic in Rails because every checkbox
//gets a hidden input with the same name.
//Here's how to validate the checkbox, not the hidden input:
var validate = function(){
$(':input:hidden').attr('name', 'new_name');
$('form').validate({
rules: {"checkbox": "required"},
messages: {"checkbox": "CHECK ME"},
View gist:244795
//bookmarklet to validate html5 docs using the experimental validator(.nu).
//adapted from http://tantek.com/favelets/
javascript:void(document.location='http://validator.nu/?doc='+escape(document.location)+'&parser=html5&profile=pedagogical&showsource=yes')
View jquery.benchmark.js
// based on methodology developed by PPK:
// http://www.quirksmode.org/blog/archives/2009/08/when_to_read_ou.html
(function($){
$.benchmark = function(times, result_selector, func){
var startTime = new Date().getTime();
while (times != 0){
func();
times--;
}
View Usage
$ spawn 3
# => open 5 new Terminal tabs, cd to the current directory
$ spawn 5 ~/Code/project-x
# => Open 5 new Terminal tabs, cd to ~/Code/project-x
View provide_html5.js
// 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() {
View gist:278231
<!--[if IE]>
<script>
(function(){var elems="abbr article aside audio canvas datalist details figure footer header hgroup mark menu meter nav output progress section time video".split(" ");for(i=elems.length+1;--i;)elem=doc.createElement(elems[i]);elem=null;})();
</script>
<![endif]-->
View gist:286515
/*
* Titan - Javascript Web Framework
* Version 1.1
* Copyright 2009 Valio, Inc.
*
* Visit the Titan website for more information and documentation:
* http://www.titanproject.org
*
* ---------------------------------------------------------------------------
*
View gist:296521
// 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])}})()
You can’t perform that action at this time.