text:
package net.dv8tion.jda.api.interactions.components;

import net.dv8tion.jda.api.utils.data.DataArray;
import net.dv8tion.jda.api.utils.data.DataObject;
import net.dv8tion.jda.internal.interactions.component.ButtonImpl;
import net.dv8tion.jda.internal.interactions.component.EntitySelectMenuImpl;
import net.dv8tion.jda.internal.interactions.component.StringSelectMenuImpl;
import net.dv8tion.jda.internal.interactions.component.TextInputImpl;
import net.dv8tion.jda.internal.utils.Checks;
import net.dv8tion.jda.internal.utils.EntityString;

import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import java.util.*;
import java.util.stream.Collectors;

/**
 * One row of components.
 *
 * @see ItemComponent
 * @see LayoutComponent
 */
public class ActionRow implements LayoutComponent
{
    private final List<ItemComponent> components = new ArrayList<>();

    private ActionRow() {}

    /**
     * Load ActionRow from serialized representation.
     *
Inverse of {@link #toData()}.
     *
     * @param  data
     *         Serialized version of an action row
     *
     * @throws net.dv8tion.jda.api.exceptions.ParsingException
     *         If the provided data is not a valid action row
     * @throws IllegalArgumentException
     *         If the data is null or the type is not 1
     *
     * @return ActionRow instance
     */
    @Nonnull
    public static ActionRow fromData(@Nonnull DataObject data)
    {
        Checks.notNull(data, "Data");
        ActionRow row = new ActionRow();
        if (data.getInt("type", 0) != 1)
            throw new IllegalArgumentException("Data has incorrect type. Expected: 1 Found: " + data.getInt("type"));
        data.getArray("components")
            .stream(DataArray::getObject)
            .map(obj -> {
                switch (Component.Type.fromKey(obj.getInt("type")))
                {
                case BUTTON:
                    return new ButtonImpl(obj);
                case STRING_SELECT:
                    return new StringSelectMenuImpl(obj);
                case TEXT_INPUT:
                    return new TextInputImpl(obj);
                case USER_SELECT:
                case ROLE_SELECT:
                case CHANNEL_SELECT:
                case MENTIONABLE_SELECT:
                    return new EntitySelectMenuImpl(obj);
                default:
                    return null;
                }
            })
            .filter(Objects::nonNull)
            .forEach(row.components::add);
        return row;
    }

    /**
     * Create one row of {@link ItemComponent components}.
     *
You cannot currently mix different types of components and each type has its own maximum defined by {@link Component.Type#getMaxPerRow()}.
     *
     * @param  components
     *         The components for this action row
     *
     * @throws IllegalArgumentException
     *         If anything is null, empty, or an invalid number of components are provided
     *
     * @return The action row
     */
    @Nonnull
    public static ActionRow of(@Nonnull Collection<? extends ItemComponent> components)
    {
        Checks.noneNull(components, "Components");
        return of(components.toArray(new ItemComponent[0]));
    }

    /**
     * Create one row of {@link ItemComponent components}.
     *
You cannot currently mix different types of components and each type has its own maximum defined by {@link Component.Type#getMaxPerRow()}.
     *
     * @param  components
     *         The components for this action row
     *
     * @throws IllegalArgumentException
     *         If anything is null, empty, or an invalid number of components are provided
     *
     * @return The action row
     */
    @Nonnull
    public static ActionRow of(@Nonnull ItemComponent... components)
    {
        Checks.noneNull(components, "Components");
        Checks.check(components.length > 0, "Cannot have empty row!");
        ActionRow row = new ActionRow();
        Collections.addAll(row.components, components);
        if (!row.isValid())
        {
            Map<Component.Type, List<ItemComponent>> grouped = Arrays.stream(components).collect(Collectors.groupingBy(Component::getType));
            String provided = grouped.entrySet()
                .stream()
                .map(entry -> entry.getValue().size() + "/" + entry.getKey().getMaxPerRow() + " of " + entry.getKey())
                .collect(Collectors.joining(", "));
            throw new IllegalArgumentException("Cannot create action row with invalid component combinations. Provided: " + provided);
        }
        return row;
    }

    /**
     * Partitions the provided {@link ItemComponent components} into a list of ActionRow instances.
     *
This will split the provided components by {@link Type#getMaxPerRow()} and create homogeneously typed rows,
     * meaning they will not have mixed component types.
     *
     *
Example
     *
{@code
     * List<ItemComponent> components = Arrays.asList(
     *   Button.primary("id1", "Hello"),
     *   Button.secondary("id2", "World"),
     *   SelectMenu.create("menu:id").build()
     * );
     *
     * List<ActionRow> partitioned = ActionRow.partition(components);
     * // partitioned[0] = ActionRow(button, button)
     * // partitioned[1] = ActionRow(selectMenu)
     * }

     *
     * @param  components
     *         The components to partition
     *
     * @throws IllegalArgumentException
     *         If null is provided
     *
     * @return {@link List} of {@link ActionRow}
     */
    @Nonnull
    public static List<ActionRow> partitionOf(@Nonnull Collection<? extends ItemComponent> components)
    {
        Checks.noneNull(components, "Components");

        List<ActionRow> rows = new ArrayList<>();
        // The current action row we are building
        List<ItemComponent> currentRow = null;
        // The component types contained in that row (for now it can't have mixed types)
        Component.Type type = null;

        for (ItemComponent current : components)
        {
            if (type != current.getType() || currentRow.size() == type.getMaxPerRow())
            {
                type = current.getType();
                ActionRow row = ActionRow.of(current);
                currentRow = row.components;
                rows.add(row);
            }
            else
            {
                currentRow.add(current);
            }
        }

        return rows;
    }

    /**
     * Partitions the provided {@link ItemComponent components} into a list of ActionRow instances.
     *
This will split the provided components by {@link Type#getMaxPerRow()} and create homogeneously typed rows,
     * meaning they will not have mixed component types.
     *
     *
Example
     *
{@code
     * List<ItemComponent> components = Arrays.asList(
     *   Button.primary("id1", "Hello"),
     *   Button.secondary("id2", "World"),
     *   SelectMenu.create("menu:id").build()
     * );
     *
     * List<ActionRow> partitioned = ActionRow.partition(components);
     * // partitioned[0] = ActionRow(button, button)
     * // partitioned[1] = ActionRow(selectMenu)
     * }

     *
     * @param  components
     *         The components to partition
     *
     * @throws IllegalArgumentException
     *         If null is provided
     *
     * @return {@link List} of {@link ActionRow}
     */
    @Nonnull
    public static List<ActionRow> partitionOf(@Nonnull ItemComponent... components)
    {
        Checks.notNull(components, "Components");
        return partitionOf(Arrays.asList(components));
    }

    /**
     * Mutable list of components in this ActionRow.
     *
ActionRows should not be empty and are limited to 5 buttons.
     *
     * @return The list of components
     */
    @Nonnull
    @Override
    public List<ItemComponent> getComponents()
    {
        return components;
    }

    @Nonnull
    @Override
    @CheckReturnValue
    public ActionRow withDisabled(boolean disabled)
    {
        return ActionRow.of(components.stream()
                .map(c -> {
                    if (c instanceof ActionComponent)
                        return ((ActionComponent) c).withDisabled(disabled);
                    return c;
                })
                .collect(Collectors.toList()));
    }

    @Nonnull
    @Override
    @CheckReturnValue
    public ActionRow asDisabled()
    {
        return withDisabled(true);
    }

    @Nonnull
    @Override
    @CheckReturnValue
    public ActionRow asEnabled()
    {
        return withDisabled(false);
    }

    @Nonnull
    @Override
    public ActionRow createCopy()
    {
        return ActionRow.of(components);
    }

    @Nonnull
    @Override
    public Component.Type getType()
    {
        return Component.Type.ACTION_ROW;
    }

    @Nonnull
    @Override
    public DataObject toData()
    {
        return DataObject.empty()
                .put("type", 1)
                .put("components", DataArray.fromCollection(components));
    }

