#### main entry point
546189
function () {
            // If the first argument is init, this is the setup, Ie.
            // `Pilotish('recorder', 'init', { ... })`
            if (arguments[0] == "init") {
                settings = Pilotfish('extend', {}, settings, arguments[1]);

                // If they passed in events to listen for...
                if (settings.events) {
                    for (var i = 0; i < settings.events.length; i++) {
                        Pilotfish('on', settings.events[i], function (evt) {
                            recordEvent(evt.type);
                        });
                    }
                }

                // For thick clients that use the hash tag as page views, record them that way.
                if (settings.hashChangePageView) {
                    Pilotfish('on', 'window:hashchange', function (evt) {
                        recordEvent(PAGEVIEW, evt.path);
                    });
                }

                // recordClicks is a css 3 selector to listen for clicks on
                if (settings.recordClicks) {
                    jQuery(settings.recordClicks).click(function recordClicks() {
                        var $this = jQuery(this);
                        // They supplied an event via an attribute named data-event
                        if ($this.data("event")) {
                            recordEvent($this.data("event"));

                        // It's a form element, use the value
                        } else if ($this.val() && $this.val().length < 25) {
                            recordEvent($this.val());

                        // This has some reasonable inner text. use it.
                        } else if ($this.text().length < 25) {
                            recordEvent($this.text());
                        }
                    });
                }

                // Record a page view to the pilotfish session backend
                if (settings.recordSession) {
                    jQuery(window).load(function () {
                        track("pilotfish-session", PAGEVIEW, {path: location.pathname});
                    });
                }

            } else {
                // We are tracking data
                recordEvent.apply(this, arguments);
            }
        }
131306
public function main()
    {
        $this->validate();
        $this->datetimeTaskStart = new \DateTimeImmutable();

        if ($this->describeMainStack()) {
            $this->updateStacks();
        } else {
            $this->creationStacks();
        }

        while (!$this->stackIsReady()) {
            sleep(3);
            if (empty($this->events)) {
                $this->log("Waiting for stack provisioning...");
            }
        }

        $stacks = $this->describeMainStack($e);

        if (null === $stacks) {
            throw $e;
        }

        $outputLog = '';

        if ($stacks[0]['Outputs']) {
            foreach ($stacks[0]['Outputs'] as $row) {
                $outputLog .= PHP_EOL . $row['OutputKey'] . ': ' . $row['OutputValue'];
                if ($output = $this->getOutput($row['OutputKey'])) {
                    /** @var StackOutput $output */
                    $this->project->setProperty($output->getProperty(), $row['OutputValue']);
                }
            }
        }

        $this->log($outputLog);
    }
204985
function main() {
	var project = parseSource( errBuf );

	if ( project && writeDictionary( project, errBuf ) ) {
		console.log( 'localization database correctly built' );
	} // if

	if ( errBuf.length ) {
		commons.outputErrors( errBuf, console.error );
		process.exit( 1 );
	} // if

	process.exit( 0 );
}
170398
public function main()
    {
        if ($this->composer === null) {
            $this->findComposer();
        }

        $files = array();
        if (!empty($this->file) && file_exists($this->file)) {
            $files[] = $this->file;
        }

        if (!empty($this->dir)) {
            $found = $this->findFiles();
            foreach ($found as $file) {
                $files[] = $this->dir . DIRECTORY_SEPARATOR . $file;
            }
        }

        foreach ($files as $file) {

            $cmd = $this->composer . ' validate ' . $file;
            $cmd = escapeshellcmd($cmd);

            if ($this->passthru) {
                $retval = null;
                passthru($cmd, $retval);
                if ($retval == 1) {
                    throw new BuildException('invalid composer.json');
                }
            } else {
                $out = array();
                $retval = null;
                exec($cmd, $out, $retval);
                if ($retval == 1) {
                    $err = join("\n", $out);
                    throw new BuildException($err);
                } else {
                    $this->log($out[0]);
                }
            }

        }

    }
