text:
<?php

namespace Psy;

use Psy\Exception\BreakException;
use Psy\Exception\ErrorException;
use Psy\Exception\Exception as PsyException;
use Psy\Exception\ThrowUpException;
use Psy\Output\ShellOutput;
use Psy\TabCompletion\Matcher;
use Psy\VarDumper\PresenterAware;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command as BaseCommand;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * The Psy Shell application.
 *
 * Usage:
 *
 *     $shell = new Shell;
 *     $shell->run();
 *
 * @author Justin Hileman <justin@justinhileman.info>
 */
class Shell extends Application
{
    const VERSION = 'v0.6.0';

    const PROMPT      = '>>> ';
    const BUFF_PROMPT = '... ';
    const REPLAY      = '--> ';
    const RETVAL      = '=> ';

    private $config;
    private $cleaner;
    private $output;
    private $readline;
    private $inputBuffer;
    private $code;
    private $codeBuffer;
    private $codeBufferOpen;
    private $context;
    private $includes;
    private $loop;
    private $outputWantsNewline = false;
    private $completion;
    private $tabCompletionMatchers = array();

    /**
     * Create a new Psy Shell.
     *
     * @param Configuration $config (default: null)
     */
    public function __construct(Configuration $config = null)
    {
        $this->config   = $config ?: new Configuration();
        $this->cleaner  = $this->config->getCodeCleaner();
        $this->loop     = $this->config->getLoop();
        $this->context  = new Context();
        $this->includes = array();
        $this->readline = $this->config->getReadline();

        parent::__construct('Psy Shell', self::VERSION);

        $this->config->setShell($this);
        // auto completer needs shell to be linked to configuration because of the context aware matchers
        if ($this->config->getTabCompletion()) {
            $this->completion = $this->config->getAutoCompleter();
            $this->addTabCompletionMatchers($this->config->getTabCompletionMatchers());
            foreach ($this->getTabCompletionMatchers() as $matcher) {
                if ($matcher instanceof ContextAware) {
                    $matcher->setContext($this->context);
                }
                $this->completion->addMatcher($matcher);
            }
            $this->completion->activate();
        }
    }

    /**
     * Check whether the first thing in a backtrace is an include call.
     *
     * This is used by the psysh bin to decide whether to start a shell on boot,
     * or to simply autoload the library.
     */
    public static function isIncluded(array $trace)
    {
        return isset($trace[0]['function']) &&
          in_array($trace[0]['function'], array('require', 'include', 'require_once', 'include_once'));
    }

    /**
     * Invoke a Psy Shell from the current context.
     *
     * For example:
     *
     *     foreach ($items as $item) {
     *         \Psy\Shell::debug(get_defined_vars());
     *     }
     *
     * If you would like your shell interaction to affect the state of the
     * current context, you can extract() the values returned from this call:
     *
     *     foreach ($items as $item) {
     *         extract(\Psy\Shell::debug(get_defined_vars()));
     *         var_dump($item); // will be whatever you set $item to in Psy Shell
     *     }
     *
     * Optionally, supply an object as the `$bind` parameter. This determines
     * the value `$this` will have in the shell, and sets up class scope so that
     * private and protected members are accessible:
     *
     *     class Foo {
     *         function bar() {
     *             \Psy\Shell::debug(get_defined_vars(), $this);
     *         }
     *     }
     *
     * This only really works in PHP 5.4+ and HHVM 3.5+, so upgrade already.
     *
     * @param array  $vars Scope variables from the calling context (default: array())
     * @param object $bind Bound object ($this) value for the shell
     *
     * @return array Scope variables from the debugger session.
     */
    public static function debug(array $vars = array(), $bind = null)
    {
        echo PHP_EOL;

        if ($bind !== null) {
            $vars['this'] = $bind;
        }

        $sh = new \Psy\Shell();
        $sh->setScopeVariables($vars);
        $sh->run();

        return $sh->getScopeVariables();
    }

    /**
     * Adds a command object.
     *
     * {@inheritdoc}
     *
     * @param BaseCommand $command A Symfony Console Command object
     *
     * @return BaseCommand The registered command
     */
    public function add(BaseCommand $command)
    {
        if ($ret = parent::add($command)) {
            if ($ret instanceof ContextAware) {
                $ret->setContext($this->context);
            }

            if ($ret instanceof PresenterAware) {
                $ret->setPresenter($this->config->getPresenter());
            }
        }

        return $ret;
    }

    /**
     * Gets the default input definition.
     *
     * @return InputDefinition An InputDefinition instance
     */
    protected function getDefaultInputDefinition()
    {
        return new InputDefinition(array(
            new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
            new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message.'),
        ));
    }

    /**
     * Gets the default commands that should always be available.
     *
     * @return array An array of default Command instances
     */
    protected function getDefaultCommands()
    {
        $hist = new Command\HistoryCommand();
        $hist->setReadline($this->readline);

        return array(
            new Command\HelpCommand(),
            new Command\ListCommand(),
            new Command\DumpCommand(),
            new Command\DocCommand(),
            new Command\ShowCommand(),
            new Command\WtfCommand(),
            new Command\WhereamiCommand(),
            new Command\ThrowUpCommand(),
            new Command\TraceCommand(),
            new Command\BufferCommand(),
            new Command\ClearCommand(),
            // new Command\PsyVersionCommand(),
            $hist,
            new Command\ExitCommand(),
        );
    }

    /**
     * @return array
     */
    protected function getTabCompletionMatchers()
    {
        if (empty($this->tabCompletionMatchers)) {
            $this->tabCompletionMatchers = array(
                new Matcher\CommandsMatcher($this->all()),
                new Matcher\KeywordsMatcher(),
                new Matcher\VariablesMatcher(),
                new Matcher\ConstantsMatcher(),
                new Matcher\FunctionsMatcher(),
                new Matcher\ClassNamesMatcher(),
                new Matcher\ClassMethodsMatcher(),
                new Matcher\ClassAttributesMatcher(),
                new Matcher\ObjectMethodsMatcher(),
                new Matcher\ObjectAttributesMatcher(),
            );
        }

        return $this->tabCompletionMatchers;
    }

    /**
     * @param array $matchers
     */
    public function addTabCompletionMatchers(array $matchers)
    {
        $this->tabCompletionMatchers = array_merge($matchers, $this->getTabCompletionMatchers());
    }

    /**
     * Set the Shell output.
     *
     * @param OutputInterface $output
     */
    public function setOutput(OutputInterface $output)
    {
        $this->output = $output;
    }

    /**
     * Runs the current application.
     *
     * @param InputInterface  $input  An Input instance
     * @param OutputInterface $output An Output instance
     *
     * @return int 0 if everything went fine, or an error code
     */
    public function run(InputInterface $input = null, OutputInterface $output = null)
    {
        if ($input === null && !isset($_SERVER['argv'])) {
            $input = new ArgvInput(array());
        }

        if ($output === null) {
            $output = $this->config->getOutput();
        }

        try {
            return parent::run($input, $output);
        } catch (\Exception $e) {
            $this->writeException($e);
        }
    }

    /**
     * Runs the current application.
     *
     * @throws Exception if thrown via the `throw-up` command.
     *
     * @param InputInterface  $input  An Input instance
     * @param OutputInterface $output An Output instance
     *
     * @return int 0 if everything went fine, or an error code
     */
    public function doRun(InputInterface $input, OutputInterface $output)
    {
        $this->setOutput($output);

        $this->resetCodeBuffer();

        $this->setAutoExit(false);
        $this->setCatchExceptions(false);

        $this->readline->readHistory();

        // if ($this->config->useReadline()) {
        //     readline_completion_function(array($this, 'autocomplete'));
        // }

        $this->output->writeln($this->getHeader());

        try {
            $this->loop->run($this);
        } catch (ThrowUpException $e) {
            throw $e->getPrevious();
        }
    }

    /**
     * Read user input.
     *
     * This will continue fetching user input until the code buffer contains
     * valid code.
     *
     * @throws BreakException if user hits Ctrl+D
     */
    public function getInput()
    {
        $this->codeBufferOpen = false;

        do {
            // reset output verbosity (in case it was altered by a subcommand)
            $this->output->setVerbosity(ShellOutput::VERBOSITY_VERBOSE);

            $input = $this->readline();

            /*
             * Handle Ctrl+D. It behaves differently in different cases:
             *
             *   1) In an expression, like a function or "if" block, clear the input buffer
             *   2) At top-level session, behave like the exit command
             */
            if ($input === false) {
                $this->output->writeln('');

                if ($this->hasCode()) {
                    $this->resetCodeBuffer();
                } else {
                    throw new BreakException('Ctrl+D');
                }
            }

            // handle empty input
            if (trim($input) === '') {
                continue;
            }

            if ($this->hasCommand($input)) {
                $this->readline->addHistory($input);
                $this->runCommand($input);
                continue;
            }

            $this->addCode($input);
        } while (!$this->hasValidCode());
    }

