text:
#include <algorithm>
#include <memory>
#include <set>
#include <stdexcept>
#include <string>

#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>

#include <thrift/compiler/ast/t_program.h>
#include <thrift/compiler/ast/t_type.h>
#include <thrift/compiler/generate/common.h>
#include <thrift/compiler/generate/mstch_objects.h>
#include <thrift/compiler/generate/t_mstch_generator.h>
#include <thrift/compiler/lib/py3/util.h>

namespace apache {
namespace thrift {
namespace compiler {

namespace {

// Reserved Python keywords that are not blocked by thrift grammar - note that
// this is actually a longer list than what t_py_generator checks, but may
// as well fix up more of them here.
const std::unordered_set<std::string> kKeywords = {
    "async",
    "await",
    "from",
    "nonlocal",
    "DEF",
    "ELIF",
    "ELSE",
    "False",
    "IF",
    "None",
    "True",
};

// TO-DO: remove duplicate in py3
mstch::array create_string_array(const std::vector<std::string>& values) {
  mstch::array mstch_array;
  for (auto it = values.begin(); it != values.end(); ++it) {
    mstch_array.push_back(mstch::map{
        {"value", *it},
        {"first?", it == values.begin()},
        {"last?", std::next(it) == values.end()},
    });
  }

  return mstch_array;
}

// TO-DO: remove duplicate in py3
bool has_types(const t_program* program) {
  assert(program != nullptr);

  return !(
      program->objects().empty() && program->enums().empty() &&
      program->typedefs().empty() && program->consts().empty());
}

std::vector<std::string> get_py_namespaces_raw(
    const t_program* program, bool is_asyncio, const std::string& tail = {}) {
  assert(program != nullptr);

  auto& py_namespace = program->get_namespace("py");
  auto& py_asyncio_namespace = program->get_namespace("py.asyncio");
  auto namespace_name = is_asyncio && !py_asyncio_namespace.empty()
      ? py_asyncio_namespace
      : py_namespace;

  auto ns = split_namespace(namespace_name);
  if (ns.empty()) {
    ns.push_back(program->name());
  }
  if (!tail.empty()) {
    ns.push_back(tail);
  }

  return ns;
}

std::string to_flat_type_name(const t_type* type) {
  assert(type != nullptr);

  const auto* true_type = type->get_true_type();
  assert(true_type != nullptr);

  if (true_type->is_list()) {
    const auto* listType = dynamic_cast<const t_list*>(true_type);
    assert(listType != nullptr);

    return fmt::format(
        "List__{}", to_flat_type_name(listType->get_elem_type()));
  }

  if (true_type->is_set()) {
    const auto* setType = dynamic_cast<const t_set*>(true_type);
    assert(setType != nullptr);

    return fmt::format("Set__{}", to_flat_type_name(setType->get_elem_type()));
  }

  if (true_type->is_map()) {
    const auto* mapType = dynamic_cast<const t_map*>(true_type);
    assert(mapType != nullptr);

    return fmt::format(
        "Map__{}_{}",
        to_flat_type_name(mapType->get_key_type()),
        to_flat_type_name(mapType->get_val_type()));
  }

  if (true_type->is_binary()) {
    return "binary";
  }

  return true_type->get_name();
}

const std::string* get_py_adapter(const t_type* type) {
  assert(type != nullptr);

  if (!type->get_true_type()->is_struct()) {
    return nullptr;
  }

  return t_typedef::get_first_annotation_or_null(type, {"py.adapter"});
}

std::set<std::string> get_distinct_adapters(const t_program* program) {
  assert(program != nullptr);

  std::set<std::string> adapters;

  auto add_adapter = [&adapters](const t_type* type) {
    const auto* adapter = get_py_adapter(type);
    if (adapter != nullptr) {
      adapters.insert(adapter->substr(0, adapter->find_last_of('.')));
    }
  };

  for (const auto* strct : program->structs()) {
    for (const auto* type : collect_types(strct)) {
      add_adapter(type);
    }
  }

  for (const auto* type : program->typedefs()) {
    add_adapter(type);
  }

  return adapters;
}

std::vector<std::string> gather_import_modules(
    const t_program* program, bool is_asyncio) {
  assert(program != nullptr);

  std::vector<std::string> import_modules = {};

  for (const auto* prog : program->get_included_programs()) {
    if (prog->path() == program->path()) {
      continue;
    }

    if (has_types(prog)) {
      import_modules.push_back(boost::algorithm::join(
          get_py_namespaces_raw(prog, is_asyncio, "ttypes"), "."));
    }
  }

  auto adapters = get_distinct_adapters(program);
  for (const auto& adapter : adapters) {
    import_modules.push_back(adapter);
  }

  return import_modules;
}

// Program

class pyi_mstch_program : public mstch_program {
 public:
  pyi_mstch_program(
      const t_program* program,
      mstch_context& context,
      mstch_element_position position)
      : mstch_program(program, context, position) {
    register_methods(
        this,
        {
            {"program:returnTypes", &pyi_mstch_program::get_return_types},
            {"program:pyNamespaces", &pyi_mstch_program::get_py_namespaces},
            {"program:pythonNamespaces",
             &pyi_mstch_program::get_python_namespaces},
            {"program:py3Namespaces", &pyi_mstch_program::get_py3_namespaces},
            {"program:importModules", &pyi_mstch_program::get_import_modules},
            {"program:containerTypes", &pyi_mstch_program::get_containers},
            {"program:moveContainerTypes",
             &pyi_mstch_program::get_move_containers},
        });
    register_has_option("program:asyncio?", "asyncio");
    register_has_option("program:cpp_transport?", "cpp_transport");

    this->visit_import_modules();
    this->visit_return_types();
    this->visit_containers();
  }

  mstch::node get_return_types() {
    return make_mstch_types(this->return_types_);
  }

  mstch::node get_py_namespaces() {
    return create_string_array(get_py_namespaces_raw(
        mstch_program::program_, mstch_base::has_option("asyncio")));
  }

  mstch::node get_python_namespaces() {
    // TODO: take root_module_prefix into account
    return create_string_array(
        ::apache::thrift::compiler::get_py3_namespace(mstch_program::program_));
  }

  mstch::node get_py3_namespaces() {
    return create_string_array(
        ::apache::thrift::compiler::get_py3_namespace(mstch_program::program_));
  }

  mstch::node get_import_modules() {
    mstch::array mstch_array;
    for (const auto& module : this->import_modules_) {
      mstch_array.push_back(module);
    }
    return mstch_array;
  }

  mstch::node get_containers() { return make_mstch_types(this->containers_); }

  mstch::node get_move_containers() {
    return make_mstch_types(this->move_containers_);
  }

 private:
  std::vector<const t_type*> return_types_;
  std::vector<std::string> import_modules_;
  std::vector<const t_type*> containers_;
  std::vector<const t_type*> move_containers_;

  void visit_import_modules() {
    this->import_modules_ = gather_import_modules(
        mstch_program::program_, mstch_base::has_option("asyncio"));
  }

  void visit_return_types() {
    std::set<std::string> visited;
    for (const auto* service : mstch_program::program_->services()) {
      for (const auto* function : service->get_functions()) {
        const auto* returnType = function->get_returntype();
        std::string name = to_flat_type_name(returnType);

        if (visited.find(name) == visited.end()) {
          visited.insert(name);
          this->return_types_.push_back(returnType);
        }
      }
    }
  }

  void visit_containers() {
    std::set<std::string> visited;

    for (const auto* service : mstch_program::program_->services()) {
      for (const auto& function : service->functions()) {
        for (const auto& param : function.get_paramlist()->fields()) {
          this->add_containers(visited, param.get_type());
        }

        auto return_type = function.get_returntype();
        this->add_containers(visited, return_type);
      }
    }

    for (const auto* object : mstch_program::program_->objects()) {
      for (const auto& field : object->fields()) {
        this->add_containers(visited, field.get_type());
      }
    }

    for (const auto* constant : mstch_program::program_->consts()) {
      const auto* const_type = constant->get_type();
      this->add_containers(visited, const_type);
    }

    // Collecting move containers within found containers
    visited.clear();
    for (const auto* container : this->containers_) {
      auto name = to_flat_type_name(container);
      boost::algorithm::replace_all(name, "binary", "string");

      if (visited.find(name) == visited.end()) {
        visited.insert(name);
        this->move_containers_.push_back(container);
      }
    }
  }

  void add_containers(std::set<std::string>& visited, const t_type* type) {
    assert(type != nullptr);

    if (!type->is_container()) {
      return;
    }

    std::string name = to_flat_type_name(type);
    if (visited.find(name) != visited.end()) {
      return;
    }

    if (type->is_list()) {
      const auto* listType = dynamic_cast<const t_list*>(type)->get_elem_type();
      add_containers(visited, listType);
    } else if (type->is_set()) {
      const auto* setType = dynamic_cast<const t_set*>(type)->get_elem_type();
      add_containers(visited, setType);
    } else if (type->is_map()) {
      const auto* mapType = dynamic_cast<const t_map*>(type);
      add_containers(visited, mapType->get_key_type());
      add_containers(visited, mapType->get_val_type());
    }

    visited.insert(name);
    this->containers_.push_back(type);
  }
};

// Field

class pyi_mstch_field : public mstch_field {
 public:
  pyi_mstch_field(
      const t_field* field,
      mstch_context& context,
      mstch_element_position position,
      const field_generator_context* field_context)
      : mstch_field(field, context, position, field_context) {
    register_methods(
        this,
        {
            {"field:requireValue?", &pyi_mstch_field::get_require_value},
            {"field:PEP484Optional?", &pyi_mstch_field::get_PEP484_optional},
            {"field:origName", &pyi_mstch_field::get_original_name},
            {"field:capitalizedName", &pyi_mstch_field::get_capitalized_name},
            {"field:py_name", &pyi_mstch_field::get_filtered_name},
        });

    auto field_type = mstch_field::field_->get_req();
    bool is_required = (field_type == t_field::e_req::required);
    bool is_optional = (field_type == t_field::e_req::optional);
    bool is_unqualified = !is_required && !is_optional;
    bool has_value = (mstch_field::field_->get_value() != nullptr);
    bool has_default_value = has_value || is_unqualified;

    this->require_value_ = is_required && !has_default_value;
    this->pep484_optional_ =
        (is_optional || (!has_default_value && !is_required));

    auto filteredName = mstch_field::field_->get_name();
    if (kKeywords.find(filteredName) != kKeywords.end()) {
      filteredName += "_PY_RESERVED_KEYWORD";
    }
    this->filtered_name_ = filteredName;
  }

  mstch::node get_require_value() { return this->require_value_; }

  mstch::node get_PEP484_optional() { return this->pep484_optional_; }

  mstch::node get_filtered_name() { return this->filtered_name_; }

