text:
import logging
import pytest
from tests.common.test_vector import *
from tests.common.impala_test_suite import ImpalaTestSuite
from tests.common.test_dimensions import create_exec_option_dimension
from tests.common.test_dimensions import create_uncompressed_text_dimension
from tests.util.test_file_parser import QueryTestSectionReader

agg_functions = ['sum', 'count', 'min', 'max', 'avg']

data_types = ['int', 'bool', 'double', 'bigint', 'tinyint',
              'smallint', 'float', 'timestamp']

result_lut = {
  # TODO: Add verification for other types
  'sum-tinyint': 45000, 'avg-tinyint': 5, 'count-tinyint': 9000,
      'min-tinyint': 1, 'max-tinyint': 9,
  'sum-smallint': 495000, 'avg-smallint': 50, 'count-smallint': 9900,
      'min-smallint': 1, 'max-smallint': 99,
  'sum-int': 4995000, 'avg-int': 500, 'count-int': 9990,
      'min-int': 1, 'max-int': 999,
  'sum-bigint': 49950000, 'avg-bigint': 5000, 'count-bigint': 9990,
      'min-bigint': 10, 'max-bigint': 9990,
}

class TestAggregation(ImpalaTestSuite):
  @classmethod
  def get_workload(self):
    return 'functional-query'

  @classmethod
  def add_test_dimensions(cls):
    super(TestAggregation, cls).add_test_dimensions()

    # Add two more dimensions
    cls.TestMatrix.add_dimension(TestDimension('agg_func', *agg_functions))
    cls.TestMatrix.add_dimension(TestDimension('data_type', *data_types))
    cls.TestMatrix.add_constraint(lambda v: cls.is_valid_vector(v))

  @classmethod
  def is_valid_vector(cls, vector):
    data_type, agg_func = vector.get_value('data_type'), vector.get_value('agg_func')
    file_format = vector.get_value('table_format').file_format
    if file_format not in ['parquet']: return False

    if cls.exploration_strategy() == 'core':
      # Reduce execution time when exploration strategy is 'core'
      if vector.get_value('exec_option')['batch_size'] != 0: return False

    # Avro doesn't have timestamp type
    if file_format == 'avro' and data_type == 'timestamp':
      return False
    elif agg_func not in ['min', 'max', 'count'] and data_type == 'bool':
      return False
    elif agg_func == 'sum' and data_type == 'timestamp':
      return False
    return True

  def test_aggregation(self, vector):
    data_type, agg_func = (vector.get_value('data_type'), vector.get_value('agg_func'))
    query = 'select %s(%s_col) from alltypesagg where day is not null' % (agg_func,
        data_type)
    result = self.execute_scalar(query, vector.get_value('exec_option'),
                                 table_format=vector.get_value('table_format'))
    if 'int' in data_type:
      assert result_lut['%s-%s' % (agg_func, data_type)] == int(result)

    # AVG
    if vector.get_value('data_type') == 'timestamp' and\
       vector.get_value('agg_func') == 'avg':
      return
    query = 'select %s(DISTINCT(%s_col)) from alltypesagg where day is not null' % (
        agg_func, data_type)
    result = self.execute_scalar(query, vector.get_value('exec_option'))

class TestAggregationQueries(ImpalaTestSuite):
  """Run the aggregation test suite, with codegen enabled and disabled, to exercise our
  non-codegen code"""
  @classmethod
  def get_workload(self):
    return 'functional-query'

  @classmethod
  def add_test_dimensions(cls):
    super(TestAggregationQueries, cls).add_test_dimensions()

    cls.TestMatrix.add_dimension(
      create_exec_option_dimension(disable_codegen_options=[False, True]))

    if cls.exploration_strategy() == 'core':
      cls.TestMatrix.add_dimension(create_uncompressed_text_dimension(cls.get_workload()))

  @pytest.mark.execute_serially
  def test_non_codegen_tinyint_grouping(self, vector):
    # Regression for IMPALA-901. The test includes an INSERT statement, so can only be run
    # on INSERT-able formats - text only in this case, since the bug doesn't depend on the
    # file format.
    if vector.get_value('table_format').file_format == 'text' \
        and vector.get_value('table_format').compression_codec == 'none':
      self.run_test_case('QueryTest/aggregation_no_codegen_only', vector)

  def test_aggregation(self, vector):
    if vector.get_value('table_format').file_format == 'hbase':
      pytest.xfail(reason="IMPALA-283 - select count(*) produces inconsistent results")
    self.run_test_case('QueryTest/aggregation', vector)

  def test_distinct(self, vector):
    if vector.get_value('table_format').file_format == 'hbase':
      pytest.xfail("HBase returns columns in alphabetical order for select distinct *, "
                   "making the result verication to fail.")
    self.run_test_case('QueryTest/distinct', vector)


text:
<constraint-mappings
        xmlns="http://jboss.org/xml/ns/javax/validation/mapping"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation=
                "http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.1.xsd" version="1.1">

    <bean class="org.hibernate.validator.test.internal.engine.methodvalidation.model.Address"
          ignore-annotations="true"/>
    <bean class="org.hibernate.validator.test.internal.engine.methodvalidation.model.Customer"
          ignore-annotations="true"/>

    <bean class="org.hibernate.validator.test.internal.engine.methodvalidation.service.CustomerRepository"
          ignore-annotations="true"/>
    <bean class="org.hibernate.validator.test.internal.engine.methodvalidation.service.CustomerRepositoryImpl"
          ignore-annotations="true">
        <constructor>
            <parameter type="foo">
                <constraint annotation="javax.validation.constraints.NotNull">
                    <message>xml configured not null constraint</message>
                </constraint>
            </parameter>
            <return-value ignore-annotations="false">
                <valid/>
            </return-value>
        </constructor>
    </bean>

    <bean class="org.hibernate.validator.test.internal.engine.methodvalidation.service.RepositoryBase"
          ignore-annotations="true"/>
</constraint-mappings>

redpajama_set_name: RedPajamaGithub


text:
#region License

#endregion License

using System.Collections.Generic;
using System.Linq;

namespace Sudoku.Core
{
    public static class Resolver
    {
        public static bool CanResolve(Cell[,] cells)
        {
            return Resolve(CloneCells(cells));
        }

        public static bool Resolve(Cell[,] cells)
        {
            var cell = GetEmptyCell(cells);
            if (cell != null)
            {
                foreach (var number in Numbers.List(1, cells.GetLength(1)))
                {
                    if (Validator.TryNumber(cells, cell.Y, cell.X, number))
                    {
                        cell.Value = number;
                        if (Resolve(cells))
                            return true;
                        else
                            cell.Value = 0;
                    }
                }

                return false;
            }
            return true;
        }

        private static Cell GetEmptyCell(Cell[,] cells)
        {
            for (int y = 0; y < cells.GetLength(0); ++y)
            {
                for (int x = 0; x < cells.GetLength(1); ++x)
                {
                    if (cells[y, x].Value == 0)
                        return cells[y, x];
                }
            }
            return null;
        }

        private static Cell[,] CloneCells(Cell[,] cells)
        {
            var cellCopy = new Cell[cells.GetLength(0), cells.GetLength(1)];
            for (int y = 0; y < cells.GetLength(0); ++y)
            {
                for (int x = 0; x < cells.GetLength(1); ++x)
                {
                    var cell = cells[y, x];
                    cellCopy[y, x] = new Cell(cell.Y, cell.X, cell.Value, cell.Region);
                    cellCopy[y, x].IsEditable = cell.IsEditable;
                }
            }
            return cellCopy;
        }

        public static bool CanResolveUnique(Cell[,] cells)
        {
            cells = CloneCells(cells);
            if (Validator.EmptyCellsExist(cells))
            {
                var regions = GetRegions(cells);
                bool freeCells = true;
                while (freeCells)
                {
                    bool valueSet = false;
                    foreach (var region in regions)
                    {
                        var numbers = GetFreeNumbers(cells, region);
                        foreach (var number in numbers)
                        {
                            var possible = PossiblePositionsCount(cells, region, number);
                            if (possible.Count == 1)
                            {
                                possible[0].Value = number;
                                valueSet = true;
                            }
                        }
                    }
                    if (!valueSet)
                        return false;
                    freeCells = Validator.EmptyCellsExist(cells);
                }
            }
            return true;
        }

        private static List<int> GetFreeNumbers(Cell[,] cells, Region region)
        {
            var freeNumbers = Numbers.List(1, 9);
            for (int y = region.BeginY; y < region.EndY; ++y)
            {
                for (int x = region.BeginX; x < region.EndX; ++x)
                {
                    freeNumbers.Remove(cells[y, x].Value);
                }
            }
            return freeNumbers;
        }

        private static List<Region> GetRegions(Cell[,] cells)
        {
            var regions = new List<Region>();

            for (int y = 0; y < cells.GetLength(0); ++y)
            {
                for (int x = 0; x < cells.GetLength(1); ++x)
                {
                    var region = cells[y, x].Region;
                    var available = regions.Where(r => r.BeginX == region.BeginX &&
                                                       r.BeginY == region.BeginY);
                    if (available.Count() == 0)
                        regions.Add(region);
                }
            }

            return regions;
        }

        private static List<Cell> PossiblePositionsCount(Cell[,] cells, Region region, int number)
        {
            var possibleCells = new List<Cell>();
            for (int y = region.BeginY; y < region.EndY; ++y)
            {
                for (int x = region.BeginX; x < region.EndX; ++x)
                {
                    if (cells[y, x].Value == 0)
                    {
                        if (Validator.TryNumber(cells, y, x, number))
                        {
                            possibleCells.Add(cells[y, x]);
                        }
                    }
                }
            }
            return possibleCells;
        }
    }
}


text:
#include "ble_rpc_cmd_decoder_gatts.h"
#include <stdio.h>
#include <string.h>
#include "app_util.h"
#include "ble.h"
#include "ble_gatts.h"
#include "ble_rpc_cmd_decoder.h"
#include "ble_rpc_defines.h"
#include "nrf_error.h"
#include "nrf_soc.h"
#include "nordic_common.h"

#define GATTS_CHAR_USER_DESC_LEN_MAX 512 /**< Max length of characteristic user description. */

/**@brief Function for decoding attribute meta data.
 *
 * @note The attribute meta data vloc needs to be @ref BLE_GATTS_VLOC_STACK. As the Connectivity
 *       Chip SoftDevice is not able to refer to a memory address on the Application Chip.
 *
 * @param[in]  p_buffer         The buffer containing the encoded ble_gatts_attr_md_t.
 * @param[out] p_attr_md        Decoded attribute meta data.
 * @param[out] p_index          Number of bytes decoded.
 *
 * @retval NRF_SUCCESS               If the decoding of attribute meta data was successful.
 * @retval NRF_ERROR_INVALID_PARAM   If vloc is set to a value other than BLE_GATTS_VLOC_STACK.
 */
