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);
#!/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;
// 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
@eculver
eculver / MySQL select word count
Created February 22, 2010 20:02
MySQL select word count
SELECT SUM(LENGTH(name) - LENGTH(REPLACE(name, ' ', ''))+1) FROM table
// everyone's new favorite closure pattern:
(function(window,document,undefined){ ... })(this,this.document);
// when minified:
(function(w,d,u){ ... })(this,this.document);
// which means all uses of window/document/undefined inside the closure
// will be single-lettered, so big gains in minification.
// it also will speed up scope chain traversal a tiny tiny little bit.
//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);
});