TODO fix the eventemitter issue TODO possible libs : - create a jsonschema from code  goals : - be good at reporting the whole diff at once (not just the first one found) - make repeated requests easy (with cookies) - test: chaining with cookies
484446
function(title) {
  var logChar = "#";
  var row1 = "";
  var row2 = " " + title + " ";
  var row3 = "";
  while(row1.length < row2.length) {
    row1 = row1 + logChar;
    row3 = row3 + logChar;
  }
  for (var i = 0; i < 10; i++) {
    row1 = logChar + row1 + logChar;
    row2 = logChar + row2 + logChar;
    row3 = logChar + row3 + logChar;
  }

  return "\n\n" + [row1, row2, row3].join("\n") + "\n\n";
}
1373026
function createJsonpCallback( requestSettings, mockHandler, origSettings ) {
		var callbackContext = origSettings && origSettings.context || requestSettings;
		var jsonp = requestSettings.jsonpCallback || ("jsonp" + jsc++);

		// Replace the =? sequence both in the query string and the data
		if ( requestSettings.data ) {
			requestSettings.data = (requestSettings.data + "").replace(CALLBACK_REGEX, "=" + jsonp + "$1");
		}

		requestSettings.url = requestSettings.url.replace(CALLBACK_REGEX, "=" + jsonp + "$1");


		// Handle JSONP-style loading
		window[ jsonp ] = window[ jsonp ] || function( tmp ) {
			data = tmp;
			jsonpSuccess( requestSettings, callbackContext, mockHandler );
			jsonpComplete( requestSettings, callbackContext, mockHandler );
			// Garbage collect
			window[ jsonp ] = undefined;

			try {
				delete window[ jsonp ];
			} catch(e) {}

			if ( head ) {
				head.removeChild( script );
			}
		};
	}
796305
function JsonParserES5() {
    // invoke super constructor
    Parser.call(this, allTokens)

    // not mandatory, using <$> (or any other sign) to reduce verbosity (this. this. this. this. .......)
    var $ = this

    this.RULE("json", function() {
        // prettier-ignore
        $.OR([
            {ALT: function() {$.SUBRULE($.object)}},
            {ALT: function() {$.SUBRULE($.array)}}
        ])
    })

    this.RULE("object", function() {
        $.CONSUME(LCurly)
        $.MANY_SEP({
            SEP: Comma,
            DEF: function() {
                $.SUBRULE2($.objectItem)
            }
        })
        $.CONSUME(RCurly)
    })

    this.RULE("objectItem", function() {
        $.CONSUME(StringLiteral)
        $.CONSUME(Colon)
        $.SUBRULE($.value)
    })

    this.RULE("array", function() {
        $.CONSUME(LSquare)
        $.MANY_SEP({
            SEP: Comma,
            DEF: function() {
                $.SUBRULE2($.value)
            }
        })
        $.CONSUME(RSquare)
    })

    this.RULE("value", function() {
        // prettier-ignore
        $.OR([
            {ALT: function() {$.CONSUME(StringLiteral)}},
            {ALT: function() {$.CONSUME(NumberLiteral)}},
            {ALT: function() {$.SUBRULE($.object)}},
            {ALT: function() {$.SUBRULE($.array)}},
            {ALT: function() {$.CONSUME(True)}},
            {ALT: function() {$.CONSUME(False)}},
            {ALT: function() {$.CONSUME(Null)}}
        ])
    })

    // very important to call this after all the rules have been defined.
    // otherwise the parser may not work correctly as it will lack information
    // derived during the self analysis phase.
    this.performSelfAnalysis()
}
582220
function (json, callback) {
        //validate input
        if (!inputValidation(json)) {
            var inputError = new SearchError('invalid input');
            callback(undefined, inputError);
            return;
        }
        var number = json.number;
        //mongodb api here, then handle the response from mongodb
        database.getSentimentTimeframe(json.startDate, json.endDate, function (json, err) {
            if (err) {
                callback(undefined, err);
            } else {
                var res = calculateTopSum(json, number, ["posSum"]);
                callback(res);
            }
        });
    }
