trainAndTest.trainAndTest_async(classifiers[_.values(classifierList)[2]], bars.copyobj(sim_train3), bars.copyobj(testset), function(err, stats3){
                        console.log("DEBUGSIMDIST: Simualte dist for the third run:"+JSON.stringify(bars.getDist(sim_train3)))
                               
				    	extractGlobal(_.values(classifierList)[2], mytrain, fold, stats3['stats'], glob_stats, classifierList)

				    	var results4 = bars.simulateds(buffer_train4, mytrainset.length - sim_train4.length, gold, 0)
						buffer_train4 = results4["dataset"]
				    	sim_train4 = sim_train4.concat(results4["simulated"])
				 
				    	trainAndTest.trainAndTest_async(classifiers[_.values(classifierList)[3]], bars.copyobj(sim_train4), bars.copyobj(testset), function(err, stats4){
                        
                        	console.log("DEBUGSIMDIST: Simualte dist 1st:"+JSON.stringify(bars.getDist(sim_train1)))
							console.log("DEBUGSIMDIST: Simualte dist 2st:"+JSON.stringify(bars.getDist(sim_train2)))
							console.log("DEBUGSIMDIST: Simualte dist 3st:"+JSON.stringify(bars.getDist(sim_train3)))
							console.log("DEBUGSIMDIST: Simualte dist 4st:"+JSON.stringify(bars.getDist(sim_train4)))

				    		extractGlobal(_.values(classifierList)[3], mytrain, fold, stats4['stats'], glob_stats, classifierList)

							_.each(glob_stats, function(data, param, list){
								master.plotlc(fold, param, glob_stats)
								console.log("DEBUGLC: param "+param+" fold "+fold+" build")
								master.plotlc('average', param, glob_stats)
							})

							callback_while();
						})
					})
	    	trainAndTest.trainAndTest_async(classifiers[_.values(classifierList)[0]], bars.copyobj(mytrainset), bars.copyobj(testset), function(err, stats1){

			    extractGlobal(_.values(classifierList)[0], mytrain, fold, stats1['stats'], glob_stats, classifierList)
			    console.log(_.values(classifierList)[0])
			    console.log(JSON.stringify(stats1['stats'], null, 4))

			    bars.generateoppositeversion2(JSON.parse(JSON.stringify(mytrainset)), function(err, sim_train1){

			    	console.log("DEBUGGEN: size of the strandard train" + mytrainset.length + " and generated "+ sim_train1.length)

			    	trainAndTest.trainAndTest_async(classifiers[_.values(classifierList)[1]], bars.copyobj(sim_train1), bars.copyobj(testset), function(err, stats2){

					    extractGlobal(_.values(classifierList)[1], mytrain, fold, stats2['stats'], glob_stats, classifierList)
			    		    console.log(_.values(classifierList)[1])
					    console.log(JSON.stringify(stats2['stats'], null, 4))

			    		_.each(glob_stats, function(data, param, list){
							master.plotlc(fold, param, glob_stats)
							console.log("DEBUGLC: param "+param+" fold "+fold+" build")
							master.plotlc('average', param, glob_stats)
						})

						callback_while();
			    	})
			    })
			})
module.exports = function (config, callback) {
    if (!intf) {
        return callback(false);
    }

    function addIp(ip, callback) {
        con.info('Adding local IP ' + ip + ' for forwards; if asked for password, give your local (sudo) password.');
        var ifconfig = pspawn('sudo', ['ifconfig', intf, 'add', ip]);
        ifconfig.on('exit', callback);
    }

    function addMissingIps(exitCode) {
        if (exitCode === 0 && missing.length > 0) {
            addIp(missing.shift(), addMissingIps);
        } else {
            callback(exitCode === 0);
        }
    }

    var allForwards = _.flatten(_.values(config.forwards).concat(_.values(config.localForwards)));
    var ips = [];
    allForwards.forEach(function (f) {
        var m = f.from.match(/^([0-9.]+):/);
        ips.push(m[1]);
    });
    ips = _.uniq(ips);

    var currentIps = _.pluck(os.networkInterfaces()[intf], 'address');
    var missing = _.difference(ips, currentIps);

    // Add any missing IP:s and finally call the callback.

    addMissingIps(0);
};
			    	trainAndTest.trainAndTest_async(classifiers[_.values(classifierList)[1]], bars.copyobj(sim_train1), bars.copyobj(testset), function(err, stats2){

					    extractGlobal(_.values(classifierList)[1], mytrain, fold, stats2['stats'], glob_stats, classifierList)
			    		    console.log(_.values(classifierList)[1])
					    console.log(JSON.stringify(stats2['stats'], null, 4))

			    		_.each(glob_stats, function(data, param, list){
							master.plotlc(fold, param, glob_stats)
							console.log("DEBUGLC: param "+param+" fold "+fold+" build")
							master.plotlc('average', param, glob_stats)
						})

						callback_while();
			    	})