static uint32_t attr_md_decode(uint8_t *             p_buffer,
                               ble_gatts_attr_md_t * p_attr_md,
                               uint32_t *            p_index)
{
    uint32_t index = 0;

    p_attr_md->read_perm.sm     = ((p_buffer[index]   >> 0) & 0xF);
    p_attr_md->read_perm.lv     = ((p_buffer[index++] >> 4) & 0xF);

    p_attr_md->write_perm.sm    = ((p_buffer[index]   >> 0) & 0xF);
    p_attr_md->write_perm.lv    = ((p_buffer[index++] >> 4) & 0xF);

    p_attr_md->vlen             = ((p_buffer[index]   >> 0) & 0x1);
    p_attr_md->vloc             = ((p_buffer[index]   >> 1) & 0x3);
    p_attr_md->rd_auth          = ((p_buffer[index]   >> 3) & 0x1);
    p_attr_md->wr_auth          = ((p_buffer[index++] >> 4) & 0x1);

    *p_index += index;

    return (p_attr_md->vloc == BLE_GATTS_VLOC_STACK) ? NRF_SUCCESS : NRF_ERROR_INVALID_PARAM;
}

/**@brief Function for decoding a command packet with RPC_SD_BLE_GATTS_SERVICE_ADD opcode.
 *
 * This function will decode the command, call the BLE Stack API, and also send command response
 * to the peer through the the transport layer.
 *
 * @param[in] p_command         The encoded structure that needs to be decoded and passed on
 *                              to the BLE Stack API.
 * @param[in] command_len       The length of the encoded command read from transport layer.
 *
 * @retval NRF_SUCCESS               If the decoding of the command was successful, the SoftDevice
 *                                   API was called, and the command response was sent to peer,
 *                                   otherwise an error code.
 * @retval NRF_ERROR_INVALID_LENGTH  If the content length of the packet is not conforming to the
 *                                   codec specification.
 */
static uint32_t gatts_service_add_handle(const uint8_t * const p_command, uint32_t command_len)
{
    uint8_t      type;
    uint16_t *   p_handle;
    uint32_t     err_code;
    ble_uuid_t   uuid;
    ble_uuid_t * p_uuid;
    uint8_t      resp_data[sizeof(uint16_t)];

    uint32_t index  = 0;
    uint16_t handle = 0;

    type = p_command[index++];
    RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_SERVICE_ADD);

    // Service UUID field is present.
    if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
    {
        uuid.uuid = uint16_decode(&p_command[index]);
        index    += sizeof(uint16_t);
        uuid.type = p_command[index++];
        p_uuid    = &uuid;
        RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_SERVICE_ADD);
    }
    else
    {
        RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_SERVICE_ADD);
        p_uuid = NULL;
    }

    // Handle present.
    if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
    {
        p_handle = &handle;
    }
    else
    {
        p_handle = NULL;
    }

    RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_SERVICE_ADD);

    err_code = sd_ble_gatts_service_add(type, p_uuid, p_handle);

    if (err_code == NRF_SUCCESS)
    {
        UNUSED_VARIABLE(uint16_encode(handle, resp_data));
        return ble_rpc_cmd_resp_data_send(SD_BLE_GATTS_SERVICE_ADD,
                                          err_code,
                                          resp_data,
                                          sizeof(resp_data));
    }
    else
    {
        return ble_rpc_cmd_resp_send(SD_BLE_GATTS_SERVICE_ADD, err_code);
    }
}

/**@brief Function for decoding a command packet with RPC_SD_BLE_GATTS_SYS_ATTR_GET opcode.
 *
 * This function will decode the command, call the BLE Stack API, and also send command response
 * to the peer through the the transport layer.
 *
 * @param[in] p_command         The encoded structure that needs to be decoded and passed on
 *                              to the BLE Stack API.
 * @param[in] command_len       The length of the encoded command read from transport layer.
 *
 * @retval NRF_SUCCESS               If the decoding of the command was successful, the SoftDevice
 *                                   API was called, and the command response was sent to peer,
 *                                   otherwise an error code.
 * @retval NRF_ERROR_INVALID_LENGTH  If the content length of the packet is not conforming to the
 *                                   codec specification.
 */
static uint32_t gatts_sys_attr_get_handle(uint8_t const * const p_command, uint32_t command_len)
{
    uint32_t err_code;
    uint8_t  resp_data[BLE_GATTS_VAR_ATTR_LEN_MAX];
    uint16_t conn_handle;

    uint32_t   index              = 0;
    uint16_t   attr_data_length   = 0;
    uint8_t *  p_attr_data        = &resp_data[3];
    uint16_t * p_attr_data_length = &attr_data_length;

    conn_handle  = uint16_decode(&p_command[index]);
    index       += sizeof(uint16_t);
    RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_SYS_ATTR_GET);

    if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
    {
        attr_data_length  = uint16_decode(&p_command[index]);
        index            += sizeof(uint16_t);
    }
    else
    {
        p_attr_data_length = NULL;
    }

    RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_SYS_ATTR_GET);

    if (p_command[index++] == RPC_BLE_FIELD_NOT_PRESENT)
    {
        p_attr_data = NULL;
    }

    RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_SYS_ATTR_GET);

    err_code = sd_ble_gatts_sys_attr_get(conn_handle, p_attr_data, p_attr_data_length);

    if (err_code == NRF_SUCCESS)
    {
        index  = 0;
        index += uint16_encode(*p_attr_data_length, &resp_data[0]);

        if (p_attr_data == NULL)
        {
            resp_data[index++] = RPC_BLE_FIELD_NOT_PRESENT;
        }
        else
        {
            resp_data[index++]  = RPC_BLE_FIELD_PRESENT;
            index              += *p_attr_data_length;
        }

        return ble_rpc_cmd_resp_data_send(SD_BLE_GATTS_SYS_ATTR_GET,
                                          err_code,
                                          resp_data,
                                          index);
    }
    else
    {
        return ble_rpc_cmd_resp_send(SD_BLE_GATTS_SYS_ATTR_GET, err_code);
    }
}

/**@brief Function for decoding a command packet with RPC_SD_BLE_GATTS_SYS_ATTR_SET opcode.
 *
 * This function will decode the command, call the BLE Stack API, and also send command response
 * to the peer through the the transport layer.
 *
 * @param[in] p_command         The encoded structure that needs to be decoded and passed on
 *                              to the BLE Stack API.
 * @param[in] command_len       The length of the encoded command read from transport layer.
 *
 * @retval NRF_SUCCESS               If the decoding of the command was successful, the SoftDevice
 *                                   API was called, and the command response was sent to peer,
 *                                   otherwise an error code.
 * @retval NRF_ERROR_INVALID_LENGTH  If the content length of the packet is not conforming to the
 *                                   codec specification.
 */
static uint32_t gatts_sys_attr_set_handle(uint8_t const * const p_command, uint32_t command_len)
{
    uint16_t conn_handle;
    uint32_t err_code;

    uint32_t        index            = 0;
    uint16_t        attr_data_length = 0;
    const uint8_t * p_attr_data      = NULL;

    conn_handle  = uint16_decode(&p_command[index]);
    index       += sizeof(uint16_t);
    RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_SYS_ATTR_SET);

    if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
    {
        attr_data_length  = uint16_decode(&p_command[index]);
        index            += sizeof(uint16_t);
        p_attr_data       = &(p_command[index]);
        index            += attr_data_length;
    }

    RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_SYS_ATTR_SET);

    err_code = sd_ble_gatts_sys_attr_set(conn_handle, p_attr_data, attr_data_length);

    return ble_rpc_cmd_resp_send(SD_BLE_GATTS_SYS_ATTR_SET, err_code);
}

/**@brief Function for decoding a command packet with RPC_SD_BLE_GATTS_VALUE_SET opcode.
 *
 * This function will decode the command, call the BLE Stack API, and also send command response
 * to the peer through the the transport layer.
 *
 * @param[in] p_command         The encoded structure that needs to be decoded and passed on
 *                              to the BLE Stack API.
 * @param[in] command_len       The length of the encoded command read from transport layer.
 *
 * @retval NRF_SUCCESS               If the decoding of the command was successful, the SoftDevice
 *                                   API was called, and the command response was sent to peer,
 *                                   otherwise an error code.
 * @retval NRF_ERROR_INVALID_LENGTH  If the content length of the packet is not conforming to the
 *                                   codec specification.
 */
static uint32_t gatts_value_set_handle(uint8_t const * const p_command, uint32_t command_len)
{
    uint16_t handle;
    uint16_t offset;
    uint32_t err_code;

    uint32_t        index    = 0;
    uint16_t        length   = 0;
    uint16_t *      p_length = NULL;
    const uint8_t * p_value  = NULL;

    handle  = uint16_decode(&p_command[index]);
    index  += sizeof(uint16_t);
    RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_VALUE_SET);

    offset  = uint16_decode(&p_command[index]);
    index  += sizeof(uint16_t);
    RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_VALUE_SET);

    // Value length present.
    if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
    {
        length    = uint16_decode(&p_command[index]);
        p_length  = &length;
        index    += sizeof(uint16_t);
    }

    RPC_DECODER_LENGTH_CHECK(command_len, (index + length), SD_BLE_GATTS_VALUE_SET);

    // Value present.
    if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
    {
        p_value = &p_command[index];
    }

    RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_VALUE_SET);

    err_code = sd_ble_gatts_value_set(handle, offset, p_length, p_value);

    if (err_code == NRF_SUCCESS)
    {
        uint8_t resp_data[sizeof(uint16_t)];
        UNUSED_VARIABLE(uint16_encode(*p_length, resp_data));

        return ble_rpc_cmd_resp_data_send(SD_BLE_GATTS_VALUE_SET,
                                          err_code,
                                          resp_data,
                                          sizeof(resp_data));
    }
    else
    {
        return ble_rpc_cmd_resp_send(SD_BLE_GATTS_VALUE_SET, err_code);
    }
}

/**@brief Function for decoding a command packet with RPC_SD_BLE_GATTS_HVX opcode.
 *
 * This function will decode the command, call the BLE Stack API, and also send command response
 * to the peer through the the transport layer.
 *
 * @param[in] p_command         The encoded structure that needs to be decoded and passed on
 *                              to the BLE Stack API.
 * @param[in] command_len       The length of the encoded command read from transport layer.
 *
 * @retval NRF_SUCCESS               If the decoding of the command was successful, the SoftDevice
 *                                   API was called, and the command response was sent to peer,
 *                                   otherwise an error code.
 * @retval NRF_ERROR_INVALID_LENGTH  If the content length of the packet is not conforming to the
 *                                   codec specification.
 */
