text:
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2020 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITCOIN_PRIMITIVES_TRANSACTION_H
#define BITCOIN_PRIMITIVES_TRANSACTION_H

#include <stdint.h>
#include <amount.h>
#include <script/script.h>
#include <serialize.h>
#include <uint256.h>
#include <primitives/confidential.h>
#include <primitives/txwitness.h>

#include <tuple>

/**
 * A flag that is ORed into the protocol version to designate that a transaction
 * should be (un)serialized without witness data.
 * Make sure that this does not collide with any of the values in `version.h`
 * or with `ADDRV2_FORMAT`.
 */
static const int SERIALIZE_TRANSACTION_NO_WITNESS = 0x40000000;

// ELEMENTS:
// Globals to avoid circular dependencies.
extern bool g_con_elementsmode;

/** An outpoint - a combination of a transaction hash and an index n into its vout */
class COutPoint
{
public:
    uint256 hash;
    uint32_t n;

    //
    // ELEMENTS flags:

    /* If this flag is set, the CTxIn including this COutPoint has a
     * CAssetIssuance object. */
    static const uint32_t OUTPOINT_ISSUANCE_FLAG = (1 << 31);

    /* If this flag is set, the CTxIn including this COutPoint
     * is a peg-in input. */
    static const uint32_t OUTPOINT_PEGIN_FLAG = (1 << 30);

    /* The inverse of the combination of the preceding flags. Used to
     * extract the original meaning of `n` as the index into the
     * transaction's output array. */
    static const uint32_t OUTPOINT_INDEX_MASK = 0x3fffffff;

    // END ELEMENTS
    //

    static constexpr uint32_t NULL_INDEX = std::numeric_limits<uint32_t>::max();

    COutPoint(): n(NULL_INDEX) { }
    COutPoint(const uint256& hashIn, uint32_t nIn): hash(hashIn), n(nIn) { }

    SERIALIZE_METHODS(COutPoint, obj) { READWRITE(obj.hash, obj.n); }

    void SetNull() { hash.SetNull(); n = NULL_INDEX; }
    bool IsNull() const { return (hash.IsNull() && n == NULL_INDEX); }

    friend bool operator<(const COutPoint& a, const COutPoint& b)
    {
        int cmp = a.hash.Compare(b.hash);
        return cmp < 0 || (cmp == 0 && a.n < b.n);
    }

    friend bool operator==(const COutPoint& a, const COutPoint& b)
    {
        return (a.hash == b.hash && a.n == b.n);
    }

    friend bool operator!=(const COutPoint& a, const COutPoint& b)
    {
        return !(a == b);
    }

    std::string ToString() const;
};

/** An input of a transaction.  It contains the location of the previous
 * transaction's output that it claims and a signature that matches the
 * output's public key.
 */
class CTxIn
{
public:
    COutPoint prevout;
    CScript scriptSig;
    uint32_t nSequence;

    //
    // ELEMENTS:

    CAssetIssuance assetIssuance;

    /* If this is set to true, the input is interpreted as a
     * peg-in claim and processed as such */
    bool m_is_pegin = false;

    // END ELEMENTS
    //

    /* Setting nSequence to this value for every input in a transaction
     * disables nLockTime. */
    static const uint32_t SEQUENCE_FINAL = 0xffffffff;

    /* Below flags apply in the context of BIP 68*/
    /* If this flag set, CTxIn::nSequence is NOT interpreted as a
     * relative lock-time. */
    static const uint32_t SEQUENCE_LOCKTIME_DISABLE_FLAG = (1U << 31);

    /* If CTxIn::nSequence encodes a relative lock-time and this flag
     * is set, the relative lock-time has units of 512 seconds,
     * otherwise it specifies blocks with a granularity of 1. */
    static const uint32_t SEQUENCE_LOCKTIME_TYPE_FLAG = (1 << 22);

    /* If CTxIn::nSequence encodes a relative lock-time, this mask is
     * applied to extract that lock-time from the sequence field. */
    static const uint32_t SEQUENCE_LOCKTIME_MASK = 0x0000ffff;

    /* In order to use the same number of bits to encode roughly the
     * same wall-clock duration, and because blocks are naturally
     * limited to occur every 600s on average, the minimum granularity
     * for time-based relative lock-time is fixed at 512 seconds.
     * Converting from CTxIn::nSequence to seconds is performed by
     * multiplying by 512 = 2^9, or equivalently shifting up by
     * 9 bits. */
    static const int SEQUENCE_LOCKTIME_GRANULARITY = 9;

    CTxIn()
    {
        nSequence = SEQUENCE_FINAL;
    }

    explicit CTxIn(COutPoint prevoutIn, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=SEQUENCE_FINAL);
    CTxIn(uint256 hashPrevTx, uint32_t nOut, CScript scriptSigIn=CScript(), uint32_t nSequenceIn=SEQUENCE_FINAL);

    // ELEMENTS: explicit serialization methods for selective asset/pegin encoding
    template <typename Stream>
    inline void Serialize(Stream& s) const {
        bool fHasAssetIssuance;
        COutPoint outpoint;
        if (!g_con_elementsmode || prevout.n == (uint32_t) -1) {
            // Coinbase inputs do not have asset issuances attached
            // to them.
            fHasAssetIssuance = false;
            outpoint = prevout;
        } else {
            // The issuance and pegin bits can't be set as it is used to indicate
            // the presence of the asset issuance or pegin objects. They should
            // never be set anyway as that would require a parent
            // transaction with over one billion outputs.
            assert(!(prevout.n & ~COutPoint::OUTPOINT_INDEX_MASK));
            // The assetIssuance object is used to represent both new
            // asset generation and reissuance of existing asset types.
            fHasAssetIssuance = !assetIssuance.IsNull();
            // The mode is placed in the upper bits of the outpoint's
            // index field. The IssuanceMode enum values are chosen to
            // make this as simple as a bitwise-OR.
            outpoint.hash = prevout.hash;
            outpoint.n = prevout.n & COutPoint::OUTPOINT_INDEX_MASK;
            if (fHasAssetIssuance) {
                outpoint.n |= COutPoint::OUTPOINT_ISSUANCE_FLAG;
            }
            if (m_is_pegin) {
                outpoint.n |= COutPoint::OUTPOINT_PEGIN_FLAG;
            }
        }

        // These are the same as bitcoin...
        s << outpoint;
        s << scriptSig;
        s << nSequence;
        // ...but then we add asset issuance data for issuances
        if (fHasAssetIssuance) {
            s << assetIssuance;
        }
    }

    template <typename Stream>
    inline void Unserialize(Stream& s) {
        bool fHasAssetIssuance;
        COutPoint outpoint;
        s >> outpoint;

        if (!g_con_elementsmode || outpoint.n == (uint32_t) -1) {
            // No asset issuance for Coinbase inputs.
            fHasAssetIssuance = false;
            prevout = outpoint;
            m_is_pegin = false;
        } else {
            // The presence of the asset issuance object is indicated by
            // a bit set in the outpoint index field.
            fHasAssetIssuance = !!(outpoint.n & COutPoint::OUTPOINT_ISSUANCE_FLAG);
            // The interpretation of this input as a peg-in is indicated by
            // a bit set in the outpoint index field.
            m_is_pegin = !!(outpoint.n & COutPoint::OUTPOINT_PEGIN_FLAG);
            // The mode, if set, must be masked out of the outpoint so
            // that the in-memory index field retains its traditional
            // meaning of identifying the index into the output array
            // of the previous transaction.
            prevout.hash = outpoint.hash;
            prevout.n = outpoint.n & COutPoint::OUTPOINT_INDEX_MASK;
        }

        s >> scriptSig;
        s >> nSequence;

        if (fHasAssetIssuance) {
            s >> assetIssuance;
            if (assetIssuance.IsNull()) {
                throw std::ios_base::failure("Superfluous issuance record");
            }
        } else {
            assetIssuance.SetNull();
        }
    }

    friend bool operator==(const CTxIn& a, const CTxIn& b)
    {
        return (a.prevout   == b.prevout &&
                a.scriptSig == b.scriptSig &&
                a.nSequence     == b.nSequence &&
                a.assetIssuance == b.assetIssuance);
    }

    friend bool operator!=(const CTxIn& a, const CTxIn& b)
    {
        return !(a == b);
    }

    std::string ToString() const;
};

/** An output of a transaction.  It contains the public key that the next input
 * must be able to sign with to claim it.
 */
class CTxOut
{
public:
    CConfidentialAsset nAsset;
    CConfidentialValue nValue;
    CConfidentialNonce nNonce;
    CScript scriptPubKey;

    CTxOut()
    {
        SetNull();
    }

    CTxOut(const CConfidentialAsset& nAssetIn, const CConfidentialValue& nValueIn, CScript scriptPubKeyIn);

    // ELEMENTS: explicit serialization methods for different g_con_elementsmode serializations
    template <typename Stream>
    inline void Serialize(Stream& s) const {
        if (g_con_elementsmode) {
            s << nAsset;
            s << nValue;
            s << nNonce;
        } else {
            s << nValue.GetAmount();
        }
        s << scriptPubKey;
    }

    template <typename Stream>
    inline void Unserialize(Stream& s) {
        if (g_con_elementsmode) {
            s >> nAsset;
            s >> nValue;
            s >> nNonce;
        } else {
            CAmount value;
            s >> value;
            nValue.SetToAmount(value);
        }
        s >> scriptPubKey;
    }

    void SetNull()
    {
        nAsset.SetNull();
        nValue.SetNull();
        nNonce.SetNull();
        scriptPubKey.clear();
    }

    bool IsNull() const
    {
        if (!g_con_elementsmode) {
            // Ignore the asset and the nonce in compatibility mode.
            return nValue.IsNull() && scriptPubKey.empty();
        }

        return nAsset.IsNull() && nValue.IsNull() && nNonce.IsNull() && scriptPubKey.empty();
    }

    bool IsFee() const {
        return g_con_elementsmode && scriptPubKey == CScript()
            && nValue.IsExplicit() && nAsset.IsExplicit();
    }

    friend bool operator==(const CTxOut& a, const CTxOut& b)
    {
        return (a.nAsset == b.nAsset &&
                a.nValue == b.nValue &&
                a.nNonce == b.nNonce &&
                a.scriptPubKey == b.scriptPubKey);
    }

    friend bool operator!=(const CTxOut& a, const CTxOut& b)
    {
        return !(a == b);
    }

    std::string ToString() const;

    friend bool operator<(const CTxOut& a, const CTxOut& b)
    {
        return a.scriptPubKey < b.scriptPubKey;
    }
};

struct CMutableTransaction;

/**
 * Basic transaction serialization format:
 * - int32_t nVersion
 * - std::vector<CTxIn> vin
 * - std::vector<CTxOut> vout
 * - uint32_t nLockTime
 *
 * Extended transaction serialization format:
 * - int32_t nVersion
 * - unsigned char dummy = 0x00
 * - unsigned char flags (!= 0)
 * - std::vector<CTxIn> vin
 * - std::vector<CTxOut> vout
 * - if (flags & 1):
 *   - CTxWitness wit;
 * - uint32_t nLockTime
 */
