text:
<?php
namespace php_active_record;

class test_archive_validator extends SimpletestUnitBase
{
    function setUp()
    {
        parent::setUp();
        recursive_rmdir_contents(DOC_ROOT . "vendor/eol_content_schema_v2/extension_cache/");
        $this->archive_directory = DOC_ROOT . "tmp/test_archive_validator/";
        // delete the contents of the created archive
        if(!file_exists($this->archive_directory)) mkdir($this->archive_directory);
        $this->archive_builder = new \eol_schema\ContentArchiveBuilder(array('directory_path' => $this->archive_directory));
    }

    function tearDown()
    {
        $files_in_archive = read_dir($this->archive_directory);
        foreach($files_in_archive as $file)
        {
            if(substr($file, 0, 1) == '.') continue;
            unlink($this->archive_directory . $file);
        }
        rmdir($this->archive_directory);
        unset($this->archive_builder);
        parent::tearDown();
    }

    function reset()
    {
        // delete existing files
        $files_in_archive = read_dir($this->archive_directory);
        foreach($files_in_archive as $file)
        {
            if(substr($file, 0, 1) == '.') continue;
            unlink($this->archive_directory . $file);
        }
        $this->archive_builder = new \eol_schema\ContentArchiveBuilder(array('directory_path' => $this->archive_directory));
    }

    function testValidateTaxonComplete()
    {
        $t = new \eol_schema\Taxon();
        $t->taxonID = "12345";
        $t->scientificName = "Aus bus";
        $t->taxonRank = "species";
        $t->taxonomicStatus = "accepted";
        $this->archive_builder->write_object_to_file($t);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->assertFalse($warnings);
    }

    function testValidateTaxonID()
    {
        $t = new \eol_schema\Taxon();
        $t->scientificName = "Aus bus";
        $this->archive_builder->write_object_to_file($t);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertTrue($errors, 'There should be errors');
        $this->assertTrue($errors[0]->file == 'taxon.tab');
        $this->assertTrue($errors[0]->message == 'Taxa must have identifiers');
        $this->reset();

        // identifier used in the place of TaxonID is OK. We'll interpret it as TaxonID
        $t = new \eol_schema\Taxon();
        $t->identifier = "12345";
        $t->scientificName = "Aus bus";
        $this->archive_builder->write_object_to_file($t);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->assertFalse($warnings);
    }

    function testValidateTaxonScientificName()
    {
        $t = new \eol_schema\Taxon();
        $t->taxonID = "12345";
        $this->archive_builder->write_object_to_file($t);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->assertTrue($warnings, 'There should be warnings');
        $this->assertTrue($warnings[0]->uri == 'http://rs.tdwg.org/dwc/terms/scientificName');
        $this->assertTrue($warnings[0]->message == 'Taxa should have scientificNames');
    }

    function testValidateTaxonAnyName()
    {
        $t = new \eol_schema\Taxon();
        $t->taxonID = "12345";
        $t->scientificName = "Aus bus";
        $this->archive_builder->write_object_to_file($t);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->assertFalse($warnings);
        $this->reset();

        $t = new \eol_schema\Taxon();
        $t->taxonID = "12345";
        $t->genus = "Aus";
        $this->archive_builder->write_object_to_file($t);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->assertTrue($warnings, 'There should be warnings');
        $this->assertTrue(count($warnings) == 1, 'There should be only one warning');
        $this->assertTrue($warnings[0]->uri == 'http://rs.tdwg.org/dwc/terms/scientificName');
        $this->assertTrue($warnings[0]->message == 'Taxa should have scientificNames');
        $this->reset();

        $t = new \eol_schema\Taxon();
        $t->taxonID = "12345";
        $t->family = "Aus";
        $this->archive_builder->write_object_to_file($t);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->assertTrue($warnings, 'There should be warnings');
        $this->assertTrue(count($warnings) == 1, 'There should be only one warning');
        $this->assertTrue($warnings[0]->uri == 'http://rs.tdwg.org/dwc/terms/scientificName');
        $this->assertTrue($warnings[0]->message == 'Taxa should have scientificNames');
        $this->reset();

        $t = new \eol_schema\Taxon();
        $t->taxonID = "12345";
        $t->order = "Aus";
        $this->archive_builder->write_object_to_file($t);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->assertTrue($warnings, 'There should be warnings');
        $this->assertTrue(count($warnings) == 1, 'There should be only one warning');
        $this->assertTrue($warnings[0]->uri == 'http://rs.tdwg.org/dwc/terms/scientificName');
        $this->assertTrue($warnings[0]->message == 'Taxa should have scientificNames');
        $this->reset();

        $t = new \eol_schema\Taxon();
        $t->taxonID = "12345";
        $t->class = "Aus";
        $this->archive_builder->write_object_to_file($t);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->assertTrue($warnings, 'There should be warnings');
        $this->assertTrue(count($warnings) == 1, 'There should be only one warning');
        $this->assertTrue($warnings[0]->uri == 'http://rs.tdwg.org/dwc/terms/scientificName');
        $this->assertTrue($warnings[0]->message == 'Taxa should have scientificNames');
        $this->reset();

        $t = new \eol_schema\Taxon();
        $t->taxonID = "12345";
        $t->phylum = "Aus";
        $this->archive_builder->write_object_to_file($t);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->assertTrue($warnings, 'There should be warnings');
        $this->assertTrue(count($warnings) == 1, 'There should be only one warning');
        $this->assertTrue($warnings[0]->uri == 'http://rs.tdwg.org/dwc/terms/scientificName');
        $this->assertTrue($warnings[0]->message == 'Taxa should have scientificNames');
        $this->reset();

        $t = new \eol_schema\Taxon();
        $t->taxonID = "12345";
        $t->kingdom = "Aus";
        $this->archive_builder->write_object_to_file($t);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->assertTrue($warnings, 'There should be warnings');
        $this->assertTrue(count($warnings) == 1, 'There should be only one warning');
        $this->assertTrue($warnings[0]->uri == 'http://rs.tdwg.org/dwc/terms/scientificName');
        $this->assertTrue($warnings[0]->message == 'Taxa should have scientificNames');
        $this->reset();
    }

    function testValidateTaxonRank()
    {
        $t = new \eol_schema\Taxon();
        $t->taxonID = "12345";
        $t->scientificName = "Aus bus";
        $t->taxonRank = "nonsense";
        $this->archive_builder->write_object_to_file($t);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->assertTrue($warnings, 'There should be warnings');
        $this->assertTrue(count($warnings) == 1, 'There should be only one warning');
        $this->assertTrue($warnings[0]->uri == 'http://rs.tdwg.org/dwc/terms/taxonRank');
        $this->assertTrue($warnings[0]->message == 'Unrecognized taxon rank');
    }

    function testValidateTaxonStatus()
    {
        $t = new \eol_schema\Taxon();
        $t->taxonID = "12345";
        $t->scientificName = "Aus bus";
        $t->taxonomicStatus = "nonsense";
        $this->archive_builder->write_object_to_file($t);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->assertTrue($warnings, 'There should be warnings');
        $this->assertTrue(count($warnings) == 1, 'There should be only one warning');
        $this->assertTrue($warnings[0]->uri == 'http://rs.tdwg.org/dwc/terms/taxonomicStatus');
        $this->assertTrue($warnings[0]->message == 'Unrecognized taxonomicStatus');
    }

    function testValidateMediaID()
    {
        $mr = new \eol_schema\MediaResource();
        $mr->title = 'not much here';
        $this->archive_builder->write_object_to_file($mr);
        $mr = new \eol_schema\MediaResource();
        $mr->identifier = 'someid';
        $mr->title = 'not much here';
        $this->archive_builder->write_object_to_file($mr);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertTrue($errors, 'There should be errors');
        $this->assertTrue($errors[0]->uri == 'http://purl.org/dc/terms/identifier');
        $this->assertTrue($errors[0]->message == 'Media must have identifiers');
        $this->assertTrue($errors[1]->uri == 'http://rs.tdwg.org/dwc/terms/taxonID');
        $this->assertTrue($errors[1]->message == 'Media must have taxonIDs');
        $this->assertTrue($errors[2]->uri == 'http://purl.org/dc/terms/type');
        $this->assertTrue($errors[2]->message == 'DataType must be present');
    }

    function testValidateImagesNeedUrls()
    {
        $mr = new \eol_schema\MediaResource();
        $mr->identifier = "12345";
        $mr->type = 'http://purl.org/dc/dcmitype/StillImage';
        $mr->UsageTerms = 'http://creativecommons.org/licenses/by/3.0/';
        $this->archive_builder->write_object_to_file($mr);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertTrue($errors, 'There should be errors');
        $this->assertTrue($errors[0]->message == 'Media must have taxonIDs');
        $this->assertTrue($errors[1]->message == 'Multimedia must have accessURIs');
    }

    function testValidateLicense()
    {
        $mr = new \eol_schema\MediaResource();
        $mr->identifier = "12345";
        $mr->taxonID = "99999";
        $mr->type = 'http://purl.org/dc/dcmitype/Text';
        $mr->description = "This is the text";
        $mr->CVterm = "http://rs.tdwg.org/ontology/voc/SPMInfoItems#Description";
        $mr->UsageTerms = 'http://creativecommons.org/licenses/by/3.0/';
        $this->archive_builder->write_object_to_file($mr);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->reset();

        $mr->UsageTerms = 'not applicable';
        $this->archive_builder->write_object_to_file($mr);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->reset();

        $mr->UsageTerms = 'no known copyright restrictions';
        $this->archive_builder->write_object_to_file($mr);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->reset();

        $mr->UsageTerms = 'http://www.flickr.com/commons/usage/';
        $this->archive_builder->write_object_to_file($mr);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->reset();

        $mr->UsageTerms = 'http://creativecommons.org/publicdomain/zero/1.0/';
        $this->archive_builder->write_object_to_file($mr);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->reset();

        $mr->UsageTerms = NULL;
        $mr->license = 'http://creativecommons.org/publicdomain/zero/1.0/';
        $this->archive_builder->write_object_to_file($mr);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->reset();

        $mr->license = 'http://creativecommons.org/licences/by/3.0/';
        $this->archive_builder->write_object_to_file($mr);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->reset();

        $mr->license = NULL;
        $mr->UsageTerms = 'nonsense';
        $this->archive_builder->write_object_to_file($mr);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertTrue($errors, 'There should be errors');
        $this->assertTrue($errors[0]->message == 'Invalid license');
    }