1163209
function nudge(emitter, eventSpecs) {
	'use strict';

	checkValidity(eventSpecs);

	var proxy = makeProxyEmitter(emitter, eventSpecs);

	return function middleware(req, res) {
		function write(string) {
			res.write(string);
		}

		proxy.on('data', write);

		req.once('close', function removeListener() {
			proxy.removeListener('data', write);
		});

		// Necessary headers for SSE.
		res.writeHead(200, {
			'Content-Type': 'text/event-stream',
			'Cache-Control': 'no-cache',
			'Connection': 'keep-alive',
			'X-Accel-Buffering': 'no' // Tell Nginx not to buffer this response.
		});

		// SSE required newline.
		write('\n');
	};
}
1358332
function EventEmitter(name, node) {
        if ('string' !== typeof name) {
            throw new TypeError('EventEmitter constructor: name must be ' +
                                'string. Found: ' + name);
        }

        this.node = node;

        // ## Public properties

        this.name = name;

        /**
         * ### EventEmitter.listeners
         *
         * Event listeners collection
         */
        this.events = {};

        /**
         * ## EventEmitter.recordChanges
         *
         * If TRUE, keeps tracks of addition and deletion of listeners
         *
         * @see EventEmitter.changes
         */
        this.recordChanges = false;

        /**
         * ## EventEmitter.changes
         *
         * If TRUE, keeps tracks of addition and deletion of listeners
         *
         * @see EventEmitter.recordChanges
         */
        this.changes = {
            added: [],
            removed: []
        };

        /**
         * ## EventEmitter.labels
         *
         * List of labels associated to an event listener
         *
         * @see EventEmitter.on
         */
        this.labels = {};

        /**
         * ### EventEmitter.history
         *
         * Database of emitted events
         *
         * @experimental
         *
         * @see NDDB
         * @see EventEmitter.EventHistory
         * @see EventEmitter.store
         */
        this.history = new EventHistory(this.node);
    }
156221
private void understandSchema(String schema) throws JSONException {

    JSONObject j1 = new JSONObject(schema);
    JSONArray fields = j1.getJSONArray(FIELDS);

    String fieldName;
    String fieldTypeValue;
    Object recName;

    for (int k = 0; k < fields.length(); k++) {
      if (fields.get(k) == null) {
        continue;
      }
      JSONObject allEvents = new JSONObject(fields.get(k).toString());
      Object name = allEvents.get(NAME);
      if (name != null) {
        if (name.toString().equalsIgnoreCase(EVENT)) {
          JSONArray allTypeDetails = allEvents.getJSONArray(TYPE);
          for (int i = 0; i < allTypeDetails.length(); i++) {
            JSONObject actual = (JSONObject) allTypeDetails.get(i);
            JSONArray types = actual.getJSONArray(FIELDS);
            Map<String, String> typeDetails = new HashMap<String, String>();
            for (int j = 0; j < types.length(); j++) {
              if (types.getJSONObject(j) == null ) {
                continue;
              }
              fieldName = types.getJSONObject(j).getString(NAME);
              fieldTypeValue = types.getJSONObject(j).getString(TYPE);
              if ((fieldName != null) && (fieldTypeValue != null)) {
                typeDetails.put(fieldName, fieldTypeValue);
              }
            }

            recName = actual.get(NAME);
            if (recName != null) {
              /* the next statement may throw an IllegalArgumentException if
               * it finds a new string that's not part of the Hadoop2RecordType enum
               * that way we know what types of events we are parsing
               */
              fieldTypes.put(Hadoop2RecordType.valueOf(recName.toString()), typeDetails);
            }
          }
        }
      }
    }
  }