    /**
     * Pass the beforeLoop callback through to the Loop instance.
     *
     * @see Loop::beforeLoop
     */
    public function beforeLoop()
    {
        $this->loop->beforeLoop();
    }

    /**
     * Pass the afterLoop callback through to the Loop instance.
     *
     * @see Loop::afterLoop
     */
    public function afterLoop()
    {
        $this->loop->afterLoop();
    }

    /**
     * Set the variables currently in scope.
     *
     * @param array $vars
     */
    public function setScopeVariables(array $vars)
    {
        $this->context->setAll($vars);
    }

    /**
     * Return the set of variables currently in scope.
     *
     * @return array Associative array of scope variables.
     */
    public function getScopeVariables()
    {
        return $this->context->getAll();
    }

    /**
     * Get the set of variable names currently in scope.
     *
     * @return array Array of variable names.
     */
    public function getScopeVariableNames()
    {
        return array_keys($this->context->getAll());
    }

    /**
     * Get a scope variable value by name.
     *
     * @param string $name
     *
     * @return mixed
     */
    public function getScopeVariable($name)
    {
        return $this->context->get($name);
    }

    /**
     * Add includes, to be parsed and executed before running the interactive shell.
     *
     * @param array $includes
     */
    public function setIncludes(array $includes = array())
    {
        $this->includes = $includes;
    }

    /**
     * Get PHP files to be parsed and executed before running the interactive shell.
     *
     * @return array
     */
    public function getIncludes()
    {
        return array_merge($this->config->getDefaultIncludes(), $this->includes);
    }

    /**
     * Check whether this shell's code buffer contains code.
     *
     * @return bool True if the code buffer contains code.
     */
    public function hasCode()
    {
        return !empty($this->codeBuffer);
    }

    /**
     * Check whether the code in this shell's code buffer is valid.
     *
     * If the code is valid, the code buffer should be flushed and evaluated.
     *
     * @return bool True if the code buffer content is valid.
     */
    protected function hasValidCode()
    {
        return !$this->codeBufferOpen && $this->code !== false;
    }

    /**
     * Add code to the code buffer.
     *
     * @param string $code
     */
    public function addCode($code)
    {
        try {
            // Code lines ending in \ keep the buffer open
            if (substr(rtrim($code), -1) === '\\') {
                $this->codeBufferOpen = true;
                $code = substr(rtrim($code), 0, -1);
            } else {
                $this->codeBufferOpen = false;
            }

            $this->codeBuffer[] = $code;
            $this->code         = $this->cleaner->clean($this->codeBuffer, $this->config->requireSemicolons());
        } catch (\Exception $e) {
            // Add failed code blocks to the readline history.
            $this->readline->addHistory(implode("\n", $this->codeBuffer));
            throw $e;
        }
    }

    /**
     * Get the current code buffer.
     *
     * This is useful for commands which manipulate the buffer.
     *
     * @return array
     */
    public function getCodeBuffer()
    {
        return $this->codeBuffer;
    }

    /**
     * Run a Psy Shell command given the user input.
     *
     * @throws InvalidArgumentException if the input is not a valid command.
     *
     * @param string $input User input string
     *
     * @return mixed Who knows?
     */
    protected function runCommand($input)
    {
        $command = $this->getCommand($input);

        if (empty($command)) {
            throw new \InvalidArgumentException('Command not found: ' . $input);
        }

        $input = new StringInput(str_replace('\\', '\\\\', rtrim($input, " \t\n\r\0\x0B;")));

        if ($input->hasParameterOption(array('--help', '-h'))) {
            $helpCommand = $this->get('help');
            $helpCommand->setCommand($command);

            return $helpCommand->run($input, $this->output);
        }

        return $command->run($input, $this->output);
    }

    /**
     * Reset the current code buffer.
     *
     * This should be run after evaluating user input, catching exceptions, or
     * on demand by commands such as BufferCommand.
     */
    public function resetCodeBuffer()
    {
        $this->codeBuffer = array();
        $this->code       = false;
    }

    /**
     * Inject input into the input buffer.
     *
     * This is useful for commands which want to replay history.
     *
     * @param string|array $input
     */
    public function addInput($input)
    {
        foreach ((array) $input as $line) {
            $this->inputBuffer[] = $line;
        }
    }

    /**
     * Flush the current (valid) code buffer.
     *
     * If the code buffer is valid, resets the code buffer and returns the
     * current code.
     *
     * @return string PHP code buffer contents.
     */
    public function flushCode()
    {
        if ($this->hasValidCode()) {
            $this->readline->addHistory(implode("\n", $this->codeBuffer));
            $code = $this->code;
            $this->resetCodeBuffer();

            return $code;
        }
    }

    /**
     * Get the current evaluation scope namespace.
     *
     * @see CodeCleaner::getNamespace
     *
     * @return string Current code namespace.
     */
    public function getNamespace()
    {
        if ($namespace = $this->cleaner->getNamespace()) {
            return implode('\\', $namespace);
        }
    }

    /**
     * Write a string to stdout.
     *
     * This is used by the shell loop for rendering output from evaluated code.
     *
     * @param string $out
     * @param int    $phase Output buffering phase
     */
    public function writeStdout($out, $phase = PHP_OUTPUT_HANDLER_END)
    {
        $isCleaning = false;
        if (version_compare(PHP_VERSION, '5.4', '>=')) {
            $isCleaning = $phase & PHP_OUTPUT_HANDLER_CLEAN;
        }

        // Incremental flush
        if (!empty($out) && !$isCleaning) {
            $this->output->write($out, false, ShellOutput::OUTPUT_RAW);
            $this->outputWantsNewline = (substr($out, -1) !== "\n");
        }

        // Output buffering is done!
        if ($this->outputWantsNewline && $phase & PHP_OUTPUT_HANDLER_END) {
            $this->output->writeln('<aside>⏎</aside>');
            $this->outputWantsNewline = false;
        }
    }

    /**
     * Write a return value to stdout.
     *
     * The return value is formatted or pretty-printed, and rendered in a
     * visibly distinct manner (in this case, as cyan).
     *
     * @see self::presentValue
     *
     * @param mixed $ret
     */
    public function writeReturnValue($ret)
    {
        $this->context->setReturnValue($ret);
        $ret    = $this->presentValue($ret);
        $indent = str_repeat(' ', strlen(self::RETVAL));

        $this->output->writeln(self::RETVAL . str_replace(PHP_EOL, PHP_EOL . $indent, $ret));
    }

    /**
     * Renders a caught Exception.
     *
     * Exceptions are formatted according to severity. ErrorExceptions which were
     * warnings or Strict errors aren't rendered as harshly as real errors.
     *
     * Stores $e as the last Exception in the Shell Context.
     *
     * @param \Exception      $e      An exception instance
     * @param OutputInterface $output An OutputInterface instance
     */
    public function writeException(\Exception $e)
    {
        $this->context->setLastException($e);

        $message = $e->getMessage();
        if (!$e instanceof PsyException) {
            $message = sprintf('%s with message \'%s\'', get_class($e), $message);
        }

        $severity = ($e instanceof \ErrorException) ? $this->getSeverity($e) : 'error';
        $this->output->writeln(sprintf('<%s>%s</%s>', $severity, OutputFormatter::escape($message), $severity));

        $this->resetCodeBuffer();
    }

    /**
     * Helper for getting an output style for the given ErrorException's level.
     *
     * @param \ErrorException $e
     *
     * @return string
     */
    protected function getSeverity(\ErrorException $e)
    {
        $severity = $e->getSeverity();
        if ($severity & error_reporting()) {
            switch ($severity) {
                case E_WARNING:
                case E_NOTICE:
                case E_CORE_WARNING:
                case E_COMPILE_WARNING:
                case E_USER_WARNING:
                case E_USER_NOTICE:
                case E_STRICT:
                    return 'warning';

                default:
                    return 'error';
            }
        } else {
            // Since this is below the user's reporting threshold, it's always going to be a warning.
            return 'warning';
        }
    }

    /**
     * Helper for throwing an ErrorException.
     *
     * This allows us to:
     *
     *     set_error_handler(array($psysh, 'handleError'));
     *
     * Unlike ErrorException::throwException, this error handler respects the
     * current error_reporting level; i.e. it logs warnings and notices, but
     * doesn't throw an exception unless it's above the current error_reporting
     * threshold. This should probably only be used in the inner execution loop
     * of the shell, as most of the time a thrown exception is much more useful.
     *
     * If the error type matches the `errorLoggingLevel` config, it will be
     * logged as well, regardless of the `error_reporting` level.
     *
     * @see \Psy\Exception\ErrorException::throwException
     * @see \Psy\Shell::writeException
     *
     * @throws \Psy\Exception\ErrorException depending on the current error_reporting level.
     *
     * @param int    $errno   Error type
     * @param string $errstr  Message
     * @param string $errfile Filename
     * @param int    $errline Line number
     */
    public function handleError($errno, $errstr, $errfile, $errline)
    {
        if ($errno & error_reporting()) {
            ErrorException::throwException($errno, $errstr, $errfile, $errline);
        } elseif ($errno & $this->config->errorLoggingLevel()) {
            // log it and continue...
            $this->writeException(new ErrorException($errstr, 0, $errno, $errfile, $errline));
        }
    }

