text:
// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
// (C) Copyright 2003-2007 Jonathan Turkanis
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)

// See http://www.boost.org/libs/iostreams for documentation.

// Contains machinery for performing code conversion.

#ifndef BOOST_IOSTREAMS_CODE_CONVERTER_HPP_INCLUDED
#define BOOST_IOSTREAMS_CODE_CONVERTER_HPP_INCLUDED

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif

#include <boost/iostreams/detail/config/wide_streams.hpp>
#if defined(BOOST_IOSTREAMS_NO_WIDE_STREAMS) || \
    defined(BOOST_IOSTREAMS_NO_LOCALE) \
    /**/
# error code conversion not supported on this platform
#endif

#include <algorithm>                       // max.
#include <cstring>                         // memcpy.
#include <exception>
#include <boost/config.hpp>                // DEDUCED_TYPENAME,
#include <boost/iostreams/char_traits.hpp>
#include <boost/iostreams/constants.hpp>   // default_filter_buffer_size.
#include <boost/iostreams/detail/adapter/concept_adapter.hpp>
#include <boost/iostreams/detail/adapter/direct_adapter.hpp>
#include <boost/iostreams/detail/buffer.hpp>
#include <boost/iostreams/detail/call_traits.hpp>
#include <boost/iostreams/detail/codecvt_holder.hpp>
#include <boost/iostreams/detail/codecvt_helper.hpp>
#include <boost/iostreams/detail/double_object.hpp>
#include <boost/iostreams/detail/execute.hpp>
#include <boost/iostreams/detail/forward.hpp>
#include <boost/iostreams/detail/functional.hpp>
#include <boost/iostreams/detail/ios.hpp> // failure, openmode, int types.
#include <boost/iostreams/detail/optional.hpp>
#include <boost/iostreams/detail/select.hpp>
#include <boost/iostreams/traits.hpp>
#include <boost/iostreams/operations.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/static_assert.hpp>
#include <boost/throw_exception.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_same.hpp>

// Must come last.
#include <boost/iostreams/detail/config/disable_warnings.hpp> // Borland 5.x

namespace boost { namespace iostreams {

struct code_conversion_error : BOOST_IOSTREAMS_FAILURE {
    code_conversion_error()
        : BOOST_IOSTREAMS_FAILURE("code conversion error")
        { }
};

namespace detail {

//--------------Definition of strncpy_if_same---------------------------------//

// Helper template for strncpy_if_same, below.
template<bool B>
struct strncpy_if_same_impl;

template<>
struct strncpy_if_same_impl<true> {
    template<typename Ch>
    static Ch* copy(Ch* tgt, const Ch* src, std::streamsize n)
    { return BOOST_IOSTREAMS_CHAR_TRAITS(Ch)::copy(tgt, src, n); }
};

template<>
struct strncpy_if_same_impl<false> {
    template<typename Src, typename Tgt>
    static Tgt* copy(Tgt* tgt, const Src*, std::streamsize) { return tgt; }
};

template<typename Src, typename Tgt>
Tgt* strncpy_if_same(Tgt* tgt, const Src* src, std::streamsize n)
{
    typedef strncpy_if_same_impl<is_same<Src, Tgt>::value> impl;
    return impl::copy(tgt, src, n);
}

//--------------Definition of conversion_buffer-------------------------------//

// Buffer and conversion state for reading.
template<typename Codecvt, typename Alloc>
class conversion_buffer
    : public buffer<
                 BOOST_DEDUCED_TYPENAME detail::codecvt_extern<Codecvt>::type,
                 Alloc
             >
{
public:
    typedef typename Codecvt::state_type state_type;
    conversion_buffer()
        : buffer<
              BOOST_DEDUCED_TYPENAME detail::codecvt_extern<Codecvt>::type,
              Alloc
          >(0)
    {
        reset();
    }
    state_type& state() { return state_; }
    void reset()
    {
        if (this->size())
            this->set(0, 0);
        state_ = state_type();
    }
private:
    state_type state_;
};

//--------------Definition of converter_impl----------------------------------//

// Contains member data, open/is_open/close and buffer management functions.
template<typename Device, typename Codecvt, typename Alloc>
struct code_converter_impl {
    typedef typename codecvt_extern<Codecvt>::type          extern_type;
    typedef typename category_of<Device>::type              device_category;
    typedef is_convertible<device_category, input>          can_read;
    typedef is_convertible<device_category, output>         can_write;
    typedef is_convertible<device_category, bidirectional>  is_bidir;
    typedef typename
            iostreams::select<  // Disambiguation for Tru64.
                is_bidir, bidirectional,
                can_read, input,
                can_write, output
            >::type                                         mode;
    typedef typename
            mpl::if_<
                is_direct<Device>,
                direct_adapter<Device>,
                Device
            >::type                                         device_type;
    typedef optional< concept_adapter<device_type> >        storage_type;
    typedef is_convertible<device_category, two_sequence>   is_double;
    typedef conversion_buffer<Codecvt, Alloc>               buffer_type;

    code_converter_impl() : cvt_(), flags_(0) { }

    ~code_converter_impl()
    {
        try {
            if (flags_ & f_open) close();
        } catch (...) { /* */ }
    }