319957
function processJson (json) {
                        if (json.length != 1) {
                            renderContext.renderErrors[graph.id] = "TSDB results doesn't contain exactly 1 metric, was "+json.length;
                            renderContext.renderMessages[graph.id] = "";
                            return;
                        }

                        var series = json[0];

                        if (heatmapOptions.excludeNegative) {
                            for (var i=0; i<series.dps.length; i++) {
                                if (series.dps[i][1] < 0) {
                                    series.dps[i][1] = 0;
                                }
                            }
                        }

                        var isFilteredOutFn = function(value) {
                            return false;
                        }
                        var tsdbLinkRangeLower = "";
                        var tsdbLinkRangeUpper = "";
                        if ((heatmapOptions.filterLowerBound != null && heatmapOptions.filterLowerBound != "") || (heatmapOptions.filterUpperBound != null && heatmapOptions.filterUpperBound != "")) {
                            if (heatmapOptions.filterUpperBound == null || heatmapOptions.filterUpperBound == "") {
                                try {
                                    var lower = parseInt(heatmapOptions.filterLowerBound);
                                    tsdbLinkRangeLower = lower;
                                    isFilteredOutFn = function(value) {
                                        return value < lower
                                    };
                                }
                                catch (e) {
                                    // ignore
                                }
                            }
                            else if (heatmapOptions.filterLowerBound == null || heatmapOptions.filterLowerBound == "") {
                                try {
                                    var upper = parseInt(heatmapOptions.filterUpperBound);
                                    tsdbLinkRangeUpper = upper;
                                    isFilteredOutFn = function(value) {
                                        return value > upper
                                    };
                                }
                                catch (e) {
                                    // ignore
                                }
                            }
                            else {
                                try {
                                    var lower = parseInt(heatmapOptions.filterLowerBound);
                                    var upper = parseInt(heatmapOptions.filterUpperBound);
                                    tsdbLinkRangeLower = lower;
                                    tsdbLinkRangeUpper = upper;
                                    isFilteredOutFn = function(value) {
                                        return value < lower || value > upper
                                    };
                                }
                                catch (e) {
                                    // ignore
                                }
                            }
                        }

                        // remove old heatmaps..
                        d3.select(divSelector)
                            .selectAll("svg")
                            .remove();

                        var heatmap = renderer.heatmap()
                            .cellSize(cellSize)
                            .scale(d3.scale.quantize())
                            .dps(series.dps)
                            .width(width)
                            .height(height)
                            .colourScheme(heatmapOptions.colourScheme);

                        if (style == "week_day") {
                            heatmap.weekDayRender(divSelector, fromYear, toYear, isFilteredOutFn);
                        }
                        else if (style == "day_hour") {
                            heatmap.dayHourRender(divSelector, fromMonth, toMonth, isFilteredOutFn);
                        }

                        if (heatmapOptions.excludeNegative && true && (tsdbLinkRangeLower == "" || tsdbLinkRangeLower < 0)) {
                            tsdbLinkRangeLower = 0;
                        }
                        var yAxisParams = {
                            range: "[" + tsdbLinkRangeLower + ":" + tsdbLinkRangeUpper + "]"
                        };
                        ret.tsdb_export_link = graphServices.tsdbGraphUrl("/#", renderContext, config, global, graph, queries, "x1y1", downsampleOverrideFn, yAxisParams, /*y2AxisParams*/null, /*keyParams*/{}, /*lineSmoothing*/false, /*style*/null, /*globalAnnotations*/false);
                        renderContext.renderMessages[graph.id] = "";
                        renderContext.graphRendered(graph.id);
                        return;
                    }
