text:
/**
 * @file
 *
 * Utilities for mocking memory IO access. These are main tools for simulating
 * hardware in tests.
 */

#pragma once

#include <iostream>
#include <cstdint>
#include <list>
#include <map>
#include <tuple>
#include <vector>

namespace mock {

class Memory;

/**
 * @brief Base class for more complex IO handlers.
 *
 * The default behavior is the same as not having the custom handler at all,
 * which makes this class by itself not very useful. The derived classes should
 * override at least one of read32(), write32() methods.
 *
 * The objects typically don't need their own value storage, because the values
 * written are still stored in Virtual Memory.
 *
 * FIXME: The API for accessing the global virtual memory is a little awkward at
 * the moment. If the implementation uses global virtual memory object, the user
 * needs to know that and they need to initialize mem_ value. This is not ideal.
 */
class IOHandlerStub {
    public:
        /**
         * @brief Handle write at 32 bit aligned virtual memory address.
         *
         * @param[in] addr Virtual memory address. 32 bit aligned.
         * @param[in] old_value Value currently stored at that address.
         * @param[in] new_value Value that is being written
         *
         * @return The new value that should be stored in the virtual memory at addr.
         */
        virtual uint32_t write32(uint32_t addr, uint32_t old_value, uint32_t new_value) {
            (void)addr;
            (void)old_value;
            return new_value;
        }

        /**
         * @brief Handle read from 32 bit aligned virtual memory address.
         *
         * @param[in]
         * @param[in] addr Virtual memory address. 32 bit aligned.
         *
         * @return The value that should be returned to the reader.
         */
        virtual uint32_t read32(uint32_t addr, uint32_t value) {
            (void)addr;
            return value;
        }

        /**
         * @brief Setter for the mem_ field.
         */
        void set_memory(Memory* mem) {
            mem_ = mem;
        }

    protected:
        /**
         * @brief Same as mem_->set_value_at(uint32_t, uint32_t)
         */
        void set_mem_value(uint32_t addr, uint32_t value);

        /**
         * @brief Same as mem_->get_value_at(uint32_t)
         */
        uint32_t get_mem_value(uint32_t addr) const;

    private:
        /**
         * @brief Pointer to global virtual memory object
         *
         * If the implementation wants to use set_mem_value() or get_mem_value()
         * methods, this should be initialized to point to global virtual memory
         * object.
         */
        Memory* mem_;
};

/**
 * @brief IO Handler for the register with separate "set" and "clear" registers.
 *
 * Implements set/clear/rw addresses for the same register.
 *
 * Writing to "set" address sets the bits in the register that are set in the
 * written value. All other bits are preserved.
 *
 * Writing to "clear" address clears the bits in the register that are *set* in
 * the written value. All other bits are preserved.
 *
 * The main address has usual Read/Write access. All addresses read as a current
 * value for the register.
 */
class RegSetClearStub : public IOHandlerStub {
    public:
        /**
         * @brief Constructor for the handler.
         *
         * @param addr Normal Read/Write access address.
         * @param set_addr Address for "set" access.
         * @param clr_addr Address for "clear" access.
         */
        RegSetClearStub(uint32_t addr, uint32_t set_addr, uint32_t clr_addr) :
            rw_addr_{addr}, set_addr_{set_addr}, clr_addr_{clr_addr} {}

        uint32_t write32(uint32_t addr, uint32_t old_value, uint32_t new_value) override {
            auto write_value = new_value;
            if (addr == set_addr_) {
                write_value = (old_value | new_value);
            } else if (addr == clr_addr_) {
                write_value = (old_value & (~new_value));
            }

            if (addr != rw_addr_) {
                set_mem_value(rw_addr_, write_value);
                set_mem_value(set_addr_, write_value);
                set_mem_value(clr_addr_, write_value);
            }
            return write_value;
        }

        uint32_t read32(uint32_t addr, uint32_t value) override {
            if (addr == set_addr_ || addr == clr_addr_) {
                return get_mem_value(rw_addr_);
            }

            return value;
        }

    protected:
        const uint32_t rw_addr_;
        const uint32_t set_addr_;
        const uint32_t clr_addr_;
};

/**
 * @brief Ignore writes to the handled virtual memory address.
 *
 * If this handler is assigned to a particular address, all writes
 * to that address will be ignored.
 */
class IgnoreWrites : public IOHandlerStub {
    public:
        uint32_t write32(uint32_t addr, uint32_t old_value, uint32_t new_value) override {
            (void)addr;
            (void)new_value;
            return old_value;
        }
};

/**
 * @brief Source reads from a list.
 *
 * Each subsequent read from the handled address will return a value
 * from the top of the list and pop that value.
 *
 * Useful for simulating incoming transmission of some sort for UART,
 * I2C etc. peripherals.
 */
class SourceIOHandler : public IOHandlerStub {
    public:
        uint32_t read32(uint32_t addr, uint32_t value) override {
            (void)addr;
            uint32_t ret = value;
            if (!read_seq_.empty()) {
                ret = *(read_seq_.begin());
                read_seq_.pop_front();
            }

            return ret;
        }

        /**
         * @brief Add value to the back of the read list
         */
        void add_value(uint32_t value) {
            read_seq_.push_back(value);
        }

        /**
         * @brief Get number of values in read sequence.
         */
        size_t get_seq_len() const {
            return read_seq_.size();
        }

    private:
        std::list<uint32_t> read_seq_;
};

/**
 * @brief Write values into a sink.
 *
 * Each subsequent write to the handled address will be stored in a vector,
 * after being cast to type T.
 *
 * This is useful for simulating outgoing transmission of some sort for UART,
 * I2C etc. peripherals.
 */
template <typename T>
class WriteSink : public IOHandlerStub {
    public:
        uint32_t write32(uint32_t addr, uint32_t old_value, uint32_t new_value) override {
            (void)addr;
            (void)old_value;

            sink_.push_back(static_cast<T>(new_value));
            return new_value;
        }

        /**
         * @brief Clear the sink. Removes all data from it.
         */
        void clear() {
            sink_.clear();
        }

        /**
         * @brief Get reference to the data in the sink.
         */
        const std::vector<T>& get_data() const {
            return sink_;
        }

    private:
        std::vector<T> sink_;
};

/**
 * @brief Write One To Clear Handler.
 *
 * Instead of writing the specified value to the register,
 * this handler will clear the bits set in written value, i.e.
 * if the bit is set in the written value, it will be cleared
 * in the value stored at specified address.
 */
class W1CStub : public IOHandlerStub {
    public:
        uint32_t write32(uint32_t addr, uint32_t old_value, uint32_t new_value) override {
            (void)addr;

            return old_value & (~new_value);
        }
};

/**
 * @brief Virtual Memory IO handler for tests.
 *
 * The tests should treat this class as a singleton and use mock::get_global_memory() function
 * to get an instance. Memory class' tests do not treat it as a singleton though, so
 * the rule is not strictly enforced.
 *
 * The methods of this class can be split into two groups: simulation and examination.
 * Simulations methods are the ones that simulate memory IO operations for the firmware.
 * These are readptr(), writeptr(), read32(), write32(), read16(), write16(), read8(), write8().
 *
 * The rest of the methods are used in tests to examine or to configure the state of the virtual
 * memory for testing purposes.
 *
 * The class allows further customization of address' handling. One can specify a handler
 * for a specific address or an address range and all IO operations will be forwarded to that
 * handler. This is the main simulation mechanizm.
 */
class Memory {
    public:
        Memory() = default;
        Memory(const Memory&) = delete;
        enum class Op {
            READ8,
            READ16,
            READ32,
            READPTR,
            WRITE8,
            WRITE16,
            WRITE32,
            WRITEPTR,
        };

        /**
         * @brief MemoryIO operations journal entry.
         *
         * This is a tuple of Op, memory address and value. For read operations
         * the value is what the operation has returned. For write operations
         * it is a new value.
         */
        using JournalEntry = std::tuple<Op, uint32_t, uint32_t>;

        /**
         * @brief List of memio operations.
         */
        using JournalT = std::vector<JournalEntry>;

        /**
         * @brief Get the journal for examination.
         *
         * There should not be any reason to modify the journal,
         * so this return a constant reference.
         */
        const JournalT& get_journal() const;

        /**
         * @brief Reset the Memory object.
         *
         * This clears the journal, all IO handlers and all of the virtual
         * memory contents. The test suite should call this before
         * performing any of the IO operations.
         */
        void reset();

        /**
         * @brief Read pointer from virtual memory address.
         *
         * Called by the simulation.
         *
         * This needs to be previously set by set_ptr_at() or writeptr(), otherwise
         * it would return nullptr.
         */
        void* readptr(uint32_t addr) const;

        /**
         * @brief Read 32 bit value from 32 bit aligned address.
         *
         * Called by the simulation.
         */
        uint32_t read32(uint32_t addr) const;

        /**
         * @brief Read 16 bit value from 16 bit aligned address.
         *
         * Called by the simulation.
         */
        uint16_t read16(uint32_t addr) const;

        /**
         * @brief Read 8 bit value from the address.
         *
         * Called by the simulation.
         */
        uint8_t read8(uint32_t addr) const;

        /**
         * @brief Store the pointer (the address it points to) at virtual memory address.
         *
         * Called by the simulation.
         *
         * Since simulated ARM MCU's are 32bit and most desktop OS (where the tests are run)
         * are 64 bit, storing and reading pointers needs special handling.
         */
        void writeptr(uint32_t addr, void* ptr);

        /**
         * @brief Store 32 bit value at 32 bit aligned virtual memory address.
         *
         * Called by the simulation.
         */
        void write32(uint32_t addr, uint32_t value);

        /**
         * @brief Store 16 bit value at 16 bit aligned virtual memory address.
         *
         * Called by the simulation.
         */
        void write16(uint32_t addr, uint16_t value);

        /**
         * @brief Store 8 bit value in virtual memory address.
         *
         * Called by the simulation.
         */
        void write8(uint32_t addr, uint8_t value);

        /**
         * @brief Store value at virtual memory address.
         *
         * The difference from write32() is that this method bypasses the journal
         * and if there are any IOHandlerStub objects registered for that address,
         * this also bypasses them.
         *
         * This meant to be used by tests.
         */
        void set_value_at(uint32_t addr, uint32_t value);

        /**
         * @brief Get value at virtual memory address.
         *
         * The difference from read32() is that this method bypasses the journal
         * and if there are any IOHandlerStub objects registered for that address,
         * this also bypasses them.
         *
         * This meant to be used by tests.
         */
        uint32_t get_value_at(uint32_t addr) const;

        /**
         * @brief Get value at virtual memory address.
         *
         * The difference from read32() is that this method bypasses the journal
         * and if there are any IOHandlerStub objects registered for that address,
         * this also bypasses them. If the value at the address was not previously set,
         * returns default value.
         *
         * The difference from get_value_at(uint32_t) is that this method does
         * not throw an exception when the value wasn't initialized.
         *
         * This meant to be used by tests.
         */
        uint32_t get_value_at(uint32_t addr, uint32_t default_value) const;