661196
function main() {
    console.log("Will create symlink from " + languageDir + " to " + baseDir);
    let relativeLanguageDir = path.relative(currentDir, languageDir);
    let relativeBaseDir = path.relative(currentDir, baseDir);
    console.log("Using relative paths " + relativeLanguageDir + " to " + relativeBaseDir);
    symlinkOrCopySync(relativeLanguageDir, relativeBaseDir);

    // clean out elm-stuff cache
    glob(path.join(currentDir, "/elm-stuff/**/user/project/*/"+argv.rootModule+"*"), function(er, files) {
        files.forEach(function(file) {
            console.log("clearing out cache at", file);
            fs.removeSync(file);
        });
        if (argv.output) {
            build(argv.output);
        }
    });
}
1253083
public function main()
    {
        $this->setup();
        while (!$this->eos()) {
            $p = $this->pos();
            $state = $this->stateName();

            $this->loadTransitions();
            list($nextPatternData, $nextPatternIndex, $nextPatternMatches) = $this->nextStartData();
            list($endIndex, $endMatches) = $this->nextEndData();

            if (($nextPatternIndex <= $endIndex || $endIndex === -1) && $nextPatternIndex !== -1) {
                // we're pushing a new state
                if ($p < $nextPatternIndex) {
                    $this->recordRange($p, $nextPatternIndex);
                }
                $newPos = $nextPatternIndex;
                $this->pos($newPos);
                $tok = $nextPatternData[0];
                if (isset($this->overrides[$tok])) {
                    // call override
                    $ret = call_user_func($this->overrides[$tok], $nextPatternMatches);
                    if ($ret === true) {
                        break;
                    }
                    if ($this->stateName() === $state && $this->pos() <= $newPos) {
                        throw new Exception('Override failed to either advance the pointer or change the state');
                    }
                } else {
                    // no override
                    $this->posShift(strlen($nextPatternMatches[0]));
                    $this->pushState($nextPatternData);
                    $this->record($nextPatternMatches[0]);
                    if ($nextPatternData[2] === null) {
                        // state was a full pattern, so pop now
                        $this->popState();
                    }
                }
            } elseif ($endIndex !== -1) {
                // we're at the end of a state, record what's left and pop it
                $to = $endIndex + strlen($endMatches[0]);
                $this->recordRange($this->pos(), $to);
                $this->pos($to);
                $this->popState();
            } else {
                // no more matches, consume the rest of the stirng and break
                $this->record($this->rest());
                $this->terminate();
                break;
            }
            if ($this->stateName() === $state && $this->pos() <= $p) {
                throw new Exception('Failed to advance pointer in state' . $this->stateName());
            }
        }

        // unterminated states will have left some tokens open, we need to
        // close these so there's just the root node on the stack
        assert(count($this->tokenTreeStack) >= 1);
        while (count($this->tokenTreeStack) > 1) {
            $this->popState();
        }

        return $this->tokenTreeStack[0];
    }