Example #5
0
 _.toArray = function(iterable) {
   if (!iterable)                return [];
   if (iterable.toArray)         return iterable.toArray();
   if (_.isArray(iterable))      return slice.call(iterable);
   if (_.isArguments(iterable))  return slice.call(iterable);
   return _.values(iterable);
 };
Example #6
0
DB.prototype.stream = function () {
  //we expect sql, options, params and a callback
  var args = ArgTypes.queryArgs(arguments);

  //check to see if the params are an array, which they need to be
  //for the pg module
  if(_.isObject(args.params)){
    //we only need the values from the object,
    //so swap it out
    args.params = _.values(args.params);
  }

  //weird param bug that will mess up multiple statements
  //with the pg_node driver
  if(args.params === [{}]) args.params = [];

  pg.connect(this.connectionString, function (err, db, done) {
    //throw if there's a connection error
    assert.ok(err === null, err);

    var query = new QueryStream(args.sql, args.params);

    var stream = db.query(query);

    stream.on('end', done);

    args.next(null, stream);
  });
};
Example #7
0
exports.addDependency = function (parent, name, range, sources, packages, cb) {
    debugger;
    if (!packages[name]) {
        packages[name] = exports.createPackage(sources);
    }
    var dep = packages[name];
    var curr = dep.current_version;
    dep.ranges[parent || '_root'] = range;

    if (!curr || !versions.satisfiesAll(curr, Object.keys(dep.ranges))) {
        var available = Object.keys(dep.versions);
        var ranges = _.values(dep.ranges);
        var match = versions.maxSatisfying(available, ranges);

        if (match) {
            dep.current_version = match;
            exports.extend(dep.versions[match], sources, packages, cb);
        }
        else {
            return exports.updateDep(name, dep, function (err) {
                if (err) {
                    return cb(err);
                }
                // re-run iterator with original args now there are
                // new versions available
                return exports.addDependency(
                    parent, name, range, sources, packages, cb
                );
            });
        }
    }
};
function endGame(notifyPlayers) {

	util.log("Ending game...");

	// tell players the game has ended
	if(notifyPlayers) {
		io.sockets.emit("game over", {score: score, players: players});
	}

	// set game over
	gameInProgress = false;

	// reset all player variables
	_.each(_.values(players), function(player) {
		player.team = "";
		player.carryingFlag = false;
		player.tags = 0;
		player.timesTagged = 0;
		player.flagCaps = 0;
		player.flagReturns = 0;
		player.jailReleases = 0;
	});

	// reset the score
	score = {};

	// update the waiting message
	updateWaitingMessage();

}
Example #9
0
function optToFn() {
  var
    map = cmd === 'seek' ? POS_abbr : POS,
    fns = _.reject(map, function(fn, opt) { return !program[opt] });
  if (!fns.length && cmd === 'rand') return fns = ['']; // run rand()
  if (!fns.length) fns = _.values(map); //default to all if no POS given
  return fns;
}
Example #10
0
function randomize(deck) {
  var i;
  deck = _.values(deck);
  for (i = Math.floor(Math.random() * 400 + 10); i > 0; i = -1) {
    deck = _.shuffle(deck);
  }
  return deck;
}
Example #11
0
	    			trainAndTest.trainAndTest_async(classifiers[_.values(classifierList)[1]], bars.copyobj(sim_train2), bars.copyobj(testset), function(err, stats2){

		    			console.log("DEBUGSIM:"+results2["simulated"].length+" size of the simulated train")
						console.log("DEBUGSIMDIST: Simualte dist for the second run:"+JSON.stringify(bars.getDist(sim_train2)))
						console.log("DEBUGSIM: Results for the second run "+ JSON.stringify(stats2['stats'], null, 4))

			    		extractGlobal(_.values(classifierList)[1], mytrain, fold, stats2['stats'], glob_stats, classifierList)	
					    		

						console.log("DEBUGSIM: before results3")
			    		var results3 = bars.simulateds(buffer_train3, mytrainset.length - sim_train3.length, gold, 0.03125)
						console.log("DEBUGSIM: after results3")
						buffer_train3 = results3["dataset"]
				    	sim_train3 = sim_train3.concat(results3["simulated"])

				    	console.log("DEBUGSIM: size of aggregated simulated after plus "+ sim_train3.length + " in utterances "+_.flatten(sim_train3).length)
	
				    	trainAndTest.trainAndTest_async(classifiers[_.values(classifierList)[2]], bars.copyobj(sim_train3), bars.copyobj(testset), function(err, stats3){
                        console.log("DEBUGSIMDIST: Simualte dist for the third run:"+JSON.stringify(bars.getDist(sim_train3)))
                               
				    	extractGlobal(_.values(classifierList)[2], mytrain, fold, stats3['stats'], glob_stats, classifierList)

				    	var results4 = bars.simulateds(buffer_train4, mytrainset.length - sim_train4.length, gold, 0)
						buffer_train4 = results4["dataset"]
				    	sim_train4 = sim_train4.concat(results4["simulated"])
				 
				    	trainAndTest.trainAndTest_async(classifiers[_.values(classifierList)[3]], bars.copyobj(sim_train4), bars.copyobj(testset), function(err, stats4){
                        
                        	console.log("DEBUGSIMDIST: Simualte dist 1st:"+JSON.stringify(bars.getDist(sim_train1)))
							console.log("DEBUGSIMDIST: Simualte dist 2st:"+JSON.stringify(bars.getDist(sim_train2)))
							console.log("DEBUGSIMDIST: Simualte dist 3st:"+JSON.stringify(bars.getDist(sim_train3)))
							console.log("DEBUGSIMDIST: Simualte dist 4st:"+JSON.stringify(bars.getDist(sim_train4)))

				    		extractGlobal(_.values(classifierList)[3], mytrain, fold, stats4['stats'], glob_stats, classifierList)

							_.each(glob_stats, function(data, param, list){
								master.plotlc(fold, param, glob_stats)
								console.log("DEBUGLC: param "+param+" fold "+fold+" build")
								master.plotlc('average', param, glob_stats)
							})

							callback_while();
						})
					})
				})