        /**
         * @brief Get pointer stored at address.
         *
         * The method will return nullptr, if the address wasn't initialized.
         */
        void* get_ptr_at(uint32_t addr) const;

        /**
         * @brief Store pointer at virtual memory address.
         */
        void set_ptr_at(uint32_t addr, void* ptr);

        /**
         * @brief Set IOHandlerStub for a single 32bit aligned address.
         *
         * @param[in] addr Virtual memory address. Must be 32 bit aligned.
         * @param[in] io_handler All memory IO operations on the address will
         *  be forwarded to this object. Note, that Memory object does not own the pointer,
         *  which is a primary reason why calling reset() at the beginning of a test is required.
         */
        void set_addr_io_handler(uint32_t addr, IOHandlerStub* io_handler);

        /**
         * @brief Set IOHandlerStub for a range of virtual memory addresses.
         *
         * The range is [range_start; range_end).
         *
         * @param[in] range_start Virtual memory address. Must be 32 bit aligned.
         * @param[in] range_end Virtual memory address. Must be 32 bit aligned.
         * @param[in] io_handler All memory IO operations on the address will
         *  be forwarded to this object. Note, that Memory object does not own the pointer,
         *  which is a primary reason why calling reset() at the beginning of a test is required.
         */
        void set_addr_io_handler(uint32_t range_start, uint32_t range_end, IOHandlerStub* io_handler);

        /**
         * @brief Count the number of operations performed.
         *
         * This basically looks at the journal and counts how many operations
         * are of this type.
         *
         * @param[in] op The operation the caller is interested in.
         */
        unsigned int get_op_count(Op op) const;

        /**
         * @brief Count the number of operations performed.
         *
         * This basically looks at the journal and counts how many operations
         * are of this type and at a given address.
         *
         * @param[in] op The operation the caller is interested in.
         * @param[in] addr The address the caller is interested in.
         */
        unsigned int get_op_count(Op op, uint32_t addr) const;

        /**
         * @brief Print the journal to stdout.
         *
         * This is kind of a last resort for debugging.
         */
        void print_journal() const;

        /**
         * @brief Print virtual memory map to stdout.
         *
         * Only prints cells that were set by the user or simulation, i.e.
         * using set_value_at() or writeXXX() methods.
         * Does not (yet) print stored pointers.
         */
        void print_map() const;

    private:
        void priv_write32(uint32_t addr, uint32_t value);
        uint32_t priv_read32(uint32_t addr) const;

        std::map<uint32_t, uint32_t> mem_map_;
        std::map<uint32_t, void*> mem_ptr_map_;
        // Note, memory mock does not own the pointers.
        // It is the responsibility of the caller to clean them up.
        // Special care needs to be taken in the case of the global
        // memory map object.
        std::map<uint32_t, IOHandlerStub*> addr_handler_map_;
        mutable JournalT journal_;
};

/**
 * @brief Return global Memory object.
 *
 * The tests that user memio mocking should use this function
 * to get the Singleton Memory object.
 */
Memory& get_global_memory();

}  // namespace mock


text:
package com.amazonaws.services.cognitoidp.model.transform;

import java.util.Map;

import javax.annotation.Generated;

import com.amazonaws.SdkClientException;
import com.amazonaws.services.cognitoidp.model.*;

import com.amazonaws.protocol.*;
import com.amazonaws.annotation.SdkInternalApi;

/**
 * AdminRespondToAuthChallengeRequestMarshaller
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
@SdkInternalApi
public class AdminRespondToAuthChallengeRequestMarshaller {

    private static final MarshallingInfo<String> USERPOOLID_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
            .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("UserPoolId").build();
    private static final MarshallingInfo<String> CLIENTID_BINDING = MarshallingInfo.builder(MarshallingType.STRING).marshallLocation(MarshallLocation.PAYLOAD)
            .marshallLocationName("ClientId").build();
    private static final MarshallingInfo<String> CHALLENGENAME_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
            .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("ChallengeName").build();
    private static final MarshallingInfo<Map> CHALLENGERESPONSES_BINDING = MarshallingInfo.builder(MarshallingType.MAP)
            .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("ChallengeResponses").build();
    private static final MarshallingInfo<String> SESSION_BINDING = MarshallingInfo.builder(MarshallingType.STRING).marshallLocation(MarshallLocation.PAYLOAD)
            .marshallLocationName("Session").build();

    private static final AdminRespondToAuthChallengeRequestMarshaller instance = new AdminRespondToAuthChallengeRequestMarshaller();

    public static AdminRespondToAuthChallengeRequestMarshaller getInstance() {
        return instance;
    }

    /**
     * Marshall the given parameter object.
     */
    public void marshall(AdminRespondToAuthChallengeRequest adminRespondToAuthChallengeRequest, ProtocolMarshaller protocolMarshaller) {

        if (adminRespondToAuthChallengeRequest == null) {
            throw new SdkClientException("Invalid argument passed to marshall(...)");
        }

        try {
            protocolMarshaller.marshall(adminRespondToAuthChallengeRequest.getUserPoolId(), USERPOOLID_BINDING);
            protocolMarshaller.marshall(adminRespondToAuthChallengeRequest.getClientId(), CLIENTID_BINDING);
            protocolMarshaller.marshall(adminRespondToAuthChallengeRequest.getChallengeName(), CHALLENGENAME_BINDING);
            protocolMarshaller.marshall(adminRespondToAuthChallengeRequest.getChallengeResponses(), CHALLENGERESPONSES_BINDING);
            protocolMarshaller.marshall(adminRespondToAuthChallengeRequest.getSession(), SESSION_BINDING);
        } catch (Exception e) {
            throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
        }
    }

}

redpajama_set_name: RedPajamaGithub


text:
/*****************************************************************
 * *******                  UDF_SPHERE                     *******
 *****************************************************************
 * a box on a sphere
 *
 *****************************************************************
 */

#include "path.h"

#ifndef __SQLITE_BOX_H__
#define __SQLITE_BOX_H__

/*!
	\file
	\brief Box declarations
*/

/*!
	The definition of spherical box using two spherical
	 points: south-west and north-east
	\brief Spherical box
*/
class SBox {
public:
	SPoint  sw;   //!< South-west value of box
	SPoint  ne;   //!< North-east value of box

	SBox() : sw(SPoint(0.0, 0.0)), ne(SPoint(0.0, 0.0)) {}

	SBox( SPoint nSw, SPoint nNe ) {
		sw = nSw;
		ne = nNe;
	}
};

/*!
	\addtogroup SQLITE_RELATIONSHIPS
	@{
*/
/*! \defgroup SQLITE_BOX_CIRCLE_REL Box and circle */
/*!
	\addtogroup SQLITE_BOX_CIRCLE_REL
	@{
*/
#define SQLITE_BOX_CIRCLE_AVOID 0    //!< box avoids circle
#define SQLITE_BOX_CONT_CIRCLE  1    //!< box contains circle
#define SQLITE_CIRCLE_CONT_BOX  2    //!< circle contains box
#define SQLITE_BOX_CIRCLE_EQUAL 3    //!< circle equals box
#define SQLITE_BOX_CIRCLE_OVER  4    //!< circle and box are overlapping
/*! @} */

/*! \defgroup SQLITE_BOX_LINE_REL Box and line */
/*!
	\addtogroup SQLITE_BOX_LINE_REL
	@{
*/
#define SQLITE_BOX_LINE_AVOID 0    //!< box avoids line
#define SQLITE_BOX_CONT_LINE  1    //!< box contains line
#define SQLITE_BOX_LINE_OVER  2    //!< box and line are overlapping
/*! @} */

/*! \defgroup SQLITE_BOX_PATH_REL Box and path */
/*!
	\addtogroup SQLITE_BOX_PATH_REL
	@{
*/
#define SQLITE_BOX_PATH_AVOID 0    //!< box avoids path
#define SQLITE_BOX_CONT_PATH  1    //!< box contains path
#define SQLITE_BOX_PATH_OVER  2    //!< box and path are overlapping
/*! @} */

/*! \defgroup SQLITE_BOX_POLY_REL Box and polygon */
/*!
	\addtogroup SQLITE_BOX_POLY_REL
	@{
*/
#define SQLITE_BOX_POLY_AVOID 0    //!< box avoids polygon
#define SQLITE_BOX_CONT_POLY  1    //!< box contains polygon
#define SQLITE_POLY_CONT_BOX  2    //!< polygon contains box
#define SQLITE_BOX_POLY_OVER  3    //!< polygon and box are overlapping
/*! @} */

/*! \defgroup SQLITE_BOX_ELLIPSE_REL Box and ellipse */
/*!
	\addtogroup SQLITE_BOX_ELLIPSE_REL
	@{
*/
#define SQLITE_BOX_ELLIPSE_AVOID 0    //!< box avoids ellipse
#define SQLITE_BOX_CONT_ELLIPSE  1    //!< box contains ellipse
#define SQLITE_ELLIPSE_CONT_BOX  2    //!< ellipse contains box
#define SQLITE_BOX_ELLIPSE_OVER  3    //!< ellipse and box are overlapping
/*! @} */

/*! \defgroup SQLITE_BOX_REL Box and box */
/*!
	\addtogroup SQLITE_BOX_REL
	@{
*/
#define SQLITE_BOX_AVOID        0    //!< box avoids other box
#define SQLITE_BOX_CONT         1    //!< box contains other box
#define SQLITE_BOX_OVER         2    //!< boxes are overlapping
/*! @} */

/*! @} */

/*!
	\brief Checks , whether two boxes are equal
	\param b1 pointer to first box
	\param b2 pointer to second box
	\return true, if equal
*/
bool sbox_eq ( SBox * b1 , SBox * b2);

/*!
	\brief Checks , whether point is contained by a box
	\param p  pointer to point
	\param b  pointer to box
	\return true, if box contains point
*/
bool sbox_cont_point ( const SBox * b, const SPoint * p );

/*!
	\brief Input function of box
	\return box datum
*/
SBox * spherebox_in(char * boxString);

/*!
	The first point is the south-west position,
	the second the north-east position.
	\brief Input function of box from two points
	\return box datum
*/
SBox * spherebox_in_from_points(SPoint * p1, SPoint * p2);

/*!
	\brief Returns the south-west edge of box
	\return point datum
*/
SPoint * spherebox_sw(SBox * box);

/*!
	\brief Returns the north-east edge of box
	\return point datum
*/
SPoint * spherebox_ne(SBox * box);

/*!
	\brief Returns the south-east edge of box
	\return point datum
*/
SPoint * spherebox_se(SBox * box);

/*!
	\brief Returns the north-west edge of box
	\return point datum
*/
SPoint * spherebox_nw(SBox * box);

/*!
	\brief Returns the area of a box
	\return float8 datum
*/
double spherebox_area(SBox * box);

