render() {
     var strings = this.props.info.strings;
     var weatherText = this.props.info.place.weather.toLowerCase();
     var temp = this.props.info.place.temp;
     var image;
     
     if (weatherText.indexOf("rain") > -1) {
         image = 'images/rain.png';
     } else if (weatherText.indexOf("cloud") > -1) {
         image = 'images/clouds.png';
     } else {
         image = 'images/sun.png'
     }
     
     return (
         <Paper style={styles.root} id="place_page_tab">
             <IconButton onTouchTap={this.handleBackButtonClick}>
                 <NavigationArrowBack />
             </IconButton>
             <div style={styles.headerStyle} >
                 <div style={styles.nameStyle}>{this.props.info.place.name}</div>
                 <div style={styles.starStyle}>
                 {
                     _.range(this.props.info.place.starRating).map((e) => (
                         <ToggleStar style={styles.oneStarStyle} />
                     ))
                 }
                 </div>
                 <div style={styles.infoStyle}>
                     {this.props.info.place.address}
                 </div>
             </div>
             <List>
                 <ListItem primaryText={strings.likePlace} onTouchTap={this.handlePlaceLike} leftIcon={<ActionFavorite />} /> 
                 <ListItem primaryText={strings.rateReviews} onTouchTap={this.handleShowReviewPage} leftIcon={<ToggleStar />} />
             </List>
             <div style={styles.fillerStyle}></div>
             <div style={styles.containerStyle}>
                 <div style={styles.mapBorderStyle}>
                     <div id="map" style={styles.mapStyle}></div>
                 </div>
                 <div style={styles.weatherStyle}>
                     <div style={styles.oneWeatherStyle}>
                         <img src={image} style={styles.weatherIconStyle}/>
                         <div>{temp}</div>
                     </div>
                 </div>
             </div>
             <div>
                 <Snackbar
                     open={this.state.open}
                     message={this.props.info.place.name + strings.added}
                     autoHideDuration={2000}
                     onRequestClose={this.handleSnackbarClose}
                 />
             </div>
         </Paper>
     );
 }
Example #2
0
 clear_redis(function(){
     async.map(_.range(100), function(index, callback){
         var num = (index + 1);
         BuildInstruction.create({
             name: 'Lorem Ipsum project #' + num,
             repository_address: 'git@github.com:lorem/ipsum-'+num+'-sit-amet.git',
             build_command: 'make test:unit:' + num
         }, callback);
     }, done);
 });
Example #3
0
                function create_the_same_build_10_times (pk, instance, storage, connection, callback){
                    async.mapSeries(_.range(10), function(index, callback){
                        Build.create({
                            __id__: 568,
                            status: 0,
                            error: 'none',
                            output: 'I am new, buddy!'
                        }, callback);
                    }, callback);

                },
Example #4
0
 _.each(_.range(_trail_quad_resolution), function(i) {
         _.each(_.range(_trail_quad_resolution), function(j) {
             _trail_quads.push(
                 {'x': i * quad_width,
                  'x2' : i == _trail_quad_resolution - 1 ? settings.GAME_WIDTH : (i + 1) * quad_width,
                  'y': j * quad_height,
                  'y2' : j == _trail_quad_resolution - 1 ? settings.GAME_HEIGHT : (j + 1) * quad_height,
                  'trail' : []
             });
         });
 });