    @Nonnull
    @Override
    public Iterator<ItemComponent> iterator()
    {
        return components.iterator();
    }

    @Override
    public String toString()
    {
        return new EntityString(this)
                .addMetadata("components", components)
                .toString();
    }

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

    @Override
    public boolean equals(Object obj)
    {
        if (obj == this)
            return true;
        if (!(obj instanceof ActionRow))
            return false;
        return components.equals(((ActionRow) obj).components);
    }
}


text:
<?php
/**
 * @file
 * Contains \DrupalCI\Plugin\BuildSteps\environment\DbEnvironment
 *
 * Processes "environment: db:" parameters from within a job definition,
 * ensures appropriate Docker container images exist, and launches any new
 * database service containers as required.
 */

namespace DrupalCI\Plugin\BuildSteps\environment;

use DrupalCI\Console\Output;
use DrupalCI\Plugin\JobTypes\JobInterface;

/**
 * @PluginID("db")
 */
class DbEnvironment extends EnvironmentBase {

  /**
   * {@inheritdoc}
   */
  public function run(JobInterface $job, $data) {
    // We don't need to initialize any service container for SQLite.
    if (strpos($job->getBuildVar('DCI_DBVersion'), 'sqlite') === 0) {
      return;
    }

    // Data format: 'mysql-5.5' or array('mysql-5.5', 'pgsql-9.1')
    // $data May be a string if one version required, or array if multiple
    // Normalize data to the array format, if necessary
    $data = is_array($data) ? $data : [$data];
    Output::writeLn("<info>Parsing required database container image names ...</info>");
    $containers = $this->buildImageNames($data, $job);
    if ($valid = $this->validateImageNames($containers, $job)) {
      $service_containers = $job->getServiceContainers();
      $service_containers['db'] = $containers;
      $job->setServiceContainers($service_containers);
      $job->startServiceContainerDaemons('db');
    }
  }

  public function buildImageNames($data, JobInterface $job) {
    $images = [];
    foreach ($data as $key => $db_version) {
      $images["$db_version"]['image'] = "drupalci/$db_version";
      Output::writeLn("<comment>Adding image: <options=bold>drupalci/$db_version</options=bold></comment>");
    }
    return $images;
  }

}

redpajama_set_name: RedPajamaGithub


text:
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 324714 $ -->
<refentry xml:id="function.bcompiler-write-footer" xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>bcompiler_write_footer</refname>
  <refpurpose>Writes the single character \x00 to indicate End of compiled data</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>bool</type><methodname>bcompiler_write_footer</methodname>
   <methodparam><type>resource</type><parameter>filehandle</parameter></methodparam>
  </methodsynopsis>
  <para>
   Writes the single character <literal>\x00</literal> to indicate End of compiled data.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>filehandle</parameter></term>
     <listitem>
      <para>
       A file handle as returned by <function>fopen</function>.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   &return.success;
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title><function>bcompiler_write_footer</function> example</title>
    <programlisting role="php">
<![CDATA[
<?php
$fh = fopen("/tmp/example","w");
bcompiler_write_header($fh);
bcompiler_write_class($fh,"DB");
bcompiler_write_class($fh,"DB_common");
bcompiler_write_footer($fh);
fclose($fh);

?>
]]>
    </programlisting>
   </example>
  </para>
 </refsect1>

 <refsect1 role="notes">
  &reftitle.notes;
  &warn.experimental.func;
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>bcompiler_write_header</function></member>
   </simplelist>
  </para>
 </refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->


text:
<?php
namespace TYPO3\CMS\Fluid\Core\Widget;

/*
 * This script is backported from the TYPO3 Flow package "TYPO3.Fluid".   *
 *                                                                        *
 * It is free software; you can redistribute it and/or modify it under    *
 * the terms of the GNU Lesser General Public License, either version 3   *
 *  of the License, or (at your option) any later version.                *
 *                                                                        *
 *                                                                        *
 * This script is distributed in the hope that it will be useful, but     *
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
 * General Public License for more details.                               *
 *                                                                        *
 * You should have received a copy of the GNU Lesser General Public       *
 * License along with the script.                                         *
 * If not, see http://www.gnu.org/licenses/lgpl.html                      *
 *                                                                        *
 * The TYPO3 project - inspiring people to share!                         *
 *                                                                        */
/**
 * Builds the WidgetRequest if an AJAX widget is called.
 */
class WidgetRequestBuilder extends \TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder
{
    /**
     * @var \TYPO3\CMS\Fluid\Core\Widget\AjaxWidgetContextHolder
     */
    private $ajaxWidgetContextHolder;

    /**
     * @param \TYPO3\CMS\Fluid\Core\Widget\AjaxWidgetContextHolder $ajaxWidgetContextHolder
     * @return void
     */
    public function injectAjaxWidgetContextHolder(\TYPO3\CMS\Fluid\Core\Widget\AjaxWidgetContextHolder $ajaxWidgetContextHolder)
    {
        $this->ajaxWidgetContextHolder = $ajaxWidgetContextHolder;
    }