1239164
function ( json ) {
    pageNotFoundJson = sqsUtil.copy( json );
    pageNotFoundJson.collection = {};
    pageNotFoundJson.error = true;
}
80724
function createJsonPreprocessor(logger, basePath, config) {
  const log = logger.create('preprocessor.json');
  const conf = config || {};
  const stripPrefix = new RegExp(`^${(conf.stripPrefix || '')}`);

  return function(content, file, done) {
    log.debug('Processing "%s".', file.originalPath);

    // Build json path file.
    const jsonPath = file.originalPath
        .replace(`${basePath}/`, '')
        .replace(stripPrefix, '');

    const template = createTemplate(conf.varName || '__json__');

    // Update file path
    file.path = `${file.path}.js`;

    try {
      const o = JSON.parse(content.trim());
      done(util.format(template, jsonPath, JSON.stringify(o)));
    } catch (e) {
      log.error('Json representation of %s is not valid !', file.originalPath);
      done('');
    }
  };
}
604368
function setup(check) {
  if (!check) {
    throw new Error('Data to match is not defined')
  } else if (!check.jsonBody) {
    throw new Error('jsonBody is not defined')
  } else if (!check.jsonTest) {
    throw new Error('jsonTest is not defined')
  }

  // define the defaults
  const defaults = {
    isNot: false,
    path: undefined,
    // jsonBody will be present
    // jsonTest will be present
  }

  // merge the passed in values with the defaults
  return _.merge(defaults, check)
}
690739
function main() {

    var database = fs.createWriteStream('./lib/database-min.js', { flags: 'w', encoding: 'utf8' });
    var testFile;

    fs.mkdir('./data', 493, function (error) {  // 493 == 0755 (no octal in strict mode.)
        // ignore errors.
    });
    
    database.write("// Do not edit this file, your changes will be lost.\n");
    database.write("module.exports = { \n");
    getJSON('http://alscan.info/agent_groups/groups.json', function (groups) {
        var s = JSON.stringify(groups);
        database.write("groups:" + s + ",\n");
        testFile = fs.createWriteStream('./data/groups.json', { flags: 'w', encoding: 'utf8' });
        testFile.write(s+"\n");
        testFile.end();
        getJSON('http://alscan.info/agent_sources/sources.json', function (sources) {
            var s = JSON.stringify(sources);
            database.write("sources:" + s + ",\n");
            testFile = fs.createWriteStream('./data/sources.json', { flags: 'w', encoding: 'utf8' });
            testFile.write(s+"\n");
            testFile.end();
            getJSON('http://alscan.info/patterns/patterns.json', function (patterns) {
                database.write("patterns:[\n");
                patterns.forEach(function (pattern) {
                    database.write("{p: new RegExp('" + pattern.pattern + "'), x:" + 
                            agentdb.getX(pattern.groupId, pattern.sourceId) + "},");
                });
                database.write("],\n");
                testFile = fs.createWriteStream('./data/patterns.json', { flags: 'w', encoding: 'utf8' });
                testFile.write(JSON.stringify(patterns)+"\n");
                testFile.end();
                getJSON('http://alscan.info/agents/agents.json', function (agents) {
                    var hash = new HashTable(HASH_TABLE_SIZE, HASH_TABLE_SEED, HASH_TABLE_MULTIPLIER);
                    agents.forEach(function (agent) {
                        if (agent.status < 2) {
                            var obj = { a: agent.agent, x: agentdb.getX(agent.groupId, agent.sourceId) };
                            hash.add('a', obj);
                        }
                    });
                    database.write("table:" + JSON.stringify(hash.table) + ",\n");
                    database.write("HASH_TABLE_SIZE:" + HASH_TABLE_SIZE + ",\n");
                    database.write("HASH_TABLE_SEED:" + HASH_TABLE_SEED + ",\n");
                    database.write("HASH_TABLE_MULTIPLIER:" + HASH_TABLE_MULTIPLIER + ",\n");
                    database.write("hash: undefined\n}\n");
                    testFile = fs.createWriteStream('./data/agents.json', { flags: 'w', encoding: 'utf8' });
                    testFile.write(JSON.stringify(agents)+"\n");
                    testFile.end();
                    if (debug) {
                        var history = hash.getHistory();
                        console.log("Hash table history");
                        for (var n=0; n < history.length; n++) {
                            console.log("  Depth=" + n + ", count=" + history[n] + ", percent=" + (history[n] / HASH_TABLE_SIZE));
                        }
                    }
                });
            });
        });
    });
}
1028967
function () {
				this.oModel = new JSONModel();
				this.getView().setModel(this.oModel);

				this.router = this.getRouter();
				this.router.getRoute("code").attachPatternMatched(this.onRouteMatched, this);
				this.router.getRoute("codeFile").attachPatternMatched(this.onRouteMatched, this);

				this._codeCache = {};
				this._aFilesAvailable = [];

				this._bFirstLoad = true;
			}