// New socket connection
function onSocketConnection(client) {
	util.log("New player has connected: "+client.id);

	// Pass client ID back to client
	client.emit("id assignment", {id: client.id});

	// Send existing players to the new player
	var existingPlayer;
	_.each(_.values(players), function(thisPlayer) {
		client.emit("new player", {id: thisPlayer.id, name: thisPlayer.username, team: thisPlayer.team});
	});

	// if there is already a game in progress, notify the client
	if(gameInProgress) { client.emit("game in progress"); }

	// otherwise, add this player to the inactive players array
	else {
		inactivePlayers[client.id] = true;
	}

	// Listen for client disconnected
	client.on("disconnect", onClientDisconnect);

	// Listen for new player message
	client.on("new player", onNewPlayer);

	// Listen for team assignment requests
	client.on("team assignment", onTeamAssignment);

	// Listen for new chat messages
	client.on("chat msg", onChatMsg);

	// Listen for player movement
	client.on("move", onMove);

	// Listen for tags
	client.on("tag", onTag);

	// Listen for flag reset
	client.on("flag reset", flagReset);

	// Listen for flag pick up
	client.on("flag pick up", flagPickUp);

	// Listen for jail release
	client.on("jail release", jailRelease);

	// Listen for jail release countdown
	client.on("start jail countdown", startJailCountdown);

	// Listen for increment score
	client.on("increment score", incScore);

	// Listen for inc jail release
	client.on("inc jail release", incJailRelease);

}
Example #13
0
DB.prototype.query = function () {
  //we expect sql, options, params and a callback
  var args = ArgTypes.queryArgs(arguments);
  var e = new Error();  // initialize error object before we do any async stuff to get a useful stacktrace

  //check to see if the params are an array, which they need to be
  //for the pg module
  if(_.isObject(args.params)){
    //we only need the values from the object,
    //so swap it out
    args.params = _.values(args.params);
  }

  //weird param bug that will mess up multiple statements
  //with the pg_node driver
  if(args.params === [{}]) args.params = [];

  pg.connect(this.connectionString, function (err, db, done) {
    //throw if there's a connection error
    //assert.ok(err === null, err);
    if(err){
      done();
      args.next(err,null);
    }else{
      db.query(args.sql, args.params, function (err, result) {
        //we have the results, release the connection
        done();

        if (err) {
          //DO NOT THROW if there's a query error
          //bubble it up
          //handle if it's that annoying parameter issue
          //wish I could find a way to deal with this
          if (err.toString().indexOf("there is no parameter") > -1) {
            e.message = "You need to wrap your parameter into an array";
          } else {
            e.message = err.message || err.toString();
            e.code = err.code;
            e.detail = err.detail;
          }

          args.next(e, null);
        } else {
          //only return one result if single is sent in
          if (args.options.single) {
            result.rows = result.rows.length >= 0 ? result.rows[0] : null;
          }

          args.next(null, result.rows);
        }
      });
    }
  });
};
Example #14
0
function output(results) {
  var str;
  if (program.count && cmd != 'lookup') {
    var label = program.brief ? '' : _.flatten(['#', _.values(POS), 'Parsed\n']).join(' ');
    str = (cmd == 'get' && (label + _.reduce(POS, function(memo, v){
      return memo + ((results[v] && results[v].length) || 0) +" ";
    },''))) + nWords;
  } else {
    str = sprint(results);
  }
  console.log(str);
}
Example #15
0
  insertQuery: function (tableName, attrValueHash) {
    var query = "INSERT INTO <%= table %> (<%= attributes %>) VALUES (<%= values %>);"

    var replacements  = {
      table: helper.addTicks(tableName),
      attributes: _.keys(attrValueHash).map(function (attr) {return helper.addTicks(attr)}).join(","),
      values: _.values(attrValueHash).map(function (value) {
        return helper.escape((value instanceof Date) ? helper.toSqlDate(value) : value)
      }).join(",")
    }

    return _.template(query)(replacements)
  },
    		function (callback_while) {

			console.log("INDEX "+index)

    		var mytrain = data['train'].slice(0, index)
    		    	
    		if (index<10)
       		{
           		index += 1
       		} 
    		else if (index<20)
			{
               	index += 2
           	}
       		else index += 10

           	var mytrainset = JSON.parse(JSON.stringify((bars.isDialogue(mytrain) ? _.flatten(mytrain) : mytrain)))

           	// filter train to contain only single label utterances
           	// var mytrainset = _.filter(mytrainset, function(num){ return num.output.length == 1 })

	    	trainAndTest.trainAndTest_async(classifiers[_.values(classifierList)[0]], bars.copyobj(mytrainset), bars.copyobj(testset), function(err, stats1){

			    extractGlobal(_.values(classifierList)[0], mytrain, fold, stats1['stats'], glob_stats, classifierList)
			    console.log(_.values(classifierList)[0])
			    console.log(JSON.stringify(stats1['stats'], null, 4))

			    bars.generateoppositeversion2(JSON.parse(JSON.stringify(mytrainset)), function(err, sim_train1){

			    	console.log("DEBUGGEN: size of the strandard train" + mytrainset.length + " and generated "+ sim_train1.length)

			    	trainAndTest.trainAndTest_async(classifiers[_.values(classifierList)[1]], bars.copyobj(sim_train1), bars.copyobj(testset), function(err, stats2){

					    extractGlobal(_.values(classifierList)[1], mytrain, fold, stats2['stats'], glob_stats, classifierList)
			    		    console.log(_.values(classifierList)[1])
					    console.log(JSON.stringify(stats2['stats'], null, 4))

			    		_.each(glob_stats, function(data, param, list){
							master.plotlc(fold, param, glob_stats)
							console.log("DEBUGLC: param "+param+" fold "+fold+" build")
							master.plotlc('average', param, glob_stats)
						})

						callback_while();
			    	})
			    })
			})
    	},