  mstch::node get_original_name() { return mstch_field::field_->get_name(); }

  mstch::node get_capitalized_name() {
    std::string name(this->filtered_name_);
    std::transform(name.begin(), name.end(), name.begin(), ::toupper);

    return name;
  }

 private:
  bool require_value_;
  bool pep484_optional_;
  std::string filtered_name_;
};

// Type

class pyi_mstch_type : public mstch_type {
 public:
  pyi_mstch_type(
      const t_type* type,
      mstch_context& context,
      mstch_element_position position,
      const t_program* program)
      : mstch_type(type, context, position), program_(program) {
    register_methods(
        this,
        {
            {"type:modulePath", &pyi_mstch_type::get_module_path},
            {"type:externalProgram?", &pyi_mstch_type::is_external_program},
            {"type:flat_name", &pyi_mstch_type::get_flat_name},
            {"type:adapter", &pyi_mstch_type::get_adapter},
            {"type:has_adapter?", &pyi_mstch_type::has_adapter},
        });
  }

  mstch::node get_module_path() {
    return create_string_array(get_py_namespaces_raw(
        this->get_type_program(), mstch_base::has_option("asyncio"), "ttypes"));
  }

  mstch::node is_external_program() {
    return (this->get_type_program()->path() != this->program_->path());
  }

  mstch::node get_flat_name() { return to_flat_type_name(mstch_type::type_); }

  mstch::node get_adapter() {
    return std::string(*get_py_adapter(mstch_type::type_));
  }

  mstch::node has_adapter() {
    return (get_py_adapter(mstch_type::type_) != nullptr);
  }

 private:
  const t_program* program_;

  const t_program* get_type_program() const {
    const auto* typeProgram = mstch_type::type_->program();
    return (typeProgram != nullptr) ? typeProgram : this->program_;
  }
};

// Service

class pyi_mstch_service : public mstch_service {
 public:
  pyi_mstch_service(
      const t_service* service,
      mstch_context& context,
      mstch_element_position position,
      const t_program* program)
      : mstch_service(service, context, position), program_(program) {
    register_methods(
        this,
        {
            {"service:externalProgram?",
             &pyi_mstch_service::is_external_program},
            {"service:pyNamespaces", &pyi_mstch_service::get_py_namespaces},
            {"service:programName", &pyi_mstch_service::getProgramName},
            {"program:pyNamespaces",
             &pyi_mstch_service::get_program_py_namespaces},
            {"program:importModules",
             &pyi_mstch_service::get_program_import_modules},
        });
    register_has_option("program:asyncio?", "asyncio");

    this->visit_program_import_modules();
  }

  mstch::node is_external_program() {
    const auto& programPath = mstch_service::service_->program()->path();
    return (programPath != this->program_->path());
  }

  mstch::node get_py_namespaces() {
    return create_string_array(get_py_namespaces_raw(
        mstch_service::service_->program(), mstch_base::has_option("asyncio")));
  }

  mstch::node getProgramName() {
    return mstch_service::service_->program()->name();
  }

  mstch::node get_program_py_namespaces() {
    return create_string_array(get_py_namespaces_raw(
        this->program_, mstch_base::has_option("asyncio")));
  }

  mstch::node get_program_import_modules() {
    mstch::array mstch_array;
    for (const auto& module : this->program_import_modules_) {
      mstch_array.push_back(module);
    }
    return mstch_array;
  }

 private:
  const t_program* program_;
  std::vector<std::string> program_import_modules_;

  void visit_program_import_modules() {
    this->program_import_modules_ = gather_import_modules(
        this->program_, mstch_base::has_option("asyncio"));
  }
};

// Function

class pyi_mstch_function : public mstch_function {
 public:
  pyi_mstch_function(
      const t_function* function,
      mstch_context& context,
      mstch_element_position position)
      : mstch_function(function, context, position) {
    register_methods(
        this,
        {
            {"function:isSupported?", &pyi_mstch_function::is_supported},
        });
  }

  mstch::node is_supported() {
    // Stream and sink functions are not supported, see
    // t_py_generator::get_functions.
    return (
        !mstch_function::function_->returns_stream() &&
        !mstch_function::function_->returns_sink() &&
        !mstch_function::function_->get_returntype()->is_service());
  }
};

// Generator

class t_mstch_pyi_generator : public t_mstch_generator {
 public:
  using t_mstch_generator::t_mstch_generator;

  std::string template_prefix() const override { return "pyi"; }

  void generate_program() override;

 private:
  boost::filesystem::path root_path_;

  bool should_resolve_typedefs() const override { return true; }

  void create_factories();
  void generate_init_files();
  void generate_constants();
  void generate_ttypes();
  void generate_services();
  void render_file(
      const std::string& template_name,
      const boost::filesystem::path& path,
      const t_service* service = nullptr);
  boost::filesystem::path get_root_path() const;
};

void t_mstch_pyi_generator::generate_program() {
  this->root_path_ = this->get_root_path();
  this->out_dir_base_ = "gen-py";

  this->create_factories();

  this->generate_init_files();
  this->generate_constants();
  this->generate_ttypes();
  this->generate_services();
}

void t_mstch_pyi_generator::create_factories() {
  t_mstch_generator::mstch_context_.add<pyi_mstch_program>();
  t_mstch_generator::mstch_context_.add<pyi_mstch_field>();
  t_mstch_generator::mstch_context_.add<pyi_mstch_type>(this->get_program());
  t_mstch_generator::mstch_context_.add<pyi_mstch_service>(this->get_program());
  t_mstch_generator::mstch_context_.add<pyi_mstch_function>();
}

void t_mstch_pyi_generator::generate_init_files() {
  boost::filesystem::path directory;
  for (const auto& part : this->root_path_) {
    directory /= part;

    this->render_file("common/AutoGeneratedPy", directory / "__init__.pyi");
  }
}

void t_mstch_pyi_generator::generate_constants() {
  const std::string template_name = "constants.pyi";
  this->render_file(template_name, this->root_path_ / template_name);
}

void t_mstch_pyi_generator::generate_ttypes() {
  const std::string template_name = "ttypes.pyi";
  this->render_file(template_name, this->root_path_ / template_name);
}

void t_mstch_pyi_generator::generate_services() {
  const std::string template_name = "service.pyi";
  for (const auto* service : this->get_program()->services()) {
    const std::string module = service->get_name() + ".pyi";

    this->render_file(template_name, this->root_path_ / module, service);
  }
}

void t_mstch_pyi_generator::render_file(
    const std::string& template_name,
    const boost::filesystem::path& path,
    const t_service* service) {
  auto mstchObject = (service == nullptr)
      ? make_mstch_program_cached(
            this->get_program(), t_mstch_generator::mstch_context_)
      : make_mstch_service_cached(
            service->get_program(), service, t_mstch_generator::mstch_context_);

  t_mstch_generator::render_to_file(mstchObject, template_name, path);
}

boost::filesystem::path t_mstch_pyi_generator::get_root_path() const {
  boost::filesystem::path path;

  auto namespaces = get_py_namespaces_raw(
      this->get_program(), t_mstch_generator::has_option("asyncio"));
  for (const auto& ns : namespaces) {
    path /= ns;
  }
  path += boost::filesystem::path::preferred_separator;

  return path;
}

} // namespace

THRIFT_REGISTER_GENERATOR(
    mstch_pyi, "Legacy Python type information", "    no arguments\n");

} // namespace compiler
} // namespace thrift
} // namespace apache


text:
package iso20022

// Choice of formats to express a price.
type PriceFormat3Choice struct {

	// Price expressed as a currency and amount.
	Amount *AmountPrice1 `xml:"Amt"`

	// Price expressed as a rate, ie, percentage.
	Rate *PriceRate1 `xml:"Rate"`
}

func (p *PriceFormat3Choice) AddAmount() *AmountPrice1 {
	p.Amount = new(AmountPrice1)
	return p.Amount
}

func (p *PriceFormat3Choice) AddRate() *PriceRate1 {
	p.Rate = new(PriceRate1)
	return p.Rate
}

redpajama_set_name: RedPajamaGithub


text:
using System;
using System.Globalization;
using System.IO;
using System.Text;

namespace Mond
{
    class IndentTextWriter : TextWriter
    {
        private readonly TextWriter _writer;
        private readonly string _indentStr;
        private bool _shouldIndent;

        public int Indent { get; set; }

        public IndentTextWriter(TextWriter writer, string indentStr = "  ")
        {
            _writer = writer;
            _indentStr = indentStr;
            _shouldIndent = false;
        }

        public override Encoding Encoding => Encoding.Unicode;

        public override IFormatProvider FormatProvider => CultureInfo.InvariantCulture;

        public override void Write(char value)
        {
            if (_shouldIndent)
            {
                _shouldIndent = false; // shouldIndent must be cleared first
                WriteIndent();
            }

            _writer.Write(value);
        }

        public override void WriteLine()
        {
            base.WriteLine();

            _shouldIndent = true; // defer indenting until the next Write
        }

        public override void WriteLine(string value)
        {
            Write(value);
            WriteLine();
        }

        private void WriteIndent()
        {
            for (var i = 0; i < Indent; i++)
                Write(_indentStr);
        }
    }
}


text:
> Lighthouse analyzes web apps and web pages, collecting modern performance metrics and insights on developer best practices.

## Using Lighthouse in Chrome DevTools

Lighthouse is integrated directly into the Chrome Developer Tools, under the "Audits" panel.