    template <class T>
    void open(const T& dev, int buffer_size)
    {
        if (flags_ & f_open)
            boost::throw_exception(BOOST_IOSTREAMS_FAILURE("already open"));
        if (buffer_size == -1)
            buffer_size = default_filter_buffer_size;
        int max_length = cvt_.get().max_length();
        buffer_size = (std::max)(buffer_size, 2 * max_length);
        if (can_read::value) {
            buf_.first().resize(buffer_size);
            buf_.first().set(0, 0);
        }
        if (can_write::value && !is_double::value) {
            buf_.second().resize(buffer_size);
            buf_.second().set(0, 0);
        }
        dev_.reset(concept_adapter<device_type>(dev));
        flags_ = f_open;
    }

    void close()
    {
        detail::execute_all(
            detail::call_member_close(*this, BOOST_IOS::in),
            detail::call_member_close(*this, BOOST_IOS::out)
        );
    }

    void close(BOOST_IOS::openmode which)
    {
        if (which == BOOST_IOS::in && (flags_ & f_input_closed) == 0) {
            flags_ |= f_input_closed;
            iostreams::close(dev(), BOOST_IOS::in);
        }
        if (which == BOOST_IOS::out && (flags_ & f_output_closed) == 0) {
            flags_ |= f_output_closed;
            detail::execute_all(
                detail::flush_buffer(buf_.second(), dev(), can_write::value),
                detail::call_close(dev(), BOOST_IOS::out),
                detail::call_reset(dev_),
                detail::call_reset(buf_.first()),
                detail::call_reset(buf_.second())
            );
        }
    }

    bool is_open() const { return (flags_ & f_open) != 0;}

    device_type& dev() { return **dev_; }

    enum flag_type {
        f_open             = 1,
        f_input_closed     = f_open << 1,
        f_output_closed    = f_input_closed << 1
    };

    codecvt_holder<Codecvt>  cvt_;
    storage_type             dev_;
    double_object<
        buffer_type,
        is_double
    >                        buf_;
    int                      flags_;
};

} // End namespace detail.

//--------------Definition of converter---------------------------------------//

#define BOOST_IOSTREAMS_CONVERTER_PARAMS() , int buffer_size = -1
#define BOOST_IOSTREAMS_CONVERTER_ARGS() , buffer_size

template<typename Device, typename Codecvt, typename Alloc>
struct code_converter_base {
    typedef detail::code_converter_impl<
                Device, Codecvt, Alloc
            > impl_type;
    code_converter_base() : pimpl_(new impl_type) { }
    shared_ptr<impl_type> pimpl_;
};

template< typename Device,
          typename Codecvt = detail::default_codecvt,
          typename Alloc = std::allocator<char> >
class code_converter
    : protected code_converter_base<Device, Codecvt, Alloc>
{
private:
    typedef detail::code_converter_impl<
                Device, Codecvt, Alloc
            >                                                       impl_type;
    typedef typename impl_type::device_type                         device_type;
    typedef typename impl_type::buffer_type                         buffer_type;
    typedef typename detail::codecvt_holder<Codecvt>::codecvt_type  codecvt_type;
    typedef typename detail::codecvt_intern<Codecvt>::type          intern_type;
    typedef typename detail::codecvt_extern<Codecvt>::type          extern_type;
    typedef typename detail::codecvt_state<Codecvt>::type           state_type;
public:
    typedef intern_type                                             char_type;
    struct category
        : impl_type::mode, device_tag, closable_tag, localizable_tag
        { };
    BOOST_STATIC_ASSERT((
        is_same<
            extern_type,
            BOOST_DEDUCED_TYPENAME char_type_of<Device>::type
        >::value
    ));
public:
    code_converter() { }
#if BOOST_WORKAROUND(__GNUC__, < 3)
    code_converter(code_converter& rhs)
        : code_converter_base<Device, Codecvt, Alloc>(rhs)
        { }
    code_converter(const code_converter& rhs)
        : code_converter_base<Device, Codecvt, Alloc>(rhs)
        { }
#endif
    BOOST_IOSTREAMS_FORWARD( code_converter, open_impl, Device,
                             BOOST_IOSTREAMS_CONVERTER_PARAMS,
                             BOOST_IOSTREAMS_CONVERTER_ARGS )

        // fstream-like interface.

    bool is_open() const { return this->pimpl_->is_open(); }
    void close(BOOST_IOS::openmode which = BOOST_IOS::in | BOOST_IOS::out )
    { impl().close(which); }

        // Device interface.

    std::streamsize read(char_type*, std::streamsize);
    std::streamsize write(const char_type*, std::streamsize);
    void imbue(const std::locale& loc) { impl().cvt_.imbue(loc); }

        // Direct device access.

    Device& operator*() { return detail::unwrap_direct(dev()); }
    Device* operator->() { return &detail::unwrap_direct(dev()); }
private:
    template<typename T> // Used for forwarding.
    void open_impl(const T& t BOOST_IOSTREAMS_CONVERTER_PARAMS())
    {
        impl().open(t BOOST_IOSTREAMS_CONVERTER_ARGS());
    }

    const codecvt_type& cvt() { return impl().cvt_.get(); }
    device_type& dev() { return impl().dev(); }
    buffer_type& in() { return impl().buf_.first(); }
    buffer_type& out() { return impl().buf_.second(); }
    impl_type& impl() { return *this->pimpl_; }
};

//--------------Implementation of converter-----------------------------------//

// Implementation note: if end of stream contains a partial character,
// it is ignored.
template<typename Device, typename Codevt, typename Alloc>
std::streamsize code_converter<Device, Codevt, Alloc>::read
    (char_type* s, std::streamsize n)
{
    const extern_type*   next;        // Next external char.
    intern_type*         nint;        // Next internal char.
    std::streamsize      total = 0;   // Characters read.
    int                  status = iostreams::char_traits<char>::good();
    bool                 partial = false;
    buffer_type&         buf = in();

    do {

        // Fill buffer.
        if (buf.ptr() == buf.eptr() || partial) {
            status = buf.fill(dev());
            if (buf.ptr() == buf.eptr())
                break;
            partial = false;
        }

        // Convert.
        std::codecvt_base::result result =
            cvt().in( buf.state(),
                      buf.ptr(), buf.eptr(), next,
                      s + total, s + n, nint );
        buf.ptr() += next - buf.ptr();
        total = static_cast<std::streamsize>(nint - s);

        switch (result) {
        case std::codecvt_base::partial:
            partial = true;
            break;
        case std::codecvt_base::ok:
            break;
        case std::codecvt_base::noconv:
            {
                std::streamsize amt =
                    std::min<std::streamsize>(next - buf.ptr(), n - total);
                detail::strncpy_if_same(s + total, buf.ptr(), amt);
                total += amt;
            }
            break;
        case std::codecvt_base::error:
        default:
            buf.state() = state_type();
            boost::throw_exception(code_conversion_error());
        }

    } while (total < n && status != EOF && status != WOULD_BLOCK);

    return total == 0 && status == EOF ? -1 : total;
}

template<typename Device, typename Codevt, typename Alloc>
std::streamsize code_converter<Device, Codevt, Alloc>::write
    (const char_type* s, std::streamsize n)
{
    buffer_type&        buf = out();
    extern_type*        next;              // Next external char.
    const intern_type*  nint;              // Next internal char.
    std::streamsize     total = 0;         // Characters written.
    bool                partial = false;

    while (total < n) {

        // Empty buffer.
        if (buf.eptr() == buf.end() || partial) {
            if (!buf.flush(dev()))
                break;
            partial = false;
        }

        // Convert.
        std::codecvt_base::result result =
            cvt().out( buf.state(),
                       s + total, s + n, nint,
                       buf.eptr(), buf.end(), next );
        int progress = (int) (next - buf.eptr());
        buf.eptr() += progress;

        switch (result) {
        case std::codecvt_base::partial:
            partial = true; // Fall through.
        case std::codecvt_base::ok:
            total = static_cast<std::streamsize>(nint - s);
            break;
        case std::codecvt_base::noconv:
            {
                std::streamsize amt =
                    std::min<std::streamsize>( nint - total - s,
                                               buf.end() - buf.eptr() );
                detail::strncpy_if_same(buf.eptr(), s + total, amt);
                total += amt;
            }
            break;
        case std::codecvt_base::error:
        default:
            buf.state() = state_type();
            boost::throw_exception(code_conversion_error());
        }
    }
    return total;
}

//----------------------------------------------------------------------------//

} } // End namespaces iostreams, boost.