    /**
     * Builds a widget request object from the raw HTTP information
     *
     * @return \TYPO3\CMS\Fluid\Core\Widget\WidgetRequest The widget request as an object
     */
    public function build()
    {
        $request = $this->objectManager->get(\TYPO3\CMS\Fluid\Core\Widget\WidgetRequest::class);
        $request->setRequestURI(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
        $request->setBaseURI(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL'));
        $request->setMethod(isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : null);
        if (strtolower($_SERVER['REQUEST_METHOD']) === 'post') {
            $request->setArguments(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST());
        } else {
            $request->setArguments(\TYPO3\CMS\Core\Utility\GeneralUtility::_GET());
        }
        $rawGetArguments = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET();
        // @todo rename to @action, to be consistent with normal naming?
        if (isset($rawGetArguments['action'])) {
            $request->setControllerActionName($rawGetArguments['action']);
        }
        $widgetContext = $this->ajaxWidgetContextHolder->get($rawGetArguments['fluid-widget-id']);
        $request->setWidgetContext($widgetContext);
        return $request;
    }
}


text:
require 'rails_helper'
require 'models/concerns/transactable'

::RSpec.describe ::Category, type: :model do
	context 'category' do
		it_behaves_like ::Transactable do
			let(:context_factory) { :category_with_children }
			let(:ledger_json_key) { :category }
			let(:expected_closing_balances) { {with_date: -1, without_date: -2} }
		end
	end

	context 'subcategory' do
		it_behaves_like ::Transactable do
			let(:context_factory) { :subcategory }
			let(:ledger_json_key) { :subcategory }
			let(:expected_closing_balances) { {with_date: -1, without_date: -2} }
		end
	end

	describe '::find_or_new' do
		context 'existing category' do
			let(:category) { create :category }

			it 'should return the existing category' do
				expect(described_class.find_or_new 'id' => category.id).to eq category
			end
		end

		context 'new category' do
			let(:category_name) { 'New category' }

			it 'should return a newly created category' do
				category = described_class.find_or_new category_name
				expect(category.name).to eq category_name
				expect(category.direction).to eq 'outflow'
				expect(category.parent).to be_nil
			end

			context 'with parent' do
				let(:parent) { create :inflow_category }

				it 'should return a newly created category' do
					category = described_class.find_or_new category_name, parent
					expect(category.name).to eq category_name
					expect(category.direction).to eq 'inflow'
					expect(category.parent).to eq parent
				end
			end
		end
	end

	describe '#opening_balance' do
		subject(:category) { create :category }

		it 'should return zero' do
			expect(category.opening_balance).to eq 0
		end
	end

	describe '#account_type' do
		subject(:category) { create :category }

		it 'should return nil' do
			expect(category.account_type).to be_nil
		end
	end

	describe '#as_json' do
		after do
			expect(json).to include id: category.id
			expect(json).to include name: 'Test Category'
			expect(json).to include direction: 'outflow'
			expect(json).to include favourite: false
		end

		context 'with default options' do
			let(:json) { category.as_json }

			before do
				expect(::ActiveModelSerializers::SerializableResource).to receive(:new).with(category, fields: %i[id name direction parent_id favourite]).and_call_original
			end

			after do
				expect(json).not_to include :num_children
				expect(json).not_to include :parent
				expect(json).not_to include :closing_balance
				expect(json).not_to include :num_transactions
				expect(json).not_to include :children
			end

			context 'category' do
				subject(:category) { create :category, name: 'Test Category', children: 1, transactions: 1 }

				it 'should return a JSON representation excluding children' do
					expect(json).to include parent_id: nil
				end
			end

			context 'subcategory' do
				subject(:category) { create :subcategory, name: 'Test Category', transactions: 1 }

				it 'should return a JSON representation excluding parent' do
					expect(json).to include parent_id: category.parent.id
				end
			end
		end

		context 'with empty options' do
			let(:json) { category.as_json({}) }

			before do
				# Access the children association to ensure it is loaded
				category.children.length
				expect(::ActiveModelSerializers::SerializableResource).to receive(:new).with(category, {}).and_call_original
			end

			after do
				expect(json).to include closing_balance: category.closing_balance
				expect(json).to include num_transactions: 1
			end

			context 'category' do
				subject(:category) { create :category, name: 'Test Category', children: 1, transactions: 1 }

				let(:child) { json[:children].first }
				let(:child_parent) { child[:parent] }

				before do
					expect(::ActiveModelSerializers::SerializableResource).to receive(:new).with(category.children.first, fields: %i[id name direction parent_id parent num_transactions favourite]).and_call_original
					expect(::ActiveModelSerializers::SerializableResource).to receive(:new).with(category, fields: %i[id name direction]).and_call_original
				end

				it 'should return a JSON representation including children' do
					expect(json).to include parent_id: nil
					expect(json).to include num_children: 1
					expect(json).to include parent: nil

					expect(child).to include id: category.children.first.id
					expect(child).to include name: category.children.first.name
					expect(child).to include direction: 'outflow'
					expect(child).to include favourite: false
					expect(child).to include parent_id: category.id
					expect(child).to include num_transactions: 0
					expect(child).not_to include :children

					expect(child_parent).to include id: category.id
					expect(child_parent).to include name: category.name
					expect(child_parent).to include direction: category.direction
					expect(child_parent).not_to include :num_children
					expect(child_parent).not_to include :parent
					expect(child_parent).not_to include :closing_balance
					expect(child_parent).not_to include :num_transactions
					expect(child_parent).not_to include :children
				end
			end

			context 'subcategory' do
				subject(:category) { create :subcategory, name: 'Test Category', transactions: 1 }

				let(:parent) { json[:parent] }

				before do
					expect(::ActiveModelSerializers::SerializableResource).to receive(:new).with(category.parent, fields: %i[id name direction]).and_call_original
				end

				it 'should return a JSON representation including parent' do
					expect(json).to include parent_id: category.parent.id
					expect(json).not_to include :children
					expect(parent).to include id: category.parent.id
					expect(parent).to include name: category.parent.name
					expect(parent).to include direction: 'outflow'
				end
			end
		end
	end
end


text:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectModuleManager">
    <modules>
      <module fileurl="file://$PROJECT_DIR$/.idea/vue2.0Test1.iml" filepath="$PROJECT_DIR$/.idea/vue2.0Test1.iml" />
    </modules>
  </component>
</project>


text:
const shorthandIdentToLonghandPropertyMap = require('../../constants/shorthandIdentToLonghandPropertyMap.json');

// maps the length of the property value to an array mapping the property value index that should be used for each
// computed property.
const valueLengthToCornerPropertyIndexMap = {
  0: [],
  1: [1, 1, 1, 1],
  2: [1, 2, 1, 2],
  3: [1, 2, 3, 2],
  4: [1, 2, 3, 4],
};

module.exports = class BorderRadiusPropertyFormatter {
  /**
   * Formats a border-radius value into an object mapping border-radius longhand property names to their
   * values.
   *
   * @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius | border-radius spec}
   *
   * @param {string} propertyName - the css property name. In this case, 'border-radius'
   * @param {Object} node - the root node of the nearley parser tree
   * @param {string} value - the property value string. For example, "4px 4px 3px / 2px".
   * @returns {Object} - a mapping between longhand property names to their longhand values.
   */
  static format(propertyName, node, value) {
    // split property value by any whitespace or by the "/"
    const [firstRadii, additionalRadii = ''] = value.split('/');
    const borderRadiusProperties = shorthandIdentToLonghandPropertyMap[propertyName];

    // get everything before the '/' and create a map from longhand property name to value
    const radiusValues = firstRadii.trim().split(/\s+/);
    const radiusValueMap = valueLengthToCornerPropertyIndexMap[radiusValues.length]
      .reduce((expandedPropertyMap, propertyValueIndex, idx) => (
        Object.assign({
          [borderRadiusProperties[idx]]: radiusValues[propertyValueIndex - 1],
        }, expandedPropertyMap)
      ), {});

    // do the same for everything after the '/'
    const additionalValues = additionalRadii.trim().split(/\s+/);
    const additionalValueMap = valueLengthToCornerPropertyIndexMap[additionalValues.length]
      .reduce((expandedPropertyMap, propertyValueIndex, idx) => (
        Object.assign({
          [borderRadiusProperties[idx]]: additionalValues[propertyValueIndex - 1],
        }, expandedPropertyMap)
      ), {});

    // merge radiusValues and additional values for each longhand property
    return Object.entries(radiusValueMap)
      .map(([property, value]) => (additionalValueMap[property]
        ? [property, `${value} / ${additionalValueMap[property]}`]
        : [property, value]))
      .reduce((propertyMap, [key, value]) => Object.assign({ [key]: value }, propertyMap), {});
  }
};


text:
<?php

namespace Crunchmail\Tests;

use Crunchmail\PHPUnit\TestCase;
use \Crunchmail\Exception\ApiException;

/**
 * Test class
 *
 * @coversDefaultClass \Crunchmail\Exception\ApiException
 */
class ApiExceptionTest extends TestCase
{
    /**
     * @testdox getDetail() returns the last exception
     *
     * @covers ::getDetail
     * @todo test error format
     */
    public function testGetDetail()
    {
        try
        {
            $client = $this->quickMock(['message_error', 400]);
            $client->messages->get('http://fake');
        }
        catch (ApiException $e)
        {
            $err = $e->getDetail();
        }

        $this->assertInstanceOf('\stdClass', $err);

        return $e;
    }

    /**
     * @testdox toHtml() method returns a proper string and code (500)
     *
     * @covers ::toHtml
     * @covers ::getCode
     *
     */
    public function testExceptionToHtmlFor500()
    {
        try
        {
            $client = $this->quickMock(['empty', 500]);
            $client->messages->delete('http://fake');
        }
        catch (ApiException $e)
        {
            $err  = $e->toHtml();
            $code = $e->getCode();
        }

        $this->assertInternalType('string', $err);
        $this->assertContains('500 Internal Server Error', $err);
        $this->assertEquals(500, $code);
    }

    /**
     * @testdox toHtml() method can format domain verify errors
     *
     * @covers ::toHtml
     */
    public function testDomainErrorFormatting()
    {
        try
        {
            $cli = $this->quickMock(
                ['message_ok', '200'],
                ['domain_error', 500]
            );
            $msg = $cli->messages->get('http://fake');
            $msg->post([]);
        }
        catch (ApiException $e)
        {
            $this->assertInternalType('string', $e->toHtml());
            $this->assertEquals(500, $e->getCode());
        }
    }

    /**
     * @testdox toHtml() method returns a proper string and code (400)
     *
     * @covers ::toHtml
     * @covers ::getCode
     */
    public function testExceptionToHtmlFor400()
    {
        try
        {
            $client = $this->quickMock(['message_invalid', 400]);
            $client->messages->post([]);
        }
        catch (ApiException $e)
        {
            $code = $e->getCode();
            $err  = $e->toHtml();
        }

        $this->assertContains('sender_email', $err);
        $this->assertEquals(400, $code);
    }

    /**
     * @depends testGetDetail
     */
    public function testExceptionIsConvertedToString($exception)
    {
        $this->assertContains('400', (string) $exception);
    }
}


text:
package apple.metalperformanceshaders;

import apple.NSObject;
import apple.foundation.NSArray;
import apple.foundation.NSCoder;
import apple.foundation.NSMethodSignature;
import apple.foundation.NSSet;
import apple.metal.protocol.MTLDevice;
import apple.metal.struct.MTLSize;
import org.moe.natj.c.ann.FunctionPtr;
import org.moe.natj.general.NatJ;
import org.moe.natj.general.Pointer;
import org.moe.natj.general.ann.ByValue;
import org.moe.natj.general.ann.Generated;
import org.moe.natj.general.ann.Library;
import org.moe.natj.general.ann.Mapped;
import org.moe.natj.general.ann.NInt;
import org.moe.natj.general.ann.NUInt;
import org.moe.natj.general.ann.Owned;
import org.moe.natj.general.ann.Runtime;
import org.moe.natj.general.ptr.VoidPtr;
import org.moe.natj.objc.Class;
import org.moe.natj.objc.ObjCRuntime;
import org.moe.natj.objc.SEL;
import org.moe.natj.objc.ann.ObjCClassBinding;
import org.moe.natj.objc.ann.ProtocolClassMethod;
import org.moe.natj.objc.ann.Selector;
import org.moe.natj.objc.map.ObjCObjectMapper;

/**
 * MPSCNNDropoutGradient
 * [@dependency] This depends on Metal.framework
 *

 * This filter is the backward filter for the MPSCNNDropout forward filter.
 * It requires the mask data, along with all the associated parameters used
 * to generate the mask, from the forward pass. The mask is associated with
 * a MPSCNNDropoutGradientState object.
 *

 * In this kernel, use the secondaryOffset to apply an offset to the mask data.
 */
@Generated
@Library("MetalPerformanceShaders")
@Runtime(ObjCRuntime.class)
@ObjCClassBinding
public class MPSCNNDropoutGradient extends MPSCNNGradientKernel {
    static {
        NatJ.register();
    }

    @Generated
    protected MPSCNNDropoutGradient(Pointer peer) {
        super(peer);
    }

    @Generated
    @Selector("accessInstanceVariablesDirectly")
    public static native boolean accessInstanceVariablesDirectly();

    @Generated
    @Owned
    @Selector("alloc")
    public static native MPSCNNDropoutGradient alloc();

    @Owned
    @Generated
    @Selector("allocWithZone:")
    public static native MPSCNNDropoutGradient allocWithZone(VoidPtr zone);

    @Generated
    @Selector("automaticallyNotifiesObserversForKey:")
    public static native boolean automaticallyNotifiesObserversForKey(String key);

    @Generated
    @Selector("cancelPreviousPerformRequestsWithTarget:")
    public static native void cancelPreviousPerformRequestsWithTarget(@Mapped(ObjCObjectMapper.class) Object aTarget);

    @Generated
    @Selector("cancelPreviousPerformRequestsWithTarget:selector:object:")
    public static native void cancelPreviousPerformRequestsWithTargetSelectorObject(
            @Mapped(ObjCObjectMapper.class) Object aTarget, SEL aSelector,
            @Mapped(ObjCObjectMapper.class) Object anArgument);

    @Generated
    @Selector("classFallbacksForKeyedArchiver")
    public static native NSArray<String> classFallbacksForKeyedArchiver();

    @Generated
    @Selector("classForKeyedUnarchiver")
    public static native Class classForKeyedUnarchiver();

    @Generated
    @Selector("debugDescription")
    public static native String debugDescription_static();

    @Generated
    @Selector("description")
    public static native String description_static();

    @Generated
    @Selector("hash")
    @NUInt
    public static native long hash_static();

    @Generated
    @Selector("init")
    public native MPSCNNDropoutGradient init();

    @Generated
    @Selector("initWithCoder:")
    public native MPSCNNDropoutGradient initWithCoder(NSCoder aDecoder);

    /**
     * <NSSecureCoding> support
     */
    @Generated
    @Selector("initWithCoder:device:")
    public native MPSCNNDropoutGradient initWithCoderDevice(NSCoder aDecoder,
            @Mapped(ObjCObjectMapper.class) Object device);

    @Generated
    @Selector("initWithDevice:")
    public native MPSCNNDropoutGradient initWithDevice(@Mapped(ObjCObjectMapper.class) Object device);

    /**
     * Standard init with default properties per filter type.
     *
     * @param device             The device that the filter will be used on.
     * @param keepProbability    The probability that each element in the input is kept.
     *                           The valid range is (0.0f, 1.0f).
     * @param seed               The seed used to generate random numbers.
     * @param maskStrideInPixels The mask stride in the x, y, and z dimensions, which
     *                           allows for the broadcasting of mask data. The only valid
     *                           values are 0 and 1 for each dimension. For no
     *                           broadcasting, set the values for each dimension to 1.
     *                           For broadcasting, set desired values to 0.
     * @return A valid MPSCNNDropoutGradient object or nil, if failure.
     */
    @Generated
    @Selector("initWithDevice:keepProbability:seed:maskStrideInPixels:")
    public native MPSCNNDropoutGradient initWithDeviceKeepProbabilitySeedMaskStrideInPixels(
            @Mapped(ObjCObjectMapper.class) MTLDevice device, float keepProbability, @NUInt long seed,
            @ByValue MTLSize maskStrideInPixels);

    @Generated
    @Selector("instanceMethodForSelector:")
    @FunctionPtr(name = "call_instanceMethodForSelector_ret")
    public static native NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(SEL aSelector);

    @Generated
    @Selector("instanceMethodSignatureForSelector:")
    public static native NSMethodSignature instanceMethodSignatureForSelector(SEL aSelector);

    @Generated
    @Selector("instancesRespondToSelector:")
    public static native boolean instancesRespondToSelector(SEL aSelector);

    @Generated
    @Selector("isSubclassOfClass:")
    public static native boolean isSubclassOfClass(Class aClass);

    /**
     * [@property] keepProbability
     *

     * The probability that each element in the input is kept.
     * The valid range is (0.0f, 1.0f).
     */
    @Generated
    @Selector("keepProbability")
    public native float keepProbability();

    @Generated
    @Selector("keyPathsForValuesAffectingValueForKey:")
    public static native NSSet<String> keyPathsForValuesAffectingValueForKey(String key);

    /**
     * [@property] maskStrideInPixels
     *

     * The mask stride in the x, y, and x dimensions, which
     * allows for the broadcasting the mask data.
     *

     * The only valid values are 0 and 1 for each dimension.
     * For no broadcasting, set the values for each dimension
     * to 1. For broadcasting, set desired values to 0.
     */
    @Generated
    @Selector("maskStrideInPixels")
    @ByValue
    public native MTLSize maskStrideInPixels();

    @Generated
    @Owned
    @Selector("new")
    public static native MPSCNNDropoutGradient new_objc();

    @Generated
    @Selector("resolveClassMethod:")
    public static native boolean resolveClassMethod(SEL sel);

    @Generated
    @Selector("resolveInstanceMethod:")
    public static native boolean resolveInstanceMethod(SEL sel);

    /**
     * [@property] seed
     *

     * The seed used to generate random numbers.
     */
    @Generated
    @Selector("seed")
    @NUInt
    public native long seed();

    @Generated
    @Selector("setVersion:")
    public static native void setVersion_static(@NInt long aVersion);

    @Generated
    @Selector("superclass")
    public static native Class superclass_static();

    @Generated
    @Selector("supportsSecureCoding")
    public static native boolean supportsSecureCoding();

    @Generated
    @ProtocolClassMethod("supportsSecureCoding")
    public boolean _supportsSecureCoding() {
        return supportsSecureCoding();
    }

    @Generated
    @Selector("version")
    @NInt
    public static native long version_static();
}


text:
require 'htmlentities'

module Griddler
  class Email
    include ActionView::Helpers::SanitizeHelper
    attr_reader :to, :from, :cc, :bcc, :subject, :body, :raw_body, :raw_text, :raw_html,
      :headers, :raw_headers, :attachments

    def initialize(params)
      @params = params

      @to = recipients(:to)
      @from = extract_address(params[:from])
      @subject = params[:subject]

      @body = extract_body
      @raw_text = params[:text]
      @raw_html = params[:html]
      @raw_body = @raw_text.presence || @raw_html

      @headers = extract_headers

      @cc = recipients(:cc)
      @bcc = recipients(:bcc)

      @raw_headers = params[:headers]

      @attachments = params[:attachments]
      p "made"
      p self.inspect
    end

    private

    attr_reader :params

    def config
      @config ||= Griddler.configuration
    end

    def recipients(type)
      params[type].to_a.map { |recipient| extract_address(recipient) }
    end

    def extract_address(address)
      EmailParser.parse_address(clean_text(address))
    end

    def extract_body
      EmailParser.extract_reply_body(text_or_sanitized_html)
    end

    def extract_headers
      if params[:headers].is_a?(Hash)
        deep_clean_invalid_utf8_bytes(params[:headers])
      else
        EmailParser.extract_headers(clean_invalid_utf8_bytes(params[:headers]))
      end
    end

    def extract_cc_from_headers(headers)
      EmailParser.extract_cc(headers)
    end

    def text_or_sanitized_html
      text = clean_text(params.fetch(:text, ''))
      text.presence || clean_html(params.fetch(:html, '')).presence
    end

    def clean_text(text)
      clean_invalid_utf8_bytes(text)
    end

    def clean_html(html)
      cleaned_html = clean_invalid_utf8_bytes(html)
      cleaned_html = strip_tags(cleaned_html)
      cleaned_html = HTMLEntities.new.decode(cleaned_html)
      cleaned_html
    end

    def deep_clean_invalid_utf8_bytes(object)
      case object
      when Hash
        object.inject({}) do |clean_hash, (key, dirty_value)|
          clean_hash[key] = deep_clean_invalid_utf8_bytes(dirty_value)
          clean_hash
        end
      when Array
        object.map { |element| deep_clean_invalid_utf8_bytes(element) }
      when String
        clean_invalid_utf8_bytes(object)
      else
        object
      end
    end

    def clean_invalid_utf8_bytes(text)
      if text && !text.valid_encoding?
        text.force_encoding('ISO-8859-1').encode('UTF-8')
      else
        text
      end
    end
  end
end


text:
template<typename T>
class Vector2D {
 public:
    T x, y;

    Vector2D() { }
    explicit Vector2D(T value) : x(value), y(value) { }
    Vector2D(T x, T y) : x(x), y(y) { }

    void set(T x, T y);

    int operator==(const Vector2D & vector) const;
    Vector2D & operator=(const Vector2D & vector);
    Vector2D operator+() const;
    Vector2D operator-() const;
    Vector2D & operator+=(const Vector2D & vector);
    Vector2D & operator-=(const Vector2D & vector);
    Vector2D & operator*=(const Vector2D & vector);
    Vector2D & operator*=(T value);
    Vector2D & operator/=(const Vector2D & vector);
    Vector2D & operator/=(T value);
    T& operator[](int index);
    int operator!=(const Vector2D & vector) const;
    operator T*();
    operator const T*() const;

    T length() const;
    T lengthSquare() const;
    Vector2D & normalize();
    T maxLength() const;

    template<typename T1>
    friend Vector2D<T1> operator+(const Vector2D<T1> &vector1, const Vector2D<T1> &vector2);

    template<typename T1>
    friend Vector2D<T1> operator-(const Vector2D<T1> &vector1, const Vector2D<T1> &vector2);

    template<typename T1>
    friend Vector2D<T1> operator*(const Vector2D<T1> &vector1, const Vector2D<T1> &vector2);

    template<typename T1>
    friend Vector2D<T1> operator*(T value, const Vector2D<T1> & vector);

    template<typename T1>
    friend Vector2D<T1> operator*(const Vector2D<T1> &vector, T value);

    template<typename T1>
    friend Vector2D<T1> operator/(const Vector2D<T1> &vector, T value);

    template<typename T1>
    friend Vector2D<T1> operator/(const Vector2D<T1> &vector1, const Vector2D<T1> &vector2);

    template<typename T1>
    friend T dot(const Vector2D<T1> &vector1, const Vector2D<T1> &vector2);

    ~Vector2D() { }
};

typedef Vector2D<int> Vector2i;
typedef Vector2D<float> Vector2f;

template<typename T>
void Vector2D<T>::set(T x, T y) {
    this->x = x;
    this->y = y;
}

template<typename T>
int Vector2D<T>::operator==(const Vector2D<T> &vector) const {
    return (x == vector.x) && (y == vector.y);
}

template<typename T>
Vector2D<T>& Vector2D<T>::operator=(const Vector2D<T> &vector) {
    x = vector.x;
    y = vector.y;

    return *this;
}

template<typename T>
Vector2D<T> Vector2D<T>::operator+() const {
    return *this;
}

template<typename T>
Vector2D<T> Vector2D<T>::operator-() const {
    return Vector2D(-x, -y);
}

template<typename T>
Vector2D<T>& Vector2D<T>::operator+=(const Vector2D<T> &vector) {
    x += vector.x;
    y += vector.y;

    return *this;
}

template<typename T>
Vector2D<T>& Vector2D<T>::operator-=(const Vector2D<T> &vector) {
    x -= vector.x;
    y -= vector.y;

    return *this;
}

template<typename T>
Vector2D<T>& Vector2D<T>::operator*=(const Vector2D<T> &vector) {
    x *= vector.x;
    y *= vector.y;

    return *this;
}

template<typename T>
Vector2D<T>& Vector2D<T>::operator*=(T value) {
    x *= value;
    y *= value;

    return *this;
}

template<typename T>
Vector2D<T>& Vector2D<T>::operator/=(const Vector2D<T> &vector) {
    x /= vector.x;
    y /= vector.y;

    return *this;
}

template<typename T>
Vector2D<T>& Vector2D<T>::operator/=(T value) {
    x /= value;
    y /= value;

    return *this;
}

template<typename T>
T& Vector2D<T>::operator[](int index) {
    return *(index + &x);
}

template<typename T>
int Vector2D<T>::operator!=(const Vector2D<T> & vector) const {
    return x != vector.x || y != vector.y;
}

template<typename T>
Vector2D<T>::operator T*() {
    return &x;
}

template<typename T>
Vector2D<T>::operator const T*() const {
    return &x;
}

template<typename T>
T Vector2D<T>::length() const {
    return static_cast<T>(sqrt(x*x + y*y));
}

template<typename T>
T Vector2D<T>::lengthSquare() const {
    return x * x + y * y;
}

template<typename T>
Vector2D<T> &Vector2D<T>::normalize() {
    return (*this) /= length();
}

template<typename T>
T Vector2D<T>::maxLength() const {
    return std::max(abs(x), abs(y));
}

template<typename T1>
inline Vector2D<T1> operator+(const Vector2D<T1> &vector1, const Vector2D<T1> &vector2) {
    return Vector2D<T1>(vector1.x + vector2.x, vector1.y + vector2.y);
}

template<typename T1>
inline Vector2D<T1> operator-(const Vector2D<T1> &vector1, const Vector2D<T1> &vector2) {
    return Vector2D<T1>(vector1.x - vector2.x, vector1.y - vector2.y);
}

template<typename T1>
inline Vector2D<T1> operator*(const Vector2D<T1> &vector1, const Vector2D<T1> &vector2) {
    return Vector2D<T1>(vector1.x* vector2.x, vector1.y* vector2.y);
}

template<typename T1>
inline Vector2D<T1> operator*(const Vector2D<T1> &vector, T1 value) {
    return Vector2D<T1>(vector.x * value, vector.y * value);
}

template<typename T1>
inline Vector2D<T1> operator*(T1 value, const Vector2D<T1> &vector) {
    return Vector2D<T1>(vector.x * value, vector.y * value);
}

template<typename T1>
inline Vector2D<T1> operator/(const Vector2D<T1> &vector1, const Vector2D<T1> &vector2) {
    return Vector2D<T1>(vector1.x / vector2.x, vector1.y / vector2.y);
}

template<typename T1>
inline Vector2D<T1> operator/(const Vector2D<T1> &vector, T1 value) {
    return Vector2D<T1>(vector.x / value, vector.y / value);
}

template<typename T1>
inline Vector2D<T1> operator/(T1 value, const Vector2D<T1> &vector) {
    return Vector2D<T1>(value / vector.x, value / vector.y);
}

template<typename T1>
inline T1 dot(const Vector2D<T1> &vector1, const Vector2D<T1> &vector2) {
    return vector1.x* vector2.x + vector1.y* vector2.y;
}

#endif  // MODEL_INCLUDE_VECTOR2D_H_


text:
<bill session="115" type="h" number="46" updated="2017-08-10T13:23:13Z">
  <state datetime="2017-01-30T16:51:37-05:00">PASS_OVER:HOUSE</state>
  <status>
    <unknown datetime="2017-01-30T16:51:37-05:00"/>
  </status>
  <introduced datetime="2017-01-03"/>
  <titles>
    <title type="short" as="introduced">Fort Ontario Study Act</title>
    <title type="short" as="introduced">Fort Ontario Study Act</title>
    <title type="short" as="passed house">Fort Ontario Study Act</title>
    <title type="short" as="passed house">Fort Ontario Study Act</title>
    <title type="short" as="reported to senate">Fort Ontario Study Act</title>
    <title type="short" as="reported to senate">Fort Ontario Study Act</title>
    <title type="official" as="introduced">To authorize the Secretary of the Interior to conduct a special resource study of Fort Ontario in the State of New York.</title>
    <title type="display">Fort Ontario Study Act</title>
  </titles>
  <sponsor bioguide_id="K000386"/>
  <cosponsors>
    <cosponsor bioguide_id="S000480" joined="2017-01-03"/>
    <cosponsor bioguide_id="T000478" joined="2017-01-03"/>
  </cosponsors>
  <actions>
    <action datetime="2017-01-03">
      <text>Introduced in House</text>
    </action>
    <action datetime="2017-01-03" state="REFERRED">
      <text>Referred to the House Committee on Natural Resources.</text>
    </action>
    <action datetime="2017-01-30">
      <text>Sponsor introductory remarks on measure.</text>
      <reference ref="CR H712-713"/>
    </action>
    <action datetime="2017-01-30T16:44:18-05:00">
      <text>Mr. McClintock moved to suspend the rules and pass the bill.</text>
    </action>
    <action datetime="2017-01-30T16:44:30-05:00">
      <text>Considered under suspension of the rules.</text>
      <reference ref="CR H712-713" label="consideration"/>
    </action>
    <action datetime="2017-01-30T16:44:32-05:00">
      <text>DEBATE - The House proceeded with forty minutes of debate on H.R. 46.</text>
    </action>
    <vote how="by voice vote" type="vote" datetime="2017-01-30T16:51:37-05:00" where="h" result="pass" state="PASS_OVER:HOUSE">
      <text>On motion to suspend the rules and pass the bill Agreed to by voice vote.</text>
      <reference ref="CR H712" label="text"/>
    </vote>
    <action datetime="2017-01-30T16:51:57-05:00">
      <text>Motion to reconsider laid on the table Agreed to without objection.</text>
    </action>
    <action datetime="2017-01-31">
      <text>Received in the Senate.</text>
    </action>
    <action datetime="2017-03-07">
      <text>Read twice and referred to the Committee on Energy and Natural Resources.</text>
    </action>
    <calendar datetime="2017-03-30">
      <text>Committee on Energy and Natural Resources. Ordered to be reported with an amendment in the nature of a substitute favorably.</text>
    </calendar>
    <action datetime="2017-06-14">
      <text>Committee on Energy and Natural Resources. Reported by Senator Murkowski with an amendment in the nature of a substitute. With written report No. 115-110.</text>
    </action>
    <calendar datetime="2017-06-14" calendar="Senate Legislative" under="General Orders" number="147">
      <text>Placed on Senate Legislative Calendar under General Orders. Calendar No. 147.</text>
    </calendar>
  </actions>
  <committees>
    <committee subcommittee="" code="SSEG" name="Senate Energy and Natural Resources" activity="Reporting, Markup, Referral"/>
    <committee subcommittee="" code="HSII" name="House Natural Resources" activity="Referral"/>
  </committees>
  <relatedbills>
    <bill type="s" session="115" relation="unknown" number="55"/>
  </relatedbills>
  <subjects>
    <term name="Public lands and natural resources"/>
    <term name="Government studies and investigations"/>
    <term name="Historic sites and heritage areas"/>
    <term name="Military history"/>
    <term name="New York State"/>
    <term name="Parks, recreation areas, trails"/>
    <term name="U.S. history"/>
  </subjects>
  <amendments/>
  <summary date="2017-06-14T12:19:16Z" status="Reported to Senate with amendment(s)">Fort Ontario Study Act

(Sec. 3) This bill directs the Department of the Interior to conduct a special resource study of Fort Ontario in Oswego, New York.

Interior shall: (1) evaluate the Fort's national significance, and (2) determine the suitability and feasibility of designating it as a unit of the National Park System.</summary>
  <committee-reports>
    <report>S. Rept. 115-110</report>
  </committee-reports>
</bill>


text:
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET FOREIGN_KEY_CHECKS=0 */;

DROP PROCEDURE IF EXISTS `sp_AddCharacterToAccount`;
DELIMITER //
CREATE PROCEDURE `sp_AddCharacterToAccount`(IN `object_id` BIGINT, IN `account_id` INT)
BEGIN
	   DECLARE player_id BIGINT(20);
		-- PLAYER ACCOUNT
      SELECT id FROM player_account where account_id = reference_id INTO player_id;
      INSERT INTO player_accounts_creatures values (player_id, object_id);
END//
DELIMITER ;
/*!40014 SET FOREIGN_KEY_CHECKS=1 */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;


text:
extern crate releasetag;

use std::time::Duration;
use std::thread;
use std::io::stdout;
use std::io::Write;

fn main() {
    releasetag!(b"BUILD_TAG=pre");
    releasetag!(b"BUILD_TAG=",     b"MAIN_2016-wk16-05-AAAA-BBBB-CCCC-DDDD-EEEE-FFFF-GGGG-HHHH-IIII-JJJJ-KKKK");

    // Including data from one or multiple files or compile time env params.
    // Note: the content mustn't contain any newline or linebreak as those would interfer with zero terminated strings!!
    let mut version: [u8; 5] = [0; 5];
    version.copy_from_slice(env!("CARGO_PKG_VERSION").as_bytes());
    releasetag!(b"BUILD_VERSION=", &version);
    releasetag!(b"BUILD_TAG=",     &version, b"/", include_bytes!("../../AUTHOR"));

    // or as byte array
    releasetag!(b"BUILD_HOST=",    &[0x30u8, 0x31u8, 0x33u8]);

    println!("Waiting until being aborted");
    loop {
      thread::sleep(Duration::from_millis(200));
      print!(".");
      stdout().flush().ok();
    }
}


text:
package com.thegongoliers.paths;

public enum PathStepType {
    ROTATION, STRAIGHT_AWAY
}


text:
package com.apkfuns.virtualapkdemo;

import android.app.Application;
import android.content.Context;

import com.didi.virtualapk.PluginManager;

/**
 * Created by pengwei on 2017/6/30.
 */

public class HiApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        PluginManager.getInstance(base).init();
    }
}


