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 fakeNodeData = { __fake: true }; | |
| sugiyamaService.insertFakeNodeBeforeNext = function(list, currentNode, nextNode) { | |
| var fakeNode = sugiyamaService.createNode(fakeNodeData); | |
| sugiyamaService.disconnectNodes(currentNode, nextNode); | |
| sugiyamaService.connectNodes(fakeNode, nextNode); | |
| sugiyamaService.connectNodes(currentNode, fakeNode); | |
| list.push(fakeNode); |
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 minimizeCrossingsArisingFromColumnAndRows = function(grid, columnIndex, rowIndex1, rowIndex2) { | |
| var originalNode1 = grid[columnIndex][rowIndex1]; | |
| var originalNode2 = grid[columnIndex][rowIndex2]; | |
| var nextColumn = grid[columnIndex + 1]; | |
| for (var nextNode1Index = 0; nextNode1Index < originalNode1.nextNodes.length; nextNode1Index++) { | |
| var nextNode1 = originalNode1.nextNodes[nextNode1Index]; | |
| var nextNode1Row = nextColumn.indexOf(nextNode1); | |
| for (var nextNode2Index = 0; nextNode2Index < originalNode2.nextNodes.length; nextNode2Index++) { |
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 unlinkFakeNode = function (fakeNode) { | |
| // fake node: remove and connect nodes that it is connecting | |
| var previousNodes = fakeNode.previousNodes.slice(0); // copy since it's going to be modified | |
| previousNodes.forEach(function (previousNode) { | |
| // previous --> next1, previous --> next2, etc | |
| fakeNode.nextNodes.forEach(function (nextNode) { | |
| sugiyamaService.connectNodes(previousNode, nextNode); | |
| }); | |
| // previous --X--> fake |
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 httpResponseQueue = Ember.A(); | |
| var checkQueueInterval = null; | |
| var checkQueue = function() { | |
| for (var i = 0; i < httpResponseQueue.length; i++) { | |
| var queuedItem = httpResponseQueue[i]; | |
| var found = fakehr.match(queuedItem.verb.toUpperCase(), queuedItem.url); | |
| if (found) { | |
| found.respond(queuedItem.status || 200, {'content-type': 'application/json'}, queuedItem.body); |
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
| fakehr.requests.filter(function (r) { | |
| return r.readyState != 4; | |
| }).map(function (r) { | |
| return r.method + ' ' + r.url | |
| }); |
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 MyController = function($scope, ApiService) { | |
| $scope.awesomeThings = ['everything']; // everything is awesome | |
| $scope.randomStuff = null; | |
| ApiService.getStuff('random').then(function(retrievedStuff) { | |
| $scope.randomStuff = retrievedStuff; | |
| }); | |
| }; | |
| angular.module('MyApp').controller('MyController', MyController); |
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
| describe('Testable controller', function() { | |
| beforeEach(module('MyApp')); | |
| it('should be testable against the controller logic', inject(function($controller, $rootScope, ApiService) { | |
| var $scope = $rootScope.new(); | |
| var controller = $controller('MyController', { $scope: $scope, ApiService: ApiService }); | |
| expect(controller.generateGreeting).toBeDefined(); | |
| var greeting = controller.generateGreeting(); | |
| expect(greeting).toBe('...'); |
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
| module('My application tests', { | |
| setup: function() { | |
| App = startApp(); | |
| }, | |
| teardown: function() { | |
| App.destroy(); | |
| } | |
| }); | |
| test('Click on next page button takes user to next page', function() { |
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 Date(); | |
| // => Thu Aug 28 2014 19:47:15 GMT-0500 (Central Daylight Time) | |
| tardis.travelToFuture(24 * 60 * 60 * 1000); | |
| new Date(); | |
| // => Fri Aug 29 2014 19:47:15 GMT-0500 (Central Daylight Time) | |
| tardis.travelToPast(60 * 60 * 1000); | |
| new Date(); | |
| // => Fri Aug 29 2014 18:47:15 GMT-0500 (Central Daylight Time) |
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 mongoose = require('mongoose'); | |
| var mongoFacets = require('../lib/mongo-facets'); | |
| var ExampleSchema = new mongoose.Schema({ | |
| stringField: String, | |
| numberField: Number, | |
| arrayOfStringsField: [String] | |
| }); | |
| mongoFacets('Example', ExampleSchema); |