static uint32_t gatts_hvx_handle(uint8_t * const p_command, uint32_t command_len)
{
    uint32_t               err_code;
    uint16_t               conn_handle;
    ble_gatts_hvx_params_t hvx_params;
    uint8_t                resp_data[sizeof(uint16_t)];

    uint16_t                 hvx_params_data_length = 0;
    uint32_t                 index                  = 0;
    ble_gatts_hvx_params_t * p_hvx_params           = NULL;

    conn_handle  = uint16_decode(&p_command[index]);
    index       += sizeof(uint16_t);
    RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_HVX);

    if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
    {
        hvx_params.handle  = uint16_decode(&p_command[index]);
        index             += sizeof(uint16_t);
        hvx_params.type    = p_command[index++];
        hvx_params.offset  = uint16_decode(&p_command[index]);
        index             += sizeof(uint16_t);
        RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_HVX);
        if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
        {
            hvx_params_data_length  = uint16_decode(&p_command[index]);
            index                  += sizeof(uint16_t);
            hvx_params.p_len        = &hvx_params_data_length;
        }
        else
        {
            hvx_params.p_len = NULL;
        }
        RPC_DECODER_LENGTH_CHECK(command_len,
                                 (index + hvx_params_data_length),
                                 SD_BLE_GATTS_HVX);

        if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
        {
            hvx_params.p_data = &(p_command[index]);
        }
        else
        {
            hvx_params.p_data = NULL;
        }
        p_hvx_params = &hvx_params;
    }

    RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_HVX);

    err_code = sd_ble_gatts_hvx(conn_handle, p_hvx_params);

    if (err_code == NRF_SUCCESS)
    {
        if (p_hvx_params != NULL && p_hvx_params->p_len != NULL)
        {
            UNUSED_VARIABLE(uint16_encode(*(p_hvx_params->p_len), resp_data));
            return ble_rpc_cmd_resp_data_send(SD_BLE_GATTS_HVX,
                                              err_code,
                                              resp_data,
                                              sizeof(resp_data));
        }
    }

    return ble_rpc_cmd_resp_send(SD_BLE_GATTS_HVX, err_code);
}

/**@brief Function for decoding a command packet with RPC_SD_BLE_GATTS_CHARACTERISTIC_ADD opcode.
 *
 * This function will decode the command, call the BLE Stack API, and also send command response
 * to the peer through the the transport layer.
 *
 * @param[in] p_command         The encoded structure that needs to be decoded and passed on
 *                              to the BLE Stack API.
 * @param[in] command_len       The length of the encoded command read from transport layer.
 *
 * @retval NRF_SUCCESS               If the decoding of the command was successful, the SoftDevice
 *                                   API was called, and the command response was sent to peer,
 *                                   otherwise an error code.
 * @retval NRF_ERROR_INVALID_LENGTH  If the content length of the packet is not conforming to the
 *                                   codec specification.
 */
static uint32_t gatts_characteristic_add_handle(uint8_t * const p_command, uint32_t command_len)
{
    uint32_t                   err_code;
    uint16_t                   service_handle;
    uint8_t                    attr_data[BLE_GATTS_VAR_ATTR_LEN_MAX];
    uint8_t                    char_user_desc[GATTS_CHAR_USER_DESC_LEN_MAX];
    ble_gatts_char_md_t        char_md;
    ble_gatts_attr_md_t        char_md_user_desc_md;
    ble_gatts_attr_md_t        char_md_cccd_md;
    ble_gatts_attr_md_t        char_md_sccd_md;
    ble_gatts_char_pf_t        char_md_char_pf;
    ble_gatts_char_md_t *      p_char_md;
    ble_gatts_attr_t           attr_char_value;
    ble_uuid_t                 attr_char_value_uuid;
    ble_gatts_attr_md_t        attr_char_value_attr_md;
    ble_gatts_attr_t *         p_attr_char_value;
    ble_gatts_char_handles_t   handles;
    ble_gatts_char_handles_t * p_handles;

    uint32_t index = 0;

    service_handle  = uint16_decode(&p_command[index]);
    index          += sizeof(uint16_t);
    RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_CHARACTERISTIC_ADD);

    // Char Metadata present.
    if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
    {
        // Properties.
        char_md.char_props.broadcast       = ((p_command[index]   >> 0) & 1);
        char_md.char_props.read            = ((p_command[index]   >> 1) & 1);
        char_md.char_props.write_wo_resp   = ((p_command[index]   >> 2) & 1);
        char_md.char_props.write           = ((p_command[index]   >> 3) & 1);
        char_md.char_props.notify          = ((p_command[index]   >> 4) & 1);
        char_md.char_props.indicate        = ((p_command[index]   >> 5) & 1);
        char_md.char_props.auth_signed_wr  = ((p_command[index++] >> 6) & 1);

        // Extended properties.
        char_md.char_ext_props.reliable_wr = ((p_command[index]   >> 0) & 1);
        char_md.char_ext_props.wr_aux      = ((p_command[index++] >> 1) & 1);

        // User description.
        char_md.char_user_desc_max_size  = uint16_decode(&p_command[index]);
        index                           += sizeof(uint16_t);

        char_md.char_user_desc_size  = uint16_decode(&p_command[index]);
        index                       += sizeof(uint16_t);

        RPC_DECODER_LENGTH_CHECK(command_len,
                                 (index + char_md.char_user_desc_size),
                                 SD_BLE_GATTS_CHARACTERISTIC_ADD);

        // User description present.
        if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
        {
            uint32_t desc_index;
            for (desc_index = 0; desc_index < char_md.char_user_desc_size; desc_index++)
            {
                char_user_desc[desc_index] = p_command[index++];
            }
            char_md.p_char_user_desc = char_user_desc;
        }
        else
        {
            char_md.p_char_user_desc = NULL;
        }

        RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_CHARACTERISTIC_ADD);

        // Presentation format present.
        if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
        {
            char_md_char_pf.format     = p_command[index++];
            char_md_char_pf.exponent   = p_command[index++];
            char_md_char_pf.unit       = uint16_decode(&p_command[index]);
            index += sizeof(uint16_t);
            char_md_char_pf.name_space = p_command[index++];
            char_md_char_pf.desc       = uint16_decode(&p_command[index]);
            index += sizeof(uint16_t);
            char_md.p_char_pf          = &char_md_char_pf;
        }
        else
        {
            char_md.p_char_pf = NULL;
        }
        RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_CHARACTERISTIC_ADD);

        // User descriptor metadata.
        if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
        {
            RPC_DECODER_LENGTH_CHECK(command_len,
                                     (index + sizeof(ble_gatts_attr_md_t)),
                                     SD_BLE_GATTS_CHARACTERISTIC_ADD);
            err_code = attr_md_decode(&p_command[index], &char_md_user_desc_md, &index);
            if (err_code != NRF_SUCCESS)
            {
                return ble_rpc_cmd_resp_send(SD_BLE_GATTS_CHARACTERISTIC_ADD, err_code);
            }
            char_md.p_user_desc_md = &char_md_user_desc_md;
        }
        else
        {
            char_md.p_user_desc_md = NULL;
        }

        // CCCD metadata.
        if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
        {
            RPC_DECODER_LENGTH_CHECK(command_len,
                                     (index + sizeof(ble_gatts_attr_md_t)),
                                     SD_BLE_GATTS_CHARACTERISTIC_ADD);

            err_code = attr_md_decode(&p_command[index], &char_md_cccd_md, &index);
            if (err_code != NRF_SUCCESS)
            {
                return ble_rpc_cmd_resp_send(SD_BLE_GATTS_CHARACTERISTIC_ADD, err_code);
            }
            char_md.p_cccd_md = &char_md_cccd_md;
        }
        else
        {
            char_md.p_cccd_md = NULL;
        }

        // SCCD metadata.
        if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
        {
            RPC_DECODER_LENGTH_CHECK(command_len,
                                     (index + sizeof(ble_gatts_attr_md_t)),
                                     SD_BLE_GATTS_CHARACTERISTIC_ADD);
            err_code = attr_md_decode(&p_command[index], &char_md_sccd_md, &index);
            if (err_code != NRF_SUCCESS)
            {
                return ble_rpc_cmd_resp_send(SD_BLE_GATTS_CHARACTERISTIC_ADD, err_code);
            }
            char_md.p_sccd_md = &char_md_sccd_md;
        }
        else
        {
            char_md.p_sccd_md = NULL;
        }

        p_char_md = &char_md;
    }
    else
    {
        p_char_md = NULL;
    }

    RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_CHARACTERISTIC_ADD);

    // Char attribute present.
    if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
    {
        // UUID present.
        if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
        {
            attr_char_value_uuid.uuid  = uint16_decode(&p_command[index]);
            index                     += sizeof(uint16_t);

            attr_char_value_uuid.type = p_command[index++];
            attr_char_value.p_uuid    = &attr_char_value_uuid;
        }
        else
        {
            attr_char_value.p_uuid = NULL;
        }
        RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_CHARACTERISTIC_ADD);
        // Attribute metadata present.
        if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
        {
            RPC_DECODER_LENGTH_CHECK(command_len,
                                     (index + sizeof(ble_gatts_attr_md_t)),
                                     SD_BLE_GATTS_CHARACTERISTIC_ADD);
            err_code = attr_md_decode(&p_command[index], &attr_char_value_attr_md, &index);
            if (err_code != NRF_SUCCESS)
            {
                return ble_rpc_cmd_resp_send(SD_BLE_GATTS_CHARACTERISTIC_ADD, err_code);
            }
            attr_char_value.p_attr_md = &attr_char_value_attr_md;
        }
        else
        {
            attr_char_value.p_attr_md = NULL;
        }

        attr_char_value.init_len   = uint16_decode(&p_command[index]);
        index                     += sizeof(uint16_t);
        attr_char_value.init_offs  = uint16_decode(&p_command[index]);
        index                     += sizeof(uint16_t);
        attr_char_value.max_len    = uint16_decode(&p_command[index]);
        index                     += sizeof(uint16_t);

        RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_CHARACTERISTIC_ADD);

        // Attribute data present
        if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
        {
            uint32_t data_index;
            RPC_DECODER_LENGTH_CHECK(command_len,
                                     (index + attr_char_value.init_len),
                                     SD_BLE_GATTS_CHARACTERISTIC_ADD);
            for (data_index = 0; data_index < attr_char_value.init_len; data_index++)
            {
                attr_data[data_index] = p_command[index++];
            }
            attr_char_value.p_value = attr_data;
        }
        else
        {
            attr_char_value.p_value = NULL;
        }
        RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_CHARACTERISTIC_ADD);
        p_attr_char_value = &attr_char_value;
    }
    else
    {
        p_attr_char_value = NULL;
    }

    if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
    {
        p_handles = &handles;
    }
    else
    {
        p_handles = NULL;
    }

    RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_CHARACTERISTIC_ADD);

    err_code = sd_ble_gatts_characteristic_add(service_handle,
                                               p_char_md,
                                               p_attr_char_value,
                                               p_handles);

    if (p_handles != NULL)
    {
        index = 0;
        uint8_t resp_data[sizeof(ble_gatts_char_handles_t)];

        index += uint16_encode(p_handles->value_handle, &resp_data[index]);
        index += uint16_encode(p_handles->user_desc_handle, &resp_data[index]);
        index += uint16_encode(p_handles->cccd_handle, &resp_data[index]);
        index += uint16_encode(p_handles->sccd_handle, &resp_data[index]);

        return ble_rpc_cmd_resp_data_send(SD_BLE_GATTS_CHARACTERISTIC_ADD,
                                          err_code,
                                          resp_data,
                                          sizeof(resp_data));
    }

    return ble_rpc_cmd_resp_send(SD_BLE_GATTS_CHARACTERISTIC_ADD, err_code);
}

