Skip to content

Instantly share code, notes, and snippets.

View michaelfox's full-sized avatar
🦊

Michael Fox michaelfox

🦊
  • Kirschbaum Development Group
View GitHub Profile
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
function check_git_changes {
var=`git status 2> /dev/null | sed -e '/(working directory clean)$/!d' | wc -l`
if [ $var -ne 1 ]; then
tput setaf 1 # red
else
tput setaf 2 # green
fi
var foo = [1,2,3];
for(var i = 0; i < foo.length; i++){
(function(el, i){
})(foo[i], i, foo);
}
my.each = function(ar, fn, obj){
for(var i = 0; i < ar.length; i++){
fn.apply(obj || window, ar[i], i, ar);
// sorta like manual profiling.
// peek into your jquery method calls to see why they are being called so much
// usage:
// $.logCallsTo('append');
// $.logCallsTo('curCSS',true);
// output:
// http://gyazo.com/40cec25d875a7a767e95fd7a2f451b32.png
#!/bin/sh
# setup ------------------------------------------------------------------------
tempDir="/tmp/`whoami`/chrome-nightly/";
baseURL="http://build.chromium.org/buildbot/snapshots/chromium-rel-mac/";
baseName="chrome-mac";
baseExt="zip";
appName="Chromium.app";
appDir="/Applications";
version=~/.CURRENT_CHROME;
//EnhanceJS isIE test idea
//detect IE 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(){
var doc = document,
import urllib
print 'javascript:' + urllib.quote("""
(function(){
var e = document.createElement('script');
e.src='/boot.js';
e.type='text/javascript';
document.getElementsByTagName('body')[0].appendChild(e);})()
""".strip().replace('\n', ' '))
(function (undefined) {
function detectMutation() {
mutationSupported = true;
this.removeEventListener('DOMAttrModified', detectMutation, false);
}
var forEach = [].forEach,
regex = /^data-(.+)/,
el = document.createElement('div'),
mutationSupported = false,
// mousewheel normalization.
// taken from http://html5readiness.com/js/script.js - cheers paul!
$(document).bind('DOMMouseScroll mousewheel', function(e, delta) {
delta = delta || (e.detail && -e.detail/3) || (e.wheelDelta && e.wheelDelta/120);
});
// Idea from http://dbaron.org/log/20100424-any
jQuery.expr[':'].any = function(el, i, match) {
return jQuery.find.matches(match[3], [el]).length > 0;
};
jQuery('body :any(div, form) p'); // Same as jQuery('body div p, body form p')
jQuery('div:any(.foo,.bar)'); // Same as jQuery('div.foo, div.bar')
/*
* media.matchMedium()- test whether a CSS media type or media query applies
* primary author: Scott Jehl
* Copyright (c) 2010 Filament Group, Inc
* MIT license
* adapted by Paul Irish to use the matchMedium API
* http://www.w3.org/TR/cssom-view/#media
* Doesn't implement media.type as there's no way for crossbrowser property
* getters. instead of media.type == 'tv' just use media.matchMedium('tv')