/*!
	\brief Returns the circumference of a box
	\return float8 datum
*/
double spherebox_circ(SBox * box);

/*!
	\brief Checks, wheter two boxes are equal
	\return boolean datum
	\note PostgreSQL function
*/
bool spherebox_equal(SBox * b1, SBox * b2);

/*!
	\brief Checks, wheter two boxes are not equal
	\return boolean datum
*/
bool spherebox_equal_neg(SBox * b1, SBox * b2);

/*!
	\brief Checks , whether point is contained by a box
	\return boolean datum
*/
bool spherebox_cont_point(SBox * b, SPoint * p);

/*!
	\brief Checks , whether point isn't contained by a box
	\return boolean datum
*/
bool spherebox_cont_point_neg(SBox * b, SPoint * p);

/*!
	\brief Checks , whether point is contained by a box
	\return boolean datum
*/
bool spherebox_cont_point_com(SPoint * p, SBox * b);

/*!
	\brief Checks , whether point isn't contained by a box
	\return boolean datum
*/
bool spherebox_cont_point_com_neg(SPoint * p, SBox * b);

/*!
	\brief Checks , whether box contains a circle
	\return boolean datum
*/
bool spherebox_cont_circle(SBox * b, SCircle * c);

/*!
	\brief Checks , whether box doesn't contain a circle
	\return boolean datum
*/
bool spherebox_cont_circle_neg (SBox * b, SCircle * c);

/*!
	\brief Checks , whether box contains a circle
	\return boolean datum
*/
bool spherebox_cont_circle_com(SCircle * c, SBox * b);

/*!
	\brief Checks , whether box doesn't contain a circle
	\return boolean datum
*/
bool spherebox_cont_circle_com_neg (SCircle * c, SBox * b);

/*!
	\brief Checks , whether circle contains a box
	\return boolean datum
*/
bool spherecircle_cont_box(SCircle * c, SBox * b);

/*!
	\brief Checks , whether circle doesn't contain a box
	\return boolean datum
*/
bool spherecircle_cont_box_neg(SCircle * c, SBox * b);

/*!
	\brief Checks , whether circle contains a box
	\return boolean datum
*/
bool spherecircle_cont_box_com(SBox * b, SCircle * c);

/*!
	\brief Checks , whether circle doesn't contain a box
	\return boolean datum
*/
bool spherecircle_cont_box_com_neg(SBox * b, SCircle * c);

/*!
	\brief Checks , whether circle and box are overlapping
	\return boolean datum
*/
bool spherebox_overlap_circle(SBox * b, SCircle * c);

/*!
	\brief Checks , whether circle and box aren't overlapping
	\return boolean datum
*/
bool spherebox_overlap_circle_neg(SBox * b, SCircle * c);

/*!
	\brief Checks , whether circle and box are overlapping
	\return boolean datum
*/
bool spherebox_overlap_circle_com(SCircle * c, SBox * b);

/*!
	\brief Checks , whether circle and box aren't overlapping
	\return boolean datum
*/
bool spherebox_overlap_circle_com_neg(SCircle * c, SBox * b);

/*!
	\brief Checks , whether box contains line
	\return boolean datum
*/
bool spherebox_cont_line(SBox * b, SLine * l);

/*!
	\brief Checks , whether box doesn't contain line
	\return boolean datum
*/
bool spherebox_cont_line_neg(SBox * b, SLine * l);

/*!
	\brief Checks , whether box contains line
	\return boolean datum
*/
bool spherebox_cont_line_com(SLine * l, SBox * b);

/*!
	\brief Checks , whether box doesn't contain line
	\return boolean datum
*/
bool spherebox_cont_line_com_neg(SLine * l, SBox * b);

/*!
	\brief Checks , whether box and line are overlapping
	\return boolean datum
*/
bool spherebox_overlap_line(SBox * b, SLine * l);

/*!
	\brief Checks , whether box and line aren't overlapping
	\return boolean datum
*/
bool spherebox_overlap_line_neg(SBox * b, SLine * l);

/*!
	\brief Checks , whether box and line are overlapping
	\return boolean datum
*/
bool spherebox_overlap_line_com(SLine * l, SBox * b);

/*!
	\brief Checks , whether box and line aren't overlapping
	\return boolean datum
*/
bool spherebox_overlap_line_com_neg(SLine * l, SBox * b);

/*!
	\brief Checks , whether box contains path
	\return boolean datum
*/
bool spherebox_cont_path(SBox * b, SPath * p);

/*!
	\brief Checks , whether box doesn't contain path
	\return boolean datum
*/
bool spherebox_cont_path_neg(SBox * b, SPath * p);

/*!
	\brief Checks , whether box contains path
	\return boolean datum
*/
bool spherebox_cont_path_com(SPath * p, SBox * b);

/*!
	\brief Checks , whether box doesn't contain path
	\return boolean datum
*/
bool spherebox_cont_path_com_neg(SPath * p, SBox * b);

/*!
	\brief Checks , whether box and path are overlapping
	\return boolean datum
*/
bool spherebox_overlap_path(SBox * b, SPath * p);

/*!
	\brief Checks , whether box and path aren't overlapping
	\return boolean datum
*/
bool spherebox_overlap_path_neg(SBox * b, SPath * p);

/*!
	\brief Checks , whether box and path are overlapping
	\return boolean datum
*/
bool spherebox_overlap_path_com(SPath * p, SBox * b);

/*!
	\brief Checks , whether box and path aren't overlapping
	\return boolean datum
*/
bool spherebox_overlap_path_com_neg(SPath * p, SBox * b);

/*!
	\brief Checks , whether box contains a polygon
	\return boolean datum
*/
bool spherebox_cont_poly(SBox * b, SPoly * p);

/*!
	\brief Checks , whether box doesn't contain a polygon
	\return boolean datum
*/
bool spherebox_cont_poly_neg (SBox * b, SPoly * p);

/*!
	\brief Checks , whether box contains a polygon
	\return boolean datum
*/
bool spherebox_cont_poly_com(SPoly * p, SBox * b);

/*!
	\brief Checks , whether box doesn't contain a polygon
	\return boolean datum
*/
bool spherebox_cont_poly_com_neg (SPoly * p, SBox * b);

/*!
	\brief Checks , whether polygon contains a box
	\return boolean datum
*/
bool spherepoly_cont_box(SPoly * p, SBox * b);

/*!
	\brief Checks , whether polygon doesn't contain a box
	\return boolean datum
*/
bool spherepoly_cont_box_neg(SPoly * p, SBox * b);

/*!
	\brief Checks , whether polygon contains a box
	\return boolean datum
*/
bool spherepoly_cont_box_com(SBox * b, SPoly * p);

/*!
	\brief Checks , whether polygon doesn't contain a box
	\return boolean datum
*/
bool spherepoly_cont_box_com_neg(SBox * b, SPoly * p);

/*!
	\brief Checks , whether polygon and box are overlapping
	\return boolean datum
*/
bool spherebox_overlap_poly(SBox * b, SPoly * p);

/*!
	\brief Checks , whether polygon and box aren't overlapping
	\return boolean datum
*/
bool spherebox_overlap_poly_neg(SBox * b, SPoly * p);

/*!
	\brief Checks , whether polygon and box are overlapping
	\return boolean datum
*/
bool spherebox_overlap_poly_com(SPoly * p, SBox * b);

/*!
	\brief Checks , whether polygon and box aren't overlapping
	\return boolean datum
*/
bool spherebox_overlap_poly_com_neg(SPoly * p, SBox * b);

/*!
	\brief Checks , whether box contains a ellipse
	\return boolean datum
*/
bool spherebox_cont_ellipse(SBox * b, SEllipse * e);

/*!
	\brief Checks , whether box doesn't contain a ellipse
	\return boolean datum
*/
bool spherebox_cont_ellipse_neg (SBox * b, SEllipse * e);

/*!
	\brief Checks , whether box contains a ellipse
	\return boolean datum
*/
bool spherebox_cont_ellipse_com(SEllipse * e, SBox * b);

/*!
	\brief Checks , whether box doesn't contain a ellipse
	\return boolean datum
*/
bool spherebox_cont_ellipse_com_neg (SEllipse * e, SBox * b);

/*!
	\brief Checks , whether ellipse contains a box
	\return boolean datum
*/
bool sphereellipse_cont_box(SEllipse * e, SBox * b);

/*!
	\brief Checks , whether ellipse doesn't contain a box
	\return boolean datum
*/
bool sphereellipse_cont_box_neg(SEllipse * e, SBox * b);

/*!
	\brief Checks , whether ellipse contains a box
	\return boolean datum
*/
bool sphereellipse_cont_box_com(SBox * b, SEllipse * e);

/*!
	\brief Checks , whether ellipse doesn't contain a box
	\return boolean datum
*/
bool sphereellipse_cont_box_com_neg(SBox * b, SEllipse * e);

/*!
	\brief Checks , whether ellipse and box are overlapping
	\return boolean datum
*/
bool spherebox_overlap_ellipse(SBox * b, SEllipse * e);

/*!
	\brief Checks , whether ellipse and box aren't overlapping
	\return boolean datum
*/
bool spherebox_overlap_ellipse_neg(SBox * b, SEllipse * e);

/*!
	\brief Checks , whether ellipse and box are overlapping
	\return boolean datum
*/
bool spherebox_overlap_ellipse_com(SEllipse * e, SBox * b);

/*!
	\brief Checks , whether ellipse and box aren't overlapping
	\return boolean datum
*/
bool spherebox_overlap_ellipse_com_neg(SEllipse * e, SBox * b);

/*!
	\brief Checks , whether a box contains another box
	\return boolean datum
*/
bool spherebox_cont_box(SBox * box1, SBox * box2);

/*!
	\brief Checks , whether box doesn't contain another box
	\return boolean datum
*/
bool spherebox_cont_box_neg (SBox * box1, SBox * box2);

/*!
	\brief Checks , whether box contains another box
	\return boolean datum
*/
bool spherebox_cont_box_com(SBox * box2, SBox * box1);

/*!
	\brief Checks , whether box doesn't contain another box
	\return boolean datum
*/
bool spherebox_cont_box_com_neg (SBox * box2, SBox * box1);

/*!
	\brief Checks , whether boxes are overlapping
	\return boolean datum
*/
bool spherebox_overlap_box(SBox * box1, SBox * box2);

/*!
	\brief Checks , whether boxes aren't overlapping
	\return boolean datum
*/
bool spherebox_overlap_box_neg(SBox * box1, SBox * box2);

#endif


text:
require 'spec_helper'