uint32_t ble_rpc_cmd_gatts_decode(uint8_t * p_command, uint8_t op_code, uint32_t command_len)
{
    uint32_t err_code;

    switch (op_code)
    {
        case SD_BLE_GATTS_SERVICE_ADD:
            err_code = gatts_service_add_handle(p_command, command_len);
            break;

        case SD_BLE_GATTS_SYS_ATTR_GET:
            err_code = gatts_sys_attr_get_handle(p_command, command_len);
            break;

        case SD_BLE_GATTS_SYS_ATTR_SET:
            err_code = gatts_sys_attr_set_handle(p_command, command_len);
            break;

        case SD_BLE_GATTS_VALUE_SET:
            err_code = gatts_value_set_handle(p_command, command_len);
            break;

        case SD_BLE_GATTS_HVX:
            err_code = gatts_hvx_handle(p_command, command_len);
            break;

        case SD_BLE_GATTS_CHARACTERISTIC_ADD:
            err_code = gatts_characteristic_add_handle(p_command, command_len);
            break;

        default:
            err_code = ble_rpc_cmd_resp_send(op_code, NRF_ERROR_NOT_SUPPORTED);
            break;
    }

    return err_code;
}


text:
using System;
using System.Windows.Forms;

namespace NBTExplorer.Windows
{
    public partial class Find : Form
    {
        public Find ()
        {
            InitializeComponent();
        }

        public bool MatchName
        {
            get { return _cbName.Checked; }
        }

        public bool MatchValue
        {
            get { return _cbValue.Checked; }
        }

        public string NameToken
        {
            get { return _textName.Text; }
        }

        public string ValueToken
        {
            get { return _textValue.Text; }
        }

        private void _buttonFind_Click (object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Close();
        }

        private void _buttonCancel_Click (object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }

        private void _textName_TextChanged (object sender, EventArgs e)
        {
            _cbName.Checked = true;
        }

        private void _textValue_TextChanged (object sender, EventArgs e)
        {
            _cbValue.Checked = true;
        }
    }
}


text:
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';

import { MdSnackBar } from '@angular/material';

import { AuthService, UserService } from '../_services/';

import { LoaderService } from '../loader';

@Component({
  moduleId: module.id,
  templateUrl: 'login.component.html',
  styleUrls: ['login.component.css']
})
export class LoginComponent implements OnInit {

  public loginForm: FormGroup;

  public returnUrl: String;

  constructor(public authService: AuthService, public userService: UserService, public formBuilder: FormBuilder, public router: Router, private route: ActivatedRoute, public snackBar: MdSnackBar, public loaderService: LoaderService) {
    this.loginForm = formBuilder.group({
      email: ['', Validators.compose([Validators.email, Validators.required])],
      password: ['', Validators.required]
    });
  }

  ngOnInit() {
    this.authService.logout();

    // get return url from route parameters or default to '/'
    this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
  }

  login() {
    this.loaderService.show();
    this.authService.login(this.loginForm.value)
      .subscribe(
        () => {
          this.loaderService.hide();
          this.router.navigate(['/']);
        },
        error => {
          this.loaderService.hide();
          this.showError(error);
        }
      )
  }

  private showError(error: any) {
    var body = JSON.parse(error._body);
    var message = "Une erreur technique est survenue";

    if (body.message !== undefined) {
      message = body.message;
    }

    this.snackBar.open(message, 'Fermer', {
      duration: 3000,
    });
  }
}


text:
package com.easyapp.ble.model;

import android.bluetooth.BluetoothGattCharacteristic;
import android.os.Parcel;
import android.os.Parcelable;

import com.easyapp.ble.utils.ListUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * Created by dingjikerbo on 2016/9/5.
 */
public class BleGattProfile implements Parcelable {

    private List<BleGattService> services;

    public BleGattProfile(Map< UUID, Map<UUID, BluetoothGattCharacteristic >> map) {
        Iterator itor = map.entrySet().iterator();

        List<BleGattService> serviceList = new ArrayList<BleGattService>();

        while (itor.hasNext()) {
            Map.Entry entry = (Map.Entry) itor.next();
            UUID serviceUUID = (UUID) entry.getKey();
            Map<UUID, BluetoothGattCharacteristic> characters = (Map<UUID, BluetoothGattCharacteristic>) entry.getValue();

            BleGattService service = new BleGattService(serviceUUID, characters);
            if (!serviceList.contains(service)) {
                serviceList.add(service);
            }
        }

        addServices(serviceList);
    }

    public BleGattProfile(Parcel in) {
        in.readTypedList(getServices(), BleGattService.CREATOR);
    }

    public void addServices(List<BleGattService> services) {
        Collections.sort(services);
        getServices().addAll(services);
    }

    public List<BleGattService> getServices() {
        if (services == null) {
            services = new ArrayList<BleGattService>();
        }
        return services;
    }

    public BleGattService getService(UUID serviceId) {
        if (serviceId == null) {
            return null;
        }

        List<BleGattService> services = getServices();
        for (BleGattService service : services) {
            if (service.getUUID().equals(serviceId)) {
                return service;
            }
        }

        return null;
    }

    public boolean containsCharacter(UUID serviceId, UUID characterId) {
        if (serviceId == null || characterId == null) {
            return false;
        }

        BleGattService service = getService(serviceId);
        if (service != null) {
            List<BleGattCharacter> characters = service.getCharacters();
            if (!ListUtils.isEmpty(characters)) {
                for (BleGattCharacter character : characters) {
                    if (characterId.equals(character.getUuid())) {
                        return true;
                    }
                }
            }
        }

        return false;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeTypedList(getServices());
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<BleGattProfile> CREATOR = new Creator<BleGattProfile>() {
        @Override
        public BleGattProfile createFromParcel(Parcel in) {
            return new BleGattProfile(in);
        }

        @Override
        public BleGattProfile[] newArray(int size) {
            return new BleGattProfile[size];
        }
    };

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        for (BleGattService service : services) {
            sb.append(service).append("\n");
        }
        return sb.toString();
    }
}


text:
package fr.univ_tln.trailscommunity.utilities.network;

/**
 * Project TrailsCommunity.
 * Package fr.univ_tln.trailscommunity.utilities.network.
 * File RestApiKey.java.
 * Created by Ysee on 13/12/2016 - 18:07.
 * www.yseemonnier.com
 * https://github.com/YMonnier
 */

public class RestApiKey {
    public final static String DATA = "data";
    public final static String CHAT = "chat";
}


text:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Sandbox</title>
</head>
<body>
<script src="sandbox.js"></script>

</body>
</html>


text:
function [outx, outy] = hermite(params)

%Broadband excitation pulse based on Hermite polynomials.
numPoints = params.width;
timePts = linspace(-numPoints/2,numPoints/2,numPoints)';
switch params.rotAngle
    case pi/2
        A1 = -0.677;
    case pi
        A1 = -0.956;
    otherwise
        error('Unknown rotation angle for Hermite pulse.  Currently only handle pi/2 and pi.');
end
outx = params.amp*(1+A1*(timePts/params.sigma).^2).*exp(-((timePts/params.sigma).^2));
outy = zeros(numPoints,1);

end


text:
package ee.telekom.workflow.graph.node.gateway;

import org.junit.Test;

import ee.telekom.workflow.graph.AbstractGraphTest;
import ee.telekom.workflow.graph.GraphFactory;

public class _03_SynchronizationTest extends AbstractGraphTest{

    @Test
    public void one(){
        assertExecution( GraphFactory.INSTANCE.synchronzation_one(), "2" );
    }

    @Test
    public void two(){
        assertExecution( GraphFactory.INSTANCE.synchronzation_two(), "2,3" );
    }

    @Test
    public void three(){
        assertExecution( GraphFactory.INSTANCE.synchronzation_three(), "2,3,4" );
    }

    @Test
    public void two_firstBranchEmpty(){
        assertExecution( GraphFactory.INSTANCE.synchronzation_two_firstBranchEmpty(), "2" );
    }

    @Test
    public void two_secondBranchEmpty(){
        assertExecution( GraphFactory.INSTANCE.synchronzation_two_secondBranchEmpty(), "2" );
    }

    @Test
    public void two_bothBranchesEmpty(){
        assertExecution( GraphFactory.INSTANCE.synchronzation_two_bothBranchesEmpty(), null );
    }

    @Test
    public void two_pre_post(){
        assertExecution( GraphFactory.INSTANCE.synchronzation_two_pre_post(), "1,3,4,6" );
    }

    @Test
    public void firstBranchEmpty_pre_post(){
        assertExecution( GraphFactory.INSTANCE.synchronization_firstBranchEmpty_pre_post(), "1,3,6" );
    }

    @Test
    public void secondBranchEmpty_pre_post(){
        assertExecution( GraphFactory.INSTANCE.synchronization_secondBranchEmpty_pre_post(), "1,3,6" );
    }

}


text:
<?xml version="1.0" encoding="UTF-8"?>
<LearningStandards>
  <LearningStandardItem xml:lang="en" RefID="AF9F597CEE3047739BEEBCC2086BC0D1">
    <RefURI>http://corestandards.org/Math/Content/HSG/SRT/B/4/</RefURI>
    <StandardHierarchyLevel>
      <number>7</number>
      <description>Standard</description>
    </StandardHierarchyLevel>
    <StatementCodes>
      <StatementCode>CCSS.Math.Content.HSG-SRT.B.4</StatementCode>
    </StatementCodes>
    <Statements>
      <Statement>Prove theorems about triangles. <i>Theorems include: a line parallel to one side of a triangle divides the other two proportionally, and conversely; the Pythagorean Theorem proved using triangle similarity.</Statement>
    </Statements>
    <GradeLevels>
      <GradeLevel>09</GradeLevel>
      <GradeLevel>10</GradeLevel>
      <GradeLevel>11</GradeLevel>
      <GradeLevel>12</GradeLevel>
    </GradeLevels>
    <LearningStandardDocumentRefId>B62C1C106873438AA0126760075A65A3</LearningStandardDocumentRefId>
    <RelatedLearningStandardItems>
      <LearningStandardItemRefId RelationshipType="childOf">4F170A4349664CC59D6A26D6CBC822E7</LearningStandardItemRefId>
    </RelatedLearningStandardItems>
  </LearningStandardItem>
</LearningStandards>


text:
Create Record

			Continue
			Create
			Cancel


text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <android.support.v7.widget.CardView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="12dp"
        android:layout_marginBottom="20dp"
        >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:weightSum="2"
            android:padding="10dp">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="Candid Photography"
                android:textColor="#000"
                android:gravity="left"
                android:textSize="15dp"
                android:padding="5dp"
                android:layout_weight="2"
                />
            <ImageButton
                android:id="@+id/parent_list_item_expand_arrow"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@android:drawable/arrow_down_float" />

        </LinearLayout>
    </android.support.v7.widget.CardView>
</LinearLayout>


text:
import { jsdom } from 'jsdom'
import React, { Component } from 'react'
import Alt from '../'
import AltContainer from '../AltContainer'
import AltIso from '../utils/AltIso'
import * as Render from '../utils/Render'
import connectToStores from '../utils/connectToStores'
import { assert } from 'chai'

