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 inverse(_A) { | |
| var temp, | |
| N = _A.length, | |
| E = []; | |
| for (var i = 0; i < N; i++) | |
| E[i] = []; | |
| for (i = 0; i < N; i++) | |
| for (var j = 0; j < N; j++) { |
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
| // myModule - is our global we want to export | |
| var root = this; | |
| if (typeof(exports) !== 'undefined') { | |
| if (typeof(module) !== 'undefined' && module.exports) { | |
| exports = module.exports = myModule; | |
| } | |
| exports.myModule = myModule; | |
| } else { | |
| if (typeof define === 'function' && define.amd) { |
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
| // new build | |
| { | |
| "cmd": ["node", "$file"], | |
| "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", | |
| "selector": "source.js" | |
| } | |
| //key bindings for build | |
| [ | |
| { "keys": ["ctrl+b"], "command": "build" }, | |
| { "keys": ["ctrl++alt+b"], "command": "exec", "args": {"kill": true} } |
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 Singleton() { | |
| var instance, | |
| that = this || {}; | |
| Singleton = function() { | |
| return instance; | |
| } | |
| Singleton.prototype = that; |
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
| // first don't forget to add node-webkit directory to PATH | |
| { | |
| "cmd": ["nw", "$file_path"], | |
| "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", | |
| "selector": "text.html" | |
| } |
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 Events = function() { | |
| var events = {}; | |
| return { | |
| on : function(event, callback) { | |
| events[event] = events[event] || []; | |
| events[event].push(callback); | |
| return this; | |
| }, | |
| off : function(event, callback) { |
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
| /** | |
| * Determine if point (x, y) is inside the polygon | |
| * @param {Integer} - x coord | |
| * @param {Integer} - y coord | |
| * @param {Array} - Array of vertices - {x:*, y:*} objects | |
| * @returns {Boolean} whether or not given point is inside the polygon | |
| */ | |
| function pointInPolygon(x, y, vertices) { | |
| var v = vertices, // less typing | |
| vx = v.map(function(vertice) { return vertice.x; }), |
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 toString = Object.prototype.toString, | |
| regexp = /\[object (.*?)\]/; | |
| function type(o) { | |
| var match = toString.call(o).match(regexp); | |
| return match[1].toLowerCase(); | |
| } |
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 getURLParams(url, includeEmptyValues) { | |
| return decodeURIComponent(url || window.location.search.slice(1)). | |
| replace(/.*\?/, '').split('&'). | |
| reduce((params, value) => { | |
| value = value.split('=') | |
| if (includeEmptyValues || typeof value[1] !== 'undefined') | |
| params[value[0]] = value[1]; | |
| return params; | |
| }, {}); | |
| } |
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
| class Decorator | |
| constructor: ({pre, post}) -> | |
| return (func) -> | |
| (args...) -> | |
| args = pre?(args...) or args | |
| ret = func(args...) | |
| post?(ret) or ret | |
| currency = new Decorator({post : (a) -> '$' + a}) |
OlderNewer