    function testValidateReferenceID()
    {
        $r = new \eol_schema\Reference();
        $r->title = 'not much here';
        $this->archive_builder->write_object_to_file($r);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertTrue($errors, 'There should be errors');
        $this->assertTrue($errors[0]->message == 'References must have identifiers');
        $this->reset();

        $r = new \eol_schema\Reference();
        $r->identifier = '1234';
        $r->title = 'more here';
        $this->archive_builder->write_object_to_file($r);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
    }

    function testValidateReferencesNeedTitles()
    {
        $r = new \eol_schema\Reference();
        $r->identifier = '123';
        $r->volume = 3;
        $this->archive_builder->write_object_to_file($r);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertTrue($errors, 'There should be errors');
        $this->assertTrue($errors[0]->message == 'References must minimally contain a full_reference or title');
        $this->reset();

        $r = new \eol_schema\Reference();
        $r->identifier = '123';
        $r->volume = 3;
        $r->full_reference = 'this is where its at';
        $this->archive_builder->write_object_to_file($r);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->reset();

        $r = new \eol_schema\Reference();
        $r->identifier = '123';
        $r->volume = 3;
        $r->title = 'this is where its at';
        $this->archive_builder->write_object_to_file($r);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->reset();

        $r = new \eol_schema\Reference();
        $r->identifier = '123';
        $r->volume = 3;
        $r->primaryTitle = 'this is where its at';
        $this->archive_builder->write_object_to_file($r);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
    }

    function testValidateAgentID()
    {
        $a = new \eol_schema\Agent();
        $a->term_name = 'Thomas Jefferson';
        $this->archive_builder->write_object_to_file($a);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertTrue($errors, 'There should be errors');
        $this->assertTrue($errors[0]->message == 'Agents must have identifiers');
        $this->reset();

        $a = new \eol_schema\Agent();
        $a->identifier = '1234';
        $a->term_name = 'Thomas Jefferson';
        $this->archive_builder->write_object_to_file($a);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
    }

    function testValidateAgentLogoURL()
    {
        $a = new \eol_schema\Agent();
        $a->identifier = '1234';
        $a->term_name = 'Thomas Jefferson';
        $a->term_logo = 'not a url';
        $this->archive_builder->write_object_to_file($a);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertTrue($errors, 'There should be errors');
        $this->assertTrue($errors[0]->message == 'Invalid URL');
        $this->reset();

        $a = new \eol_schema\Agent();
        $a->identifier = '1234';
        $a->term_name = 'Thomas Jefferson';
        $a->term_logo = 'http://something';
        $this->archive_builder->write_object_to_file($a);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertTrue($errors, 'There should be errors');
        $this->assertTrue($errors[0]->message == 'Invalid URL');
        $this->reset();

        $a = new \eol_schema\Agent();
        $a->identifier = '1234';
        $a->term_name = 'Thomas Jefferson';
        $a->term_logo = 'http://some.url';
        $this->archive_builder->write_object_to_file($a);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
    }

    function testValidateAgentInvalidRole()
    {
        $a = new \eol_schema\Agent();
        $a->identifier = '1234';
        $a->term_name = 'Thomas Jefferson';
        $a->agentRole = 'president';
        $this->archive_builder->write_object_to_file($a);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertTrue($warnings, 'There should be warnings');
        $this->assertTrue($warnings[0]->message == 'Unrecognized agent role');
        $this->reset();

        $a = new \eol_schema\Agent();
        $a->identifier = '1234';
        $a->term_name = 'Thomas Jefferson';
        $a->agentRole = 'author';
        $this->archive_builder->write_object_to_file($a);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($warnings);
        $this->reset();
    }

    function testValidateAgentsNeedNames()
    {
        $a = new \eol_schema\Agent();
        $a->identifier = '123';
        $a->agentRole = 'photographer';
        $this->archive_builder->write_object_to_file($a);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertTrue($errors, 'There should be errors');
        $this->assertTrue($errors[0]->message == 'Agents must minimally contain a term_name, term_firstName or term_familyName');
        $this->reset();

        $a = new \eol_schema\Agent();
        $a->identifier = '123';
        $a->term_name = 'Thomas Jefferson';
        $a->agentRole = 'photographer';
        $this->archive_builder->write_object_to_file($a);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->reset();

        $a = new \eol_schema\Agent();
        $a->identifier = '123';
        $a->term_firstName = 'Thomas';
        $a->agentRole = 'photographer';
        $this->archive_builder->write_object_to_file($a);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
        $this->reset();

        $a = new \eol_schema\Agent();
        $a->identifier = '123';
        $a->term_familyName = 'Jefferson';
        $a->agentRole = 'photographer';
        $this->archive_builder->write_object_to_file($a);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
    }

    function testValidateVernacularNameTaxonID()
    {
        $v = new \eol_schema\VernacularName();
        $v->vernacularName = 'bluefish';
        $this->archive_builder->write_object_to_file($v);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertTrue($errors, 'There should be errors');
        $this->assertTrue($errors[0]->message == 'Vernacular names must have taxonIDs');
        $this->reset();

        $v = new \eol_schema\VernacularName();
        $v->taxonID = '123';
        $v->vernacularName = 'bluefish';
        $this->archive_builder->write_object_to_file($v);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($errors);
    }

    function testValidateVernacularNameLanguage()
    {
        $v = new \eol_schema\VernacularName();
        $v->taxonID = '123';
        $v->vernacularName = 'bluefish';
        $v->language = 'English';
        $this->archive_builder->write_object_to_file($v);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertTrue($warnings, 'There should be warnings');
        $this->assertTrue($warnings[0]->message == 'Vernacular name languages should use standardized ISO 639 language codes');
        $this->reset();

        $v = new \eol_schema\VernacularName();
        $v->taxonID = '123';
        $v->vernacularName = 'bluefish';
        $v->language = 'eng-american';
        $this->archive_builder->write_object_to_file($v);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertTrue($warnings, 'There should be warnings');
        $this->assertTrue($warnings[0]->message == 'Vernacular name languages should use standardized ISO 639 language codes');
        $this->reset();

        $v = new \eol_schema\VernacularName();
        $v->taxonID = '123';
        $v->vernacularName = 'bluefish';
        $v->language = 'en';
        $this->archive_builder->write_object_to_file($v);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($warnings);
        $this->reset();

        $v = new \eol_schema\VernacularName();
        $v->taxonID = '123';
        $v->vernacularName = 'bluefish';
        $v->language = 'eng';
        $this->archive_builder->write_object_to_file($v);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($warnings);
        $this->reset();

        $v = new \eol_schema\VernacularName();
        $v->taxonID = '123';
        $v->vernacularName = 'bluefish';
        $v->language = 'en-us';
        $this->archive_builder->write_object_to_file($v);
        $this->archive_builder->finalize();
        list($errors, $warnings) = $this->validate();
        $this->assertFalse($warnings);
    }

    private function validate()
    {
        $archive = new ContentArchiveReader(null, $this->archive_directory);
        $validator = new ContentArchiveValidator($archive);
        $validator->get_validation_errors();
        return array($validator->display_errors(), $validator->display_warnings());
    }
}

?>


text:
using System.Collections.Generic;
using AutoMapper;
using PagedList;

namespace Blog.Web.Helpers
{
    public static class AutoMapperHelpers
    {
        public static IMappingExpression<TDestination, TSource> BothWays<TSource, TDestination>
            (this IMappingExpression<TSource, TDestination> mappingExpression)
        {
            return Mapper.CreateMap<TDestination, TSource>();
        }

