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 gen = function *(count){ | |
console.log("gen called: ", count); | |
if (count < 20) | |
yield count; | |
else | |
yield *gen(count/2); | |
} | |
var g = gen(100); | |
do { | |
var n = g.next(); |
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 gen = function *(count){ | |
console.log("gen called: ", count); | |
if (count < 20) | |
yield count; | |
else | |
yield *gen(count/2); | |
} | |
var g = gen(100); | |
do { | |
var n = g.next(); |
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
if (typeof define === "function" && define.amd) this.d3 = d3, define(d3); else if (typeof module === "object" && module.exports) module.exports = d3; else this.d3 = d3; |
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
app.controller('MainCtrl', function($scope) { | |
$scope.clickedTimes = 0; | |
$scope.prop1 = 2+3; | |
// $scope.prop2 = 'scope_prop2'; | |
// $scope.aNumber = 44; | |
// $scope.obj = { prop1: "obj_prop1"} | |
$scope.changeProperties = function() { | |
$scope.prop1.prop1 = 'scope_prop1_changed after ' + ($scope.clickedTimes++) + ' clicks'; |
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
app.directive('outer', function(){ | |
return { | |
restrict: 'E', | |
controllerAs: 'outer', | |
require: 'outer', | |
template: '<p>{{outer.hello}}<p ng-transclude="outerInner"></p><p ng-transclude></p></p>', | |
scope: true, | |
transclude: { | |
outerInner: 'inner' | |
}, |
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 (root, factory) { | |
if (typeof define === 'function' && define.amd) { | |
define(['angular'], factory); | |
} else if (typeof exports === 'object') { | |
factory(require('angular')); | |
} else { | |
factory(root.angular); | |
} | |
}(this, function (angular) { | |
'use strict'; |
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 myApp = angular.module('myApp', []); | |
//service style, probably the simplest one | |
myApp.service('helloWorldFromService', function() { | |
this.sayHello = function() { | |
return "Hello, World!" | |
}; | |
}); | |
//factory style, more involved but more sophisticated |
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
#include <stdio.h> | |
#include <stdint.h> | |
class A { | |
public: | |
virtual void doThing() { | |
printf("I'm an A\n"); | |
} | |
}; |
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
// $ g++ -o test -framework Foundation -Wall test.mm | |
// $ ./test | |
// The string length is 12 | |
// The string third char value is 108 | |
// The string is Hello World! | |
#include <iostream> | |
#import <Foundation/Foundation.h> | |
class MyCppNSStringWrapper |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include "array_api.h" | |
// abstract array data type types | |
// opaque pointer: | |
// an ADT implementation hidden behind the interface that is abstract to | |
// the client, making it easier to maintain, apply changes and improve | |
// in this example the array_t data type provides a bunch of functins |