Example #5
0
function pmkdir(p, cb) {
	p = path.normalize(p).split("/")
	async.forEachSeries(_.range(0, p.length), function(i, cb2) {
			var cur_p = path.join(_(p).select(function() {}))
			fs.stat(cur_p, function(e, r) {
					if(e) {
						fs.mkdir(cur_p, 644, cb2)
					} else {
						if(r.isDirectory())
							cb2(new Error("\"" + cur_p + "\" is not a directory."))
					}
				})
		}, cb)
}
Example #6
0
  it('supports change events on the deep nested model', function(){
    var bla = 'bla bla bla';

    var spies = [];

    _.each(_.range(11), function(){
      spies.push(sinon.spy());
    });

    this.zoo.set('a.b.c.d', 123);

    this.zoo.on('change:a', spies[0]);
    this.zoo.on('change:a.b', spies[1]);
    this.zoo.on('change:a.b.c', spies[2]);
    this.zoo.on('change:a.b.c.d', spies[3]);

    this.zoo.get('a').on('change:b', spies[4]);
    this.zoo.get('a').on('change:b.c', spies[5]);
    this.zoo.get('a').on('change:b.c.d', spies[6]);
    
    this.zoo.get('a.b').on('change:c', spies[7]);
    this.zoo.get('a.b').on('change:c.d', spies[8]);

    this.zoo.get('a.b.c').on('change:d', spies[9]);

    this.zoo.on('change', spies[10]);

    this.zoo.set('a.b.c.d', bla);

    should(spies[0].calledWith(this.zoo, this.zoo.get('a'))).be.true;
    should(spies[1].calledWith(this.zoo, this.zoo.get('a.b'))).be.true;
    should(spies[2].calledWith(this.zoo, this.zoo.get('a.b.c'))).be.true;
    should(spies[3].calledWith(this.zoo, bla)).be.true;

    should(spies[4].calledWith(this.zoo.get('a'), this.zoo.get('a.b'))).be.true;
    should(spies[5].calledWith(this.zoo.get('a'), this.zoo.get('a.b.c'))).be.true;
    should(spies[6].calledWith(this.zoo.get('a'), bla)).be.true;

    should(spies[7].calledWith(this.zoo.get('a.b'), this.zoo.get('a.b.c'))).be.true;
    should(spies[8].calledWith(this.zoo.get('a.b'), bla)).be.true;

    should(spies[9].calledWith(this.zoo.get('a.b.c'), bla)).be.true;

    should(spies[10].calledWith(this.zoo, {})).be.true;

    _.each(spies, function(spy){
      spy.callCount.should.be.equal(1);
    });
  });
Example #7
0
RDD.prototype.identity = function(typeName, f) {
	var parent = this;

	var dataPartition = this.dataPartition.map(function(p) {
		return { ip : p.ip, port : p.port };
	});

	var dependency = _.range(this.dataPartition.length).map(function(d) {
		return { parent : parent, partition : [d] };
	});

	var transformation = { type : typeName, func : f };

	return this.build(dataPartition, dependency, transformation);
}
Example #8
0
exports.init = function(start, count, lxc_root_folder) {
	root_folder = lxc_root_folder;
	
	config_tpl = fs.readFileSync( path.join(__dirname,'templates/config.tpl'), "utf-8");
	fstab_tpl = fs.readFileSync( path.join(__dirname,'templates/fstab.tpl'), "utf-8");

	console.log('Creating VMS from ' + start + ' to '+ ((start + count)));
	var ids = _.range(start, (start + count) + 1);
	for ( var idx in ids ) {
		var i = parseInt(ids[idx]);
		var name = 'vm' + i;
	    vms[name] = create_vm(name);
	}
	console.log( vms );
};
Example #9
0
module.exports = function crossValidate(classifierConst, data, opts, trainOpts, k) {
  k = k || 4;
  var size = data.length / k;

  data = _(data).sortBy(function() {
    return Math.random();
  });

  var avgs = {
    error : 0,
    trainTime : 0,
    testTime : 0,
    iterations: 0,
    trainError: 0,
    precision: 0,
    accuracy: 0,
    recall: 0
  };

  var misclasses = [];

  var results = _.range(k).map(function(i) {
    var dclone = _(data).clone();
    var testSet = dclone.splice(i * size, size);
    var trainSet = dclone;

    var result = testPartition(classifierConst, opts, trainOpts, trainSet, testSet);

    _(avgs).each(function(sum, i) {
      avgs[i] = sum + result[i];
    });

    misclasses.push(result.misclasses);
  });

  _(avgs).each(function(sum, i) {
    avgs[i] = sum / k;
  });

  avgs.testSize = size;
  avgs.trainSize = data.length - size;

  return {
    avgs: avgs,
    misclasses: _(misclasses).flatten()
  };
}
Example #10
0
 start = function () {
     // Create a grid of quads covering the whole play field
     // Used to filter relevant tail pieces during rendering
     var quad_width = settings.GAME_WIDTH / _trail_quad_resolution;
     var quad_height = settings.GAME_HEIGHT / _trail_quad_resolution;
     _trail_quads = [];
     _.each(_.range(_trail_quad_resolution), function(i) {
             _.each(_.range(_trail_quad_resolution), function(j) {
                 _trail_quads.push(
                     {'x': i * quad_width,
                      'x2' : i == _trail_quad_resolution - 1 ? settings.GAME_WIDTH : (i + 1) * quad_width,
                      'y': j * quad_height,
                      'y2' : j == _trail_quad_resolution - 1 ? settings.GAME_HEIGHT : (j + 1) * quad_height,
                      'trail' : []
                 });
             });
     });
 },
 this.props.reviews.map((item) => (
     <div>
         <div style={styles.containerStyle}>
             <Subheader style={styles.nameStyle}>{item.date}</Subheader>
             <div style={styles.starStyle}>
                 {
                     _.range(item.starRating).map((e) =>
                         <ToggleStar style={styles.oneStarStyle}/>
                     )
                 }
             </div>
         </div>
         <ListItem
             primaryText={item.placeName}
             secondaryText={item.content}
             secondaryTextLines={2}
             disabled={true}
         />
         <Divider />
     </div>
 ))
 recommendations: _.range(4).map((c) => ({
     exp: "For travelling alone",
     items: _.range(7).map((r) => (
         {
             cid: (7 * c + r).toString(), // Just for testing
             name: 'Seolark',
             address: 'Seoraksan-ro, Sokcho-si, Gangwon-do',
             latitude: 38.119444,
             longitude: 128.465556,
             img: "images/seolark_highres.jpg",
             starRating: 3,
             reviews: [
                 {
                     cid: "1",
                     placeName: "Seorak",
                     userName: '******',
                     starRating: 5,
                     date: '2016.06.07',
                     content: 'This place is fantastic! The food is amazing, the people are kind, and the view is magnificent. I would certainly come here again!'
                 },
                 {
                     cid: "1",
                     placeName: "Seorak",
                     userName: '******',
                     starRating: 1,
                     date: '2016.05.01',
                     content: 'Imma never come \'ere again, I can tell ya that!'
                 },
                 {
                     cid: "1",
                     placeName: "Seorak",
                     userName: '******',
                     starRating: 3,
                     date: '2016.04.02',
                     content: 'Good!'
                 },
             ]
         })
     )}
 )),
