pete's notebooks

  • Immutables, ReactJS, and RxJS - /pete/react-observables-immutables
    Last edited 7 years ago
    First, let's go ahead and import all this nonesnse!
  • RxJS Behavior/Replay Example - /pete/rxjs-subject-examples
    Last edited 7 years ago
    The first example, you see a BehaviorSubject being used. BehaviorSubjects are useful in that you will always get a result on subscription. In order to mimic this in a ReplaySubject, you'd need to explicitly call onNext at least once, and set the buffer size to one.
  • Testing Reference vs Value - /pete/referencevsvalueinangularservices
    Last edited 7 years ago
    var someFunction = function() { var someArray = []; var addToArray = function(thing) { someArray.push(thing); } var addToArrayBroken = function(thing) { someArray = someArray.concat([thing]); } var getSomeArray = function() { return someArray; } return { addToArray: addToArray, addToArrayBroken: addToArrayBroken, someArray: someArray, getSomeArray: getSomeArray } } var someService;
  • Experimenting with natural language modules - /pete/pos-identification
    Last edited 7 years ago
    var pos = require("pos"); // Note; I don't think this library will currently work because it is large and // it looks like tonicdev has a restriction on size. var tagger = new pos.Tagger(); var output = { } var taggedWords = tagger.tag(new pos.Lexer().lex('I want a big apartment that is dog friendly')); for (var i in taggedWords) { var taggedWord = taggedWords[i]; var pos = taggedWord[1]; var word = taggedWord[0]; if (output[pos]) { output[pos].push(word); } else { output[pos] = [word]; } } output;
  • Big.js - /pete/bigjsfun
    Last edited 7 years ago
    var libphonenumber = require("libphonenumber") var Big = require("big.js"); Number(new Big(0.1).plus(0.2));