    /**
     * Format a value for display.
     *
     * @see Presenter::present
     *
     * @param mixed $val
     *
     * @return string Formatted value
     */
    protected function presentValue($val)
    {
        return $this->config->getPresenter()->present($val);
    }

    /**
     * Get a command (if one exists) for the current input string.
     *
     * @param string $input
     *
     * @return null|Command
     */
    protected function getCommand($input)
    {
        $input = new StringInput($input);
        if ($name = $input->getFirstArgument()) {
            return $this->get($name);
        }
    }

    /**
     * Check whether a command is set for the current input string.
     *
     * @param string $input
     *
     * @return bool True if the shell has a command for the given input.
     */
    protected function hasCommand($input)
    {
        $input = new StringInput($input);
        if ($name = $input->getFirstArgument()) {
            return $this->has($name);
        }

        return false;
    }

    /**
     * Get the current input prompt.
     *
     * @return string
     */
    protected function getPrompt()
    {
        return $this->hasCode() ? self::BUFF_PROMPT : self::PROMPT;
    }

    /**
     * Read a line of user input.
     *
     * This will return a line from the input buffer (if any exist). Otherwise,
     * it will ask the user for input.
     *
     * If readline is enabled, this delegates to readline. Otherwise, it's an
     * ugly `fgets` call.
     *
     * @return string One line of user input.
     */
    protected function readline()
    {
        if (!empty($this->inputBuffer)) {
            $line = array_shift($this->inputBuffer);
            $this->output->writeln(sprintf('<aside>%s %s</aside>', self::REPLAY, OutputFormatter::escape($line)));

            return $line;
        }

        return $this->readline->readline($this->getPrompt());
    }

    /**
     * Get the shell output header.
     *
     * @return string
     */
    protected function getHeader()
    {
        return sprintf('<aside>%s by Justin Hileman</aside>', $this->getVersion());
    }

    /**
     * Get the current version of Psy Shell.
     *
     * @return string
     */
    public function getVersion()
    {
        return sprintf('Psy Shell %s (PHP %s — %s)', self::VERSION, phpversion(), php_sapi_name());
    }

    /**
     * Get a PHP manual database instance.
     *
     * @return PDO|null
     */
    public function getManualDb()
    {
        return $this->config->getManualDb();
    }

    /**
     * Autocomplete variable names.
     *
     * This is used by `readline` for tab completion.
     *
     * @param string $text
     *
     * @return mixed Array possible completions for the given input, if any.
     */
    protected function autocomplete($text)
    {
        $info = readline_info();
        // $line = substr($info['line_buffer'], 0, $info['end']);

        // Check whether there's a command for this
        // $words = explode(' ', $line);
        // $firstWord = reset($words);

        // check whether this is a variable...
        $firstChar = substr($info['line_buffer'], max(0, $info['end'] - strlen($text) - 1), 1);
        if ($firstChar === '$') {
            return $this->getScopeVariableNames();
        }
    }
}


text:
layout: post
title: Hexo
date:  2017-03-29 20:45:58 +0800
categories: [UI]
tags: [hexo, blog]
header-img: "static/app/res/img/kon-bg.jpeg"
published: true
---

# Hexo