Example #17
0
				    	trainAndTest.trainAndTest_async(classifiers[_.values(classifierList)[3]], bars.copyobj(sim_train4), bars.copyobj(testset), function(err, stats4){
                        
                        	console.log("DEBUGSIMDIST: Simualte dist 1st:"+JSON.stringify(bars.getDist(sim_train1)))
							console.log("DEBUGSIMDIST: Simualte dist 2st:"+JSON.stringify(bars.getDist(sim_train2)))
							console.log("DEBUGSIMDIST: Simualte dist 3st:"+JSON.stringify(bars.getDist(sim_train3)))
							console.log("DEBUGSIMDIST: Simualte dist 4st:"+JSON.stringify(bars.getDist(sim_train4)))

				    		extractGlobal(_.values(classifierList)[3], mytrain, fold, stats4['stats'], glob_stats, classifierList)

							_.each(glob_stats, function(data, param, list){
								master.plotlc(fold, param, glob_stats)
								console.log("DEBUGLC: param "+param+" fold "+fold+" build")
								master.plotlc('average', param, glob_stats)
							})

							callback_while();
						})
Example #18
0
  shuffle: function (count) {
    var deck, groups, parts = [];

    deck = randomize(_.clone(initialDeck));

    groups = _.groupBy(deck, function (value, index) {
      return index % count;
    });

    _.each(_.values(groups), function (group) {
      var split = _.map(group, function (value) {
        return value.id;
      });
      parts.push(split);
    });

    return parts;
  },