const { TestUtils } = React.addons

const alt = new Alt()

const UserActions = alt.generateActions('receivedUser', 'failed')

const UserSource = {
  fetchUser() {
    return {
      remote(state, id, name) {
        return new Promise((resolve, reject) => {
          setTimeout(() => resolve({ id, name }), 10)
        })
      },

      success: UserActions.receivedUser,
      error: UserActions.failed
    }
  }
}

class UserStore {
  static displayName = 'UserStore'

  constructor() {
    this.user = null

    this.exportAsync(UserSource)
    this.bindActions(UserActions)
  }

  receivedUser(user) {
    this.user = user
  }

  failed(e) {
    console.error('Failure', e)
  }
}

const userStore = alt.createStore(UserStore)

const NumberActions = alt.generateActions('receivedNumber', 'failed')

const NumberSource = {
  fetchNumber() {
    return {
      remote(state, id) {
        return new Promise((resolve, reject) => {
          setTimeout(() => resolve(id), 5)
        })
      },

      success: NumberActions.receivedNumber,
      error: NumberActions.failed
    }
  }
}

class NumberStore {
  static displayName = 'NumberStore'

  constructor() {
    this.n = []
    this.exportAsync(NumberSource)
    this.bindActions(NumberActions)
  }

  receivedNumber(n) {
    this.n = n
  }

  failed(e) {
    console.error('Fail', e)
  }
}

const numberStore = alt.createStore(NumberStore)

@AltIso.define((props) => {
  return Promise.all([
    userStore.fetchUser(props.id, props.name),
    numberStore.fetchNumber(props.id)
  ])
})
class User extends React.Component {
  render() {
    return (

        <AltContainer
          store={userStore}
          render={(props) => {
            return (

{props.user ? props.user.name : ''}

                {props.user ? props.user.id : 0}

            )
          }}
        />
        <AltContainer
          store={numberStore}
          render={(props) => {
            return {props.n}
          }}
        />

    )
  }
}

class App extends React.Component {
  render() {
    return <User id={this.props.id} name={this.props.name} />
  }
}

export default {
  'AltIso browser': {
    afterEach() {
      delete global.document
      delete global.window
    },

    'browser requests'(done) {
      AltIso.render(alt, App, { id: 0, name: 'Z' }).then((obj) => {
        global.document = jsdom(
          `<!doctype html><html><body>${obj.html}</body></html>`
        )
        global.window = global.document.defaultView
      }).then(() => {
        return AltIso.render(alt, App, { id: 0, name: 'Z' })
      }).then((data) => {
        assert(alt.stores.UserStore.getState().user.id === 0)
        assert(alt.stores.UserStore.getState().user.name === 'Z')
        assert.isUndefined(data)

        done()
      }).catch(e => done(e))
    },

    'works with connectToStores'(done) {
      global.document = jsdom('<!doctype html>')
      global.window = global.document.defaultView

      const alt = new Alt()

      const actions = alt.generateActions('success', 'fail')

      const DataSource = {
        bananas: {
          remote() {
            return Promise.resolve(2222222)
          },

          success: actions.success,
          error: actions.fail,
        }
      }

      const Store = alt.createStore(function () {
        this.id = 0
        this.registerAsync(DataSource)

        this.bindAction(actions.success, id => this.id = id)
        this.bindAction(actions.fail, err => console.log('STORE FETCH ERROR HANDLER', err))
      }, 'Store')

      const App = Render.withData((props) => {
        return Store.bananas()
      }, connectToStores(class extends Component {
        static getStores() {
          return [Store]
        }

        static getPropsFromStores() {
          return Store.getState()
        }

        render() {
          return
{this.props.id}

        }
      }))

      Render.toString(alt, App)
        .then((obj) => {
          assert.isString(obj.html)
          assert.match(obj.html, /2222222/)

          // if you try to render this element you'll have to bootstrap the
          // stores with the state yourself prior to rendering this element.
          assert.ok(React.isValidElement(obj.element))

          done()
        })
        .catch(e => done(e))
    },
  },
}


text:
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include <stdlib.h>

#include "hal-utils.h"
#include "hal-log.h"
#include "hal.h"
#include "hal-msg.h"
#include "ipc-common.h"
#include "hal-ipc.h"

static const btrc_callbacks_t *cbs = NULL;

static bool interface_ready(void)
{
	return cbs != NULL;
}

static void handle_remote_features(void *buf, uint16_t len, int fd)
{
	struct hal_ev_avrcp_remote_features *ev = buf;

	if (cbs->remote_features_cb)
		cbs->remote_features_cb((bt_bdaddr_t *) (ev->bdaddr),
								ev->features);
}

static void handle_get_play_status(void *buf, uint16_t len, int fd)
{
	if (cbs->get_play_status_cb)
		cbs->get_play_status_cb();
}

static void handle_list_player_attrs(void *buf, uint16_t len, int fd)
{
	if (cbs->list_player_app_attr_cb)
		cbs->list_player_app_attr_cb();
}

static void handle_list_player_values(void *buf, uint16_t len, int fd)
{
	struct hal_ev_avrcp_list_player_values *ev = buf;

	if (cbs->list_player_app_values_cb)
		cbs->list_player_app_values_cb(ev->attr);
}

static void handle_get_player_values(void *buf, uint16_t len, int fd)
{
	struct hal_ev_avrcp_get_player_values *ev = buf;
	btrc_player_attr_t attrs[4];
	int i;

	if (!cbs->get_player_app_value_cb)
		return;

	/* Convert uint8_t array to btrc_player_attr_t array */
	for (i = 0; i < ev->number; i++)
		attrs[i] = ev->attrs[i];

	cbs->get_player_app_value_cb(ev->number, attrs);
}

static void handle_get_player_attrs_text(void *buf, uint16_t len, int fd)
{
	struct hal_ev_avrcp_get_player_attrs_text *ev = buf;
	btrc_player_attr_t attrs[4];
	int i;

	if (!cbs->get_player_app_attrs_text_cb)
		return;

	/* Convert uint8_t array to btrc_player_attr_t array */
	for (i = 0; i < ev->number; i++)
		attrs[i] = ev->attrs[i];

	cbs->get_player_app_attrs_text_cb(ev->number, attrs);
}

static void handle_get_player_values_text(void *buf, uint16_t len, int fd)
{
	struct hal_ev_avrcp_get_player_values_text *ev = buf;

	if (cbs->get_player_app_values_text_cb)
		cbs->get_player_app_values_text_cb(ev->attr, ev->number,
								ev->values);
}

static void handle_set_player_value(void *buf, uint16_t len, int fd)
{
	struct hal_ev_avrcp_set_player_values *ev = buf;
	struct hal_avrcp_player_attr_value *attrs;
	btrc_player_settings_t values;
	int i;

	if (!cbs->set_player_app_value_cb)
		return;

	attrs = (struct hal_avrcp_player_attr_value *) ev->attrs;

	/* Convert to btrc_player_settings_t */
	values.num_attr = ev->number;
	for (i = 0; i < ev->number; i++) {
		values.attr_ids[i] = attrs[i].attr;
		values.attr_values[i] = attrs[i].value;
	}

	cbs->set_player_app_value_cb(&values);
}

static void handle_get_element_attrs(void *buf, uint16_t len, int fd)
{
	struct hal_ev_avrcp_get_element_attrs *ev = buf;
	btrc_media_attr_t attrs[BTRC_MAX_APP_SETTINGS];
	int i;

	if (!cbs->get_element_attr_cb)
		return;

	/* Convert uint8_t array to btrc_media_attr_t array */
	for (i = 0; i < ev->number; i++)
		attrs[i] = ev->attrs[i];

	cbs->get_element_attr_cb(ev->number, attrs);
}

static void handle_register_notification(void *buf, uint16_t len, int fd)
{
	struct hal_ev_avrcp_register_notification *ev = buf;

	if (cbs->register_notification_cb)
		cbs->register_notification_cb(ev->event, ev->param);
}

static void handle_volume_changed(void *buf, uint16_t len, int fd)
{
	struct hal_ev_avrcp_volume_changed *ev = buf;

	if (cbs->volume_change_cb)
		cbs->volume_change_cb(ev->volume, ev->type);
}

static void handle_passthrough_cmd(void *buf, uint16_t len, int fd)
{
	struct hal_ev_avrcp_passthrough_cmd *ev = buf;

	if (cbs->passthrough_cmd_cb)
		cbs->passthrough_cmd_cb(ev->id, ev->state);
}

/*
 * handlers will be called from notification thread context,
 * index in table equals to 'opcode - HAL_MINIMUM_EVENT'
 */
static const struct hal_ipc_handler ev_handlers[] = {
	/* HAL_EV_AVRCP_REMOTE_FEATURES */
	{ handle_remote_features, false,
			sizeof(struct hal_ev_avrcp_remote_features) },
	/* HAL_EV_AVRCP_GET_PLAY_STATUS */
	{ handle_get_play_status, false, 0 },
	/* HAL_EV_AVRCP_LIST_PLAYER_ATTRS */
	{ handle_list_player_attrs, false, 0 },
	/* HAL_EV_AVRCP_LIST_PLAYER_VALUES */
	{ handle_list_player_values, false,
			sizeof(struct hal_ev_avrcp_list_player_values) },
	/* HAL_EV_AVRCP_GET_PLAYER_VALUES */
	{ handle_get_player_values, true,
			sizeof(struct hal_ev_avrcp_get_player_values) },
	/* HAL_EV_AVRCP_GET_PLAYER_ATTRS_TEXT */
	{ handle_get_player_attrs_text, true,
			sizeof(struct hal_ev_avrcp_get_player_attrs_text) },
	/* HAL_EV_AVRCP_GET_PLAYER_VALUES_TEXT */
	{ handle_get_player_values_text, true,
			sizeof(struct hal_ev_avrcp_get_player_values_text) },
	/* HAL_EV_AVRCP_SET_PLAYER_VALUES */
	{ handle_set_player_value, true,
			sizeof(struct hal_ev_avrcp_set_player_values) },
	/* HAL_EV_AVRCP_GET_ELEMENT_ATTRS */
	{ handle_get_element_attrs, true,
			sizeof(struct hal_ev_avrcp_get_element_attrs) },
	/* HAL_EV_AVRCP_REGISTER_NOTIFICATION */
	{ handle_register_notification, false,
			sizeof(struct hal_ev_avrcp_register_notification) },
	/* HAL_EV_AVRCP_VOLUME_CHANGED */
	{ handle_volume_changed, false,
			sizeof(struct hal_ev_avrcp_volume_changed) },
	/* HAL_EV_AVRCP_PASSTHROUGH_CMD */
	{ handle_passthrough_cmd, false,
			sizeof(struct hal_ev_avrcp_passthrough_cmd) },
};

