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
fs.stat('public/person/'+rez.doc._id, function(err, stats){ | |
console.log('stats: ' + JSON.stringify(stats)+'\n error: '+err); | |
if (err || !stats.isDirectory()) | |
console.log(stats.isDirectory()); | |
}); | |
>> stats: {"dev":51712,"ino":434027,"mode":16804,"nlink":2,"uid":0,"gid":0,"rdev":0,"size":4096,"blksize":4096,"blocks":8,"atime":"2011-07-21T21:26:18.000Z","mtime":"2011-07-21T21:26:18.000Z","ctime":"2011-07-21T21:26:18.000Z"} | |
error: null | |
TypeError: Cannot call method 'isDirectory' of undefined |
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
console.log(require("assert").ok( err || (stats && stats instanceof fs.Stats) )) | |
>> undefined for both cases | |
#### Case1 : if the dir does not exists: | |
fs.stat('public/person100000/'+rez.doc._id, function(err, stats){ | |
console.log('stats: ' + JSON.stringify(stats)+'\n error: '+err); | |
//console.log(stats.isDirectory()); this would throw an error | |
require("assert").ok( err || (stats && stats instanceof fs.Stats) ) |
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
fs.mkdir('public/bldgs/'+req.body._id, 777, function(e){console.log(e || 'written'); | |
fs.writeFile('public/bldgs/'+req.body._id+'/'+req.body._id+'.json', JSON.stringify(req.body), function(err){ | |
console.log(err || 'saved!'); | |
res.redirect('/'+req.params.code) | |
}) | |
}); |
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
// shortest distance to checking all relative distances | |
// because with an array of game objects, we don't need to check | |
// each object's distance to all other objects | |
// That would duplicate work (don't want to check one against another | |
// and the other against the one). So each one needs only be checked | |
// against objects to right of it | |
objects = [a,b,c,d,e,f,g] // each letter represents a game object (or comprises the object whole) ie {_id:"1234567", coord:[x,y], radius: 50} | |
function checkDistance(obj, target){ |
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 connect(dataset){ | |
(function dingdong (set, x){ | |
if(set == undefined){return} | |
else{ | |
db.connect({async: true},function(error) { | |
if (error) { | |
return console.log('CONNECTION error: ' + error); | |
} | |
this.query(). |
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
nhq:~ elenagragasin$ which npm | |
/Users/elenagragasin/local/node/bin/npm | |
nhq:~ elenagragasin$ which node | |
/usr/local/bin/node | |
NHQ:webdev elenagragasin$ npm --version | |
node.js:201 | |
throw e; // process.nextTick error, or 'error' event on first tick | |
^ |
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
> Object.prototype.toJSON = function(){return JSON.stringify(this)}; | |
> obj = {a:1}; | |
> obj.toJSON(); | |
// RangeError: Maximum call stack size exceeded |
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 DONE= 0; | |
var Sound; | |
var paths= ['./build/default/sound', './build/release/sound', 'sound']; | |
while (paths.length) { | |
var p= paths.pop(); | |
try { Sound= require(p) } catch (e) { continue } | |
console.log("Módulo de sonido encontrado en: '"+ p+ "'"); | |
break; | |
} |
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 audioLib = require('audiolib'), | |
fs = require('fs'), | |
dev, osc, rec, path; | |
var DONE= 0; | |
var Sound; | |
var paths= ['./build/default/sound', './build/release/sound', 'sound']; | |
while (paths.length) { | |
var p= paths.pop(); |
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 floatToSignedInteger() {'...'} | |
var buffer = audiolib.sink().rec().join() | |
var i = 0, len = buffer.length | |
do { | |
floatToSignedInteger(/* ??? */) | |
} | |
while { i < len} |