describe Effective::WebhooksController do
  routes { EffectiveOrders::Engine.routes }

  before { StripeMock.start }
  after { StripeMock.stop }

  let(:order) { FactoryGirl.create(:order) }
  let(:buyer) { Effective::Customer.for_user(order.user) }

  let(:event) { StripeMock.mock_webhook_event('customer.subscription.created') }
  let(:event_hash) { event.to_hash }

  describe '#stripe' do
    it 'retrieves the real event from Stripe based on passed ID' do
      Stripe::Event.should_receive(:retrieve).with(event_hash[:id])
      post :stripe, event_hash
      response.code.should eq '200'
    end

    it 'assigns the @event based on the passed ID' do
      post :stripe, event_hash
      assigns(:event).id.should eq event_hash[:id]
      response.code.should eq '200'
    end

    it 'exits immediately when passed a livemode=false event in Production' do
      event_hash[:livemode] = false
      Rails.env.stub(:production?).and_return(true)

      post :stripe, event_hash
      assigns(:event).should eq nil
      response.code.should eq '200'
    end

    it 'exits immediately when passed a non-object event' do
      event_hash[:object] = 'not-object'

      post :stripe, event_hash
      assigns(:event).should eq nil
      response.code.should eq '200'
    end

  end

  describe '#stripe.subscription_created' do
    before(:each) do
      buyer.update_attributes(:stripe_customer_id => event.data.object.customer)
    end

    it 'assigns the existing customer, if exists' do
      post :stripe, event_hash
      assigns(:customer).should eq buyer
    end

    it 'creates a new purchased Order for the Subscription' do
      Effective::Subscription.any_instance.stub(:valid?).and_return(true)
      Effective::Subscription.any_instance.stub(:purchased?).and_return(false)

      post :stripe, event_hash

      assigns(:order).purchased?.should eq true
      assigns(:order).user.should eq buyer.user
      assigns(:order).payment.to_s.include?(event_hash[:id]).should eq true
    end

    it 'does not create an Order for an existing purchased Subscription' do
      Effective::Subscription.any_instance.stub(:valid?).and_return(true)
      Effective::Subscription.any_instance.stub(:purchased?).and_return(true)

      post :stripe, event_hash

      assigns(:order).present?.should eq false
    end

  end

end


text:
#include <aws/cloudformation/CloudFormationEndpoint.h>
#include <aws/core/utils/memory/stl/AWSMap.h>

using namespace Aws;
using namespace Aws::CloudFormation;

namespace Aws
{
namespace CloudFormation
{
namespace CloudFormationEndpoint
{
  Aws::String ForRegion(Region region)
  {
    switch(region)
    {
     case Region::US_EAST_1:
        return "cloudformation.us-east-1.amazonaws.com";
     case Region::US_WEST_1:
        return "cloudformation.us-west-1.amazonaws.com";
     case Region::US_WEST_2:
        return "cloudformation.us-west-2.amazonaws.com";
     case Region::EU_WEST_1:
        return "cloudformation.eu-west-1.amazonaws.com";
     case Region::EU_CENTRAL_1:
        return "cloudformation.eu-central-1.amazonaws.com";
     case Region::AP_SOUTHEAST_1:
        return "cloudformation.ap-southeast-1.amazonaws.com";
     case Region::AP_SOUTHEAST_2:
        return "cloudformation.ap-southeast-2.amazonaws.com";
     case Region::AP_NORTHEAST_1:
        return "cloudformation.ap-northeast-1.amazonaws.com";
     case Region::AP_NORTHEAST_2:
        return "cloudformation.ap-northeast-2.amazonaws.com";
     case Region::SA_EAST_1:
        return "cloudformation.sa-east-1.amazonaws.com";
     default:
        return "cloudformation.us-east-1.amazonaws.com";
    }
  }

} // namespace CloudFormationEndpoint
} // namespace CloudFormation
} // namespace Aws


text:
using System;
using System.Drawing;
using ImageDiff;
using NUnit.Framework;

namespace ImageDiffTests
{
    [TestFixture]
    public class BitmapComparerTests
    {
        protected const string TestImage1 = "./images/TestImage1.png";
        protected const string TestImage2 = "./images/TestImage2.png";
        protected const string OutputFormat = "output_{0}.png";
        protected Bitmap FirstImage { get; set; }
        protected Bitmap SecondImage { get; set; }

        [SetUp]
        public void Setup()
        {
            FirstImage = new Bitmap(TestImage1);
            SecondImage = new Bitmap(TestImage2);
        }

        [Test, ExpectedException(typeof(ArgumentNullException))]
        public void CompareThrowsWhenFirstImageIsNull()
        {
            var target = new BitmapComparer(null);
            target.Compare(null, SecondImage);
        }

        [Test, ExpectedException(typeof(ArgumentNullException))]
        public void CompareThrowsWhenSecondImageIsNull()
        {
            var target = new BitmapComparer(null);
            target.Compare(FirstImage, null);
        }

        [Test, ExpectedException(typeof(ArgumentException))]
        public void CompareThrowsWhenImagesAreNotSameWidth()
        {
            var firstBitmap = new Bitmap(10, 10);
            var secondBitmap = new Bitmap(20, 10);

            var target = new BitmapComparer(null);
            target.Compare(firstBitmap, secondBitmap);
        }

        [Test, ExpectedException(typeof(ArgumentException))]
        public void CompareThrowsWhenImagesAreNotSameHeight()
        {
            var firstBitmap = new Bitmap(10, 10);
            var secondBitmap = new Bitmap(10, 20);

            var target = new BitmapComparer(null);
            target.Compare(firstBitmap, secondBitmap);
        }

        [Test, ExpectedException(typeof(ArgumentException))]
        public void ImageDiffThrowsWhenBoundingBoxPaddingIsLessThanZero()
        {
            var target = new BitmapComparer(new CompareOptions
            {
                BoundingBoxColor = Color.Red,
                BoundingBoxMode = BoundingBoxModes.Single,
                AnalyzerType = AnalyzerTypes.ExactMatch,
                DetectionPadding = 2,
                BoundingBoxPadding = -2,
                Labeler = LabelerTypes.Basic
            });
        }

        [Test, ExpectedException(typeof(ArgumentException))]
        public void ImageDiffThrowsWhenDetectionPaddingIsLessThanZero()
        {
            var target = new BitmapComparer(new CompareOptions
            {
                BoundingBoxColor = Color.Red,
                BoundingBoxMode = BoundingBoxModes.Single,
                AnalyzerType = AnalyzerTypes.ExactMatch,
                DetectionPadding = -2,
                BoundingBoxPadding = 2,
                Labeler = LabelerTypes.Basic
            });
        }

        [Test]
        public void CompareWorksWithNoOptions()
        {
            var target = new BitmapComparer();
            var result = target.Compare(FirstImage, SecondImage);
            result.Save(string.Format(OutputFormat, "CompareWorksWithNullOptions"), SecondImage.RawFormat);
        }

        [Test]
        public void CompareWorksWithNullOptions()
        {
            var target = new BitmapComparer(null);
            var result = target.Compare(FirstImage, SecondImage);
            result.Save(string.Format(OutputFormat, "CompareWorksWithNullOptions"), SecondImage.RawFormat);
        }

        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Single, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Single, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Multiple, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Multiple, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Single, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Single, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Multiple, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Multiple, LabelerTypes.ConnectedComponentLabeling)]
        public void CompareWorksWithIdenticalImages(AnalyzerTypes aType, BoundingBoxModes bMode, LabelerTypes lType)
        {
            var target = new BitmapComparer(new CompareOptions
            {
                AnalyzerType = aType,
                BoundingBoxMode = bMode,
                Labeler = lType
            });
            var result = target.Compare(FirstImage, FirstImage);
            result.Save(string.Format(OutputFormat, string.Format("CompareWorksWithIdenticalImages_{0}_{1}_{2}", aType, bMode, lType)),
                SecondImage.RawFormat);
        }

        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Single, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Single, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Multiple, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Multiple, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Single, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Single, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Multiple, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Multiple, LabelerTypes.ConnectedComponentLabeling)]
        public void CompareWorksWithDifferentImages(AnalyzerTypes aType, BoundingBoxModes bMode, LabelerTypes lType)
        {
            var target = new BitmapComparer(new CompareOptions
            {
                BoundingBoxColor = Color.Red,
                BoundingBoxMode = bMode,
                AnalyzerType = aType,
                DetectionPadding = 2,
                BoundingBoxPadding = 2,
                Labeler = lType
            });
            var result = target.Compare(FirstImage, SecondImage);
            result.Save(string.Format(OutputFormat, string.Format("CompareWorksWithDifferentImages_{0}_{1}_{2}", aType, bMode, lType)), SecondImage.RawFormat);
        }

        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Single, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Single, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Multiple, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Multiple, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Single, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Single, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Multiple, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Multiple, LabelerTypes.ConnectedComponentLabeling)]
        public void EqualsReturnsTrueWithSameImage(AnalyzerTypes aType, BoundingBoxModes bMode, LabelerTypes lType)
        {
            var target = new BitmapComparer(new CompareOptions
            {
                BoundingBoxColor = Color.Red,
                BoundingBoxMode = bMode,
                AnalyzerType = aType,
                DetectionPadding = 2,
                BoundingBoxPadding = 2,
                Labeler = lType
            });
            var newInstanceOfFirstImage = new Bitmap(TestImage1);
            var result = target.Equals(FirstImage, newInstanceOfFirstImage);
            Assert.IsTrue(result);
        }

        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Single, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Single, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Multiple, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Multiple, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Single, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Single, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Multiple, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Multiple, LabelerTypes.ConnectedComponentLabeling)]
        public void EqualsReturnsFalseWithDifferentImage(AnalyzerTypes aType, BoundingBoxModes bMode, LabelerTypes lType)
        {
            var target = new BitmapComparer(new CompareOptions
            {
                BoundingBoxColor = Color.Red,
                BoundingBoxMode = bMode,
                AnalyzerType = aType,
                DetectionPadding = 2,
                BoundingBoxPadding = 2,
                Labeler = lType
            });
            var result = target.Equals(FirstImage, SecondImage);
            Assert.IsFalse(result);
        }

        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Single, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Single, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Multiple, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Multiple, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Single, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Single, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Multiple, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Multiple, LabelerTypes.ConnectedComponentLabeling)]
        public void EqualsReturnsTrueWithNullImages(AnalyzerTypes aType, BoundingBoxModes bMode, LabelerTypes lType)
        {
            var target = new BitmapComparer(new CompareOptions
            {
                BoundingBoxColor = Color.Red,
                BoundingBoxMode = bMode,
                AnalyzerType = aType,
                DetectionPadding = 2,
                BoundingBoxPadding = 2,
                Labeler = lType
            });
            var result = target.Equals(null, null);
            Assert.IsTrue(result);
        }

        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Single, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Single, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Multiple, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Multiple, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Single, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Single, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Multiple, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Multiple, LabelerTypes.ConnectedComponentLabeling)]
        public void EqualsReturnsFalseWithNullFirstImage(AnalyzerTypes aType, BoundingBoxModes bMode, LabelerTypes lType)
        {
            var target = new BitmapComparer(new CompareOptions
            {
                BoundingBoxColor = Color.Red,
                BoundingBoxMode = bMode,
                AnalyzerType = aType,
                DetectionPadding = 2,
                BoundingBoxPadding = 2,
                Labeler = lType
            });
            var result = target.Equals(null, SecondImage);
            Assert.IsFalse(result);
        }

        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Single, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Single, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Multiple, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.CIE76, BoundingBoxModes.Multiple, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Single, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Single, LabelerTypes.ConnectedComponentLabeling)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Multiple, LabelerTypes.Basic)]
        [TestCase(AnalyzerTypes.ExactMatch, BoundingBoxModes.Multiple, LabelerTypes.ConnectedComponentLabeling)]
        public void EqualsReturnsFalseWithNullSecondImage(AnalyzerTypes aType, BoundingBoxModes bMode, LabelerTypes lType)
        {
            var target = new BitmapComparer(new CompareOptions
            {
                BoundingBoxColor = Color.Red,
                BoundingBoxMode = bMode,
                AnalyzerType = aType,
                DetectionPadding = 2,
                BoundingBoxPadding = 2,
                Labeler = lType
            });
            var result = target.Equals(FirstImage, null);
            Assert.IsFalse(result);
        }
    }
}