#include <boost/iostreams/detail/config/enable_warnings.hpp> // Borland 5.x

#endif // #ifndef BOOST_IOSTREAMS_CODE_CONVERTER_HPP_INCLUDED


text:
package com.simple.common.view.swipe;

import android.content.Context;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.widget.AbsListView;
import android.widget.ListView;

public class SuperRefreshLayout extends SwipeRefreshLayout implements AbsListView.OnScrollListener, SwipeRefreshLayout.OnRefreshListener {
    private ListView mListView;

    private int mTouchSlop;

    private SuperRefreshLayoutListener mListener;

    private boolean mIsOnLoading = false;

    private boolean mCanLoadMore = false;

    private int mYDown;

    private int mLastY;

    private int mTextColor;
    private int mFooterBackground;
    private boolean mIsMoving = false;

    public SuperRefreshLayout(Context context) {
        this(context, null);
    }

    public SuperRefreshLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
        setOnRefreshListener(this);
    }

    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {

    }

    @Override
    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
        // 滚动时到了最底部也可以加载更多
        if (canLoad()) {
            loadData();
        }
    }

    @Override
    public void onRefresh() {
        if (mListener != null && !mIsOnLoading) {
            mListener.onRefreshing();
        }
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
        // 初始化ListView对象
        if (mListView == null) {
            getListView();
        }
    }

    /**
     * 获取ListView并添加Footer
     */
    private void getListView() {
        int child = getChildCount();
        if (child > 0) {
            View childView = getChildAt(0);
            if (childView instanceof ListView) {
                mListView = (ListView) childView;
                // 设置滚动监听器给ListView, 使得滚动的情况下也可以自动加载
                mListView.setOnScrollListener(this);
            }
        }
    }

    public void setCanLoadMore() {
        this.mCanLoadMore = true;
    }

    public void setNoMoreData() {
        this.mCanLoadMore = false;
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        final int action = event.getAction();
        switch (action) {
            case MotionEvent.ACTION_DOWN:
                // 按下
                mYDown = (int) event.getRawY();
                break;

            case MotionEvent.ACTION_MOVE:
                // 移动
                mIsMoving = true;
                mLastY = (int) event.getRawY();
                break;
            case MotionEvent.ACTION_UP:
                mIsMoving = false;
                break;
            default:
                break;
        }
        return super.dispatchTouchEvent(event);
    }

    /**
     * 是否可以加载更多, 条件是到了最底部, listview不在加载中, 且为上拉操作.
     *
     * @return 是否可以加载更多
     */
    private boolean canLoad() {
        return isInBottom() && !mIsOnLoading && isPullUp() && mCanLoadMore;
    }

    /**
     * 如果到了最底部,而且是上拉操作.那么执行onLoad方法
     */
    private void loadData() {
        if (mListener != null) {
            setIsOnLoading(true);
            mListener.onLoadMore();
        }
    }

    /**
     * 是否是上拉操作
     *
     * @return 是否是上拉操作
     */
    private boolean isPullUp() {
        return (mYDown - mLastY) >= mTouchSlop;
    }

    /**
     * 设置正在加载
     *
     * @param loading loading
     */
    public void setIsOnLoading(boolean loading) {
        mIsOnLoading = loading;
        if (!mIsOnLoading) {
            mYDown = 0;
            mLastY = 0;
        }
    }

    /**
     * 判断是否到了最底部
     */
    private boolean isInBottom() {
        return (mListView != null && mListView.getAdapter() != null)
                && mListView.getLastVisiblePosition() == (mListView.getAdapter().getCount() - 1);
    }

    public interface SuperRefreshLayoutListener {
        void onRefreshing();

        void onLoadMore();
    }

    /**
     * 加载结束记得调用
     */
    public void onLoadComplete() {
        setIsOnLoading(false);
        setRefreshing(false);
    }

    /**
     * set
     *
     * @param loadListener loadListener
     */
    public void setSuperRefreshLayoutListener(SuperRefreshLayoutListener loadListener) {
        mListener = loadListener;
    }

    public boolean isMoving() {
        return mIsMoving;
    }
}