text:
license: >
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF 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.
---

Upgrading Cordova Android
=========================

This document is for people who need to upgrade their Cordova versions from an older version to a current version of Cordova.

## Upgrade to 2.0.0 from 1.9.0 ##

1. Remove cordova-1.9.0.jar from the libs directory in your project
2. Add cordova-2.0.0.jar to the libs directory in your project
3. If you are using Eclipse, please refresh your eclipse project and do a clean
4. Copy the new cordova-2.0.0.js into your project
5. Update your HTML to use the new cordova-2.0.0.js file
6. Copy the res/xml/config.xml to be the same as the one found in framework/res/xml/config.xmll

### Notes about 2.0.0 release
config.xml will be replacing cordova.xml and plugins.xml.  This new file is a combination of the previous two.  However, the
old files are deprecated, and and while currently still work, will cease working in a future release.

## Upgrade to 1.9.0 from 1.8.1 ##

1. Remove cordova-1.8.0.jar from the libs directory in your project
2. Add cordova-1.9.0.jar to the libs directory in your project
3. If you are using Eclipse, please refresh your eclipse project and do a clean
4. Copy the new cordova-1.9.0.js into your project
5. Update your HTML to use the new cordova-1.9.0.js file
6. Update the res/xml/plugins.xml to be the same as the one found in framework/res/xml/plugins.xml