[Hexo](https://hexo.io/) is a fast, simple & powerful blog framework.

一直使用的是 [jekyll](https://houbb.github.io/2016/04/13/jekyll),文章越写越多,不太好管理。是时候换个博客尝试一下。

# Prepare

> [blog zh_CN](http://www.jianshu.com/p/465830080ea9)

本机为 MAC。不同系统会略有不同,但是大同小异。

- [Node.js](https://nodejs.org/)

必须。

作用:用来生成静态页面的。

```
houbinbindeMacBook-Pro:~ houbinbin$ node -v
v6.2.2
```

- [Git](https://git-scm.com/)

必须。

作用:代码仓库管理。

```
houbinbindeMacBook-Pro:~ houbinbin$ git --version
git version 2.8.1
```

- [Github](https://github.com/)

申请个账号。我相信你应该知道。

# Install

- 下载安装 hexo

找一个你想放置blog的文件夹,执行:

```
sudo npm install -g hexo-cli
```

实际操作:

```
houbinbindeMacBook-Pro:fork houbinbin$ pwd
/Users/houbinbin/it/fork
houbinbindeMacBook-Pro:fork houbinbin$ npm install -g hexo-cli
fetchMetadata → network  。。。。
```

- 测试

等待下载完成。输入命令 `hexo`

```
houbinbindeMacBook-Pro:fork houbinbin$ hexo
Usage: hexo <command>

Commands:
  help     Get help on a command.
  init     Create a new Hexo folder.
  version  Display version information.

Global Options:
  --config  Specify config file instead of using _config.yml
  --cwd     Specify the CWD
  --debug   Display all verbose messages in the terminal
  --draft   Display draft posts
  --safe    Disable all plugins and scripts
  --silent  Hide output on console

For more help, you can use 'hexo help [command]' for the detailed information
or you can check the docs: http://hexo.io/docs/
```

- 初始化博客

```
// 建立一个博客文件夹,并初始化博客,<folder>为文件夹的名称,可以随便起名字
$ hexo init <folder>
// 进入博客文件夹,<folder>为文件夹的名称
$ cd <folder>
// node.js的命令,根据博客既定的dependencies配置安装所有的依赖包
$ npm install
```

此处为了方便, 直接使用 `XXX.github.io` 命名。
实际操作

```
houbinbindeMacBook-Pro:fork houbinbin$ hexo init ryo.github.io
INFO  Cloning hexo-starter to ~/IT/fork/ryo.github.io
Cloning into '/Users/houbinbin/IT/fork/ryo.github.io'...
remote: Counting objects: 53, done.
remote: Total 53 (delta 0), reused 0 (delta 0), pack-reused 53
Unpacking objects: 100% (53/53), done.
Checking connectivity... done.
Submodule 'themes/landscape' (https://github.com/hexojs/hexo-theme-landscape.git) registered for path 'themes/landscape'
Cloning into 'themes/landscape'...
remote: Counting objects: 764, done.
remote: Total 764 (delta 0), reused 0 (delta 0), pack-reused 764
Receiving objects: 100% (764/764), 2.53 MiB | 130.00 KiB/s, done.
Resolving deltas: 100% (390/390), done.
Checking connectivity... done.
Submodule path 'themes/landscape': checked out 'decdc2d9956776cbe95420ae94bac87e22468d38'
INFO  Install dependencies
npm WARN deprecated swig@1.4.2: This package is no longer maintained
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN prefer global marked@0.3.6 should be installed with -g

> fsevents@1.1.1 install /Users/houbinbin/IT/fork/ryo.github.io/node_modules/fsevents
> node install

[fsevents] Success: "/Users/houbinbin/IT/fork/ryo.github.io/node_modules/fsevents/lib/binding/Release/node-v48-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile

> dtrace-provider@0.8.1 install /Users/houbinbin/IT/fork/ryo.github.io/node_modules/dtrace-provider
> node scripts/install.js
```

新开一个窗口

```
houbinbindeMacBook-Pro:blog houbinbin$ pwd
/Users/houbinbin/it/fork/ryo.github.io
houbinbindeMacBook-Pro:blog houbinbin$ npm install
houbinbindeMacBook-Pro:blog houbinbin$ ls
_config.yml	node_modules	package.json	scaffolds	source		themes
```

# config blog

类似 jekyll,需要修改 `_config.yml`文件。

> 修改网站相关信息

```
title: echo blog
subtitle: the blog of ryo
description: One Echo, Endless Miss
author: ryo
language: zh-CN
timezone: Asia/Shanghai
```

> 配置统一资源定位符(个人域名)

```
url: https://ryo.github.io
```

对于root(根目录)、permalink(永久链接)、permalink_defaults(默认永久链接)等其他信息保持默认。

> 配置部署

```
deploy:
  type: git
  repo: https://github.com/houbb/ryo.github.io.git
  branch: master
```

# Hello World

- 新建一篇文章

```
// 新建一篇文章
hexo new "文章标题"
```

实际:

```
houbinbindeMacBook-Pro:ryo.github.io houbinbin$ hexo new "helloworld"
INFO  Created: ~/IT/fork/ryo.github.io/source/_posts/helloworld.md
```

- 启动服务

```
hexo server
```

实际

```
houbinbindeMacBook-Pro:ryo.github.io houbinbin$ hexo server
INFO  Start processing
INFO  Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.
```

![hello world](https://raw.githubusercontent.com/houbb/resource/master/img/hexo/2017-03-29-hexo-helloworld.png)

# 博客发布

```
$ hexo generate
$ hexo deploy
```

前面的 `deploy` 已经指定了其对应的 github 仓库。你可以在github上创建一个 `XXX.github.io` 项目,或者使用其他方式。

其中 **XXX** 是你的github用户名。我以前使用 jekyll 已经占用一个了。此处先演示本地。

实际操作:

```
houbinbindeMacBook-Pro:ryo.github.io houbinbin$ hexo generate
INFO  Start processing
INFO  Files loaded in 177 ms
INFO  Generated: index.html
INFO  Generated: archives/index.html
INFO  Generated: fancybox/blank.gif
INFO  Generated: fancybox/jquery.fancybox.css
INFO  Generated: fancybox/jquery.fancybox.pack.js
INFO  Generated: fancybox/fancybox_loading.gif
INFO  Generated: fancybox/jquery.fancybox.js
INFO  Generated: fancybox/fancybox_overlay.png
INFO  Generated: fancybox/fancybox_loading@2x.gif
INFO  Generated: fancybox/fancybox_sprite.png
INFO  Generated: fancybox/fancybox_sprite@2x.png
INFO  Generated: archives/2017/03/index.html
INFO  Generated: archives/2017/index.html
INFO  Generated: css/fonts/FontAwesome.otf
INFO  Generated: js/script.js
INFO  Generated: fancybox/helpers/jquery.fancybox-buttons.js
INFO  Generated: fancybox/helpers/jquery.fancybox-buttons.css
INFO  Generated: fancybox/helpers/jquery.fancybox-thumbs.css
INFO  Generated: fancybox/helpers/jquery.fancybox-thumbs.js
INFO  Generated: css/style.css
INFO  Generated: css/fonts/fontawesome-webfont.woff
INFO  Generated: fancybox/helpers/jquery.fancybox-media.js
INFO  Generated: css/fonts/fontawesome-webfont.eot
INFO  Generated: fancybox/helpers/fancybox_buttons.png
INFO  Generated: css/images/banner.jpg
INFO  Generated: css/fonts/fontawesome-webfont.svg
INFO  Generated: css/fonts/fontawesome-webfont.ttf
INFO  Generated: 2017/03/29/hello-world/index.html
INFO  28 files generated in 656 ms
```

<label class="label label-danger">Deployer not found</label>

解决方式 `npm install hexo-deployer-git --save`

```
houbinbindeMacBook-Pro:ryo.github.io houbinbin$ hexo deploy
ERROR Deployer not found: github
houbinbindeMacBook-Pro:ryo.github.io houbinbin$ npm install hexo-deployer-git --save
hexo-site@0.0.0 /Users/houbinbin/IT/fork/ryo.github.io
`-- hexo-deployer-git@0.2.0
```

重新运行

```
houbinbindeMacBook-Pro:ryo.github.io houbinbin$ hexo deploy
INFO  Deploying: git
INFO  Setting up Git deployment...
Initialized empty Git repository in /Users/houbinbin/IT/fork/ryo.github.io/.deploy_git/.git/
[master (root-commit) 29675e7] First commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 placeholder
INFO  Clearing .deploy_git folder...
INFO  Copying files from public folder...
[master 02b7255] Site updated: 2017-03-29 23:17:16
 29 files changed, 5793 insertions(+)
 create mode 100644 2017/03/29/hello-world/index.html
 create mode 100644 archives/2017/03/index.html
 create mode 100644 archives/2017/index.html
 create mode 100644 archives/index.html
 create mode 100644 css/fonts/FontAwesome.otf
 create mode 100644 css/fonts/fontawesome-webfont.eot
 create mode 100644 css/fonts/fontawesome-webfont.svg
 create mode 100644 css/fonts/fontawesome-webfont.ttf
 create mode 100644 css/fonts/fontawesome-webfont.woff
 create mode 100644 css/images/banner.jpg
 create mode 100644 css/style.css
 create mode 100644 fancybox/blank.gif
 create mode 100644 fancybox/fancybox_loading.gif
 create mode 100644 fancybox/fancybox_loading@2x.gif
 create mode 100644 fancybox/fancybox_overlay.png
 create mode 100644 fancybox/fancybox_sprite.png
 create mode 100644 fancybox/fancybox_sprite@2x.png
 create mode 100644 fancybox/helpers/fancybox_buttons.png
 create mode 100644 fancybox/helpers/jquery.fancybox-buttons.css
 create mode 100644 fancybox/helpers/jquery.fancybox-buttons.js
 create mode 100644 fancybox/helpers/jquery.fancybox-media.js
 create mode 100644 fancybox/helpers/jquery.fancybox-thumbs.css
 create mode 100644 fancybox/helpers/jquery.fancybox-thumbs.js
 create mode 100644 fancybox/jquery.fancybox.css
 create mode 100644 fancybox/jquery.fancybox.js
 create mode 100644 fancybox/jquery.fancybox.pack.js
 create mode 100644 index.html
 create mode 100644 js/script.js
 delete mode 100644 placeholder
To https://github.com/houbb/ryo.github.io.git
 + 921a4a1...02b7255 HEAD -> master (forced update)
Branch master set up to track remote branch master from https://github.com/houbb/ryo.github.io.git.
INFO  Deploy done: git
```

# Windows 安装记录

## 准备工作

-  安装 Node(必须)

官方 [https://nodejs.org/en/](https://nodejs.org/en/) 下载安装即可。

```
node -v
v12.16.2
```

- git 安装

```
git --version
git version 2.24.0.rc1.windows.1
```

- github 申请

## 正式使用

- 安装 hexo

```
npm install -g hexo-cli
```

- 初始化文件夹

```
$ hexo init itbook52.github.io
$ cd itbook52.github.io
```

这个目标文件夹必须为空

生成的文件信息

```
$ ls
_config.yml  db.json  node_modules/  package.json  package-lock.json  scaffolds/  source/  themes/
```

## 修改配置

为了更方便的使用,我们修改一下 `_config.yml` 配置文件。

- 原始内容

```yml
# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: Hexo
subtitle: ''
description: ''
keywords:
author: John Doe
language: en
timezone: ''

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://yoursite.com
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:
pretty_urls:
  trailing_index: true # Set to false to remove trailing 'index.html' from permalinks
  trailing_html: true # Set to false to remove trailing '.html' from permalinks

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link:
  enable: true # Open external links in new tab
  field: site # Apply to the whole site
  exclude: ''
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
  enable: true
  line_number: true
  auto_detect: false
  tab_replace: ''
  wrap: true
  hljs: false

# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
  path: ''
  per_page: 10
  order_by: -date

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Metadata elements
## https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
meta_generator: true

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss
## Use post's date for updated date unless set in front-matter
use_date_for_updated: false

# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

# Include / Exclude file(s)
## include:/exclude: options only apply to the 'source/' folder
include:
exclude:
ignore:

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: landscape

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: ''
```

- 修改后

主要修改以下三个部分的内容:

```yml
title: IT Books
subtitle: the it books
description: 收集常见的 it 书籍,供学习之用
author: ryo
language: zh-CN
timezone: Asia/Shanghai

url: https://itbook52.github.io

deploy:
  type: git
  repo: https://github.com/itbook52/itbook52.github.io.git
  branch: master
```

## 运行

- 新建博客

```
hexo new "helloworld"
```

- 启动

```
hexo server
```

通过 [http://localhost:4000](http://localhost:4000) 可以访问。

## 生成与发布

- 生成静态文件

```
$ hexo generate
```

- 将本地文件与远程进行管理

```
git init
git add *
git commit -m "first commit"
git remote add origin https://github.com/itbook52/itbook52.github.io.git
git push -u origin master
```

- 部署

```
$ hexo deploy
```

报错:

```
ERROR Deployer not found: git
```

执行

```
npm install --save hexo-deployer-git
```

重新执行即可。

# 主题

## 主题列表

[主题](https://github.com/hexojs/hexo/wiki/Themes)

## 推荐主题

[hexo-theme-next](https://notes.iissnan.com/)

[hexo-theme-yilia](http://litten.me/)

## 使用 next 主题

```
$ pwd
D:\_github\itbook52.github.io
```

在 blog 的 themes 目录下,下载 next 主题。

```
$ git clone https://github.com/theme-next/hexo-theme-next themes/next
```

将主题直接下载到对应的 themes\next 目录下。

## 配置 _config.yml

配置主题为 next

```
theme: next
```

## 启动

- 清空历史数据

```
hexo clean
```

- 启动服务

```
hexo server
```

再次访问即可 [http://localhost:4000/](http://localhost:4000/)

# 添加本地搜索

## 安装

安装 hexo-generator-searchdb,在站点的根目录下执行以下命令:

```
npm install hexo-generator-searchdb --save
```

## 编辑配置

编辑站点配置文件,新增以下内容到任意位置:

```yml
search:
  path: search.xml
  field: post
  format: html
  limit: 10000
```

## 编辑主题配置文件

启用本地搜索功能:

```yml
# Local search
local_search:
  enable: true
```

# 报错

```
INFO  Start processing
FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Template render error: (unknown path)
  Error: expected end of comment, got end of file
```

## 原因

```
hexo 中 {# 属于吧保留字,会报错。
```

## 解决方案

将 `{` 与 `#` 拆开写。

# 参考资料

[hexo-theme-next](https://github.com/theme-next)

[Hexo个人博客NexT主题添加Local Search本地搜索](https://blog.csdn.net/mqdxiaoxiao/article/details/93257866)

* any list
{:toc}

redpajama_set_name: RedPajamaGithub


text:
var fromArray = require( 'flow-from-array' ),
	append = require( './../lib' ).objectMode;

// Create some data...
var data = new Array( 1000 );
for ( var i = 0; i < data.length; i++ ) {
	data[ i ] = Math.random();
}

// Create a readable stream:
var readableStream = fromArray( data );

// Pipe the data:
readableStream
	.pipe( append( '\n' ) )
	.pipe( process.stdout );


text:
namespace Senparc.Weixin.Work.Entities
{
    /// <summary>
    /// 变更授权的通知
    /// </summary>
    public class RequestMessageInfo_Create_Auth : ThirdPartyInfoBase, IThirdPartyInfoBase
    {
        public override ThirdPartyInfo InfoType
        {
            get { return ThirdPartyInfo.CREATE_AUTH; }
        }

        /// <summary>
        /// 授权的auth_code,用于获取企业的永久授权码
        /// </summary>
        public string AuthCode { get; set; }
    }
}


text:
<? include "include/basketball_menu.php"; ?>

      Custom - Sublimated Singlets

Choose your colours and select from our designs or design your own.

        Logos, school/club names and numbers included.

Sizes: Mens, Ladies and Childrens
Styles: V neck, Round neck, Female, Male

See also: <a href="<?=base_url()?>apparel/basketball_diy_shorts">Matching sublimated shorts

<a href="<?=base_url()?>images/apparel/basketball/singlets/s1-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s1.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s1-large.jpg" rel="thumbnail">S1

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb1">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB1.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s2-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s2.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s2-large.jpg" rel="thumbnail">S2

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb2">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB2.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s3-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s3.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s3-large.jpg" rel="thumbnail">S3

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb3">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB3.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s4-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s4.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s4-large.jpg" rel="thumbnail">S4

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb4">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB4.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s5-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s5.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s5-large.jpg" rel="thumbnail">S5

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb5">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB5.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s6-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s6.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s6-large.jpg" rel="thumbnail">S6

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb6">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB6.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s7-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s7.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s7-large.jpg" rel="thumbnail">S7

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb7">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB7.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s8-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s8.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s8-large.jpg" rel="thumbnail">S8

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb8">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB8.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s9-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s9.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s9-large.jpg" rel="thumbnail">S9

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb9">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB9.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s10-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s10.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s10-large.jpg" rel="thumbnail">S10

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb10">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB10.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s11-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s11.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s11-large.jpg" rel="thumbnail">S11

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb11">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB11.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s12-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s12.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s12-large.jpg" rel="thumbnail">S12

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb12">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB12.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s13-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s13.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s13-large.jpg" rel="thumbnail">S13

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb13">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB13.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s14-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s14.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s14-large.jpg" rel="thumbnail">S14

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb14">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB14.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s15-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s15.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s15-large.jpg" rel="thumbnail">S15

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb15">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB15.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s16-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s16.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s16-large.jpg" rel="thumbnail">S16

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb16">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB16.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s17-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s17.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s17-large.jpg" rel="thumbnail">S17

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb17">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB17.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s18-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s18.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s18-large.jpg" rel="thumbnail">S18

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb18">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB18.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s19-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s19.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s19-large.jpg" rel="thumbnail">S19

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb19">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB19.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s20-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s20.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s20-large.jpg" rel="thumbnail">S20

 <a href="<?=base_url()?>apparel/diy_basketball/rhsb20">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSB20.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s21-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s21.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s21-large.jpg" rel="thumbnail">S21

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf1">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF1.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s22-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s22.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s22-large.jpg" rel="thumbnail">S22

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf2">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF2.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s23-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s23.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s23-large.jpg" rel="thumbnail">S23

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf3">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF3.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s24-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s24.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s24-large.jpg" rel="thumbnail">S24

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf4">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF4.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s25-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s25.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s25-large.jpg" rel="thumbnail">S25

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf5">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF5.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s26-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s26.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s26-large.jpg" rel="thumbnail">S26

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf6">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF6.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s27-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s27.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s27-large.jpg" rel="thumbnail">S27

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf7">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF7.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s28-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s28.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s28-large.jpg" rel="thumbnail">S28

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf8">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF8.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s29-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s29.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s29-large.jpg" rel="thumbnail">S29

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf9">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF9.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s30-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s30.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s30-large.jpg" rel="thumbnail">S30

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf10">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF10.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s31-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s31.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s31-large.jpg" rel="thumbnail">S31

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf11">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF11.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s32-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s32.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s32-large.jpg" rel="thumbnail">S32

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf12">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF12.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s33-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s33.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s33-large.jpg" rel="thumbnail">S33

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf13">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF13.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s34-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s34.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s34-large.jpg" rel="thumbnail">S34

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf14">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF14.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s35-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s35.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s35-large.jpg" rel="thumbnail">S35

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf15">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF15.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s36-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s36.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s36-large.jpg" rel="thumbnail">S36

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf16">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF16.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s37-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s37.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s37-large.jpg" rel="thumbnail">S37

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf17">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF17.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s38-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s38.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s38-large.jpg" rel="thumbnail">S38

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf18">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF18.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s39-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s39.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s39-large.jpg" rel="thumbnail">S39

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf19">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF19.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s40-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s40.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s40-large.jpg" rel="thumbnail">S40

 <a href="<?=base_url()?>apparel/diy_basketball/rhsf20">+ DIY Template

    <a href="<?=base_url()?>images/apparel/pdf/RHSF20.pdf" target="_blank">+ Design Request Form

<a href="<?=base_url()?>images/apparel/basketball/singlets/s41-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s41.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s41-large.jpg" rel="thumbnail">S41

<a href="<?=base_url()?>images/apparel/basketball/singlets/s42-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s42.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s42-large.jpg" rel="thumbnail">S42

<a href="<?=base_url()?>images/apparel/basketball/singlets/s43-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s43.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s43-large.jpg" rel="thumbnail">S43

<a href="<?=base_url()?>images/apparel/basketball/singlets/s44-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s44.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s44-large.jpg" rel="thumbnail">S44

<a href="<?=base_url()?>images/apparel/basketball/singlets/s45-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s45.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s45-large.jpg" rel="thumbnail">S45

<a href="<?=base_url()?>images/apparel/basketball/singlets/s46-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s46.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s46-large.jpg" rel="thumbnail">S46

<a href="<?=base_url()?>images/apparel/basketball/singlets/s47-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s47.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s47-large.jpg" rel="thumbnail">S47

<a href="<?=base_url()?>images/apparel/basketball/singlets/s48-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s48.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s48-large.jpg" rel="thumbnail">S48

<a href="<?=base_url()?>images/apparel/basketball/singlets/s49-large.jpg" rel="thumbnail"><img src="<?=base_url()?>images/apparel/basketball/singlets/s49.jpg" height="160" width="130" border="0">

<a href="<?=base_url()?>images/apparel/basketball/singlets/s49-large.jpg" rel="thumbnail">S49


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NoteStatistics
{
    class NoteStatistics
    {
        static void Main(string[] args)
        {
            var freqChart = new Dictionary<string, double>();
            freqChart["C"] = 261.63;
            freqChart["C#"] = 277.18;
            freqChart["D"] = 293.66;
            freqChart["D#"] = 311.13;
            freqChart["E"] = 329.63;
            freqChart["F"] = 349.23;
            freqChart["F#"] = 369.99;
            freqChart["G"] = 392.00;
            freqChart["G#"] = 415.30;
            freqChart["A"] = 440.00;
            freqChart["A#"] = 466.16;
            freqChart["B"] = 493.88;

            List<string> possibleNotes = freqChart.Keys.ToList();
            List<double> possibleFreqs = freqChart.Values.ToList();

            List<double> frequences = Console.ReadLine().Split().Select(double.Parse).ToList();

            List<string> notes = new List<string>();
            List<string> naturalNotes = new List<string>();
            List<string> sharpNotes = new List<string>();
            double naturalsSum = 0;
            double sharpsSum = 0;

            for (int i = 0; i < frequences.Count; i++)
            {
                double currentFreq = frequences[i];
                int index = possibleFreqs.IndexOf(currentFreq);

                notes.Add(possibleNotes[index]);
                if (notes[i].Contains("#"))
                {
                    sharpNotes.Add(possibleNotes[index]);
                    sharpsSum += possibleFreqs[index];
                }
                else
                {
                    naturalNotes.Add(possibleNotes[index]);
                    naturalsSum += possibleFreqs[index];
                }
            }

            Console.WriteLine("Notes: " + string.Join(" ", notes));
            Console.WriteLine("Naturals: " + string.Join(", ", naturalNotes));
            Console.WriteLine("Sharps: " + string.Join(", ", sharpNotes));
            Console.WriteLine("Naturals sum: {0:0.##}", naturalsSum);
            Console.WriteLine("Sharps sum: {0:0.##}", sharpsSum);

            foreach (var item in frequences)
            {
                Console.Beep((int)item, 400);
            }
        }
    }
}


text:
import { Formatter } from '../types';

/**
 * Generates a random Base64 encoded character string
 *
 * @method     byte
 * @param      {Object}  gen - The genator object passed from json-schema-faker
 * @return     {string}      - A base64 encoded string of characters
 */
function byte(gen: any): string {
  const randomWord = gen.faker.random.words();
  const buff = new Buffer(randomWord);
  const base64Encoded = buff.toString('base64');

  return base64Encoded;
}

export const byteFormatter: Formatter = { formatName: 'byte', callback: byte };


text:
ALTER TABLE users ADD COLUMN language VARCHAR(16);

ALTER TABLE notifications ADD COLUMN message_args VARCHAR(255)[];
UPDATE notifications SET message_args = ARRAY[message];

ALTER TABLE notifications DROP COLUMN message;

# --- !Downs

ALTER TABLE users DROP COLUMN language;

ALTER TABLE notifications ADD COLUMN message VARCHAR(255);
UPDATE notifications SET message = message_args[0];

ALTER TABLE notifications DROP COLUMN message_args;


text:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//NetBeans//DTD Module Status 1.0//EN"
                        "http://www.netbeans.org/dtds/module-status-1_0.dtd">
<module name="org.netbeans.modules.mobility.project.bridge">
    <param name="autoload">false</param>
    <param name="eager">false</param>
    <param name="enabled">false</param>
    <param name="jar">modules/org-netbeans-modules-mobility-project-bridge.jar</param>
    <param name="reloadable">false</param>
</module>


text:
<?php

namespace Witty\BarBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

class BarController extends Controller
{
    /**
     * @Template()
     */
    public function displayAction()
    {
        return $this->render('WittyBarBundle:Bar:index.html.twig', array());
    }
}


text:
include_recipe 'bcs_common_system::basic'
include_recipe 'bcs_common_system::server'


text:
package ml.shifu.shifu.core.correlation;

import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Counter;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.JobContext;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.OutputCommitter;
import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.hadoop.mapreduce.RecordWriter;
import org.apache.hadoop.mapreduce.StatusReporter;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.TaskAttemptID;
import org.apache.hadoop.util.ReflectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Copy from MultithreadedMapper to do some customization. Merge mapper output results and then write to reducer.
 *
 * @author Zhang David (pengzhang@paypal.com)
 */
@InterfaceAudience.Public
@InterfaceStability.Stable
public class FastCorrelationMultithreadedMapper extends Mapper<LongWritable, Text, IntWritable, CorrelationWritable> {

    private final static Logger LOG = LoggerFactory.getLogger(FastCorrelationMultithreadedMapper.class);
    public static String NUM_THREADS = "mapreduce.mapper.multithreadedmapper.threads";
    public static String MAP_CLASS = "mapreduce.mapper.multithreadedmapper.mapclass";

    private Class<? extends Mapper<LongWritable, Text, IntWritable, CorrelationWritable>> mapClass;
    private Context outer;
    private List<MapRunner> runners;

    private Map<Integer, CorrelationWritable> finalCorrelationMap;

    /**
     * Output key cache to avoid new operation.
     */
    private IntWritable outputKey;

    /**
     * The number of threads in the thread pool that will run the map function.
     *
     * @param job
     *            the job
     * @return the number of threads
     */
    public static int getNumberOfThreads(JobContext job) {
        return job.getConfiguration().getInt(NUM_THREADS, 10);
    }

    /**
     * Set the number of threads in the pool for running maps.
     *
     * @param job
     *            the job to modify
     * @param threads
     *            the new number of threads
     */
    public static void setNumberOfThreads(Job job, int threads) {
        job.getConfiguration().setInt(NUM_THREADS, threads);
    }

    /**
     * Get the application's mapper class.
     *
     * @param <K1>
     *            the map's input key type
     * @param <V1>
     *            the map's input value type
     * @param <K2>
     *            the map's output key type
     * @param <V2>
     *            the map's output value type
     * @param job
     *            the job
     * @return the mapper class to run
     */
    @SuppressWarnings("unchecked")
    public static <K1, V1, K2, V2> Class<Mapper<K1, V1, K2, V2>> getMapperClass(JobContext job) {
        return (Class<Mapper<K1, V1, K2, V2>>) job.getConfiguration().getClass(MAP_CLASS, Mapper.class);
    }

    /**
     * Set the application's mapper class.
     *
     * @param <K1>
     *            the map input key type
     * @param <V1>
     *            the map input value type
     * @param <K2>
     *            the map output key type
     * @param <V2>
     *            the map output value type
     * @param job
     *            the job to modify
     * @param cls
     *            the class to use as the mapper
     */
    public static <K1, V1, K2, V2> void setMapperClass(Job job, Class<? extends Mapper<K1, V1, K2, V2>> cls) {
        if(FastCorrelationMultithreadedMapper.class.isAssignableFrom(cls)) {
            throw new IllegalArgumentException("Can't have recursive " + "MultithreadedMapper instances.");
        }
        job.getConfiguration().setClass(MAP_CLASS, cls, Mapper.class);
    }

    /**
     * Run the application's maps using a thread pool.
     */
    @Override
    public void run(Context context) throws IOException, InterruptedException {
        outer = context;
        this.finalCorrelationMap = new HashMap<Integer, CorrelationWritable>();

        int numberOfThreads = getNumberOfThreads(context);
        mapClass = getMapperClass(context);
        if(LOG.isDebugEnabled()) {
            LOG.debug("Configuring multithread runner to use " + numberOfThreads + " threads");
        }

        runners = new ArrayList<MapRunner>(numberOfThreads);
        for(int i = 0; i < numberOfThreads; ++i) {
            MapRunner thread = new MapRunner(context);
            thread.start();
            runners.add(i, thread);
        }
        for(int i = 0; i < numberOfThreads; ++i) {
            MapRunner thread = runners.get(i);
            thread.join();
            Throwable th = thread.throwable;
            if(th != null) {
                if(th instanceof IOException) {
                    throw (IOException) th;
                } else if(th instanceof InterruptedException) {
                    throw (InterruptedException) th;
                } else {
                    throw new RuntimeException(th);
                }
            }
        }

        outputKey = new IntWritable();

        // after all sub mapper completed, finalCorrelationMap includes global results and send them to reducer.
        // send to reducer with only one merged copy no matter how many threads
        synchronized(outer) {
            for(Entry<Integer, CorrelationWritable> entry: finalCorrelationMap.entrySet()) {
                if (entry.getValue().isValid()) {
                    outputKey.set(entry.getKey());
                    context.write(outputKey, entry.getValue());
                } else {
                    LOG.warn("Key: {} final correlation writable is not init, skip passing to reducer", entry.getKey());
                }
            }
        }
    }

    private class SubMapRecordReader extends RecordReader<LongWritable, Text> {
        private LongWritable key;
        private Text value;
        private Configuration conf;

        @Override
        public void close() throws IOException {
        }

        @Override
        public float getProgress() throws IOException, InterruptedException {
            return 0;
        }

        @Override
        public void initialize(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException {
            conf = context.getConfiguration();
        }

        @Override
        public boolean nextKeyValue() throws IOException, InterruptedException {
            synchronized(outer) {
                if(!outer.nextKeyValue()) {
                    return false;
                }
                key = ReflectionUtils.copy(outer.getConfiguration(), outer.getCurrentKey(), key);
                value = ReflectionUtils.copy(conf, outer.getCurrentValue(), value);
                return true;
            }
        }

        public LongWritable getCurrentKey() {
            return key;
        }

        @Override
        public Text getCurrentValue() {
            return value;
        }
    }

    private class SubMapRecordWriter extends RecordWriter<IntWritable, CorrelationWritable> {

        @Override
        public void close(TaskAttemptContext context) throws IOException, InterruptedException {
        }

        @Override
        public void write(IntWritable key, CorrelationWritable value) throws IOException, InterruptedException {
            synchronized(outer) {
                // replace outer.write by merge to one global corrMap
                CorrelationWritable cw = FastCorrelationMultithreadedMapper.this.finalCorrelationMap.get(key.get());
                if(cw == null) {
                    cw = value;
                } else {
                    cw.combine(value);
                }
                FastCorrelationMultithreadedMapper.this.finalCorrelationMap.put(key.get(), cw);
            }
        }
    }

    private class SubMapStatusReporter extends StatusReporter {

        @Override
        public Counter getCounter(Enum<?> name) {
            return outer.getCounter(name);
        }

        @Override
        public Counter getCounter(String group, String name) {
            return outer.getCounter(group, name);
        }

        @Override
        public void progress() {
            outer.progress();
        }

        @Override
        public void setStatus(String status) {
            outer.setStatus(status);
        }

        public float getProgress() {
            try {
                Method method = outer.getClass().getDeclaredMethod("getProgress", new Class[] {});
                if(method != null) {
                    return (Float) (method.invoke(outer, new Object[] {}));
                }
            } catch (Throwable e) {
                return 0f;
            }
            return 0f;
        }
    }

    private class MapRunner extends Thread {
        private Mapper<LongWritable, Text, IntWritable, CorrelationWritable> mapper;
        private Context subcontext;
        private Throwable throwable;
        private RecordReader<LongWritable, Text> reader = new SubMapRecordReader();

        MapRunner(Context context) throws IOException, InterruptedException {
            mapper = ReflectionUtils.newInstance(mapClass, context.getConfiguration());
            subcontext = createSubContext(context);
            reader.initialize(context.getInputSplit(), context);
        }

        private Context createSubContext(Context context) {
            boolean isHadoop2 = false;
            Class<?> mapContextImplClazz = null;
            try {
                mapContextImplClazz = Class.forName("org.apache.hadoop.mapreduce.task.MapContextImpl");
                isHadoop2 = true;
            } catch (ClassNotFoundException e) {
                isHadoop2 = false;
            }

            if(mapContextImplClazz == null) {
                isHadoop2 = false;
            }

            try {
                if(isHadoop2) {
                    return createSubContextForHadoop2(context, mapContextImplClazz);
                } else {
                    return createSubContextForHadoop1(context);
                }
            } catch (Throwable t) {
                throw new RuntimeException(t);
            }
        }

        @SuppressWarnings("unchecked")
        private Context createSubContextForHadoop2(Context context, Class<?> mapContextImplClazz)
                throws NoSuchMethodException, InstantiationException, IllegalAccessException,
                InvocationTargetException, ClassNotFoundException {
            Constructor<?> constructor = mapContextImplClazz.getDeclaredConstructor(Configuration.class,
                    TaskAttemptID.class, RecordReader.class, RecordWriter.class, OutputCommitter.class,
                    StatusReporter.class, InputSplit.class);
            constructor.setAccessible(true);
            Object mapContext = constructor.newInstance(outer.getConfiguration(), outer.getTaskAttemptID(), reader,
                    new SubMapRecordWriter(), context.getOutputCommitter(), new SubMapStatusReporter(),
                    outer.getInputSplit());
            Class<?> wrappedMapperClazz = Class.forName("org.apache.hadoop.mapreduce.lib.map.WrappedMapper");
            Object wrappedMapper = wrappedMapperClazz.newInstance();
            Method method = wrappedMapperClazz.getDeclaredMethod("getMapContext",
                    Class.forName("org.apache.hadoop.mapreduce.MapContext"));
            return (Context) (method.invoke(wrappedMapper, mapContext));
        }

        @SuppressWarnings("unchecked")
        private Context createSubContextForHadoop1(Context context) throws NoSuchMethodException,
                InstantiationException, IllegalAccessException, InvocationTargetException {
            Constructor<?> constructor = Context.class.getDeclaredConstructor(Mapper.class, Configuration.class,
                    TaskAttemptID.class, RecordReader.class, RecordWriter.class, OutputCommitter.class,
                    StatusReporter.class, InputSplit.class);
            constructor.setAccessible(true);
            return (Context) constructor.newInstance(mapper, outer.getConfiguration(), outer.getTaskAttemptID(),
                    reader, new SubMapRecordWriter(), context.getOutputCommitter(), new SubMapStatusReporter(),
                    outer.getInputSplit());
        }

        @SuppressWarnings("unused")
        public Throwable getThrowable() {
            return throwable;
        }

        @Override
        public void run() {
            try {
                mapper.run(subcontext);
            } catch (Throwable ie) {
                throwable = ie;
            } finally {
                try {
                    reader.close();
                } catch (IOException ignore) {
                }
            }
        }
    }

}


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<title>GnipApi::Errors::PowerTrack</title>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
<link href='../../../css/style.css' media='screen' rel='stylesheet' type='text/css'>

module
GnipApi::Errors::PowerTrack

lib/gnip_api/errors.rb

lib/gnip_api/power_track/stream.rb

show all

Classes and Modules

GnipApi::Errors::PowerTrack::MissingRules

GnipApi::Errors::PowerTrack::StreamDown

Hanna Nouveau RDoc template


text:
/*
 * @description Expression is always true via if (true_expression)
 *
 * */

#include "std_testcase.h"

#ifndef OMITBAD

void CWE571_Expression_Always_True__string_equals_01_bad()
{
    char charString[10] = "true";

    /* FLAW: This expression is always true */
    if (strcmp(charString, "true") == 0)
    {
        printLine("Always prints");
    }
}

#endif /* OMITBAD */

#ifndef OMITGOOD

static void good1()
{
    char charString[10] = "";
    int charStringLen;

    if (fgets(charString, 10, stdin) == NULL)
    {
        printLine("fgets() failed.");

        /* Restore NUL terminator if fgets fails */
        charString[0] = '\0';
    }

    /* Remove trailing newline */
    charStringLen = strlen(charString);
    if (charStringLen > 0)
    {
        charString[charStringLen-1] = '\0';
    }

    /* FIX: Possibly evaluate to false */
    if(strcmp(charString, "true") == 0)
    {
        printLine("Sometimes prints");
    }
}

void CWE571_Expression_Always_True__string_equals_01_good()
{
    good1();
}

#endif /* OMITGOOD */

/* Below is the main(). It is only used when building this testcase on
 * its own for testing or for building a binary to use in testing binary
 * analysis tools. It is not used when compiling all the testcases as one
 * application, which is how source code analysis tools are tested.
 */

#ifdef INCLUDEMAIN

int main(int argc, char * argv[])
{
    /* seed randomness */
    srand( (unsigned)time(NULL) );

#ifndef OMITGOOD
    printLine("Calling good()...");
    CWE571_Expression_Always_True__string_equals_01_good();
    printLine("Finished good()");
#endif /* OMITGOOD */

#ifndef OMITBAD
    printLine("Calling bad()...");
    CWE571_Expression_Always_True__string_equals_01_bad();
    printLine("Finished bad()");
#endif /* OMITBAD */

    return 0;
}

#endif


text:
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;

namespace GRA.Domain.Model
{
    public class Page : Abstract.BaseDomainEntity
    {
        public int SiteId { get; set; }
        [Required]
        [MaxLength(255)]
        public string Title { get; set; }
        [Required]
        [MaxLength(255)]
        public string Stub { get; set; }
        [Required]
        public string Content { get; set; }
        [DisplayName("Footer Text")]
        [MaxLength(255)]
        public string FooterText { get; set; }
        [DisplayName("Nav Text")]
        [MaxLength(255)]
        public string NavText { get; set; }
        [DisplayName("Publish this page")]
        public bool IsPublished { get; set; }
    }
}


text:
```bash
# Update to latest binaries
apt-get update
apt-get -y upgrade
apt-get -y install git

# Install Go
curl -O https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.7.4.linux-amd64.tar.gz

# Download this repo
mkdir -p ./git/src/github.com/v2ray
cd ./git/src/github.com/v2ray
git clone https://github.com/v2ray/experiments.git
cd experiments/benchmark/testcases
source ./env.sh

# Build benchmark tools
./build.sh
```

## 单项测试

### 直连
```bash
./bare.sh
```

### V2Ray

```bash
# Install
curl -O https://install.direct/go.sh
chmod +x go.sh
./go.sh

# V2Ray direct: Dokodemo-door <-> Freedom
./v2ray_bare.sh

# V2Ray VMess
./v2ray_vmess.sh
```

### Shadowsocks Libev

```bash
# Install (Debian Jessie)
sh -c 'printf "deb http://httpredir.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backports.list'
apt-get update
apt-get install shadowsocks-libev

# Test
./ss_libev.sh
```

### ShadowsocksR Python

```bash
# Install
mkdir -p $GOPATH/src/github.com/shadowsocksr
pushd $GOPATH/src/github.com/shadowsocksr
git clone https://github.com/shadowsocksr/shadowsocksr.git
cd shadowsocksr
bash initcfg.sh
popd

# Test
./ssr_py.sh
```


text:
body{
    margin: 0px;
    padding: 0px;
    font-family: Agency FB, Verdana, Tahoma, sans-serif;
}
#wrapper{
    width: 100%;
    height: 100%;
    border: 2px solid black;
    background: #F1F1F1;
    margin-left: 1px;
    display: flex;
}
#wrapper nav{
    width: 20%;
    height: 100%;
    padding-top: 15px;
    padding-left: 5px;
}
#wrapper nav #home {
    margin: 0px;
    padding: 0px;
}
#wrapper nav #home img{
    width: 30px;
    height: 30px;
    position: relative;
    top: 5px;
}
#wrapper nav #home h3{
    font-size: 20px;
    display: inline-block;
    text-transform: uppercase;
    margin: 0px;
    padding: 0px;
}
#wrapper nav .nav-items{
    padding-left:4px;
    margin: 0px;
    padding: 0px;
    padding-top: 15px;
   font-size: 22px;
}
#wrapper nav .nav-items h4{
    color: #8A0303;
    margin: 0px;
    padding: 0px;
}
#wrapper nav .nav-items ul{
    list-style-type: none;
    margin: 0px;
    padding: 0px;
}
#wrapper main{
    width: 70%;
    height: 100;
    background: white;
    border: 2px solid #999999;
    padding: 5px;
    margin-bottom: 50px;
}
#wrapper main div#header-content{
    border-bottom: 3px solid #999999;
    padding-bottom: 5px;
    margin-bottom: 5px;
}#wrapper main div input[type=submit]{
    width: 150px;
    height: 30px;
    border: 2px solid black;
    font-family: Agency FB, Verdana, Tahoma, sans-serif;
    font-size: 19px;
    background: white;
}
#wrapper main div input.prev-btn{
    background: url(imgs/arrowhead-prev.png);
    background-repeat: no-repeat;
    background-size: cover;
    background-size: 40px;
    background-position-x:-12px;
}
#wrapper main div input.next-btn{
    background: url(imgs/arrowhead-next.png);
    background-repeat: no-repeat;
    background-size: cover;
    background-size: 40px;
    background-position-x: 118px;
}
#wrapper main article{

    font-size: 21px;
    margin-bottom: 35px;
}
#wrapper main article h4{
    background: #999999;
    color: white;
    font-weight: bold;
    padding-left: 5px;
    margin: 0px;
}
#wrapper main article a,#wrapper aside div a{
    color: #B0514E;
}
#wrapper main article#css-tutorial div{
    height: 265px;
    display: flex;
}
#wrapper main article#css-tutorial img{
    width: 160px;
    padding-top: 40px;
}
#wrapper main article#css-tutorial p{
    font-weight: bold;
    padding-top: 15px;
    padding-left: 15px;
    padding-right: 30px;
    padding-bottom: 15px;
}
#wrapper main article#css-tutorial a{
    padding-left: 15px;

}
#wrapper main div#main-bottom{
    border-top: 3px solid #999999;
    border-bottom: 3px solid #999999;
    padding-top: 15px;
    padding-bottom: 15px;
}
#wrapper aside{
    width: 20%;
    height: 100%;
    border: 1px solid black;
}
#wrapper aside>div{
    background: white;
    border: 2px solid #999999;
    text-align: center;
    font-size: 21px;
    margin-left: 10px;
    margin-bottom:10px;
    padding-bottom: 5px;
}
#wrapper aside div h4{
    text-transform: uppercase;
    color:white;
    background: #808080;
    margin-top: 0px;
    margin-bottom: 10px;
}
#wrapper aside #search-div div{
    margin-bottom: 10px;
}
#wrapper aside #search-div div input[type=text]{
    border: 2px solid #99B1C7;
    height: 30px;
    width: 150px;
    font-size: 16px;
}
#wrapper aside #search-div div input[type=submit]{
    border: 2px solid #99B1C7;
    border-radius: 3px;
    height: 35px;
    width: 40px;
    font-size: 16px;
    font-weight: bold;
}
#wrapper aside #div-with-button input[type=submit]{
    height: 45px;
}
#wrapper aside #search-div>a, #div-with-button>a, #web-hosting>a, .div-a-more>a{
    display: block;
}
#wrapper aside .div-a-only{
    border: 2px solid #999999;

}