redpajama_set_name: RedPajamaGithub


text:
name             'mesos'
maintainer       'Shingo Omura'
maintainer_email 'everpeace@gmail.com'
license          'MIT'
description      'Installs/Configures mesos'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version          '0.2.2'

supports         'ubuntu', '>= 12.04'
supports         'centos', '>= 6.0'

recipe           "mesos::default", "install mesos."
recipe           "mesos::mesosphere", "install mesos from mesosphere package."
recipe           "mesos::build_from_source", "install mesos from source(default recipe)."
recipe           "mesos::master",  "configure the machine as master."
recipe           "mesos::slave",   "configure the machine as slave."
recipe           "mesos::docker-executor", "install mesos-docker executor"

depends          'java'
depends          'python'
depends          'build-essential'
depends          'maven'
depends          'ulimit'
suggests         'docker'
suggests         'zookeeper'

attribute           "mesos/type",
  :recipes       => ["mesos::build_from_source", "mesos::mesosphere", "mesos::master", "mesos::slave"],
  :display_name  => "installation type",
  :description   => "Value should be 'source' | 'mesosphere'.",
  :description   => "instlal type",
  :default       => "source"

attribute           "mesos/version",
  :recipes       => ["mesos::build_from_source", "mesos::mesosphere"],
  :display_name  => "Version to be installed.",
  :description   => "branch name or tag name at http://github.com/apache/mesos, or mesos's version name",
  :default       => "0.20.1"

attribute           "mesos/mesosphere/with_zookeeper",
  :recipes       => ["mesos::mesosphere"],
  :display_name  => "switch for installing zookeeper packages",
  :description   => "if true, zookeeper packages will be installed with mesosphere's mesos package",
  :default       => "false"

attribute           "mesos/prefix",
  :recipes       => ["mesos::build_from_source", "mesos::master", "mesos::slave"],
  :display_name  => "Prefix value to be passed to configure script",
  :description   => "prefix value to be passed to configure script",
  :default       => "/usr/local"

attribute           "mesos/home",
  :recipes       => ["mesos::build_from_source"],
  :display_name  => "mesos home directory",
  :description   => "directory which mesos sources are extracted to.",
  :default       => "/opt"

attribute           "mesos/build/skip_test",
  :recipes       => ["mesos::build_from_source"],
  :display_name  => "Flag whether test will be performed.",
  :description   => "if true, test will be skipped.",
  :default       => "true"

attribute           "mesos/ssh_opts",
  :recipes       => ["mesos::master"],
  :display_name  => "ssh options",
  :description   => "passed to be mesos-deploy-env.sh",
  :default       => "-o StrictHostKeyChecking=no -o ConnectTimeout=2"

attribute           "mesos/deploy_with_sudo",
  :recipes       => ["mesos::master"],
  :display_name  => "Flag whether sudo will be used in mesos deploy scripts",
  :description   => "Flag whether sudo will be used in mesos deploy scripts",
  :default       => "1"

attribute           "mesos/cluster_name",
  :recipes       => ["mesos::master"],
  :display_name  => "cluster name",
  :description   => "[OBSOLUTE] Human readable name for the cluster, displayed at webui"