        public static IPagedList<TDestination> ToMappedPagedList<TSource, TDestination>(this IPagedList<TSource> list)
        {
            IEnumerable<TDestination> sourceList = Mapper.Map<IEnumerable<TSource>, IEnumerable<TDestination>>(list);
            IPagedList<TDestination> pagedResult = new StaticPagedList<TDestination>(sourceList, list.GetMetaData());
            return pagedResult;

        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
current_path=$(pwd)
code_source_path=$current_path/src/StatisticsHelperDemo
target_path=$current_path/bin
build_path=$target_path/build
#
mkdir -p $target_path
rm -rf $target_path/* 2>/dev/null
mkdir -p $build_path
rm -r $build_path/* 2>/dev/null
#
cd $build_path
cmake $code_source_path
make
cd $current_path
echo "installing binaries to $target_path"
cp $build_path/validate_statistics_module $target_path/


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Jb. nassau. Ver. Naturk. 23-24: (1870)

#### Original name
Gibbera euonymi Fuckel

### Remarks
null


text:
var util = require('util');
var flow = require('flow');
var imap = exports;

imap.SEQUENTIAL = 0x0000;
imap.PARALLEL = 0x0001;
imap.RANGED = 0x0002;

imap.DEFAULT = imap.SEQUENTIAL;

imap.flowType = function(flags) {
  flags = flags || imap.DEFAULT;
  return (flags & imap.PARALLEL) ? 'parallel' : 'sequence';
};

function Connection() { };
exports.Connection = Connection;

Connection.prototype.message = function(msg, obj, timeout) {
  var timeout = timeout || 50;
  var response = { status: 'OK' };
  if (typeof obj === 'function') {
    setTimeout(obj.bind(this, response), timeout);
  }
  else {
    var i = 0;
    if (obj.line) for (i = 0; i < 3; i++) {
      var line = i + ': ' + msg;
      setTimeout(obj.line.bind(this, response, line), timeout + i);
    }
    if (obj.complete) setTimeout(obj.complete.bind(this, response), timeout + i * timeout);
  }
};

Connection.prototype.end = function() {
};

function Entity() {}
Entity.prototype.run = flow.run;
Entity.prototype.external = flow.external;

function Account(connection) {
  this.connection = connection;
  this.commands = new flow.Sequence(this);
};
exports.Account = Account;
util.inherits(Account, Entity);

Account.prototype.login = flow.defer(function(flow, user, pass) {
  this.connection.message('LOGIN ' + user + ' ' + pass, function(response) {
    if (response.status === 'OK') flow.next();
    else flow.error('failed to login');
  });
});

Account.prototype.logout = flow.defer(function(flow) {
  this.connection.message('LOGOUT', function(response) {
    this.end();
    flow.next();
  });
});

Account.prototype.mailboxes = flow.defer(function(flow, filter, callback, flags) {
  var group = flow[imap.flowType(flags)](this);

  this.connection.message('LSUB "" "*"', {
    line: function(response, line) {
      group.perform(callback, new imap.Mailbox(group, line));
    },
    complete: function(response) {
      group.complete();
    }
  });
});

function Mailbox(flow, line) {
  this.line = line;
  this.connection = flow.context.connection;
  this.commands = flow.sequence(this);
};
util.inherits(Mailbox, Entity);
exports.Mailbox = Mailbox;

Mailbox.prototype.select = flow.defer(function(flow) {
  var mailbox = this;
  this.connection.message('SELECT ' + mailbox, function() {
    flow.next();
  });
});

Mailbox.prototype.fetch = flow.defer(function(flow, filter, parts, callback, flags) {
  var group = flow.parallel(this);

  this.connection.message('FETCH ' + filter + ' (' + parts.join(', ') + ')', {
    line: function(response, line) {
      group.perform(callback, new imap.Message(group, line));
    },
    complete: function(response) {
      group.complete();
    }
  });
});

function Message(flow, line) {
  this.line = line;
  this.id = 1;
  this.connection = flow.context.connection;
  this.commands = flow.sequence(this);
}
util.inherits(Message, Entity);
exports.Message = Message;

Message.prototype.get = flow.defer(function(flow, parts) {
  if (typeof parts === 'string') parts = [ parts ];

  this.connection.message('FETCH ' + this.id + ' (' + parts.join(', ') + ')', function(response) {
    flow.next();
  });
});


text:
""" TV information related tasks """

__author__ = "the01"
__email__ = "jungflor@gmail.com"
__copyright__ = "Copyright (C) 2014-20, Florian JUNG"
__license__ = "MIT"
__date__ = "2020-06-15"
# Created: 2015-02-26 03:39

import logging

from .__version__ import __version__
from .cli_main import main
from .next_tvdb import TVNextTVDB
from .tv_next import TVNext

logger = logging.getLogger(__name__)  # pylint: disable=invalid-name
__all__ = [
    "__version__",
    "tv_next", "next_tvdb", "cli_main",
    "TVNext", "TVNextTVDB", "main",
]


text:
/**
 * @fileOverview Global functionality. Contains a script loader that will
 * control the initialization flow, initial instantiation of the namespace.
 */

var NS = NS || {};

(function($) {
	/**
	 * @namespace Object that defines which JS gets executed, and in what order.
	 * @see NS.Initializer
	 */
	NS.initialization = {
		global: {
			init: function(){
				console.log('global:init');
			},
			finalize: function(){
				console.log('global:finalize');
			}
		}
	};

	// kick it all off here
	var init = new NS.Initializer();
		init.loadEvents();

})(jQuery);


text:
package com.kloudtek.ktserializer;

import org.jetbrains.annotations.NotNull;

import java.io.IOException;
import java.util.Arrays;

/**
 * Created by yannick on 16/01/2015.
 */
public class LargeTestObj extends AbstractCustomSerializable {
    public byte[] val = new byte[5000];

    public LargeTestObj() {
    }

    public LargeTestObj(byte v) {
        Arrays.fill(val, v);
    }

    @Override
    public void serialize(@NotNull SerializationStream os) throws IOException {
        os.writeData(val);
    }

    @Override
    public void deserialize(@NotNull DeserializationStream is, int version) throws IOException, InvalidSerializedDataException {
        val = is.readData();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        LargeTestObj that = (LargeTestObj) o;

        if (!Arrays.equals(val, that.val)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return Arrays.hashCode(val);
    }
}


text:
"""we_are_social URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url, include
from django.conf import settings
from django.contrib import admin
from django.contrib.flatpages import views
from django.views.static import serve
from paypal.standard.ipn import urls as paypal_urls
from paypal_store import views as paypal_views
from accounts import views as accounts_views
from products import views as product_views
from hello import views as hello_views
from magazines import views as magazine_views
from threads import views as forum_views
from .settings import MEDIA_ROOT

urlpatterns = [  # pylint: disable-msg=C0103
    # admin backend url
    url(r'^admin/', admin.site.urls),
    # hello urls
    url(r'^$', hello_views.get_index, name='index'),
    # accounts urls
    url(r'^register/$', accounts_views.register, name='register'),
    url(r'^login/$', accounts_views.login, name='login'),
    url(r'^profile/$', accounts_views.profile, name='profile'),
    url(r'^logout/$', accounts_views.logout, name='logout'),
    url(r'^about/$', views.flatpage, {'url': '/pages/about/'}, name='about'),
    url(r'^cancel_subscription/$', accounts_views.cancel_subscription, name='cancel_subscription'),
    url(r'^subscriptions_webhook/$', accounts_views.subscriptions_webhook, name='subscriptions_webhook'),
    # paypal urls
    url(r'^a-very-hard-to-guess-url/', include(paypal_urls)),
    url(r'^paypal-return/', paypal_views.paypal_return),
    url(r'^paypal-cancel/', paypal_views.paypal_cancel),
    # products urls
    url(r'^products/$', product_views.all_products),
    # magazines urls
    url(r'^magazines/$', magazine_views.all_magazines),
    # reusable_blog urls
    url(r'^blog/', include('reusable_blog.urls')),
    url(r'^media/(?P<path>.*)$', serve, {'document_root': MEDIA_ROOT}),
    # threads/forum views
    url(r'^forum/$', forum_views.forum),
    url(r'^thread/(?P<thread_id>\d+)/$', forum_views.thread, name='thread'),
    url(r'^threads/(?P<subject_id>\d+)/$', forum_views.threads, name='threads'),
    url(r'^new_thread/(?P<subject_id>\d+)/$', forum_views.new_thread, name='new_thread'),
    url(r'^post/new/(?P<thread_id>\d+)/$', forum_views.new_post, name='new_post'),
    url(r'^post/edit/(?P<thread_id>\d+)/(?P<post_id>\d+)/$', forum_views.edit_post, name='edit_post'),
    url(r'^post/delete/(?P<thread_id>\d+)/(?P<post_id>\d+)/$', forum_views.delete_post, name='delete_post'),
    url(r'^thread/vote/(?P<thread_id>\d+)/(?P<subject_id>\d+)/$', forum_views.thread_vote, name='cast_vote'),
]

# debug_toolbar urls
if settings.DEBUG:
    import debug_toolbar
    urlpatterns.append(url(r'^debug/', include(debug_toolbar.urls))),


text:
<?xml version="1.0" encoding="UTF-8"?>
<!--

     Copyright 2005-2015 Red Hat, Inc.

     Red Hat licenses this file to you under the Apache License, version
     2.0 (the "License"); you may not use this file except in compliance
     with the License.  You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
     implied.  See the License for the specific language governing
     permissions and limitations under the License.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>io.fabric8.quickstarts</groupId>
    <artifactId>karaf</artifactId>
    <version>2.2.84-SNAPSHOT</version>
  </parent>

  <artifactId>karaf-cxf-rest</artifactId>
  <packaging>bundle</packaging>
  <name>Fabric8 :: Quickstarts :: Karaf :: CXF REST</name>
  <description>REST example using CXF in Karaf container</description>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <version.maven-bundle-plugin>2.3.7</version.maven-bundle-plugin>

    <!-- fabric8 version -->
    <fabric8.version>2.2.82</fabric8.version>
    <docker.maven.plugin.version>0.13.6</docker.maven.plugin.version>

    <!-- configure the versions you want to use here -->
    <cxf.version>3.1.4</cxf.version>
    <cxf.plugin.version>3.1.4</cxf.plugin.version>
    <karaf.version>2.4.3</karaf.version>
    <karaf.plugin.version>4.0.3</karaf.plugin.version>

    <docker.from>fabric8/s2i-karaf:1.2</docker.from>
    <fabric8.dockerUser>fabric8/</fabric8.dockerUser>
    <docker.image>${fabric8.dockerUser}${project.artifactId}:${project.version}</docker.image>
    <docker.assemblyDescriptor>${basedir}/src/main/fabric8/assembly.xml</docker.assemblyDescriptor>
    <docker.port.container.jolokia>8778</docker.port.container.jolokia>
    <docker.port.container.http>8181</docker.port.container.http>

    <fabric8.service.name>${project.artifactId}</fabric8.service.name>
    <fabric8.service.port>9412</fabric8.service.port>
    <fabric8.service.containerPort>8181</fabric8.service.containerPort>

    <fabric8.label.component>${project.artifactId}</fabric8.label.component>
    <fabric8.label.container>karaf</fabric8.label.container>
    <fabric8.label.group>quickstarts</fabric8.label.group>
    <fabric8.iconRef>karaf</fabric8.iconRef>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.fabric8</groupId>
        <artifactId>fabric8-project-bom-with-platform-deps</artifactId>
        <version>${fabric8.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>

    <!-- cxf -->
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-core</artifactId>
      <version>${cxf.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-transports-http</artifactId>
      <version>${cxf.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-frontend-jaxrs</artifactId>
      <version>${cxf.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-rs-service-description</artifactId>
      <version>${cxf.version}</version>
    </dependency>

    <!-- swagger -->
    <dependency>
      <groupId>io.swagger</groupId>
      <artifactId>swagger-jaxrs</artifactId>
      <version>1.5.4</version>
      <optional>true</optional>
      <exclusions>
        <!-- avoid this old dependency which breaks CXF -->
        <exclusion>
          <groupId>javax.ws.rs</groupId>
          <artifactId>jsr311-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- Karaf microcontainer dependencies -->
    <dependency>
      <!-- scope is compile so all features (there is only one) are installed into startup.properties,
      and the feature repo itself is not added in etc/org.apache.karaf.features.cfg file -->
      <groupId>org.apache.karaf.features</groupId>
      <artifactId>static</artifactId>
      <version>${karaf.plugin.version}</version>
      <type>kar</type>
      <!-- no need to download kar dependencies -->
      <exclusions>
        <exclusion>
          <groupId>*</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.karaf.assemblies.features</groupId>
      <artifactId>standard</artifactId>
      <version>${karaf.version}</version>
      <classifier>features</classifier>
      <type>xml</type>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf.karaf</groupId>
      <artifactId>apache-cxf</artifactId>
      <version>${cxf.version}</version>
      <classifier>features</classifier>
      <type>xml</type>
    </dependency>

  </dependencies>

  <build>
    <finalName>${project.artifactId}</finalName>

    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
    </resources>

    <plugins>
      <!-- Compiler plugin enforces Java 1.7 compatibility and activates annotation processors -->
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.18.1</version>
      </plugin>

      <!-- Need to setup the OSGi meta information here -->
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>${version.maven-bundle-plugin}</version>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Import-Package>
              javax.ws.rs;version="[2,3)",
              javax.ws.rs.core;version="[2,3)",
              javax.ws.rs.ext;version="[2,3)",
              javax.xml.bind.annotation,
              org.osgi.service.blueprint,
              io.swagger.jaxrs.config,
              io.swagger.jaxrs.listing,
              io.swagger.annotations,
              org.apache.cxf.transport.http,
              io.fabric8.cxf.endpoint,
              com.fasterxml.jackson.annotation,
              com.fasterxml.jackson.core,
              com.fasterxml.jackson.databind,
              com.fasterxml.jackson.jaxrs.json,
              *
            </Import-Package>
            <Export-Package>
              io.fabric8.quickstarts.rest
            </Export-Package>
          </instructions>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-java2wadl-plugin</artifactId>
        <version>${cxf.plugin.version}</version>
        <executions>
          <execution>
            <id>parsejavadoc</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>parsejavadoc</goal>
            </goals>
          </execution>
          <execution>
            <id>process-classes</id>
            <phase>process-classes</phase>
            <goals>
              <goal>java2wadl</goal>
            </goals>
            <configuration>
              <classResourceNames>
                <classResourceName>io.fabric8.quickstarts.rest.CustomerService</classResourceName>
              </classResourceNames>
              <docProvider>org.apache.cxf.maven_plugin.javatowadl.ResourceMapJavaDocProvider</docProvider>
              <attachWadl>false</attachWadl>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>fabric8-cxf-plugins</artifactId>
        <version>${fabric8.version}</version>
        <executions>
          <execution>
            <id>process-classes</id>
            <phase>process-classes</phase>
            <goals>
              <goal>java2swagger</goal>
            </goals>
            <configuration>
              <classResourceNames>
                <classResourceName>io.fabric8.quickstarts.rest.CustomerService</classResourceName>
              </classResourceNames>
              <attachSwagger>false</attachSwagger>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>fabric8-maven-plugin</artifactId>
        <version>${fabric8.version}</version>
        <executions>
          <execution>
            <id>json</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>json</goal>
            </goals>
          </execution>
          <execution>
            <id>attach</id>
            <phase>package</phase>
            <goals>
              <goal>attach</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- attach feature file to install for karaf assembly -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.9.1</version>
        <executions>
          <execution>
            <id>attach-artifacts</id>
            <phase>package</phase>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <configuration>
              <artifacts>
                <artifact>
                  <file>${project.build.outputDirectory}/features.xml</file>
                  <classifier>features</classifier>
                  <type>xml</type>
                </artifact>
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- plugin goals have to be executed in order -->
      <!-- 1. install the bundle and features file -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-install-plugin</artifactId>
        <version>2.5.2</version>
        <executions>
          <execution>
            <id>install-artifacts</id>
            <goals>
              <goal>install</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- 2. create karaf assembly -->
      <!-- karaf-maven-plugin creates custom microservice distribution -->
      <plugin>
        <groupId>org.apache.karaf.tooling</groupId>
        <artifactId>karaf-maven-plugin</artifactId>
        <version>${karaf.plugin.version}</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>karaf-assembly</id>
            <goals>
              <goal>assembly</goal>
            </goals>
            <phase>install</phase>
          </execution>
          <execution>
            <id>karaf-archive</id>
            <goals>
              <goal>archive</goal>
            </goals>
            <phase>install</phase>
          </execution>
        </executions>
        <configuration>
          <karafVersion>v4x</karafVersion>
          <useReferenceUrls>true</useReferenceUrls>
          <!-- do not include build output directory -->
          <includeBuildOutputDirectory>false</includeBuildOutputDirectory>
          <startupRepositories>
            <repo>mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features</repo>
          </startupRepositories>
          <!-- no startupFeatures -->
          <startupFeatures>
            <feature>karaf-framework</feature>
            <feature>jaas</feature>
            <feature>aries-blueprint</feature>

            <feature>cxf-core</feature>
            <feature>cxf-jaxrs</feature>
            <feature>cxf-http-jetty</feature>

            <!-- swagger -->
            <feature>http</feature>
            <feature>cxf-specs</feature>
            <feature>swagger2</feature>
          </startupFeatures>
          <startupBundles>
            <bundle>mvn:io.fabric8/fabric8-cxf/${fabric8.version}</bundle>
            <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
          </startupBundles>
          <blacklistedBundles>
            <bundle>mvn:org.ops4j.pax.logging/pax-logging-api/1.8.4</bundle>
            <bundle>mvn:org.ops4j.pax.logging/pax-logging-service/1.8.4</bundle>
          </blacklistedBundles>
          <libraries>
            <library>
              mvn:org.apache.karaf.jaas/org.apache.karaf.jaas.boot/${karaf.version};type:=boot;export:=true;delegate:=true
            </library>
          </libraries>
        </configuration>
      </plugin>

      <!-- 3. create docker image -->
      <plugin>
        <groupId>org.jolokia</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <version>${docker.maven.plugin.version}</version>
        <configuration>
          <images>
            <image>
              <name>${docker.image}</name>
              <build>
                <from>${docker.from}</from>
                <assembly>
                  <basedir>/deployments</basedir>
                  <user>jboss:jboss:jboss</user>
                  <inline xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
                          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
                    <id>${project.artifactId}</id>
                    <files>
                      <!-- copy karaf archive -->
                      <file>
                        <source>${project.build.directory}/${project.artifactId}-${project.version}.tar.gz</source>
                        <outputDirectory>/</outputDirectory>
                      </file>
                    </files>
                  </inline>
                </assembly>
                <cmd>
                  <shell>/deployments/deploy-and-run.sh</shell>
                </cmd>
              </build>
            </image>
          </images>
        </configuration>
      </plugin>

    </plugins>
  </build>

    <!--
  Default sample commands:

  mvn -Pf8-build         ... build Docker images and create OpenShift deployment configs
  mvn -Pf8-deploy        ... f8-build + push to Docker registry + applying deployment config to OpenShift
  mvn -Pf8-local-deploy ... deployment for a single node setup without pushing to a registry

  For individual goal usage please consult the fabric8 documentation
  -->
  <profiles>
    <profile>
      <id>f8-build</id>
      <build>
        <defaultGoal>clean install docker:build fabric8:json</defaultGoal>
      </build>
    </profile>
    <profile>
      <id>f8-deploy</id>
      <properties>
        <fabric8.imagePullPolicySnapshot>Always</fabric8.imagePullPolicySnapshot>
        <fabric8.recreate>true</fabric8.recreate>
      </properties>
      <build>
        <defaultGoal>clean install docker:build docker:push fabric8:json fabric8:apply</defaultGoal>
      </build>
    </profile>
    <profile>
      <id>f8-local-deploy</id>
      <properties>
        <fabric8.recreate>true</fabric8.recreate>
      </properties>
      <build>
        <defaultGoal>clean install docker:build fabric8:json fabric8:apply</defaultGoal>
      </build>
    </profile>
  </profiles>
</project>


text:
package org.adonai;

import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiDevice;
import javax.sound.midi.MidiMessage;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Receiver;
import javax.sound.midi.ShortMessage;
import javax.sound.midi.Synthesizer;

public class MidiTester {

  public static void main(String[] args) throws MidiUnavailableException, InvalidMidiDataException {

    ShortMessage myMsg = new ShortMessage();
    // Start playing the note Middle C (60),
    // moderately loud (velocity = 93).
    myMsg.setMessage(ShortMessage.NOTE_ON, 0, 60, 93);

    MidiSystem.getTransmitter().setReceiver(MidiSystem.getReceiver());

    MidiDevice device;
    MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
    for (int i = 0; i < infos.length; i++) {

      try {
        device = MidiSystem.getMidiDevice(infos[i]);
        device.open();
        System.out.println (device.getDeviceInfo().getName() + "-" + device.getReceivers().size());
        //does the device have any recievers?
        if (device.getReceivers().size() > 0) {
          //if it does, add it to the device list
          for (Receiver next: device.getReceivers()) {
            System.out.println ("Device: " + device.getDeviceInfo().getName());
            next.send(myMsg, 100);

          }

        }

        device.close();
      } catch (MidiUnavailableException e) {}
    }

    System.out.println ("Done");

  }
}


text:
package org.apache.camel.component.file.remote.integration;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

/**
 * Concurrent producers test.
 */
@Disabled("TODO: investigate for Camel 3.0")
public class FtpProducerConcurrentIT extends FtpServerTestSupport {

    private String getFtpUrl() {
        return "ftp://admin@localhost:{{ftp.server.port}}/concurrent?binary=false&password=admin";
    }

    @Test
    public void testNoConcurrentProducers() throws Exception {
        doSendMessages(1, 1);
    }

    @Test
    public void testConcurrentProducers() throws Exception {
        doSendMessages(10, 5);
    }

    private void doSendMessages(int files, int poolSize) throws Exception {
        getMockEndpoint("mock:result").expectedMessageCount(files);

        ExecutorService executor = Executors.newFixedThreadPool(poolSize);
        for (int i = 0; i < files; i++) {
            getMockEndpoint("mock:result").expectedFileExists(service.ftpFile("concurrent/" + i + ".txt"));

            final int index = i;
            executor.submit(new Callable<Object>() {
                public Object call() {
                    sendFile("direct:start", "Hello World", index + ".txt");
                    return null;
                }
            });
        }

        MockEndpoint.assertIsSatisfied(context);
        executor.shutdownNow();
    }

    @Override
    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            @Override
            public void configure() {
                from("direct:start").to(getFtpUrl(), "mock:result");
            }
        };
    }
}


text:
import optparse
import os
import re
import subprocess
import sys

# Nomenclature:
#   x_root - "x"
#   x_filename - "x.ext"
#   x_path - "path/to/a/b/c/x.ext"
#   c_dir - "path/to/a/b/c"

def generate_and_test(input_filename, source_dir, working_dir,
                      fixup_path, pdfium_test_path):
  input_root, _ = os.path.splitext(input_filename)
  input_path = os.path.join(source_dir, input_root + '.in')
  pdf_path = os.path.join(working_dir, input_root + '.pdf')
  actual_path_template = os.path.join(working_dir, input_root + '.pdf.%d.ppm')
  expected_path_template = os.path.join(source_dir,
                                        input_root + '_expected.pdf.%d.ppm')
  try:
    subprocess.check_call(
        [fixup_path, '--output-dir=' + working_dir, input_path])
    subprocess.check_call([pdfium_test_path, '--ppm', pdf_path])
    i = 0;
    while True:
      expected_path = expected_path_template % i;
      actual_path = actual_path_template % i;
      if not os.path.exists(expected_path):
        break
      subprocess.check_call(['diff', expected_path, actual_path])
      i += 1
  except subprocess.CalledProcessError as e:
    print "FAILURE: " + input_filename + "; " + str(e)

def main():
  parser = optparse.OptionParser()
  parser.add_option('--build-dir', default=os.path.join('out', 'Debug'),
                    help='relative path from the base source directory')
  options, args = parser.parse_args()

  # Expect |my_dir| to be .../pdfium/testing/tools.
  my_dir = os.path.dirname(os.path.realpath(__file__))
  testing_dir = os.path.dirname(my_dir)
  pdfium_dir = os.path.dirname(testing_dir)
  if (os.path.basename(my_dir) != 'tools' or
      os.path.basename(testing_dir) != 'testing'):
    print 'Confused, can not find pdfium root directory, aborting.'
    return 1

  # Other scripts are found in the same directory as this one.
  fixup_path = os.path.join(my_dir, 'fixup_pdf_template.py')

  # test files are in .../pdfium/testing/resources/pixel.
  source_dir = os.path.join(testing_dir, 'resources', 'pixel')

  # Find path to build directory.  This depends on whether this is a
  # standalone build vs. a build as part of a chromium checkout. For
  # standalone, we expect a path like .../pdfium/out/Debug, but for
  # chromium, we expect a path like .../src/out/Debug two levels
  # higher (to skip over the third_party/pdfium path component under
  # which chromium sticks pdfium).
  base_dir = pdfium_dir
  one_up_dir = os.path.dirname(base_dir)
  two_up_dir = os.path.dirname(one_up_dir)
  if (os.path.basename(two_up_dir) == 'src' and
      os.path.basename(one_up_dir) == 'third_party'):
    base_dir = two_up_dir
  build_dir = os.path.join(base_dir, options.build_dir)

  # Compiled binaries are found under the build path.
  pdfium_test_path = os.path.join(build_dir, 'pdfium_test')
  if sys.platform.startswith('win'):
    pdfium_test_path = pdfium_test_path + '.exe'
  # TODO(tsepez): Mac may require special handling here.

  # Place generated files under the build directory, not source directory.
  gen_dir = os.path.join(build_dir, 'gen', 'pdfium')
  working_dir = os.path.join(gen_dir, 'testing', 'pixel')
  if not os.path.exists(working_dir):
    os.makedirs(working_dir)

  input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]in$')
  for input_filename in os.listdir(source_dir):
    if input_file_re.match(input_filename):
      input_path = os.path.join(source_dir, input_filename)
      if os.path.isfile(input_path):
        generate_and_test(input_filename, source_dir, working_dir,
                          fixup_path, pdfium_test_path)
  return 0

if __name__ == '__main__':
  sys.exit(main())


text:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <View
        android:id="@+id/separator"
        android:layout_width="0dp"
        android:layout_height="10dp"
        android:layout_centerInParent="true" />

    <RadioGroup
        android:id="@+id/radio_group"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <RadioButton
            android:id="@+id/type_system_error"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TYPE_SYSTEM_ERROR" />

        <RadioButton
            android:id="@+id/type_system_overlay"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TYPE_SYSTEM_OVERLAY" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#ccc"
            android:gravity="center"
            android:text="ロック画面"
            android:textColor="#000"
            android:textSize="18dp" />

        <RadioButton
            android:id="@+id/type_system_alert"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TYPE_SYSTEM_ALERT" />

        <RadioButton
            android:id="@+id/type_priority_phone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TYPE_PRIORITY_PHONE" />

        <RadioButton
            android:id="@+id/type_toast"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TYPE_TOAST" />

        <RadioButton
            android:id="@+id/type_phone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="TYPE_PHONE" />
    </RadioGroup>

    <Button
        android:id="@+id/button3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_toLeftOf="@id/separator"
        android:text="tutorial view" />

    <Button
        android:id="@+id/button4"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_toRightOf="@id/separator"
        android:text="stop" />

    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/button3"
        android:layout_toLeftOf="@id/separator"
        android:text="floating view" />

    <Button
        android:id="@+id/button2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/button3"
        android:layout_toRightOf="@id/separator"
        android:text="stop" />

    <ImageView
        android:id="@+id/image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</RelativeLayout>


text:
package org.docksidestage.mylasta.action;

import org.lastaflute.web.response.next.HtmlNext;

/**
 * The path definition of HTML.
 * @author FreeGen
 */
public interface MermaidlagHtmlPath {

    /** The path of the HTML: /error/show_errors.html */
    HtmlNext path_Error_ShowErrorsHtml = new HtmlNext("/error/show_errors.html");

    /** The path of the HTML: /mypage/mypage.html */
    HtmlNext path_Mypage_MypageHtml = new HtmlNext("/mypage/mypage.html");

    /** The path of the HTML: /product/product_detail.html */
    HtmlNext path_Product_ProductDetailHtml = new HtmlNext("/product/product_detail.html");

    /** The path of the HTML: /product/product_list.html */
    HtmlNext path_Product_ProductListHtml = new HtmlNext("/product/product_list.html");

    /** The path of the HTML: /product/th_product_list.html */
    HtmlNext path_Product_ThProductListHtml = new HtmlNext("/product/th_product_list.html");

    /** The path of the HTML: /signin/signin.html */
    HtmlNext path_Signin_SigninHtml = new HtmlNext("/signin/signin.html");
}


text:
namespace blink {

class CORE_EXPORT MediaValuesCached final : public MediaValues {
 public:
  struct CORE_EXPORT MediaValuesCachedData final {
    DISALLOW_NEW();
    // Members variables must be thread safe, since they're copied to the parser
    // thread
    double viewport_width = 0;
    double viewport_height = 0;
    double small_viewport_width = 0;
    double small_viewport_height = 0;
    double large_viewport_width = 0;
    double large_viewport_height = 0;
    double dynamic_viewport_width = 0;
    double dynamic_viewport_height = 0;
    int device_width = 0;
    int device_height = 0;
    float device_pixel_ratio = 1.0;
    bool device_supports_hdr = false;
    int color_bits_per_component = 24;
    int monochrome_bits_per_component = 0;
    mojom::blink::PointerType primary_pointer_type =
        mojom::blink::PointerType::kPointerNone;
    // Bitmask of |ui::PointerType|
    int available_pointer_types = ui::POINTER_TYPE_NONE;
    mojom::blink::HoverType primary_hover_type =
        mojom::blink::HoverType::kHoverNone;
    // Bitmask of |ui::HoverType|
    int available_hover_types = ui::HOVER_TYPE_NONE;
    float em_size = 16.f;
    float ex_size = 8.f;
    float ch_size = 8.f;
    bool three_d_enabled = false;
    bool immersive_mode = false;
    bool strict_mode = true;
    String media_type;
    mojom::blink::DisplayMode display_mode =
        mojom::blink::DisplayMode::kBrowser;
    ColorSpaceGamut color_gamut = ColorSpaceGamut::kUnknown;
    mojom::blink::PreferredColorScheme preferred_color_scheme =
        mojom::blink::PreferredColorScheme::kLight;
    mojom::blink::PreferredContrast preferred_contrast =
        mojom::blink::PreferredContrast::kNoPreference;
    bool prefers_reduced_motion = false;
    bool prefers_reduced_data = false;
    ForcedColors forced_colors = ForcedColors::kNone;
    NavigationControls navigation_controls = NavigationControls::kNone;
    int horizontal_viewport_segments = 0;
    int vertical_viewport_segments = 0;
    device::mojom::blink::DevicePostureType device_posture =
        device::mojom::blink::DevicePostureType::kContinuous;

    MediaValuesCachedData();
    explicit MediaValuesCachedData(Document&);

    MediaValuesCachedData DeepCopy() const {
      MediaValuesCachedData data;
      data.viewport_width = viewport_width;
      data.viewport_height = viewport_height;
      data.device_width = device_width;
      data.device_height = device_height;
      data.device_pixel_ratio = device_pixel_ratio;
      data.device_supports_hdr = device_supports_hdr;
      data.color_bits_per_component = color_bits_per_component;
      data.monochrome_bits_per_component = monochrome_bits_per_component;
      data.primary_pointer_type = primary_pointer_type;
      data.available_pointer_types = available_pointer_types;
      data.primary_hover_type = primary_hover_type;
      data.available_hover_types = available_hover_types;
      data.em_size = em_size;
      data.ex_size = ex_size;
      data.ch_size = ch_size;
      data.three_d_enabled = three_d_enabled;
      data.immersive_mode = immersive_mode;
      data.strict_mode = strict_mode;
      data.media_type = media_type.IsolatedCopy();
      data.display_mode = display_mode;
      data.color_gamut = color_gamut;
      data.preferred_color_scheme = preferred_color_scheme;
      data.preferred_contrast = preferred_contrast;
      data.prefers_reduced_motion = prefers_reduced_motion;
      data.prefers_reduced_data = prefers_reduced_data;
      data.forced_colors = forced_colors;
      data.navigation_controls = navigation_controls;
      data.horizontal_viewport_segments = horizontal_viewport_segments;
      data.vertical_viewport_segments = vertical_viewport_segments;
      data.device_posture = device_posture;
      return data;
    }
  };

  MediaValuesCached();
  explicit MediaValuesCached(Document&);
  explicit MediaValuesCached(const MediaValuesCachedData&);

  MediaValues* Copy() const;

  int DeviceWidth() const override;
  int DeviceHeight() const override;
  float DevicePixelRatio() const override;
  bool DeviceSupportsHDR() const override;
  int ColorBitsPerComponent() const override;
  int MonochromeBitsPerComponent() const override;
  mojom::blink::PointerType PrimaryPointerType() const override;
  int AvailablePointerTypes() const override;
  mojom::blink::HoverType PrimaryHoverType() const override;
  int AvailableHoverTypes() const override;
  bool ThreeDEnabled() const override;
  bool InImmersiveMode() const override;
  bool StrictMode() const override;
  Document* GetDocument() const override;
  bool HasValues() const override;
  const String MediaType() const override;
  blink::mojom::DisplayMode DisplayMode() const override;
  ColorSpaceGamut ColorGamut() const override;
  mojom::blink::PreferredColorScheme GetPreferredColorScheme() const override;
  mojom::blink::PreferredContrast GetPreferredContrast() const override;
  bool PrefersReducedMotion() const override;
  bool PrefersReducedData() const override;
  ForcedColors GetForcedColors() const override;
  NavigationControls GetNavigationControls() const override;
  int GetHorizontalViewportSegments() const override;
  int GetVerticalViewportSegments() const override;
  device::mojom::blink::DevicePostureType GetDevicePosture() const override;

  void OverrideViewportDimensions(double width, double height);

 protected:
  double ViewportWidth() const override;
  double ViewportHeight() const override;
  double SmallViewportWidth() const override;
  double SmallViewportHeight() const override;
  double LargeViewportWidth() const override;
  double LargeViewportHeight() const override;
  double DynamicViewportWidth() const override;
  double DynamicViewportHeight() const override;
  float EmSize() const override;
  float RemSize() const override;
  float ExSize() const override;
  float ChSize() const override;
  WritingMode GetWritingMode() const override {
    return WritingMode::kHorizontalTb;
  }

  MediaValuesCachedData data_;
};

}  // namespace blink

namespace WTF {

template <>
struct CrossThreadCopier<blink::MediaValuesCached::MediaValuesCachedData> {
  typedef blink::MediaValuesCached::MediaValuesCachedData Type;
  static Type Copy(const Type& data) { return data.DeepCopy(); }
};

}  // namespace WTF

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_MEDIA_VALUES_CACHED_H_


text:
package org.infinispan.eviction;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.infinispan.configuration.cache.Configuration;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.test.AbstractInfinispanTest;
import org.testng.annotations.Test;

import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

@Test(groups = "unit", testName = "eviction.EvictionManagerTest")
public class EvictionManagerTest extends AbstractInfinispanTest {

   private ConfigurationBuilder getCfg() {
      ConfigurationBuilder builder = new ConfigurationBuilder();
      builder.eviction().strategy(EvictionStrategy.LRU).maxEntries(123);
      return builder;
   }

   public void testNoEvictionThread() {
      EvictionManagerImpl em = new EvictionManagerImpl();
      Configuration cfg = getCfg().expiration().wakeUpInterval(0L).build();

      ScheduledExecutorService mockService = mock(ScheduledExecutorService.class);
      em.initialize(mockService, "", cfg, null, null, null);
      em.start();

      assert em.evictionTask == null : "Eviction task is not null!  Should not have scheduled anything!";
   }

   public void testWakeupInterval() {
      EvictionManagerImpl em = new EvictionManagerImpl();
      Configuration cfg = getCfg().expiration().wakeUpInterval(789L).build();

      ScheduledExecutorService mockService = mock(ScheduledExecutorService.class);
      em.initialize(mockService, "", cfg, null, null, null);

      ScheduledFuture mockFuture = mock(ScheduledFuture.class);
      when(mockService.scheduleWithFixedDelay(isA(EvictionManagerImpl.ScheduledTask.class), eq(789l),
                                                eq(789l), eq(TimeUnit.MILLISECONDS)))
            .thenReturn(mockFuture);
      em.start();

      assert em.evictionTask == mockFuture;
      verify(mockService).scheduleWithFixedDelay(any(Runnable.class), anyLong(), anyLong(), any(TimeUnit.class)); // expect that the executor was never used!!
   }
}


text:
all:
	gcc -O1 -o test search_rotated_array.c


text:
/* eslint-env node */
module.exports = {
  extends: '@savvy-css/stylelint-config-savvy'
};


text:
//
//  ZXViewController2.m
//  Review_DataBase
//
//  Created by zx on 1/15/15.
//  Copyright (c) 2015 zx. All rights reserved.
//

#import "ZXViewController2.h"

@interface ZXViewController2 ()

@end

@implementation ZXViewController2

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end


text:
'use strict';

var HttpHash = require('http-hash');
var url = require('url');
var TypedError = require('error/typed');
var extend = require('xtend');

var ExpectedCallbackError = TypedError({
    type: 'http-hash-router.expected.callback',
    message: 'http-hash-router: Expected a callback to be ' +
        'passed as the 4th parameter to handleRequest.\n' +
        'SUGGESTED FIX: call the router with ' +
        '`router(req, res, opts, cb).\n',
    value: null
});
var NotFoundError = TypedError({
    type: 'http-hash-router.not-found',
    message: 'Resource Not Found',
    statusCode: 404
});

module.exports = HttpHashRouter;

function HttpHashRouter() {
    var hash = HttpHash();

    handleRequest.set = hash.set.bind(hash);

    return handleRequest;

    function handleRequest(req, res, opts, cb) {
        if (typeof cb !== 'function') {
            throw ExpectedCallbackError({
                value: cb
            });
        }

        var pathname = url.parse(req.url).pathname;

        var route = hash.get(pathname);
        if (route.handler === null) {
            return cb(NotFoundError({
                pathname: pathname
            }));
        }

        opts = extend(opts, {
            params: route.params,
            splat: route.splat
        });
        return route.handler(req, res, opts, cb);
    }
}


text:
/* $Id$ $Revision$ */
/* vim:set shiftwidth=4 ts=8: */

/*************************************************************************
 * Copyright (c) 2011 AT&T Intellectual Property
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors: See CVS logs. Details at http://www.graphviz.org/
 *************************************************************************/

#include <cghdr.h>

static Agraph_t *agfindsubg_by_id(Agraph_t * g, IDTYPE id)
{
    Agraph_t template;

    agdtdisc(g, g->g_dict, &Ag_subgraph_id_disc);
    AGID(&template) = id;
    return (Agraph_t *) dtsearch(g->g_dict, &template);
}

static Agraph_t *localsubg(Agraph_t * g, IDTYPE id)
{
    Agraph_t *subg;

    subg = agfindsubg_by_id(g, id);
    if (subg)
	return subg;

    subg = agalloc(g, sizeof(Agraph_t));
    subg->clos = g->clos;
    subg->desc = g->desc;
    subg->desc.maingraph = FALSE;
    subg->parent = g;
    subg->root = g->root;
    AGID(subg) = id;
    return agopen1(subg);
}

Agraph_t *agidsubg(Agraph_t * g, IDTYPE id, int cflag)
{
    Agraph_t *subg;
    subg = agfindsubg_by_id(g, id);
    if ((subg == NILgraph) && cflag && agallocid(g, AGRAPH, id))
	subg = localsubg(g, id);
    return subg;
}

Agraph_t *agsubg(Agraph_t * g, char *name, int cflag)
{
    IDTYPE id;
    Agraph_t *subg;

    if (name && agmapnametoid(g, AGRAPH, name, &id, FALSE)) {
	/* might already exist */
	if ((subg = agfindsubg_by_id(g, id)))
	    return subg;
    }

    if (cflag && agmapnametoid(g, AGRAPH, name, &id, TRUE)) {	/* reserve id */
	subg = localsubg(g, id);
	agregister(g, AGRAPH, subg);
	return subg;
    }

    return NILgraph;
}

Agraph_t *agfstsubg(Agraph_t * g)
{
    return (Agraph_t *) dtfirst(g->g_dict);
}

Agraph_t *agnxtsubg(Agraph_t * subg)
{
    Agraph_t *g;

    g = agparent(subg);
    return g? (Agraph_t *) dtnext(g->g_dict, subg) : 0;
}

Agraph_t *agparent(Agraph_t * g)
{
    return g->parent;
}

/* this function is only responsible for deleting the entry
 * in the parent's subg dict.  the rest is done in agclose().
 */
long agdelsubg(Agraph_t * g, Agraph_t * subg)
{
    return (long) dtdelete(g->g_dict, subg);
}


text:
import os
test_dir = "../AXUI"
total_lines = 0
for _root, _dirs, _files in os.walk(test_dir):
    for _file in _files:
        file_lines = sum(1 for line in open(os.path.join(_root, _file)))
        total_lines += file_lines

print(("total lines: %d" % total_lines))


text:
CFX_WideString JSGetStringFromID(CJS_Context* pContext, FX_UINT id) {
  switch (id) {
    case IDS_STRING_JSALERT:
      return L"Alert";
    case IDS_STRING_JSPARAMERROR:
      return L"Incorrect number of parameters passed to function.";
    case IDS_STRING_JSAFNUMBER_KEYSTROKE:
      return L"The input value is invalid.";
    case IDS_STRING_JSPARAM_TOOLONG:
      return L"The input value is too long.";
    case IDS_STRING_JSPARSEDATE:
      return L"The input value can't be parsed as a valid date/time (%s).";
    case IDS_STRING_JSRANGE1:
      return L"The input value must be greater than or equal to %s"
             L" and less than or equal to %s.";
    case IDS_STRING_JSRANGE2:
      return L"The input value must be greater than or equal to %s.";
    case IDS_STRING_JSRANGE3:
      return L"The input value must be less than or equal to %s.";
    case IDS_STRING_NOTSUPPORT:
      return L"Operation not supported.";
    case IDS_STRING_JSBUSY:
      return L"System is busy.";
    case IDS_STRING_JSEVENT:
      return L"Duplicate formfield event found.";
    case IDS_STRING_RUN:
      return L"Script ran successfully.";
    case IDS_STRING_JSPRINT1:
      return L"The second parameter can't be converted to a Date.";
    case IDS_STRING_JSPRINT2:
      return L"The second parameter is an invalid Date!";
    case IDS_STRING_JSNOGLOBAL:
      return L"Global value not found.";
    case IDS_STRING_JSREADONLY:
      return L"Cannot assign to readonly property.";
    case IDS_STRING_JSTYPEERROR:
      return L"Incorrect parameter type.";
    case IDS_STRING_JSVALUEERROR:
      return L"Incorrect parameter value.";
    default:
      return L"";
  }
}

CFX_WideString JSFormatErrorString(const char* class_name,
                                   const char* property_name,
                                   const CFX_WideString& details) {
  CFX_WideString result = CFX_WideString::FromLocal(class_name);
  if (property_name) {
    result += L".";
    result += CFX_WideString::FromLocal(property_name);
  }
  result += L": ";
  result += details;
  return result;
}


text:
<?php
// src/Flyd/DashboardBundle/DataFixtures/ORM/LoadClientData.php
namespace Flyd\DashboardBundle\DataFixtures\ORM;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Flyd\DashboardBundle\Entity\Client;
use Flyd\DashboardBundle\Entity\Contact;
use Flyd\DashboardBundle\Entity\Address;

class LoadClientData extends AbstractFixture implements OrderedFixtureInterface
{
  public function load(ObjectManager $em)
  {

    for ($i = 0; $i < 10; $i++) {
      // On crée la catégorie

      $contact = new Contact();
      $contact->setFirstname('Contact '.$i);
      $contact->setLastname('Contact last');
      $contact->setEmail('tw@tw.fr');
      $contact->setJob('Maçon');
      $contact->setPhone('0241857845');
      $contact->setMobile('0241857845');

      $address = new Address();
      $address->setStreet($i.'rue factice');
      $address->setStreetComp('complement');
      $address->setZipcode('4402'.$i);
      $address->setCity('Nantes');
      $address->setCityComp('Cedex '.$i);
      $address->setType($this->getReference('Globale'));

      $client = new Client();
      $client->setName('Client '.$i);
      $client->setReminder(new \DateTime());
      $client->setEntrance(new \DateTime());
      $client->setType(Client::ACTUAL);
      $client->setJob('Imprimeur');
      $client->setOrigin($this->getReference('Réseau'));
      $client->addContact($contact );
      $client->addAddress($address);
      $em->persist($client);
      $this->setReference('client '.$i, $client);

      // On la persiste
      $em->persist($client);
    }

    // On déclenche l'enregistrement de toutes les catégories
    $em->flush();
  }

  public function getOrder()
  {
    return 3; // the order in which fixtures will be loaded
  }
}

?>


text:
include Forwardable

module Gnip
  class Response
    extend Forwardable

    def_delegators :@http_party_response, :response, :request, :body, :headers, :code

    attr_reader :http_party_response

    def initialize(http_party_response)
      @http_party_response = http_party_response
    end

    def rules
      http_party_response["rules"]
    end

    def created?
      code == 201
    end

    def unauthorized?
      code == 401
    end

    def rate_limited?
      code == 429
    end

    def unavailable?
      code == 503
    end

    def bad_request?
      code == 400
    end

    def unprocessable?
      code == 422
    end

    def ok?
      code == 200
    end

    def success?
      ok?
    end

    def error
      http_party_response["error"]
    end

  end
end


text:
require 'fog/core/collection'
require 'fog/hp/models/block_storage_v2/snapshot'

module Fog
  module HP
    class BlockStorageV2

      class Snapshots < Fog::Collection

        attribute :filters

        model Fog::HP::BlockStorageV2::Snapshot

        def initialize(attributes)
          self.filters ||= {}
          super
        end

        def all(filters = filters)
          details = filters.delete(:details)
          self.filters = filters
          non_aliased_filters = Fog::HP.convert_aliased_attributes_to_original(self.model, filters)
          if details
            data = service.list_snapshots_detail(non_aliased_filters).body['snapshots']
          else
            data = service.list_snapshots(non_aliased_filters).body['snapshots']
          end
          load(data)
        end

        def get(snapshot_id)
          if snapshot = service.get_snapshot_details(snapshot_id).body['snapshot']
            new(snapshot)
          end
        rescue Fog::HP::BlockStorageV2::NotFound
          nil
        end

      end

    end
  end
end


text:
<resources>

    <!-- Default screen margins, per the Android Design guidelines. -->
    <dimen name="activity_horizontal_margin">16dp</dimen>
    <dimen name="activity_vertical_margin">16dp</dimen>
    <dimen name="headline_padding">16dp</dimen>
    <dimen name="headline_source">18dp</dimen>
    <dimen name="headline_description">32dp</dimen>
    <dimen name="headline_description_height">140dp</dimen>
    <dimen name="headline_moment">12dp</dimen>

</resources>


text:
from sae import storage

class SaeStorage(object):
    def __init__(self, app=None):
        self.app = app
        if app is not None:
            self.init_app(app)

    def init_app(self, app):
        access_key = app.config.get('SAE_ACCESS_KEY', storage.ACCESS_KEY)
        secret_key = app.config.get('SAE_SECRET_KEY', storage.SECRET_KEY)
        app_name = app.config.get('SAE_APP_NAME', storage.APP_NAME)
        bucket_name = app.config.get('SAE_BUCKET_NAME', '')
        connection = storage.Connection(access_key, secret_key, app_name)
        self._bucket = connection.get_bucket(bucket_name)

    def save(self, data, filename):
        return self._bucket.put_object(filename, data)

    def delete(self, filename):
        return self._bucket.delete_object(filename)

    def url(self, filename):
        return self._bucket.generate_url(filename)


text:
import { bindable, inject, customAttribute } from 'aurelia-framework';
import { VGrid } from '../v-grid';
import { Controller, BindingContextInterface, OverrideContextInterface } from '../../interfaces';

/**
 * Custom attribute "v-resize-col"
 * enablkes checkbox selection
 * Used by default by the simple html setup
 * Can be used with custom html
 *
 */
@customAttribute('v-selection')
@inject(Element, VGrid)
export class VGridAttributesSelection {
  private element: HTMLInputElement;
  private vGrid: VGrid;
  private controller: Controller;
  private bindingContext: BindingContextInterface;
  private overrideContext: OverrideContextInterface;
  @bindable private selected: boolean;
  @bindable private type: string;

  constructor(element: HTMLInputElement, vGrid: VGrid) {
    this.vGrid = vGrid;
    this.controller = vGrid.controller;
    this.element = element;
  }

  /**
   * triggers when scrolling
   *
   */
  public selectedChanged(newValue: boolean): void {
    if (this.type === 'row') {
      (this.element as HTMLInputElement).checked = newValue;
    }
  }

  /**
   * get the binding context
   *
   */
  public bind(bindingContext: BindingContextInterface, overrideContext: OverrideContextInterface): void {
    this.bindingContext = bindingContext;
    this.overrideContext = overrideContext;
  }

  /**
   * when custom element is created
   * register click event
   * checks if header or row in click and resonds depending on where it is
   *
   */
  public attached(): void {

    this.element.checked = this.selected;
    this.element.onclick = () => {

      // todo, check... think ff had something weird here
      let status = (this.element.checked as any) === 'true' || this.element.checked === true ? true : false;

      if (status) {
        if (this.type === 'header') {
          this.bindingContext.selection.selectRange(0, this.controller.collectionLength() - 1);
          this.controller.rowClickHandler.updateSelectionOnAllRows();
        }
        if (this.type === 'row') {
          this.bindingContext.selection.select(this.bindingContext.row, true);
          this.controller.rowClickHandler.updateSelectionOnAllRows();
        }
      } else {

        if (this.type === 'header') {
          this.bindingContext.selection.deSelectAll();
          this.controller.rowClickHandler.updateSelectionOnAllRows();
        }

        if (this.type === 'row') {
          this.bindingContext.selection.deSelect(this.bindingContext.row);
          this.controller.rowClickHandler.updateSelectionOnAllRows();
        }
      }

    };

  }

}


text:
* Type: Read-Only
* Packed-Encoding: `b`

Reading this property will cause an assert on the NCP. This
is intended for testing the assert functionality of
underlying platform/NCP. Assert should ideally cause the
NCP to reset, but if `assert` is not supported or disabled
boolean value of `false` is returned in response.

### PROP 16385: PROP_DEBUG_NCP_LOG_LEVEL {#prop-debug-ncp-log-level}
* Type: Read-Write
* Packed-Encoding: `C`

Provides access to the NCP log level. Currently defined values are (which follows
the RFC 5424):

 *  0: Emergency (emerg).
 *  1: Alert (alert).
 *  2: Critical (crit).
 *  3: Error (err).
 *  4: Warning (warn).
 *  5: Notice (notice).
 *  6: Information (info).
 *  7: Debug (debug).

If the NCP supports dynamic log level control, setting this property
changes the log level accordingly. Getting the value returns the current
log level.  If the dynamic log level control is not supported, setting this
property returns a `PROP_LAST_STATUS` with `STATUS_INVALID_COMMAND_FOR_PROP`.


text:
from functools import wraps
import sys
# sys.path.append('../')
from util.util import print_trace_exception

class ServiceException(Exception):
    pass

class ServiceHandlerMissingException(ServiceException):
    pass

def register(_self):
    def outer_wrapper(func):
        _self.add_handler(func)

        @wraps(func)
        def inner_wrapper(*args, **kwargs):
            return func(*args, **kwargs)
        return inner_wrapper
    return outer_wrapper

def handler(func):
    _id = BaseService.get_id(func)

    @wraps(func)
    def func_wrapper(*args, **kwargs):
        '''
        Append id to return
        :param args:
        :param kwargs:
        :return: function
        '''
        re = func(*args, **kwargs)
        re.update({'id': _id})
        return re
    return func_wrapper

class BaseService(object):
    def __init__(self, service_name):
        self.handler = {}
        self.handler_keys = []
        self.service_name = service_name

    def add_handler(self, func):
        assert callable(func)
        key = BaseService.get_id(func)
        self.handler_keys.append(key)
        self.handler[key] = func

    def del_handler(self, key): pass

    def __getitem__(self, key):
        return self.get_handler(key)

    def get_handler(self, key):
        assert isinstance(key, (unicode, str)) is True
        try:
            return self.handler[key]
        except KeyError:
            print_trace_exception()
            raise ServiceHandlerMissingException()

    def get_handler_list(self):
        return self.handler.keys()

    def get_handler_id(self, key):
        self.get_handler(key)
        return '{}_{}'.format(self.service_name, key)

    def get_name(self):
        return self.service_name

    @classmethod
    def get_id(cls, func):
        return str(func.__name__).upper()


text:
function str = hlp_tostring(v,stringcutoff,prec)
% Get an human-readable string representation of a data structure.
% String = hlp_tostring(Data,StringCutoff)
%
% The resulting string representations are usually executable, but there are corner cases (e.g.,
% certain anonymous function handles and large data sets), which are not supported. For
% general-purpose serialization, see hlp_serialize/hlp_deserialize.
%
% In:
%   Data : a data structure
%
%   StringCutoff : optional maximum string length for atomic fields (default: 0=off)
%
%   Precision : maximum significant digits (default: 15)
%
% Out:
%   String : string form of the data structure
%
% Notes:
%   hlp_tostring has builtin support for displaying expression data structures.
%
% Examples:
%   % get a string representation of a data structure
%   hlp_tostring({'test',[1 2 3], struct('field','value')})
%
% See also:
%   hlp_serialize
%
%                                Christian Kothe, Swartz Center for Computational Neuroscience, UCSD
%                                2010-04-15
%
%                                adapted from serialize.m
%                                (C) 2006 Joger Hansegord (jogerh@ifi.uio.no)

% Copyright (C) Christian Kothe, SCCN, 2010, christian@sccn.ucsd.edu
%
% This program is free software; you can redistribute it and/or modify it under the terms of the GNU
% General Public License as published by the Free Software Foundation; either version 2 of the
% License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
% even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
% General Public License for more details.
%
% You should have received a copy of the GNU General Public License along with this program; if not,
% write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
% USA

if nargin < 2
    stringcutoff = 0; end
if nargin < 3
    prec = 15; end

str = serializevalue(v);

    function val = serializevalue(v)
        % Main hub for serializing values
        if isnumeric(v) || islogical(v)
            val = serializematrix(v);
        elseif ischar(v)
            val = serializestring(v);
        elseif isa(v,'function_handle')
            val = serializefunction(v);
        elseif is_impure_expression(v)
            val = serializevalue(v.tracking.expression);
        elseif has_canonical_representation(v)
            val = serializeexpression(v);
        elseif is_dataset(v)
            val = serializedataset(v);
        elseif isstruct(v)
            val = serializestruct(v);
        elseif iscell(v)
            val = serializecell(v);
        elseif isobject(v)
            val = serializeobject(v);
        else
            try
                val = serializeobject(v);
            catch
                error('Unhandled type %s', class(v));
            end
        end
    end

    function val = serializestring(v)
        % Serialize a string
        if any(v == '''')
            val = ['''' strrep(v,'''','''''') ''''];
            try
                if ~isequal(eval(val),v)
                    val = ['char(' serializevalue(uint8(v)) ')']; end
            catch
                val = ['char(' serializevalue(uint8(v)) ')'];
            end
        else
            val = ['''' v ''''];
        end
        val = trim_value(val,'''');
    end

    function val = serializematrix(v)
        % Serialize a matrix and apply correct class and reshape if required
        if ndims(v) < 3 %#ok<ISMAT>
            if isa(v, 'double')
                if size(v,1) == 1 && length(v) > 3 && isequal(v,v(1):v(2)-v(1):v(end))
                    % special case: colon sequence
                    if v(2)-v(1) == 1
                        val = ['[' num2str(v(1)) ':' num2str(v(end)) ']'];
                    else
                        val = ['[' num2str(v(1)) ':' num2str(v(2)-v(1)) ':' num2str(v(end)) ']'];
                    end
                elseif size(v,2) == 1 && length(v) > 3 && isequal(v',v(1):v(2)-v(1):v(end))
                    % special case: colon sequence
                    if v(2)-v(1) == 1
                        val = ['[' num2str(v(1)) ':' num2str(v(end)) ']'''];
                    else
                        val = ['[' num2str(v(1)) ':' num2str(v(2)-v(1)) ':' num2str(v(end)) ']'''];
                    end
                else
                    val = mat2str(v,prec);
                end
            else
                val = mat2str(v,prec,'class');
            end
            val = trim_value(val,']');
        else
            if isa(v, 'double')
                val = mat2str(v(:),prec);
            else
                val = mat2str(v(:),prec,'class');
            end
            val = trim_value(val,']');
            val = sprintf('reshape(%s, %s)', val, mat2str(size(v)));
        end
    end

    function val = serializecell(v)
        % Serialize a cell
        if isempty(v)
            val = '{}';
            return
        end
        cellSep = ', ';
        if isvector(v) && size(v,1) > 1
            cellSep = '; ';
        end

        % Serialize each value in the cell array, and pad the string with a cell
        % separator.
        vstr = cellfun(@(val) [serializevalue(val) cellSep], v, 'UniformOutput', false);
        vstr{end} = vstr{end}(1:end-2);

        % Concatenate the elements and add a reshape if requied
        val = [ '{' vstr{:} '}'];
        if ~isvector(v)
            val = ['reshape('  val sprintf(', %s)', mat2str(size(v)))];
        end
    end

    function val = serializeexpression(v)
        % Serialize an expression
        if numel(v) > 1
            val = ['['];
            for k = 1:numel(v)
                val = [val serializevalue(v(k)), ', ']; end
            val = [val(1:end-2) ']'];
        else
            if numel(v.parts) > 0
                val = [char(v.head) '('];
                for fieldNo = 1:numel(v.parts)
                    val = [val serializevalue(v.parts{fieldNo}), ', ']; end
                val = [val(1:end-2) ')'];
            else
                val = char(v.head);
            end
        end
    end

    function val = serializedataset(v) %#ok<INUSD>
        % Serialize a data set
        val = '<EEGLAB data set>';
    end

    function val = serializestruct(v)
        % Serialize a struct by converting the field values using struct2cell
        fieldNames   = fieldnames(v);
        fieldValues  = struct2cell(v);
        if ndims(fieldValues) > 6
            error('Structures with more than six dimensions are not supported');
        end
        val = 'struct(';
        for fieldNo = 1:numel(fieldNames)
            val = [val serializevalue( fieldNames{fieldNo}) ', '];
            val = [val serializevalue( permute(fieldValues(fieldNo, :,:,:,:,:,:), [2:ndims(fieldValues) 1]) ) ];
            val = [val ', '];
        end
        if numel(fieldNames)==0
            val = [val ')'];
        else
            val = [val(1:end-2) ')'];
        end
        if ~isvector(v)
            val = sprintf('reshape(%s, %s)', val, mat2str(size(v)));
        end
    end

    function val = serializeobject(v)
        % Serialize an object by converting to struct and add a call to the copy constructor
        val = sprintf('%s(%s)', class(v), serializevalue(struct(v)));
    end

    function val = serializefunction(v)
        % Serialize a function handle
        try
            val = ['@' char(get_function_symbol(v))];
        catch
            val = char(v);
        end
    end

    function v = trim_value(v,appendix)
        if nargin < 2
            appendix = ''; end
        % Trim a serialized value to a certain length
        if stringcutoff && length(v) > stringcutoff
            v = [v(1:stringcutoff) '...' appendix]; end
    end

end

function result___ = get_function_symbol(expression___)
% internal: some function_handle expressions have a function symbol (an @name expression), and this function obtains it
% note: we are using funny names here to bypass potential name conflicts within the eval() clause further below
if ~isa(expression___,'function_handle')
    error('the expression has no associated function symbol.'); end

string___ = char(expression___);
if string___(1) == '@'
    % we are dealing with a lambda function
    if is_symbolic_lambda(expression___)
        result___ = eval(string___(27:end-21));
    else
        error('cannot derive a function symbol from a non-symbolic lambda function.');
    end
else
    % we are dealing with a regular function handle
    result___ = expression___;
end
end

function res = is_symbolic_lambda(x)
% internal: a symbolic lambda function is one which generates expressions when invoked with arguments (this is what exp_symbol generates)
res = isa(x,'function_handle') && ~isempty(regexp(char(x),'@\(varargin\)struct\(''head'',\{.*\},''parts'',\{varargin\}\)','once'));
end


text:
package com.cyrillrx.android.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 * @author Cyril Leroux
 *         Created on 01/03/2015
 */
public class NetworkUtils {

    public static boolean isConnected(Context context) {
        final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        final NetworkInfo netInfo = cm.getActiveNetworkInfo();
        return netInfo != null && netInfo.isConnected();
    }
}