function flagReset(data) {

	// increment this player's flag releases
	var player = players[this.id];
	if(player && player.team === data.team) {
		players[this.id].flagReturns++;
	}

	// notify all other clients that flag reset occurred
	io.sockets.emit("flag reset", {team: data.team, id: this.id});

	// set all players on the reset team to no longer be carrying the flag
	_.each(_.values(players), function(thisPlayer) {
		if(thisPlayer.team === data.team) {
			thisPlayer.carryingFlag = false;
		}
	});

}
Example #20
0
 collectInitialData(eventId, function(err, result) {
     var zapTotal = 0
     , users = {};
     result.zaps.forEach(function(zap) {
         zapTotal += zap.count;
         users[zap.author._id] = zap.author;
     });
     result.messages.forEach(function(msg) {
         users[msg.author._id] = msg.author;
     });
     users = _.values(users);
     res.render('result', {
         event: result.event.toObject({getters: true}),
         zaps: result.zaps,
         messages: result.messages,
         zapTotal: zapTotal,
         users: users
     });
 }, true);
var init=function init(opts, transports){
  console.log('Generic Driver Init');

  var shorts={'i':'insert','u':'update','d':'delete','t':'truncate'};

  //Make opts.addflds an object array in case it is a pure object
  //{description:'varchar(100)'} ==> [{name:'description', type:'varchar(100)'}]
  if (opts.addflds){
    if (_.isObject(opts.addflds) && !_.isArray(opts.addflds)){
      var addflds=[];
      _.each(opts.addflds, function(type,name){
        addflds.push({name:name, type:type});
      });
      opts.addflds=addflds;
    }
  }

  //Dynamic Method Init
  var method=require('../methods/'+opts.driver+'-'+opts.method+'-method').init(opts);
  _.each(_.values(shorts), function(op){
    method.on(op, function(rows){
      // console.log('generic-driver method.on('+op+')');
      if (rows && rows.length){
        _.each(rows, function(row){
          _.each(transports, function(t){
            t.notify(shorts[row.op], row);
          });
        });
      }else{
        t.notify(op);
      }
    });
  });

  var me={
    stop:function(callback){
      method.stop(callback);
    }
  };
  return me;
};
function startGame() {

	// it should theoretically never hit this case
	// but better safe than sorry.
	if(gameInProgress) { return; }

	gameInProgress = true;

	// notify each of the inactive players that the game is in progress
	_.each(_.keys(inactivePlayers), function(inactivePlayer) {
		io.sockets.socket(inactivePlayer).emit("game in progress");
	});

	// set the initial score to 0-0
	score.white = 0;
	score.black = 0;

	var randMap = Math.floor(Math.random() * numMaps) + 1;
	io.sockets.emit("set map", {map: randMap});

	// set player positions
	_.each(_.values(players), function(thisPlayer) {

		if(thisPlayer.team === "white") {
			thisPlayer.x = 17;
			thisPlayer.y = 20;
		}
		else {
			thisPlayer.x = 142;
			thisPlayer.y = 20;
		}

		io.sockets.emit("init player", {id:thisPlayer.id, x: thisPlayer.x, y: thisPlayer.y});

	});

}
Example #23
0
Person.prototype.getAllViewedCase = function() {
  return _.pluck(_.values(this.connections), 'caseViewed');
};
Example #24
0
 _.each(command['hooks'], function(hook) {
     hook.apply(hook.module, _.values(results)); 
 }, this);