text:
<?php

namespace FS\SolrBundle\Event\Listener;

use FS\SolrBundle\Console\ConsoleCommandResults;
use FS\SolrBundle\Console\CommandResult;
use FS\SolrBundle\Console\ConsoleResultFactory;
use FS\SolrBundle\Event\ErrorEvent;
use FS\SolrBundle\Event\Event;

class SynchronizationSummaryListener
{
    private $commandResult = null;
    private $resultFactory = null;

    public function __construct(ConsoleCommandResults $commandResult, ConsoleResultFactory $resultFactory)
    {
        $this->commandResult = $commandResult;
        $this->resultFactory = $resultFactory;
    }

    public function onSolrError(Event $event)
    {
        if ($event instanceof ErrorEvent) {
            $this->commandResult->error(
                $this->resultFactory->fromEvent($event)
            );
        }
    }

    public function onSolrSuccess(Event $event)
    {
        $this->commandResult->success(
            $this->resultFactory->fromEvent($event)
        );
    }
}


text:
var express = require('express');
var router = express.Router();
var Client = require('telapi').client;
var sendgrid  = require('sendgrid')(process.env.SENDGRID_USER, process.env.SENDGRID_PASS);
var bodyParser = require('body-parser');
var numbers = [];
var emails = [];
var telapi = new Client(process.env.TELAPI_SID, process.env.TELAPI_TOKEN);