template<typename Stream, typename TxType>
inline void UnserializeTransaction(TxType& tx, Stream& s) {

    s >> tx.nVersion;
    unsigned char flags = 0;
    tx.vin.clear();
    tx.vout.clear();
    tx.witness.SetNull();

    // Witness serialization is different between Elements and Core.
    // See code comments in SerializeTransaction for details about the differences.
    if (g_con_elementsmode) {
        s >> flags;
        s >> tx.vin;
        s >> tx.vout;
        s >> tx.nLockTime;
        if (flags & 1) {
            /* The witness flag is present. */
            flags ^= 1;
            tx.witness.vtxinwit.resize(tx.vin.size());
            tx.witness.vtxoutwit.resize(tx.vout.size());
            s >> tx.witness;
            if (!tx.HasWitness()) {
                /* It's illegal to encode witnesses when all witness stacks are empty. */
                throw std::ios_base::failure("Superfluous witness record");
            }
        }
    } else {
        const bool fAllowWitness = !(s.GetVersion() & SERIALIZE_TRANSACTION_NO_WITNESS);

        /* Try to read the vin. In case the dummy is there, this will be read as an empty vector. */
        s >> tx.vin;
        if (tx.vin.size() == 0 && fAllowWitness) {
            /* We read a dummy or an empty vin. */
            s >> flags;
            if (flags != 0) {
                s >> tx.vin;
                s >> tx.vout;
            }
        } else {
            /* We read a non-empty vin. Assume a normal vout follows. */
            s >> tx.vout;
        }

        if ((flags & 1) && fAllowWitness) {
            /* The witness flag is present. */
            flags ^= 1;
            tx.witness.vtxinwit.resize(tx.vin.size());
            tx.witness.vtxoutwit.resize(tx.vout.size());
            for (size_t i = 0; i < tx.vin.size(); i++) {
                s >> tx.witness.vtxinwit[i].scriptWitness.stack;
                // ELEMENTS:
                if (tx.vin[i].m_is_pegin) {
                    s >> tx.witness.vtxinwit[i].m_pegin_witness.stack;
                }
            }

            if (!tx.HasWitness()) {
                /* It's illegal to encode witnesses when all witness stacks are empty. */
                throw std::ios_base::failure("Superfluous witness record");
            }
        }
        s >> tx.nLockTime;
    }

    if (flags) {
        /* Unknown flag in the serialization */
        throw std::ios_base::failure("Unknown transaction optional data");
    }
}

template<typename Stream, typename TxType>
inline void SerializeTransaction(const TxType& tx, Stream& s) {
    const bool fAllowWitness = !(s.GetVersion() & SERIALIZE_TRANSACTION_NO_WITNESS);

    s << tx.nVersion;

    // Consistency check
    assert(tx.witness.vtxinwit.size() <= tx.vin.size());
    assert(tx.witness.vtxoutwit.size() <= tx.vout.size());

    // Check whether witnesses need to be serialized.
    unsigned char flags = 0;
    if (fAllowWitness && tx.HasWitness()) {
        flags |= 1;
    }

    // Witness serialization is different between Elements and Core.
    if (g_con_elementsmode) {
        // In Elements-style serialization, all normal data is serialized first and the
        // witnesses all in the end.
        s << flags;
        s << tx.vin;
        s << tx.vout;
        s << tx.nLockTime;
        if (flags & 1) {
            const_cast<CTxWitness*>(&tx.witness)->vtxinwit.resize(tx.vin.size());
            const_cast<CTxWitness*>(&tx.witness)->vtxoutwit.resize(tx.vout.size());
            s << tx.witness;
        }
    } else {
        // In Core-style serialization, we encode the input dummy and the witnesses
        // follow the outputs before the nLockTime.

        if (flags) {
            /* Use extended format in case witnesses are to be serialized. */
            std::vector<CTxIn> vinDummy;
            s << vinDummy;
            s << flags;
        }
        s << tx.vin;
        s << tx.vout;

        if (flags & 1) {
            const_cast<CTxWitness*>(&tx.witness)->vtxinwit.resize(tx.vin.size());
            const_cast<CTxWitness*>(&tx.witness)->vtxoutwit.resize(tx.vout.size());
            for (size_t i = 0; i < tx.vin.size(); i++) {
                s << tx.witness.vtxinwit[i].scriptWitness.stack;
                // ELEMENTS:
                if (tx.vin[i].m_is_pegin) {
                    s << tx.witness.vtxinwit[i].m_pegin_witness.stack;
                }
            }
        }
        s << tx.nLockTime;
    }
}

/** The basic transaction that is broadcasted on the network and contained in
 * blocks.  A transaction can contain multiple inputs and outputs.
 */
class CTransaction
{
public:
    // Default transaction version.
    static const int32_t CURRENT_VERSION;

    // The local variables are made const to prevent unintended modification
    // without updating the cached hash value. However, CTransaction is not
    // actually immutable; deserialization and assignment are implemented,
    // and bypass the constness. This is safe, as they update the entire
    // structure, including the hash.
    const std::vector<CTxIn> vin;
    const std::vector<CTxOut> vout;
    const int32_t nVersion;
    const uint32_t nLockTime;
    // For elements we need to keep track of some extra state for script witness outside of vin
    const CTxWitness witness;

private:
    /** Memory only. */
    const uint256 hash;
    const uint256 m_witness_hash;

    uint256 ComputeHash() const;
    uint256 ComputeWitnessHash() const;

public:
    /** Convert a CMutableTransaction into a CTransaction. */
    explicit CTransaction(const CMutableTransaction& tx);
    CTransaction(CMutableTransaction&& tx);

    template <typename Stream>
    inline void Serialize(Stream& s) const {
        SerializeTransaction(*this, s);
    }

    /** This deserializing constructor is provided instead of an Unserialize method.
     *  Unserialize is not possible, since it would require overwriting const fields. */
    template <typename Stream>
    CTransaction(deserialize_type, Stream& s) : CTransaction(CMutableTransaction(deserialize, s)) {}

    bool IsNull() const {
        return vin.empty() && vout.empty();
    }

    const uint256& GetHash() const { return hash; }
    const uint256& GetWitnessHash() const { return m_witness_hash; };
    // ELEMENTS: the witness only hash used in elements witness roots
    uint256 GetWitnessOnlyHash() const;

    // Return sum of txouts.
    CAmountMap GetValueOutMap() const;

    /**
     * Get the total transaction size in bytes, including witness data.
     * "Total Size" defined in BIP141 and BIP144.
     * @return Total transaction size in bytes
     */
    unsigned int GetTotalSize() const;

    bool IsCoinBase() const
    {
        return (vin.size() == 1 && vin[0].prevout.IsNull());
    }

    friend bool operator==(const CTransaction& a, const CTransaction& b)
    {
        return a.hash == b.hash;
    }

    friend bool operator!=(const CTransaction& a, const CTransaction& b)
    {
        return a.hash != b.hash;
    }

    std::string ToString() const;

    bool HasWitness() const
    {
        return !witness.IsNull();
    }
};

/** A mutable version of CTransaction. */
struct CMutableTransaction
{
    std::vector<CTxIn> vin;
    std::vector<CTxOut> vout;
    int32_t nVersion;
    uint32_t nLockTime;
    // For elements we need to keep track of some extra state for script witness outside of vin
    CTxWitness witness;

    CMutableTransaction();
    explicit CMutableTransaction(const CTransaction& tx);

    template <typename Stream>
    inline void Serialize(Stream& s) const {
        SerializeTransaction(*this, s);
    }

    template <typename Stream>
    inline void Unserialize(Stream& s) {
        UnserializeTransaction(*this, s);
    }

    template <typename Stream>
    CMutableTransaction(deserialize_type, Stream& s) {
        Unserialize(s);
    }

    /** Compute the hash of this CMutableTransaction. This is computed on the
     * fly, as opposed to GetHash() in CTransaction, which uses a cached result.
     */
    uint256 GetHash() const;

    bool HasWitness() const
    {
        return !witness.IsNull();
    }
};

typedef std::shared_ptr<const CTransaction> CTransactionRef;
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }

/** A generic txid reference (txid or wtxid). */
class GenTxid
{
    bool m_is_wtxid;
    uint256 m_hash;
public:
    GenTxid(bool is_wtxid, const uint256& hash) : m_is_wtxid(is_wtxid), m_hash(hash) {}
    bool IsWtxid() const { return m_is_wtxid; }
    const uint256& GetHash() const { return m_hash; }
    friend bool operator==(const GenTxid& a, const GenTxid& b) { return a.m_is_wtxid == b.m_is_wtxid && a.m_hash == b.m_hash; }
    friend bool operator<(const GenTxid& a, const GenTxid& b) { return std::tie(a.m_is_wtxid, a.m_hash) < std::tie(b.m_is_wtxid, b.m_hash); }
};

#endif // BITCOIN_PRIMITIVES_TRANSACTION_H


text:
$packageName = 'exiftool'
$url = 'http://owl.phy.queensu.ca/~phil/exiftool/exiftool-10.36.zip'
$checksum = '09af0acb49c006a307b002117424a38d9a81c1df'
$checksumType = 'sha1'
$url64 = "$url"
$checksum64 = "$checksum"
$checksumType64 = "$checksumType"
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"