static bt_status_t init(btrc_callbacks_t *callbacks)
{
	struct hal_cmd_register_module cmd;
	int ret;

	DBG("");

	if (interface_ready())
		return BT_STATUS_DONE;

	cbs = callbacks;

	hal_ipc_register(HAL_SERVICE_ID_AVRCP, ev_handlers,
				sizeof(ev_handlers) / sizeof(ev_handlers[0]));

	cmd.service_id = HAL_SERVICE_ID_AVRCP;
	cmd.mode = HAL_MODE_DEFAULT;
	cmd.max_clients = 1;

	ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
					sizeof(cmd), &cmd, NULL, NULL, NULL);

	if (ret != BT_STATUS_SUCCESS) {
		cbs = NULL;
		hal_ipc_unregister(HAL_SERVICE_ID_AVRCP);
	}

	return ret;
}

static bt_status_t get_play_status_rsp(btrc_play_status_t status,
					uint32_t song_len, uint32_t song_pos)
{
	struct hal_cmd_avrcp_get_play_status cmd;

	DBG("");

	if (!interface_ready())
		return BT_STATUS_NOT_READY;

	cmd.status = status;
	cmd.duration = song_len;
	cmd.position = song_pos;

	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP, HAL_OP_AVRCP_GET_PLAY_STATUS,
					sizeof(cmd), &cmd, NULL, NULL, NULL);
}

static bt_status_t list_player_app_attr_rsp(int num_attr,
						btrc_player_attr_t *p_attrs)
{
	char buf[IPC_MTU];
	struct hal_cmd_avrcp_list_player_attrs *cmd = (void *) buf;
	size_t len;

	DBG("");

	if (!interface_ready())
		return BT_STATUS_NOT_READY;

	if (num_attr < 0)
		return BT_STATUS_PARM_INVALID;

	len = sizeof(*cmd) + num_attr;
	if (len > IPC_MTU)
		return BT_STATUS_PARM_INVALID;

	cmd->number = num_attr;
	memcpy(cmd->attrs, p_attrs, num_attr);

	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
					HAL_OP_AVRCP_LIST_PLAYER_ATTRS,
					len, cmd, NULL, NULL, NULL);
}

static bt_status_t list_player_app_value_rsp(int num_val, uint8_t *p_vals)
{
	char buf[IPC_MTU];
	struct hal_cmd_avrcp_list_player_values *cmd = (void *) buf;
	size_t len;

	DBG("");

	if (!interface_ready())
		return BT_STATUS_NOT_READY;

	if (num_val < 0)
		return BT_STATUS_PARM_INVALID;

	len = sizeof(*cmd) + num_val;

	if (len > IPC_MTU)
		return BT_STATUS_PARM_INVALID;

	cmd->number = num_val;
	memcpy(cmd->values, p_vals, num_val);

	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
					HAL_OP_AVRCP_LIST_PLAYER_VALUES,
					len, cmd, NULL, NULL, NULL);
}

static bt_status_t get_player_app_value_rsp(btrc_player_settings_t *p_vals)
{
	char buf[IPC_MTU];
	struct hal_cmd_avrcp_get_player_attrs *cmd = (void *) buf;
	size_t len, attrs_len;
	int i;

	DBG("");

	if (!interface_ready())
		return BT_STATUS_NOT_READY;

	if (!p_vals)
		return BT_STATUS_PARM_INVALID;

	attrs_len = p_vals->num_attr *
				sizeof(struct hal_avrcp_player_attr_value);
	len = sizeof(*cmd) + attrs_len;

	if (len > IPC_MTU)
		return BT_STATUS_PARM_INVALID;

	cmd->number = p_vals->num_attr;

	for (i = 0; i < p_vals->num_attr; i++) {
		cmd->attrs[i].attr = p_vals->attr_ids[i];
		cmd->attrs[i].value = p_vals->attr_values[i];
	}

	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
					HAL_OP_AVRCP_GET_PLAYER_ATTRS,
					len, cmd, NULL, NULL, NULL);
}

static int write_text(uint8_t *ptr, uint8_t id, uint8_t *text, size_t *len)
{
	struct hal_avrcp_player_setting_text *value = (void *) ptr;
	size_t attr_len = sizeof(*value);

	if (attr_len + *len > IPC_MTU)
		return 0;

	value->id = id;
	value->len = strnlen((const char *) text, BTRC_MAX_ATTR_STR_LEN);

	*len += attr_len;

	if (value->len + *len > IPC_MTU)
		value->len = IPC_MTU - *len;

	memcpy(value->text, text, value->len);

	*len += value->len;

	return attr_len + value->len;
}

static uint8_t write_player_setting_text(uint8_t *ptr, uint8_t num_attr,
					btrc_player_setting_text_t *p_attrs,
					size_t *len)
{
	int i;

	for (i = 0; i < num_attr && *len < IPC_MTU; i++) {
		int ret;

		ret = write_text(ptr, p_attrs[i].id, p_attrs[i].text, len);
		if (ret == 0)
			break;

		ptr += ret;
	}

	return i;
}

static bt_status_t get_player_app_attr_text_rsp(int num_attr,
					btrc_player_setting_text_t *p_attrs)
{
	char buf[IPC_MTU];
	struct hal_cmd_avrcp_get_player_attrs_text *cmd = (void *) buf;
	uint8_t *ptr;
	size_t len;

	DBG("");

	if (!interface_ready())
		return BT_STATUS_NOT_READY;

	if (num_attr < 0 || num_attr > BTRC_MAX_APP_SETTINGS)
		return BT_STATUS_PARM_INVALID;

	len = sizeof(*cmd);
	ptr = (uint8_t *) &cmd->attrs[0];
	cmd->number = write_player_setting_text(ptr, num_attr, p_attrs, &len);

	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
					HAL_OP_AVRCP_GET_PLAYER_ATTRS_TEXT,
					len, cmd, NULL, NULL, NULL);
}

static bt_status_t get_player_app_value_text_rsp(int num_val,
					btrc_player_setting_text_t *p_vals)
{
	char buf[IPC_MTU];
	struct hal_cmd_avrcp_get_player_values_text *cmd = (void *) buf;
	uint8_t *ptr;
	size_t len;

	DBG("");

	if (!interface_ready())
		return BT_STATUS_NOT_READY;

	if (num_val < 0)
		return BT_STATUS_PARM_INVALID;

	len = sizeof(*cmd);
	ptr = (uint8_t *) &cmd->values[0];
	cmd->number = write_player_setting_text(ptr, num_val, p_vals, &len);

	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
					HAL_OP_AVRCP_GET_PLAYER_VALUES_TEXT,
					len, cmd, NULL, NULL, NULL);
}

static uint8_t write_element_attr_text(uint8_t *ptr, uint8_t num_attr,
					btrc_element_attr_val_t *p_attrs,
					size_t *len)
{
	int i;

	for (i = 0; i < num_attr && *len < IPC_MTU; i++) {
		int ret;

		ret = write_text(ptr, p_attrs[i].attr_id, p_attrs[i].text, len);
		if (ret == 0)
			break;

		ptr += ret;
	}

	return i;
}

static bt_status_t get_element_attr_rsp(uint8_t num_attr,
					btrc_element_attr_val_t *p_attrs)
{
	char buf[IPC_MTU];
	struct hal_cmd_avrcp_get_element_attrs_text *cmd = (void *) buf;
	size_t len;
	uint8_t *ptr;

	DBG("");

	if (!interface_ready())
		return BT_STATUS_NOT_READY;

	len = sizeof(*cmd);
	ptr = (uint8_t *) &cmd->values[0];
	cmd->number = write_element_attr_text(ptr, num_attr, p_attrs, &len);

	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
					HAL_OP_AVRCP_GET_ELEMENT_ATTRS_TEXT,
					len, cmd, NULL, NULL, NULL);
}

static bt_status_t set_player_app_value_rsp(btrc_status_t rsp_status)
{
	struct hal_cmd_avrcp_set_player_attrs_value cmd;

	DBG("");

	if (!interface_ready())
		return BT_STATUS_NOT_READY;

	cmd.status = rsp_status;

	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
					HAL_OP_AVRCP_SET_PLAYER_ATTRS_VALUE,
					sizeof(cmd), &cmd, NULL, NULL, NULL);
}

static bt_status_t play_status_changed_rsp(btrc_notification_type_t type,
						btrc_play_status_t *play_status)
{
	char buf[IPC_MTU];
	struct hal_cmd_avrcp_register_notification *cmd = (void *) buf;
	size_t len;

	cmd->event = BTRC_EVT_PLAY_STATUS_CHANGED;
	cmd->type = type;
	cmd->len = 1;
	memcpy(cmd->data, play_status, cmd->len);

	len = sizeof(*cmd) + cmd->len;

	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
					HAL_OP_AVRCP_REGISTER_NOTIFICATION,
					len, cmd, NULL, NULL, NULL);
}

static bt_status_t track_change_rsp(btrc_notification_type_t type,
							btrc_uid_t *track)
{
	char buf[IPC_MTU];
	struct hal_cmd_avrcp_register_notification *cmd = (void *) buf;
	size_t len;

	cmd->event = BTRC_EVT_TRACK_CHANGE;
	cmd->type = type;
	cmd->len = sizeof(*track);
	memcpy(cmd->data, track, cmd->len);

	len = sizeof(*cmd) + cmd->len;

	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
					HAL_OP_AVRCP_REGISTER_NOTIFICATION,
					len, cmd, NULL, NULL, NULL);
}

static bt_status_t track_reached_end_rsp(btrc_notification_type_t type)
{
	struct hal_cmd_avrcp_register_notification cmd;

	cmd.event = BTRC_EVT_TRACK_REACHED_END;
	cmd.type = type;
	cmd.len = 0;

	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
					HAL_OP_AVRCP_REGISTER_NOTIFICATION,
					sizeof(cmd), &cmd, NULL, NULL, NULL);
}

static bt_status_t track_reached_start_rsp(btrc_notification_type_t type)
{
	struct hal_cmd_avrcp_register_notification cmd;

	cmd.event = BTRC_EVT_TRACK_REACHED_START;
	cmd.type = type;
	cmd.len = 0;

	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
					HAL_OP_AVRCP_REGISTER_NOTIFICATION,
					sizeof(cmd), &cmd, NULL, NULL, NULL);
}

static bt_status_t play_pos_changed_rsp(btrc_notification_type_t type,
							uint32_t *song_pos)
{
	char buf[IPC_MTU];
	struct hal_cmd_avrcp_register_notification *cmd = (void *) buf;
	size_t len;

	cmd->event = BTRC_EVT_PLAY_POS_CHANGED;
	cmd->type = type;
	cmd->len = sizeof(*song_pos);
	memcpy(cmd->data, song_pos, cmd->len);

	len = sizeof(*cmd) + cmd->len;

	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
					HAL_OP_AVRCP_REGISTER_NOTIFICATION,
					len, cmd, NULL, NULL, NULL);
}