856063
async function main () {

    let exchanges = []

    // instantiate all exchanges
    await Promise.all (ccxt.exchanges.map (async id => {
        let exchange = new (ccxt)[id] ()
        exchanges.push (exchange)
        await test (exchange, symbol)
    }))

    let succeeded = exchanges.filter (exchange => exchange.markets ? true : false).length.toString ().bright.green
    let failed = exchanges.filter (exchange => exchange.markets ? false : true).length
    let total = ccxt.exchanges.length.toString ().bright.white
    console.log (succeeded, 'of', total, 'exchanges loaded', ('(' + failed + ' errors)').red)
}
765653
function main () {
  var taskList = _(arguments).toArray().flatten(true).value()
  gulp.task('default', taskList)
  return this
}
258210
function _main() {
  const {guides: acGuidePaths, images: acGuideImagesPaths, examples: acExamplePaths} = getPathsFromAioContent();
  const {guides: coGuidePaths, images: coGuideImagesPaths, examples: coExamplePaths} = getPathsFromCodeowners();

  const guidesDiff = arrayDiff(acGuidePaths, coGuidePaths);
  const imagesDiff = arrayDiff(acGuideImagesPaths, coGuideImagesPaths);
  const examplesDiff = arrayDiff(acExamplePaths, coExamplePaths);
  const hasDiff = !!(guidesDiff.diffCount || imagesDiff.diffCount || examplesDiff.diffCount);

  if (hasDiff) {
    const expectedGuidesSrc = path.relative(PROJECT_ROOT_DIR, AIO_GUIDES_DIR);
    const expectedImagesSrc = path.relative(PROJECT_ROOT_DIR, AIO_GUIDE_IMAGES_DIR);
    const expectedExamplesSrc = path.relative(PROJECT_ROOT_DIR, AIO_GUIDE_EXAMPLES_DIR);
    const actualSrc = path.relative(PROJECT_ROOT_DIR, CODEOWNERS_PATH);

    reportDiff(guidesDiff, expectedGuidesSrc, actualSrc);
    reportDiff(imagesDiff, expectedImagesSrc, actualSrc);
    reportDiff(examplesDiff, expectedExamplesSrc, actualSrc);
  }

  process.exit(hasDiff ? 1 : 0);
}
125873
function run() {
		$fw=\Base::instance();
		// Assign signal handlers
		declare(ticks=1);
		pcntl_signal(SIGINT,[$this,'kill']);
		pcntl_signal(SIGTERM,[$this,'kill']);
		gc_enable();
		// Activate WebSocket listener
		$listen=stream_socket_server(
			$this->addr,$errno,$errstr,
			STREAM_SERVER_BIND|STREAM_SERVER_LISTEN,
			$this->ctx
		);
		$socket=socket_import_stream($listen);
		register_shutdown_function(function() use($listen) {
			foreach ($this->sockets as $socket)
				if ($socket!=$listen)
					$this->close($socket);
			$this->close($listen);
			if (isset($this->events['stop']) &&
				is_callable($func=$this->events['stop']))
				$func($this);
		});
		if ($errstr)
			user_error($errstr,E_USER_ERROR);
		if (isset($this->events['start']) &&
			is_callable($func=$this->events['start']))
			$func($this);
		$this->sockets=[(int)$listen=>$listen];
		$empty=[];
		$wait=$this->wait;
		while (TRUE) {
			$active=$this->sockets;
			$mark=microtime(TRUE);
			$count=@stream_select(
				$active,$empty,$empty,(int)$wait,round(1e6*($wait-(int)$wait))
			);
			if (is_bool($count) && $wait) {
				if (isset($this->events['error']) &&
					is_callable($func=$this->events['error']))
					$func($this);
				die;
			}
			if ($count) {
				// Process active connections
				foreach ($active as $socket) {
					if (!is_resource($socket))
						continue;
					if ($socket==$listen) {
						if ($socket=@stream_socket_accept($listen,0))
							$this->alloc($socket);
						else
						if (isset($this->events['error']) &&
							is_callable($func=$this->events['error']))
							$func($this);
					}
					else {
						$id=(int)$socket;
						if (isset($this->agents[$id]))
							$this->agents[$id]->fetch();
					}
				}
				$wait-=microtime(TRUE)-$mark;
				while ($wait<1e-6) {
					$wait+=$this->wait;
					$count=0;
				}
			}
			if (!$count) {
				$mark=microtime(TRUE);
				foreach ($this->sockets as $id=>$socket) {
					if (!is_resource($socket))
						continue;
					if ($socket!=$listen &&
						isset($this->agents[$id]) &&
						isset($this->events['idle']) &&
						is_callable($func=$this->events['idle']))
						$func($this->agents[$id]);
				}
				$wait=$this->wait-microtime(TRUE)+$mark;
			}
			gc_collect_cycles();
		}
	}