router.post('/', function(req, res) {
  if(req.body.user.name == null | req.body.user.phone == null || req.body.user.email == null) {
    return res.send(400, "You need to put in your user information in the settings page.");
  }
  for(var i = 0; i < req.body.selected.length; i++) {
    if(req.body.selected[i].phone != undefined) {
      numbers.push(req.body.selected[i].phone);
    }
    if(req.body.selected[i].email != undefined) {
      emails.push(req.body.selected[i].email);
    }
  }
  console.log(numbers);
  for(var i = 0; i < numbers.length; i++) {
    telapi.create("sms_messages", {
        "From": process.env.TELAPI_NUMBER,
        "To": numbers[i],
        "Body": req.body.user.name + ' is suicidal and needs help. Contact them and take them to a hospital to get a suicide assessment. If you can\'t reach them, call 911.'
      }, function (response) {
        res.send("Messages sent successfully");
      },
      function (error) {
        return res.send(400, "An error occurred while sending messages");
      }
    );
  }
  numbers = [];

  console.log(emails);
  sendgrid.send({
    to      : emails,
    from    : process.env.SENDGRID_USER,
    fromname: "Defcon One",
    subject : 'Emergency! ' + req.body.user.name + ' needs your help immediately',
    text    : 'I am having suicidal thoughts right now and I need your help. Please call or text me immediately at ' + req.body.user.phone + ' and take me to a local hospital to get a suicide assessment. If you are unable to reach me, call 911. I am not safe and cannot guarantee you that right now I will not hurt myself. This is urgent and you must take immediate action.\n\n' + req.body.user.name + '\n(via the Defcon One app)'
  }, function(err, json) {
    if (err) { return res.send(400, "An error occurred while sending messages"); }
    res.send("Messages sent successfully");
  });
  emails = [];
});

