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 Subject = function() { | |
| this.observers = []; | |
| return { | |
| subscribeObserver: function(observer) { | |
| this.observers.push(observer); | |
| }, | |
| unsubscribeObserver: function(observer) { | |
| var index = this.observers.indexOf(observer); | |
| if(index > -1) { |
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 items = ['one', 'two', 'three', 'four']; | |
| items.splice(items.length / 2, 0, 'hello'); |
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 debounce(func, wait, immediate) { | |
| var timeout; | |
| return function() { | |
| var context = this, args = arguments; | |
| var later = function() { | |
| timeout = null; | |
| if (!immediate) func.apply(context, args); | |
| }; | |
| var callNow = immediate && !timeout; | |
| clearTimeout(timeout); |
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 once(fn, context) { | |
| var result; | |
| return function() { | |
| if(fn) { | |
| result = fn.apply(context || this, arguments); | |
| fn = null; | |
| } | |
| return result; |
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
| import fs from 'fs' | |
| var output = fs.readFileSystem('example.txt', 'utf8') | |
| .trim() | |
| .split('\n') | |
| .map(line => line.split('\t')) | |
| .reduce((customers, line) => { | |
| customers[line[0]] = customers[line[0]] || [] | |
| customers[line[0]].push({ | |
| name: line[1], |
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
| const dog = () => { | |
| const sound = 'woof' | |
| return { | |
| talk: () => console.log(sound) | |
| } | |
| } | |
| const obj = dog(); | |
| obj.talk(); |
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
| const stream = { | |
| each: (callback) => { | |
| setTimeout(() => callback(1), 1000); | |
| setTimeout(() => callback(2), 2000); | |
| setTimeout(() => callback(3), 3000); | |
| } | |
| } | |
| createStream.each(console.log) |
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 (!file) { | |
| return $q.reject(false); | |
| } | |
| return $q(function (resolve, reject) { | |
| var reader = new FileReader(); | |
| reader.onloadend = function (response) { | |
| var src = response.target.result; | |
| var imgPromise = srcToDataURI(src); |
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 byteString; | |
| if (dataURI.split(',')[0].indexOf('base64') >= 0) | |
| byteString = atob(dataURI.split(',')[1]); | |
| else | |
| byteString = unescape(dataURI.split(',')[1]); | |
| // separate out the mime component | |
| var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; | |
| // write the bytes of the string to a typed array |
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(){ | |
| 'use strict'; | |
| var tau = Math.PI * 2; | |
| var width, height; | |
| var scene, camera, renderer, pointCloud; | |
| function onDocumentReady(){ | |
| initialize(); | |
OlderNewer