Install-ChocolateyZipPackage -PackageName "$packageName" `
                             -Url "$url" `
                             -UnzipLocation "$toolsDir" `
                             -Url64bit "$url64" `
                             -Checksum "$checksum" `
                             -ChecksumType "$checksumType" `
                             -Checksum64 "$checksum64" `
                             -ChecksumType64 "$checksumType64"

Move-Item "$(Join-Path $toolsDir 'exiftool(-k).exe')" "$(Join-Path $toolsDir 'exiftool.exe')" -Force

redpajama_set_name: RedPajamaGithub


text:
#ifndef ANDROID_UNICODE_H
#define ANDROID_UNICODE_H

#include <sys/types.h>
#include <stdint.h>

extern "C" {

// Standard string functions on char16_t strings.
int strcmp16(const char16_t *, const char16_t *);
int strncmp16(const char16_t *s1, const char16_t *s2, size_t n);
size_t strlen16(const char16_t *);
size_t strnlen16(const char16_t *, size_t);
char16_t *strcpy16(char16_t *, const char16_t *);
char16_t *strncpy16(char16_t *, const char16_t *, size_t);
char16_t *strstr16(const char16_t*, const char16_t*);

// Version of comparison that supports embedded NULs.
// This is different than strncmp() because we don't stop
// at a nul character and consider the strings to be different
// if the lengths are different (thus we need to supply the
// lengths of both strings).  This can also be used when
// your string is not nul-terminated as it will have the
// equivalent result as strcmp16 (unlike strncmp16).
int strzcmp16(const char16_t *s1, size_t n1, const char16_t *s2, size_t n2);

// Version of strzcmp16 for comparing strings in different endianness.
int strzcmp16_h_n(const char16_t *s1H, size_t n1, const char16_t *s2N, size_t n2);

// Standard string functions on char32_t strings.
size_t strlen32(const char32_t *);
size_t strnlen32(const char32_t *, size_t);

/**
 * Measure the length of a UTF-32 string in UTF-8. If the string is invalid
 * such as containing a surrogate character, -1 will be returned.
 */
ssize_t utf32_to_utf8_length(const char32_t *src, size_t src_len);

/**
 * Stores a UTF-8 string converted from "src" in "dst", if "dst_length" is not
 * large enough to store the string, the part of the "src" string is stored
 * into "dst" as much as possible. See the examples for more detail.
 * Returns the size actually used for storing the string.
 * dst" is not nul-terminated when dst_len is fully used (like strncpy).
 *
 * \code
 * Example 1
 * "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84)
 * "src_len" == 2
 * "dst_len" >= 7
 * ->
 * Returned value == 6
 * "dst" becomes \xE3\x81\x82\xE3\x81\x84\0
 * (note that "dst" is nul-terminated)
 *
 * Example 2
 * "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84)
 * "src_len" == 2
 * "dst_len" == 5
 * ->
 * Returned value == 3
 * "dst" becomes \xE3\x81\x82\0
 * (note that "dst" is nul-terminated, but \u3044 is not stored in "dst"
 * since "dst" does not have enough size to store the character)
 *
 * Example 3
 * "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84)
 * "src_len" == 2
 * "dst_len" == 6
 * ->
 * Returned value == 6
 * "dst" becomes \xE3\x81\x82\xE3\x81\x84
 * (note that "dst" is NOT nul-terminated, like strncpy)
 * \endcode
 */
void utf32_to_utf8(const char32_t* src, size_t src_len, char* dst, size_t dst_len);

/**
 * Returns the unicode value at "index".
 * Returns -1 when the index is invalid (equals to or more than "src_len").
 * If returned value is positive, it is able to be converted to char32_t, which
 * is unsigned. Then, if "next_index" is not NULL, the next index to be used is
 * stored in "next_index". "next_index" can be NULL.
 */
int32_t utf32_from_utf8_at(const char *src, size_t src_len, size_t index, size_t *next_index);

/**
 * Returns the UTF-8 length of UTF-16 string "src".
 */
ssize_t utf16_to_utf8_length(const char16_t *src, size_t src_len);

/**
 * Converts a UTF-16 string to UTF-8. The destination buffer must be large
 * enough to fit the UTF-16 as measured by utf16_to_utf8_length with an added
 * NUL terminator.
 */
void utf16_to_utf8(const char16_t* src, size_t src_len, char* dst, size_t dst_len);

/**
 * Returns the length of "src" when "src" is valid UTF-8 string.
 * Returns 0 if src is NULL or 0-length string. Returns -1 when the source
 * is an invalid string.
 *
 * This function should be used to determine whether "src" is valid UTF-8
 * characters with valid unicode codepoints. "src" must be nul-terminated.
 *
 * If you are going to use other utf8_to_... functions defined in this header
 * with string which may not be valid UTF-8 with valid codepoint (form 0 to
 * 0x10FFFF), you should use this function before calling others, since the
 * other functions do not check whether the string is valid UTF-8 or not.
 *
 * If you do not care whether "src" is valid UTF-8 or not, you should use
 * strlen() as usual, which should be much faster.
 */
ssize_t utf8_length(const char *src);

/**
 * Measure the length of a UTF-32 string.
 */
size_t utf8_to_utf32_length(const char *src, size_t src_len);

/**
 * Stores a UTF-32 string converted from "src" in "dst". "dst" must be large
 * enough to store the entire converted string as measured by
 * utf8_to_utf32_length plus space for a NUL terminator.
 */
void utf8_to_utf32(const char* src, size_t src_len, char32_t* dst);

/**
 * Returns the UTF-16 length of UTF-8 string "src". Returns -1 in case
 * it's invalid utf8. No buffer over-read occurs because of bound checks. Using overreadIsFatal you
 * can ask to log a message and fail in case the invalid utf8 could have caused an override if no
 * bound checks were used (otherwise -1 is returned).
 */
ssize_t utf8_to_utf16_length(const uint8_t* src, size_t srcLen, bool overreadIsFatal = false);

/**
 * Convert UTF-8 to UTF-16 including surrogate pairs.
 * Returns a pointer to the end of the string (where a NUL terminator might go
 * if you wanted to add one). At most dstLen characters are written; it won't emit half a surrogate
 * pair. If dstLen == 0 nothing is written and dst is returned. If dstLen > SSIZE_MAX it aborts
 * (this being probably a negative number returned as an error and casted to unsigned).
 */
char16_t* utf8_to_utf16_no_null_terminator(
        const uint8_t* src, size_t srcLen, char16_t* dst, size_t dstLen);

/**
 * Convert UTF-8 to UTF-16 including surrogate pairs. At most dstLen - 1
 * characters are written; it won't emit half a surrogate pair; and a NUL terminator is appended
 * after. dstLen - 1 can be measured beforehand using utf8_to_utf16_length. Aborts if dstLen == 0
 * (at least one character is needed for the NUL terminator) or dstLen > SSIZE_MAX (the latter
 * case being likely a negative number returned as an error and casted to unsigned) . Returns a
 * pointer to the NUL terminator.
 */
char16_t *utf8_to_utf16(
        const uint8_t* src, size_t srcLen, char16_t* dst, size_t dstLen);

}

#endif


text:
"use strict";
var _ = require("lodash");

module.exports = function(data) {
    var posts     = data.data.children;
    var last_post = _.last(posts);
    var author    = last_post.data.author;

    return author;
};


text:
var Obscure = Document.progeny('Obscure', {
}, {
  classMethods: {
  }
});

module.exports = Obscure;


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<artifactId>em-core</artifactId>
	<packaging>jar</packaging>

	<name>em-core</name>
	<description>Core of em</description>

	<parent>
		<groupId>com.mbrull</groupId>
		<artifactId>em</artifactId>
		<version>0.0.1-SNAPSHOT</version>
	</parent>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<java.version>1.8</java.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>com.mbrull</groupId>
			<artifactId>em-persistence</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>

		<dependency>
			<groupId>com.mbrull</groupId>
			<artifactId>em-commons</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>

		<dependency>
			<groupId>javax.validation</groupId>
			<artifactId>validation-api</artifactId>
			<version>1.1.0.Final</version>
		</dependency>

	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-failsafe-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

</project>


text:
package alluxio.master;

import alluxio.Constants;
import alluxio.ServiceUtils;
import alluxio.util.CommonUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;

/**
 * This class encapsulates the different master services that are configured to run.
 */
final class MasterUtils {
  private MasterUtils() {}  // prevent instantiation

  /**
   * Creates all the masters and registers them to the master registry.
   *
   * @param registry the master registry
   * @param context master context
   */
  public static void createMasters(MasterRegistry registry, MasterContext context) {
    List<Callable<Void>> callables = new ArrayList<>();
    for (final MasterFactory factory : ServiceUtils.getMasterServiceLoader()) {
      callables.add(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
          if (factory.isEnabled()) {
            factory.create(registry, context);
          }
          return null;
        }
      });
    }
    try {
      CommonUtils.invokeAll(callables, 10 * Constants.SECOND_MS);
    } catch (Exception e) {
      throw new RuntimeException("Failed to start masters", e);
    }
  }
}


text:
package com.github.t3t5u.common.expression;

import java.text.NumberFormat;

@SuppressWarnings("serial")
public class NumberLiteral<T extends Number> extends AbstractLiteralExpression<T> {
	private final NumberFormat format;

	NumberLiteral(final Class<T> expressionClass, final T value, final NumberFormat format) {
		super(expressionClass, value);
		this.format = format;
	}

	@Override
	public <R> R accept(final Visitor<R> visitor) {
		return visitor.visit(this);
	}

	public NumberFormat getFormat() {
		return format;
	}
}


text:
<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>HTTP requests with Zones</title>
  <link rel="stylesheet" href="css/style.css">
  <script src="../dist/zone.js"></script>
</head>
<body>

  <script>

  function checkZone () {
    console.log(!!window.zone.parent);
  }

  var oReq = new XMLHttpRequest();
  //oReq.onload = checkZone;
  oReq.onreadystatechange = checkZone;
  oReq.open('get', 'index.html', true);
  oReq.send();

  /*
  var oReq = new XMLHttpRequest();

  oReq.upload.addEventListener('progress', checkZone, false);
  oReq.upload.addEventListener('load', checkZone, false);
  oReq.upload.addEventListener('error', checkZone, false);
  oReq.upload.addEventListener('abort', checkZone, false);

  oReq.open();
  */

  </script>
</body>
</html>


text:
class Soce::Address < Soce::Base
  self.table_name = "adresses"

  belongs_to :user, foreign_key: "id_user"

  def self.serialize
    hruid = self.first.user.hruid
    sql = "SELECT tel_fixe, fax, adresse_1, adresse_2, code_postal, ville, nompays, adt.libelle  FROM users AS u
    left JOIN adresses AS ad ON (u.id_user=ad.id_user )
    left JOIN pays AS py ON (py.id_pays=ad.id_pays )
    left JOIN liste_adresse_types AS adt ON (adt.id_adresse_type=ad.id_adresse_type )
    where hruid = '#{hruid}'"

    SoceDatabaseConnection.custom_sql_query(sql,SoceDatabaseConnection)
  end

  def self.get_pays_id_from_name(name)
    safe_name=Mysql2::Client.escape(name)
    sql = "SELECT id_pays FROM pays WHERE pays.nom_iso = '#{safe_name}'"
    record=SoceDatabaseConnection.custom_sql_query(sql,SoceDatabaseConnection).first
    record&&record["id_pays"]
  end

end


text:
let contentWindow;

function test() {
  waitForExplicitFinish();

  registerCleanupFunction(function() {
    while (gBrowser.tabs[1])
      gBrowser.removeTab(gBrowser.tabs[1]);
    hideTabView();
  });

  gBrowser.addTab("about:mozilla");
  showTabView(setup);
}

function setup() {
  let prefix = "setup: ";

  registerCleanupFunction(function() {
    let groupItem =  contentWindow.GroupItems.groupItem(groupItemTwoId);
    if (groupItem)
      closeGroupItem(groupItem);
  });

  contentWindow = TabView.getContentWindow();
  let groupItemOne = contentWindow.GroupItems.groupItems[0];

  contentWindow = TabView.getContentWindow();
  is(contentWindow.GroupItems.groupItems.length, 1,
    prefix + "There is only one group");

  is(groupItemOne.getChildren().length, 2,
    prefix + "The number of tabs in group one is 2");

  // Create a second group with a dummy page.
  let groupItemTwo = createGroupItemWithTabs(
    window, 300, 300, 310, ["about:blank"]);
  let groupItemTwoId = groupItemTwo.id;

  // Add a new tab to the second group, from where we will execute the switch
  // to tab.
  groupItemTwo.newTab("about:blank");

  is(contentWindow.GroupItems.getActiveGroupItem(), groupItemTwo,
     prefix + "The group two is the active group");

  is(contentWindow.UI.getActiveTab(), groupItemTwo.getChild(1),
     prefix + "The second tab item in group two is active");

  hideTabView(function () { switchToURL(groupItemOne, groupItemTwo) } );
}

function switchToURL(groupItemOne, groupItemTwo) {
  let prefix = "after switching: ";

  /**
   * At this point, focus is on group one. Let's switch to a tab with an URL
   * contained in group two and then open a new tab in group two after the
   * switch. The tab should be opened in group two and not in group one.
   */
  // Set the urlbar to include the moz-action.
  gURLBar.value = "moz-action:switchtab,about:mozilla";
  // Focus the urlbar so we can press enter.
  gURLBar.focus();
  // Press enter.
  EventUtils.synthesizeKey("VK_RETURN", {});

  // Open a new tab and make sure the tab is opened in the group one.
  EventUtils.synthesizeKey("t", { accelKey: true });

  // Check group two is active after a "switch to tab" action was executed and
  // a new tab has been open.
  is(contentWindow.GroupItems.getActiveGroupItem(), groupItemOne,
    prefix + "The group one is the active group");

  // Make sure the new tab is open in group one after the "switch to tab" action.
  is(groupItemOne.getChildren().length, 3,
    prefix + "The number of children in group one is 3");

  // Verify there's only one tab in group two after the "switch to tab" action.
  is(groupItemTwo.getChildren().length, 1,
    prefix + "The number of children in group two is 1");

  finish();
}


text:
\hypertarget{_baby_shih_tzu_8cpp}{\section{jamms/\+Tower\+Defense/\+Tower\+Defense/src/game\+Objects/\+Baby\+Shih\+Tzu.cpp File Reference}
\label{_baby_shih_tzu_8cpp}\index{jamms/\+Tower\+Defense/\+Tower\+Defense/src/game\+Objects/\+Baby\+Shih\+Tzu.\+cpp@{jamms/\+Tower\+Defense/\+Tower\+Defense/src/game\+Objects/\+Baby\+Shih\+Tzu.\+cpp}}
}
{\ttfamily \#include \char`\"{}Game\+Objects/\+Baby\+Shih\+Tzu.\+h\char`\"{}}\\*
Include dependency graph for Baby\+Shih\+Tzu.\+cpp\+:
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{_baby_shih_tzu_8cpp__incl}
\end{center}
\end{figure}