### Notes about 1.9.0 release

- Third-Party plugins may or may not work.  This is because of the introduction of the CordovaWebView.  These plugins need to get a context from the CordovaInterface using
getContext() or getActivity().  If you are not an experienced Android developer, please contact the plugin maintainer and add this task to their bug tracker.

## Upgrade to 1.8.0 from 1.8.0 ##

1. Remove cordova-1.8.0.jar from the libs directory in your project
2. Add cordova-1.8.1.jar to the libs directory in your project
3. If you are using Eclipse, please refresh your eclipse project and do a clean
4. Copy the new cordova-1.8.1.js into your project
5. Update your HTML to use the new cordova-1.8.1.js file
6. Update the res/xml/plugins.xml to be the same as the one found in framework/res/xml/plugins.xml

## Upgrade to 1.8.0 from 1.7.0 ##

1. Remove cordova-1.7.0.jar from the libs directory in your project
2. Add cordova-1.8.0.jar to the libs directory in your project
3. If you are using Eclipse, please refresh your eclipse project and do a clean
4. Copy the new cordova-1.8.0.js into your project
5. Update your HTML to use the new cordova-1.8.0.js file
6. Update the res/xml/plugins.xml to be the same as the one found in framework/res/xml/plugins.xml

## Upgrade to 1.8.0 from 1.7.0 ##

