This file contains 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
_ = require 'underscore' | |
registry = require './registry.json' | |
console.log 'Existing packages: ' + Object.keys(registry).length | |
console.log 'Grouped by appType:' | |
groupedByAppType = _.groupBy registry, 'appType' | |
for k, v of groupedByAppType | |
console.log k, v.length |
This file contains 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
// View (a template) | |
<p>First name: <input data-bind=”value: firstName” /></p> | |
<p>Last name: <input data-bind=”value: lastName” /></p> | |
<h2>Hello, <span data-bind=”text: fullName”> </span>!</h2> | |
// ViewModel (diplay data… and logic?) | |
var ViewModel = function(first, last) { | |
this.firstName = ko.observable(first); | |
this.lastName = ko.observable(last); |
This file contains 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
// View (a template) | |
<div ng-controller=”HelloController as hello”> | |
<label>Name:</label> | |
<input type=”text” ng-model=”hello.firstName”> | |
<input type=”text” ng-model=”hello.lastName”> | |
<h1>Hello {{hello.fullName()}}!</h1> | |
</div> | |
// Controller | |
angular.module(‘helloApp’, []) |
This file contains 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 Hello = React.createClass({displayName: "Hello", | |
render: function() { | |
return React.createElement("div", null, "Hello ", this.props.name); | |
} | |
}); | |
React.render( | |
React.createElement(Hello, {name: "World"}), | |
document.getElementById('container') | |
); |
This file contains 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 Hello = React.createClass({ | |
render: function() { | |
return <div>Hello {this.props.name}</div>; | |
} | |
}); | |
React.render( | |
<Hello name=”World” />, | |
document.getElementById(‘container’) | |
); |
This file contains 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 CommentList = React.createClass({ | |
render: function() { | |
var commentNodes = this.props.data.map(function (comment) { | |
return ( | |
<Comment author={comment.author}> | |
{comment.text} | |
</Comment> | |
); | |
}); | |
return ( |
This file contains 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 array = [{name: "Foo", points: 1}, {name: "Bar", points: 3}]; | |
var increasePoints = function (player) { | |
player.points++; | |
}; | |
var i; | |
for (i = 0; i < array.length; i++) { | |
increasePoints(array[i]); | |
} |
This file contains 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 array = [{name: "Foo", points: 1}, {name: "Bar", points: 3}]; | |
var value, i; | |
for (i = 0; i < array.length; i++) { | |
value = array[i]; | |
value.points++; | |
} | |
console.log(array) // [{name: "Foo", points: 2}, {name: "Bar", points: 4}] |
This file contains 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 array = [{name: "Foo", points: 1}, {name: "Bar", points: 3}]; | |
var increasePoints = function (player) { | |
player.points++; | |
}; | |
_.each(array, increasePoints); // MAGIC! |
This file contains 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 array = [{name: "Foo", points: 1}, {name: "Bar", points: 3}]; | |
var increasePoints = function (player) { | |
return {name: player.name, points: player.points + 1}; | |
}; | |
var newArray = []; | |
_.each(array, function (player) { | |
newArray.push(increasePoints(player)); | |
}); | |
// array is undisturbed! a little clunky, though... |
OlderNewer