attribute           "mesos/master_ips",
  :recipes       => ["mesos::master"],
  :display_name  => "IP list of masters",
  :description   => "used in mesos-start/stop-cluster scripts."

attribute           "mesos/slave_ips",
  :recipes       => ["mesos::master"],
  :display_name  => "IP list of slaves",
  :description   => "used in mesos-start/stop-cluster scripts."

attribute           "mesos/slave/master_url",
  :required      => "required",
  :recipes       => ["mesos::slave"],
  :display_name  => "master url",
  :description   => "[OBSOLUTE] Use mesos/slave/master.  mesos master url. this should  be host:port for non-ZooKeeper based masters, otherwise a zk:// or file://."


text:
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';

import { Users, LivechatRooms, LivechatVisitors } from '../../../models';

Meteor.methods({
	'livechat:getAgentData'({ roomId, token }) {
		check(roomId, String);
		check(token, String);

		const room = LivechatRooms.findOneById(roomId);
		const visitor = LivechatVisitors.getVisitorByToken(token);

		if (!room || room.t !== 'l' || !room.v || room.v.token !== visitor.token) {
			throw new Meteor.Error('error-invalid-room', 'Invalid room');
		}

		if (!room.servedBy) {
			return;
		}

		return Users.getAgentInfo(room.servedBy._id);
	},
});


text:
package org.verizon.userservices.service;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.verizon.userservices.application.UserServicesApplication;
import org.verizon.userservices.domain.AppUser;
import org.verizon.userservices.domain.AppGroup;

/**
 * Integration tests for {@link UserRepository}.
 *
 * @author
 */
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(UserServicesApplication.class)
public class UserRepositoryIntegrationTests {

	@Autowired
	UserServiceRepository repository;
	@Autowired
	UserWorkGroupServiceRepository workgrouprep;

	@Test
	public void executesQueryMethodsCorrectly() {

		//AppUser userName = this.repository.findUserByFirstName("Rao");
		//List<AppUser> users = this.repository.findAll();
		//AppUser userName = this.repository.findUserByUserId(101);
		//this.repository.deleteUserByUserId(102);
		//AppUser userName = this.repository.findByGarmLevel(101);

		//AppGroup findWorkGroupById = workgrouprep.findWorkGroupById(1002);
		int findWorkGroupById = 1001;
		//List<AppUser> users = this.repository.findAllUsersByWorkGroup(workgrouprep.getOne(findWorkGroupById));
		AppGroup wkg = workgrouprep.findOne(findWorkGroupById);
		List<AppUser> users = new ArrayList<AppUser>(1); //this.repository.findAllUsersByWorkGroup(wkg);
		//System.out.println("Username::::"+userName + "--------------------" + users);

		System.out.println("users::::"+users.size());
		//assertThat(cities.getTotalElements()).isGreaterThan(20L);
	}
}


text:
#if !defined( _${tools_name_upper_case}_GETOPT_H )
#define _${tools_name_upper_case}_GETOPT_H

#include <common.h>
#include <types.h>

/* unistd.h is included here to export getopt, optarg, optind and optopt
 */
#if defined( HAVE_UNISTD_H )
#include <unistd.h>
#endif

#if defined( __cplusplus )
extern "C" {
#endif

#if defined( HAVE_GETOPT )
#define ${tools_name}_getopt( argument_count, argument_values, options_string ) \
	getopt( argument_count, argument_values, options_string )

#else

#if !defined( __CYGWIN__ )
extern int optind;
extern system_character_t *optarg;
extern system_integer_t optopt;

#else
int optind;
system_character_t *optarg;
system_integer_t optopt;

#endif /* !defined( __CYGWIN__ ) */

system_integer_t ${tools_name}_getopt(
                  int argument_count,
                  system_character_t * const argument_values[],
                  const system_character_t *options_string );

#endif /* defined( HAVE_GETOPT ) */

#if defined( __cplusplus )
}
#endif

#endif /* !defined( _${tools_name_upper_case}_GETOPT_H ) */


text:
<!DOCTYPE html>

        <meta charset="UTF-8" />
        <meta name="robots" content="index, follow, all" />
        <title>Thelia\Core\FileFormat\Archive\ArchiveBuilderManagerTrait | </title>
                    <link rel="stylesheet" type="text/css" href="../../../../stylesheet.css">

Classes

Namespaces

Interfaces

Traits

Index

Trait

Thelia\Core\FileFormat\Archive\ArchiveBuilderManagerTrait

    trait
    ArchiveBuilderManagerTrait

Trait ArchiveBuilderManagerTrait

Methods

                    ArchiveBuilderManager

                    getArchiveBuilderManager(ContainerInterface $container)

Details

at line 27

                    public            ArchiveBuilderManager
    getArchiveBuilderManager(ContainerInterface $container)

Parameters

                ContainerInterface
                $container

Return Value

            ArchiveBuilderManager

        Generated by Sami, the API Documentation Generator.


text:
import os
from shutil import copyfile
import cv2

aggregatedPath = 'train'
trainPath = 'train'
valPath = 'val'
imagesPath = ['cheung', 'chin2', 'chiu', 'cup', 'ho', 'ka', 'ma', 'sheung', 'shi', 'yi', 'sin', 'ngou', 'lai']

