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 sys = require('sys'); | |
| var Euler9 = function() { | |
| for(var a = 1; a < 1000; a++) { | |
| for(var b = a+1; b < 1000; b++) { | |
| c = Math.sqrt(Math.pow(a,2)+Math.pow(b,2)); | |
| if(c==Math.round(c)) { | |
| if(1000===a+b+c) { | |
| sys.puts(a*b*c); | |
| } | |
| } |
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 onclick(e) { | |
| var range; | |
| if (document.caretRangeFromPoint) { | |
| range = document.caretRangeFromPoint(e.pageX, e.pageY); | |
| } else if (e.rangeParent) { | |
| range = document.createRange(); | |
| range.setStart(e.rangeParent, e.rangeOffset); | |
| } | |
| var textContainer = range.startContainer; |
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 Stats(arr) { | |
| var self = this; | |
| var theArray = arr || []; | |
| //http://en.wikipedia.org/wiki/Mean#Arithmetic_mean_.28AM.29 | |
| self.getArithmeticMean = function() { | |
| var sum = 0, length = theArray.length; | |
| for(var i=0;i<length;i++) { | |
| sum += theArray[i]; | |
| } |
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 SimpleStats(optionalInputArray) { | |
| var self = this; | |
| var setSize = 0, | |
| arithmeticMean = 0, | |
| standardDeviation = 0, | |
| pwrSumAvg = 0; | |
| //http://en.wikipedia.org/wiki/Mean#Arithmetic_mean_.28AM.29 | |
| var setArithmeticMean = function(x) { |
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
| /** | |
| * First, better, "set exports/return" option | |
| */ | |
| (function (define) { | |
| //The 'id' is optional, but recommended if this is | |
| //a popular web library that is used mostly in | |
| //non-AMD/Node environments. However, if want | |
| //to make an anonymous module, remove the 'id' | |
| //below, and remove the id use in the define shim. | |
| define('id', function (require) { |
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
| /* | |
| smtpd.js is SMTP server written for node.js | |
| MIT License | |
| */ | |
| var tcp = require('tcp'); | |
| var sys = require('sys'); |
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
| define('utils/files/nameGenerator', function() { | |
| var count = 0; | |
| var lastId = 0; | |
| this.getName = function(ext) { | |
| var d = new Date; | |
| var f = d.getTime(); | |
| if(f == lastId) { | |
| count++; | |
| } 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
| require(['utils/files/nameGenerator'], function(filenameGenerator) { | |
| for(var i=0;i<100;i++) { | |
| console.log(filenameGenerator.getName('mp'+(i%2+2))); | |
| } | |
| }); | |
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
| define('SimplePromise', [], function() { | |
| var constructor = function() { | |
| _ = this; | |
| var theHandler = function(response) {}; | |
| var theFunction= function() {}; | |
| var theThis; | |
| this.then = function(fn, thisObject) { | |
| handler = fn; |
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
| require(['SimplePromise'], function(SimplePromise) { | |
| var p = SimplePromise(); | |
| p.promise(function(sleepTime) { | |
| //This function is called by the run call at the end of this file. | |
| var alarm, now = new Date(); | |
| var startingMSeconds = now.getTime(); | |
| var sleeping = true; | |
| while(sleeping){ | |
| alarm = new Date(); |