Example #25
0
	    	function (callback_while) {

				console.log("DEBUGSIM: INDEX "+index)
		    	var mytrain = data['train'].slice(0, index)
    		    	
		    	if (index<10)
       				{
		           		index += 2
		       		} 
 		   		else if (index<20)
					{
			           	index += 2
		           	}
		       		else index += 10

           		var mytrainset = JSON.parse(JSON.stringify((bars.isDialogue(mytrain) ? _.flatten(mytrain) : mytrain)))

           		console.log("DEBUGSIM: size of the strandard train" + mytrain.length + " in utterances "+ mytrainset.length)

				console.log("DEBUGSIM: before results1")
				var results1 = bars.simulateds(buffer_train1, mytrainset.length - sim_train1.length, gold, 1)
				console.log("DEBUGSIM: after results1")
				buffer_train1 = results1["dataset"]
				sim_train1 = sim_train1.concat(results1["simulated"])

	    		trainAndTest.trainAndTest_async(classifiers[_.values(classifierList)[0]], bars.copyobj(sim_train1), bars.copyobj(testset), function(err, stats1){
	    		  
			    	console.log("DEBUGSIM:"+results1["simulated"].length+" size of the simulated train")
					console.log("DEBUGSIMDIST: Simualte dist for the first run:"+JSON.stringify(bars.getDist(sim_train1)))
					console.log("DEBUGSIM: Results for the first run "+ JSON.stringify(stats1['stats'], null, 4))
		    		
					extractGlobal(_.values(classifierList)[0], mytrain, fold, stats1['stats'], glob_stats, classifierList)
			 	
					console.log("DEBUGSIM: before results2")
					var results2 = bars.simulateds(buffer_train2, mytrainset.length - sim_train2.length, gold, 0.5)
					console.log("DEBUGSIM: after results2")
					buffer_train2 = results2["dataset"]
			    	sim_train2 = sim_train2.concat(results2["simulated"])
	
			    	console.log("DEBUGSIM: size of aggregated simulated after plus "+ sim_train2.length + " in utterances "+_.flatten(sim_train2).length)

	    			trainAndTest.trainAndTest_async(classifiers[_.values(classifierList)[1]], bars.copyobj(sim_train2), bars.copyobj(testset), function(err, stats2){

		    			console.log("DEBUGSIM:"+results2["simulated"].length+" size of the simulated train")
						console.log("DEBUGSIMDIST: Simualte dist for the second run:"+JSON.stringify(bars.getDist(sim_train2)))
						console.log("DEBUGSIM: Results for the second run "+ JSON.stringify(stats2['stats'], null, 4))

			    		extractGlobal(_.values(classifierList)[1], mytrain, fold, stats2['stats'], glob_stats, classifierList)	
					    		

						console.log("DEBUGSIM: before results3")
			    		var results3 = bars.simulateds(buffer_train3, mytrainset.length - sim_train3.length, gold, 0.03125)
						console.log("DEBUGSIM: after results3")
						buffer_train3 = results3["dataset"]
				    	sim_train3 = sim_train3.concat(results3["simulated"])

				    	console.log("DEBUGSIM: size of aggregated simulated after plus "+ sim_train3.length + " in utterances "+_.flatten(sim_train3).length)
	
				    	trainAndTest.trainAndTest_async(classifiers[_.values(classifierList)[2]], bars.copyobj(sim_train3), bars.copyobj(testset), function(err, stats3){
                        console.log("DEBUGSIMDIST: Simualte dist for the third run:"+JSON.stringify(bars.getDist(sim_train3)))
                               
				    	extractGlobal(_.values(classifierList)[2], mytrain, fold, stats3['stats'], glob_stats, classifierList)

				    	var results4 = bars.simulateds(buffer_train4, mytrainset.length - sim_train4.length, gold, 0)
						buffer_train4 = results4["dataset"]
				    	sim_train4 = sim_train4.concat(results4["simulated"])
				 
				    	trainAndTest.trainAndTest_async(classifiers[_.values(classifierList)[3]], bars.copyobj(sim_train4), bars.copyobj(testset), function(err, stats4){
                        
                        	console.log("DEBUGSIMDIST: Simualte dist 1st:"+JSON.stringify(bars.getDist(sim_train1)))
							console.log("DEBUGSIMDIST: Simualte dist 2st:"+JSON.stringify(bars.getDist(sim_train2)))
							console.log("DEBUGSIMDIST: Simualte dist 3st:"+JSON.stringify(bars.getDist(sim_train3)))
							console.log("DEBUGSIMDIST: Simualte dist 4st:"+JSON.stringify(bars.getDist(sim_train4)))

				    		extractGlobal(_.values(classifierList)[3], mytrain, fold, stats4['stats'], glob_stats, classifierList)

							_.each(glob_stats, function(data, param, list){
								master.plotlc(fold, param, glob_stats)
								console.log("DEBUGLC: param "+param+" fold "+fold+" build")
								master.plotlc('average', param, glob_stats)
							})

							callback_while();
						})
					})
				})
			})
    	},