static bt_status_t settings_changed_rsp(btrc_notification_type_t type,
					btrc_player_settings_t *player_setting)
{
	char buf[IPC_MTU];
	struct hal_cmd_avrcp_register_notification *cmd = (void *) buf;
	struct hal_avrcp_player_attr_value *attrs;
	size_t len, param_len;
	int i;

	param_len = player_setting->num_attr * sizeof(*attrs);
	len = sizeof(*cmd) + param_len;

	if (len > IPC_MTU)
		return BT_STATUS_PARM_INVALID;

	cmd->event = BTRC_EVT_APP_SETTINGS_CHANGED;
	cmd->type = type;
	cmd->len = param_len;

	attrs = (struct hal_avrcp_player_attr_value *) &cmd->data[0];
	for (i = 0; i < player_setting->num_attr; i++) {
		attrs[i].attr = player_setting->attr_ids[i];
		attrs[i].value = player_setting->attr_values[i];
	}

	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP,
					HAL_OP_AVRCP_REGISTER_NOTIFICATION,
					len, cmd, NULL, NULL, NULL);
}

static bt_status_t register_notification_rsp(btrc_event_id_t event_id,
					btrc_notification_type_t type,
					btrc_register_notification_t *p_param)
{
	DBG("");

	if (!interface_ready())
		return BT_STATUS_NOT_READY;

	switch (event_id) {
	case BTRC_EVT_PLAY_STATUS_CHANGED:
		return play_status_changed_rsp(type, &p_param->play_status);
	case BTRC_EVT_TRACK_CHANGE:
		return track_change_rsp(type, &p_param->track);
	case BTRC_EVT_TRACK_REACHED_END:
		return track_reached_end_rsp(type);
	case BTRC_EVT_TRACK_REACHED_START:
		return track_reached_start_rsp(type);
	case BTRC_EVT_PLAY_POS_CHANGED:
		return play_pos_changed_rsp(type, &p_param->song_pos);
	case BTRC_EVT_APP_SETTINGS_CHANGED:
		return settings_changed_rsp(type, &p_param->player_setting);
	default:
		return BT_STATUS_PARM_INVALID;
	}
}

static bt_status_t set_volume(uint8_t volume)
{
	struct hal_cmd_avrcp_set_volume cmd;

	DBG("");

	if (!interface_ready())
		return BT_STATUS_NOT_READY;

	cmd.value = volume;

	return hal_ipc_cmd(HAL_SERVICE_ID_AVRCP, HAL_OP_AVRCP_SET_VOLUME,
					sizeof(cmd), &cmd, NULL, NULL, NULL);
}

static void cleanup(void)
{
	struct hal_cmd_unregister_module cmd;

	DBG("");

	if (!interface_ready())
		return;

	cmd.service_id = HAL_SERVICE_ID_AVRCP;

	hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_UNREGISTER_MODULE,
					sizeof(cmd), &cmd, NULL, NULL, NULL);

	hal_ipc_unregister(HAL_SERVICE_ID_AVRCP);

	cbs = NULL;
}

static btrc_interface_t iface = {
	.size = sizeof(iface),
	.init = init,
	.get_play_status_rsp = get_play_status_rsp,
	.list_player_app_attr_rsp = list_player_app_attr_rsp,
	.list_player_app_value_rsp = list_player_app_value_rsp,
	.get_player_app_value_rsp = get_player_app_value_rsp,
	.get_player_app_attr_text_rsp = get_player_app_attr_text_rsp,
	.get_player_app_value_text_rsp = get_player_app_value_text_rsp,
	.get_element_attr_rsp = get_element_attr_rsp,
	.set_player_app_value_rsp = set_player_app_value_rsp,
	.register_notification_rsp = register_notification_rsp,
	.set_volume = set_volume,
	.cleanup = cleanup
};

btrc_interface_t *bt_get_avrcp_interface(void)
{
	return &iface;
}


text:
package com.intellij.openapi.project;

import com.intellij.openapi.util.Computable;
import org.jetbrains.annotations.Nullable;

import java.io.PrintStream;
import java.io.PrintWriter;

/**
 * Thrown on accessing indices when they're not ready, in so-called dumb mode. Possible fixes:
 * <ul>
 * <li> If {@link com.intellij.openapi.actionSystem.AnAction#actionPerformed(com.intellij.openapi.actionSystem.AnActionEvent)} is in stack trace,
 * consider making the action not implement {@link DumbAware}.
 *
 * <li> A {@link DumbAware} action, having got this exception, may just notify the user that the requested activity is not possible while
 * indexing is in progress. It can be done via a dialog (see {@link com.intellij.openapi.ui.Messages}) or a status bar balloon
 * (see {@link DumbService#showDumbModeNotification(String)}, {@link com.intellij.openapi.actionSystem.ex.ActionUtil#showDumbModeWarning(com.intellij.openapi.actionSystem.AnActionEvent...)}).
 *
 * <li> If index access is performed from some non-urgent invokeLater activity, consider replacing it with
 * {@link DumbService#smartInvokeLater(Runnable)}. Note that this 'later' can be very late, several minutes may pass. So if that code
 * involves user interaction, {@link DumbService#smartInvokeLater(Runnable)} should probably not be used to avoid dialogs popping out of the blue.
 *
 * <li> If it's a non-urgent background process (e.g. compilation, usage search), consider replacing topmost read-action with
 * {@link DumbService#runReadActionInSmartMode(Computable)}.
 *
 * <li> If the exception comes from within Java's findClass call, and the IDE is currently performing a user-initiated action or a
 * task when skipping findClass would lead to very negative consequences (e.g. not stopping at a breakpoint), then it might be possible
 * to avoid index query by using alternative resolve (and findClass) strategy, which is significantly slower and might return null. To do this,
 * use {@link DumbService#setAlternativeResolveEnabled(boolean)}.
 *
 * <li> It's preferable to avoid the exception entirely by adding {@link DumbService#isDumb()} checks where necessary.
 * </ul>
 *
 * @author peter
 * @see DumbService
 * @see DumbAware
 */
public class IndexNotReadyException extends RuntimeException {
  @Nullable private final Throwable myStartTrace;

  public IndexNotReadyException() {
    this(null);
  }

  public IndexNotReadyException(@Nullable Throwable startTrace) {
    super("Please change caller according to " + IndexNotReadyException.class.getName() + " documentation");
    myStartTrace = startTrace;
  }

  @Override
  public void printStackTrace(PrintStream s) {
    super.printStackTrace(s);
    if (myStartTrace != null) {
      s.println();
      s.println("-----------");
      s.println("Indexing started at:");
      myStartTrace.printStackTrace(s);
    }
  }

  @Override
  public void printStackTrace(PrintWriter s) {
    super.printStackTrace(s);
    if (myStartTrace != null) {
      s.println();
      s.println("-----------");
      s.println("Indexing started at:");
      myStartTrace.printStackTrace(s);
    }
  }
}


text:
import * as compEvents from "./lib/comp-events";
import setDom from "set-dom";
import clone from "clone";
import html from "./lib/html-template";
import { renderAfterPromise, renderAfterGenerator } from "./lib/render-after-async";
import { findChildComponents } from "./lib/render-children";

const components = {};

function componentize(name, actions, render, model) {
    render(model);
    let component = {};
    Object.keys(actions).map((action) => {
        component[action] = (...args) => {

            let returnValue = actions[action].apply(actions, args);

            if (returnValue && returnValue.then) {
                renderAfterPromise(returnValue, render);
            }

            if (returnValue && typeof returnValue === "function" && returnValue().next) {
                renderAfterGenerator(returnValue(), render);
            }
            render(model);
        }
    }, this);
    component.name = name;
    component.get = (prop) => model[prop];
    component.render = () => render(model);
    return component;
}

function create(name, actions, view, model) {
    if (name == null || name === "") {
        throw new Error("Your component needs a name");
    }

    if (actions == null) {
        const example = "// It must be a function that takes a model and returns an object of functions, e.g.\r\n\r\nYourComponent.Actions = function (model) {\r\n    return {\r\n        sayHello: function () { console.log('Hi.'); },\r\n        greet: function (name) { console.log('Hello, ' + name); }\r\n    }\r\n}";
        throw new Error(`${name} needs some actions! Here's an example of an Actions function:\r\n\r\n${example}\r\n\r\n`);
    }

    model = clone(model);
    let _view = view && view();
    let viewInit = _view && _view.init ? _view.init : () => {};
    let viewRender = _view && _view.render
        ? (_model) => {
            const htmlString = _view.render(_model, html);
            if (typeof document !== "undefined" && htmlString) {
                let target = document.querySelector(`[data-component=${name}]`);
                if (target) {
                    if (target.innerHTML === "") {
                        target.innerHTML = htmlString;
                    } else {
                        setDom(target.firstElementChild, htmlString);
                    }
                    const childComponents = findChildComponents(target);
                    if (childComponents.length) {
                        childComponents.map(x => components[x] && components[x].render());
                    }
                }
            }
        }
        : () => {};

    let component = componentize(name, actions(model), viewRender, model);
    components[name] = component;

    viewInit(component, model);

    return component;
}

if (typeof document !== "undefined" && typeof compEvents !== "undefined") {
    document.addEventListener("DOMContentLoaded", function () {
        compEvents.registerEventDelegator(components);
    });
}

export default {
    components: components,
    create: create
};


text:
require 'rubygems'
require 'test/unit'
require 'unicode'

require "lib/simhash"
require "lib/string"
require "lib/integer"
begin
  require "string_hashing"
rescue LoadError
  nil
end


text:
package org.springframework.cloud.netflix.eureka.reactive;

import com.netflix.discovery.EurekaClient;
import com.netflix.discovery.EurekaClientConfig;

import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.ConditionalOnDiscoveryEnabled;
import org.springframework.cloud.client.ConditionalOnDiscoveryHealthIndicatorEnabled;
import org.springframework.cloud.client.ConditionalOnReactiveDiscoveryEnabled;
import org.springframework.cloud.client.ReactiveCommonsClientAutoConfiguration;
import org.springframework.cloud.client.discovery.composite.reactive.ReactiveCompositeDiscoveryClientAutoConfiguration;
import org.springframework.cloud.client.discovery.health.DiscoveryClientHealthIndicatorProperties;
import org.springframework.cloud.client.discovery.health.reactive.ReactiveDiscoveryClientHealthIndicator;
import org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Configuration related to service discovery when using Netflix Eureka.
 *
 * @author Tim Ysewyn
 */
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(EurekaClientConfig.class)
@ConditionalOnDiscoveryEnabled
@ConditionalOnReactiveDiscoveryEnabled
@ConditionalOnProperty(value = "eureka.client.enabled", matchIfMissing = true)
@EnableConfigurationProperties
@AutoConfigureAfter({ EurekaClientAutoConfiguration.class, ReactiveCompositeDiscoveryClientAutoConfiguration.class })
@AutoConfigureBefore(ReactiveCommonsClientAutoConfiguration.class)
@ImportAutoConfiguration(EurekaClientAutoConfiguration.class)
public class EurekaReactiveDiscoveryClientConfiguration {

	@Bean
	@ConditionalOnMissingBean
	public EurekaReactiveDiscoveryClient eurekaReactiveDiscoveryClient(EurekaClient client,
			EurekaClientConfig clientConfig) {
		return new EurekaReactiveDiscoveryClient(client, clientConfig);
	}