**Installation**: install [Chrome](https://www.google.com/chrome/browser).

**Run it**: open Chrome DevTools, select the Audits panel, and hit "Run audits".

## Using the Chrome extension

**Installation**: [install the extension](https://chrome.google.com/webstore/detail/lighthouse/blipmdconlkpinefehnmjammfjpmpbjk) from the Chrome Web Store.

**Run it**: follow the [extension quick-start guide](https://developers.google.com/web/tools/lighthouse/#extension).

## Using the Node CLI

_Lighthouse requires Node 8 LTS (8.9) or later._

**Installation**:

```sh
npm install -g lighthouse
# or use yarn:
# yarn global add lighthouse
```

**Run it**: `lighthouse https://airhorner.com/`

By default, Lighthouse writes the report to an HTML file. You can control the output format by passing flags.

### CLI options

```sh
$ lighthouse --help

lighthouse <url>

Logging:
  --verbose  Displays verbose logging                                                                                [boolean]
  --quiet    Displays no progress, debug logs or errors                                                                                [boolean]

Configuration:
  --save-assets                  Save the trace contents & screenshots to disk                                                             [boolean]
  --list-all-audits              Prints a list of all available audits and exits                                                           [boolean]
  --list-trace-categories        Prints a list of all required trace categories and exits                                                  [boolean]
  --additional-trace-categories  Additional categories to capture with the trace (comma-delimited).
  --config-path                  The path to the config JSON.
  --chrome-flags                 Custom flags to pass to Chrome (space-delimited). For a full list of flags, see
                                 http://peter.sh/experiments/chromium-command-line-switches/.

                                 Environment variables:
                                 CHROME_PATH: Explicit path of intended Chrome binary. If set must point to an executable of a build of
                                 Chromium version 66.0 or later. By default, any detected Chrome Canary or Chrome (stable) will be launched.
                                                                                [default: ""]
  --port                         The port to use for the debugging protocol. Use 0 for a random port                                    [default: 0]
  --preset                       Use a built-in configuration.                                            [choices: "full", "perf", "mixed-content"]
  --hostname                     The hostname to use for the debugging protocol.                                              [default: "localhost"]
  --max-wait-for-load            The timeout (in milliseconds) to wait before the page is considered done loading and the run should continue.
                                 WARNING: Very high values can lead to large traces and instability                                 [default: 45000]
  --enable-error-reporting       Enables error reporting, overriding any saved preference. --no-enable-error-reporting will do the opposite. More:
                                 https://git.io/vFFTO
  --gather-mode, -G              Collect artifacts from a connected browser and save to disk. If audit-mode is not also enabled, the run will quit
                                 early.                                                                                [boolean]
  --audit-mode, -A               Process saved artifacts from disk                                                                         [boolean]

Output:
  --output       Reporter for the results, supports multiple values                        [choices: "csv", "json", "html"] [default: "html"]
  --output-path  The file path to output the results. Use 'stdout' to write to stdout.
                 If using JSON or CSV output, default is stdout.
                 If using HTML output, default is a file in the working directory with a name based on the test URL and date.
                 If using multiple outputs, --output-path is ignored.
                 Example: --output-path=./lighthouse-results.html
  --view         Open HTML report in your browser                                                                                [boolean]

Options:
  --help                        Show help                                                                                [boolean]
  --version                     Show version number                                                                                [boolean]
  --blocked-url-patterns        Block any network requests to the specified URL patterns                                                     [array]
  --disable-storage-reset       Disable clearing the browser cache and other storage APIs before a run                                     [boolean]
  --disable-device-emulation    Disable Nexus 5X emulation                                                                                [boolean]
  --throttling-method                  Controls throttling method         [choices: "devtools", "provided", "simulate"]
  --throttling.rttMs                   Controls simulated network RTT (TCP layer)
  --throttling.throughputKbps          Controls simulated network download throughput
  --throttling.requestLatencyMs        Controls emulated network RTT (HTTP layer)
  --throttling.downloadThroughputKbps  Controls emulated network download throughput
  --throttling.uploadThroughputKbps    Controls emulated network upload throughput
  --throttling.cpuSlowdownMultiplier   Controls simulated + emulated CPU throttling
  --extra-headers               Set extra HTTP Headers to pass with request                                                                 [string]

Examples:
  lighthouse <url> --view                                                   Opens the HTML report in a browser after the run completes
  lighthouse <url> --config-path=./myconfig.js                              Runs Lighthouse with your own configuration: custom audits, report
                                                                            generation, etc.
  lighthouse <url> --output=json --output-path=./report.json --save-assets  Save trace, screenshots, and named JSON report.
  lighthouse <url> --disable-device-emulation                               Disable device emulation and all throttling.
    --throttling-method=provided
  lighthouse <url> --chrome-flags="--window-size=412,732"                   Launch Chrome with a specific window size
  lighthouse <url> --quiet --chrome-flags="--headless"                      Launch Headless Chrome, turn off logging
  lighthouse <url> --extra-headers "{\"Cookie\":\"monster=blue\"}"          Stringify\'d JSON HTTP Header key/value pairs to send in requests
  lighthouse <url> --extra-headers=./path/to/file.json                      Path to JSON file of HTTP Header key/value pairs to send in requests

For more information on Lighthouse, see https://developers.google.com/web/tools/lighthouse/.
```

##### Output Examples

```sh
lighthouse
# saves `./<HOST>_<DATE>.report.html`

lighthouse --output json
# json output sent to stdout

lighthouse --output html --output-path ./report.html
# saves `./report.html`

# NOTE: specifying an output path with multiple formats ignores your specified extension for *ALL* formats
lighthouse --output json --output html --output-path ./myfile.json
# saves `./myfile.report.json` and `./myfile.report.html`

lighthouse --output json --output html
# saves `./<HOST>_<DATE>.report.json` and `./<HOST>_<DATE>.report.html`

lighthouse --output-path=~/mydir/foo.out --save-assets
# saves `~/mydir/foo.report.html`
# saves `~/mydir/foo-0.trace.json` and `~/mydir/foo-0.screenshots.html`

lighthouse --output-path=./report.json --output json
# saves `./report.json`
```

##### Lifecycle Examples
You can run a subset of Lighthouse's lifecycle if desired via the `--gather-mode` (`-G`) and  `--audit-mode` (`-A`) CLI flags.

```sh
lighthouse http://example.com -G
# launches browser, collects artifacts, saves them to disk (in `./latest-run/`) and quits

lighthouse http://example.com -A
# skips browser interaction, loads artifacts from disk (in `./latest-run/`), runs audits on them, generates report

lighthouse http://example.com -GA
# Normal gather + audit run, but also saves collected artifacts to disk for subsequent -A runs.

# You can optionally provide a custom folder destination to -G/-A/-GA. Without a value, the default will be `$PWD/latest-run`.
lighthouse -GA=./gmailartifacts https://gmail.com
```

#### Notes on Error Reporting

The first time you run the CLI you will be prompted with a message asking you if Lighthouse can anonymously report runtime exceptions. The Lighthouse team uses this information to detect new bugs and avoid regressions. Opting out will not affect your ability to use Lighthouse in any way. [Learn more](https://github.com/GoogleChrome/lighthouse/blob/master/docs/error-reporting.md).

## Viewing a report

Lighthouse can produce a report as JSON or HTML.

HTML report:

![Lighthouse report](https://user-images.githubusercontent.com/2301202/40556754-b9361c66-6002-11e8-8957-68c7bac85fa4.png)

### Online Viewer

Running Lighthouse with the `--output=json` flag generates a json dump of the run.
You can view this report online by visiting <https://googlechrome.github.io/lighthouse/viewer/>
and dragging the file onto the app. You can also use the "Export" button from the
top of any Lighthouse HTML report and open the report in the
[Lighthouse Viewer](https://googlechrome.github.io/lighthouse/viewer/).

In the Viewer, reports can be shared by clicking the share icon in the top
right corner and signing in to GitHub.

> **Note**: shared reports are stashed as a secret Gist in GitHub, under your account.

## Docs & Recipes

Useful documentation, examples, and recipes to get you started.

**Docs**

- [Using Lighthouse programmatically](./docs/readme.md#using-programmatically)
- [Testing a site with authentication](./docs/readme.md#testing-on-a-site-with-authentication)
- [Testing on a mobile device](./docs/readme.md#testing-on-a-mobile-device)
- [Lighthouse Architecture](./docs/architecture.md)

**Recipes**

- [gulp](docs/recipes/gulp) - helpful for CI integration
- [Custom Audit example](./docs/recipes/custom-audit) - extend Lighthouse, run your own audits

**Videos**

The session from Google I/O 2018 covers the new performance engine, upcoming Lighthouse REST API, and using the Chrome UX report to evaluate real-user data.

[![Lighthouse @ Google I/O 2018](https://img.youtube.com/vi/UvK9zAsSM8Q/0.jpg)](https://www.youtube.com/watch?v=UvK9zAsSM8Q)

The session from Google I/O 2017 covers architecture, writing custom audits,
GitHub/Travis/CI integration, headless Chrome, and more:

[![Lighthouse @ Google I/O 2017](https://img.youtube.com/vi/NoRYn6gOtVo/0.jpg)](https://www.youtube.com/watch?v=NoRYn6gOtVo)

_click to watch the video_

## Develop

Read on for the basics of hacking on Lighthouse. Also see [Contributing](./CONTRIBUTING.md)
for detailed information.

### Setup

```sh
# yarn should be installed first

git clone https://github.com/GoogleChrome/lighthouse

cd lighthouse
yarn
yarn install-all
yarn build-all
```

### Run

```sh
node lighthouse-cli http://example.com
```

> **Getting started tip**: `node --inspect --debug-brk lighthouse-cli http://example.com` to open up Chrome DevTools and step
through the entire app. See [Debugging Node.js with Chrome
DevTools](https://medium.com/@paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27#.59rma3ukm)
for more info.

### Tests

```sh
# lint and test all files
yarn test

# watch for file changes and run tests
#   Requires http://entrproject.org : brew install entr
yarn watch

## run linting, unit, and smoke tests separately
yarn lint
yarn unit
yarn smoke

## run tsc compiler
yarn type-check
```

## Lighthouse Integrations
This section details services that have integrated Lighthouse data. If you're working on a cool project integrating Lighthouse and would like to be featured here, file an issue to this repo or tweet at us [@_____lighthouse](https://twitter.com/____lighthouse?lang=en)!

* **[Calibre](https://calibreapp.com)** - Calibre is a web performance monitoring tool running Lighthouse continuously or on-demand via an API. Test using emulated devices and connection speeds from a number of geographical locations. Set budgets and improve performance with actionable guidelines. Calibre comes with a free 14-day trial.

* **[HTTPArchive](http://httparchive.org/)** - HTTPArchive tracks how the web is built by crawling 500k pages with Web Page Test, including Lighthouse results, and stores the information in BigQuery where it is [publicly available](https://discuss.httparchive.org/t/quickstart-guide-to-exploring-the-http-archive/682).

* **[SpeedCurve](https://speedcurve.com)** — SpeedCurve is a tool for continuously monitoring web performance across different browsers, devices, and regions. It can aggregate any metric including Lighthouse scores across multiple pages and sites, and allows you to set performance budgets with Slack or email alerts. SpeedCurve is a paid product with a free 30-day trial.

* **[Treo](https://treo.sh)** - Treo is Lighthouse as a Service. It provides regression testing, geographical regions, custom networks, and integrations with GitHub & Slack. Treo is a paid product with plans for solo-developers and teams.

* **[Web Page Test](https://www.webpagetest.org)** — An [open source](https://github.com/WPO-Foundation/webpagetest) tool for measuring and analyzing the performance of web pages on real devices. Users can choose to produce a Lighthouse report alongside the analysis of WebPageTest results.

## Related Projects
Other awesome open source projects that use Lighthouse.

* **[webpack-lighthouse-plugin](https://github.com/addyosmani/webpack-lighthouse-plugin)** - run Lighthouse from a Webpack build.
* **[lighthouse-mocha-example](https://github.com/justinribeiro/lighthouse-mocha-example)** - gather performance metrics via Lighthouse and tests them in Mocha
* **[pwmetrics](https://github.com/paulirish/pwmetrics/)** - gather performance metrics
* **[lighthouse-hue](https://github.com/ebidel/lighthouse-hue)** - set the color of Philips Hue lights based on a Lighthouse score
   * **[lighthouse-magic-light](https://github.com/manekinekko/lighthouse-magic-light)** set the color of the MagicLight Bluetooth Smart Light Bulb based on Lighthouse score
* **[lighthouse-batch](https://www.npmjs.com/package/lighthouse-batch)** - run Lighthouse over a number of sites and generate a summary of their metrics/scores.
* **[lighthouse-cron](https://github.com/thearegee/lighthouse-cron)** - Cron multiple batch Lighthouse audits and emit results for sending to remote server.
* **[lightcrawler](https://github.com/github/lightcrawler)** - Crawl a website and run each page found through Lighthouse.
* **[lighthouse-lambda](https://github.com/joytocode/lighthouse-lambda)** - Run Lighthouse on AWS Lambda with prebuilt stable desktop Headless Chrome.
* **[lighthouse-security](https://github.com/voorhoede/lighthouse-security#readme)** - Run a set of security audits along with Lighthouse.
* **[Garie](https://github.com/boyney123/garie)** — An open source tool for monitoring performance using Lighthouse,  PageSpeed Insights, [Prometheus](https://prometheus.io/), [Grafana](https://grafana.com/) and [Docker](https://www.docker.com/).
* **[lighthouse-ci](https://github.com/andreasonny83/lighthouse-ci)** - Run Lighthouse and assert scores satisfy your custom thresholds.

## FAQ

### How does Lighthouse work?

See [Lighthouse Architecture](./docs/architecture.md).

### Can I configure the lighthouse run?

Yes! Details in [Lighthouse configuration](./docs/configuration.md).

### How does Lighthouse use network throttling, and how can I make it better?

Good question. Network and CPU throttling are applied by default in a Lighthouse run. The network
attempts to emulate 3G and the CPU is slowed down 4x from your machine's default speed. If you
prefer to run Lighthouse without throttling, you'll have to use the CLI and disable it with the
`--throttling.*` flags mentioned above.

Read more in our [guide to network throttling](./docs/throttling.md).

### Are results sent to a remote server?

Nope. Lighthouse runs locally, auditing a page using a local version of the Chrome browser installed the
machine. Report results are never processed or beaconed to a remote server.

### How do I author custom audits to extend Lighthouse?

> **Tip**: see [Lighthouse Architecture](./docs/architecture.md) for more information
on terminology and architecture.

Lighthouse can be extended to run custom audits and gatherers that you author.
This is great if you're already tracking performance metrics in your site and
want to surface those metrics within a Lighthouse report.

If you're interested in running your own custom audits, check out our
[Custom Audit Example](./docs/recipes/custom-audit) over in recipes.

### How do I contribute?

We'd love help writing audits, fixing bugs, and making the tool more useful!
See [Contributing](./CONTRIBUTING.md) to get started.

---

  Lighthouse, ˈlītˌhous (n): a <s>tower or other structure</s> tool containing a beacon light
  to warn or guide <s>ships at sea</s> developers.


text:
.class public abstract Landroid/view/DisplayEventReceiver;
.super Ljava/lang/Object;
.source "DisplayEventReceiver.java"

# static fields
.field private static final TAG:Ljava/lang/String; = "DisplayEventReceiver"

# instance fields
.field private final mCloseGuard:Ldalvik/system/CloseGuard;

.field private mMessageQueue:Landroid/os/MessageQueue;

.field private mReceiverPtr:J

# direct methods
.method public constructor <init>(Landroid/os/Looper;)V
    .registers 4
    .param p1, "looper"    # Landroid/os/Looper;

    .prologue
    .line 57
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 39
    invoke-static {}, Ldalvik/system/CloseGuard;->get()Ldalvik/system/CloseGuard;

    move-result-object v0

    iput-object v0, p0, Landroid/view/DisplayEventReceiver;->mCloseGuard:Ldalvik/system/CloseGuard;

    .line 58
    if-nez p1, :cond_14

    .line 59
    new-instance v0, Ljava/lang/IllegalArgumentException;

    const-string/jumbo v1, "looper must not be null"

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 62
    :cond_14
    invoke-virtual {p1}, Landroid/os/Looper;->getQueue()Landroid/os/MessageQueue;

    move-result-object v0

    iput-object v0, p0, Landroid/view/DisplayEventReceiver;->mMessageQueue:Landroid/os/MessageQueue;

    .line 63
    new-instance v0, Ljava/lang/ref/WeakReference;

    invoke-direct {v0, p0}, Ljava/lang/ref/WeakReference;-><init>(Ljava/lang/Object;)V

    iget-object v1, p0, Landroid/view/DisplayEventReceiver;->mMessageQueue:Landroid/os/MessageQueue;

    invoke-static {v0, v1}, Landroid/view/DisplayEventReceiver;->nativeInit(Ljava/lang/ref/WeakReference;Landroid/os/MessageQueue;)J

    move-result-wide v0

    iput-wide v0, p0, Landroid/view/DisplayEventReceiver;->mReceiverPtr:J

    .line 65
    iget-object v0, p0, Landroid/view/DisplayEventReceiver;->mCloseGuard:Ldalvik/system/CloseGuard;

    const-string/jumbo v1, "dispose"

    invoke-virtual {v0, v1}, Ldalvik/system/CloseGuard;->open(Ljava/lang/String;)V

    .line 57
    return-void
.end method

.method private dispatchHotplug(JIZ)V
    .registers 6
    .param p1, "timestampNanos"    # J
    .param p3, "builtInDisplayId"    # I
    .param p4, "connected"    # Z

    .prologue
    .line 147
    invoke-virtual {p0, p1, p2, p3, p4}, Landroid/view/DisplayEventReceiver;->onHotplug(JIZ)V

    .line 146
    return-void
.end method

.method private dispatchVsync(JII)V
    .registers 6
    .param p1, "timestampNanos"    # J
    .param p3, "builtInDisplayId"    # I
    .param p4, "frame"    # I

    .prologue
    .line 141
    invoke-virtual {p0, p1, p2, p3, p4}, Landroid/view/DisplayEventReceiver;->onVsync(JII)V

    .line 140
    return-void
.end method

.method private dispose(Z)V
    .registers 8
    .param p1, "finalized"    # Z

    .prologue
    const-wide/16 v4, 0x0

    const/4 v2, 0x0

    .line 85
    iget-object v0, p0, Landroid/view/DisplayEventReceiver;->mCloseGuard:Ldalvik/system/CloseGuard;

    if-eqz v0, :cond_13

    .line 86
    if-eqz p1, :cond_e

    .line 87
    iget-object v0, p0, Landroid/view/DisplayEventReceiver;->mCloseGuard:Ldalvik/system/CloseGuard;

    invoke-virtual {v0}, Ldalvik/system/CloseGuard;->warnIfOpen()V

    .line 89
    :cond_e
    iget-object v0, p0, Landroid/view/DisplayEventReceiver;->mCloseGuard:Ldalvik/system/CloseGuard;

    invoke-virtual {v0}, Ldalvik/system/CloseGuard;->close()V

    .line 92
    :cond_13
    iget-wide v0, p0, Landroid/view/DisplayEventReceiver;->mReceiverPtr:J

    cmp-long v0, v0, v4

    if-eqz v0, :cond_20

    .line 93
    iget-wide v0, p0, Landroid/view/DisplayEventReceiver;->mReceiverPtr:J

    invoke-static {v0, v1}, Landroid/view/DisplayEventReceiver;->nativeDispose(J)V

    .line 94
    iput-wide v4, p0, Landroid/view/DisplayEventReceiver;->mReceiverPtr:J

    .line 96
    :cond_20
    iput-object v2, p0, Landroid/view/DisplayEventReceiver;->mMessageQueue:Landroid/os/MessageQueue;

    .line 84
    return-void
.end method

.method private static native nativeDispose(J)V
.end method

.method private static native nativeInit(Ljava/lang/ref/WeakReference;Landroid/os/MessageQueue;)J
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/ref/WeakReference",
            "<",
            "Landroid/view/DisplayEventReceiver;",
            ">;",
            "Landroid/os/MessageQueue;",
            ")J"
        }
    .end annotation
.end method

.method private static native nativeScheduleVsync(J)V
.end method

# virtual methods
.method public dispose()V
    .registers 2

    .prologue
    .line 81
    const/4 v0, 0x0

    invoke-direct {p0, v0}, Landroid/view/DisplayEventReceiver;->dispose(Z)V

    .line 80
    return-void
.end method

.method protected finalize()V
    .registers 2
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Throwable;
        }
    .end annotation

    .prologue
    .line 71
    const/4 v0, 0x1

    :try_start_1
    invoke-direct {p0, v0}, Landroid/view/DisplayEventReceiver;->dispose(Z)V
    :try_end_4
    .catchall {:try_start_1 .. :try_end_4} :catchall_8

    .line 73
    invoke-super {p0}, Ljava/lang/Object;->finalize()V

    .line 69
    return-void

    .line 72
    :catchall_8
    move-exception v0

    .line 73
    invoke-super {p0}, Ljava/lang/Object;->finalize()V

    .line 72
    throw v0
.end method

.method public onHotplug(JIZ)V
    .registers 5
    .param p1, "timestampNanos"    # J
    .param p3, "builtInDisplayId"    # I
    .param p4, "connected"    # Z

    .prologue
    .line 122
    return-void
.end method

.method public onVsync(JII)V
    .registers 5
    .param p1, "timestampNanos"    # J
    .param p3, "builtInDisplayId"    # I
    .param p4, "frame"    # I

    .prologue
    .line 110
    return-void
.end method

.method public scheduleVsync()V
    .registers 5

    .prologue
    .line 130
    iget-wide v0, p0, Landroid/view/DisplayEventReceiver;->mReceiverPtr:J

    const-wide/16 v2, 0x0

    cmp-long v0, v0, v2

    if-nez v0, :cond_12

    .line 131
    const-string/jumbo v0, "DisplayEventReceiver"

    const-string/jumbo v1, "Attempted to schedule a vertical sync pulse but the display event receiver has already been disposed."

    invoke-static {v0, v1}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I

    .line 129
    :goto_11
    return-void

    .line 134
    :cond_12
    iget-wide v0, p0, Landroid/view/DisplayEventReceiver;->mReceiverPtr:J

    invoke-static {v0, v1}, Landroid/view/DisplayEventReceiver;->nativeScheduleVsync(J)V

    goto :goto_11
.end method


text:
package org.uma.jmetal.util.measure;

/**
 * A {@link PullMeasure} is a {@link Measure} from which the {@link Value} can
 * be accessed on demand through the {@link #get()} method. As such, a
 * {@link PullMeasure} should ensure that its current {@link Value} is always
 * available or generated before to be returned by {@link #get()}.
 *
 * @author Created by Antonio J. Nebro on 21/10/14 based on the ideas of
 *         Matthieu Vergne <matthieu.vergne@gmail.com>
 *
 * @param <Value>
 *            the type of value the {@link PullMeasure} can provide
 */
public interface PullMeasure<Value> extends Measure<Value> {
	/**
	 *
	 * @return the current {@link Value} of the {@link Measure}
	 */
	public Value get();
}


text:
namespace MonoCatalog {

	// Base type probably should be MonoTouch.UIKit.UIViewController or subclass
	[Foundation.Register("TextFieldController")]
	public partial class TextFieldController {

		private UIKit.UITableView __mt_view;

		#pragma warning disable 0169
		[Foundation.Connect("view")]
		private UIKit.UITableView view {
			get {
				this.__mt_view = ((UIKit.UITableView)(this.GetNativeField("view")));
				return this.__mt_view;
			}
			set {
				this.__mt_view = value;
				this.SetNativeField("view", value);
			}
		}
	}
}


text: find /var/www/*/www/modules/kovspace/update.sh -exec sh -f {} \;


text:
angular.module('app.home')
	.config(['$translateProvider', function ($translateProvider) {
		$translateProvider.translations('fr', {
			home: {
				title: 'Accueil'
			}
		});
	}])
;


text:
(function(module) {
try {
  module = angular.module('ml.esri-maps.tpls');
} catch (e) {
  module = angular.module('ml.esri-maps.tpls', []);
}
module.run(['$templateCache', function($templateCache) {
  $templateCache.put('/templates/detail-map.html',
    '

');
}]);
})();


text:
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using LinqToTwitter;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System.Net.Http;
using LinqToTwitter.Provider;
using LinqToTwitter.Tests.Common;
using LinqToTwitter.OAuth;

namespace LinqToTwitterPcl.Tests.AccountTests
{
    [TestClass]
    public class UserCommandsTests
    {
        Mock<ITwitterExecute> execMock;

        public UserCommandsTests()
        {
            TestCulture.SetCulture();
        }

        TwitterContext InitTwitterContextWithPostToTwitter<TEntity>(string response)
        {
            var authMock = new Mock<IAuthorizer>();
            var tcsResponse = new TaskCompletionSource<string>();
            tcsResponse.SetResult(response);
            execMock = new Mock<ITwitterExecute>();
            execMock.SetupGet(exec => exec.Authorizer).Returns(authMock.Object);
            execMock.Setup(
                exec => exec.PostFormUrlEncodedToTwitterAsync<User>(
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<Dictionary<string, string>>(),
                    It.IsAny<CancellationToken>()))
                    .Returns(tcsResponse.Task);
            execMock.Setup(
                exec => exec.PostMediaAsync(
                    It.IsAny<string>(),
                    It.IsAny<Dictionary<string, string>>(),
                    It.IsAny<byte[]>(),
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<bool>(),
                    It.IsAny<CancellationToken>()))
                    .Returns(tcsResponse.Task);
            execMock.Setup(exec =>
                exec.SendJsonToTwitterAsync(
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<IDictionary<string, string>>(),
                    It.IsAny<TwitterUserTargetID>(),
                    It.IsAny<CancellationToken>()))
                .Returns(tcsResponse.Task);
            execMock.Setup(exec =>
                exec.SendJsonToTwitterAsync(
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<IDictionary<string, string>>(),
                    It.IsAny<RetweetTweetID>(),
                    It.IsAny<CancellationToken>()))
                .Returns(tcsResponse.Task);
            var ctx = new TwitterContext(execMock.Object);
            return ctx;
        }

        [TestMethod]
        public async Task ReportSpamAsync_ScreenName_Invokes_Executor_Execute()
        {
            const string ScreenName = "twitterapi";
            var ctx = InitTwitterContextWithPostToTwitter<User>(SingleUserResponse);

            User actual = await ctx.ReportSpamAsync(ScreenName);

            execMock.Verify(exec =>
                exec.PostFormUrlEncodedToTwitterAsync<User>(
                    HttpMethod.Post.ToString(),
                    "https://api.twitter.com/1.1/users/report_spam.json",
                    It.IsAny<IDictionary<string, string>>(),
                    It.IsAny<CancellationToken>()),
                Times.Once());
            Assert.AreEqual(ScreenName, actual.ScreenNameResponse);
        }

        [TestMethod]
        public async Task ReportSpamAsync_WithRawResponse_Succeeds()
        {
            const string ScreenName = "twitterapi";
            var ctx = InitTwitterContextWithPostToTwitter<User>(SingleUserResponse);

            await ctx.ReportSpamAsync(ScreenName);

            Assert.AreEqual(SingleUserResponse, ctx.RawResult);
        }

        [TestMethod]
        public async Task ReportSpamAsync_UserID_Invokes_Executor_Execute()
        {
            const string ScreenName = "twitterapi";
            var ctx = InitTwitterContextWithPostToTwitter<User>(SingleUserResponse);

            User actual = await ctx.ReportSpamAsync(1);

            execMock.Verify(exec =>
                exec.PostFormUrlEncodedToTwitterAsync<User>(
                    HttpMethod.Post.ToString(),
                    "https://api.twitter.com/1.1/users/report_spam.json",
                    It.IsAny<IDictionary<string, string>>(),
                    It.IsAny<CancellationToken>()),
                Times.Once());
            Assert.AreEqual(ScreenName, actual.ScreenNameResponse);
        }

        [TestMethod]
        public async Task ReportSpamAsync_WithBlockUer_InvokesExecutorExecute()
        {
            const string PerformBlock = "perform_block";
            const string ScreenName = "twitterapi";
            var ctx = InitTwitterContextWithPostToTwitter<User>(SingleUserResponse);

            User actual = await ctx.ReportSpamAsync(1, performBlock: true);

            execMock.Verify(exec =>
                exec.PostFormUrlEncodedToTwitterAsync<User>(
                    HttpMethod.Post.ToString(),
                    "https://api.twitter.com/1.1/users/report_spam.json",
                    It.Is<Dictionary<string, string>>(parms => parms.ContainsKey(PerformBlock) && parms[PerformBlock] == bool.TrueString.ToLower()),
                    It.IsAny<CancellationToken>()),
                Times.Once());
            Assert.AreEqual(ScreenName, actual.ScreenNameResponse);
        }

        [TestMethod]
        public async Task ReportSpamAsync_Throws_On_Null_ScreenName()
        {
            const string ExpectedParamName = "screenName";
            var ctx = InitTwitterContextWithPostToTwitter<User>(SingleUserResponse);

            var ex = await L2TAssert.Throws<ArgumentException>(
                async () => await ctx.ReportSpamAsync((string)null));

            Assert.AreEqual(ExpectedParamName, ex.ParamName);
        }

        [TestMethod]
        public async Task ReportSpamAsync_Throws_On_Zero_UserID()
        {
            const string ExpectedParamName = "userID";
            var ctx = InitTwitterContextWithPostToTwitter<User>(SingleUserResponse);

            var ex = await L2TAssert.Throws<ArgumentException>(
                async () => await ctx.ReportSpamAsync(0));

            Assert.AreEqual(ExpectedParamName, ex.ParamName);
        }

        [TestMethod]
        public async Task Follow_WithProperParameters_Succeeds()
        {
            const string followingUser = "abc";
            const string userToFollow = "def";
            var ctx = InitTwitterContextWithPostToTwitter<User>(FollowResponse);

            TwitterUserFollowResponse response =
                await ctx.FollowAsync(followingUser, userToFollow);

            Assert.IsNotNull(response);
            TwitterUserFollowResponseData data = response.Data;
            Assert.IsNotNull(data);
            Assert.IsTrue(data.Following);
        }

        [TestMethod]
        public async Task Follow_WithoutSource_Throws()
        {
            const string ExpectedParamName = "sourceUserID";
            var ctx = InitTwitterContextWithPostToTwitter<User>(FollowResponse);

            var ex = await L2TAssert.Throws<ArgumentException>(
                async () => await ctx.FollowAsync(null, "abc"));

            Assert.AreEqual(ExpectedParamName, ex.ParamName);
        }

        [TestMethod]
        public async Task Follow_WithoutTarget_Throws()
        {
            const string ExpectedParamName = "targetUserID";
            var ctx = InitTwitterContextWithPostToTwitter<User>(FollowResponse);

            var ex = await L2TAssert.Throws<ArgumentException>(
                async () => await ctx.FollowAsync("abc", null));

            Assert.AreEqual(ExpectedParamName, ex.ParamName);
        }

        [TestMethod]
        public async Task UnFollow_WithProperParameters_Succeeds()
        {
            const string followingUser = "abc";
            const string userToFollow = "def";
            var ctx = InitTwitterContextWithPostToTwitter<User>(UnFollowResponse);

            TwitterUserFollowResponse response =
                await ctx.UnFollowAsync(followingUser, userToFollow);

            Assert.IsNotNull(response);
            TwitterUserFollowResponseData data = response.Data;
            Assert.IsNotNull(data);
            Assert.IsFalse(data.Following);
        }

        [TestMethod]
        public async Task UnFollow_WithoutSource_Throws()
        {
            const string ExpectedParamName = "sourceUserID";
            var ctx = InitTwitterContextWithPostToTwitter<User>(UnFollowResponse);

            var ex = await L2TAssert.Throws<ArgumentException>(
                async () => await ctx.UnFollowAsync(null, "abc"));

            Assert.AreEqual(ExpectedParamName, ex.ParamName);
        }

        [TestMethod]
        public async Task UnFollow_WithoutTarget_Throws()
        {
            const string ExpectedParamName = "targetUserID";
            var ctx = InitTwitterContextWithPostToTwitter<User>(UnFollowResponse);

            var ex = await L2TAssert.Throws<ArgumentException>(
                async () => await ctx.UnFollowAsync("abc", null));

            Assert.AreEqual(ExpectedParamName, ex.ParamName);
        }

        [TestMethod]
        public async Task Retweet_WithProperParameters_Succeeds()
        {
            const string userID = "abc";
            const string tweetID = "def";
            var ctx = InitTwitterContextWithPostToTwitter<User>(RetweetResponse);

            RetweetResponse response =
                await ctx.RetweetAsync(userID, tweetID);

            Assert.IsNotNull(response);
            RetweetResponseData data = response.Data;
            Assert.IsNotNull(data);
            Assert.IsTrue(data.Retweeted);
        }

        [TestMethod]
        public async Task Retweet_WithoutUserID_Throws()
        {
            const string ExpectedParamName = "userID";
            var ctx = InitTwitterContextWithPostToTwitter<User>(RetweetResponse);

            var ex = await L2TAssert.Throws<ArgumentException>(
                async () => await ctx.RetweetAsync(null, "abc"));

            Assert.AreEqual(ExpectedParamName, ex.ParamName);
        }

        [TestMethod]
        public async Task Retweet_WithoutTweetID_Throws()
        {
            const string ExpectedParamName = "tweetID";
            var ctx = InitTwitterContextWithPostToTwitter<User>(RetweetResponse);

            var ex = await L2TAssert.Throws<ArgumentException>(
                async () => await ctx.RetweetAsync("abc", null));

            Assert.AreEqual(ExpectedParamName, ex.ParamName);
        }

        [TestMethod]
        public async Task UndoRetweet_WithProperParameters_Succeeds()
        {
            const string userID = "abc";
            const string sourceTweetID = "def";
            var ctx = InitTwitterContextWithPostToTwitter<User>(UndoRetweetResponse);

            RetweetResponse response =
                await ctx.UndoRetweetAsync(userID, sourceTweetID);

            Assert.IsNotNull(response);
            RetweetResponseData data = response.Data;
            Assert.IsNotNull(data);
            Assert.IsFalse(data.Retweeted);
        }

        [TestMethod]
        public async Task UndoRetweet_WithoutUserID_Throws()
        {
            const string ExpectedParamName = "userID";
            var ctx = InitTwitterContextWithPostToTwitter<User>(UndoRetweetResponse);

            var ex = await L2TAssert.Throws<ArgumentException>(
                async () => await ctx.UndoRetweetAsync(null, "abc"));

            Assert.AreEqual(ExpectedParamName, ex.ParamName);
        }

        [TestMethod]
        public async Task UndoRetweet_WithoutTweetID_Throws()
        {
            const string ExpectedParamName = "sourceTweetID";
            var ctx = InitTwitterContextWithPostToTwitter<User>(UndoRetweetResponse);

            var ex = await L2TAssert.Throws<ArgumentException>(
                async () => await ctx.UndoRetweetAsync("abc", null));

            Assert.AreEqual(ExpectedParamName, ex.ParamName);
        }

        const string SingleUserResponse = @"{
   ""id"":6253282,
   ""id_str"":""6253282"",
   ""name"":""Twitter API"",
   ""screen_name"":""twitterapi"",
   ""location"":""San Francisco, CA"",
   ""description"":""The Real Twitter API. I tweet about API changes, service issues and happily answer questions about Twitter and our API. Don't get an answer? It's on my website."",
   ""url"":""http:\/\/dev.twitter.com"",
   ""protected"":false,
   ""followers_count"":1009508,
   ""friends_count"":31,
   ""listed_count"":10361,
   ""created_at"":""Wed May 23 06:01:13 +0000 2007"",
   ""favourites_count"":24,
   ""utc_offset"":-28800,
   ""time_zone"":""Pacific Time (US & Canada)"",
   ""geo_enabled"":true,
   ""verified"":true,
   ""statuses_count"":3278,
   ""lang"":""en"",
   ""status"":{
      ""created_at"":""Mon Apr 30 17:16:17 +0000 2012"",
      ""id"":197011505181507585,
      ""id_str"":""197011505181507585"",
      ""text"":""Developer Teatime is coming to Paris - please sign up to join us on June 16th! https:\/\/t.co\/pQOUNKGD  @rno @jasoncosta"",
      ""source"":""web"",
      ""truncated"":false,
      ""in_reply_to_status_id"":null,
      ""in_reply_to_status_id_str"":null,
      ""in_reply_to_user_id"":null,
      ""in_reply_to_user_id_str"":null,
      ""in_reply_to_screen_name"":null,
      ""geo"":null,
      ""coordinates"":null,
      ""place"":null,
      ""contributors"":[
         14927800
      ],
      ""retweet_count"":25,
      ""favorited"":false,
      ""retweeted"":false,
      ""possibly_sensitive"":false
   },
   ""contributors_enabled"":true,
   ""is_translator"":false,
   ""profile_background_color"":""E8F2F7"",
   ""profile_background_image_url"":""http:\/\/a0.twimg.com\/profile_background_images\/229557229\/twitterapi-bg.png"",
   ""profile_background_image_url_https"":""https:\/\/si0.twimg.com\/profile_background_images\/229557229\/twitterapi-bg.png"",
   ""profile_background_tile"":false,
   ""profile_image_url"":""http:\/\/a0.twimg.com\/profile_images\/1438634086\/avatar_normal.png"",
   ""profile_image_url_https"":""https:\/\/si0.twimg.com\/profile_images\/1438634086\/avatar_normal.png"",
   ""profile_banner_url"":""https:\/\/si0.twimg.com\/profile_images\/1438634086\/avatar_normal.png"",
   ""profile_link_color"":""0094C2"",
   ""profile_sidebar_border_color"":""0094C2"",
   ""profile_sidebar_fill_color"":""A9D9F1"",
   ""profile_text_color"":""437792"",
   ""profile_use_background_image"":true,
   ""show_all_inline_media"":false,
   ""default_profile"":false,
   ""default_profile_image"":false,
   ""following"":false,
   ""follow_request_sent"":false,
   ""notifications"":false
}";

        const string FollowResponse = @"{
    ""data"": {
		""following"": true,
		""pending_follow"": false
	}
}
";

        const string UnFollowResponse = @"{
    ""data"": {
		""following"": false,
		""pending_follow"": false
	}
}
";

        const string RetweetResponse = @"{
    ""data"": {
		""retweeted"": true
	}
}
";

        const string UndoRetweetResponse = @"{
    ""data"": {
		""retweeted"": false
	}
}
";
    }
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<annotations textSource="16121256.txt">
  <annotation>
    <mention id="cellular_component_Instance_185440" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>cells</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_185442" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>cells</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_185444" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>cells</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_185446" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>cells</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_185448" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>cell</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_185450" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>cell</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_185452" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>cell</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_185454" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>cell</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_185456" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>cells</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_185458" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>cell</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_185460" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>cells</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_190001" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>mitochondrial</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_190014" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>mitochondria</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_190018" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>Mitochondrial</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_190034" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>mitochondrial</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_190043" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>mitochondrial</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_200053" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>autosomal</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_200059" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>antibody</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_200066" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>antibody</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_200073" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>antibody</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_200080" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>antibodies</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_200112" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>Nuclei</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_200118" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>vesicular</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_200123" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>nucleoli</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_200145" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>mitochondrial</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_200163" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>antibody</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_200170" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>antibody</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_330533" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>electron transport flavoprotein</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_330537" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>ETF</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_330541" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>ETF</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_330545" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>ETF</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_330549" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>ETF</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_Instance_330553" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>electron transport flavoprotein</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_new_Instance_27972" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>nucleus</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_new_Instance_27974" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>cytosol</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_new_Instance_27976" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>mitochondrial matrix</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_new_Instance_27978" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>mitochondrial matrix</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_new_Instance_27980" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>sarcoplasm</spannedText>
  </annotation>
  <annotation>
    <mention id="cellular_component_new_Instance_27982" />
    <annotator id="cellular_component_Instance_130000">CCP Colorado Computational Pharmacology</annotator>

    <spannedText>myofibrils</spannedText>
  </annotation>
  <classMention id="cellular_component_new_Instance_27978">
    <mentionClass id="GO:0005759">mitochondrial matrix</mentionClass>
  </classMention>
  <classMention id="cellular_component_new_Instance_27980">
    <mentionClass id="GO:0016528">sarcoplasm</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_190034">
    <mentionClass id="GO:0005739">mitochondrion</mentionClass>
  </classMention>
  <classMention id="cellular_component_new_Instance_27982">
    <mentionClass id="GO:0030016">myofibril</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_190043">
    <mentionClass id="GO:0005739">mitochondrion</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_190018">
    <mentionClass id="GO:0005739">mitochondrion</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_190014">
    <mentionClass id="GO:0005739">mitochondrion</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_190001">
    <mentionClass id="GO:0005739">mitochondrion</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_200053">
    <mentionClass id="GO:0030849">autosome</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_200059">
    <mentionClass id="GO:0019814">immunoglobulin complex</mentionClass>
    <hasSlotMention id="cellular_component_Instance_200065" />
  </classMention>
  <booleanSlotMention id="cellular_component_Instance_200065">
    <mentionSlot id="macromolecular complex or protein ambiguity" />
    <booleanSlotMentionValue value="false" />
  </booleanSlotMention>
  <classMention id="cellular_component_Instance_185440">
    <mentionClass id="GO:0005623">cell</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_185448">
    <mentionClass id="GO:0005623">cell</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_330549">
    <mentionClass id="GO:0045251">electron transfer flavoprotein complex</mentionClass>
    <hasSlotMention id="cellular_component_Instance_330552" />
  </classMention>
  <booleanSlotMention id="cellular_component_Instance_330552">
    <mentionSlot id="macromolecular complex or protein ambiguity" />
    <booleanSlotMentionValue value="true" />
  </booleanSlotMention>
  <classMention id="cellular_component_Instance_185446">
    <mentionClass id="GO:0005623">cell</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_185444">
    <mentionClass id="GO:0005623">cell</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_200066">
    <mentionClass id="GO:0019814">immunoglobulin complex</mentionClass>
    <hasSlotMention id="cellular_component_Instance_200072" />
  </classMention>
  <booleanSlotMention id="cellular_component_Instance_200072">
    <mentionSlot id="macromolecular complex or protein ambiguity" />
    <booleanSlotMentionValue value="false" />
  </booleanSlotMention>
  <classMention id="cellular_component_Instance_330545">
    <mentionClass id="GO:0045251">electron transfer flavoprotein complex</mentionClass>
    <hasSlotMention id="cellular_component_Instance_330548" />
  </classMention>
  <booleanSlotMention id="cellular_component_Instance_330548">
    <mentionSlot id="macromolecular complex or protein ambiguity" />
    <booleanSlotMentionValue value="true" />
  </booleanSlotMention>
  <classMention id="cellular_component_Instance_185442">
    <mentionClass id="GO:0005623">cell</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_185456">
    <mentionClass id="GO:0005623">cell</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_200112">
    <mentionClass id="GO:0005634">nucleus</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_185454">
    <mentionClass id="GO:0005623">cell</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_185452">
    <mentionClass id="GO:0005623">cell</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_200080">
    <mentionClass id="GO:0019814">immunoglobulin complex</mentionClass>
    <hasSlotMention id="cellular_component_Instance_200086" />
  </classMention>
  <booleanSlotMention id="cellular_component_Instance_200086">
    <mentionSlot id="macromolecular complex or protein ambiguity" />
    <booleanSlotMentionValue value="false" />
  </booleanSlotMention>
  <classMention id="cellular_component_Instance_185450">
    <mentionClass id="GO:0005623">cell</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_200073">
    <mentionClass id="GO:0019814">immunoglobulin complex</mentionClass>
    <hasSlotMention id="cellular_component_Instance_200079" />
  </classMention>
  <booleanSlotMention id="cellular_component_Instance_200079">
    <mentionSlot id="macromolecular complex or protein ambiguity" />
    <booleanSlotMentionValue value="false" />
  </booleanSlotMention>
  <classMention id="cellular_component_Instance_330553">
    <mentionClass id="GO:0045251">electron transfer flavoprotein complex</mentionClass>
    <hasSlotMention id="cellular_component_Instance_330556" />
  </classMention>
  <booleanSlotMention id="cellular_component_Instance_330556">
    <mentionSlot id="macromolecular complex or protein ambiguity" />
    <booleanSlotMentionValue value="true" />
  </booleanSlotMention>
  <classMention id="cellular_component_Instance_200163">
    <mentionClass id="GO:0019814">immunoglobulin complex</mentionClass>
    <hasSlotMention id="cellular_component_Instance_200169" />
  </classMention>
  <booleanSlotMention id="cellular_component_Instance_200169">
    <mentionSlot id="macromolecular complex or protein ambiguity" />
    <booleanSlotMentionValue value="false" />
  </booleanSlotMention>
  <classMention id="cellular_component_Instance_200145">
    <mentionClass id="GO:0005739">mitochondrion</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_185460">
    <mentionClass id="GO:0005623">cell</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_200123">
    <mentionClass id="GO:0005730">nucleolus</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_185458">
    <mentionClass id="GO:0005623">cell</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_200118">
    <mentionClass id="GO:0031982">vesicle</mentionClass>
  </classMention>
  <classMention id="cellular_component_new_Instance_27976">
    <mentionClass id="GO:0005759">mitochondrial matrix</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_330541">
    <mentionClass id="GO:0045251">electron transfer flavoprotein complex</mentionClass>
    <hasSlotMention id="cellular_component_Instance_330544" />
  </classMention>
  <booleanSlotMention id="cellular_component_Instance_330544">
    <mentionSlot id="macromolecular complex or protein ambiguity" />
    <booleanSlotMentionValue value="true" />
  </booleanSlotMention>
  <classMention id="cellular_component_new_Instance_27974">
    <mentionClass id="GO:0005829">cytosol</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_330537">
    <mentionClass id="GO:0045251">electron transfer flavoprotein complex</mentionClass>
    <hasSlotMention id="cellular_component_Instance_330540" />
  </classMention>
  <booleanSlotMention id="cellular_component_Instance_330540">
    <mentionSlot id="macromolecular complex or protein ambiguity" />
    <booleanSlotMentionValue value="true" />
  </booleanSlotMention>
  <classMention id="cellular_component_new_Instance_27972">
    <mentionClass id="GO:0005634">nucleus</mentionClass>
  </classMention>
  <classMention id="cellular_component_Instance_200170">
    <mentionClass id="GO:0019814">immunoglobulin complex</mentionClass>
    <hasSlotMention id="cellular_component_Instance_200176" />
  </classMention>
  <booleanSlotMention id="cellular_component_Instance_200176">
    <mentionSlot id="macromolecular complex or protein ambiguity" />
    <booleanSlotMentionValue value="false" />
  </booleanSlotMention>
  <classMention id="cellular_component_Instance_330533">
    <mentionClass id="GO:0045251">electron transfer flavoprotein complex</mentionClass>
    <hasSlotMention id="cellular_component_Instance_330536" />
  </classMention>
  <booleanSlotMention id="cellular_component_Instance_330536">
    <mentionSlot id="macromolecular complex or protein ambiguity" />
    <booleanSlotMentionValue value="true" />
  </booleanSlotMention>
</annotations>


text:
package org.tmoerman.plongeur.tda

import org.tmoerman.plongeur.util.IterableFunctions

import scalaz.Memo
import Model._

/**
  * Inspections on a TDA result only needed in debugging/analysis context.
  *
  * @author Thomas Moerman
  */
object Inspections {

  implicit def pimpTdaResult(result: TDAResult)(implicit counter: (Any => Int)): TDAResultInspections = new TDAResultInspections(result, counter)

  def mapToInt: (Any => Int) = {
    val source = Stream.iterate(0)(_ + 1).iterator
    Memo.mutableHashMapMemo(_ => source.next)
  }

  val r = scala.util.Random

  def format(result: TDAResult) = Map(
    "nodes" -> result.clusters.map(c =>
      Map(
        "id"     -> c.id.toString,
        "label"  -> c.id.toString,
        "size"   -> c.dataPoints.size,
        "x"      -> r.nextInt(100),
        "y"      -> r.nextInt(100))),
    "edges" -> result.edges.map(e => {
      val (from, to) = e.toArray match {case Array(f, t) => (f, t)}

      Map(
        "id"     -> s"$from--$to",
        "source" -> from.toString,
        "target" -> to.toString)}))

//  def json(result: TDAResult) = {
//    import play.api.libs.json._
//
//    JsObject(
//      Seq(
//        "nodes" -> JsArray(
//          result.clusters.map(c => {
//            JsObject(Seq(
//              "id"    -> JsString(c.id.toString),
//              "label" -> JsString(c.id.toString),
//              "size"  -> JsNumber(c.dataPoints.size),
//              "x"     -> JsNumber(r.nextInt(100)),
//              "y"     -> JsNumber(r.nextInt(100))))
//          })),
//        "edges" -> JsArray(
//          result.edges.map(e => {
//            val (from, to) = e.toArray match {case Array(f, t) => (f, t)}
//            JsObject(Seq(
//              "id"     -> JsString(s"$from--$to"),
//              "source" -> JsString(from.toString),
//              "target" -> JsString(to.toString)))
//          }))))
//  }

}

class TDAResultInspections(val result: TDAResult,
                           val clusterCounter: (Any => Int)) extends Serializable {

  def dotGraph(name: String) =
    Seq(
      s"graph $name {",
      result.clusters.map(_.id).map(clusterCounter).sorted.mkString("\n"),
      result.edges
        .map(_.map(clusterCounter))
        .map(_.toArray match { case Array(x, y) => s"$x -- $y" })
        .sorted
        .mkString("\n"),
      "}").mkString("\n")

  def connectedComponents: Seq[Set[Int]] = Nil // TODO complete

  def clusterPoints =
    result
      .clusters
      .sortBy(_.id.toString)
      .map(cluster => "[c." + clusterCounter(cluster.id) + "]" + " -> " + cluster.dataPoints.map(_.index).toList.sorted.mkString(", "))

  import IterableFunctions._

  def levelSetsToClusters =
    result
        .clustersRDD
        .keyBy(_.levelSetID)
        .groupByKey
        .sortBy(_._1)
        .collect
        .map{ case (levelSetID, clusters) => levelSetID.mkString(" ") + " [" + clusters.flatMap(_.dataPoints).map(_.index).min + ", " + clusters.flatMap(_.dataPoints).map(_.index).max + "]" + "\n" +
          clusters
            .toSeq
            .map(cluster => "  [c." + clusterCounter(cluster.id) + "]" + " -> " + cluster.dataPoints.map(_.index).toList.sorted.mkString(", "))
            .sorted
            .mkString("\n")
        }

  def pointsToClusters =
    result
      .clustersRDD
      .flatMap(cluster => cluster.dataPoints.map(p => (p.index, cluster.id)))
      .groupByKey
      .sortBy(_._1)
      .collect
      .map{ case (point, clusterIds) => point + " -> " + clusterIds.map(clusterCounter).toList.sorted.mkString(", ") }

}


text:
#pragma warning disable CS1591
using Newtonsoft.Json;

namespace Discord.API
{
    internal class Application
    {
        [JsonProperty("description")]
        public string Description { get; set; }
        [JsonProperty("rpc_origins")]
        public string[] RPCOrigins { get; set; }
        [JsonProperty("name")]
        public string Name { get; set; }
        [JsonProperty("id")]
        public ulong Id { get; set; }
        [JsonProperty("icon")]
        public string Icon { get; set; }

        [JsonProperty("flags"), Int53]
        public Optional<ulong> Flags { get; set; }
        [JsonProperty("owner")]
        public Optional<User> Owner { get; set; }
    }
}


text:
/*
  PlainPyramidDomain.hpp

  Li-Yi Wei
  October 17, 2014

*/

#ifndef _PLAIN_PYRAMID_DOMAIN_HPP
#define _PLAIN_PYRAMID_DOMAIN_HPP

#include "PyramidDomain.hpp"

class PlainPyramidDomain : public PyramidDomain
{
public:

    bool Trace(const vector<int> & source_size, const vector<int> & source_index, const vector<int> & destination_size, vector<int> & destination_index) const;
};
#endif


text:
> **DEPRECATED. At 2amigos we are not longer supporting Yii 1. We highly recommend you to adopt Yii 2 as soon as possible.**

Yiinitializr
============

Library that will help boost your application installation with ease and also to run Yii applications from its
bootstrap files on a much cleaner way that the framework currently proposes. For example:

```

// if installed via composer
require('./../../common/lib/vendor/autoload.php');

Yiinitializr\Helpers\Initializer::create('./../', 'frontend', array(
	__DIR__ .'/../../common/config/main.php',
	__DIR__ .'/../../common/config/env.php',
	__DIR__ .'/../../common/config/local.php'
))->run();
```

##How to use it
If you are going to use Yiinitializr to make use of `Yiinitializr\Helpers\Initializr` you can easily install it via
`composer`, but if you are going to use it within your application structure in order to configure your application
according to your custom needs, then the recommended use is that you [download](https://github.com/2amigos/yiinitializr/archive/master.zip)
its source files and place them on a top level folder.

###Configuration Settings
As with Yii, you need to go through a bit of configuration settings if you wish to handle your project structure setup
with `composer`. Don't worry, is not going to be too hard, the following is an example configuration file:

```
\\ where am i?
$dirname = dirname(__FILE__);
\\ where is the application folder?
$app = $dirname . '/../../..';
\\ where is the root?
$root = $app . '/..';

return array(
    // yii configurations
	'yii' => array(
		// where is the path of the yii framework?
		// On this example we have installed yii with composer
		// and as it is used after composer installation, we
		// can safely point to the vendor folder.
		'path' => $app . '/lib/vendor/yiisoft/yii/framework'
	),
	// yiinitializr specific settings
	'yiinitializr' => array(
	    // config folders
		'config' => array(
		    // we just need the console settings
		    // On this example, and due that I used environments
		    // i created a custom console.php app for
		    // Yiinitializr\Composer\Callbak class (see below example)
			'console' => $dirname . '/console.php'
		),
		// application structure settings
		'app' => array(
			// where is the root?
			'root' => $root,
			// directories setup
			'directories' => array(
				// where are the different configuration files settings?
				'config' => array(
					// 'key' is the configuration name (see above init example)
					'main' => $app . '/config',
					'console' => $app . '/config',
					'test' => $app . '/config'
				),
				// where are my runtime folders?
				'runtime' => array(
					// heads up! only the folder location as "/config" will be
					// appended
					$app
				),
				'assets' => array(
					// where to write the "assets folders"?
					$root . '/www'
				)
			),
			'files' => array(
				// files to merge the main configuration file with
				// initializr will merge it automatically
				'config' => array(
					'main' => array('env', 'local'),
					'console' => array('env', 'local'),
				)
			)
		),
	)
);
```

Here is an example of a custom `console.php` settings file when working with environments. As you saw on the previous
code, this file on the example was located on the same `Yiinitializr\config` folder:

```
require_once dirname(__FILE__) . '/../Helpers/Initializer.php';
require_once dirname(__FILE__) . '/../Helpers/ArrayX.php';

return Yiinitializr\Helpers\ArrayX::merge(
	Yiinitializr\Helpers\Initializer::config('console', array('common', 'env', 'local')),
	array(
		'params' => array(
			// here is where the composer magic start.
			// Thanks! mr Tobias a.k.a Phundament man!
			'composer.callbacks' => array(
				'post-update' => array('yiic', 'migrate'),
				'post-install' => array('yiic', 'migrate'),
			)
		),
	)
);
```

####Examples

- [YIInitializr-basic](https://github.com/tonydspaniard/yiinitializr-basic)
- [YIInitializr-intermediate](https://github.com/tonydspaniard/yiinitializr-intermediate)
- [YIInitializr-advanced](https://github.com/tonydspaniard/yiinitializr-advanced)

###Requirements
It works in conjunction with `composer` to install the boilerplate but
The minimum requirements by Yiinitializr that you have installed `composer` or have a `composer.phar` on your application
root in order to run and ** PHP 5.3+**

###Resources
- [Composer](http://getcomposer.org)
- [Phundament](http://phundament.com/)
- [Download latest ZIPball](https://github.com/2amigos/yiinitializr/archive/master.zip)
- [2amigOS Packagist Profile](https://packagist.org/packages/2amigos/)

> [![2amigOS!](http://www.gravatar.com/avatar/55363394d72945ff7ed312556ec041e0.png)](http://www.2amigos.us)
<i>web development has never been so fun</i>
[www.2amigos.us](http://www.2amigos.us)


text:
ArrayProto = Array.prototype;
var slice  = ArrayProto.slice,
    nativeForEach = ArrayProto.forEach,
    breaker = {};

// The cornerstone, an `each` implementation, aka `forEach`.
// Handles objects with the built-in `forEach`, arrays, and raw objects.
// Delegates to **ECMAScript 5**'s native `forEach` if available.
var each = function(obj, iterator, context) {
    if (obj == null) return;
    if (nativeForEach && obj.forEach === nativeForEach) {
        obj.forEach(iterator, context);
    } else if (obj.length === +obj.length) {
        for (var i = 0, l = obj.length; i < l; i++) {
            if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) return;
        }
    } else {
        for (var key in obj) {
            if (_.has(obj, key)) {
                if (iterator.call(context, obj[key], key, obj) === breaker) return;
            }
        }
    }
};

// Extend a given object with all the properties in passed-in object(s).
var extend = function(obj) {
    each(slice.call(arguments, 1), function(source) {
        for (var prop in source) {
            obj[prop] = source[prop];
        }
    });
    return obj;
};

var sumObjects = function(calc, obj) {
    for (var k in obj) {
        if(isNaN(parseInt(obj[k]))) {
            sumObjects(calc[k], obj[k]);
//            sumObjects(calc[k], obj[k]);
        } else
            calc[k] += obj[k];
    }
};

// Pathindia Reduce Helpers
// --------------------------------------------------

var PathIndiaAntenatalStats = function () {
    var self = this;
    self.calc = {
        missed_period: 0,
        confirmed_preg: 0,
        using_contraception: 0,
        registered_preg: 0,
        reg_place: {
            govt: 0,
            priv: 0
        },
        early_registration: 0,
        anc_examination: 0,
        stats: {
            bp: 0,
            weight: 0,
            abdominal_exam: 0,
            hb_exam: 0
        },
        hb: {
            low: 0,
            avg: 0,
            high: 0
        },
        tt_booster: 0,
        ifa_tabs: 0,
        injection_syrup: 0,
        danger_signs: {
            headache: 0,
            blurred_vision: 0,
            edema: 0,
            fetal_mvmt: 0,
            bleeding: 0
        },
        delivery_place: {
            govt: 0,
            priv: 0
        }
    };

    self.rereduce = function (agEntry) {
        sumObjects(self.calc, agEntry);
    };

    self.reduce = function (anc) {
        self.calc.missed_period += anc.missed_period ? 1 : 0;
        self.calc.confirmed_preg += anc.pregnancy_confirmation ? 1 : 0;
        self.calc.using_contraception += anc.using_contraception ? 1 : 0;

        if (anc.is_anc_visit === true) {
            self.calc.anc_examination += 1;
            self.calc.registered_preg += anc.pregnancy_registration ? 1 : 0;
            self.calc.reg_place.govt += (anc.pregnancy_registration_place === 'government') ? 1 : 0;
            self.calc.reg_place.priv += (anc.pregnancy_registration_place === 'private') ? 1 : 0;

            if (anc.pregnancy_registration &&
                anc.pregnancy_registration_date &&
                anc.lmp) {
                var lmpDate = new Date(anc.lmp),
                    pregRegDate = new Date(anc.pregnancy_registration_date);
                self.calc.early_registration += (Math.abs(pregRegDate.getTime() - lmpDate.getTime()) <= 84*24*60*60*1000) ? 1 : 0;
            }

            self.calc.stats.bp += anc.most_recent_anc_visit_bp ? 1 : 0;
            self.calc.stats.weight += anc.most_recent_anc_visit_weight ? 1 : 0;
            self.calc.stats.abdominal_exam += anc.most_recent_anc_visit_abdomen ? 1 : 0;
            self.calc.stats.hb_exam += anc.anc_hemoglobin ? 1 : 0;

            self.calc.hb.low += (anc.hemoglobin_value < 7) ? 1 : 0;
            self.calc.hb.avg += (7 <= anc.hemoglobin_value && anc.hemoglobin_value <= 10) ? 1 : 0;
            self.calc.hb.high += (anc.hemoglobin_value > 10) ? 1 : 0;

            self.calc.tt_booster += (anc.tetanus_which_ones === 'tt2' || anc.tetanus_which_ones === 'booster') ? 1 : 0;
            self.calc.ifa_tabs += (anc.how_many_ifa_total > 100) ? 1 : 0;
            self.calc.injection_syrup += (anc.injection_syrup_received) ? 1 : 0;

            self.calc.danger_signs.headache += (anc.anc_headache) ? 1 : 0;
            self.calc.danger_signs.blurred_vision += (anc.anc_blurred_vision) ? 1 : 0;
            self.calc.danger_signs.edema += (anc.anc_edema) ? 1 : 0;
            self.calc.danger_signs.fetal_mvmt += (anc.anc_no_fetal_mvmt) ? 1 : 0;
            self.calc.danger_signs.bleeding += (anc.anc_bleeding) ? 1 : 0;

            self.calc.delivery_place.govt += (anc.delivery_place_determined === 'government_hospital') ? 1 : 0;
            self.calc.delivery_place.priv += (anc.delivery_place_determined === 'private_hospital') ? 1 : 0;
        }

    };

    self.getResult = function () {
        return { antenatal: self.calc };
    };
};

var PathIndiaIntranatalStats = function () {
    var self = this;
    self.calc = {
        outcome: {
            live_birth: 0,
            still_birth: 0,
            abortion: 0
        },
        place: {
            govt: 0,
            priv: 0,
            home: 0
        },
        type: {
            normal: 0,
            lscs: 0,
            forceps: 0
        },
        sex: {
            male: 0,
            female: 0
        },
        weight: {
            low: 0,
            avg: 0,
            high: 0
        }
    };

    self.rereduce = function (agEntry) {
        sumObjects(self.calc, agEntry);
    };

    self.reduce = function (inc) {
        self.calc.outcome.live_birth += (inc.pregnancy_outcome === 'live_birth') ? 1 : 0;
        self.calc.outcome.still_birth += (inc.pregnancy_outcome === 'still_birth') ? 1 : 0;
        self.calc.outcome.abortion += (inc.pregnancy_outcome === 'abortion') ? 1 : 0;

        self.calc.place.govt += (inc.birth_place === 'government_hospital') ? 1 : 0;
        self.calc.place.priv += (inc.birth_place === 'private_hospital') ? 1 : 0;
        self.calc.place.home += (inc.birth_place === 'home') ? 1 : 0;

        self.calc.type.normal += (inc.delivery_type === 'normal') ? 1 : 0;
        self.calc.type.lscs += (inc.delivery_type === 'instrumental') ? 1 : 0;
        self.calc.type.forceps += (inc.delivery_type === 'ceasarean') ? 1 : 0;

        self.calc.sex.male += (inc.child_sex === 'male') ? 1 : 0;
        self.calc.sex.female += (inc.child_sex === 'female') ? 1 : 0;

        self.calc.weight.low += (inc.birth_weight < 2) ? 1 : 0;
        self.calc.weight.avg += (2 <= inc.birth_weight && inc.birth_weight <= 2.5) ? 1 : 0;
        self.calc.weight.high += (inc.birth_weight > 2.5) ? 1 : 0;
    };

    self.getResult = function () {
        return { intranatal: self.calc };
    };
};

var PathIndiaPostnatalStats = function () {
    var self = this;
    self.calc = {
        currently_breastfeeding: 0,
        at_least_one_pnc: 0,
        no_pnc: 0,
        complications: {
            bleeding: 0,
            fever: 0,
            convulsions: 0
        },
        jsy: 0
    };

    self.rereduce = function (agEntry) {
        sumObjects(self.calc, agEntry);
    };

    self.reduce = function (pnc) {
        self.calc.currently_breastfeeding += (pnc.breastfeeding_outcome) ? 1 : 0;
        self.calc.at_least_one_pnc += (pnc.pnc_checkup !== 'no_pnc') ? 1 : 0;
        self.calc.no_pnc += (pnc.pnc_checkup === 'no_pnc') ? 1 : 0;

        self.calc.complications.bleeding += (pnc.pnc_complications === 'bleeding') ? 1 : 0;
        self.calc.complications.fever += (pnc.pnc_complications === 'fever') ? 1 : 0;
        self.calc.complications.convulsions += (pnc.pnc_complications === 'convulsions') ? 1 : 0;

        self.calc.jsy += (pnc.jsy_received) ? 1 : 0;
    };

    self.getResult = function () {
        return { postnatal: self.calc };
    };
};