1. Remove cordova-1.7.0.jar from the libs directory in your project
2. Add cordova-1.8.0.jar to the libs directory in your project
3. If you are using Eclipse, please refresh your eclipse project and do a clean
4. Copy the new cordova-1.8.0.js into your project
5. Update your HTML to use the new cordova-1.8.0.js file
6. Update the res/xml/plugins.xml to be the same as the one found in framework/res/xml/plugins.xml

## Upgrade to 1.7.0 from 1.6.1 ##

1. Remove cordova-1.6.1.jar from the libs directory in your project
2. Add cordova-1.7.0.jar to the libs directory in your project
3. If you are using Eclipse, please refresh your eclipse project and do a clean
4. Copy the new cordova-1.7.0.js into your project
5. Update the res/xml/plugins.xml to be the same as the one found in framework/res/xml/plugins.xml

## Upgrade to 1.6.1 from 1.6.0 ##

1. Remove cordova-1.6.0.jar from the libs directory in your project
2. Add cordova-1.6.1.jar to the libs directory in your project
3. If you are using Eclipse, please refresh your eclipse project and do a clean
4. Copy the new cordova-1.6.1.js into your project
5. Update the res/xml/plugins.xml to be the same as the one found in framework/res/xml/plugins.xml

## Upgrade to 1.6.0 from 1.5.0 ##
1. Remove cordova-1.5.0.jar from the libs directory in your project
2. Add cordova-1.6.0.jar to the libs directory in your project
3. If you are using Eclipse, please refresh your eclipse project and do a clean
4. Copy the new cordova-1.6.0.js into your project
5. Update your HTML to use the new cordova-1.6.0.js file
6. Update the res/xml/plugins.xml so that it is the same as the one found in framework/res/xml/plugins.xml
7. Replace the res/xml/phonegap.xml with res/xml/cordova.xml so that it is the same as the one found in framework/res/xml/cordova.xml