labelsFileTrain = './trainLabels.csv'
labelsFileVal = './valLabels.csv'

numVal = 160 #200 images, 80%  training, 20% validation

f = open(labelsFileTrain,'w')
f2 = open(labelsFileVal,'w')

aggregatedPath = trainPath #init with train path
writeFile = f

count = 0
eachClassCount = 0

for imagedir in imagesPath:
    print(imagedir)
    aggregatedPath = trainPath #init with train path
    writeFile = f
    eachClassCount = 0

    for fileName in os.listdir(imagedir):
        print(fileName)
        if(fileName == ".DS_Store"):
            continue
        filename_split = os.path.splitext(fileName)

        if eachClassCount >= numVal: #validation files
        	aggregatedPath = valPath
        	writeFile = f2

        oldFileName = imagedir + "/" + fileName
        newFileOnlyName = '{0:05d}'.format(count) + "." + "png"
        newFileName = "./" + aggregatedPath + "/" + newFileOnlyName
        print(oldFileName)
        print(newFileName)

        copyfile(oldFileName, newFileName)
        writeFile.write('{0:05d}'.format(count) + "," + imagedir + '\n')

        count = count + 1
        eachClassCount = eachClassCount + 1

f.close()
f2.close()

def resizeme(path):

  #resize 32x32
  for fileName in os.listdir(path):
    if(fileName == ".DS_Store"):
      continue
    print("resize:" + fileName)
    image = cv2.imread(path + "/" + fileName)
    resized_image = cv2.resize(image, (32, 32))
    cv2.imwrite(path + "/" + fileName, resized_image)

resizeme(trainPath)
resizeme(valPath)


text:
//----------------------------------------------------------------
// <copyright company="Microsoft Corporation">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//----------------------------------------------------------------

namespace System.Activities.Presentation.Model
{
    internal enum LinkType
    {
        Property = 0,
        Item,
    }
}


text:
[![Build Status](https://travis-ci.org/guidance-guarantee-programme/locator.svg)](https://travis-ci.org/guidance-guarantee-programme/locator)

Locate branches of the Citizens Advice service providing [Pension Wise] face to face guidance appointments.

## Prerequisites

* [Go]
* [Git]
* [A configured GOPATH](https://github.com/golang/go/wiki/GOPATH)

## Installation

Clone the repository:

```sh
$ cd $GOPATH/src
$ git clone https://github.com/guidance-guarantee-programme/locator.git
```

Install godep:

```sh
go get github.com/tools/godep
```

## Usage

To start the application:

```sh
$ godep go build .
$ ./locator
```

## Heroku

[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)

## Contributing

Please see the [contributing guidelines](/CONTRIBUTING.md).

[git]: http://git-scm.com
[go]: https://golang.org
[pension wise]: https://www.pensionwise.gov.uk


text:
@interface FSSearchViewController () <UISearchResultsUpdating, UISearchBarDelegate, UICollectionViewDelegateFlowLayout>

@property (nonatomic, strong) FSSource *source;
@property (nonatomic, strong) FSConfig *config;
@property (nonatomic, strong) UISearchController *searchController;
@property (nonatomic, strong) UIActivityIndicatorView *activityIndicator;
@property (nonatomic, strong) UIImage *selectedOverlay;
@property (nonatomic, strong) NSMutableArray<FSContentItem *> *selectedContent;
@property (nonatomic, strong) NSMutableArray<NSIndexPath *> *selectedIndexPaths;
@property (nonatomic, strong) NSArray<FSContentItem *> *contentData;
@property (nonatomic, assign) BOOL toolbarColorsSet;

@end

@implementation FSSearchViewController

static NSString * const reuseIdentifier = @"fsCell";
static NSString * const headerReuseIdentifier = @"headerView";

-(instancetype)initWithConfig:(FSConfig *)config source:(FSSource *)source {
    if ((self = [super initWithCollectionViewLayout:[[UICollectionViewFlowLayout alloc] init]])) {
        _config = config;
        _source = source;
        _selectedContent = [[NSMutableArray alloc] init];
        _selectedOverlay = [FSImage cellSelectedOverlay];
        _selectedIndexPaths = [[NSMutableArray alloc] init];
    }

    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupSearchController];
    [self setupCollectionView];
    [self setupActivityIndicator];
    [self setupToolbar];
    self.title = self.source.name;
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController setToolbarHidden:YES animated:YES];
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self.searchController setActive:YES];
    // Hacky, hacky
    [self performSelector:@selector(showKeyboard) withObject:nil afterDelay:0.1];
}

- (void)showKeyboard {
    [self.searchController.searchBar becomeFirstResponder];
}

#pragma mark - Setup views

- (void)setupSearchController {
    self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
    self.searchController.searchBar.delegate = self;
    self.searchController.searchResultsUpdater = self;
    self.searchController.dimsBackgroundDuringPresentation = YES;
    self.searchController.hidesNavigationBarDuringPresentation = NO;
    self.searchController.searchBar.placeholder = @"Search for images";
    self.searchController.searchBar.searchBarStyle = UISearchBarStyleDefault;
    self.searchController.searchBar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    self.searchController.searchBar.autocapitalizationType = NO;
    [self.searchController.searchBar sizeToFit];
}

