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
| route: function (route) { | |
| if (typeof this[route] === 'function') { | |
| // pass on any remaining arguments to route method | |
| var args = [].slice.call(arguments, 1); | |
| this[route].apply(this, args); | |
| } else { | |
| // some kind of error handling | |
| } | |
| } |
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('A hypothetical situation', function () { | |
| var View = Backbone.View.extend({ | |
| initialize: function () { | |
| this.model = new Backbone.Model; | |
| this.model.on('change', this.render, this); | |
| } | |
| }), instance; | |
| beforeEach(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
| git stash -q --keep-index | |
| if phantomjs ; then | |
| echo "Running Jasmine unit tests" | |
| if [ "$DEBUG" = "true" ] ; then | |
| phantomjs src/test/phantom.runner.js src/test/index.html 8080 true | |
| else | |
| phantomjs src/test/phantom.runner.js src/test/index.html 8080 false | |
| fi | |
| RESULT=$? | |
| else |
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 router = require('router.js'); | |
| app.route = function (path, map) { | |
| ['get', 'post', 'put', 'delete'].forEach(function (method) { | |
| if (typeof map[method] !== 'undefined') { | |
| app[method](path, map[method]); | |
| } | |
| }); | |
| } |
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 user = { | |
| name: 'Mike', | |
| points: 1 | |
| }; | |
| var ractive1 = new Ractive({ | |
| el: 'container', | |
| template: '#template', | |
| data: user | |
| }); |
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 Checkout = function Checkout(inventory) { | |
| inventory = inventory || []; | |
| this.basket = {}; | |
| this.inventory = {}; | |
| inventory.forEach(function (product) { | |
| this.inventory[product.code] = new Product(product); | |
| }.bind(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
| var vm = require('vm'); | |
| function checkArr(arr) { | |
| return arr instanceof Array; | |
| } | |
| var context = vm.createContext({ | |
| checkArr: checkArr, | |
| console: console | |
| }); |
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 Mocha = require('mocha'), | |
| expect = require('chai').expect; | |
| var mocha = new Mocha({ | |
| reporter: 'spec' | |
| }); | |
| var dashboards = Mocha.Suite.create(mocha.suite, 'dashboards'); | |
| var subsuite = Mocha.Suite.create(dashboards, 'something'); |
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
| [ | |
| { | |
| "userName": "alphagov", | |
| "repo": "datainsight-frontend" | |
| }, | |
| { | |
| "userName": "alphagov", | |
| "repo": "fourth-wall" | |
| }, | |
| { |
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
| /** | |
| Usage: `node domains.js --file <inputfile.csv> | |
| **/ | |
| var fs = require('fs'); | |
| var argh = require('argh').argv; | |
| var _ = require('underscore'); | |
| var input = argh.file; | |
| fs.readFile(input, function (err, filedata) { |