Example #13
0
      this.generatingID(function(err) {
        if (err) {
          if (callback) callback.call(this, err);
          return;
        }

        if (opts.serialize) {
          // Either serialize those arguments indicated or all of them...
          var indices = _.isArray(opts.serialize) ? opts.serialize : _.range(args.length);
          for (var i in indices) {
            args[i] = this.serialize(args[i]);
          }
        }

        if (callback) {
          // Process outputs if necessary. Put callback at end of args.
          args.push(this.redisHandler(opts.rfunc || fname, function(err, retval) {
            // Handle argument deserialization.
            //sys.log("list: return from " + (opts.rfunc || fname) + " err = " + err);
            if (! err && opts.deserialize) {
              if (_.isArray(retval)) {
                this.deserialize_all(retval, callback);
              } else {
                //sys.log("list: deserialize " + sys.inspect(retval));
                this.deserialize(retval, callback);
              }
            } else {
              callback.call(this, err, retval);
            }
          }));
        }

        // Now call the function...
        this.log(opts.rfunc || fname, args);
        args.unshift(this.redis_key);
        //sys.log("list: call " + (opts.rfunc || fname) + " with " + sys.inspect(args));
        var client = (opts.pubsub ? this.pubsubClient : this.client);
        client[opts.rfunc || fname].apply(client, args);
      });