## Upgrade to 1.5.0 from 1.4.0##
1. Remove phonegap-1.4.0.jar from the libs directory in your project
2. Add cordova-1.5.0.jar to the libs directory in your project
3. If you are using Eclipse, please refresh your eclipse project and do a clean
4. Copy the new cordova-1.5.0.js into your project
5. Update your HTML to use the new cordova-1.5.0.js file
6. Update the res/xml/plugins.xml so that it is the same as the one found in framework/res/xml/plugins.xml
7. Replace the res/xml/phonegap.xml with res/xml/cordova.xml so that it is the same as the one found in framework/res/xml/cordova.xml

## Upgrade to 1.4.0 from 1.3.0 ##
1. Remove phonegap-1.3.0.jar from the libs directory in your project
2. Add phonegap-1.4.0.jar to the libs directory in your project
3. If you are using Eclipse, please refresh your eclipse project and do a clean
4. Copy the new phonegap-1.4.0.js into your project
5. Update your HTML to use the new phonegap-1.4.0.js file
6. Update the res/xml/plugins.xml so that it is the same as the one found in framework/res/xml/plugins.xml
7. Update the res/xml/phonegap.xml so that it is the same as the one found in framework/res/xml/phonegap.xml

## Upgrade to 1.3.0 from 1.2.0 ##
1. Remove phonegap-1.2.0.jar from the libs directory in your project
2. Add phonegap-1.3.0.jar to the libs directory in your project
3. If you are using Eclipse, please refresh your eclipse project and do a clean
4. Copy the new phonegap-1.3.0.js into your project
5. Update your HTML to use the new phonegap-1.2.0.js file
6. Update the res/xml/plugins.xml so that it is the same as the one found in framework/res/xml/plugins.xml
7. Update the res/xml/phonegap.xml so that it is the same as the one found in framework/res/xml/phonegap.xml

## Upgrade to 1.2.0 from 1.1.0 ##
1. Remove phonegap-1.1.0.jar from the libs directory in your project
2. Add phonegap-1.2.0.jar to the libs directory in your project
3. If you are using Eclipse, please refresh your eclipse project and do a clean
4. Copy the new phonegap-1.2.0.js into your project
5. Update your HTML to use the new phonegap-1.2.0.js file
6. Update the res/xml/plugins.xml so that it is the same as the one found in framework/res/xml/plugins.xml
7. Update the res/xml/phonegap.xml so that it is the same as the one found in framework/res/xml/phonegap.xml

## Upgrade to 1.1.0 from 1.0.0 ##
1. Remove phonegap-1.0.0.jar from the libs directory in your project
2. Add phonegap-1.1.0.jar to the libs directory in your project
3. If you are using Eclipse, please refresh your eclipse project and do a clean
4. Copy the new phonegap-1.1.0.js into your project
5. Update your HTML to use the new phonegap-1.1.0.js file
6. Update the res/xml/plugins.xml so that it is the same as the one found in framework/res/xml/plugins.xml