Example #26
0
console.log(_.isEqual(moe, clone));//true
//判断对象类型以下都为空
console.log(_.isEmpty({})); //如果object里没包含任何东西,将返回true
console.log(_.isArray([1,2,3]));
console.log(_.isObject({}));
console.log((function(){ return _.isArguments(arguments); })(1, 2, 3));
console.log(_.isFunction(console.log));
console.log(_.isString("moe"));
console.log(_.isNumber(8.4 * 5));
console.log(_.isFinite(-101));
console.log(_.isBoolean(true));
console.log(_.isDate(new Date()));
console.log(_.isNaN(NaN));
console.log(_.isNull(null));
console.log(_.isUndefined(undefined));

// invert _.invert(object)
// 返回一个object的副本,并且里面的键和值是对调的,要使之有效,必须确保object里所有的值都是唯一的且可以序列号成字符串
console.log(_.invert({a:'b', c:'d', e:'f'})); // { b: 'a', d: 'c', f: 'e' }

// pairs _.pairs(object)
// 把一个对象转换成一个[key, value]形式的数组
console.log(_.pairs({one:1, two:2, three: 3})); // [ [ 'one', 1 ], [ 'two', 2 ], [ 'three', 3 ] ]

// values _.values(object)
// 获取object对象的所有属性值
console.log(_.values({one:1, two:2, three:3})); // [ 1, 2, 3 ]

// keys _.keys(object)
// 获取object对象的所有属性名
console.log(_.keys({one:1, two:2, three:3})); //[ 'one', 'two', 'three' ]
Example #27
0
			sock.on("connection", function() {
				var socketsList = _.values(s.unauthenticatedSockets);
				socketsList.length.should.equal(1);
				socketsList[0].authenticated.should.equal(false);
				done();
			});
 entry.request.queryString.forEach(function(q) {
     var values = _.values(q);
     if (values[0] != 'apiKey' && values[0] != 'hash' && values[0] != 'time') {
         return tmpQuery.push(_.values(q).join('='));
     }
 });
Example #29
0
Person.prototype.getAllAppVersions = function() {
  return _.pluck(_.values(this.connections), 'appVersion');
};
        entries.forEach(function(entry) {
            var query = entry.request.postData,
                url = entry.request.url,
                object, pairs, first;

            url = url.split('?');
            var tmpUrl = url[0];

            if (url[1]) {
                url[1].split('&').map(function(i) {
                    var key = i.split('=')[0];
                    if (key && key == 'base') {
                        tmpUrl = i.split('=')[1];
                    }
                });
            }

            if (query) {
                query = JSON.stringify(query.text);
            } else {
                var tmpQuery = [];

                entry.request.queryString.forEach(function(q) {
                    var values = _.values(q);
                    if (values[0] != 'apiKey' && values[0] != 'hash' && values[0] != 'time') {
                        return tmpQuery.push(_.values(q).join('='));
                    }
                });
                query = tmpQuery.join(',');
            }

            // if(store[url + query]){
            //     return;
            // } 

            // store[url + query ] = url + query;

            object = {
                api_call: tmpUrl,
                query: query,
                method: entry.request.method,
                destination: entry.request.url,
                status: entry.response.status,
                response: entry.response.content.text || ''
            };

            try {
                object.response = JSON.parse(object.response);

                pairs = _.pairs(object.response);
                first = pairs[0];
                if (_.isArray(first[1])) {
                    object.response = JSON.stringify(first[1][0]);
                } else {
                    object.response = JSON.stringify(object.response);
                }

            } catch (e) {
                object.response = JSON.stringify(object.response);
                console.log('Cannot parse the response because: ', e);
                console.log("\nAdding as response: ", object.response);
            }
            csv.push(_.values(object).join('~') + '\n');
        });