- (void)setupCollectionView {
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];

    [layout calculateAndSetItemSizeReversed:NO];
    layout.minimumInteritemSpacing = 2;
    layout.minimumLineSpacing = 2;
    self.collectionView.collectionViewLayout = layout;
    self.collectionView.alwaysBounceVertical = YES;
    self.collectionView.allowsMultipleSelection = YES;
    [self.collectionView registerClass:[FSCollectionViewCell class]
            forCellWithReuseIdentifier:reuseIdentifier];
    [self.collectionView registerClass:[UICollectionReusableView class]
            forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
                   withReuseIdentifier:headerReuseIdentifier];
}

- (void)setupActivityIndicator {
    self.activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.activityIndicator];
}

#pragma mark - UISearchBar delegate

- (void)updateSearchResultsForSearchController:(UISearchController *)searchController {
}

- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
    [self.searchController.searchBar resignFirstResponder];
}

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
    self.collectionView.userInteractionEnabled = NO;
    [self.searchController.searchBar resignFirstResponder];
    [self.selectedContent removeAllObjects];
    [self.selectedIndexPaths removeAllObjects];
    [self updateToolbar];
    [self loadSourceContentWithSearchString:self.searchController.searchBar.text];

    self.searchController.active = NO;
}

#pragma mark - Loading data

- (void)loadSourceContentWithSearchString:(NSString *)searchString {
    [self.activityIndicator startAnimating];

    NSString *encodedSearchString = [searchString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLPathAllowedCharacterSet]];
    NSString *contentPath = [NSString stringWithFormat:@"%@/%@", self.source.rootPath, encodedSearchString];
    FSSession *session = [[FSSession alloc] initWithConfig:self.config mimeTypes:self.source.mimeTypes];
    NSDictionary *parameters = [session toQueryParametersWithFormat:@"info"];

    [Filestack getContentForPath:contentPath parameters:parameters completionHandler:^(NSDictionary *responseJSON, NSError *error) {
        self.collectionView.userInteractionEnabled = YES;
        [self.activityIndicator stopAnimating];

        if (error) {
            [self showAlertWithError:error];
        } else {
            self.contentData = [FSContentItem itemsFromResponseJSON:responseJSON];
        }
    }];
}

- (void)setContentData:(NSArray<FSContentItem *> *)contentData {
    _contentData = contentData;
    [self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];
}

- (void)showAlertWithError:(NSError *)error {
    UIAlertController *alert = [UIAlertController fsAlertWithError:error];
    [self presentViewController:alert animated:YES completion:nil];
}

#pragma mark - Collection view data source

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.contentData.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    FSCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
    FSContentItem *item = [self itemAtIndexPath:indexPath];

    cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
    cell.imageView.clipsToBounds = YES;
    cell.imageView.alpha = 0.0;
    cell.type = FSCollectionViewCellTypeMedia;

    if ([self.selectedIndexPaths containsObject:indexPath]) {
        cell.overlayImageView.image = self.selectedOverlay;
    } else {
        cell.overlayImageView.image = nil;
    }

    NSURL *dataTaskURL = [NSURL URLWithString:item.thumbnailURL];
    NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:dataTaskURL completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        if (data) {
            dispatch_async(dispatch_get_main_queue(), ^{
                cell.imageView.image = [UIImage imageWithData:data];
                [UIView animateWithDuration:0.1 animations:^{
                    cell.imageView.alpha = 1.0;
                }];
            });
        }
    }];

    [task resume];

    return cell;
}

- (FSContentItem *)itemAtIndexPath:(NSIndexPath *)indexPath {
    return self.contentData[indexPath.row];
}

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
    if (kind == UICollectionElementKindSectionHeader) {
        UICollectionReusableView* reusableView;
        UICollectionReusableView *headerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader
                                                                                withReuseIdentifier:headerReuseIdentifier
                                                                                forIndexPath:indexPath];

        [headerView addSubview:self.searchController.searchBar];
        reusableView = headerView;

        return reusableView;
    }

    return [super collectionView:collectionView viewForSupplementaryElementOfKind:kind atIndexPath:indexPath];
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {
    return CGSizeMake(self.view.frame.size.width, self.searchController.searchBar.frame.size.height);
}

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
    [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
    [self updateCollectionViewLayoutWithSize];

    [coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext>  _Nonnull context) {
    } completion:^(id<UIViewControllerTransitionCoordinatorContext>  _Nonnull context) {
        CGFloat testOffset = self.collectionView.contentSize.height - self.collectionView.frame.size.height;
        if (self.collectionView.contentOffset.y > testOffset && testOffset > 0) {
            [self.collectionView setContentOffset:CGPointMake(0, testOffset) animated:YES];
        }
    }];
}

#pragma mark - Collection view delegate

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    FSCollectionViewCell *cell = (FSCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
    FSContentItem *item = [self itemAtIndexPath:indexPath];

    [self selectedCell:cell forItem:item atIndexPath:indexPath];
}

- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath {
    FSCollectionViewCell *cell = (FSCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
    FSContentItem *item = [self itemAtIndexPath:indexPath];

    [self deselectedCell:cell forItem:item atIndexPath:indexPath];
}

#pragma mark - (De)Selection methods

- (void)selectedCell:(FSCollectionViewCell *)cell forItem:(FSContentItem *)item atIndexPath:(NSIndexPath *)indexPath {
    cell.overlayImageView.image = self.selectedOverlay;
    [self.selectedContent addObject:item];
    [self.selectedIndexPaths addObject:indexPath];

    if (self.config.selectMultiple) {
        [self updateToolbar];
    } else {
        [self uploadSelectedContents];
    }
}

- (void)deselectedCell:(FSCollectionViewCell *)cell forItem:(FSContentItem *)item atIndexPath:(NSIndexPath *)indexPath {
    cell.overlayImageView.image = nil;
    [self.selectedContent removeObject:item];
    [self.selectedIndexPaths removeObject:indexPath];
    [self updateToolbar];
}

#pragma mark - Upload button

- (void)setupToolbar {
    [self setToolbarItems:@[[self spaceButtonItem], [self uploadButtonItem], [self spaceButtonItem]] animated:NO];
}

- (UIBarButtonItem *)spaceButtonItem {
    return [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
}

- (UIBarButtonItem *)uploadButtonItem {
    return [[UIBarButtonItem alloc] initWithTitle:nil style:UIBarButtonItemStylePlain target:self action:@selector(uploadSelectedContents)];
}

- (void)updateToolbar {
    if (!self.toolbarColorsSet) {
        self.toolbarColorsSet = YES;
        self.navigationController.toolbar.barTintColor = [FSBarButtonItem appearance].backgroundColor;
        self.navigationController.toolbar.tintColor = [FSBarButtonItem appearance].normalTextColor;
    }

    if (self.selectedContent.count > 0) {
        [self updateListAndGridInsetsForToolbarHidden:NO];
        [self.navigationController setToolbarHidden:NO animated:YES];
        [self updateToolbarButtonTitle];
    } else {
        [self updateListAndGridInsetsForToolbarHidden:YES];
        [self.navigationController setToolbarHidden:YES animated:YES];
    }
}

- (void)updateListAndGridInsetsForToolbarHidden:(BOOL)hidden {
    CGFloat toolbarHeight = self.navigationController.toolbar.frame.size.height;
    BOOL currentlyHidden = self.navigationController.toolbar.isHidden;
    [self updateCollectionInsetsForToolbarHidden:hidden currentlyHidden:currentlyHidden toolbarHeight:toolbarHeight];
}

- (void)updateToolbarButtonTitle {
    NSString *title;

    if ((long)self.selectedContent.count > self.config.maxFiles && self.config.maxFiles != 0) {
        title = [NSString stringWithFormat:@"Maximum %lu file%@", (long)self.config.maxFiles, self.config.maxFiles > 1 ? @"s" : @""];
        self.uploadButton.enabled = NO;
    } else {
        title = [NSString stringWithFormat:@"Upload %lu file%@", (unsigned long)self.selectedContent.count, self.selectedContent.count > 1 ? @"s" : @""];
        self.uploadButton.enabled = YES;
    }

    [self.uploadButton setTitle:title];
}

- (UIBarButtonItem *)uploadButton {
    return self.toolbarItems[1];
}

#pragma mark - Upload

- (void)uploadSelectedContents {
    FSProgressModalViewController *uploadModal = [[FSProgressModalViewController alloc] init];
    uploadModal.modalPresentationStyle = UIModalPresentationOverCurrentContext;

    FSUploader *uploader = [[FSUploader alloc] initWithConfig:self.config source:self.source];
    uploader.uploadModalDelegate = uploadModal;
    uploader.pickerDelegate = (FSPickerController *)self.navigationController;

    [self presentViewController:uploadModal animated:YES completion:nil];
    [uploader uploadCloudItems:self.selectedContent];

    [self.selectedContent removeAllObjects];

    for (NSIndexPath *indexPath in [self.selectedIndexPaths copy]) {
        [self collectionView:self.collectionView didDeselectItemAtIndexPath:indexPath];
    }

    [self.selectedIndexPaths removeAllObjects];
    [self updateToolbar];
}

- (CGFloat)topInset {
    CGFloat navBarHeight = self.navigationController.navigationBar.frame.size.height;
    CGFloat navBarOriginY = self.navigationController.navigationBar.frame.origin.y;
    CGFloat searchBarHeight = self.searchController.searchBar.frame.size.height;
    return navBarHeight + navBarOriginY + searchBarHeight;
}

- (void)updateCollectionInsetsForToolbarHidden:(BOOL)hidden currentlyHidden:(BOOL)currentlyHidden toolbarHeight:(CGFloat)height {
    CGPoint currentOffset = self.collectionView.contentOffset;
    CGFloat yOffset;

    if (hidden) {
        yOffset = -height;
    } else {
        yOffset = currentlyHidden ? height : 0.0;
    }

    if (currentOffset.y > [self topInset]) {
        [self.collectionView setContentOffset:CGPointMake(currentOffset.x, currentOffset.y + yOffset) animated:YES];
    }
}

- (void)updateCollectionViewLayoutWithSize {
    UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout;

    [layout calculateAndSetItemSizeReversed:YES];
    [layout invalidateLayout];
}

- (void)dealloc {
    [self.searchController.view removeFromSuperview];
}

@end