This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT SUM(LENGTH(name) - LENGTH(REPLACE(name, ' ', ''))+1) FROM table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', ' ')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (undefined) { | |
function detectMutation() { | |
mutationSupported = true; | |
this.removeEventListener('DOMAttrModified', detectMutation, false); | |
} | |
var forEach = [].forEach, | |
regex = /^data-(.+)/, | |
el = document.createElement('div'), | |
mutationSupported = false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
}); | |
OlderNewer