Template.ShowAllNodes.onCreated(function() { console.info("[ShowAllNodes] Created") var instance = this; instance.nodes = new ReactiveVar([]); instance.actions = new ReactiveVar([]); updateNodeData = function updateNodeDataCB(err, res) { var newActions = Tracker.nonreactive(instance.actions.get.bind(instance.actions)); newActions.push(res); instance.actions.set(newActions); Meteor.call('get-forest', function(err, res) { console.log("[" + (new Date()) + "] Nodes:", res); instance.nodes.set(res); }); } Meteor.call('refresh', updateNodeData); _.times(9, function(x) { setTimeout(function() { Meteor.call("step-" + (x + 1), updateNodeData); }, 5000 + x * 5000); }); });
coll.createIndex('at', function (err, indexName) { var count = 0; var total = 1000; _.times(total, function (idx) { var doc = { at: new Date(now - (idx*60*60*1000)), k: req.params.name, ip: req.connection.remoteAddress, v: (40000 + (Math.random() * 20000)) }; coll.insert(doc, function (err, coll) { count += 1; if (count == total) { db.close(); res.send('Loaded ' + total + ' entries', 201); } }); }); });
db.collection(req.params.name, function(err, coll) { if (err) console.log(err); var prev = parseInt(req.param('previous', 1)); var overallResults = []; _.times(prev, function(idx) { coll.find(query(req, idx), { sort: [['at', 1]] }, function (err, cursor) { if (err) console.log(err); cursor.toArray(function (err, results) { if (err) console.log(err); overallResults[idx] = results; prev -= 1; if (prev == 0) { db.close(); res.send(overallResults, 200); } }); }); }); });
this.api.getLibrary(s2, function(err, l2) { if(!err) { var g1 = _.pluck(l1.games, 'name'), g2 = _.pluck(l2.games, 'name'), common = _.filter(g1, function(game) { return _.include(g2, game); }), examples = []; _.times(5, function() { var choice = _.random(0, common.length - 1); if(!_.include(examples, common[choice])) { examples.push(common[choice]); } }); event.reply(dbot.t('steam_games', { 'u1': u1.currentNick, 'u2': u2.currentNick, 'count': common.length, 'examples': examples.join(', ') })); } else { event.reply('Unable to fetch steam library :\'('); } });
import { Meteor } from 'meteor/meteor'; import { Factory } from 'meteor/dburles:factory'; import { _ } from 'underscore'; import { Proposals } from '../../api/proposals/proposals'; if (Meteor.isDevelopment && Proposals.find().count() === 0) { _.times(100, () => Factory.create('proposal')); }