Skip to content

Instantly share code, notes, and snippets.

View miketaylr's full-sized avatar
🌭

Mike Taylor miketaylr

🌭
View GitHub Profile
// 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(){
@miketaylr
miketaylr / Usage
Created December 13, 2009 00:42 — forked from akahn/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
// 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() {
// 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])}})()
@miketaylr
miketaylr / README
Created February 10, 2010 00:21 — forked from sh1mmer/README
This script updates to Chromium nightly. You can run it manually, but I run it using cron.
If you run it using cron remember that it _will quit_ your running Chromium so make sure you have it set to save tabs if you want them.
In order to install it with cron run:
crontab -e
Add the line:
// Assumes jQ 1.4+
function preload(file) {
return jQuery('<link/>', {
href: file,
rel: 'stylesheet',
media: 'print',
load: function() {
jQuery(this).remove();
}
if (!window.localStorage || !window.sessionStorage) (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
(function (undefined) {
function detectMutation() {
mutationSupported = true;
this.removeEventListener('DOMAttrModified', detectMutation, false);
}
var forEach = [].forEach,
regex = /^data-(.+)/,
el = document.createElement('div'),
mutationSupported = false,
//detect Internet Explorer and version number through injected conditional comments (no UA detect, no need for cond. compilation / jscript check)
//version arg is for IE version (optional)
//comparison arg supports 'lte', 'gte', etc (optional)
var isIE = (function(undefined){
var doc = document,
doc_elem = doc.documentElement,
cache = {},
function benchmark(method, times, name){
//See http://gist.github.com/227048
var startTime = (new Date()).getTime(), endTime;
while(times--){
method();
}
endTime = (new Date()).getTime();
console.log(name, endTime - startTime);
}
var x = 1, y = 0;