module.exports = router;


text:
abstract class Foo {
  protected int field;

  public int f(Bar t){
    ((Foo)t).field = 0;
    return ((Foo)t).field;
  }

}

class Bar extends Foo{}


text:
//! dns security extension related modules

#[cfg(any(feature = "openssl", feature = "ring"))]
mod key_format;
mod keypair;
mod signer;

use crate::proto::rr::dnssec;

pub use self::dnssec::tbs;
pub use self::dnssec::Algorithm;
pub use self::dnssec::DigestType;
pub use self::dnssec::Nsec3HashAlgorithm;
pub use self::dnssec::PublicKey;
pub use self::dnssec::PublicKeyBuf;
pub use self::dnssec::PublicKeyEnum;
pub use self::dnssec::SupportedAlgorithms;
pub use self::dnssec::TrustAnchor;
pub use self::dnssec::Verifier;
pub use self::dnssec::TBS;
#[cfg(any(feature = "openssl", feature = "ring"))]
pub use self::key_format::KeyFormat;
pub use self::keypair::KeyPair;
pub use self::signer::Signer;

pub use crate::error::DnsSecError;
pub use crate::error::DnsSecErrorKind;
pub use crate::error::DnsSecResult;

#[cfg(all(not(feature = "ring"), feature = "openssl"))]
pub use openssl::hash::DigestBytes as Digest;

#[cfg(feature = "ring")]
pub use ring::digest::Digest;

#[cfg(feature = "openssl")]
pub use openssl::pkey::{HasPrivate, HasPublic, Private, Public};

#[cfg(not(feature = "openssl"))]
pub use self::faux_key_type::{HasPrivate, HasPublic, Private, Public};

#[cfg(not(feature = "openssl"))]
mod faux_key_type {
    /// A key that contains public key material
    pub trait HasPublic {}

    /// A key that contains private key material
    pub trait HasPrivate {}

    impl<K: HasPrivate> HasPublic for K {}

    /// Faux implementation of the Openssl Public key types
    pub enum Public {}

    impl HasPublic for Public {}

    /// Faux implementation of the Openssl Public key types
    pub enum Private {}

    impl HasPrivate for Private {}
}