text:
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
    <link href="assets/css/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css">
    <link href="assets/css/style.css" media="screen" rel="stylesheet" type="text/css">

                 >> Task / Kanbanery einlesen <<

                Datensätze

                            #
                            ID
                            Ort
                            Title
                            erstellt am


text:
//Tic Tac Toe by SilverTactic (Siiilver)
/*if (!global.ttt) global.ttt = [{}, {}];
var tttgames = global.ttt[0];
var tttplayers = global.ttt[1];

const EXPIRATION_TIME = 90 * 1000;
const INACTIVE_KICK_TIME = 30 * 1000;

var TicTacToe = (function () {
	function TicTacToe(user1, user2, gameNo) {
		this.gameNo = gameNo;
		this.p1 = user1;
		this.p2 = user2;
		this.players = [this.p1, this.p2];
		this.checkPlayer = function (user) {
			if (this.p1.userid === user.userid) return this.p2.name;
			if (this.p2.userid === user.userid) return this.p1.name;
			return false;
		}.bind(this);
		this.markers = {};
		this.markers[this.p1.userid] = 'X';
		this.boxes = {'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9};
		this.markedCount = 0;
		this.phase = 'waiting';
		this.timer = setTimeout(this.end.bind(this, 'The game request has expired.'), EXPIRATION_TIME);
	}

	TicTacToe.prototype.accept = function () {
		this.markers[this.p2.userid] = 'O';
		this.currentPlayer = this.players[Math.floor(Math.random() * 2)];
		this.phase = 'started';
		this.resetTimer();
		this.update('If you accidentally close out, use /ttt open to reopen the game.');
	};

	TicTacToe.prototype.switchPlayer = function () {
		if (this.currentPlayer === this.p1) this.currentPlayer = this.p2;
		else this.currentPlayer = this.p1;
	};

	TicTacToe.prototype.getGrid = function (gameOver) {
		var marked = [];
		for (var i in this.boxes) {
			if (typeof this.boxes[i] === 'string') marked.push(this.boxes[i]);
			else marked.push('<button style = "height: 80px%; width: 80px; font-size: 20pt" name = "send" value = "/ttt markbox ' + i + '">' + i + '</button>');
		}
		var style = 'width: 100px; height: 100px; font-size: 20pt;';
		var grid = '
' +
			//row 1
			'
' + marked[0] + '	' +
			'' + marked[1] + '	' +
			'' + marked[2] + '
' +
			//row 2
			'
' + marked[3] + '	' +
			'' + marked[4] + '	' +
			'' + marked[5] + '
' +
			//row 3
			'
' + marked[6] + '	' +
			'' + marked[7] + '	' +
			'' + marked[8] + '

';
		if (!gameOver) grid += '<button name = "send" value = "/ttt end">End Game</button>';
		return grid;
	};

	TicTacToe.prototype.markBox = function (user, num) {
		if (this.currentPlayer.userid !== user.userid) return this.updateUser(user, 'It isn\'t your turn right now.');
		if (!num || num.length > 1 || num.match(/[^1-9]/g)) return this.updateUser(user, 'That is not a valid box number.');
		if (typeof this.boxes[num] === 'string') return this.updateUser(user, 'That box has already been marked.');
		this.boxes[num] = this.markers[this.currentPlayer.userid];
		this.markedCount++;
		if (!this.checkWinner()) {
			this.resetTimer();
			this.switchPlayer();
			this.update();
		}
	};

	TicTacToe.prototype.update = function (text) {
		var message = '|html|' + this.currentPlayer.name + '\'s turn!
' + this.getGrid();
		if (text) message += '
' + text;
		this.players.forEach(function (user) {
			user.popup(message);
		});
	};

	TicTacToe.prototype.updateUser = function (user, issue) {
		var message = '|html|' + this.currentPlayer.name + '\'s turn!
' +
			this.getGrid() + (issue ? '
' + issue : '');
		user.popup(message);
	};

	TicTacToe.prototype.checkWinner = function () {
		if ((this.boxes['1'] === this.boxes['2'] && this.boxes['2'] === this.boxes['3']) || (this.boxes['4'] === this.boxes['5'] && this.boxes['5'] === this.boxes['6']) || (this.boxes['7'] === this.boxes['8'] && this.boxes['8'] === this.boxes['9']) || (this.boxes['1'] === this.boxes['4'] && this.boxes['4'] === this.boxes['7']) || (this.boxes['2'] === this.boxes['5'] && this.boxes['5'] === this.boxes['8']) || (this.boxes['3'] === this.boxes['6'] && this.boxes['6'] === this.boxes['9']) || (this.boxes['1'] === this.boxes['5'] && this.boxes['5'] === this.boxes['9']) || (this.boxes['3'] === this.boxes['5'] && this.boxes['5'] === this.boxes['7'])) {
			this.declareWinner();
			return true;
		}
		if (this.markedCount === 9) {
			this.declareDraw();
			return true;
		}
	};

	TicTacToe.prototype.declareDraw = function () {
		var message = '|html|Draw between ' + this.p1.name + ' and ' + this.p2.name + '!
' + this.getGrid(true);
		this.players.forEach(function (user) {
			user.popup(message);
		});
		this.end();
	};

	TicTacToe.prototype.declareWinner = function () {
		var message = '|html|' + this.currentPlayer.name + ' has won the game!
' + this.getGrid(true);
		this.players.forEach(function (user) {
			user.popup(message);
		});
		this.end();
	};

	TicTacToe.prototype.end = function (message) {
		if (message) {
			if (this.phase === 'waiting') {
				message = '|pm|' + this.p2.getIdentity() + '|' + this.p1.getIdentity() + '|/error ' + message;
			} else message = '|popup|' + message;
			this.players.forEach(function (user) {
				user.send(message);
			});
		}
		clearTimeout(this.timer);
		delete tttplayers[this.p1.userid];
		delete tttplayers[this.p2.userid];
		delete tttgames[this.gameNo];
	};

	TicTacToe.prototype.resetTimer = function () {
		clearTimeout(this.timer);
		this.timer = setTimeout(this.end.bind(this, 'The game has been ended due to player inactivity.'), INACTIVE_KICK_TIME);
	};

	return TicTacToe;
})();

var cmds = {
	'': 'help',
	help: function (target, room, user) {
		if (!this.canBroadcast()) return;
		this.sendReplyBox('Tic-Tac-Toe commands
' +
			'
/ttt c User - Sends a user a request to play Tic-Tac-Toe. This can also be used in PMs. (Requests automatically expire if they\'re not accepted or declined within 1.5 minutes.)
' +
			'
/ttt accept User  - Accepts a Tic-Tac-Toe request from a user.
' +
			'
/ttt decline User - Declines a Tic-Tac-Toe request from a user.
' +
			'
/ttt see or /ttt show - Opens up the Tic-Tac-Toe board, in case you accidentally closed it out.
' +
			'
/ttt end - Exits the current game of Tic-Tac-Toe. Cancels a play request if the game hasn\'t been started yet. (Note: The game automatically ends after a user stays inactive for more than 30 seconds.)
'
		);
	},

	chall: 'c',
	challenge: 'c',
	play: 'c',
	c: function (target, room, user, connection, cmd) {
		if (!target || !target.trim()) return this.sendReply('|html|/ttt ' + cmd + ' User - Challenges a user to a game of Tic-Tac-Toe.');
		var targetUser = (Users.get(target) ? Users.get(target).name : target);
		target = Users.get(target);
		if (!target || !target.connected) return this.sendReply('User ' + targetUser + ' is offline.');
		if (user.userid === target.userid) return this.sendReply('You can\'t play Tic-Tac-Toe with yourself!');
		if (user.userid in tttplayers) {
			var game = tttgames[tttplayers[user.userid]];
			if (game.phase === 'waiting') return this.sendReply('You have already challenged ' + game.checkPlayer(user) + ' to a game of Tic-Tac-Toe. Wait for their response.');
			if (game.checkPlayer(target)) return this.sendReply('You\'re playing Tic-Tac-Toe with ' + target.name + ' right now!');
			return this.sendReply('You are currently playing Tic-Tac-Toe with another user. You cannot send ' + target.name + ' a request.');
		}
		if (target.userid in tttplayers) {
			var game = tttgames[tttplayers[target.userid]];
			if (game.checkPlayer(user)) return this.sendReply(game.checkPlayer(user) + ' has already sent you a game request...');
			return this.sendReply(target.name + ' has already challenged someone else to a game of Tic-Tac-Toe. Either wait for them to finish, or play with someone else.');
		}
		for (var i in tttgames) {
			if (tttgames[i].checkPlayer(user)) return this.sendReply(tttgames[i].checkPlayer(user) + ' sent you a request. Respond to that before challenging anyone else.');
			if (tttgames[i].checkPlayer(target)) return this.sendReply(target.name + ' has already challenged someone else to a game of Tic-Tac-Toe. Either wait for them to finish, or play with someone else.');
		}
		target.send('|pm|' + user.getIdentity() + '|' + target.getIdentity() + '|/html ' + user.getIdentity() + ' wants to play Tic-Tac-Toe!
' +
			'<button name = "send" value = "/ttt accept ' + user.userid + '">Accept</button> <button name = "send" value = "/ttt decline ' + user.userid + '">Decline</button>'
		);
		user.send('|pm|' + target.getIdentity() + '|' + user.getIdentity() + '|/html You have challenged ' + target.getIdentity() + ' to a game of Tic-Tac-Toe. Waiting for their response...');
		var gameId = tttplayers[user.userid] = Object.keys(tttgames).length;
		tttgames[gameId] = new TicTacToe(user, target, gameId);
	},

	acc: 'accept',
	accept: function (target, room, user, connection, cmd) {
		if (!target || !target.trim()) return this.sendReply('|html|/ttt ' + cmd + ' User - Accepts a Tic-Tac-Toe challenge from a user.');
		var game = tttgames[tttplayers[user.userid]];
		var targetUser = (Users.get(target) ? Users.get(target).name : target);
		target = Users.get(target);
		if (!target || !target.connected) return this.sendReply('User ' + targetUser + ' is offline. Wait for them to come back online.');
		if (user.userid in tttplayers) {
			if (game.phase === 'waiting') return this.sendReply('You have already challenged someone else to a game of Tic-Tac-Toe. You cannot accept this user\'s challenge.');
			if (game.checkPlayer(target)) return this.sendReply('You\'re playing Tic-Tac-Toe with ' + game.checkPlayer(user) + ' right now!');
			return this.sendReply('You are currently playing Tic-Tac-Toe with another user. You cannot accept ' + target.name + '\'s request.');
		}
		if (user.userid === target.userid) return this.sendReply('You can\'t accept a challenge from yourself!');
		if (!(target.userid in tttplayers)) return this.sendReply(target.name + ' has not challenged you to a game of Tic-Tac-Toe.');

		game = tttgames[tttplayers[target.userid]];
		if (game.p2.userid !== user.userid) return this.sendReply(target.name + ' has not challenged you to a game of Tic-Tac-Toe.');
		tttplayers[user.userid] = tttplayers[target.userid];
		game.accept();
	},

	dec: 'decline',
	decline: function (target, room, user, connection, cmd) {
		if (!target || !target.trim()) return this.sendReply('|html|/ttt ' + cmd + ' User - Declines a Tic-Tac-Toe challenge from a user.');
		var targetUser = (Users.get(target) ? Users.get(target).name : target);
		target = Users.get(target);
		if (!target || !target.connected) return this.sendReply('User ' + targetUser + ' is offline.');
		if (user.userid === target.userid) return this.sendReply('You can\'t use this command on yourself.');
		var game = tttgames[tttplayers[toId(targetUser)]];
		if (!(target.userid in tttplayers) || !game.checkPlayer(target)) return this.sendReply(target + ' has not challenged you to a game of Tic-Tac-Toe.');
		if (game.checkPlayer(target) && game.phase == 'started') return this.sendReply('You are playing with ' + game.checkPlayer(user) + ' right now. If you want to end the game, use /ttt end.');

		game.end('The Tic-Tac-Toe challenge was declined.');
	},

	mark: 'markbox',
	markbox: function (target, room, user, connection, cmd) {
		if (!(user.userid in tttplayers)) return this.sendReply('You aren\'t playing a game of Tic-Tac-Toe right now.');
		var game = tttgames[tttplayers[user.userid]];
		if (game.phase === 'waiting') return this.sendReply('Your request has not been accepted yet. You can only use this command in an active game.');
		game.markBox(user, target);
	},

	update: 'see',
	view: 'see',
	show: 'see',
	open: 'see',
	see: function (target, room, user) {
		if (!(user.userid in tttplayers)) return this.sendReply('You aren\'t playing a game of Tic-Tac-Toe right now...');
		var game = tttgames[tttplayers[user.userid]];
		if (game.phase === 'waiting') return this.sendReply('Your request has not been accepted yet. You can only use this command in an active game.');
		game.update();
	},

	exit: 'end',
	leave: 'end',
	end: function (target, room, user) {
		if (!(user.userid in tttplayers)) return this.sendReply('You aren\'t playing a game of Tic-Tac-Toe right now...');
		var game = tttgames[tttplayers[user.userid]];
		if (game.phase === 'waiting') game.end('The Tic-Tac-Toe challenge was withdrawn.');
		else game.end(user.name + ' has decided to leave the game midway.');
	}
};

exports.commands = {
	ttt: 'tictactoe',
	tictactoe: cmds,
	tttend: 'endttt',
	endttt: cmds.end
}*/