## Upgrade to 1.0.0 from 0.9.6 ##
1. Remove phonegap-0.9.6.jar from the libs directory in your project
2. Add phonegap-1.0.0.jar to the libs directory in your project
3. If you are using Eclipse, please refresh your eclipse project and do a clean
4. Copy the new phonegap-1.0.0.js into your project
5. Update your HTML to use the new phonegap-1.0.0.js file
6. Add the res/xml/plugins.xml so that it is the same as the one found in framework/res/xml/plugins.xml


text:
TODO: describe the idea behind the current detector

# 2018 Arm Collision Detector
TODO: describe the idea behind the old detector


text:
window.onload = function() {
  var dweets = document.querySelectorAll('.dweet');
  var dweetiframes = document.querySelectorAll('.dweetiframe');
  var editor = document.querySelector('#editor');
  var editoriframe = document.querySelector('#preview-iframe');
  var oldCode = editor && editor.value;

  addEventListener('message', receiveMessage, false);

  [].forEach.call(dweetiframes, function(iframe) {
    registerWaypoint(iframe);
  });

  [].forEach.call(dweets, function(dweet) {
    registerOnKeyListener(dweet);
    registerStatsClickListeners(dweet);
  });

  window.onmessage = function(event) {
    var recordButton;
    if (event.data.msg === 'finished') {
      recordButton = document.getElementById('record-' + event.data.dweetId);
      recordButton.classList.remove('processing');
      recordButton.getElementsByTagName('span')[0].innerHTML = 'record';
    }
  };

  if (editor && editoriframe) {
    // Update editor!
    showCode(editoriframe, oldCode);
    editor.addEventListener('keyup', function() {
      if (editor.value === oldCode) {
        return;
      }
      editor.size = Math.max(editor.value.length, 1);
      showCode(editoriframe, editor.value);
      oldCode = editor.value;
    });
  }

  // eslint-disable-next-line no-new
  new Waypoint.Infinite({
    element: $('.dweet-feed')[0],
    items: '.dweet-wrapper, .loading, .end-of-feed',
    more: '.next-page',
    onAfterPageLoad: function(items) {
      $('.loading:not(:last-of-type)').hide();

      function requestFullscreen(el) {
        (el.mozRequestFullScreen ||
           el.webkitRequestFullscreen ||
           el.requestFullscreen).call(el);
      }

      $.each(items, function(index, div) {
        var iframe = $(div).find('.dweetiframe')[0];
        var link = $(div).find('.fullscreen-button');
        var timestamp = $(div).find('time');
        var postedDate = moment.utc(timestamp.attr('datetime'));

        registerOnKeyListener(div);
        registerStatsClickListeners(div);
        registerWaypoint(iframe);

        // Register full-screen button
        link.on('click', function(e) {
          e.preventDefault();
          requestFullscreen(iframe);
        });

        moment.locale(navigator.userLanguage || navigator.language || 'en-US');
        timestamp.text(postedDate.local().format('lll'));
      });
    },
  });
};

function receiveMessage(event) {
  var origin = event.origin || event.originalEvent.origin;
  if (origin !== 'http://dweet.localhost:8000'
      && origin !== 'https://dweet.dwitter.net'
      && origin !== 'https://dweet.localhost:8000') {
    return;
  }

  if (event.data.type === 'error') {
    displayError(event.data.location, event.data.error);
  }
}

function displayError(iframeurl, e) {
  $('iframe[src^="' + iframeurl + '"]')
    .closest('.dweet')
    .find('.error-display')[0]
    .innerText = e;
}

function registerWaypoint(iframe) {
  // eslint-disable-next-line no-new
  new Waypoint.Inview({
    element: iframe,
    entered: function() {
      play(iframe);
    },
    exit: function() {
      var fullscreenElement = (document.fullscreenElement ||
            document.webkitFullscreenElement ||
            document.mozFullScreenElement);
      if (fullscreenElement !== iframe) {
        pause(iframe);
      }
    },
  });
}

function play(iframe) {
  var dweetwin = iframe.contentWindow || iframe;
  dweetwin.postMessage('play', '*');
}

function pause(iframe) {
  var dweetwin = iframe.contentWindow || iframe;
  dweetwin.postMessage('pause', '*');
}

function showCode(iframe, code) {
  var dweetwin = iframe.contentWindow || iframe;
  dweetwin.postMessage('code ' + code, '*');
}

function showStats(dweet, iframe) {
  (iframe.contentWindow || iframe).postMessage('showStats', '*');
  $(dweet).find('.show-stats').hide();
  $(dweet).find('.hide-stats').show();
}

function hideStats(dweet, iframe) {
  (iframe.contentWindow || iframe).postMessage('hideStats', '*');
  $(dweet).find('.show-stats').show();
  $(dweet).find('.hide-stats').hide();
}

function registerOnKeyListener(dweet) {
  var iframe = $(dweet).find('.dweetiframe')[0];
  var editor = $(dweet).find('.code-input')[0];
  var changedDweetMenu = $(dweet).find('.dweet-changed');
  var submitButton = $(dweet).find('.remix-button,.dweet-button')[0];
  var captionField = $(dweet).find('.new-dweet-comment-input')[0];
  var captionFieldDisabled = 'Change the code...';

  // Use the string from the template:
  var captionFieldEnabled = $(captionField).prop('placeholder');

  var oldCode = editor.value;
  var originalCode = oldCode;

  showCode(iframe, oldCode);

  editor.addEventListener('focus', function() {
    changedDweetMenu.show();
    if (editor.value === originalCode) {
      $(submitButton).prop('disabled', true);
      $(captionField).prop('placeholder', captionFieldDisabled);
    }
  });

  editor.addEventListener('keyup', function() {
    showStats(dweet, iframe);

    changedDweetMenu.show();

    if (editor.value === originalCode) {
      $(submitButton).prop('disabled', true);
      $(captionField).prop('placeholder', captionFieldDisabled);
    } else {
      $(submitButton).prop('disabled', false);
      $(captionField).prop('placeholder', captionFieldEnabled);
    }

    if (editor.value === oldCode) {
      return;
    }
    editor.size = Math.max(editor.value.length, 1);
    showCode(iframe, editor.value);
    oldCode = editor.value;
  });
}

function registerStatsClickListeners(element) {
  var iframe = $(element).find('.dweetiframe')[0];
  $(element).find('.show-stats').click(function(e) {
    e.preventDefault();
    showStats(element, iframe);
  });
  $(element).find('.hide-stats').click(function(e) {
    e.preventDefault();
    hideStats(element, iframe);
  });
}

// Show/hide header when scrolling
(function() {
  var lastScrollTop = null;
  // One user scroll action can fire many browser 'scroll' events.
  // To reduce calls to toggleClass() we keep the current state in a boolean.
  var isHidden = false;
  window.addEventListener('scroll', function() {
    var newScrollTop = $(this).scrollTop();
    var newHiddenState = getHeaderHiddenState(lastScrollTop, newScrollTop);
    if (newHiddenState !== null && newHiddenState !== isHidden) {
      isHidden = newHiddenState;
      $('.head-menu').toggleClass('hidden', isHidden);
    }
    lastScrollTop = newScrollTop;
  });
}());

// Returns whether header should be hidden or not,
// or returns null if unsure (no state change requested).
function getHeaderHiddenState(lastScrollTop, newScrollTop) {
  // Ignore the first scroll event, because we don't have lastScrollTop yet
  if (lastScrollTop === null) {
    return null;
  }
  // Do not hide the header after scrolling only one pixel down from the top
  // of the page; that would look empty because there is nothing behind it!
  // Only hide after 85 pixels (this value is #content padding-top minus 5)
  if (newScrollTop > lastScrollTop && newScrollTop > 85) {
    return true;
  }
  if (newScrollTop < lastScrollTop) {
    return false;
  }
  return null;
}


text:
import Vue from 'vue';
import App from './Setup/SetupCustom.vue';
import '../style/main.scss';

new Vue({
	el: '#app',
	render: h => h(App)
});