111807
async function main () {

    const requirements = exchangeId && methodName
    if (!requirements) {

        printUsage ()

    } else {

        let args = params
            .map (s => s.match (/^[0-9]{4}[-]?[0-9]{2}[-]?[0-9]{2}[T\s]?[0-9]{2}[:]?[0-9]{2}[:]?[0-9]{2}/g) ? exchange.parse8601 (s) : s)
            .map (s => (() => { try { return eval ('(() => (' + s + ')) ()') } catch (e) { return s } }) ())

        const www = Array.isArray (exchange.urls.www) ? exchange.urls.www[0] : exchange.urls.www

        if (cloudscrape)
            exchange.headers = await scrapeCloudflareHttpHeaderCookie (www)

        if (cfscrape)
            exchange.headers = cfscrapeCookies (www)

        if (cors) {
            exchange.proxy =  'https://cors-anywhere.herokuapp.com/';
            exchange.origin = exchange.uuid ()
        }

        no_load_markets = no_send ? true : no_load_markets

        if (debug) {
            exchange.verbose = verbose
        }

        if (!no_load_markets) {
            await exchange.loadMarkets ()
        }

        exchange.verbose = verbose

        if (no_send) {

            exchange.verbose = no_send
            exchange.fetch = function fetch (url, method = 'GET', headers = undefined, body = undefined) {
                log.dim.noLocate ('-------------------------------------------')
                log.dim.noLocate (exchange.iso8601 (exchange.milliseconds ()))
                log.green.unlimited ({
                    url,
                    method,
                    headers,
                    body,
                })
                process.exit ()
            }
        }

        if (typeof exchange[methodName] === 'function') {

            log (exchange.id + '.' + methodName, '(' + args.join (', ') + ')')

            while (true) {

                try {

                    const result = await exchange[methodName] (... args)
                    printHumanReadable (exchange, result)

                } catch (e) {

                    if (e instanceof ExchangeError) {

                        log.red (e.constructor.name, e.message)

                    } else if (e instanceof NetworkError) {

                        log.yellow (e.constructor.name, e.message)

                    }

                    log.dim ('---------------------------------------------------')

                    // rethrow for call-stack // other errors
                    throw e

                }

                if (!poll)
                    break;
            }

        } else if (exchange[methodName] === undefined) {

            log.red (exchange.id + '.' + methodName + ': no such property')

        } else {

            printHumanReadable (exchange, exchange[methodName])
        }
    }
}
583835
public function main()
    {
        // INIT
        $this->metaTagList = array();

        $this->initialize();

        $sysLanguageId = 0;
        if (!empty($this->tsSetup['config.']['sys_language_uid'])) {
            $sysLanguageId = $this->tsSetup['config.']['sys_language_uid'];
        }

        // Init News extension
        $this->initExtensionSupport();

        if ($this->tsSetupSeo) {
            $this->collectMetaDataFromPage();
            $customMetaTagList = $this->collectMetaDataFromConnector();

            // #####################################
            // Blacklists
            // #####################################

            // Check search engine indexing blacklist
            if (!empty($this->tsSetupSeo['robotsIndex.']['blacklist.'])) {
                // Page is blacklisted, set to noindex
                $this->tsSetupSeo['robotsIndex'] = 0;
            }

            // #####################################
            // Process StdWrap List
            // #####################################
            $stdWrapItemList = array(
                'title',
                'description',
                'keywords',
                'copyright',
                'email',
                'author',
                'publisher',
                'distribution',
                'rating',
                'lastUpdate',
            );
            foreach ($stdWrapItemList as $key) {
                $this->tsSetupSeo[$key] = $this->applyStdWrap($key, $this->tsSetupSeo[$key]);
            }

            // Call hook
            GeneralUtility::callHookAndSignal(
                __CLASS__,
                'metatagSetup',
                $this,
                $this->tsSetupSeo
            );

            // standard metatags
            $this->generateStandardMetaTags();

            // crawler (eg. robots)
            $this->generateCrawlerMetaTags();

            // geo position
            $this->generateGeoPosMetaTags();

            // services (eg. google plus)
            $this->generateServicesMetaTags();

            // user agent stuff
            $this->generateUserAgentMetaTags();

            // Link meta tags (eg. prev, next...)
            if (!empty($this->tsSetupSeo['linkGeneration'])) {
                $this->generateLinkMetaTags();
            }

            // canonical url
            $this->generateCanonicalUrlMetaTags();

            // OpenGraph
            if (!empty($this->tsSetupSeo['opengraph']) && !empty($this->tsSetupSeo['opengraph.'])) {
                $this->generateOpenGraphMetaTags();
            }

            // Advanced meta tags
            $this->advMetaTags($this->metaTagList, $this->pageRecord, $sysLanguageId, $customMetaTagList);
        }

        // #################
        // SOCIAL
        // #################
        if (!empty($this->tsSetup['plugin.']['metaseo.']['social.'])) {
            $this->tsSetupSeo = $this->tsSetup['plugin.']['metaseo.']['social.'];

            if (!empty($this->tsSetupSeo['googlePlus.']['profilePageId'])) {
                $this->metaTagList['social.googleplus.direct-connect'] = array(
                    'tag'        => 'link',
                    'attributes' => array(
                        'rel'  => 'publisher',
                        'href' => 'https://plus.google.com/' . $this->tsSetupSeo['googlePlus.']['profilePageId'],
                    ),
                );
            }
        }

        $this->processMetaTags($this->metaTagList);

        return $this->renderMetaTags($this->metaTagList);
    }