if (!global.ttt) global.ttt = new Map();
var ttt = global.ttt;

const EXPIRATION_TIME = 90 * 1000;
const INACTIVE_KICK_TIME = 30 * 1000;

var TicTacToe = (function () {
	function TicTacToe(user1, user2) {
		this.p1 = user1;
		this.p2 = user2;
		this.plName = user1.name;
		this.p2Name = user2.name;
		this.checkPlayer = function (user) {
			if (this.p1.userid === user.userid) return this.p2.name;
			if (this.p2.userid === user.userid) return this.p1.name;
			return false;
		}.bind(this);
		this.markers = new Map([[this.p1, 'X']]);
		this.boxes = {'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9};
		this.markedCount = 0;
		this.phase = 'waiting';
		this.timer = setTimeout(this.end.bind(this, 'The Tic-Tac-Toe request has expired.'), EXPIRATION_TIME);
	}

	TicTacToe.prototype.accept = function () {
		this.markers.set(this.p2, 'O');
		this.currentPlayer = [this.p1, this.p2][Math.floor(Math.random() * 2)];
		this.phase = 'started';
		this.resetTimer();
		this.update('If you accidentally close out, use /ttt open to reopen the game.');
	};

	TicTacToe.prototype.switchPlayer = function () {
		if (this.currentPlayer === this.p1) this.currentPlayer = this.p2;
		else this.currentPlayer = this.p1;
	};

	TicTacToe.prototype.getGrid = function (gameOver) {
		var marked = [];
		for (var i in this.boxes) {
			if (typeof this.boxes[i] === 'string') marked.push(this.boxes[i]);
			else marked.push('<button style = "height: 80px%; width: 80px; font-size: 20pt" name = "send" value = "/ttt markbox ' + i + '">' + i + '</button>');
		}
		var style = 'width: 100px; height: 100px; font-size: 20pt;';
		var grid = '
' +
			//row 1
			'
' + marked[0] + '	' +
			'' + marked[1] + '	' +
			'' + marked[2] + '
' +
			//row 2
			'
' + marked[3] + '	' +
			'' + marked[4] + '	' +
			'' + marked[5] + '
' +
			//row 3
			'
' + marked[6] + '	' +
			'' + marked[7] + '	' +
			'' + marked[8] + '

';
		if (!gameOver) grid += '<button name = "send" value = "/ttt end">End Game</button>';
		return grid;
	};

	TicTacToe.prototype.markBox = function (user, num) {
		if (this.currentPlayer.userid !== user.userid) return this.updateUser(user, 'It isn\'t your turn right now.');
		if (!num || num.length > 1 || num.match(/[^1-9]/g)) return this.updateUser(user, 'That is not a valid box number.');
		if (typeof this.boxes[num] === 'string') return this.updateUser(user, 'That box has already been marked.');
		this.boxes[num] = this.markers.get(this.currentPlayer.userid);
		this.markedCount++;
		if (!this.checkWinner()) {
			this.resetTimer();
			this.switchPlayer();
			this.update();
		}
	};

	TicTacToe.prototype.update = function (text) {
		var message = '|html|' + this.currentPlayer.name + '\'s turn!
' + this.getGrid();
		if (text) message += '
' + text;
		this.players.forEach(function (user) {
			user.popup(message);
		});
	};

	TicTacToe.prototype.updateUser = function (user, issue) {
		var message = '|html|' + this.currentPlayer.name + '\'s turn!
' +
			this.getGrid() + (issue ? '
' + issue : '');
		user.popup(message);
	};

	TicTacToe.prototype.checkWinner = function () {
		if ((this.boxes['1'] === this.boxes['2'] && this.boxes['2'] === this.boxes['3']) || (this.boxes['4'] === this.boxes['5'] && this.boxes['5'] === this.boxes['6']) || (this.boxes['7'] === this.boxes['8'] && this.boxes['8'] === this.boxes['9']) || (this.boxes['1'] === this.boxes['4'] && this.boxes['4'] === this.boxes['7']) || (this.boxes['2'] === this.boxes['5'] && this.boxes['5'] === this.boxes['8']) || (this.boxes['3'] === this.boxes['6'] && this.boxes['6'] === this.boxes['9']) || (this.boxes['1'] === this.boxes['5'] && this.boxes['5'] === this.boxes['9']) || (this.boxes['3'] === this.boxes['5'] && this.boxes['5'] === this.boxes['7'])) {
			this.declareWinner();
			return true;
		}
		if (this.markedCount === 9) {
			this.declareDraw();
			return true;
		}
	};

	TicTacToe.prototype.declareDraw = function () {
		var message = '|html|Draw between ' + this.p1.name + ' and ' + this.p2.name + '!
' + this.getGrid(true);
		this.players.forEach(function (user) {
			user.popup(message);
		});
		this.end();
	};

	TicTacToe.prototype.declareWinner = function () {
		var message = '|html|' + this.currentPlayer.name + ' has won the game!
' + this.getGrid(true);
		this.players.forEach(function (user) {
			user.popup(message);
		});
		this.end();
	};

	TicTacToe.prototype.end = function (message) {
		if (message) {
			if (this.phase === 'waiting') {
				message = '|pm|' + this.p2.getIdentity() + '|' + this.p1.getIdentity() + '|/error ' + message;
			} else message = '|popup|' + message;
			this.players.forEach(function (user) {
				user.send(message);
			});
		}
		clearTimeout(this.timer);
		delete tttplayers[this.p1.userid];
		delete tttplayers[this.p2.userid];
		delete tttgames[this.gameNo];
	};

	TicTacToe.prototype.resetTimer = function () {
		clearTimeout(this.timer);
		this.timer = setTimeout(this.end.bind(this, 'The game has been ended due to player inactivity.'), INACTIVE_KICK_TIME);
	};

	return TicTacToe;
})();

var cmds = {
	'': 'help',
	help: function (target, room, user) {
		if (!this.runBroadcast()) return;
		this.sendReplyBox('Tic-Tac-Toe commands
' +
			'
/ttt c User - Sends a user a request to play Tic-Tac-Toe. This can also be used in PMs. (Requests automatically expire if they\'re not accepted or declined within 1.5 minutes.)
' +
			'
/ttt accept User  - Accepts a Tic-Tac-Toe request from a user.
' +
			'
/ttt decline User - Declines a Tic-Tac-Toe request from a user.
' +
			'
/ttt see or /ttt show - Opens up the Tic-Tac-Toe board, in case you accidentally closed it out.
' +
			'
/ttt end - Exits the current game of Tic-Tac-Toe. Cancels a play request if the game hasn\'t been started yet. (Note: The game automatically ends after a user stays inactive for more than 30 seconds.)
'
		);
	},

	chall: 'c',
	challenge: 'c',
	play: 'c',
	c: function (target, room, user, connection, cmd) {
		if (!target || !target.trim()) return this.sendReply('|html|/ttt ' + cmd + ' User - Challenges a user to a game of Tic-Tac-Toe.');
		var targetUser = (Users.get(target) ? Users.get(target).name : target);
		target = Users.get(target);
		if (!target || !target.connected) return this.sendReply('User ' + targetUser + ' is offline.');
		if (user.userid === target.userid) return this.sendReply('You can\'t play Tic-Tac-Toe with yourself!');
		if (ttt.has(user)) {
			var game = ttt.get(user);
			if (game.phase === 'waiting') return this.sendReply('You have already challenged ' + game.checkPlayer(user) + ' to a game of Tic-Tac-Toe. Wait for their response.');
			if (game.checkPlayer(target)) return this.sendReply('You\'re playing Tic-Tac-Toe with ' + target.name + ' right now!');
			return this.sendReply('You are currently playing Tic-Tac-Toe with ' + game.checkPlayer(user) + '. You cannot send ' + target.name + ' a request.');
		}
		if (ttt.has(target)) {
			var game = ttt.get(target);
			if (game.checkPlayer(user)) return this.sendReply(game.checkPlayer(user) + ' has already sent you a Tic-Tac-Toe request...');
			return this.sendReply(target.name + ' has already challenged someone else to a game of Tic-Tac-Toe. Either wait for them to finish, or play with someone else.');
		}
		ttt.forEach(function (game) {
			if (game.checkPlayer(user)) return this.sendReply(game.checkPlayer(user) + ' sent you a request. Respond to that before challenging anyone else.');
			if (game.checkPlayer(target)) return this.sendReply(target.name + ' has already challenged someone else to a game of Tic-Tac-Toe. Either wait for them to finish, or play with someone else.');
		});
		target.send('|pm|' + user.getIdentity() + '|' + target.getIdentity() + '|/html ' + user.getIdentity() + ' wants to play Tic-Tac-Toe!
' +
			'<button name = "send" value = "/ttt accept ' + user.userid + '">Accept</button> <button name = "send" value = "/ttt decline ' + user.userid + '">Decline</button>'
		);
		user.send('|pm|' + target.getIdentity() + '|' + user.getIdentity() + '|/html You have challenged ' + target.getIdentity() + ' to a game of Tic-Tac-Toe. Waiting for their response...');
		ttt.set(user, new TicTacToe(user, target));
	},

	acc: 'accept',
	accept: function (target, room, user, connection, cmd) {
		if (!target || !target.trim()) return this.sendReply('|html|/ttt ' + cmd + ' User - Accepts a Tic-Tac-Toe challenge from a user.');
		var game = ttt.get(user);
		var targetUser = (Users.get(target) ? Users.get(target).name : target);
		target = Users.get(target);
		if (!target) return this.sendReply('User ' + targetUser + ' was not found. Did you misspell their name?');
		if (!target.connected) return this.sendReply('User ' + targetUser + ' is offline. Wait for them to come back online.');
		if (ttt.has(user)) {
			if (game.phase === 'waiting') return this.sendReply('You have already challenged ' + game.checkPlayer(user) + ' to a game of Tic-Tac-Toe. You cannot accept ' + target.name + '\'s challenge.');
			if (game.checkPlayer(target)) return this.sendReply('You\'re playing Tic-Tac-Toe with ' + game.checkPlayer(user) + ' right now!');
			return this.sendReply('You are currently playing Tic-Tac-Toe with ' + game.checkPlayer(user) + '. You cannot accept ' + target.name + '\'s challenge.');
		}
		if (user.userid === target.userid) return this.sendReply('You can\'t accept a challenge from yourself!');
		if (!ttt.has(target)) return this.sendReply(target.name + ' has not challenged you to a game of Tic-Tac-Toe.');

		game = ttt.get(target);
		if (game.p2 !== user) return this.sendReply(target.name + ' has not challenged you to a game of Tic-Tac-Toe.');
		ttt.set(user, ttt.get(target));
		game.accept();
	},

	dec: 'decline',
	decline: function (target, room, user, connection, cmd) {
		if (!target || !target.trim()) return this.sendReply('|html|/ttt ' + cmd + ' User - Declines a Tic-Tac-Toe challenge from a user.');
		var targetUser = (Users.get(target) ? Users.get(target).name : target);
		target = Users.get(target);
		if (!target || !target.connected) return this.sendReply('User ' + targetUser + ' is offline.');
		if (user.userid === target.userid) return this.sendReply('You can\'t use this command on yourself.');
		var game = ttt.get(target);
		if (!game || !game.checkPlayer(user))  return this.sendReply(target + ' has not challenged you to a game of Tic-Tac-Toe.');
		if (game.checkPlayer(user) && game.phase == 'started') return this.sendReply('You are playing with ' + game.checkPlayer(user) + ' right now. If you want to end the game, use /ttt end.');

		game.end('The Tic-Tac-Toe challenge was declined.');
	},

	mark: 'markbox',
	markbox: function (target, room, user, connection, cmd) {
		if (!ttt.has(user)) return this.sendReply('You aren\'t playing a game of Tic-Tac-Toe right now.');
		var game = ttt.get(user);
		if (game.phase === 'waiting') return this.sendReply('Your request has not been accepted yet. You can only use this command in an active game.');
		game.markBox(user, target);
	},

	update: 'see',
	view: 'see',
	show: 'see',
	open: 'see',
	see: function (target, room, user) {
		if (!ttt.has(user)) return this.sendReply('You aren\'t playing a game of Tic-Tac-Toe right now...');
		var game = tttgames[tttplayers[user.userid]];
		if (game.phase === 'waiting') return this.sendReply('Your request has not been accepted yet. You can only use this command in an active game.');
		game.update();
	},

	exit: 'end',
	leave: 'end',
	end: function (target, room, user) {
		if (!ttt.has(user)) return this.sendReply('You aren\'t playing a game of Tic-Tac-Toe right now...');
		var game = ttt.get(user);
		if (game.phase === 'waiting') game.end('The Tic-Tac-Toe challenge was withdrawn.');
		else game.end(user.name + ' has decided to leave the game midway.');
	}
};

exports.commands = {
	ttt: 'tictactoe',
	tictactoe: cmds,
	tttend: 'endttt',
	endttt: cmds.end
}


text:
from .common import generic_url_role

def readthedocs_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
    """Role for linking to readthedocs.org page.

    :rtd:`django-pipeline` ->
       link: https://django-pipeline.readthedocs.io/
       text: django-pipeline

    :rtd:`a rtd site <django-pipeline>` ->
       link: https://django-pipeline.readthedocs.io/
       text: a rtd site

    :rtd:`python-guide:dev/virtualenvs` ->
       link: https://python-guide.readthedocs.io/en/latest/dev/virtualenvs/
       text: python-guide:dev/virtualenvs

    :rtd:`about virtualenvs <python-guide:dev/virtualenvs>` ->
       link: https://python-guide.readthedocs.io/en/latest/dev/virtualenvs/
       text: about virtalenvs
    """

    def url_handler(target):
        if ":" in target:
            project, path = target.split(":")
            return "https://{project}.readthedocs.io/en/latest/{path}".format(
                project=project, path=path
            )
        return f"https://{target}.readthedocs.io"

    return generic_url_role(name, text, url_handler)


text:
dotfiles
========

My dotfiles


text:
import React from 'react';
import { connect } from 'react-redux';
import moment from 'moment';
import { createSelector } from 'reselect';
import PropTypes from 'prop-types';

import { get, actions } from '../../store';

import { translate as $t, localeComparator } from '../../helpers';

import BudgetListItem from './item';
import withCurrentAccountId from '../withCurrentAccountId';

class Budget extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            showBudgetWithoutThreshold: this.props.displayNoThreshold,
            displayInPercent: this.props.displayPercent
        };
    }

    handleChange = event => {
        let period = event.currentTarget.value.split('-');
        this.props.setPeriod(parseInt(period[0], 10), parseInt(period[1], 10));
    };

    handleToggleWithoutThreshold = () => {
        let newValue = !this.state.showBudgetWithoutThreshold;
        this.props.updateDisplayNoThreshold(newValue);
        this.setState({
            showBudgetWithoutThreshold: newValue
        });
    };

    handleTogglePercentDisplay = () => {
        let newValue = !this.state.displayInPercent;
        this.props.updateDisplayPercent(newValue);
        this.setState({
            displayInPercent: newValue
        });
    };

    showOperations = catId => {
        let periodDate = moment({ year: this.props.year, month: this.props.month, day: 1 });
        let fromDate = periodDate.toDate();
        let toDate = periodDate.endOf('month').toDate();
        this.props.showOperations(catId, fromDate, toDate);
    };

    componentDidMount() {
        if (!this.props.budgets) {
            this.props.fetchBudgets(this.props.year, this.props.month);
        }
    }

    render() {
        let sumAmounts = 0;
        let sumThresholds = 0;
        let remaining = '-';
        let items = null;

        if (this.props.budgets) {
            let periodDate = moment({ year: this.props.year, month: this.props.month, day: 1 });
            let fromDate = periodDate.toDate();
            let toDate = periodDate.endOf('month').toDate();

            let dateFilter = op => op.budgetDate >= fromDate && op.budgetDate <= toDate;
            let operations = this.props.operations.filter(dateFilter);

            let budgetsToShow = this.props.budgets;
            if (!this.state.showBudgetWithoutThreshold) {
                budgetsToShow = budgetsToShow.filter(budget => budget.threshold !== 0);
            }

            budgetsToShow = budgetsToShow.slice().sort((prev, next) => {
                return localeComparator(
                    this.props.categoriesNamesMap.get(prev.categoryId),
                    this.props.categoriesNamesMap.get(next.categoryId)
                );
            });

            items = budgetsToShow.map(budget => {
                let catOps = operations.filter(op => budget.categoryId === op.categoryId);
                let amount = catOps.reduce((acc, op) => acc + op.amount, 0);

                sumAmounts += amount;
                sumThresholds += budget.threshold;

                let key = `${budget.categoryId}${budget.year}${budget.month}`;

                return (
                    <BudgetListItem
                        key={key}
                        id={key}
                        budget={budget}
                        amount={parseFloat(amount.toFixed(2))}
                        updateBudget={this.props.updateBudget}
                        showOperations={this.showOperations}
                        displayInPercent={this.state.displayInPercent}
                        currentAccountId={this.props.currentAccountId}
                    />
                );
            });

            // Number.EPSILON would still be inferior to any rounding issue
            // since we make several additions so we use 0.000001.
            if (Math.abs(sumAmounts) <= 0.000001) {
                sumAmounts = 0;
            }

            if (Math.abs(sumThresholds) <= 0.000001) {
                sumThresholds = 0;
            }

            if (sumAmounts) {
                if (this.state.displayInPercent) {
                    if (sumThresholds) {
                        remaining = (100 * (sumAmounts - sumThresholds)) / sumThresholds;
                        remaining = `${remaining.toFixed(2)}%`;
                    } else {
                        remaining = '-';
                    }
                } else {
                    remaining = (sumAmounts - sumThresholds).toFixed(2);
                }
            }
        } else {
            items = (

            );
        }

        let currentDate = new Date();
        let currentYear = currentDate.getFullYear();
        let currentMonth = currentDate.getMonth();

        let months = this.props.periods.map(period => {
            let monthId = `${period.year}-${period.month}`;
            let label = '';

            if (period.month === currentMonth && period.year === currentYear) {
                label = $t('client.budget.this_month');
            } else {
                label = `${moment.months(period.month)} ${period.year}`;
            }

            return (
                <option value={monthId} key={monthId}>
                    {label}
                </option>
            );
        });

        return (

                <form>

                        {$t('client.budget.period')}:

                        <select
                            onChange={this.handleChange}
                            defaultValue={`${this.props.year}-${this.props.month}`}>
                            {months}
                        </select>

                            {$t('client.budget.show_categories_without_budget')}:
                            <input
                                type="checkbox"
                                onChange={this.handleToggleWithoutThreshold}
                                checked={this.state.showBudgetWithoutThreshold}
                            />

                            {$t('client.budget.display_in_percent')}:
                            <input
                                type="checkbox"
                                onChange={this.handleTogglePercentDisplay}
                                checked={this.state.displayInPercent}
                            />

                </form>

                            {$t('client.budget.category')}
                            {$t('client.budget.amount')}

                                {$t('client.budget.threshold')}

                            {$t('client.budget.difference')}

{items}

                            {$t('client.budget.total')}
                            {sumAmounts.toFixed(2)}

                                {sumThresholds.toFixed(2)}

                            {remaining}

        );
    }
}

