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 winningBoards = [ | |
| genWinningColBoard(0), | |
| genWinningColBoard(1), | |
| genWinningColBoard(2), | |
| genWinningRowBoard(0), | |
| genWinningRowBoard(1), | |
| genWinningRowBoard(2), | |
| getDiagonalBoard(3), | |
| getDiagonalBoard(3, 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 gup(name, url, defaultValue) { | |
| if (!url) url = location.href; | |
| name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); | |
| var regexS = "[\\?&]" + name + "=([^&#]*)"; | |
| var regex = new RegExp(regexS); | |
| var results = regex.exec(url); | |
| return (results == null ? null : results[1]) || defaultValue; | |
| } | |
| var id = gup('id', document.location.toString(), '50'); |
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 pick(collection, properties){ | |
| [].map.call(collection, function(val, key){ | |
| var result = {}; | |
| properties.forEach(copyProperty); | |
| return result; | |
| function copyProperty(propName){ result[propName] = val[propName]; } | |
| }) | |
| } |
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
| $provide.decorator('$exceptionHandler', [ | |
| '$delegate', '$window', '$log', '$stateParams', | |
| function($delegate, $window, $log, $stateParams) { | |
| return function(exception, cause) { | |
| if ($window.trackJs) { | |
| $log.debug('$exceptionHandler ::: $stateParams => ', angular.toJson($stateParams)); | |
| $window.trackJs.track(exception); | |
| } | |
| $delegate(exception, cause); | |
| }; |
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
| JSON.stringify((function(){ | |
| return Object.keys(window).filter(function(key) { | |
| try { | |
| var versionInfo = getVersionInfo(key) | |
| return versionInfo.version | |
| } catch (e) { | |
| return false | |
| } | |
| }).map(getVersionInfo) |
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 Game = { | |
| init: init, | |
| draw: draw | |
| } | |
| function init(name){ | |
| this.name = name; | |
| } | |
| function draw() { |
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 throttledPromiseObserver(callbacks, maxPending, checkInterval) { | |
| var remainingCalls = callbacks.length; | |
| var pendingCalls = 0; | |
| var callIdx = 0; | |
| var _checkInterval = checkInterval || 100; | |
| var _maxPending = maxPending || 0; | |
| return Rx.Observable.create(bufferedPromiseCalls); | |
| function bufferedPromiseCalls(observer) { |
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 clientSide = [ | |
| 'javascript', | |
| 'elm', | |
| 'ember', | |
| 'angular', | |
| 'jquery', | |
| 'backbone', | |
| 'react', | |
| 'reactjs', | |
| 'clojurescript', |
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 data = [{ | |
| id: 1, | |
| children: [{ | |
| id: 2, | |
| children: [{ | |
| id: 3, | |
| children: [{ | |
| id: 4, | |
| children: [] | |
| }] |
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 cache = {}; | |
| function checkCache(key){ | |
| if(cache[key]){ | |
| return cache[key]; | |
| } else { | |
| // do some long/expensive action | |
| // ex: calculation, ajax, etc... | |
| cache[key] = Math.random(); | |
| return cache[key]; | |
| } |