Example #14
0
module.exports = function crossValidate(classifierConst, options, data, k) {
  k = k || 4;
  var size = data.length / k;

  data = _(data).sortBy(function(num){
    return Math.random();
  });

  var avgs = {
    error : 0,
    trainTime : 0,
    testTime : 0,
    iterations: 0
  };

  var results = _.range(k).map(function(i) {
    var dclone = _(data).clone();
    var testSet = dclone.splice(i * size, size);
    var trainSet = dclone;

    var result = testPartition(classifierConst, options, trainSet, testSet);

    _(avgs).each(function(sum, i) {
      avgs[i] = sum + result[i];
    });
  });

  _(avgs).each(function(sum, i) {
    avgs[i] = sum / k;
  });

  avgs.testSize = size;
  avgs.trainSize = data.length - size;

  return avgs;
}
Example #15
0
exports.datetime = function (_options) {
    var w = new Widget('datetime', _options || {}),
		hours = _.range(1,13),
		minutes = _.range(0,46,15),
		meridiem = ['am', 'pm'],
		dow = ['everyday', 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
		
    w.options = _options;
    w.toHTML = function (name, value, raw, field, options) {
        if (raw === undefined) {
            raw = (value === undefined) ? '': +value;
        }
        if (raw === null || raw === undefined) {
            raw = '';
        }

				var html = '<h3>Show</h3><label>Day of Week</label>';
        html += '<select multiple';
        html += ' name="' + this._name(name, options.offset) + '-dow-start" id="';
        html += this._id(name, options.offset, options.path_extra) + '">';
        for (var i = 0; i < dow.length; i++) {
            html += '<option value="' + dow[i] + '"';
            if (dow[i] === value) {
                html += ' selected="selected"';
            }
            html += '>';
            html += dow[i];
            html += '</option>';
        }
        html += '</select>';
				
				html += '<label>Time</label>';
        html += '<select';
        html += ' name="' + this._name(name, options.offset) + '-hours-start" id="';
        html += this._id(name, options.offset, options.path_extra) + '">';
        for (var i = 0; i < hours.length; i++) {
            html += '<option value="' + hours[i] + '"';
            if (hours[i] === value) {
                html += ' selected="selected"';
            }
            html += '>';
            html += hours[i];
            html += '</option>';
        }
        html += '</select>';
        
				html += '<select';
        html += ' name="' + this._name(name, options.offset) + '-minutes-start" id="';
        html += this._id(name, options.offset, options.path_extra) + '">';
        for (var i = 0; i < minutes.length; i++) {
            html += '<option value="' + minutes[i] + '"';
            if (minutes[i] === value) {
                html += ' selected="selected"';
            }
            html += '>';
            html += _.pad(minutes[i], 2, '0');
            html += '</option>';
        }
        html += '</select>';

				html += '<select';
        html += ' name="' + this._name(name, options.offset) + '-meridiem-start" id="';
        html += this._id(name, options.offset, options.path_extra) + '">';
        for (var i = 0; i < meridiem.length; i++) {
            html += '<option value="' + meridiem[i] + '"';
            if (meridiem[i] === value) {
                html += ' selected="selected"';
            }
            html += '>';
            html += meridiem[i];
            html += '</option>';
        }
        html += '</select>';

				html += '<h3>Hide</h3><label>Day of Week</label>';
        html += '<select multiple';
        html += ' name="' + this._name(name, options.offset) + '-dow-end" id="';
        html += this._id(name, options.offset, options.path_extra) + '">';
        for (var i = 0; i < dow.length; i++) {
            html += '<option value="' + dow[i] + '"';
            if (dow[i] === value) {
                html += ' selected="selected"';
            }
            html += '>';
            html += dow[i];
            html += '</option>';
        }
        html += '</select>';
				
				html += '<label>Time</label>';
        html += '<select';
        html += ' name="' + this._name(name, options.offset) + '-hours-end" id="';
        html += this._id(name, options.offset, options.path_extra) + '">';
        for (var i = 0; i < hours.length; i++) {
            html += '<option value="' + hours[i] + '"';
            if (hours[i] === value) {
                html += ' selected="selected"';
            }
            html += '>';
            html += hours[i];
            html += '</option>';
        }
        html += '</select>';
        
				html += '<select';
        html += ' name="' + this._name(name, options.offset) + '-minutes-end" id="';
        html += this._id(name, options.offset, options.path_extra) + '">';
        for (var i = 0; i < minutes.length; i++) {
            html += '<option value="' + minutes[i] + '"';
            if (minutes[i] === value) {
                html += ' selected="selected"';
            }
            html += '>';
            html += _.pad(minutes[i], 2, '0');
            html += '</option>';
        }
        html += '</select>';

				html += '<select';
        html += ' name="' + this._name(name, options.offset) + '-meridiem-end" id="';
        html += this._id(name, options.offset, options.path_extra) + '">';
        for (var i = 0; i < meridiem.length; i++) {
            html += '<option value="' + meridiem[i] + '"';
            if (meridiem[i] === value) {
                html += ' selected="selected"';
            }
            html += '>';
            html += meridiem[i];
            html += '</option>';
        }
        html += '</select>';

        html += '<input type="text"';
        html += ' name="' + this._name(name, options.offset) + '" id="';
        html += this._id(name, options.offset, options.path_extra) + '"';
				html += ' class="hide"';
        html += 'value="' + h(raw) + '">';

        return html;
    };
    return w;
};
Example #16
0
/*global data: false, d3:false, _:false*/
var _ = require('underscore')._;

var projects = _.map(_.range(40), function(x, i) {
  return {
    cost_per_period: _.random(1,10),
    duration: _.random(1,10),
    value_per_period: _.random(1,10),
    i: i
  };
});

console.log(JSON.stringify(projects, null, 2));
injectTapEventPlugin();

/***************************************************************************
    THIS SCRIPT IS UNUSED. DO NOT READ/MODIFY THIS SCRIPT.
****************************************************************************/

// _user_, _place_: Sample data for testing
var _user_ = {
    uid: "1",
    firstLogin: true,
    nickname: "rhapsodyjs",
    age: 24,
    gender: "Male",
    nationality: "Korea, Republic Of",

    recommendations: _.range(4).map((c) => ({
        exp: "For travelling alone",
        items: _.range(7).map((r) => (
            {
                cid: (7 * c + r).toString(), // Just for testing
                name: 'Seolark',
                address: 'Seoraksan-ro, Sokcho-si, Gangwon-do',
                latitude: 38.119444,
                longitude: 128.465556,
                img: "images/seolark_highres.jpg",
                starRating: 3,
                reviews: [
                    {
                        cid: "1",
                        placeName: "Seorak",
                        userName: '******',
Example #18
0
function cycle(collection, times) {
  return helpers.flatMap(_.range(times), function (_) { return collection; });
}
Example #19
0
exports.getDates = function (q, reporting_freq) {
    var now = moment(),
        selected_time_unit = q.time_unit || 'month',
        dates = {},
        list = [];

    if (typeof reporting_freq === 'undefined') {
        reporting_freq = 'month';
    } else if (reporting_freq === 'monthly') {
        reporting_freq = 'month';
    } else if (reporting_freq === 'weekly') {
        reporting_freq = 'week';
    }

    var step = reporting_freq + 's';

    // we can only select week as reporting time unit
    // if the data record is supplied weekly
    if (selected_time_unit === 'week' && reporting_freq !== 'week') {
        selected_time_unit = 'month';
    }

    switch(selected_time_unit) {
        case 'week':
            var weeks = (q.quantity ? parseInt(q.quantity, 10) : 3),
                startweek = q.startweek || exports.dateToWeekStr(now),
                date = now,
                range = _.range(weeks);

            _.each(range, function() {
                list.push(moment(date));
                date.subtract(step, 1);
            });

            _.extend(dates, {
                startweek: startweek,
                quantity: weeks
            });

            break;

        case 'month':
            var months = (q.quantity ? parseInt(q.quantity, 10) : 3),
                startmonth = q.startmonth || exports.dateToMonthStr(now),
                yearnum = startmonth.split('-')[0],
                // previous month with zero-indexed js month is -2
                monthnum = startmonth.split('-')[1]-2,
                date = moment(new Date(yearnum, monthnum, 2)),
                range = _.range(months);

            if(reporting_freq === 'week') {
                if(!q.startmonth || q.startmonth === exports.dateToMonthStr(now)) {
                    date = now;
                }
                monthnum = startmonth.split('-')[1]-1,
                date = moment(new Date(yearnum, monthnum, 2)),
                range = _.range(Math.round(months * 4.348))
            }

            _.each(range, function() {
                list.push(moment(date));
                date.subtract(step, 1);
            });

            _.extend(dates, {
                startmonth: startmonth,
                quantity: months
            });

            break;

        case 'quarter':
            var quarters = (q.quantity ? parseInt(q.quantity, 10) : 2),
                startquarter = q.startquarter || exports.dateToQuarterStr(now),
                startmonth = q.startmonth || exports.dateToMonthStr(now),
                yearnum = startquarter.split('-')[0],
                // previous month with zero-indexed js month is -2
                monthnum = startmonth.split('-')[1]-2,
                date = moment(new Date(yearnum, monthnum, 2)),
                range = _.range(quarters * 3);

            if(reporting_freq === 'week') {
                if(!q.startquarter || q.startquarter === exports.dateToQuarterStr(now)) {
                    date = now;
                }
                range = _.range(Math.round(quarters * 3 * 4.348));
            }

            _.each(range, function() {
                list.push(moment(date));
                date.subtract(step, 1);
            });

            _.extend(dates, {
                startquarter: startquarter,
                quantity: quarters
            });

            break;

        case 'year':
            var years = (q.quantity ? parseInt(q.quantity, 10) : 2),
                startmonth = q.startmonth || exports.dateToMonthStr(now),
                // previous month with zero-indexed js month is -2
                monthnum = startmonth.split('-')[1]-2,
                startyear = q.startyear || exports.dateToYearStr(now),
                date = moment(new Date(parseInt(startyear, 10), monthnum, 2)),
                range = _.range(years * 12);

            if(reporting_freq  === 'week') {
                if(!q.startyear || q.startyear === exports.dateToMonthStr(now)) {
                    date = now;
                }
                range = _.range(Math.round(years * 12 * 4.348));
            }

            _.each(range, function() {
                list.push(moment(date));
                date.subtract(step, 1);
            });

            _.extend(dates, {
                startyear: startyear,
                quantity: years
            });

            break;
    }

    _.extend(dates, {
        form: q.form,
        now: now,
        list: list,
        time_unit: selected_time_unit,
        reporting_freq: reporting_freq
    });

    return dates;
};