Budget.propTypes = {
    // The current displayed year.
    year: PropTypes.number.isRequired,

    // The current displayed month.
    month: PropTypes.number.isRequired,

    // The list of budgets.
    budgets: PropTypes.array,

    // A map of categories with the id as key and the label as value.
    categoriesNamesMap: PropTypes.object,

    // The list of current operations.
    operations: PropTypes.array.isRequired,

    // The method to update a budget.
    updateBudget: PropTypes.func.isRequired,

    // A method to display the reports component inside the main app, pre-filled
    // with the year/month and category filters.
    showOperations: PropTypes.func.isRequired,

    // An array of the months/years tuples available since the first operation.
    periods: PropTypes.array.isRequired
};

const categoriesNamesSelector = createSelector(
    state => get.categoriesButNone(state),
    cats => {
        let categoriesNamesMap = new Map();
        for (let cat of cats) {
            categoriesNamesMap.set(cat.id, cat.label);
        }

        return categoriesNamesMap;
    }
);

const Export = connect(
    (state, ownProps) => {
        let { currentAccountId } = ownProps;

        let operations = get.operationsByAccountId(state, currentAccountId);
        let periods = [];
        let currentDate = new Date();
        if (operations.length) {
            let periodsSet = new Set();

            for (let operation of operations) {
                let { budgetDate } = operation;

                let month = budgetDate.getMonth();
                let year = budgetDate.getFullYear();
                if (!periodsSet.has(`${month}-${year}`)) {
                    periodsSet.add(`${month}-${year}`);
                    periods.push({ month, year });
                }
            }
        }

        // Always add the current month year as there might be no transactions at the beginning of
        // the month but the user might still want to set their budgets.
        let currentYear = currentDate.getFullYear();
        let currentMonth = currentDate.getMonth();
        if (!periods.some(p => p.month === currentMonth && p.year === currentYear)) {
            periods.push({
                month: currentMonth,
                year: currentYear
            });
        }

        // As the transactions are sorted by date, and the list is made of budget dates,
        // it may be necessary to sort the list in descending order.
        periods.sort((a, b) => {
            if (a.year !== b.year) {
                return a.year > b.year ? -1 : 1;
            }
            return a.month > b.month ? -1 : 1;
        });

        let displayPercent = get.boolSetting(state, 'budget-display-percent');
        let displayNoThreshold = get.boolSetting(state, 'budget-display-no-threshold');

        let { year: selectedYear, month: selectedMonth } = get.budgetSelectedPeriod(state);
        let budgets = get.budgetsFromSelectedPeriod(state);

        return {
            year: selectedYear,
            month: selectedMonth,
            budgets,
            categoriesNamesMap: categoriesNamesSelector(state),
            operations,
            periods,
            currentAccountId,
            displayPercent,
            displayNoThreshold
        };
    },
    dispatch => {
        return {
            setPeriod(year, month) {
                actions.setBudgetsPeriod(dispatch, year, month);
            },

            fetchBudgets(year, month) {
                actions.fetchBudgetsByYearMonth(dispatch, year, month);
            },

            updateBudget(former, newer) {
                actions.updateBudget(dispatch, former, newer);
            },

            showOperations(categoryId, fromDate, toDate) {
                actions.setSearchFields(dispatch, {
                    dateLow: +fromDate,
                    dateHigh: +toDate,
                    categoryIds: [categoryId]
                });
            },

            async updateDisplayPercent(newValue) {
                try {
                    await actions.setBoolSetting(dispatch, 'budget-display-percent', newValue);
                } catch (err) {
                    // TODO do something with it!
                }
            },

            async updateDisplayNoThreshold(newValue) {
                try {
                    await actions.setBoolSetting(dispatch, 'budget-display-no-threshold', newValue);
                } catch (err) {
                    // TODO do something with it!
                }
            }
        };
    }
)(Budget);