text:
A Polymer element for working with vis.js

Currently WIP. The element renders a 2d graph with random y values over time (x).

## Install the Polymer-CLI

First, make sure you have the [Polymer CLI](https://www.npmjs.com/package/polymer-cli) installed. Then run `polymer serve` to serve your element locally.

## Viewing Your Element

```
$ polymer serve
```

## Running Tests

```
$ polymer test
```

Your application is already set up to be tested via [web-component-tester](https://github.com/Polymer/web-component-tester). Run `polymer test` to run your application's test suite locally.


text:
require 'spree_core'
require 'spree_simple_stock/engine'


text:
var pollerFactory = function (window, jQuery) {
        "use strict";
        var defaults = {
            // jQuery.ajax options
                dataType: "json",
                type: "POST",
                global: false,
                timeout: 5 * 60 * 1000,
                data: {},
            // poller options
                errorSleepTime: 500,
                pollInterval: 1 // miliseconds between consecutive polls
            },
            options = {},
            errorSleepTime = {},
            listeners = {},
            deferreds = {},
            i = 0,

            // placeholder/declaration (implementation/definition put below - JSLint compliance)
            doSendRequest = null,

            // sends request according to given timeout
            sendRequest = function (url, timeout) {
                if (timeout !== (void 0) && timeout > 0) {
                    window.setTimeout(
                        function () {
                            doSendRequest(url);
                        },
                        timeout
                    );
                    return;
                }
                doSendRequest(url);
            },

            // called on erroneous response
            onError = function (response, url) {
                // poller was removed
                if (!listeners.hasOwnProperty(url)) {
                    return;
                }
                // do not increase error sleep time in case of "timeout" occured
                if (response.statusText !== 'timeout') {
                    errorSleepTime[url] *= 2;
                }
                sendRequest(url, errorSleepTime[url]);
            },

            // called on succeeded response
            onSuccess = function (response, url) {
                // poller was removed
                if (!listeners.hasOwnProperty(url)) {
                    return;
                }
                errorSleepTime[url] = options[url].errorSleepTime;
                // set data to be passed back in next request
                sendRequest(url, options[url].pollInterval);
            };

        // sends request
        doSendRequest = function (url) {
            // poller was removed
            if (!listeners.hasOwnProperty(url)) {
                return;
            }
            // send request
            deferreds[url] = jQuery.ajax(jQuery.extend(true, options[url], {url: url}));
            // append listeners
            for (i = 0; i < listeners[url].length; i = i + 1) {
                deferreds[url].success(listeners[url][i]);
            }
            // append "onError" action
            deferreds[url].error(function (response) {
                onError(response, url);
            });
        };

        return function (url, success, params) {
            // for each new URL define standard structure
            if (!listeners.hasOwnProperty(url)) {
                // set default options
                options[url] = jQuery.extend(true, {}, defaults, params);
                // add listeners (at least one - internal listener that updates data)
                listeners[url] = [function (response) { onSuccess(response, url); }];
                // set default errorSleepTime
                errorSleepTime[url] = options[url].errorSleepTime;
                // force request send right now (not after timeout)
                // it sets deferreds[url]
                doSendRequest(url);
            } else {
                // merge options
                options[url] = jQuery.extend(true, options[url], params);
            }
            // append callback to listeners
            var tmp = function (r) { jQuery.extend(true, options[url].data, success(r)); };
            listeners[url].push(tmp);
            // append callback to current deferred instance
            deferreds[url].success(tmp);
            // return function that allows to remove poller
            return function () {
                // listeners have been removed already
                if (!listeners.hasOwnProperty(url)) {
                    return;
                }
                // remove listeners
                for (i = 0; i < listeners[url].length; i = i + 1) {
                    if (listeners[url][i] === tmp) {
                        listeners[url].remove(i);
                        // force deferred to abort in order to refresh listeners
                        deferreds[url].abort();
                        // remove only one listener of that type
                        break;
                    }
                }
                // have more than 1 listeners (there is always one left - default 'onSuccess') - skip
                if (listeners[url].length > 1) {
                    return;
                }
                // no listeners - remove everything
                delete listeners[url];
                delete options[url];
                delete errorSleepTime[url];
                delete deferreds[url];
            };

        };
    },
    poller = null;

if (!Array.prototype.hasOwnProperty('remove')) {
    // Array Remove - By John Resig (MIT Licensed)
    Array.prototype.remove = function (from, to) {
        "use strict";
        var rest = this.slice(parseInt(to || from, 10) + 1 || this.length);
        this.length = from < 0 ? this.length + from : from;
        return this.push.apply(this, rest);
    };
}

try {
    poller = pollerFactory(window, jQuery);
} catch (e) {
}


text:
package org.woehlke.twitterwall.backend.mq.tweets.endpoint.splitter;

import org.woehlke.twitterwall.backend.mq.common.TweetsSplitter;

public interface FetchTweetsFromSearchSplitter extends TweetsSplitter {

}


text:
package com.haxademic.core.math;

import processing.core.PApplet;

public class MagicNumbers {
	/**
	 * A great way to traverse circular trigonometry.
	 */
	static final float GOLDEN_RATIO = ((float)Math.sqrt(5f)+1f)/2f - 1f;

	/**
	 * Works with Golden ratio for a good time.
	 */
	static final float GOLDEN_ANGLE = GOLDEN_RATIO * PApplet.TWO_PI;

	/**
	 * K
	 */
	static final float SIERPINKSI = 2.584981759579253217f;

	/**
	 * Natural log()
	 */
	static final float E = 2.71828182845904523536028747135266249f;

	/**
	 * "Golden ratio for exponentials".
	 */
	static final float OMEGA = 0.56714329040978387299996866221035555f;

	/**
	 * A naturally occurring transcendental number that exhibits continued fraction expansion.
	 */
	static final float CAHEN = 0.6434105463f;
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
    <type>org.netbeans.modules.php.project</type>
    <configuration>
        <data xmlns="http://www.netbeans.org/ns/php-project/1">
            <name>osr_scheduler</name>
        </data>
        <spellchecker-wordlist xmlns="http://www.netbeans.org/ns/spellchecker-wordlist/1">
            <word>css</word>
        </spellchecker-wordlist>
    </configuration>
</project>


text:
import logging
import weakref

from king_phisher import find
from king_phisher import utilities
from king_phisher.client import dialogs
from king_phisher.client import export
from king_phisher.client import graphs
from king_phisher.client import gui_utilities
from king_phisher.client.widget import extras
from king_phisher.client.windows import plugin_manager
from king_phisher.client.windows import rpc_terminal
from king_phisher.client.windows import campaign_import
from king_phisher.client.windows import compare_campaigns
from king_phisher.client.tabs.campaign import CampaignViewTab
from king_phisher.client.tabs.campaign import CampaignViewGenericTableTab
from king_phisher.client.tabs.mail import MailSenderTab
from king_phisher.constants import ConnectionErrorReason

from gi.repository import Gdk
from gi.repository import GdkPixbuf
from gi.repository import Gtk
import xlsxwriter

if isinstance(Gtk.Widget, utilities.Mock):
	_Gtk_ApplicationWindow = type('Gtk.ApplicationWindow', (object,), {'__module__': ''})
else:
	_Gtk_ApplicationWindow = Gtk.ApplicationWindow

__all__ = ('MainAppWindow',)

class MainMenuBar(gui_utilities.GladeGObject):
	"""
	The main menu bar for the primary application window. This configures any
	optional menu items as well as handles all the menu item signals
	appropriately.
	"""
	dependencies = gui_utilities.GladeDependencies(
		top_level=(
			'StockDeleteImage',
			'StockEditImage',
			'StockHelpImage',
			'StockPropertiesImage',
			'StockStopImage'
		)
	)
	top_gobject = 'menubar'
	def __init__(self, application, window):
		utilities.assert_arg_type(application, Gtk.Application, arg_pos=1)
		utilities.assert_arg_type(window, MainAppWindow, arg_pos=2)
		super(MainMenuBar, self).__init__(application)
		self.window = weakref.proxy(window)
		self._add_accelerators()
		graphs_menu_item = self.gtk_builder_get('menuitem_tools_create_graph')
		if graphs.has_matplotlib:
			graphs_submenu = Gtk.Menu.new()
			for graph_name in graphs.get_graphs():
				graph = graphs.get_graph(graph_name)
				menu_item = Gtk.MenuItem.new_with_label(graph.name_human)
				menu_item.connect('activate', self.signal_activate_tools_show_campaign_graph, graph_name)
				graphs_submenu.append(menu_item)
			graphs_menu_item.set_submenu(graphs_submenu)
			graphs_menu_item.show_all()
		else:
			graphs_menu_item.set_sensitive(False)

	def _add_accelerators(self):
		accelerators = (
			('file_open', Gdk.KEY_o, Gdk.ModifierType.CONTROL_MASK),
			('file_quit', Gdk.KEY_q, Gdk.ModifierType.CONTROL_MASK),
			('tools_rpc_terminal', Gdk.KEY_F1, Gdk.ModifierType.CONTROL_MASK),
			('tools_sftp_client', Gdk.KEY_F2, Gdk.ModifierType.CONTROL_MASK)
		)
		for menu_name, key, modifier in accelerators:
			menu_item = self.gtk_builder_get('menuitem_' + menu_name)
			menu_item.add_accelerator('activate', self.window.accel_group, key, modifier, Gtk.AccelFlags.VISIBLE)

	def signal_activate_edit_configure_campaign(self, _):
		self.application.campaign_configure()

	def signal_activate_edit_delete_campaign(self, _):
		if not gui_utilities.show_dialog_yes_no('Delete This Campaign?', self.application.get_active_window(), 'This action is irreversible, all campaign data will be lost.'):
			return
		self.application.emit('campaign-delete', self.config['campaign_id'])

	def signal_activate_edit_preferences(self, _):
		self.application.show_preferences()

	def signal_activate_edit_stop_service(self, _):
		self.application.stop_remote_service()

	def signal_activate_edit_companies(self, _):
		dialogs.CompanyEditorDialog(self.application).interact()

	def signal_activate_edit_tags(self, _):
		dialogs.TagEditorDialog(self.application).interact()

	def signal_activate_export_campaign_xlsx(self, _):
		self.window.export_campaign_xlsx()

	def signal_activate_export_campaign_xml(self, _):
		self.window.export_campaign_xml()

	def signal_activate_export_message_data(self, _):
		self.window.export_message_data()

	def signal_activate_export_credentials_csv(self, _):
		campaign_tab = self.window.tabs['campaign']
		credentials_tab = campaign_tab.tabs['credentials']
		credentials_tab.export_table_to_csv()

	def signal_activate_export_credentials_msf_txt(self, _):
		dialog = extras.FileChooserDialog('Export Credentials', self.application.get_active_window())
		file_name = self.config['campaign_name'] + '.txt'
		response = dialog.run_quick_save(file_name)
		dialog.destroy()
		if not response:
			return
		destination_file = response['target_path']
		export.campaign_credentials_to_msf_txt(self.application.rpc, self.config['campaign_id'], destination_file)

	def signal_activate_export_messages_csv(self, _):
		campaign_tab = self.window.tabs['campaign']
		messages_tab = campaign_tab.tabs['messages']
		messages_tab.export_table_to_csv()

	def signal_activate_export_visits_csv(self, _):
		campaign_tab = self.window.tabs['campaign']
		visits_tab = campaign_tab.tabs['visits']
		visits_tab.export_table_to_csv()

	def signal_activate_export_visits_geojson(self, _):
		self.window.export_campaign_visit_geojson()

	def signal_activate_import_message_data(self, _):
		self.window.import_message_data()

	def signal_activate_import_campaign_xml(self, _):
		campaign_import.ImportCampaignWindow(self.application)

	def signal_activate_show_campaign_selection(self, _):
		self.application.show_campaign_selection()

	def signal_activate_quit(self, _):
		self.application.quit(optional=True)

	def signal_activate_tools_rpc_terminal(self, _):
		rpc_terminal.RPCTerminal(self.application)

	def signal_activate_tools_clone_page(self, _):
		dialogs.ClonePageDialog(self.application).interact()

	def signal_activate_tools_compare_campaigns(self, _):
		compare_campaigns.CampaignCompWindow(self.application)

	def signal_activate_tools_manage_plugins(self, _):
		plugin_manager.PluginManagerWindow(self.application)

	def signal_activate_tools_sftp_client(self, _):
		self.application.emit('sftp-client-start')

	def signal_activate_tools_show_campaign_graph(self, _, graph_name):
		self.application.show_campaign_graph(graph_name)

	def signal_activate_help_about(self, _):
		dialogs.AboutDialog(self.application).interact()

	def signal_activate_help_templates(self, _):
		utilities.open_uri('https://github.com/securestate/king-phisher-templates')

	def signal_activate_help_wiki(self, _):
		utilities.open_uri('https://github.com/securestate/king-phisher/wiki')

class MainAppWindow(_Gtk_ApplicationWindow):
	"""
	This is the top level King Phisher client window. This is also the parent
	window for most GTK objects.
	"""
	def __init__(self, config, application):
		"""
		:param dict config: The main King Phisher client configuration.
		:param application: The application instance to which this window belongs.
		:type application: :py:class:`.KingPhisherClientApplication`
		"""
		utilities.assert_arg_type(application, Gtk.Application, arg_pos=2)
		super(MainAppWindow, self).__init__(application=application)
		self.application = application
		self.logger = logging.getLogger('KingPhisher.Client.MainWindow')
		self.config = config
		"""The main King Phisher client configuration."""
		self.set_property('title', 'King Phisher')
		vbox = Gtk.Box()
		vbox.set_property('orientation', Gtk.Orientation.VERTICAL)
		vbox.show()
		self.add(vbox)

		default_icon_file = find.data_file('king-phisher-icon.svg')
		if default_icon_file:
			icon_pixbuf = GdkPixbuf.Pixbuf.new_from_file(default_icon_file)
			self.set_default_icon(icon_pixbuf)
		self.accel_group = Gtk.AccelGroup()
		self.add_accel_group(self.accel_group)

		self.menu_bar = MainMenuBar(application, self)
		vbox.pack_start(self.menu_bar.menubar, False, False, 0)

		# create notebook and tabs
		self.notebook = Gtk.Notebook()
		"""The primary :py:class:`Gtk.Notebook` that holds the top level taps of the client GUI."""
		self.notebook.connect('switch-page', self.signal_notebook_switch_page)
		self.notebook.set_scrollable(True)
		vbox.pack_start(self.notebook, True, True, 0)

		self.tabs = {}
		current_page = self.notebook.get_current_page()
		self.last_page_id = current_page

		mailer_tab = MailSenderTab(self, self.application)
		self.tabs['mailer'] = mailer_tab
		self.notebook.insert_page(mailer_tab.box, mailer_tab.label, current_page + 1)
		self.notebook.set_current_page(current_page + 1)

		campaign_tab = CampaignViewTab(self, self.application)
		campaign_tab.box.show()
		self.tabs['campaign'] = campaign_tab
		self.notebook.insert_page(campaign_tab.box, campaign_tab.label, current_page + 2)

		self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
		self.set_size_request(800, 600)
		self.connect('delete-event', self.signal_delete_event)
		self.notebook.show()

		self.show()
		self.rpc = None  # needs to be initialized last
		"""The :py:class:`.KingPhisherRPCClient` instance."""

		self.application.connect('server-connected', self.signal_kp_server_connected)

		self.login_dialog = dialogs.LoginDialog(self.application)
		self.login_dialog.dialog.connect('response', self.signal_login_dialog_response)
		self.login_dialog.dialog.show()

	def signal_notebook_switch_page(self, notebook, current_page, index):
		#previous_page = notebook.get_nth_page(self.last_page_id)
		self.last_page_id = index
		mailer_tab = self.tabs.get('mailer')
		campaign_tab = self.tabs.get('campaign')

		notebook = None
		if mailer_tab and current_page == mailer_tab.box:
			notebook = mailer_tab.notebook
		elif campaign_tab and current_page == campaign_tab.box:
			notebook = campaign_tab.notebook

		if notebook:
			index = notebook.get_current_page()
			notebook.emit('switch-page', notebook.get_nth_page(index), index)

	def signal_delete_event(self, x, y):
		self.application.emit('exit-confirm')
		return True

	def signal_kp_server_connected(self, _):
		self.rpc = self.application.rpc
		if self.login_dialog:
			self.login_dialog.destroy()
			self.login_dialog = None

	def signal_login_dialog_response(self, dialog, response):
		if response == Gtk.ResponseType.CANCEL or response == Gtk.ResponseType.DELETE_EVENT:
			dialog.destroy()
			self.application.emit('exit')
			return True
		self.login_dialog.objects_save_to_config()
		username = self.config['server_username']
		password = self.config['server_password']
		otp = self.config['server_one_time_password']
		if not otp:
			otp = None
		_, reason = self.application.server_connect(username, password, otp)
		if reason == ConnectionErrorReason.ERROR_INVALID_OTP:
			revealer = self.login_dialog.gobjects['revealer_server_one_time_password']
			if revealer.get_child_revealed():
				gui_utilities.show_dialog_error('Login Failed', self, 'A valid one time password (OTP) token is required.')
			else:
				revealer.set_reveal_child(True)
			entry = self.login_dialog.gobjects['entry_server_one_time_password']
			entry.grab_focus()
		elif reason == ConnectionErrorReason.ERROR_INVALID_CREDENTIALS:
			gui_utilities.show_dialog_error('Login Failed', self, 'The provided credentials are incorrect.')
		elif reason == ConnectionErrorReason.ERROR_UNKNOWN:
			gui_utilities.show_dialog_error('Login Failed', self, 'An unknown error has occurred.')

	def export_campaign_xlsx(self):
		"""Export the current campaign to an Excel compatible XLSX workbook."""
		dialog = extras.FileChooserDialog('Export Campaign To Excel', self)
		file_name = self.config['campaign_name'] + '.xlsx'
		response = dialog.run_quick_save(file_name)
		dialog.destroy()
		if not response:
			return
		destination_file = response['target_path']
		campaign_tab = self.tabs['campaign']
		workbook = xlsxwriter.Workbook(destination_file)
		title_format = workbook.add_format({'bold': True, 'size': 18})
		for tab_name, tab in campaign_tab.tabs.items():
			if not isinstance(tab, CampaignViewGenericTableTab):
				continue
			tab.export_table_to_xlsx_worksheet(workbook.add_worksheet(tab_name), title_format)
		workbook.close()

	def export_campaign_xml(self):
		"""Export the current campaign to an XML data file."""
		dialog = extras.FileChooserDialog('Export Campaign XML Data', self)
		file_name = self.config['campaign_name'] + '.xml'
		response = dialog.run_quick_save(file_name)
		dialog.destroy()
		if not response:
			return
		destination_file = response['target_path']
		export.campaign_to_xml(self.rpc, self.config['campaign_id'], destination_file)

	def export_message_data(self, *args, **kwargs):
		self.tabs['mailer'].export_message_data(*args, **kwargs)

	def export_campaign_visit_geojson(self):
		"""
		Export the current campaign visit information to a GeoJSON data file.
		"""
		dialog = extras.FileChooserDialog('Export Campaign Visit GeoJSON Data', self)
		file_name = self.config['campaign_name'] + '.geojson'
		response = dialog.run_quick_save(file_name)
		dialog.destroy()
		if not response:
			return
		destination_file = response['target_path']
		export.campaign_visits_to_geojson(self.rpc, self.config['campaign_id'], destination_file)

	def import_message_data(self, *args, **kwargs):
		self.tabs['mailer'].import_message_data(*args, **kwargs)


text:
set -xe

pushd test_menu
pub get
tool/travis.sh
popd

pushd test_menu_io
pub get
tool/travis.sh
popd

pushd test_menu_browser
pub get
tool/travis.sh
popd


text:
layout: page
title: Cunningham White Entertainment Party
date: 2016-05-24
author: Diana Arellano
tags: weekly links, java
status: published
summary: Integer et tincidunt urna, non fringilla tortor. Donec in enim.
banner: images/banner/leisure-01.jpg
booking:
  startDate: 11/25/2019
  endDate: 11/26/2019
  ctyhocn: HOUWEHX
  groupCode: CWEP
published: true
---
Quisque mattis justo et luctus mollis. Nunc faucibus convallis felis, vel vulputate dolor laoreet nec. Nulla sed turpis vitae sapien commodo tincidunt vitae sit amet elit. Phasellus ultrices molestie suscipit. Integer faucibus massa nec quam euismod, nec commodo purus posuere. Nunc laoreet at ligula eget ornare. Vivamus eget consectetur orci.
Praesent purus lorem, convallis sit amet nisi ac, placerat pulvinar augue. Phasellus sollicitudin, metus in efficitur lobortis, lacus arcu pulvinar diam, sed tristique mauris ante eu lorem. Phasellus pharetra condimentum magna, eu tincidunt sem elementum vitae. In hac habitasse platea dictumst. Integer vel laoreet ex. Phasellus in erat ut dolor mollis mollis. Proin a volutpat diam, posuere ullamcorper orci. Sed a ante in nisi interdum interdum et at metus. Suspendisse potenti. Phasellus sed enim ornare, facilisis massa a, pharetra tortor. Cras sed consequat quam. Suspendisse erat nibh, suscipit non mattis quis, gravida finibus nulla.

* Pellentesque fringilla justo vel porta lacinia
* Nunc ac sem et sem suscipit feugiat
* Fusce tristique purus sed erat luctus mollis
* Pellentesque commodo diam vel felis posuere bibendum.

Aliquam quis vulputate arcu. Duis egestas felis sed nulla ullamcorper tempor a vel nulla. Mauris aliquam, tellus eget vehicula convallis, ipsum metus viverra leo, sed blandit urna est sit amet lacus. Integer consectetur dui nibh, et euismod est dictum eget. Nulla facilisi. Nam ac ornare urna. Etiam vel diam varius, accumsan dui quis, pulvinar nisl. Maecenas malesuada dolor risus, sit amet semper tellus bibendum nec. Duis nec augue rhoncus libero congue convallis. Cras auctor euismod sem, sit amet malesuada lacus fermentum sed. Aenean at interdum neque, ac blandit mauris. Fusce vitae enim eros. Donec ut convallis enim. Sed sit amet tempus eros. Sed fermentum vulputate diam, vitae blandit tellus accumsan nec.


text:
var a = true;
var b = new Object;
assert((a || b) === true)


text:
using statify::Buffer;
using statify::Event;
using statify::EventDecoder;
using statify::Log;
using statify::ProgramOptions;

namespace {

void buffer_read_callback(struct bufferevent* bev, void* ctx) {
  Log::Write(Log::INFO, "buffer_read_callback()");

  // Access the "context," which is an EventDecoder.
  statify::EventDecoder* decoder = reinterpret_cast<EventDecoder*>(ctx);
  assert(decoder != NULL);

  // TODO(tdial): Can bev be NULL?
  assert(bev != NULL);

  // Access the input
  // TODO(tdial): Can this function return NULL?
  struct evbuffer* in = bufferevent_get_input(bev);
  assert(in != NULL);

  // Access the output
  // TODO(tdial): Can this function return NULL?
  struct evbuffer* out = bufferevent_get_output(bev);
  assert(out != NULL);

  // Invoke method on EventDecoder for handling data.
  decoder->OnData(in, out);

  // Write out whatever we read
  // TODO(tdial): Remove this when done implementing.
  evbuffer_add_buffer(out, in);
}

void buffer_write_callback(struct bufferevent* bev, void* ctx) {
  // TODO(tdial): Implement
  Log::Write(Log::INFO, "buffer_write_callback()");
}

void buffer_event_callback(struct bufferevent* bev, int16_t events, void* ctx) {
  Log::Write(Log::INFO, "buffer_event_callback()");

  // Access the "context," which is an EventDecoder.
  EventDecoder* decoder = reinterpret_cast<EventDecoder*>(ctx);
  assert(decoder != NULL);

  if (events & BEV_EVENT_ERROR) {
    Log::Write(Log::ERROR, "buffer_event_callback(): BEV_EVENT_ERROR");
  }

  if (events & BEV_EVENT_EOF) {
    Log::Write(Log::INFO, "buffer_event_callback(): BEV_EVENT_EOF");
    bufferevent_free(bev);
    delete decoder;
  }
}

// Callback that is registered to handle new connection attempts.
void accept_callback(struct evconnlistener* listener, evutil_socket_t sock,
                     struct sockaddr* addr, int, void* arg) {
  // TODO(tdial): Can listener ever be NULL?
  assert(listener != NULL);

  // TODO(tdial): Can socket ever be invalid?
  assert(sock >= 0);

  // TODO(tdial): Can a valid listener ever provide an invalid base?
  struct event_base* base = evconnlistener_get_base(listener);
  assert(base != NULL);

  // Construct buffer event object
  struct bufferevent* bev(NULL);
  bev = bufferevent_socket_new(base, sock, BEV_OPT_CLOSE_ON_FREE);

  // TODO(tdial): In what circumstances may bufferevent_socket_new() fail?
  assert(bev != NULL);

  // Create a decoder for parsing events off the "wire."
  EventDecoder* decoder = new EventDecoder();

  // Configure event callbacks
  bufferevent_setcb(bev, buffer_read_callback, buffer_write_callback,
                    buffer_event_callback, decoder);

  bufferevent_enable(bev, EV_READ | EV_WRITE);
}

// Callback that is registered to handle errors occurring during accept.
void accept_error_callback(struct evconnlistener* listener, void* arg) {
  (void)listener;
  (void)arg;

  Log::Write(Log::ERROR, "failed to accept connection");
}

}  // namespace

int main(int argc, char* argv[]) {
  // Extract program options from command line
  ProgramOptions options;
  options.ParseCommandLine(argc, argv);
  if (options.help()) {
    options.DisplayHelp();
    return EXIT_SUCCESS;
  }

  // Log startup
  Log::Write(Log::INFO, "statifyd - Copyright (C) 2015 The Statify Authors");
  Log::Write(Log::INFO, "starting up");

  // Log important startup parameters
  Log::Write(Log::INFO, "listener port: %d", options.port());
  Log::Write(Log::INFO, "listener size: %d", options.backlog());

  // Create event base
  struct event_base* evbase = event_base_new();
  if (evbase == NULL) {
    Log::Write(Log::ABORT, "failed to create event base");
    return EXIT_FAILURE;
  }

  // Construct wildcard address for listening on the chosen port.
  struct sockaddr_in address;
  memset(&address, 0, sizeof(address));
  address.sin_family = AF_INET;
  address.sin_addr.s_addr = htonl(0);
  address.sin_port = htons(options.port());

  // Create a TCP listener
  struct evconnlistener* listener = NULL;
  listener = evconnlistener_new_bind(
      evbase, accept_callback, 0, LEV_OPT_CLOSE_ON_FREE | LEV_OPT_REUSEABLE,
      options.backlog(), reinterpret_cast<struct sockaddr*>(&address),
      sizeof(address));
  if (listener == NULL) {
    Log::Write(Log::ABORT, "failed to establish listener");
  }

  // Configure a callback function to invoke on errors
  evconnlistener_set_error_cb(listener, accept_error_callback);

  Log::Write(Log::INFO, "startup complete");

  // Dispatch events: This runs the event loop.
  event_base_dispatch(evbase);

  evconnlistener_free(listener);

  // Log that we're initiating shutdown
  Log::Write(Log::INFO, "shutting down");

  // Free the event base
  event_base_free(evbase);

  // Finally, log that we're done and exiting.
  Log::Write(Log::INFO, "shutdown complete");

  return EXIT_SUCCESS;
}


text:
class CreatePeerReviews < ActiveRecord::Migration[4.2]
  def self.up
    create_table :peer_reviews do |t|
      # Note: Table name pluralized by convention.
      t.column 'reviewer_id', :integer
      t.column 'reviewee_id', :integer
      t.column 'assignment_id', :integer
      # t.column "team_id", :integer
      t.column 'additional_comment', :text
    end
    begin
      add_column :assignments, :peer_review_questionnaire_id, :integer
    rescue StandardError
    end

    add_index 'peer_reviews', ['reviewer_id'], name: 'fk_reviewer_id_users'

    execute "alter table peer_reviews
               add constraint fk_reviewer_id_users
               foreign key (reviewer_id) references users(id)"

    add_index 'peer_reviews', ['reviewee_id'], name: 'fk_reviewee_id_users'

    execute "alter table peer_reviews
               add constraint fk_reviewee_id_users
               foreign key (reviewee_id) references users(id)"

    add_index 'peer_reviews', ['assignment_id'], name: 'fk_peer_reviews_assignments'

    execute "alter table peer_reviews
             add constraint fk_peer_reviews_assignments
             foreign key (assignment_id) references assignments(id)"
  end

  def self.down
    drop_table :peer_reviews
  end
end


text:
.class public Lcom/xiaomi/infra/galaxy/common/constants/ConfigKeys;
.super Ljava/lang/Object;

# static fields
.field public static final GALAXY_HBASE_TABLE_PREFIX_DEFAULT:Ljava/lang/String; = ""

.field public static final GALAXY_HBASE_TABLE_PREFIX_KEY:Ljava/lang/String; = "galaxy.hbase.table.prefix"

# direct methods
.method public constructor <init>()V
    .locals 0

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

    return-void
.end method


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Valsa mahaleb Cooke & Ellis

### Remarks
null


text:
layout: archive
lang: en
ref: matlab_groupsyncread
read_time: true
share: true
author_profile: false
permalink: /docs/en/software/dynamixel/dynamixel_sdk/api_reference/matlab/matlab_groupsyncread/
sidebar:
  title: DynamixelSDK
  nav: "dynamixel_sdk"
---

### [Matlab GroupSyncRead](#matlab-groupsyncread)

- Description

  Base functions for simultaneous dynamixel control on reading to same length data on same control table address. The function is unavailable in protocol 1.0.

- Members

  None

- Methods

| Methods                                                   | Description                                                |
|:----------------------------------------------------------|:-----------------------------------------------------------|
| **[groupSyncRead](#groupsyncread)**                       | Initializes members of packet data pointer struct          |
| **[groupSyncReadAddParam](#groupsyncread_addparam)**      | Adds parameter storage for read                            |
| **[groupSyncReadRemoveParam](#groupsyncreadremoveparam)** | Removes parameter on the storage                           |
| **[groupSyncReadClearParam](#groupsyncreadclearparam)**   | Clears parameter storage                                   |
| **[groupSyncReadTxPacket](#groupsyncreadtxpacket)**       | Transmits packet to the number of Dynamixels               |
| **[groupSyncReadRxPacket](#groupsyncreadrxpacket)**       | receives packet from the number of Dynamixels              |
| **[groupSyncReadTxRxPacket](#groupsyncreadtxrxpacket)**   | Transmits and receives packet on the number of Dynamixels  |
| **[groupSyncReadIsAvailable](#groupsyncreadisavailable)** | Checks whether there is available data in the data storage |
| **[groupSyncReadGetData](#groupsyncreadgetdata)**         | Gets data from received packet                             |

- Enumerator

  None

#### Method References

##### groupSyncRead
- Syntax
```c
int groupSyncRead(int port_num, int protocol_version, int start_address, int data_length)
```
- Parameters

| Parameters       | Description                                 |
|:-----------------|:--------------------------------------------|
| port_num         | Port number                                 |
| protocol_version | Protocol version                            |
| start_address    | Control table address to start reading data |
| data_length      | Total data length                           |

- Detailed Description

   This function initializes the parameters for packet construction. The function resizes groupData struct and initialzes struct members.

##### groupSyncReadAddParam
- Syntax
```c
bool groupSyncReadAddParam(int group_num, int id)
```
- Parameters

| Parameters | Description  |
|:-----------|:-------------|
| group_num  | Group number |
| id         | Dynamixel ID |

- Detailed Description

   This function pushes id to the Dynamixel ID list, and initializes #`group_num` parameter storage It returns false when the class uses Protocol 1.0, or it returns true.

##### groupSyncReadRemoveParam
- Syntax
```c
void groupSyncReadRemoveParam(int group_num, int id)
```
- Parameters

| Parameters | Description  |
|:-----------|:-------------|
| group_num  | Group number |
| id         | Dynamixel ID |

- Detailed Description

   This function removes id and its data for write in the #`group_num` Dynamixel ID list. It returns false when the class uses Protocol 1.0 or target ID does not exists in the ID list, or returns true.

##### groupSyncReadClearParam
- Syntax
```c
void groupSyncReadClearParam(int group_num)
```
- Parameters

| Parameters | Description  |
|:-----------|:-------------|
| group_num  | Group number |

- Detailed Description

   This function clears #`group_num` Dynamixel ID list. It returns false when the class uses Protocol 1.0, or returns true.

##### groupSyncReadTxPacket
- Syntax
```c
int groupSyncReadTxPacket(int group_num)
```
- Parameters

| Parameters | Description  |
|:-----------|:-------------|
| group_num  | Group number |

- Detailed Description

   This function transmits the packet by using `SyncReadTx` function. The communication result and the hardware error are available when the function is terminated.

##### groupSyncReadRxPacket
- Syntax
```c
int groupSyncReadRxPacket(int group_num)
```
- Parameters

| Parameters | Description  |
|:-----------|:-------------|
| group_num  | Group number |

- Detailed Description

   This function receives the packet by using `ReadRx` function. The communication result and the hardware error are available when the function is terminated.

##### groupSyncReadTxRxPacket
- Syntax
```c
int groupSyncReadTxRxPacket(int group_num)
```
- Parameters

| Parameters | Description  |
|:-----------|:-------------|
| group_num  | Group number |

- Detailed Description

   This function transmits and receives the packet by using `TxPacket` function and `RxPacket` function. The communication result and the hardware error are available when the function is terminated.

 ##### groupSyncReadIsAvailable
 - Syntax
 ```c
 bool groupSyncReadIsAvailable(int group_num, int id, int address, int data_length)
 ```
 - Parameters

| Parameters | Description                               |
|:-----------|:------------------------------------------|
| id         | Dynamixel ID                              |
| address    | Address on the control table of Dynamixel |
| data       | Packet data                               |

 - Detailed Description

    This function checks whether there is available data in the data storage. It returns false when used Protocol is 1.0 version or there is no data from target address, or returns true.

##### groupSyncReadGetData
- Syntax
```c
int groupSyncReadGetData(int group_num, int id, int address, int data_length)
```
- Parameters

| Parameters | Description                               |
|:-----------|:------------------------------------------|
| group_num  | Group number                              |
| id         | Dynamixel ID                              |
| address    | Address on the control table of Dynamixel |
| data       | Packet data                               |

- Detailed Description

   This function gets specific data from received packet. It returns false when the class uses Protocol 1.0 or there is no data from target address, or returns true.


text:
import logging
from copy import deepcopy
from typing import Any, Dict, List, Optional, cast

from great_expectations.core.batch import (
    BatchDefinition,
    BatchRequestBase,
    BatchSpec,
    IDDict,
)
from great_expectations.core.batch_spec import GlueDataCatalogBatchSpec
from great_expectations.datasource.data_connector import DataConnector
from great_expectations.datasource.data_connector.batch_filter import (
    BatchFilter,
    build_batch_filter,
)
from great_expectations.datasource.data_connector.util import (
    batch_definition_matches_batch_request,
)
from great_expectations.exceptions import DataConnectorError
from great_expectations.execution_engine import ExecutionEngine, SparkDFExecutionEngine

try:
    import boto3
except ImportError:
    boto3 = None

logger = logging.getLogger(__name__)

class ConfiguredAssetAWSGlueDataCatalogDataConnector(DataConnector):
    """
    The ConfiguredAssetAWSGlueDataCatalogDataConnector is one of two classes (InferredAssetAWSGlueDataCatalogDataConnector
    being the other one) designed for connecting to data through AWS Glue Data Catalog.

    A ConfiguredAssetAWSGlueDataCatalogDataConnector requires an explicit listing of each DataAsset one want to
    connect to. This allows more fine-tuning, but also requires more setup. One will need define the
    database and table names.
    """

    def __init__(
        self,
        name: str,
        datasource_name: str,
        execution_engine: Optional[ExecutionEngine] = None,
        catalog_id: Optional[str] = None,
        partitions: Optional[List[str]] = None,
        assets: Optional[Dict[str, dict]] = None,
        boto3_options: Optional[dict] = None,
        batch_spec_passthrough: Optional[dict] = None,
        id: Optional[str] = None,
    ):
        """
        A DataConnector that requires explicit listing of AWS Glue Data Catalog tables one want to connect to.

        Args:
            name (str): The name of this DataConnector
            datasource_name (str): Name of datasource that this DataConnector is connected to
            execution_engine (ExecutionEngine): Execution Engine object to actually read the data
            catalog_id (str): Optional catalog ID from which to retrieve databases. If none is provided, the AWS account ID is used by default.
                Make sure you use the same catalog id configured in your spark session.
            partitions (list): List of partition keys one want to define for all data assets. The partitions defined in data asset config
                will override the partitions defined in the connector level.
            assets (dict): dict of assets configuration
            boto3_options (dict): optional boto3 options
            batch_spec_passthrough (dict): dictionary with keys that will be added directly to batch_spec
        """
        logger.warning(
            "Warning: great_expectations.datasource.data_connector.ConfiguredAssetAWSGlueDataCatalogDataConnector is "
            "experimental. Methods, APIs, and core behavior may change in the future."
        )
        if execution_engine:
            execution_engine = cast(SparkDFExecutionEngine, execution_engine)

        super().__init__(
            name=name,
            datasource_name=datasource_name,
            execution_engine=execution_engine,  # type: ignore[arg-type]
            batch_spec_passthrough=batch_spec_passthrough,
            id=id,
        )
        if boto3_options is None:
            boto3_options = {}

        try:
            self._glue_client: Any = boto3.client("glue", **boto3_options)
        except (TypeError, AttributeError):
            raise ImportError(
                "Unable to load boto3 (it is required for ConfiguredAssetAWSGlueDataCatalogDataConnector)."
            )

        self._catalog_id = catalog_id
        self._partitions = partitions

        self._assets: Dict[str, dict] = {}
        self._refresh_data_assets_cache(assets=assets)

        self._data_references_cache: Dict[str, List[dict]] = {}

    @property
    def catalog_id(self) -> Optional[str]:
        return self._catalog_id

    @property
    def glue_client(self) -> Any:
        return self._glue_client

    @property
    def assets(self) -> Dict[str, dict]:
        return self._assets

    @property
    def partitions(self) -> Optional[List[str]]:
        return self._partitions

    def build_batch_spec(
        self, batch_definition: BatchDefinition
    ) -> GlueDataCatalogBatchSpec:
        """
        Build BatchSpec from batch_definition by calling DataConnector's build_batch_spec function.

        Args:
            batch_definition (BatchDefinition): to be used to build batch_spec

        Returns:
            BatchSpec built from batch_definition
        """

        data_asset_name: str = batch_definition.data_asset_name
        if (
            data_asset_name in self.assets
            and self.assets[data_asset_name].get("batch_spec_passthrough")
            and isinstance(
                self.assets[data_asset_name].get("batch_spec_passthrough"), dict
            )
        ):
            # batch_spec_passthrough from data_asset
            batch_spec_passthrough = deepcopy(
                self.assets[data_asset_name]["batch_spec_passthrough"]
            )
            batch_definition_batch_spec_passthrough = (
                deepcopy(batch_definition.batch_spec_passthrough) or {}
            )
            # batch_spec_passthrough from Batch Definition supersedes batch_spec_passthrough from data_asset
            batch_spec_passthrough.update(batch_definition_batch_spec_passthrough)
            batch_definition.batch_spec_passthrough = batch_spec_passthrough

        batch_spec: BatchSpec = super().build_batch_spec(
            batch_definition=batch_definition
        )

        return GlueDataCatalogBatchSpec(batch_spec)

    def get_available_data_asset_names(self) -> List[str]:
        """
        Return the list of asset names known by this DataConnector.

        Returns:
            A list of available names
        """
        return list(self.assets.keys())

    def get_unmatched_data_references(self) -> List[str]:
        """
        Returns the list of data_references unmatched by configuration by looping through items in _data_references_cache
        and returning data_reference that do not have an associated data_asset.

        Returns:
            list of data_references that are not matched by configuration.
        """
        return []

    def get_batch_definition_list_from_batch_request(
        self, batch_request: BatchRequestBase
    ):
        """
        Retrieve batch_definitions that match batch_request

        First retrieves all batch_definitions that match batch_request
            - if batch_request also has a batch_filter, then select batch_definitions that match batch_filter.
            - NOTE : currently glue data connectors do not support sorters.

        Args:
            batch_request (BatchRequestBase): BatchRequestBase (BatchRequest without attribute validation) to process

        Returns:
            A list of BatchDefinition objects that match BatchRequest
        """
        self._validate_batch_request(batch_request=batch_request)

        if len(self._data_references_cache) == 0:
            self._refresh_data_references_cache()

        batch_definition_list: List[BatchDefinition] = []
        try:
            sub_cache = self._get_data_reference_list_from_cache_by_data_asset_name(
                data_asset_name=batch_request.data_asset_name
            )
        except KeyError:
            raise KeyError(
                f"data_asset_name {batch_request.data_asset_name} is not recognized."
            )

        for batch_identifiers in sub_cache:
            batch_definition = BatchDefinition(
                datasource_name=self.datasource_name,
                data_connector_name=self.name,
                data_asset_name=batch_request.data_asset_name,
                batch_identifiers=IDDict(batch_identifiers),
                batch_spec_passthrough=batch_request.batch_spec_passthrough,
            )
            if batch_definition_matches_batch_request(batch_definition, batch_request):
                batch_definition_list.append(batch_definition)

        if batch_request.data_connector_query is not None:
            data_connector_query_dict = batch_request.data_connector_query.copy()
            if (
                batch_request.limit is not None
                and data_connector_query_dict.get("limit") is None
            ):
                data_connector_query_dict["limit"] = batch_request.limit

            batch_filter_obj: BatchFilter = build_batch_filter(
                data_connector_query_dict=data_connector_query_dict
            )
            batch_definition_list = batch_filter_obj.select_from_data_connector_query(
                batch_definition_list=batch_definition_list
            )

        return batch_definition_list

    def add_data_asset(
        self,
        name: str,
        config: dict,
    ) -> None:
        """
        Add data_asset to DataConnector using data_asset name as key, and data_asset config as value.
        """
        if "database_name" not in config:
            raise DataConnectorError(
                message=f"{self.__class__.__name__} ran into an error while initializing Asset names, 'database_name' was not specified"
            )
        if "table_name" not in config:
            raise DataConnectorError(
                message=f"{self.__class__.__name__} ran into an error while initializing Asset names, 'table_name' was not specified"
            )

        if self.partitions:
            # Asset config partitions takes precedence.
            config["partitions"] = config.get("partitions", self.partitions)

        partitions = config.get("partitions")
        if partitions and not isinstance(partitions, list):
            raise DataConnectorError(
                message=f"{self.__class__.__name__} ran into an error while initializing Asset names, 'partitions' must be a list, got {type(partitions)}"
            )

        name = self._update_data_asset_name_from_config(
            data_asset_name=name, data_asset_config=config
        )

        self._assets[name] = config

    def _get_glue_paginator_kwargs(self) -> dict:
        return {"CatalogId": self.catalog_id} if self.catalog_id else {}

    def _get_table_partitions(self, database_name: str, table_name: str) -> List[str]:
        paginator_kwargs = self._get_glue_paginator_kwargs()
        paginator_kwargs["DatabaseName"] = database_name
        paginator_kwargs["Name"] = table_name
        try:
            table = self.glue_client.get_table(**paginator_kwargs)
            return [p["Name"] for p in table["Table"]["PartitionKeys"]]
        except self.glue_client.exceptions.EntityNotFoundException:
            raise DataConnectorError(
                f"ConfiguredAssetAWSGlueDataCatalogDataConnector could not find a table with name: {database_name}.{table_name}"
            )

    def _get_batch_identifiers(
        self, partition_keys: List[str], database_name: str, table_name: str
    ) -> List[dict]:
        batch_identifiers: List[dict] = []
        table_partitions: List[str] = self._get_table_partitions(
            database_name=database_name, table_name=table_name
        )

        paginator_kwargs: dict = self._get_glue_paginator_kwargs()
        paginator_kwargs["DatabaseName"] = database_name
        paginator_kwargs["TableName"] = table_name
        paginator = self.glue_client.get_paginator("get_partitions")
        iterator = paginator.paginate(**paginator_kwargs)
        for page in iterator:
            for partition in page["Partitions"]:
                partition_values = partition["Values"]
                batch_id = dict(zip(table_partitions, partition_values))
                filtered_batch_id = dict(
                    filter(lambda k: k[0] in partition_keys, batch_id.items())
                )

                if filtered_batch_id not in batch_identifiers:
                    batch_identifiers.append(filtered_batch_id)

        return batch_identifiers

    def _get_batch_identifiers_list_from_data_asset_config(
        self, data_asset_config: dict
    ) -> List[dict]:
        table_name: str = data_asset_config["table_name"]
        database_name: str = data_asset_config["database_name"]
        partitions: Optional[list] = data_asset_config.get("partitions")

        batch_identifiers_list: Optional[List[dict]] = None
        if partitions:
            batch_identifiers_list = self._get_batch_identifiers(
                partition_keys=partitions,
                database_name=database_name,
                table_name=table_name,
            )

        return batch_identifiers_list or [{}]

    def _refresh_data_references_cache(self) -> None:
        self._data_references_cache = {}

        for data_asset_name in self.assets:
            data_asset_config: dict = self.assets[data_asset_name]
            batch_identifiers_list: List[
                dict
            ] = self._get_batch_identifiers_list_from_data_asset_config(
                data_asset_config=data_asset_config
            )
            self._data_references_cache[data_asset_name] = batch_identifiers_list

    def _get_data_reference_list_from_cache_by_data_asset_name(
        self, data_asset_name: str
    ) -> List[dict]:
        return self._data_references_cache[data_asset_name]

    def _update_data_asset_name_from_config(
        self, data_asset_name: str, data_asset_config: dict
    ) -> str:
        data_asset_name_prefix: str = data_asset_config.get(
            "data_asset_name_prefix", ""
        )

        data_asset_name_suffix: str = data_asset_config.get(
            "data_asset_name_suffix", ""
        )

        data_asset_name = (
            f"{data_asset_name_prefix}{data_asset_name}{data_asset_name_suffix}"
        )
        return data_asset_name

    def _map_data_reference_to_batch_definition_list(
        self, data_reference, data_asset_name: Optional[str] = None
    ) -> Optional[List[BatchDefinition]]:
        # Note: data references *are* dictionaries, allowing us to invoke `IDDict(data_reference)`
        return [
            BatchDefinition(
                datasource_name=self.datasource_name,
                data_connector_name=self.name,
                data_asset_name=data_asset_name,  # type: ignore[arg-type]
                batch_identifiers=IDDict(data_reference),
            )
        ]

    def _generate_batch_spec_parameters_from_batch_definition(
        self, batch_definition: BatchDefinition
    ) -> dict:
        """
        Build BatchSpec parameters from batch_definition with the following components:
            1. data_asset_name from batch_definition
            2. batch_identifiers from batch_definition
            3. data_asset from data_connector

        Args:
            batch_definition (BatchDefinition): to be used to build batch_spec

        Returns:
            dict built from batch_definition
        """
        data_asset_name: str = batch_definition.data_asset_name
        data_asset_config: dict = self.assets[data_asset_name]
        return {
            "data_asset_name": data_asset_name,
            "batch_identifiers": batch_definition.batch_identifiers,
            **data_asset_config,
        }

    def _refresh_data_assets_cache(
        self, assets: Optional[Dict[str, dict]] = None
    ) -> None:
        # Clear assets already stored in memory.
        self._assets = {}

        assets = assets or {}
        for data_asset_name, data_asset_config in assets.items():
            self.add_data_asset(name=data_asset_name, config=data_asset_config)


text:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <set>
#include <cassert>

#include <configment/error.h>
#include <argparser/argparser.h>

namespace argparser
{

Options   ArgParser::parse_config(const configment::Section & section, bool throw_on_error /*=false*/)
{
    Options options;
    return this->parse_config(options, section, throw_on_error);
}

Options & ArgParser::parse_config(Options & options, const configment::Section & section, bool throw_on_error /*=false*/)
{
    try
    {
        return this->_parse_section(options, section);
    }
    catch(configment::GenericError & err)
    {
        this->print_err(err);
        exit(1);
    }
}

Options & ArgParser::_parse_section(Options & options, const str_type & name, const configment::Section & section)
{
    this->check();
    argreader_vector_type argreaders = this->argreaders(options);
    std::set<str_type> dests;
    for(argreader_vector_type::iterator i_argreader = argreaders.begin(); i_argreader != argreaders.end(); ++i_argreader)
    {
        ArgReader & argreader = *i_argreader;
        const Argument & argument = argreader.argument();
        const Option & option = argument.option();
        const str_type & dest = option.dest();
        if(dests.find(dest) != dests.end())
        {
            continue;
        }
        if(section.has_key(dest))
        {
            argreader.read_object(*this, options, section.at(dest));
            dests.insert(dest);
        }
    }
    for(argparser_vector_type::iterator i = this->_subparsers.begin(); i != this->_subparsers.end(); ++i)
    {
        const str_type & subparser_name = i->first.dest();
        ArgParser & subparser = i->second;
        const str_type & subparser_dest = subparser.argparser_dest();
        if(section.has_key(subparser_name))
        {
            configment::Object subobject = section.at(subparser_name);
            if(subobject.is<configment::Section>())
            {
                configment::Section & subsection = dynamic_cast<configment::Section &>(subobject.get_object());
                Options suboptions;
                if(options.has_key(subparser_name))
                {
                    configment::Object sub_o = options.at(subparser_name);
                    if(sub_o.is<configment::Section>())
                    {
                        configment::Section & sub_s = dynamic_cast<configment::Section &>(sub_o.get_object());
                        suboptions = sub_s;
                    }
                }
                subparser._parse_section(suboptions, subparser_name, subsection);
                options[subparser_dest] = subparser_name;
                options[subparser_name] = suboptions;
            }
        }
    }
    return options;
}

} // namespace argparser


text:
<?php
/**
 * @license https://raw.github.com/mediaslave/phrails/master/LICENSE The MIT License
 * @package html
 */
/**
 * class description
 *
 * @package html
 */
class Div extends Tag
{
	/**
	 * Constructor
	 *
	 * @param string $display
	 * @param string or array $options
	 * @author Justin Palmer
	 */
	function __construct($display, $options=null)
	{
		parent::__construct($options);
		$this->display = $display;
	}
	/**
	 * @see Tag::start()
	 */
	public function start()
	{
		return '<div' . $this->options . '>';
	}
	/**
	 * @see Tag::end()
	 */
	public function end()
	{
		return '</div>';
	}
}


text:
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------

namespace System.Activities.Expressions
{
    using System.ComponentModel;
    using System.Reflection;
    using System.Runtime;
    using System.Runtime.Serialization;

    public sealed class ValueTypeFieldReference<TOperand, TResult> : CodeActivity<Location<TResult>>
    {
        FieldInfo fieldInfo;

        public ValueTypeFieldReference()
            : base()
        {
        }

        [DefaultValue(null)]
        public string FieldName
        {
            get;
            set;
        }

        [DefaultValue(null)]
        public InOutArgument<TOperand> OperandLocation
        {
            get;
            set;
        }

        protected override void CacheMetadata(CodeActivityMetadata metadata)
        {
            bool isRequired = false;
            if (!typeof(TOperand).IsValueType)
            {
                metadata.AddValidationError(SR.TypeMustbeValueType(typeof(TOperand).Name));
            }
            if (typeof(TOperand).IsEnum)
            {
                metadata.AddValidationError(SR.TargetTypeCannotBeEnum(this.GetType().Name, this.DisplayName));
            }
            if (string.IsNullOrEmpty(this.FieldName))
            {
                metadata.AddValidationError(SR.ActivityPropertyMustBeSet("FieldName", this.DisplayName));
            }
            else
            {
                this.fieldInfo = typeof(TOperand).GetField(this.FieldName);
                isRequired = this.fieldInfo != null && !this.fieldInfo.IsStatic;
                if (this.fieldInfo == null)
                {
                    metadata.AddValidationError(SR.MemberNotFound(this.FieldName, typeof(TOperand).Name));
                }
                else if (this.fieldInfo.IsInitOnly)
                {
                    metadata.AddValidationError(SR.MemberIsReadOnly(this.FieldName, typeof(TOperand).Name));
                }
            }

            MemberExpressionHelper.AddOperandLocationArgument<TOperand>(metadata, this.OperandLocation, isRequired);
        }

        protected override Location<TResult> Execute(CodeActivityContext context)
        {
            Location<TOperand> operandLocationValue = this.OperandLocation.GetLocation(context);
            Fx.Assert(operandLocationValue != null, "OperandLocation must not be null");
            Fx.Assert(this.fieldInfo != null, "fieldInfo must not be null.");
            return new FieldLocation(this.fieldInfo, operandLocationValue);
        }

        [DataContract]
        internal class FieldLocation : Location<TResult>
        {
            FieldInfo fieldInfo;

            Location<TOperand> ownerLocation;

            public FieldLocation(FieldInfo fieldInfo, Location<TOperand> ownerLocation)
                : base()
            {
                this.fieldInfo = fieldInfo;
                this.ownerLocation = ownerLocation;
            }

            public override TResult Value
            {
                get
                {
                    return (TResult)this.fieldInfo.GetValue(this.ownerLocation.Value);
                }
                set
                {
                    object copy = this.ownerLocation.Value;
                    this.fieldInfo.SetValue(copy, value);
                    this.ownerLocation.Value = (TOperand)copy;
                }
            }

            [DataMember(Name = "fieldInfo")]
            internal FieldInfo SerializedFieldInfo
            {
                get { return this.fieldInfo; }
                set { this.fieldInfo = value; }
            }

            [DataMember(EmitDefaultValue = false, Name = "ownerLocation")]
            internal Location<TOperand> SerializedOwnerLocation
            {
                get { return this.ownerLocation; }
                set { this.ownerLocation = value; }
            }
        }
    }
}


text:
package org.apache.pig.backend.hadoop.executionengine.spark.converter;

import java.io.IOException;
import java.util.List;

import scala.collection.JavaConversions;

import org.apache.pig.backend.hadoop.executionengine.physicalLayer.relationalOperators.POUnion;
import org.apache.pig.backend.hadoop.executionengine.spark.SparkUtil;
import org.apache.pig.data.Tuple;
import org.apache.spark.SparkContext;
import org.apache.spark.rdd.RDD;
import org.apache.spark.rdd.UnionRDD;

public class UnionConverter implements RDDConverter<Tuple, Tuple, POUnion> {

    private final SparkContext sc;

    public UnionConverter(SparkContext sc) {
        this.sc = sc;
    }

    @Override
    public RDD<Tuple> convert(List<RDD<Tuple>> predecessors,
            POUnion physicalOperator) throws IOException {
        SparkUtil.assertPredecessorSizeGreaterThan(predecessors,
                physicalOperator, 0);
        UnionRDD<Tuple> unionRDD = new UnionRDD<Tuple>(sc,
                JavaConversions.asScalaBuffer(predecessors),
                SparkUtil.getManifest(Tuple.class));
        return unionRDD;
    }

}


text:
module Graph

using AutoHashEquals

abstract Pattern{C}

@auto_hash_equals type Choice{C} <: Pattern{C}
    patterns::Vector{Pattern{C}}
end

@auto_hash_equals type Sequence{C} <: Pattern{C}
    patterns::Vector{Pattern{C}}
end

@auto_hash_equals type Repeat{C} <: Pattern{C}
    pattern::Pattern{C}
    lo::Int
    hi::Int
end

@auto_hash_equals type Range{C} <: Pattern{C}
    lo::C
    hi::C
end

Literal{C}(c::C) = Range{C}(c, c)
Wild{C}(::Type{C}) = Range(typemin(C), typemax(C))

@auto_hash_equals type Group{C} <: Pattern{C}
    index::Int
    pattern::Pattern{C}
end

end


text:
from keystone import exception

class VomsError(exception.Error):
    """Voms credential management error"""

    errors = {
        0: ('none', None),
        1: ('nosocket', 'Socket problem'),
        2: ('noident', 'Cannot identify itself (certificate problem)'),
        3: ('comm', 'Server problem'),
        4: ('param', 'Wrong parameters'),
        5: ('noext', 'VOMS extension missing'),
        6: ('noinit', 'Initialization error'),
        7: ('time', 'Error in time checking'),
        8: ('idcheck', 'User data in extension different from the real'),
        9: ('extrainfo', 'VO name and URI missing'),
        10: ('format', 'Wrong data format'),
        11: ('nodata', 'Empty extension'),
        12: ('parse', 'Parse error'),
        13: ('dir', 'Directory error'),
        14: ('sign', 'Signature error'),
        15: ('server', 'Unidentifiable VOMS server'),
        16: ('mem', 'Memory problems'),
        17: ('verify', 'Generic verification error'),
        18: ('type', 'Returned data of unknown type'),
        19: ('order', 'Ordering different than required'),
        20: ('servercode', 'Error from the server'),
        21: ('notavail', 'Method not available'),
    }

    http_codes = {
        5: (400, "Bad Request"),
        11: (400, "Bad Request"),
        14: (401, "Not Authorized"),
    }

    def __init__(self, code):
        short, message = self.errors.get(code, ('oops',
                                                'Unknown error %d' % code))
        message = "(%s, %s)" % (code, message)
        super(VomsError, self).__init__(message=message)

        code, title = self.http_codes.get(code, (500, "Unexpected Error"))
        self.code = code
        self.title = title