text:
// ==========================================================================
//                 SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2015, Knut Reinert, FU Berlin
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//     * Neither the name of Knut Reinert or the FU Berlin nor the names of
//       its contributors may be used to endorse or promote products derived
//       from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ==========================================================================
// Author: Andreas Gogol-Doering <andreas.doering@mdc-berlin.de>
// Author: David Weese <david.weese@fu-berlin.de>
// ==========================================================================
// Adaptions for STL strings to SeqAn strings.
// ==========================================================================

#ifndef SEQAN_SEQUENCE_ADAPT_STD_STRING_H_
#define SEQAN_SEQUENCE_ADAPT_STD_STRING_H_

namespace seqan {

// ===========================================================================
// Enums, Tags, Classes, Specializations
// ===========================================================================

// ===========================================================================
// Concepts
// ===========================================================================

// ----------------------------------------------------------------------------
// Concept StringConcept
// ----------------------------------------------------------------------------

template <typename TChar, typename TCharTraits, typename TAlloc>
SEQAN_CONCEPT_IMPL((std::basic_string<TChar, TCharTraits, TAlloc>), (StringConcept));           // resizable container

template <typename TChar, typename TCharTraits, typename TAlloc>
SEQAN_CONCEPT_IMPL((std::basic_string<TChar, TCharTraits, TAlloc> const), (ContainerConcept));  // read-only container

// ===========================================================================
// Metafunctions
// ===========================================================================

template <typename TChar, typename TCharTraits, typename TAlloc>
struct StdContainerIterator< std::basic_string<TChar, TCharTraits, TAlloc> >
{
    typedef std::basic_string<TChar, TCharTraits, TAlloc> TContainer;
    typedef typename TContainer::iterator Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct StdContainerIterator< std::basic_string<TChar, TCharTraits, TAlloc> const>
{
    typedef std::basic_string<TChar, TCharTraits, TAlloc> TContainer;
    typedef typename TContainer::const_iterator Type;
};

// std::string can be assumed to be contigous, see
// http://stackoverflow.com/questions/1986966/does-s0-point-to-contiguous-characters-in-a-stdstring
template <typename TChar, typename TCharTraits, typename TAlloc>
struct IsContiguous< std::basic_string<TChar, TCharTraits, TAlloc> > :
    True {};

template <typename  TChar, typename TCharTraits, typename TAlloc>
struct IsContiguous< std::basic_string<TChar, TCharTraits, TAlloc> const>
        : IsContiguous< std::basic_string<TChar, TCharTraits, TAlloc> > {};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Value< std::basic_string<TChar, TCharTraits, TAlloc> >
{
    typedef typename std::basic_string<TChar, TCharTraits, TAlloc>::value_type Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Value< std::basic_string<TChar, TCharTraits, TAlloc> const>
        : Value< std::basic_string<TChar, TCharTraits, TAlloc> > {};

// TODO(holtgrew): GetValue is a reference?! I thought the reverse was true in respect to Value<>.

template <typename TChar, typename TCharTraits, typename TAlloc>
struct GetValue< std::basic_string<TChar, TCharTraits, TAlloc> >
{
    typedef typename std::basic_string<TChar, TCharTraits, TAlloc>::reference Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct GetValue< std::basic_string<TChar, TCharTraits, TAlloc> const>
{
    typedef typename std::basic_string<TChar, TCharTraits, TAlloc>::const_reference Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Reference< std::basic_string<TChar, TCharTraits, TAlloc> >
{
    typedef typename std::basic_string<TChar, TCharTraits, TAlloc>::reference Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Reference< std::basic_string<TChar, TCharTraits, TAlloc> const>
{
    typedef typename std::basic_string<TChar, TCharTraits, TAlloc>::const_reference Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Iterator< std::basic_string<TChar, TCharTraits, TAlloc>, Standard >
{
    typedef TChar * Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Iterator< std::basic_string<TChar, TCharTraits, TAlloc> const, Standard>
{
    typedef TChar const * Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Position< std::basic_string<TChar, TCharTraits, TAlloc> >
{
    typedef typename std::basic_string<TChar, TCharTraits, TAlloc>::size_type Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Position< std::basic_string<TChar, TCharTraits, TAlloc> const>
        : Position< std::basic_string<TChar, TCharTraits, TAlloc> > {};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Size< std::basic_string<TChar, TCharTraits, TAlloc> >
{
    typedef typename std::basic_string<TChar, TCharTraits, TAlloc>::size_type Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Size< std::basic_string<TChar, TCharTraits, TAlloc> const>
        : Size< std::basic_string<TChar, TCharTraits, TAlloc> > {};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct DefaultOverflowImplicit< std::basic_string<TChar, TCharTraits, TAlloc> >
{
    typedef Generous Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct IsSequence<std::basic_string<TChar, TCharTraits, TAlloc> > : True {};

// ----------------------------------------------------------------------------
// Metafunction Chunk
// ----------------------------------------------------------------------------

// Chunk interface for std::basic strings.
template <typename TChar, typename TCharTraits, typename TAlloc, typename TSpec>
struct Chunk<Iter<std::basic_string<TChar, TCharTraits, TAlloc>, AdaptorIterator<TChar*, TSpec> > >
{
    typedef typename Chunk<std::basic_string<TChar, TCharTraits, TAlloc> >::Type Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSpec>
struct Chunk<Iter<std::basic_string<TChar, TCharTraits, TAlloc> const, AdaptorIterator<TChar*, TSpec> > > :
    Chunk<Iter<std::basic_string<TChar, TCharTraits, TAlloc>, AdaptorIterator<TChar*, TSpec> > > {};

// ===========================================================================
// Functions
// ===========================================================================

template <typename TChar, typename TCharTraits, typename TAlloc>
inline void const *
getObjectId(std::basic_string<TChar, TCharTraits, TAlloc> const & me)
{
    SEQAN_CHECKPOINT;
    if (me.empty())
        return NULL;
    else
        return (& *(me.end() - 1)) + 1;
}

// Based on http://stackoverflow.com/questions/1986966/does-s0-point-to-contiguous-characters-in-a-stdstring
// we can rely on contiguous memory

template <typename TChar, typename TCharTraits, typename TAlloc>
inline typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc>, Standard>::Type
begin(std::basic_string<TChar, TCharTraits, TAlloc> & me,
      Standard)
{
    return &me[0];
}
template <typename TChar, typename TCharTraits, typename TAlloc>
inline typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc> const, Standard>::Type
begin(std::basic_string<TChar, TCharTraits, TAlloc> const & me,
      Standard)
{
    return me.data();
}

template <typename TChar, typename TCharTraits, typename TAlloc>
inline typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc>, Standard>::Type
end(std::basic_string<TChar, TCharTraits, TAlloc> & me,
    Standard)
{
    return &me[me.size()];
}
template <typename TChar, typename TCharTraits, typename TAlloc>
inline typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc> const, Standard>::Type
end(std::basic_string<TChar, TCharTraits, TAlloc> const & me,
    Standard)
{
    return me.data() + me.size();
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TPos>
inline typename GetValue< std::basic_string<TChar, TCharTraits, TAlloc> >::Type
value(std::basic_string<TChar, TCharTraits, TAlloc> & me,
      TPos pos)
{
    SEQAN_CHECKPOINT;
    return me[pos];
}
template <typename TChar, typename TCharTraits, typename TAlloc, typename TPos>
inline typename GetValue< std::basic_string<TChar, TCharTraits, TAlloc> const>::Type
value(std::basic_string<TChar, TCharTraits, TAlloc> const & me,
      TPos pos)
{
    SEQAN_CHECKPOINT;
    return me[pos];
}

template <typename TChar, typename TCharTraits, typename TAlloc>
inline typename std::basic_string<TChar, TCharTraits, TAlloc>::size_type
length(std::basic_string<TChar, TCharTraits, TAlloc> const & me)
{
    SEQAN_CHECKPOINT;
    return me.length();
}

template <typename TChar, typename TCharTraits, typename TAlloc>
inline typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type
capacity(std::basic_string<TChar, TCharTraits, TAlloc> const & me)
{
    SEQAN_CHECKPOINT;
    return me.capacity();
}

template <typename TChar, typename TCharTraits, typename TAlloc>
inline bool
empty(std::basic_string<TChar, TCharTraits, TAlloc> const & me)
{
    SEQAN_CHECKPOINT;
    return me.empty();
}

template <typename TChar, typename TCharTraits, typename TAlloc>
inline void
clear(std::basic_string<TChar, TCharTraits, TAlloc> & me)
{
    SEQAN_CHECKPOINT;
    me.clear();
}

//////////////////////////////////////////////////////////////////////////////
//assign to std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource & source)
{
    SEQAN_CHECKPOINT;
    assign(target, source, Generous());
}
template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source)
{
    SEQAN_CHECKPOINT;
    assign(target, source, Generous());
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource, typename TSize>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource & source,
       TSize limit)
{
    SEQAN_CHECKPOINT;
    assign(target, source, limit, Generous());
}
template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource, typename TSize>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source,
       TSize limit)
{
    SEQAN_CHECKPOINT;
    assign(target, source, limit, Generous());
}

//____________________________________________________________________________

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource & source,
       Generous)
{
    SEQAN_CHECKPOINT;
    target.assign(begin(source, Standard()), end(source, Standard()));
}
template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source,
       Generous)
{
    SEQAN_CHECKPOINT;
    target.assign(begin(source, Standard()), end(source, Standard()));
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign_std_string_Generous_impl(std::basic_string<TChar, TCharTraits, TAlloc> & target,
                                TSource & source,
                                typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit)
{
    SEQAN_CHECKPOINT;
    typename Iterator<TSource const, Standard>::Type source_begin = begin(source, Standard());
    typename Size<TSource const>::Type source_length = length(source);
    if (source_length > limit)
    {
        source_length = limit;
    }
    target.assign(source_begin, source_begin + source_length);
}
template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource & source,
       typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit,
       Generous)
{
    SEQAN_CHECKPOINT;
    assign_std_string_Generous_impl(target, source, limit);
}
template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source,
       typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit,
       Generous)
{
    SEQAN_CHECKPOINT;
    assign_std_string_Generous_impl(target, source, limit);
}

//____________________________________________________________________________

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource & source,
       Limit)
{
    SEQAN_CHECKPOINT;
    assign(target, source, target.capacity(), Generous());
}
template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source,
       Limit)
{
    SEQAN_CHECKPOINT;
    assign(target, source, target.capacity(), Generous());
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource & source,
       typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit,
       Limit)
{
    SEQAN_CHECKPOINT;
    if (limit > target.capacity())
    {
        limit = target.capacity();
    }

    assign(target, source, limit, Generous());
}
template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source,
       typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit,
       Limit)
{
    SEQAN_CHECKPOINT;
    if (limit > target.capacity())
    {
        limit = target.capacity();
    }

    assign(target, source, limit, Generous());
}

//////////////////////////////////////////////////////////////////////////////
//append to std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
append(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source,
       Generous)
{
    SEQAN_CHECKPOINT;
    target.append(begin(source, Standard()), end(source, Standard()));
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
append(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source,
       typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit,
       Generous)
{
    SEQAN_CHECKPOINT;
    typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type target_length = target.length();
    if (target_length > limit)
    {
        target.resize(limit);
    }
    else
    {
        limit -= target_length;
        typename Iterator<TSource const, Standard>::Type source_begin = begin(source, Standard());
        typename Size<TSource const>::Type source_length = length(source);
        if (source_length > limit)
        {
            source_length = limit;
        }
        target.append(source_begin, source_begin + source_length);
    }
}

//____________________________________________________________________________

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
append(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source,
       Limit)
{
    SEQAN_CHECKPOINT;
    append(target, source, target.capacity(), Generous());
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
append(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source,
       typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit,
       Limit)
{
    SEQAN_CHECKPOINT;
    if (limit > target.capacity())
    {
        limit = target.capacity();
    }

    append(target, source, limit, Generous());
}

//////////////////////////////////////////////////////////////////////////////
template <typename TChar, typename TCharTraits, typename TAlloc, typename TValue, typename TTag>
inline void
appendValue(std::basic_string<TChar, TCharTraits, TAlloc> & me,
            TValue const & _value,
            TTag)
{
    SEQAN_CHECKPOINT;
    me.push_back(_value);
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TValue>
inline void
appendValue(std::basic_string<TChar, TCharTraits, TAlloc> & me,
            TValue const & _value,
            Limit)
{
    SEQAN_CHECKPOINT;
    if (capacity(me) > length(me)) me.push_back(_value);
}

//////////////////////////////////////////////////////////////////////////////
//replace to std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
replace(std::basic_string<TChar, TCharTraits, TAlloc> & target,
        typename Position< std::basic_string<TChar, TCharTraits, TAlloc> >::Type pos_begin,
        typename Position< std::basic_string<TChar, TCharTraits, TAlloc> >::Type pos_end,
        TSource const & source,
        Generous)
{
    SEQAN_CHECKPOINT;
    target.replace(target.begin() + pos_begin, target.begin() + pos_end, begin(source, Standard()), end(source, Standard()));
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
replace(std::basic_string<TChar, TCharTraits, TAlloc> & target,
        typename Position< std::basic_string<TChar, TCharTraits, TAlloc> >::Type pos_begin,
        typename Position< std::basic_string<TChar, TCharTraits, TAlloc> >::Type pos_end,
        TSource const & source,
        typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit,
        Generous)
{
    SEQAN_CHECKPOINT;
    if (pos_begin >= limit)
    {
        target.resize(limit);
    }
    else
    {
        typename Iterator<TSource const, Standard>::Type source_begin = begin(source, Standard());
        typename Size<TSource const>::Type source_length = length(source);
        typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type pos_mid = pos_begin + source_length;
        if (pos_mid > limit)
        {
            target.replace(target.begin() + pos_begin, target.begin() + limit, source_begin, source_begin + limit - pos_begin);
            target.resize(limit);
        }
        else
        {
            target.replace(target.begin() + pos_begin, target.begin() + pos_end, source_begin, end(source, Standard()));
            if (target.length() > limit)
            {
                target.resize(limit);
            }
        }
    }
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
replace(std::basic_string<TChar, TCharTraits, TAlloc> & target,
        typename Position< std::basic_string<TChar, TCharTraits, TAlloc> >::Type pos_begin,
        typename Position< std::basic_string<TChar, TCharTraits, TAlloc> >::Type pos_end,
        TSource const & source,
        Limit)
{
    SEQAN_CHECKPOINT;
    replace(target, pos_begin, pos_end, source, target.capacity(), Generous());
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
replace(std::basic_string<TChar, TCharTraits, TAlloc> & target,
        typename Position< std::basic_string<TChar, TCharTraits, TAlloc> >::Type pos_begin,
        typename Position< std::basic_string<TChar, TCharTraits, TAlloc> >::Type pos_end,
        TSource const & source,
        typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit,
        Limit)
{
    SEQAN_CHECKPOINT;
    if (limit > target.capacity())
    {
        limit = target.capacity();
    }

    replace(target, pos_begin, pos_end, source, limit, Generous());
}

//////////////////////////////////////////////////////////////////////////////
// handling of iterators as begin and end

/*
template<typename TChar, typename TCharTraits, typename TAlloc, typename TSource, typename TExpand>
inline void
replace(std::basic_string<TChar, TCharTraits, TAlloc> & target,
        typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc>, Rooted>::Type pos_begin,
        typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc>, Rooted>::Type pos_end,
        TSource & source,
        Tag<TExpand> tag)
{
    replace(target, position(pos_begin), position(pos_end), source, tag);
}

template<typename TChar, typename TCharTraits, typename TAlloc, typename TSource, typename TExpand>
inline void
replace(std::basic_string<TChar, TCharTraits, TAlloc> & target,
        typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc>, Rooted>::Type pos_begin,
        typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc>, Rooted>::Type pos_end,
        TSource & source,
        typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit,
        Tag<TExpand> tag)
{
    replace(target,  position(pos_begin),  position(pos_end), source, tag);
}
*/

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSize, typename TExpand>
inline typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type
reserve(
    std::basic_string<TChar, TCharTraits, TAlloc> & seq,
    TSize new_capacity,
    Tag<TExpand> tag)
{
    SEQAN_CHECKPOINT;
    seq.reserve(new_capacity);
    return _capacityReturned(seq, new_capacity, tag);
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSize>
inline typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type
reserve(
    std::basic_string<TChar, TCharTraits, TAlloc> & seq,
    TSize new_capacity,
    Insist const &)
{
    SEQAN_CHECKPOINT;
    // do nothing
    return _capacityReturned(seq, new_capacity, Insist());
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSize>
inline typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type
reserve(
    std::basic_string<TChar, TCharTraits, TAlloc> & seq,
    TSize new_capacity,
    Limit const &)
{
    SEQAN_CHECKPOINT;
    // do nothing
    return _capacityReturned(seq, new_capacity, Limit());
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSize, typename TExpand>
inline typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type
resize(
    std::basic_string<TChar, TCharTraits, TAlloc> & me,
    TSize new_length,
    Tag<TExpand>)
{
    SEQAN_CHECKPOINT;
    me.resize(new_length);
    return me.length();
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSize, typename TExpand>
inline typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type
resize(
    std::basic_string<TChar, TCharTraits, TAlloc> & me,
    TSize new_length,
    TChar const & val,
    Tag<TExpand>)
{
    SEQAN_CHECKPOINT;
    me.resize(new_length, val);
    return me.length();
}

inline char const *
toCString(std::string const & me)
{
    SEQAN_CHECKPOINT;
    return me.c_str();
}

}  // namespace seqan

#endif  // #ifndef SEQAN_SEQUENCE_ADAPT_STD_STRING_H_


text:
<!DOCTYPE html>

    <title>Congratulations, you're an Open Access Hero!</title>

    This Open Access Week, we're honoring researchers who've made
    100% of their publications free to read online--researchers like you!
    Well done...only 2% of our users managed to pull this off.

    Share it on Twitter!

    Keep up the great work,

    Heather and Jason

redpajama_set_name: RedPajamaGithub


text:
using System;

namespace SimpleNetBenchmark.Configurators
{
    public class MemoryCollectingBenchmarkHostConfigurator : IBenchmarkHostConfigurator
    {
        public void Init()
        {
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
        }

        public void Deinit()
        {
        }
    }
}


text:
using Cosmos.Common.Extensions;
using ZLibrary.Constants;
namespace ZLibrary.Machine
{
    // TODO: Create an object class instead of these extensions?
    public static class ZObject
    {
        public const ushort MAX_OBJECT = 2000;

        public const ushort O1_PARENT = 4;
        public const ushort O1_SIBLING = 5;
        public const ushort O1_CHILD = 6;
        public const ushort O1_PROPERTY_OFFSET = 7;
        public const ushort O1_SIZE = 9;

        public const ushort O4_PARENT = 6;
        public const ushort O4_SIBLING = 8;
        public const ushort O4_CHILD = 10;
        public const ushort O4_PROPERTY_OFFSET = 12;
        public const ushort O4_SIZE = 14;

        public static string GetObjectName(this ZMachine aMachine, ushort aObject)
        {
            ushort objAddress = aMachine.GetObjectAddress(aObject);

            if (aMachine.Story.Header.Version <= FileVersion.V3)
            {
                objAddress += O1_PROPERTY_OFFSET;
            }
            else
            {
                objAddress += O4_PROPERTY_OFFSET;
            }

            aMachine.Memory.GetWord(objAddress, out ushort nameAddress);

            return ZText.DecodeString((ushort)(nameAddress + 1));
        }

        public static ushort GetObjectAddress(this ZMachine aMachine, ushort aObject)
        {
            if (aObject > ((aMachine.Story.Header.Version <= FileVersion.V3) ? 255 : MAX_OBJECT))
            {
                aMachine.Output.PrintString("@Attempt to address illegal object ");
                aMachine.Output.PrintString(aObject.ToHex());
                aMachine.Output.PrintString(".  This is normally fatal.");
                aMachine.Output.PrintZSCII(13);
            }

            if (aMachine.Story.Header.Version <= FileVersion.V3)
            {
                return (ushort) (aMachine.Story.Header.ObjectsOffset + ((aObject - 1) * O1_SIZE + 62));
            }

            return (ushort) (aMachine.Story.Header.ObjectsOffset + ((aObject - 1) * O4_SIZE + 126));
        }

        public static ushort GetFirstProperty(this ZMachine aMachine, ushort aObject)
        {
            ushort xObjectAddress = aMachine.GetObjectAddress(aObject);
            aMachine.Memory.GetWord(xObjectAddress + 7, out ushort propTable);
            aMachine.Memory.GetByte(propTable, out byte nameSize);
            propTable += (ushort)(2 * nameSize + 1);
            return propTable;
        }

        public static ushort GetNextProperty(this ZMachine aMachine, ushort aProperty)
        {
            aMachine.Memory.GetByte(aProperty, out byte value);
            aProperty++;

            if (aMachine.Story.Header.Version <= FileVersion.V3)
            {
                value >>= 5;
            }
            else if (!((value & 0x80) > 0))
            {
                value >>= 6;
            }
            else
            {
                aMachine.Memory.GetByte(aProperty, out value);
                value &= 0x3f;

                if (value == 0)
                {
                    value = 64;
                }

            }

            return (ushort) (aProperty + value + 1);
        }

        public static void UnlinkObject(this ZMachine aMachine, ushort aObject)
        {
            if (aObject == 0)
            {
                return;
            }

            ushort xObjectAddress = aMachine.GetObjectAddress(aObject);

            if (aMachine.Story.Header.Version <= FileVersion.V3)
            {
                byte zero = 0;

                xObjectAddress += O1_PARENT;
                aMachine.Memory.GetByte(xObjectAddress, out byte xParentObject);
                if (xParentObject == 0)
                {
                    return;
                }

                aMachine.Memory.SetByte(xObjectAddress, zero);
                xObjectAddress += O1_SIBLING - O1_PARENT;
                aMachine.Memory.GetByte(xObjectAddress, out byte xOlderSibling);
                aMachine.Memory.SetByte(xObjectAddress, zero);

                ushort xParentAddress = (ushort) (aMachine.GetObjectAddress(xParentObject) + O1_CHILD);
                aMachine.Memory.GetByte(xParentAddress, out byte xYoungerSibling);

                if (xYoungerSibling == aObject)
                {
                    aMachine.Memory.SetByte(xParentAddress, xOlderSibling);
                }
                else
                {
                    ushort xSiblingAddress;
                    do
                    {
                        xSiblingAddress = (ushort) (aMachine.GetObjectAddress(xYoungerSibling) + O1_SIBLING);
                        aMachine.Memory.GetByte(xSiblingAddress, out xYoungerSibling);
                    } while (xYoungerSibling != aObject);

                    aMachine.Memory.SetByte(xSiblingAddress, xOlderSibling);
                }

            }
            else
            {
                ushort zero = 0;

                xObjectAddress += O4_PARENT;
                aMachine.Memory.GetWord(xObjectAddress, out ushort xParentObject);
                if (xParentObject == 0)
                {
                    return;
                }

                aMachine.Memory.SetWord(xObjectAddress, zero);
                xObjectAddress += O4_SIBLING - O4_PARENT;
                aMachine.Memory.GetWord(xObjectAddress, out ushort xOlderSibling);
                aMachine.Memory.SetWord(xObjectAddress, zero);

                ushort xParentAddress = (ushort) (aMachine.GetObjectAddress(xParentObject) + O4_CHILD);
                aMachine.Memory.GetWord(xParentAddress, out ushort xYoungerSibling);

                if (xYoungerSibling == aObject)
                {
                    aMachine.Memory.SetWord(xParentAddress, xOlderSibling);
                }
                else
                {
                    ushort xSiblingAddress;
                    do
                    {
                        xSiblingAddress = (ushort) (aMachine.GetObjectAddress(xYoungerSibling) + O4_SIBLING);
                        aMachine.Memory.GetWord(xYoungerSibling, out xYoungerSibling);
                    } while (xYoungerSibling != aObject);

                    aMachine.Memory.SetWord(xSiblingAddress, xOlderSibling);
                }
            }
        }
    }
}


text:
package org.apereo.cas.gauth.web.flow;

import org.apereo.cas.configuration.CasConfigurationProperties;
import org.apereo.cas.gauth.credential.GoogleAuthenticatorTokenCredential;
import org.apereo.cas.util.CollectionUtils;
import org.apereo.cas.web.flow.CasWebflowConstants;
import org.apereo.cas.web.flow.configurer.AbstractCasMultifactorWebflowConfigurer;
import org.apereo.cas.web.flow.configurer.CasMultifactorWebflowCustomizer;

import lombok.val;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.webflow.definition.registry.FlowDefinitionRegistry;
import org.springframework.webflow.engine.builder.support.FlowBuilderServices;

import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * This is {@link GoogleAuthenticatorMultifactorWebflowConfigurer}.
 *
 * @author Misagh Moayyed
 * @since 5.0.0
 */
public class GoogleAuthenticatorMultifactorWebflowConfigurer extends AbstractCasMultifactorWebflowConfigurer {

    /**
     * Webflow event id.
     */
    public static final String MFA_GAUTH_EVENT_ID = "mfa-gauth";

    public GoogleAuthenticatorMultifactorWebflowConfigurer(final FlowBuilderServices flowBuilderServices,
                                                           final FlowDefinitionRegistry loginFlowDefinitionRegistry,
                                                           final FlowDefinitionRegistry flowDefinitionRegistry,
                                                           final ConfigurableApplicationContext applicationContext,
                                                           final CasConfigurationProperties casProperties,
                                                           final List<CasMultifactorWebflowCustomizer> mfaFlowCustomizers) {
        super(flowBuilderServices, loginFlowDefinitionRegistry,
            applicationContext, casProperties, Optional.of(flowDefinitionRegistry),
            mfaFlowCustomizers);
    }

    @Override
    protected void doInitialize() {
        multifactorAuthenticationFlowDefinitionRegistries.forEach(registry -> {
            val flow = getFlow(registry, MFA_GAUTH_EVENT_ID);
            createFlowVariable(flow, CasWebflowConstants.VAR_ID_CREDENTIAL, GoogleAuthenticatorTokenCredential.class);

            flow.getStartActionList().add(createEvaluateAction(CasWebflowConstants.ACTION_ID_INITIAL_FLOW_SETUP));
            createEndState(flow, CasWebflowConstants.STATE_ID_SUCCESS);

            val initLoginFormState = createActionState(flow, CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM,
                createEvaluateAction("prepareGoogleAuthenticatorLoginAction"),
                createEvaluateAction(CasWebflowConstants.ACTION_ID_INIT_LOGIN_ACTION));
            createTransitionForState(initLoginFormState, CasWebflowConstants.TRANSITION_ID_SUCCESS, CasWebflowConstants.STATE_ID_CHECK_ACCOUNT_REGISTRATION);
            setStartState(flow, initLoginFormState);

            val acctRegCheckState = createActionState(flow, CasWebflowConstants.STATE_ID_CHECK_ACCOUNT_REGISTRATION,
                createEvaluateAction("googleAccountCheckRegistrationAction"));
            createTransitionForState(acctRegCheckState, CasWebflowConstants.TRANSITION_ID_REGISTER, CasWebflowConstants.STATE_ID_VIEW_REGISTRATION);
            createTransitionForState(acctRegCheckState, CasWebflowConstants.TRANSITION_ID_CONFIRM, "viewConfirmRegistration");
            createTransitionForState(acctRegCheckState, CasWebflowConstants.TRANSITION_ID_SUCCESS, CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM);

            val acctRegSaveState = createActionState(flow, CasWebflowConstants.STATE_ID_SAVE_REGISTRATION,
                createEvaluateAction("googleSaveAccountRegistrationAction"));
            createTransitionForState(acctRegSaveState, CasWebflowConstants.TRANSITION_ID_SUCCESS, CasWebflowConstants.STATE_ID_CHECK_ACCOUNT_REGISTRATION);
            createStateDefaultTransition(acctRegSaveState, CasWebflowConstants.STATE_ID_CHECK_ACCOUNT_REGISTRATION);

            val realSubmitState = createActionState(flow, CasWebflowConstants.STATE_ID_REAL_SUBMIT,
                createEvaluateAction("validateSelectedRegistrationAction"),
                createEvaluateAction(CasWebflowConstants.ACTION_ID_OTP_AUTHENTICATION_ACTION));
            createTransitionForState(realSubmitState, CasWebflowConstants.TRANSITION_ID_SUCCESS, CasWebflowConstants.STATE_ID_SUCCESS);
            createTransitionForState(realSubmitState, CasWebflowConstants.TRANSITION_ID_ERROR, CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM);

            val setPrincipalAction = createSetAction("viewScope.principal", "conversationScope.authentication.principal");

            val propertiesToBind = CollectionUtils.wrapList("token", "accountId");
            val binder = createStateBinderConfiguration(propertiesToBind);
            val viewLoginFormState = createViewState(flow, CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM,
                "gauth/casGoogleAuthenticatorLoginView", binder);
            createStateModelBinding(viewLoginFormState, CasWebflowConstants.VAR_ID_CREDENTIAL, GoogleAuthenticatorTokenCredential.class);
            viewLoginFormState.getEntryActionList().add(setPrincipalAction);

            createTransitionForState(viewLoginFormState, CasWebflowConstants.TRANSITION_ID_SUBMIT,
                CasWebflowConstants.STATE_ID_REAL_SUBMIT, Map.of("bind", Boolean.TRUE, "validate", Boolean.TRUE));
            createTransitionForState(viewLoginFormState, CasWebflowConstants.TRANSITION_ID_REGISTER, CasWebflowConstants.STATE_ID_VIEW_REGISTRATION,
                Map.of("bind", Boolean.FALSE, "validate", Boolean.FALSE));
            createTransitionForState(viewLoginFormState, CasWebflowConstants.TRANSITION_ID_SELECT, "viewConfirmRegistration",
                Map.of("bind", Boolean.FALSE, "validate", Boolean.FALSE));

            val regViewState = createViewState(flow, CasWebflowConstants.STATE_ID_VIEW_REGISTRATION, "gauth/casGoogleAuthenticatorRegistrationView");
            regViewState.getEntryActionList().addAll(setPrincipalAction, createEvaluateAction("googleAccountCreateRegistrationAction"));
            createTransitionForState(regViewState, CasWebflowConstants.TRANSITION_ID_SUBMIT, CasWebflowConstants.STATE_ID_SAVE_REGISTRATION);

            val confirmRegViewState = createViewState(flow, "viewConfirmRegistration", "gauth/casGoogleAuthenticatorConfirmRegistrationView");
            confirmRegViewState.getEntryActionList().add(setPrincipalAction);

            createTransitionForState(confirmRegViewState, CasWebflowConstants.TRANSITION_ID_REGISTER, CasWebflowConstants.STATE_ID_VIEW_REGISTRATION);
            createTransitionForState(confirmRegViewState, CasWebflowConstants.TRANSITION_ID_DELETE, "googleAccountDeleteDevice");
            createTransitionForState(confirmRegViewState, CasWebflowConstants.TRANSITION_ID_SELECT,
                CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM,
                createEvaluateAction("googleAccountConfirmSelectionAction"));

            val deleteDeviceState = createActionState(flow, "googleAccountDeleteDevice", "googleAccountDeleteDeviceAction");
            createTransitionForState(deleteDeviceState, CasWebflowConstants.STATE_ID_SUCCESS, acctRegCheckState.getId());

        });

        registerMultifactorProviderAuthenticationWebflow(getLoginFlow(), MFA_GAUTH_EVENT_ID,
            casProperties.getAuthn().getMfa().getGauth().getId());
    }
}


text:
require 'spec_helper'

describe Viagogo::Public::API::Categories do
  before do
    @client = Viagogo::Public::Client.new(:consumer_key => 'CK',
                                          :consumer_secret => 'CS',
                                          :access_token => 'AT',
                                          :access_token_secret => 'AS')
  end

  describe "#category" do
    it "makes HTTP get request" do
      stub_request(:any, /.*/).to_return(:body => "{}")
      @client.category 1
      expect(a_request(:get, /.*/)).to have_been_made
    end

    it "makes request for the correct resource" do
      expected_resource = 50
      expected_params = {:foo => "foo", :bar => "bar"}
      stub_get("/Public/Category/#{expected_resource}").
          with(:query => expected_params).
          to_return(:body => "{}")
      @client.category expected_resource, expected_params
      expect(a_get("/Public/Category/#{expected_resource}").with(:query => expected_params)).to have_been_made
    end

    it "returns Viagogo::Category created from the response" do
      stub_get("/Public/Category/1").to_return({:body => fixture("category.json")})
      expect(@client.category 1).to be_an_instance_of(Viagogo::Category)
    end
  end

  describe "#categories_top" do
    it "makes HTTP get request" do
      stub_request(:any, /.*/).to_return(:body => "{}")
      @client.categories_top "US"
      expect(a_request(:get, /.*/)).to have_been_made
    end

    it "makes request for the correct resource" do
      expected_resource = "/Public/Category/AD/Top"
      expected_params = {:foo => "foo", :bar => "bar"}
      stub_get(expected_resource).with(:query => expected_params).to_return(:body => "{}")
      @client.categories_top "AD", expected_params
      expect(a_get(expected_resource).with(:query => expected_params)).to have_been_made
    end

    it "returns Viagogo::Page created from the response" do
      stub_request(:any, /.*/).to_return(:body => fixture("categories.json"))
      expect(@client.categories_top "GB").to be_an_instance_of(Viagogo::Page)
    end
  end

  describe "#categories_parents" do
    it "makes HTTP get request" do
      stub_request(:any, /.*/).to_return(:body => "{}")
      @client.categories_parents "US", 501
      expect(a_request(:get, /.*/)).to have_been_made
    end

    it "makes request for the correct resource" do
      expected_resource = "/Public/Category/GB/Parents/21"
      expected_params = {:foo => "foo", :bar => "bar"}
      stub_get(expected_resource).with(:query => expected_params).to_return(:body => "{}")
      @client.categories_parents "GB", 21, expected_params
      expect(a_get(expected_resource).with(:query => expected_params)).to have_been_made
    end

    it "returns Viagogo::Page created from the response" do
      stub_request(:any, /.*/).to_return(:body => fixture("categories.json"))
      expect(@client.categories_parents "GB", 0).to be_an_instance_of(Viagogo::Page)
    end
  end

  describe "#categories_children" do
    it "makes HTTP get request" do
      stub_request(:any, /.*/).to_return(:body => "{}")
      @client.categories_children "US", 501
      expect(a_request(:get, /.*/)).to have_been_made
    end

    it "makes request for the correct resource" do
      expected_resource = "/Public/Category/GB/Children/21"
      expected_params = {:foo => "foo", :bar => "bar"}
      stub_get(expected_resource).with(:query => expected_params).to_return(:body => "{}")
      @client.categories_children "GB", 21, expected_params
      expect(a_get(expected_resource).with(:query => expected_params)).to have_been_made
    end

    it "returns Viagogo::Page created from the response" do
      stub_request(:any, /.*/).to_return(:body => fixture("categories.json"))
      expect(@client.categories_children "GB", 0).to be_an_instance_of(Viagogo::Page)
    end
  end
end


text:
#pragma warning(push)
#pragma warning(disable: 4273)
#pragma warning(disable: 4351)
#include "../dukpp03/include/3rdparty/tpunit++/tpunit++.hpp"
#pragma warning(pop)

int main(int argc, char** argv)
{
    /**
     * Run all of the registered tpunit++ tests. Returns 0 if
     * all tests are successful, otherwise returns the number
     * of failing assertions.
     */
    int result = tpunit::Tests::Run();
    return result;
}


text:
<!doctype html>

	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>Comm | ironworks</title>
	<meta name="description" content="">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="../assets/css/main.css">

						Search
						<input id="tsd-search-field" type="text" />

Preparing search index...

The search index is not available

					ironworks

						Options

								All

Public

Public/Protected

All

							<input type="checkbox" id="tsd-filter-inherited" checked />
							Inherited
							<input type="checkbox" id="tsd-filter-externals" checked />
							Externals
							<input type="checkbox" id="tsd-filter-only-exported" />
							Only exported

					Menu

					Globals

					"src/eventing/Comm"

					Comm

Class Comm

Hierarchy

						Eventer

								Comm

Implements

IEventEmitter

IEventer

IComm

Index

Constructors

constructor

Properties

default<wbr>Max<wbr>Listeners

event

me

opts

service<wbr>Worker<wbr>Name

who<wbr>Service

Methods

ack

add<wbr>Listener

all<wbr>Annotated<wbr>Listeners

all<wbr>Comm<wbr>Listeners

all<wbr>Interceptors

all<wbr>Listeners

annotate

annotated<wbr>Listeners

answer

ask

check

confirm

dispose

emit

get<wbr>Comm<wbr>Event

get<wbr>Emit

get<wbr>Last<wbr>Event

has<wbr>Listener

info

inform

intercept

listen

listeners

on

once

only<wbr>Once

prefix

remove<wbr>All<wbr>Annotated<wbr>Listeners

remove<wbr>All<wbr>Listeners

remove<wbr>Annotated<wbr>Listeners

remove<wbr>Listener

request

respond

set<wbr>Max<wbr>Listeners

tell

verify

get<wbr>Listen<wbr>Method<wbr>Name

listener<wbr>Count

Constructors

constructor

new <wbr>Comm(service: IAm, whoAmI: IAm, serviceWorkerName: string, opts?: ICommOpts): Comm

Overwrites Eventer.constructor

Defined in src/eventing/Comm.ts:30

Parameters

service: IAm

whoAmI: IAm

serviceWorkerName: string

Optional opts: ICommOpts

Returns Comm

Properties

default<wbr>Max<wbr>Listeners

default<wbr>Max<wbr>Listeners: number

Implementation of IComm.defaultMaxListeners

Inherited from EventEmitter.defaultMaxListeners

Defined in node_modules/iron-beam/module/iron-beam/iron-beam.d.ts:66

Protected event

event: string

Inherited from Eventer.event

Defined in src/eventing/Eventer.ts:27

me

me: IAm

Defined in src/eventing/Comm.ts:30

Protected opts

opts: Options<IEventerOpts>

Inherited from Eventer.opts

Defined in src/eventing/Eventer.ts:28

Private service<wbr>Worker<wbr>Name

service<wbr>Worker<wbr>Name: string

Defined in src/eventing/Comm.ts:28

Private who<wbr>Service

who<wbr>Service: IAm

Defined in src/eventing/Comm.ts:27

Methods

ack

ack(event: ICommEventData | string, listener: function): IComm

Overwrites Eventer.ack

Defined in src/eventing/Comm.ts:143

Parameters

event: ICommEventData | string

listener: function

(callback: function, anno?: any, emit?: ICommEmit): void

Parameters

callback: function

(e: Error): void

Parameters

e: Error

Returns void

Optional anno: any

Optional emit: ICommEmit

Returns void

Returns IComm

add<wbr>Listener

add<wbr>Listener(event: ICommEventData | string, method: Function): IComm

Implementation of IComm.addListener

Overwrites Eventer.addListener

Defined in src/eventing/Comm.ts:196

Parameters

event: ICommEventData | string

method: Function

Returns IComm

all<wbr>Annotated<wbr>Listeners

all<wbr>Annotated<wbr>Listeners(anno?: any, event?: string): IListener[]

Implementation of IComm.allAnnotatedListeners

Overwrites EventEmitter.allAnnotatedListeners

Defined in src/eventing/Comm.ts:264

Parameters

Optional anno: any

Optional event: string

Returns IListener[]

all<wbr>Comm<wbr>Listeners

all<wbr>Comm<wbr>Listeners(): ICommListener[]

Implementation of IComm.allCommListeners

Defined in src/eventing/Comm.ts:51

Returns ICommListener[]

all<wbr>Interceptors

all<wbr>Interceptors(): IInterceptors[]

Implementation of IComm.allInterceptors

Inherited from EventEmitter.allInterceptors

Defined in node_modules/iron-beam/module/iron-beam/iron-beam.d.ts:85

Returns IInterceptors[]

all<wbr>Listeners

all<wbr>Listeners(): IListener[]

Implementation of IComm.allListeners

Inherited from EventEmitter.allListeners

Defined in node_modules/iron-beam/module/iron-beam/iron-beam.d.ts:83

Returns IListener[]

annotate

annotate(anno: any): IComm

Implementation of IComm.annotate

Overwrites Eventer.annotate

Defined in src/eventing/Comm.ts:185

Parameters

anno: any

Returns IComm

annotated<wbr>Listeners

annotated<wbr>Listeners(event: string, anno?: any): IListener[]

Implementation of IComm.annotatedListeners

Overwrites EventEmitter.annotatedListeners

Defined in src/eventing/Comm.ts:259

Parameters

event: string

Optional anno: any

Returns IListener[]

answer

answer<answerType>(event: ICommEventData | string, listener: function): IComm

Overwrites Eventer.answer

Defined in src/eventing/Comm.ts:157

Type parameters

answerType

Parameters

event: ICommEventData | string

listener: function

(callback: function, anno?: any, emit?: ICommEmit): void

Parameters

callback: function

(e: Error, answer?: answerType): void

Parameters

e: Error

Optional answer: answerType

Returns void

Optional anno: any

Optional emit: ICommEmit

Returns void

Returns IComm

ask

ask<answerType>(event: ICommEmitData | string, callback: function): boolean

Overwrites Eventer.ask

Defined in src/eventing/Comm.ts:118

Type parameters

answerType

Parameters

event: ICommEmitData | string

callback: function

(e: Error, answer?: answerType, anno?: any): void

Parameters

e: Error

Optional answer: answerType

Optional anno: any

Returns void

Returns boolean

check

check<checkType>(event: ICommEmitData | string, toCheck: checkType, callback: function): boolean

Overwrites Eventer.check

Defined in src/eventing/Comm.ts:113

Type parameters

checkType

Parameters

event: ICommEmitData | string

toCheck: checkType

callback: function

(e: Error, anno?: any): void

Parameters

e: Error

Optional anno: any

Returns void

Returns boolean

confirm

confirm(event: ICommEmitData | string, callback: function): boolean

Overwrites Eventer.confirm

Defined in src/eventing/Comm.ts:108

Parameters

event: ICommEmitData | string

callback: function

(e: Error, anno?: any): void

Parameters

e: Error

Optional anno: any

Returns void

Returns boolean

dispose

dispose(callback?: function): void

Overwrites Eventer.dispose

Defined in src/eventing/Comm.ts:277

Parameters

Optional callback: function

(): void

Returns void

Returns void

emit

emit(event: ICommEventData | string, ...args: any[]): boolean

Overwrites EventEmitter.emit

Defined in src/eventing/Comm.ts:208

Parameters

event: ICommEventData | string

Rest ...args: any[]

Returns boolean

Private get<wbr>Comm<wbr>Event

get<wbr>Comm<wbr>Event(event: ICommEventData | string, method?: string): ICommEvent

Defined in src/eventing/Comm.ts:63

Parameters

event: ICommEventData | string

Optional method: string

Returns ICommEvent

Private get<wbr>Emit

get<wbr>Emit(event: ICommEmitData | string, method?: string): ICommEmit

Defined in src/eventing/Comm.ts:81

Parameters

event: ICommEmitData | string

Optional method: string

Returns ICommEmit

get<wbr>Last<wbr>Event

get<wbr>Last<wbr>Event(): string

Inherited from Eventer.getLastEvent

Defined in src/eventing/Eventer.ts:42

Returns string

has<wbr>Listener

has<wbr>Listener(event: ICommEventData | string, method?: string): boolean

Implementation of IComm.hasListener

Overwrites EventEmitter.hasListener

Defined in src/eventing/Comm.ts:254

Parameters

event: ICommEventData | string

Optional method: string

Returns boolean

info

info<infoType>(event: ICommEventData | string, listener: function): IComm

Overwrites Eventer.info

Defined in src/eventing/Comm.ts:137

Type parameters

infoType

Parameters

event: ICommEventData | string

listener: function

(info: infoType, anno?: any, emit?: ICommEmit): void

Parameters

info: infoType

Optional anno: any

Optional emit: ICommEmit

Returns void

Returns IComm

inform

inform<infoType>(event: ICommEmitData | string, info: infoType): boolean

Overwrites Eventer.inform

Defined in src/eventing/Comm.ts:103

Type parameters

infoType

Parameters

event: ICommEmitData | string

info: infoType

Returns boolean

intercept

intercept(event: ICommEventData | string, interceptors: IInterceptors): IComm

Implementation of IComm.intercept

Overwrites Eventer.intercept

Defined in src/eventing/Comm.ts:271

Parameters

event: ICommEventData | string

interceptors: IInterceptors

Returns IComm

listen

listen(event: ICommEventData | string, listener: function): IComm

Overwrites Eventer.listen

Defined in src/eventing/Comm.ts:131

Parameters

event: ICommEventData | string

listener: function

(anno?: any, emit?: ICommEmit): void

Parameters

Optional anno: any

Optional emit: ICommEmit

Returns void

Returns IComm

listeners

listeners(event: ICommEventData | string): Function[]

Overwrites EventEmitter.listeners

Defined in src/eventing/Comm.ts:249

Parameters

event: ICommEventData | string

Returns Function[]

on

on(event: ICommEventData | string, method: Function): IComm

Implementation of IComm.on

Overwrites Eventer.on

Defined in src/eventing/Comm.ts:190

Parameters

event: ICommEventData | string

method: Function

Returns IComm

once

once(event: ICommEventData | string, method: Function): IComm

Implementation of IComm.once

Overwrites Eventer.once

Defined in src/eventing/Comm.ts:202

Parameters

event: ICommEventData | string

method: Function

Returns IComm

only<wbr>Once

only<wbr>Once(): IComm

Implementation of IComm.onlyOnce

Overwrites Eventer.onlyOnce

Defined in src/eventing/Comm.ts:174

Returns IComm

prefix

prefix(): string

Implementation of IComm.prefix

Defined in src/eventing/Comm.ts:47

Returns string

remove<wbr>All<wbr>Annotated<wbr>Listeners

remove<wbr>All<wbr>Annotated<wbr>Listeners(anno?: any, event?: ICommEventData | string): IComm

Implementation of IComm.removeAllAnnotatedListeners

Overwrites Eventer.removeAllAnnotatedListeners

Defined in src/eventing/Comm.ts:237

Parameters

Optional anno: any

Optional event: ICommEventData | string

Returns IComm

remove<wbr>All<wbr>Listeners

remove<wbr>All<wbr>Listeners(event?: ICommEventData | string): IComm

Implementation of IComm.removeAllListeners

Overwrites Eventer.removeAllListeners

Defined in src/eventing/Comm.ts:225

Parameters

Optional event: ICommEventData | string

Returns IComm

remove<wbr>Annotated<wbr>Listeners

remove<wbr>Annotated<wbr>Listeners(event: string, anno?: any): IComm

Overwrites Eventer.removeAnnotatedListeners

Defined in src/eventing/Comm.ts:219

Parameters

event: string

Optional anno: any

Returns IComm

remove<wbr>Listener

remove<wbr>Listener(event: ICommEventData | string, method: Function): IComm

Implementation of IComm.removeListener

Overwrites Eventer.removeListener

Defined in src/eventing/Comm.ts:213

Parameters

event: ICommEventData | string

method: Function

Returns IComm

request

request<requestType, responseType>(event: ICommEmitData | string, request: requestType, callback: function): boolean

Overwrites Eventer.request

Defined in src/eventing/Comm.ts:123

Type parameters

requestType

responseType

Parameters

event: ICommEmitData | string

request: requestType

callback: function

(e: Error, response?: responseType, anno?: any): void

Parameters

e: Error

Optional response: responseType

Optional anno: any

Returns void

Returns boolean

respond

respond<requestType, responseType>(event: ICommEventData | string, listener: function): IComm

Overwrites Eventer.respond

Defined in src/eventing/Comm.ts:165

Type parameters

requestType

responseType

Parameters

event: ICommEventData | string

listener: function

(request: requestType, callback: function, anno?: any, emit?: ICommEmit): void

Parameters

request: requestType

callback: function

(e: Error, response?: responseType): void

Parameters

e: Error

Optional response: responseType

Returns void

Optional anno: any

Optional emit: ICommEmit

Returns void

Returns IComm

set<wbr>Max<wbr>Listeners

set<wbr>Max<wbr>Listeners(max: number): IComm

Implementation of IComm.setMaxListeners

Overwrites Eventer.setMaxListeners

Defined in src/eventing/Comm.ts:180

Parameters

max: number

Returns IComm

tell

tell(event: ICommEmitData | string): boolean

Overwrites Eventer.tell

Defined in src/eventing/Comm.ts:98

Parameters

event: ICommEmitData | string

Returns boolean

verify

verify<checkType>(event: ICommEventData | string, listener: function): IComm

Overwrites Eventer.verify

Defined in src/eventing/Comm.ts:149

Type parameters

checkType

Parameters

event: ICommEventData | string

listener: function

(toCheck: checkType, callback: function, anno?: any, emit?: ICommEmit): void

Parameters

toCheck: checkType

callback: function

(e: Error): void

Parameters

e: Error

Returns void

Optional anno: any

Optional emit: ICommEmit

Returns void

Returns IComm

Static get<wbr>Listen<wbr>Method<wbr>Name

get<wbr>Listen<wbr>Method<wbr>Name(emitMethodName: string): string

Inherited from Eventer.getListenMethodName

Defined in src/eventing/Eventer.ts:47

Parameters

emitMethodName: string

Returns string

Static listener<wbr>Count

listener<wbr>Count(emitter: EventEmitter, eventName: string): number

Inherited from EventEmitter.listenerCount

Defined in node_modules/iron-beam/module/iron-beam/iron-beam.d.ts:91

Parameters

emitter: EventEmitter

eventName: string

Returns number

						Globals

						"src/eventing/<wbr>Comm"

						Comm

								constructor

								default<wbr>Max<wbr>Listeners

								event

								me

								opts

								service<wbr>Worker<wbr>Name

								who<wbr>Service

								ack

								add<wbr>Listener

								all<wbr>Annotated<wbr>Listeners

								all<wbr>Comm<wbr>Listeners

								all<wbr>Interceptors

								all<wbr>Listeners

								annotate

								annotated<wbr>Listeners

								answer

								ask

								check

								confirm

								dispose

								emit

								get<wbr>Comm<wbr>Event

								get<wbr>Emit

								get<wbr>Last<wbr>Event

								has<wbr>Listener

								info

								inform

								intercept

								listen

								listeners

								on

								once

								only<wbr>Once

								prefix

								remove<wbr>All<wbr>Annotated<wbr>Listeners

								remove<wbr>All<wbr>Listeners

								remove<wbr>Annotated<wbr>Listeners

								remove<wbr>Listener

								request

								respond

								set<wbr>Max<wbr>Listeners

								tell

								verify

								get<wbr>Listen<wbr>Method<wbr>Name

								listener<wbr>Count

Legend

Module

Object literal

Variable

Function

Function with type parameter

Index signature

Type alias

Enumeration

Enumeration member

Property

Method

Interface

Interface with type parameter

Constructor

Property

Method

Index signature

Class

Class with type parameter

Constructor

Property

Method

Accessor

Index signature

Inherited constructor

Inherited property

Inherited method

Inherited accessor

Protected property

Protected method

Protected accessor

Private property

Private method

Private accessor

Static property

Static method

Generated using TypeDoc


text:
Future Slider
=============

Future Slider is designed to be as customisable as possible.
As an experienced developer you'll understand how frustrating it can be to work
with 3rd party modules.  For that reason Future Slider is built around the
widget system, slideshows (banners) are widgets so can be placed anywhere and
individual slides can contain other widgets.

Install
-------

Recommended installation is by Composer:

    composer require clockworkgeek/futureslider

If installing by modman please note there is one dependency:

    modman clone https://github.com/clockworkgeek/formelements
    modman clone https://github.com/clockworkgeek/FutureSlider


text:
<?php

namespace Ekyna\Bundle\SubscriptionBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;

/**
 * Class PricingPass
 * @package Ekyna\Bundle\SubscriptionBundle\DependencyInjection\Compiler
 * @author Étienne Dauvergne <contact@ekyna.com>
 */
class PricingPass implements CompilerPassInterface
{
    /**
     * {@inheritdoc}
     */
    public function process(ContainerBuilder $container)
    {
        $providerKey = $container->getParameter('ekyna_subscription.subscription.price_provider');

        if (!$container->hasDefinition($providerKey)) {
            throw new ServiceNotFoundException($providerKey);
        }
        $providerDef = $container->getDefinition($providerKey);

        // Pricing repository
        $container
            ->getDefinition('ekyna_subscription.pricing.repository')
            ->addMethodCall('setPriceProvider', array($providerDef))
        ;

        // Subscription generator
        $container
            ->getDefinition('ekyna_subscription.subscription.generator')
            ->addMethodCall('setPriceProvider', array($providerDef))
        ;
    }
}


text:
package ca.csf.connect4;

public class Cell {
    public CellType cellType;

    public enum CellType {
        RED, BLACK, EMPTY
    }

    public Cell(CellType cellType) {
        this.cellType = cellType;
    }
}


text:
Tracks the commits in a [git](http://git-scm.com/) repository.

## Source Configuration

* `uri`: *Required.* The location of the repository.

* `branch`: The branch to track. This is *optional* if the resource is
   only used in `get` steps; however, it is *required* when used in a `put` step. If unset for `get`, the repository's default branch is used; usually `master` but [could be different](https://help.github.com/articles/setting-the-default-branch/).

* `private_key`: *Optional.* Private key to use when pulling/pushing.
    Example:

    ```yaml
    private_key: |
      -----BEGIN RSA PRIVATE KEY-----
      MIIEowIBAAKCAQEAtCS10/f7W7lkQaSgD/mVeaSOvSF9ql4hf/zfMwfVGgHWjj+W
      <Lots more text>
      DWiJL+OFeg9kawcUL6hQ8JeXPhlImG6RTUffma9+iGQyyBMCGd1l
      -----END RSA PRIVATE KEY-----
    ```

* `private_key_user`: *Optional.* Enables setting User in the ssh config.

* `private_key_passphrase`: *Optional.* To unlock `private_key` if it is protected by a passphrase.

* `forward_agent`: *Optional* Enables ForwardAgent SSH option when set to true. Useful when using proxy/jump hosts. Defaults to false.

* `username`: *Optional.* Username for HTTP(S) auth when pulling/pushing.
  This is needed when only HTTP/HTTPS protocol for git is available (which does not support private key auth)
  and auth is required.

* `password`: *Optional.* Password for HTTP(S) auth when pulling/pushing.

* `paths`: *Optional.* If specified (as a list of glob patterns), only changes
  to the specified files will yield new versions from `check`.

* `ignore_paths`: *Optional.* The inverse of `paths`; changes to the specified
  files are ignored.

  Note that if you want to push commits that change these files via a `put`,
  the commit will still be "detected", as [`check` and `put` both introduce
  versions](https://github.com/concourse/concourse/issues/534).
  To avoid this you should define a second resource that you use for commits
  that change files that you don't want to feed back into your pipeline - think
  of one as read-only (with `ignore_paths`) and one as write-only (which
  shouldn't need it).

* `skip_ssl_verification`: *Optional.* Skips git ssl verification by exporting
  `GIT_SSL_NO_VERIFY=true`.

* `tag_filter`: *Optional.* If specified, the resource will only detect commits
  that have a tag matching the expression that have been made against
  the `branch`. Patterns are [glob(7)](http://man7.org/linux/man-pages/man7/glob.7.html)
  compatible (as in, bash compatible).

* `tag_regex`: *Optional.* If specified, the resource will only detect commits
  that have a tag matching the expression that have been made against
  the `branch`. Patterns are [grep](https://www.gnu.org/software/grep/manual/grep.html)
  compatible (extended matching enabled, matches entire lines only). Ignored if
  `tag_filter` is also specified.

* `fetch_tags`: *Optional.* If `true` the flag `--tags` will be used to fetch
  all tags in the repository. If `false` no tags will be fetched.

* `submodule_credentials`: *Optional.* List of credentials for HTTP(s) auth when pulling/pushing private git submodules which are not stored in the same git server as the container repository.
    Example:

    ```
    submodule_credentials:
    - host: github.com
      username: git-user
      password: git-password
    - <another-configuration>
    ```

    Note that `host` is specified with no protocol extensions.

* `git_config`: *Optional.* If specified as (list of pairs `name` and `value`)
  it will configure git global options, setting each name with each value.

  This can be useful to set options like `credential.helper` or similar.

  See the [`git-config(1)` manual page](https://www.kernel.org/pub/software/scm/git/docs/git-config.html)
  for more information and documentation of existing git options.

* `disable_ci_skip`: *Optional.* Allows for commits that have been labeled with `[ci skip]` or `[skip ci]`
   previously to be discovered by the resource.

* `commit_verification_keys`: *Optional.* Array of GPG public keys that the
  resource will check against to verify the commit (details below).

* `commit_verification_key_ids`: *Optional.* Array of GPG public key ids that
  the resource will check against to verify the commit (details below). The
  corresponding keys will be fetched from the key server specified in
  `gpg_keyserver`. The ids can be short id, long id or fingerprint.

* `gpg_keyserver`: *Optional.* GPG keyserver to download the public keys from.
  Defaults to `hkp://keyserver.ubuntu.com/`.

* `git_crypt_key`: *Optional.* Base64 encoded
  [git-crypt](https://github.com/AGWA/git-crypt) key. Setting this will
  unlock / decrypt the repository with `git-crypt`. To get the key simply
  execute `git-crypt export-key -- - | base64` in an encrypted repository.

* `https_tunnel`: *Optional.* Information about an HTTPS proxy that will be used to tunnel SSH-based git commands over.
  Has the following sub-properties:
  * `proxy_host`: *Required.* The host name or IP of the proxy server
  * `proxy_port`: *Required.* The proxy server's listening port
  * `proxy_user`: *Optional.* If the proxy requires authentication, use this username
  * `proxy_password`: *Optional.* If the proxy requires authenticate,
      use this password

* `commit_filter`: *Optional.* Object containing commit message filters
  * `exclude`: *Optional.* Array containing strings that should
    cause a commit to be skipped
  * `include`: *Optional.* Array containing strings that
    *MUST* be included in commit messages for the commit to not be
    skipped

  **Note**: *You must escape any regex sensitive characters, since the string is used as a regex filter.*
  For example, using `[skip deploy]` or `[deploy skip]` to skip non-deployment related commits in a deployment pipeline:

  ```yaml
  commit_filter:
    exclude: ["\\[skip deploy\\]", "\\[deploy skip\\]"]
  ```

* `version_depth`: *Optional.* The number of versions to return when performing a check

* `search_remote_refs`: *Optional.* True to search remote refs for the input version when checking out during the get step.
    This can be useful during the `get` step after a `put` step for unconventional workflows. One example workflow is the
    `refs/for/<branch>` workflow used by gerrit which 'magically' creates a `refs/changes/nnn` reference instead
    of the straight forward `refs/for/<branch>` reference that a git remote would usually create.
    See also `out params.refs_prefix`.

### Example

Resource configuration for a private repo with an HTTPS proxy:

``` yaml
resources:
- name: source-code
  type: git
  source:
    uri: git@github.com:concourse/git-resource.git
    branch: master
    private_key: |
      -----BEGIN RSA PRIVATE KEY-----
      MIIEowIBAAKCAQEAtCS10/f7W7lkQaSgD/mVeaSOvSF9ql4hf/zfMwfVGgHWjj+W
      <Lots more text>
      DWiJL+OFeg9kawcUL6hQ8JeXPhlImG6RTUffma9+iGQyyBMCGd1l
      -----END RSA PRIVATE KEY-----
    git_config:
    - name: core.bigFileThreshold
      value: 10m
    disable_ci_skip: true
    git_crypt_key: AEdJVEN...snip...AAA==
    https_tunnel:
      proxy_host: proxy-server.mycorp.com
      proxy_port: 3128
      proxy_user: myuser
      proxy_password: myverysecurepassword
```

Resource configuration for a private repo with a private submodule from different git server:

``` yaml
resources:
- name: source-code
  type: git
  source:
    uri: git@github.com:concourse/git-resource.git
    branch: master
    submodule_credentials:
    - host: some.other.git.server
      username: user
      password: verysecurepassword
    private_key: |
      -----BEGIN RSA PRIVATE KEY-----
      MIIEowIBAAKCAQEAtCS10/f7W7lkQaSgD/mVeaSOvSF9ql4hf/zfMwfVGgHWjj+W
      <Lots more text>
      DWiJL+OFeg9kawcUL6hQ8JeXPhlImG6RTUffma9+iGQyyBMCGd1l
      -----END RSA PRIVATE KEY-----
```

Fetching a repo with only 100 commits of history:

``` yaml
- get: source-code
  params: {depth: 100}
```

Pushing local commits to the repo:

``` yaml
- get: some-other-repo
- put: source-code
  params: {repository: some-other-repo}
```

Fetching a repo pinned to a specific commit:

``` yaml
resources:
- name: source-code
  type: git
  source:
    uri: git@github.com:concourse/git-resource.git
    branch: master
  version:
    ref: commit-sha
```

## Behavior

### `check`: Check for new commits

The repository is cloned (or pulled if already present), and any commits
from the given version on are returned. If no version is given, the ref
for `HEAD` is returned.

Any commits that contain the string `[ci skip]` will be ignored. This
allows you to commit to your repository without triggering a new version.

### `in`: Clone the repository, at the given ref

Clones the repository to the destination, and locks it down to a given ref.
It will return the same given ref as version.

`git-crypt` encrypted repositories will automatically be decrypted, when the
correct key is provided set in `git_crypt_key`.

#### Parameters

* `depth`: *Optional.* If a positive integer is given, *shallow* clone the
  repository using the `--depth` option. To prevent newer commits that do
  not pass a `paths` filter test from skewing the cloned history away from
  `version.ref`, this resource will automatically deepen the clone until
  `version.ref` is found again. It will deepen with exponentially increasing steps
  until a maximum of 127 + `depth` commits or else resort to unshallow the repository.

* `fetch_tags`: *Optional.* If `true` the flag `--tags` will be used to fetch
  all tags in the repository. If `false` no tags will be fetched.

  Will override `fetch_tags` source configuration if defined.

* `submodules`: *Optional.* If `none`, submodules will not be
  fetched. If specified as a list of paths, only the given paths will be
  fetched. If not specified, or if `all` is explicitly specified, all
  submodules are fetched.

* `submodule_recursive`: *Optional.* If `false`, a flat submodules checkout is performed. If not specified, or if `true` is explicitly specified, a recursive checkout is performed.

* `submodule_remote`: *Optional.* If `true`, the submodules are checked out for the specified remote branch specified in the `.gitmodules` file of the repository. If not specified, or if `false` is explicitly specified, the tracked sub-module revision of the repository is used to check out the submodules.

* `disable_git_lfs`: *Optional.* If `true`, will not fetch Git LFS files.

* `clean_tags`: *Optional.* If `true` all incoming tags will be deleted. This
  is useful if you want to push tags, but have reasonable doubts that the tags
  cached with the resource are outdated. The default value is `false`.

* `short_ref_format`: *Optional.* When populating `.git/short_ref` use this `printf` format. Defaults to `%s`.

* `timestamp_format`: *Optional.* When populating `.git/commit_timestamp` use this options to pass to [`git log --date`](https://git-scm.com/docs/git-log#Documentation/git-log.txt---dateltformatgt). Defaults to `iso8601`.

* `describe_ref_options`: *Optional.* When populating `.git/describe_ref` use this options to call [`git describe`](https://git-scm.com/docs/git-describe). Defaults to `--always --dirty --broken`.

#### GPG signature verification

If `commit_verification_keys` or `commit_verification_key_ids` is specified in
the source configuration, it will additionally verify that the resulting commit
has been GPG signed by one of the specified keys. It will error if this is not
the case.

#### Additional files populated

* `.git/committer`: For committer notification on failed builds.
 This special file `.git/committer` which is populated with the email address
 of the author of the last commit. This can be used together with  an email
 resource like [mdomke/concourse-email-resource](https://github.com/mdomke/concourse-email-resource)
 to notify the committer in an on_failure step.

* `.git/ref`: Version reference detected and checked out. It will usually contain
 the commit SHA-1 ref, but also the detected tag name when using `tag_filter` or
 `tag_regex`.

* `.git/short_ref`: Short (first seven characters) of the `.git/ref`. Can be templated with `short_ref_format` parameter.

* `.git/commit_message`: For publishing the Git commit message on successful builds.

 * `.git/commit_timestamp`: For tagging builds with a timestamp.

* `.git/describe_ref`: Version reference detected and checked out. Can be templated with `describe_ref_options` parameter.
 By default, it will contain the `<latest annoted git tag>-<the number of commit since the tag>-g<short_ref>` (eg. `v1.6.2-1-g13dfd7b`).
 If the repo was never tagged before, this falls back to a short commit SHA-1 ref.

### `out`: Push to a repository

Push the checked-out reference to the source's URI and branch. All tags are
also pushed to the source. If a fast-forward for the branch is not possible
and the `rebase` parameter is not provided, the push will fail.

#### Parameters

* `repository`: *Required.* The path of the repository to push to the source.

* `rebase`: *Optional.* If pushing fails with non-fast-forward, continuously
  attempt rebasing and pushing.

* `merge`: *Optional.* If pushing fails with non-fast-forward, continuously
  attempt to merge remote to local before pushing. Only one of `merge` or
  `rebase` can be provided, but not both.

* `returning`: *Optional.* When passing the `merge` flag, specify whether the
  merge commit or the original, unmerged commit should be passed as the output
  ref. Options are `merged` and `unmerged`. Defaults to `merged`.

* `tag`: *Optional.* If this is set then HEAD will be tagged. The value should be
  a path to a file containing the name of the tag.

* `only_tag`: *Optional.* When set to 'true' push only the tags of a repo.

* `tag_prefix`: *Optional.* If specified, the tag read from the file will be
prepended with this string. This is useful for adding `v` in front of
version numbers.

* `force`: *Optional.* When set to 'true' this will force the branch to be
pushed regardless of the upstream state.

* `annotate`: *Optional.* If specified the tag will be an
  [annotated](https://git-scm.com/book/en/v2/Git-Basics-Tagging#Annotated-Tags)
  tag rather than a
  [lightweight](https://git-scm.com/book/en/v2/Git-Basics-Tagging#Lightweight-Tags)
  tag. The value should be a path to a file containing the annotation message.

* `notes`: *Optional.* If this is set then notes will be added to HEAD to the
  `refs/notes/commits` ref. The value should be a path to a file containing the notes.

* `branch`: *Optional.* The branch to push commits.

  Note that the version produced by the `put` step will be picked up by subsequent `get` steps
  even if the `branch` differs from the `branch` specified in the source.
  To avoid this, you should use two resources of read-only and write-only.

* `refs_prefix`: *Optional.* Allows pushing to refs other than heads. Defaults to `refs/heads`.

  Useful when paired with `source.search_remote_refs` in cases where the git remote
  renames the ref you pushed.

## Development

### Prerequisites

* golang is *required* - version 1.9.x is tested; earlier versions may also
  work.
* docker is *required* - version 17.06.x is tested; earlier versions may also
  work.

### Running the tests

The tests have been embedded with the `Dockerfile`; ensuring that the testing
environment is consistent across any `docker` enabled platform. When the docker
image builds, the test are run inside the docker container, on failure they
will stop the build.

Run the tests with the following commands for both `alpine` and `ubuntu` images:

```sh
docker build -t git-resource --target tests -f dockerfiles/alpine/Dockerfile .
docker build -t git-resource --target tests -f dockerfiles/ubuntu/Dockerfile .
```

#### Note about the integration tests

If you want to run the integration tests, a bit more work is required. You will require
an actual git repo to which you can push and pull, configured for SSH access. To do this,
add two files to `integration-tests/ssh` (note that names **are** important):

* `test_key`: This is the private key used to authenticate against your repo.
* `test_repo`: This file contains one line of the form `test_repo_url[#test_branch]`.
  If the branch is not specified, it defaults to `master`. For example,
  `git@github.com:concourse-git-tester/git-resource-integration-tests.git` or
  `git@github.com:concourse-git-tester/git-resource-integration-tests.git#testing`

### Contributing

Please make all pull requests to the `master` branch and ensure tests pass
locally.


text: a big big world


text:
The USU Useful Script Updater
==============

This is the updater used by the scripts in this repository. You probably Don't want to download this.

But now that you're here, why not **contribute**?


text:
name             'naked'
version          '1.0.0'
description      'Bootstraps a chef-client in local mode'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
license          'Apache 2.0'
maintainer       'Marty Pauley'
maintainer_email 'marty+chef@martian.org'


text:
require 'mixins/provision'

class ProvisionInitramfsSetup
  include Genesis::Framework::Task

  init do
    @provision_config = Mixins::Config.fetch
  end

  run do
    Mixins::Provision.chroot_cmd "update-initramfs -u -k all"
  end

end


text:
package org.jcodec.codecs.mpeg12;

import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.jcodec.common.Assert;
import org.jcodec.common.NIOUtils;
import org.jcodec.common.tools.MainUtils;
import org.jcodec.common.tools.MainUtils.Cmd;
import org.jcodec.containers.mps.psi.PATSection;

/**
 * This class is part of JCodec ( www.jcodec.org ) This software is distributed
 * under FreeBSD License
 *
 * This utility relocates PAT/PMT PSI packets from anywhere within a file to the
 * beginning of the file so that the file is playable
 *
 * @author The JCodec project
 *
 */
public class HLSRelocatePMT {
    private static final int TS_START_CODE = 0x47;
    private static final int CHUNK_SIZE_PKT = 1024;
    private static final int TS_PKT_SIZE = 188;

    public static void main(String[] args) throws IOException {

        Cmd cmd = MainUtils.parseArguments(args);
        if (cmd.args.length < 2) {
            MainUtils.printHelp(new HashMap<String, String>() {
                {
                }
            }, "file in", "file out");
            return;
        }

        ReadableByteChannel in = null;
        WritableByteChannel out = null;
        try {
            in = NIOUtils.readableFileChannel(new File(cmd.args[0]));
            out = NIOUtils.writableFileChannel(new File(cmd.args[1]));
            System.err.println("Processed: " + replocatePMT(in, out) + " packets.");
        } finally {
            NIOUtils.closeQuietly(in);
            NIOUtils.closeQuietly(out);
        }
    }

    private static int replocatePMT(ReadableByteChannel in, WritableByteChannel out) throws IOException {
        ByteBuffer buf = ByteBuffer.allocate(TS_PKT_SIZE * CHUNK_SIZE_PKT);
        Set<Integer> pmtPids = new HashSet<Integer>();
        List<ByteBuffer> held = new ArrayList<ByteBuffer>();
        ByteBuffer patPkt = null;
        ByteBuffer pmtPkt = null;

        int totalPkt = 0;
        while (in.read(buf) != -1) {
            buf.flip();
            buf.limit((buf.limit() / TS_PKT_SIZE) * TS_PKT_SIZE);

            while (buf.hasRemaining()) {
                ByteBuffer pkt = NIOUtils.read(buf, TS_PKT_SIZE);
                ByteBuffer pktRead = pkt.duplicate();
                Assert.assertEquals(TS_START_CODE, pktRead.get() & 0xff);
                ++totalPkt;
                int guidFlags = ((pktRead.get() & 0xff) << 8) | (pktRead.get() & 0xff);
                int guid = (int) guidFlags & 0x1fff;
                int payloadStart = (guidFlags >> 14) & 0x1;
                int b0 = pktRead.get() & 0xff;
                int counter = b0 & 0xf;
                if ((b0 & 0x20) != 0) {
                    NIOUtils.skip(pktRead, (pktRead.get() & 0xff));
                }

                if (guid == 0 || pmtPids.contains(guid)) {
                    if (payloadStart == 1) {
                        NIOUtils.skip(pktRead, (pktRead.get() & 0xff));
                    }

                    if (guid == 0) {
                        patPkt = pkt;
                        PATSection pat = PATSection.parse(pktRead);
                        for (int pmtPid : pat.getPrograms().values())
                            pmtPids.add(pmtPid);
                    } else if (pmtPids.contains(guid)) {
                        pmtPkt = pkt;
                        out.write(patPkt);
                        out.write(pmtPkt);
                        for (ByteBuffer heldPkt : held) {
                            out.write(heldPkt);
                        }
                        held.clear();
                    }
                } else {
                    if (pmtPkt == null)
                        held.add(pkt);
                    else
                        out.write(pkt);
                }
            }
            buf.clear();
        }
        return totalPkt;
    }
}


text:
/** @file replicatetcpserver.h
 * @brief TCP/IP replication server class.
 */
/* Copyright (C) 2008,2011 Olly Betts
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 */

#ifndef XAPIAN_INCLUDED_REPLICATETCPSERVER_H
#define XAPIAN_INCLUDED_REPLICATETCPSERVER_H

#include "xapian/net/remoteconnection.h"
#include "xapian/net/tcpserver.h"

#include "xapian/visibility.h"
#include "xapian/api/replication.h"

class XAPIAN_VISIBILITY_DEFAULT ReplicateTcpServer : public TcpServer {
    /// The path to pass to DatabaseMaster.
    std::string path;

  public:
    /** Construct a ReplicateTcpServer and start listening for connections.
     *
     *  @param host	The hostname or address for the interface to listen on
     *			(or "" to listen on all interfaces).
     *  @param port	The TCP port number to listen on.
     *  @param path_	The path to the parent directory of the databases.
     */
    ReplicateTcpServer(const std::string & host, int port,
		       const std::string & path_);

    /// Destructor.
    ~ReplicateTcpServer();

    /** Handle a single connection on an already connected socket.
     *
     *  This method may be called by multiple threads.
     */
    void handle_one_connection(int socket);
};

#endif // XAPIAN_INCLUDED_REPLICATETCPSERVER_H


text:
title: Event Server Overview
---

Apache PredictionIO (incubating) offers an Event Server that collects data in an
event-based style via a RESTful API. By default, Event Server uses Apache HBase
as data store.

![EventServer Highlight](/images/eventserver-overview.png)

## What data should I collect?

The Event Server can collect and store arbitrary events. At the beginning of
your project, it is recommended to collect as much data as you can. Later on,
you can exclude data that are not relevant to your predictive model in Data
Preparator.

### Recommendation Engine

With Collaborative Filtering based Recommendation Engine, a common pattern is

```
user -- action -- item
```

where users and items have properties associated with them.

For example, for personalized book recommendation, some events to collect would
be

- User 1 purchased product X
- User 2 viewed product Y
- User 1 added product Z in the cart

User properties can be gender, age, location, etc. Item properties can be genre,
author, and other attributes that may be related to the the user's preference.

Data collection varies quite a bit based on your application and your prediction
goal. We are happy to [assist you with your
questions](mailto:support@prediction.io).


text:
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise #-}
{-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-}
{-# OPTIONS_GHC -fconstraint-solver-iterations=20 #-}
module AI.Funn.CL.Batched.Network (
  Network(..),
  params, batchSize,
  liftDiff, network,
  runNetwork
  ) where

import           Control.Applicative
import           Control.Category
import           Control.Exception
import           Control.Monad
import           Control.Monad.IO.Class
import           Data.Foldable
import           Data.Monoid
import           Data.Proxy
import           Data.Random
import           Data.Traversable
import           GHC.TypeLits
import           Prelude hiding (id)
import           System.IO.Unsafe

import           AI.Funn.CL.Batched.BTensor (BTensor(..))
import qualified AI.Funn.CL.Batched.BTensor as BT
import           AI.Funn.CL.Batched.Param (Param(..))
import qualified AI.Funn.CL.Batched.Param as Param
import           AI.Funn.CL.Tensor (Tensor)
import qualified AI.Funn.CL.Tensor as T
import qualified AI.Funn.CL.TensorLazy as TL
import           AI.Funn.Diff.Diff (Diff(..), Derivable(..))
import qualified AI.Funn.Diff.Diff as Diff
import qualified AI.Funn.Flat.Blob as Blob
import           AI.Funn.Indexed.Indexed
import           AI.Funn.Space

data Network m (ω :: Nat) (p :: Nat) a b = Network {
  netDiff :: Diff m (Param ω p, a) b,
  netInit :: RVar (Blob.Blob p)
  }

params :: Network m ω p a b -> Proxy p
params _ = Proxy

batchSize :: Network m ω p a b -> Proxy ω
batchSize _ = Proxy

network :: (Monad m, Prod ds ~ p, KnownNat ω, KnownNat p)
        => Diff m (BTensor ω ds, a) b
        -> RVar (Blob.Blob p)
        -> Network m ω p a b
network diff init = Network (Diff run) init
  where
    run (par, a) = do
      (b, k) <- runDiff diff (BTensor (Param.reshape par), a)
      return (b, backward k)
    backward k db = do
      (dpar, da) <- k db
      return (TL.fromStrict (T.reshape dpar), da)

runNetwork :: (Monad m) => Network m ω i a b -> (Tensor '[i], a) -> m (b, D b -> m (Tensor '[ω, i], D a))
runNetwork net (par, a) = do
  (b, k) <- runDiff (netDiff net) (Param par, a)
  let backward db = do
        (dpar, da) <- k db
        return (TL.toStrict dpar, da)
  return (b, backward)

connect :: (KnownDimsF [i,j,ω], Monad m) => Network m ω i a b -> Network m ω j b c -> Network m ω (i+j) a c
connect (Network one i1) (Network two i2) = Network (Diff run) init
  where
    run (par, a) = do
      let (par1, par2) = Param.split par
      (b, k1) <- runDiff one (par1, a)
      (c, k2) <- runDiff two (par2, b)
      return (c, backward k1 k2)

    backward k1 k2 dc = do
      (dpar2, db) <- k2 dc
      (dpar1, da) <- k1 db
      return (Param.appendD dpar1 dpar2, da)

    init = liftA2 Blob.cat i1 i2

instance (KnownNat ω, Monad m) => Indexed (Network m ω) where
  iid = liftDiff id
  (~>>) = connect

liftDiff :: (Monad m) => Diff m a b -> Network m ω 0 a b
liftDiff diff = Network (Diff run) (pure (Blob.fromList []))
  where
    run (_, a) = do
      (b, k) <- runDiff diff a
      return (b, backward k)
    backward k db  = do
      da <- k db
      return (TL.nul, da)

pfirst :: (Monad m) => Network m ω p a b -> Network m ω p (a,c) (b,c)
pfirst (Network diff init) = Network (Diff run) init
  where
    run (p, (a,c)) = do
      (b, k) <- runDiff diff (p, a)
      return ((b,c), backward k)
    backward k (db, dc) = do
      (dp, da) <- k db
      return (dp, (da, dc))

psecond :: (Monad m) => Network m ω p a b -> Network m ω p (c,a) (c,b)
psecond (Network diff init) = Network (Diff run) init
  where
    run (p, (c,a)) = do
      (b, k) <- runDiff diff (p, a)
      return ((c,b), backward k)
    backward k (dc, db) = do
      (dp, da) <- k db
      return (dp, (dc, da))

pswap :: (Monad m) => Network m ω 0 (a,b) (b,a)
pswap = liftDiff Diff.swap

passocL :: (Monad m) => Network m ω 0 (a,(b,c)) ((a,b),c)
passocL = liftDiff Diff.assocL

passocR :: (Monad m) => Network m ω 0 ((a,b),c) (a,(b,c))
passocR = liftDiff Diff.assocR

instance (KnownNat ω, Monad m) => Assoc (Network m ω) where
  first = pfirst
  second = psecond
  swap = pswap
  assocL = passocL
  assocR = passocR


text:
<?php
include 'head.php';
?>

Customers

<button class="btn btn-success" style="margin-left: 10px" onclick="showCustomerForm()">Add a Customer</button>

<form action="" method="get" class="form-inline" style="display: inline-block;margin-left: 10px">
    <input type="text" class="form-control" name="query" value="Customer Name">
    <button type="submit" class="btn btn-primary">Search</button>
</form>

    <form action="customers_add.php" method="post" class="form" role="form" enctype="multipart/form-data">

            Customer Name
            <input type="text" class="form-control" id="name" name="name" placeholder="Your Customer Name">

            Customer Email
            <input type="text" class="form-control" id="email" name="email" placeholder="Email">

            Phone Number
            <input type="text" class="form-control" id="phone" name="phone" placeholder="Input your phone number here like 1234567890">

            Membership
            <input type="text" class="form-control" id="membership_id" name="membership_id">

        <button type="submit" class="btn btn-default">Submit</button>
    </form>

<?php
include 'db.php';

//connect to database
$con = mysqli_connect($host, $username, $password, $database);
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL DB: " . mysqli_connect_error();
}

if(isset($_GET["query"])){
    $query = $_GET["query"];
    $result = mysqli_query($con, "SELECT * FROM Customers WHERE name LIKE '%$query%'
      or phone LIKE '%$query%' or membership_id LIKE '%$query%' ORDER BY customer_id DESC");
}
else{
    $result = mysqli_query($con, "SELECT * FROM Customers ORDER BY customer_id DESC;");
}

echo "

        ID
        Name
        Email
        Phone
        Membership

";
while ($row = mysqli_fetch_array($result)) {
    echo "
";
    echo "" . $row['customer_id'] . "	"
        . $row['name'] . "	"
        . $row['email'] . "	"
        . $row['phone'] . "	"
        . $row['membership_id'] . "	";
    echo "
";
}
echo "
";

mysqli_close($con);
include "foot.php";
?>


text:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<servico xmlns="http://servicos.gov.br/v3/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://servicos.gov.br/v3/schema ../servico.xsd">
    <nome>Declaração de Exportação - Recepção</nome>
    <sigla/>
    <nomes-populares/>
    <descricao>Entregar a Declaração de Exportação.</descricao>
    <gratuito/>
    <solicitantes/>
    <tempo-total-estimado>
        <descricao/>
    </tempo-total-estimado>
    <etapas>
        <etapa>
            <titulo/>
            <descricao/>
            <documentos>
                <default/>
            </documentos>
            <custos>
                <default/>
            </custos>
            <canais-de-prestacao>
                <default>
                    <canal-de-prestacao tipo="web">
                        <descricao>http://www.receita.fazenda.gov.br/aplicacoes/atbhe/tus/Servico.aspx?id=31&idArea=1&idAssunto=21</descricao>
                    </canal-de-prestacao>
                </default>
            </canais-de-prestacao>
        </etapa>
    </etapas>
    <orgao id="http://estruturaorganizacional.dados.gov.br/id/unidade-organizacional/77"/>
    <segmentos-da-sociedade>
        <item>Empresas</item>
    </segmentos-da-sociedade>
    <areas-de-interesse>
        <item>Economia e Finanças</item>
    </areas-de-interesse>
    <palavras-chave/>
    <legislacoes/>
</servico>