686976
function EclairJS(sessionName) {
  if (sessionName && EJSCache[sessionName]) {
    console.log("got hit")
    return EJSCache[sessionName].ejs;
  } else {
    var server = new Server();
    var kernelP = server.getKernelPromise();

    var instance = {
      Accumulable: require('./Accumulable.js')(kernelP),
      AccumulableParam: require('./AccumulableParam.js')(kernelP),
      List: require('./List.js')(kernelP),
      Tuple: require('./Tuple.js')(kernelP),
      Tuple2: require('./Tuple2.js')(kernelP),
      Tuple3: require('./Tuple3.js')(kernelP),
      Tuple4: require('./Tuple4.js')(kernelP),
      SparkConf: require('./SparkConf.js')(kernelP),
      SparkContext: require('./SparkContext.js')(kernelP, server),

      ml: require('./ml/module.js')(kernelP),
      mllib: require('./mllib/module.js')(kernelP),
      rdd: require('./rdd/module.js')(kernelP),
      sql: require('./sql/module.js')(kernelP, server),
      storage: require('./storage/module.js')(kernelP),
      streaming: require('./streaming/module.js')(kernelP),

      forceFloat: Utils.forceFloat,

      addJar: function (jar) {
        return Utils.addSparkJar(kernelP, jar);
      },

      getUtils: function () {
        return Utils;
      },

      executeMethod: function (args) {
        return Utils.executeMethod(kernelP, args);
      },

      addModule: function (module) {
        server.addModule(module);
      }
    };

    if (sessionName) {
      EJSCache[sessionName] = {ejs: instance, server: server};
    }

    return instance;
  }
}
429043
function (events) {
        "use strict";
    
        var loaded = {};
        this.loaded = loaded;
    
        var items = {};
        var keys = [];
        Object.defineProperty(this, 'items', {
            'get': function () {
                return items;
            }
        });
        Object.defineProperty(this, 'keys', {
            'get': function () {
                return keys;
            }
        });
        Object.defineProperty(this, 'length', {
            'get': function () {
                return keys.length;
            }
        });
    
        // List of modules that are multilanguage
        var multilanguage = new Map();
        Object.defineProperty(this, 'multilanguage', {
            'get': function () {
                return multilanguage;
            }
        });
    
        this.get = function (moduleID, extendedID) {
    
            var done = function () {
    
                events.trigger(moduleID + ':done');
                events.trigger('done', moduleID);
    
                loaded[moduleID] = true;
    
            };
    
            var extended;
            if (extendedID) {
                extended = items[extendedID];
                if (!extended) {
                    extended = new Module(moduleID, events);
                    items[extendedID] = extended;
                    keys.push(extendedID);
                }
            }
    
            var module = items[moduleID];
            if (!module) {
                module = new Module(moduleID, events);
                items[moduleID] = module;
                keys.push(moduleID);
            }
    
    
            if (extended) return [module, extended];
            else return [module, done];
    
        };
    
    }
1273203
function init(noEmitter) {
	if (!noEmitter) {
		if (emitter) apperror.removeErrorListener(emitter)
		emitter = new events.EventEmitter
		emitter.id = 'Api Manager'
		apperror.addErrorListener(emitter)
	}
	return emitter
}
1279669
function(json){
  
  // Protect against forgetting the new keyword when calling the constructor
  if(!(this instanceof AtomCommon)){
    return new AtomCommon(json);
  }
  
  // If the given object is already an instance then just return it. DON'T copy it.
  if(AtomCommon.isInstance(json)){
    return json;
  }
  
  this.init(json);
}