Skip to content

Instantly share code, notes, and snippets.

View miketaylr's full-sized avatar
🌭

Mike Taylor miketaylr

🌭
View GitHub Profile
#!/bin/bash
# pre-commit hook to prevent html5 video or audio files from being checked
# into the repo. because large binary files in a git repo sucks. bad.
media_files=$(git diff --cached --name-only --diff-filter=ACR | \
egrep -i '\.(webm|mp4|ogg|mp3|ogv|m4v|avi|vp8|mov|oga|mp1|mp2|mpeg|3gp|wav)$')
if [[ "$media_files" ]]; then
echo 'Commit failed. Are you trying to check in media files into the repo?'
echo 'ARE YOU A TERRIBLE PERSON?'
// ==UserScript==
// @name UTM param stripper
// @author Paul Irish
// @namespace http://github.com/paulirish
// @description Drop the UTM params from a URL when the page loads.
// @extra Cuz you know they're all ugly n shit.
// @include http://*
// ==/UserScript==
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;
//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 (undefined) {
function detectMutation() {
mutationSupported = true;
this.removeEventListener('DOMAttrModified', detectMutation, false);
}
var forEach = [].forEach,
regex = /^data-(.+)/,
el = document.createElement('div'),
mutationSupported = false,
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();
// Assumes jQ 1.4+
function preload(file) {
return jQuery('<link/>', {
href: file,
rel: 'stylesheet',
media: 'print',
load: function() {
jQuery(this).remove();
}
@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:
// 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])}})()
// 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() {