50668
public function main()
    {
        if ($this->params['stagger']) {
            sleep(rand(0, $this->params['stagger']));
        }

        Configure::write('App.baseUrl', '/');
        $emailQueue = TableRegistry::getTableLocator()->get('EmailQueue', ['className' => EmailQueueTable::class]);
        $emails = $emailQueue->getBatch($this->params['limit']);

        $count = count($emails);
        foreach ($emails as $e) {
            $configName = $e->config === 'default' ? $this->params['config'] : $e->config;
            $template = $e->template === 'default' ? $this->params['template'] : $e->template;
            $layout = $e->layout === 'default' ? $this->params['layout'] : $e->layout;
            $headers = empty($e->headers) ? [] : (array)$e->headers;
            $theme = empty($e->theme) ? '' : (string)$e->theme;
            $viewVars = empty($e->template_vars) ? [] : $e->template_vars;
            $errorMessage = null;

            try {
                $email = $this->_newEmail($configName);

                if (!empty($e->from_email) && !empty($e->from_name)) {
                    $email->setFrom($e->from_email, $e->from_name);
                }

                $transport = $email->getTransport();

                if ($transport && $transport->getConfig('additionalParameters')) {
                    $from = key($email->getFrom());
                    $transport->setConfig(['additionalParameters' => "-f $from"]);
                }

                if (!empty($e->attachments)) {
                    $email->setAttachments($e->attachments);
                }

                $sent = $email
                    ->setTo($e->email)
                    ->setSubject($e->subject)
                    ->setEmailFormat($e->format)
                    ->addHeaders($headers)
                    ->setViewVars($viewVars)
                    ->setMessageId(false)
                    ->setReturnPath($email->getFrom());

                $email->viewBuilder()
                    ->setLayout($layout)
                    ->setTheme($theme)
                    ->setTemplate($template);

                $email->send();
            } catch (SocketException $exception) {
                $this->err($exception->getMessage());
                $errorMessage = $exception->getMessage();
                $sent = false;
            }

            if ($sent) {
                $emailQueue->success($e->id);
                $this->out('<success>Email ' . $e->id . ' was sent</success>');
            } else {
                $emailQueue->fail($e->id, $errorMessage);
                $this->out('<error>Email ' . $e->id . ' was not sent</error>');
            }
        }
        if ($count > 0) {
            $locks = collection($emails)->extract('id')->toList();
            $emailQueue->releaseLocks($locks);
        }
    }
1321
def main():
    """"""
    conf = init_and_get_conf()
    logger = make_logger(__name__)
    logger.info('YaBT version {}', __version__)
    handlers = {
        'build': YabtCommand(func=cmd_build, requires_project=True),
        'dot': YabtCommand(func=cmd_dot, requires_project=True),
        'test': YabtCommand(func=cmd_test, requires_project=True),
        'tree': YabtCommand(func=cmd_tree, requires_project=True),
        'version': YabtCommand(func=cmd_version, requires_project=False),
        'list-builders': YabtCommand(func=cmd_list, requires_project=False),
    }
    command = handlers[conf.cmd]
    if command.requires_project and not conf.in_yabt_project():
        fatal('Not a YABT project (or any of the parent directories): {}',
              BUILD_PROJ_FILE)
    try:
        command.func(conf)
    except Exception as ex:
        fatal('{}', ex)
593069
function main() {
	var len;
	var min;
	var max;
	var f;
	var i;

	min = 1; // 10^min
	max = 6; // 10^max

	for ( i = min; i <= max; i++ ) {
		len = pow( 10, i );
		f = createBenchmark( len );
		bench( pkg+':len='+len, f );
	}
}
1235381
public function main()
    {
        $buildFileRoot = $this->getProject()->getProperty('phing.file');
        $buildFile     = isset($this->_buildFile) ? $this->_buildFile : $buildFileRoot;
        $buildList     = $this->getBuildList($buildFileRoot);
        $parents       = array();
        $targets       = array();

        if (isset($this->_buildFile) && is_file($this->_buildFile)
            && !empty($this->getOwningTarget()->getName())
        ) {
            foreach ($buildList as $buildFile => $buildInfo) {
                if ($this->_buildFile === $buildFile
                    || in_array($buildInfo['parent'], $parents)
                ) {
                    $parents[] = $buildFile;
                    $targets   = array_merge(
                        $targets,
                        $this->getBuildTargets($buildFile)
                    );
                }
            }

            $targets = array_merge($targets, $this->project->helpTargets);
            $this->printBuildTargets($targets, $buildFile, $buildList);
        }

    }
527833
function mainTask() {
        options = this.options(defaultOptions);
        var target = this.target;

        this.files.forEach(function (file) {

            var destJson = app.path.join(file.dest, target + '.cssstats.json');
            var destHtml = app.path.join(file.dest, target + '.cssstats.html');

            var css = {
                concat: ''
            };

            css.concat = file.src.filter(function (filepath) {
                // Remove nonexistent files (it's up to you to filter or warn here).
                if (!grunt.file.exists(filepath)) {
                    grunt.log.warn('Source file "' + filepath + '" not found.');
                    return false;
                } else {
                    return true;
                }
            }).map(function (filepath) {
                // Read and return the file's source.

                css[filepath] = app.fs.readFileSync(filepath, 'utf8');

                return '/****\n    source: ' + filepath + '\n****/\n\n' + css[filepath];

            }).join('\n');

            var stats = parseStats(css);

            if (options.logConsole) {
                console.log(stats);
            }

            if (options.jsonOutput) {
                var statsString = JSON.stringify(stats, undefined, 4);
                grunt.file.write(destJson, statsString);
            }

            if (options.htmlOutput) {
                var output = app.parseHtml(app, options, stats, css);
                grunt.file.write(destHtml, output);
            }
        });

    }