	@Bean
	@ConditionalOnClass(name = "org.springframework.boot.actuate.health.ReactiveHealthIndicator")
	@ConditionalOnDiscoveryHealthIndicatorEnabled
	public ReactiveDiscoveryClientHealthIndicator eurekaReactiveDiscoveryClientHealthIndicator(
			EurekaReactiveDiscoveryClient client, DiscoveryClientHealthIndicatorProperties properties) {
		return new ReactiveDiscoveryClientHealthIndicator(client, properties);
	}

}


text:
Ti=Privacy Policy

0.0.sec=Last Updated: January 22, 2014

0.1.sec=The OpenGov Foundation (OpenGov), lead developers of Madison, is committed to protecting the privacy of visitors to our websites, as well as our support team and citizen-users. OpenGov has established this Privacy Policy to explain what information we collect through our websites and how it is used.

0.2.sec=In this policy, "OpenGov" refers to OpenGov staff, board members, cooperating attorneys, interns, volunteers, and consultants, all of whom are bound by law or contract to keep confidential information they receive as part of their assistance to OpenGov.

0.3.sec=OpenGov does not sell or rent member, donor or website visitor information under any circumstances, and we do not share member, donor or visitor information without prior consent except as compelled by law. (See discussion below.)

0.=[Z/paras/s3]

1.Ti=Information Gathered

1.1.Ti=Logging

1.1.0.sec=For visitors to our main website www.OpenGovFoundation.org and to Madison, we generally log requests. Circumstances in which OpenGov may need to log and retain technical information for longer than seven days include when we believe it is reasonably necessary for OpenGov's mission and functionality, including situations such as:

1.1.1.sec=site testing

1.1.2.sec=diagnosis of technical problems

1.1.3.sec=defending against attacks to the site

1.1.4.sec=handling a spike in traffic or other abnormal, short-term circumstances, or

1.1.5.sec=research projects ( in anonymized form ) that serve our overall mission.

1.1.00.sec=In those and similar situations we will delete the information as soon as it is apparent that the information is no longer needed for the purpose for which it was retained. For more information on data logging and techniques OpenGov intends to use to anonymize, obfuscate, aggregate and delete information, see The Electronic Frontier Foundation's (EFF) Best Practices for Online Service Providers.

1.1.=[Z/ol-bullet/s5]

1.2.Ti=Cookies

1.2.sec=We use persistent ID cookies on this site for account sessions and to ensure that visitors do not receive notifications - such as first-visit sign-up lightboxes - more than intended. We use session cookies on certain portions of the website. Session cookies expire when you close your browser. You can use Tor if you wish to keep your connection information anonymous.

1.3.Ti=Voluntarily Submitted Information

1.3.1.sec=In addition, OpenGov collects and retains information you voluntarily submit to us. It is up to you whether to submit information to us, and how much information to provide. If you choose to support OpenGov or otherwise donate to OpenGov, we ask for your name, email address, mailing address and phone number. For those supporters, we also could ask for your credit card number. We also maintain records of our members' use of Madison or similar websites running the free, open source software Project Madison code and those currently under development. The project repositories and open source software code are viewable at www.github.com/opengovfoundation.

1.3.2.sec=We may ask for additional personal information when you provide feedback or comments, or otherwise communicate with us. We are pleased to receive anonymous donations in the mail (P.O. 3672, Washington, DC 20027), but please note that your personal information is required if you choose to donate using an online form.

1.3.3.sec=From time to time, we may ask for personal information on other portions of the site, such as asking you to sign a petition, participate in a contest, or provide prior art for an open government or software development initiative.

1.3.=[Z/paras/s3]

1.4.Ti=OpenGov Updates and other Mailing Lists

1.4.sec=If you choose to subscribe to receive Madison or OpenGov updates, or any of our other mailing lists, we collect your name, email address, and, if you choose to provide it, a zip or postal code.

1.=[Z/ol/s4]

2.Ti=OpenGov's Use of Information

2.0.sec=In general, OpenGov uses the information provided by you to further its mission, including to protect privacy, to open government at all levels, to defend freedom and innovation, and to protect your rights in the digital world.

2.1.Ti=Supporter Information

2.1.sec=We use OpenGov supporter information to process and manage your support or contribution. If you opt in, we will use your email address to send you updates and alerts on protecting your rights in the digital world, so you may contributed your talents and knowledge to a project, take action - such as contacting a friend, your elected representatives or attending an event.

2.2.Ti-Invitees to OpenGov

2.2.sec=If you invite another person to support OpenGov or contributed time, knowledge, talent or resources, we will ask for that person's name and online contact information. We use this information to contact and, if necessary, remind that person that he or she has been invited to get involved with OpenGov.

2.3.Ti=Publication by OpenGov

2.3.sec=If you provide information for publication we may use your name and contact information you have provided to us to provide you with attribution.

2.4.Ti=Other activities

2.4.sec=We may run surveys, contests, or similar activities through this site. Such information will be used for the purposes for which it was collected. We also look at technical information to diagnose problems with or consider improvements to our servers or related technologies and to administer OpenGovFoundation.org and other websites we host or provide.

2.5.Ti=Third-Party Service Providers to OpenGov

2.5.1.sec=Portions of OpenGov sites may be operated by a third-party service provider or providers. These service providers may place session cookies on your computer. OpenGov's service providers may also log standard technical information, such as the numerical Internet Protocol (IP) address of the computer you are using; the browser software you use and your operating system; the date and time you access our site; and the Internet address of the website from which you linked directly to our site. Our service providers may also store and organize the personal information collected through this site on our behalf.

2.5.2.sec=OpenGov also may use a third-party credit card processor and hosting providers. For all of OpenGov's service providers, hosting providers and credit card processors and any other providers we may use in the future, the information collected from OpenGov supporters remains under our control, and our agreement with each will require the information to be kept confidential and disclosed only to employees who require such access in the course of their assigned duties. OpenGov also requires all of our third-party service providers to notify OpenGov if they receive legal process seeking information about visitors to OpenGov's website or users of OpenGov products, software or services.

2.5.3.sec=OpenGov may change the specific third-party providers from time to time, and will transfer stored information to any new provider subject to similar restrictions and agreements. From time to time, OpenGov may work with third-party consultants or other service providers who may have access to personally identifiable information. In such cases, we will restrict their use of personally identifiable information in accordance with their assigned tasks.

2.5.4.sec=OpenGov's websites may also provide links to a wide variety of third-party websites, including interactive links to sites like Twitter or mapping services. OpenGov is not responsible for, and does not have any control over, the privacy practices or the content of such third parties. We encourage users to read the privacy policies of any website visited via links from OpenGov's websites.

2.5.5.sec=We do occasionally allow our website to interact with other services, like social networking, mapping, and video hosting websites. It is our policy not to include third-party resources when users initially load our web pages, but we may dynamically include them later after giving the user a chance to opt-in. If you believe a third-party resource is automatically loading, please let us know so we can address it.

2.5.=[Z/ol/s5]

2.=[Z/ol/5]

3.Ti=Disclosure of Your Information

3.1.sec=While OpenGov endeavors to provide the highest level of protection for your information, we may disclose personally identifiable information about you to third parties in limited circumstances, including: (1) with your consent; or (2) when we have a good faith belief it is required by law, such as pursuant to a subpoena or other judicial or administrative order.

3.2.sec=If we are required by law to disclose the information that you have submitted, we will attempt to provide you with notice (unless we are prohibited) that a request for your information has been made in order to give you an opportunity to object to the disclosure. We will attempt to provide this notice by email, if you have given us an email address, or by postal mail if you have entered a postal address. If you do not challenge the disclosure request, we may be legally required to turn over your information. In addition, we will independently object to requests for access to information about users of our site that we believe to be improper.

3.=[Z/ol/s2]

4.Ti=Updating or Removing Your Information

4.sec=You may choose to correct, update, or delete information you have submitted to us by sending an email requesting changes to sayhello@opengovfoundation.org. Furthermore, if we inadvertently collect more personal information than intended, we endeavor to delete the extraneous information. However, please understand that deleted information may continue to persist on backup media.

5.Ti=Changes to Our Policies

5.sec=OpenGov's Privacy Policy may change from time to time. However, any revised privacy policy will be consistent with OpenGov's mission. If we make any substantive changes to our policies, we will post notice of changes on this page and include them in our subsequent update email to Madison users and other OpenGov updates subscribers.

6.Ti=Security

6.1.sec=OpenGov employs industry standard security measures to protect the loss, misuse, and alteration of the information under our control.

6.2.sec=Although we make good faith efforts to store information collected by OpenGov in a secure operating environment, we cannot guarantee complete security. Information collected by OpenGov will be maintained for a length of time appropriate to our needs. However, we generally do not retain credit card information unless, when the option is available to supporters, you choose to have us make automatic monthly withdrawals from your account for your donation.

6.=[Z/ol/s2]

=[Z/ol/6]


text:
module Discordrb
  # This class is a special variant of User that represents the bot's user profile (things like own username and the avatar).
  # It can be accessed using {Bot#profile}.
  class Profile < User
    # Whether or not the user is the bot. The Profile can only ever be the bot user, so this always returns true.
    # @return [true]
    def current_bot?
      true
    end

    # Sets the bot's username.
    # @param username [String] The new username.
    def username=(username)
      update_profile_data(username: username)
    end

    alias_method :name=, :username=

    # Changes the bot's avatar.
    # @param avatar [String, #read] A JPG file to be used as the avatar, either
    #  something readable (e.g. File Object) or as a data URL.
    def avatar=(avatar)
      if avatar.respond_to? :read
        # Set the file to binary mode if supported, so we don't get problems with Windows
        avatar.binmode if avatar.respond_to?(:binmode)

        avatar_string = 'data:image/jpg;base64,'
        avatar_string += Base64.strict_encode64(avatar.read)
        update_profile_data(avatar: avatar_string)
      else
        update_profile_data(avatar: avatar)
      end
    end

    # Updates the cached profile data with the new one.
    # @note For internal use only.
    # @!visibility private
    def update_data(new_data)
      @username = new_data[:username] || @username
      @avatar_id = new_data[:avatar_id] || @avatar_id
    end

    # Sets the user status setting to Online.
    # @note Only usable on User accounts.
    def online
      update_profile_status_setting('online')
    end

    # Sets the user status setting to Idle.
    # @note Only usable on User accounts.
    def idle
      update_profile_status_setting('idle')
    end

    # Sets the user status setting to Do Not Disturb.
    # @note Only usable on User accounts.
    def dnd
      update_profile_status_setting('dnd')
    end

    alias_method(:busy, :dnd)

    # Sets the user status setting to Invisible.
    # @note Only usable on User accounts.
    def invisible
      update_profile_status_setting('invisible')
    end

    # The inspect method is overwritten to give more useful output
    def inspect
      "<Profile user=#{super}>"
    end

    private

    # Internal handler for updating the user's status setting
    def update_profile_status_setting(status)
      API::User.change_status_setting(@bot.token, status)
    end

    def update_profile_data(new_data)
      API::User.update_profile(@bot.token,
                               nil, nil,
                               new_data[:username] || @username,
                               new_data.key?(:avatar) ? new_data[:avatar] : @avatar_id)
      update_data(new_data)
    end
  end
end