export default withCurrentAccountId(Export);


text:
<!DOCTYPE html>

  <title>Twitter Tweets Miner</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

  <link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" media="screen">
    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.0-rc.3/dist/leaflet.css" />

Twitter Relationship Miner

                <input class="form-control" type="text" id="username1" placeholder="Enter Username here" ng-model="username">
                 <input class="form-control" type="text" id="username2" placeholder="Enter Username here" ng-model="name2">

<button class="btn btn-primary" ng-click="getfriendships(username,name2)">Get Relationship</button>

<button class="btn btn-primary" ng-click="getSearchTweets(zip,username)">Get Tweets</button>

<button class="btn btn-primary" ng-click="saveTweets(results)">Save Tweets</button>

<button class="btn btn-primary" ng-click="searchLocalTweets(keyword)">Search Tweets Locally</button>

        {{twitterErrors}}

            {{key}}

            {{value}}


text:
<?php

namespace AlphaLabs\Bundle\PaginationBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;

class AlphaLabsPaginationExtension extends Extension
{
    /**
     * {@inheritDoc}
     */
    public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration, $configs);

        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

        $declarationFiles = ['pagination.xml'];

        foreach ($declarationFiles as $file) {
            $loader->load($file);
        }

        $this->configurePagination($config['pagination'], $container);
    }

    /**
     * {@inheritDoc}
     */
    public function getAlias()
    {
        return 'alphalabs_pagination';
    }

    /**
     * @param array            $config    Pagination configuration
     * @param ContainerBuilder $container Container
     */
    private function configurePagination(array $config, ContainerBuilder $container)
    {
        $container->setParameter('alphalabs_pagination.default_items_per_page', $config['items_per_page']);
        $container->setParameter('alphalabs_pagination.page_attribute_key', $config['page_attribute_key']);
        $container->setParameter('alphalabs_pagination.items_per_page_attribute_key', $config['items_per_page_attribute_key']);

        $requestBasedFactoryDefinition = $container->getDefinition(
            'alphalabs_pagination.paginated_collection_request.factory.request_based'
        );

        $requestBasedFactoryDefinition->replaceArgument(1, $config['items_per_page_attribute_key']);
        $requestBasedFactoryDefinition->replaceArgument(2, $config['page_attribute_key']);
    }
}


text:
import unittest
import sys
from datetime import datetime
import cProfile

sys.path.append("../src/")
from blowfish import Blowfish

class TestRunningTime(unittest.TestCase):
    def setUp(self):
        self.n = 1

    def test_ntimes(self):
        zero_key = bytearray(b'\x00' * Blowfish.keySize())
        self.cipher = Blowfish(zero_key)
        for i in range(self.n):
            self.test_once()

    def test_once(self):
        zero_block = bytearray(b'\x00' * Blowfish.blockSize())
        self.cipher.encrypt(zero_block)
        #print(zero_block)

if __name__ == "__main__":
    if len(sys.argv) < 2:
        print("Usage: python timetrial.py [number of trials]")
        sys.exit(1)
    else:
        x = TestRunningTime()
        x.setUp()
        x.n = int(sys.argv[1])
        cProfile.run('x.test_ntimes()')
        print('Done.')


text:
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: io/grpc/reflection/v1alpha/reflection.proto

package io.grpc.reflection.v1alpha;

public interface ErrorResponseOrBuilder extends
    // @@protoc_insertion_point(interface_extends:grpc.reflection.v1alpha.ErrorResponse)
    com.google.protobuf.MessageOrBuilder {

  /**
   *

   * This field uses the error codes defined in grpc::StatusCode.
   *

   *
   * int32 error_code = 1;
   */
  int getErrorCode();

  /**
   * string error_message = 2;
   */
  java.lang.String getErrorMessage();
  /**
   * string error_message = 2;
   */
  com.google.protobuf.ByteString
      getErrorMessageBytes();
}


text:
<?php

class EFancyBox extends CWidget
{
	// @ string the id of the widget, since version 1.6
	public $id;
	// @ string the taget element on DOM
	public $target;
	// @ boolean whether to enable the easing functions. You must set the eansing on $config.
	public $easingEnabled=false;
	// @ boolean whether to enable mouse interaction
	public $mouseEnabled=true;
	// @ array of config settings for fancybox
	public $config=array();

	// function to init the widget
	public function init()
	{
		// if not informed will generate Yii defaut generated id, since version 1.6
		if(!isset($this->id))
			$this->id=$this->getId();
		// publish the required assets
		$this->publishAssets();
	}

	// function to run the widget
    public function run()
    {
		$config = CJavaScript::encode($this->config);
		Yii::app()->clientScript->registerScript($this->getId(), "
			$('$this->target').fancybox($config);
		");
	}

	// function to publish and register assets on page
	public function publishAssets()
	{
		$assets = dirname(__FILE__).'/assets';
		$baseUrl = Yii::app()->assetManager->publish($assets);
		if(is_dir($assets)){
			Yii::app()->clientScript->registerCoreScript('jquery');
			Yii::app()->clientScript->registerScriptFile($baseUrl . '/jquery.fancybox-1.3.4.pack.js', CClientScript::POS_HEAD);
			Yii::app()->clientScript->registerCssFile($baseUrl . '/jquery.fancybox-1.3.4.css');
			// if mouse actions enbled register the js
			if ($this->mouseEnabled) {
				Yii::app()->clientScript->registerScriptFile($baseUrl . '/jquery.mousewheel-3.0.4.pack.js', CClientScript::POS_HEAD);
			}
			// if easing enbled register the js
			if ($this->easingEnabled) {
				Yii::app()->clientScript->registerScriptFile($baseUrl . '/jquery.easing-1.3.pack.js', CClientScript::POS_HEAD);
			}
		} else {
			throw new Exception('EFancyBox - Error: Couldn\'t find assets to publish.');
		}
	}
}