This file contains hidden or 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
| # http://henrik.nyh.se/2008/12/git-dirty-prompt | |
| # http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/ | |
| # username@Machine ~/dev/dir[master]$ # clean working directory | |
| # username@Machine ~/dev/dir[master*]$ # dirty working directory | |
| function parse_git_dirty { | |
| [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
| } | |
| function parse_git_branch { | |
| git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" |
This file contains hidden or 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 wrap = function (fn, wrapper) { | |
| var params = [], len = fn.length; | |
| while (len--) { | |
| params[len] = 'a'+len; | |
| } | |
| return Function('fn,wrapper', | |
| 'return function ('+params+') {' + | |
| ' return wrapper.call(this, fn, [].slice.call(arguments));'+ | |
| '}')(fn, wrapper); |
This file contains hidden or 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
| /* V8 Engine internals using built-ins | |
| * | |
| * Bug report: | |
| * http://code.google.com/p/v8/issues/detail?id=1625 | |
| * Bug on code: | |
| * http://code.google.com/p/v8/source/browse/trunk/src/v8natives.js?r=8733#1026 | |
| * http://www.google.com/codesearch#W9JxUuHYyMg/trunk/src/v8natives.js&l=1026,1029 | |
| */ | |
| var _push = Array.prototype.push; |
This file contains hidden or 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
| if (typeof Function.prototype.bind != 'function') { | |
| Function.prototype.bind = (function () { | |
| var slice = Array.prototype.slice; | |
| return function (thisArg) { | |
| var target = this, boundArgs = slice.call(arguments, 1); | |
| if (typeof target != 'function') throw new TypeError(); | |
| function bound() { | |
| var args = boundArgs.concat(slice.call(arguments)); |
This file contains hidden or 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 isStrictFunction(fn) { | |
| if (typeof fn != 'function') throw "Not a function"; | |
| try { | |
| fn.caller, fn.arguments; | |
| return false; | |
| } catch (e) { | |
| return e instanceof TypeError; | |
| } | |
| } |
This file contains hidden or 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
| /* | |
| * List of ES3 Incompatibilities introduced by ES5. | |
| * | |
| */ | |
| /* | |
| * From Annex E: | |
| */ |
This file contains hidden or 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 sb = { | |
| Array: function() { | |
| var result = Array.apply(null, arguments); | |
| result.__proto__ = sb.Array.prototype; | |
| return result; | |
| } | |
| }; | |
| sb.Array.prototype = []; | |
| sb.Array.prototype.last = function () { return this[this.length -1]; }; |
This file contains hidden or 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
| Object.getPropertyNames || | |
| Object.defineProperty(Object, "getPropertyNames", { | |
| value: function(obj) { | |
| var propertyNames = []; | |
| do { | |
| propertyNames.push.apply(propertyNames, Object.getOwnPropertyNames(obj)); | |
| obj = Object.getPrototypeOf(obj); | |
| } while (obj); | |
| // get unique property names | |
| obj = {}; |
This file contains hidden or 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
| // WebKit strict mode bugs | |
| // Eval code should be "strict eval code" if the call to eval is a direct call (15.1.2.1.1) to | |
| // the eval function that is contained in strict mode code: | |
| (function () { | |
| "use strict"; | |
| return eval('(function() { return !this; })()'); | |
| })(); | |
This file contains hidden or 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
| if (typeof Array.isArray != 'function') { | |
| Array.isArray = (function () { | |
| var toString = Object.prototype.toString; | |
| return function (obj) { | |
| return toString.call(obj) == '[object Array]'; | |
| }; | |
| })(); | |
| } |