text:
/* -*- Mode: c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
 *  (C) 2010 by Argonne National Laboratory.
 *      See COPYRIGHT in top-level directory.
 */

#include "mpidimpl.h"
#include "mpl_utlist.h"

/* A random guess at an appropriate value, we can tune it later.  It could also
 * be a real tunable parameter. */
#define MPIDU_SCHED_INITIAL_ENTRIES (16)

#if 0
#define dprintf fprintf
#else
/* FIXME this requires VA_ARGS macros */
#define dprintf(...) do{}while(0)
#endif

/* helper macros to improve code readability */
/* we pessimistically assume that MPI_TYPE_NULL may be passed as a "valid" type
 * for send/recv when MPI_PROC_NULL is the destination/src */
#define dtype_add_ref_if_not_builtin(datatype_)                    \
    do {                                                           \
        if ((datatype_) != MPI_DATATYPE_NULL &&                    \
            HANDLE_GET_KIND((datatype_)) != HANDLE_KIND_BUILTIN)   \
        {                                                          \
            MPID_Datatype *dtp_ = NULL;                            \
            MPID_Datatype_get_ptr((datatype_), dtp_);              \
            MPID_Datatype_add_ref(dtp_);                           \
        }                                                          \
    } while (0)
#define dtype_release_if_not_builtin(datatype_)                    \
    do {                                                           \
        if ((datatype_) != MPI_DATATYPE_NULL &&                    \
            HANDLE_GET_KIND((datatype_)) != HANDLE_KIND_BUILTIN)   \
        {                                                          \
            MPID_Datatype *dtp_ = NULL;                            \
            MPID_Datatype_get_ptr((datatype_), dtp_);              \
            MPID_Datatype_release(dtp_);                           \
        }                                                          \
    } while (0)

/* TODO move to a header somewhere? */
void MPIDU_Sched_dump(struct MPIDU_Sched *s);
void MPIDU_Sched_dump_fh(struct MPIDU_Sched *s, FILE *fh);

struct MPIDU_Sched_state {
    struct MPIDU_Sched *head;
    /* no need for a tail with utlist */
};

/* holds on to all incomplete schedules on which progress should be made */
struct MPIDU_Sched_state all_schedules = {NULL};

/* returns TRUE if any schedules are currently pending completion by the
 * progress engine, FALSE otherwise */
#undef FUNCNAME
#define FUNCNAME MPIDU_Sched_are_pending
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPIDU_Sched_are_pending(void)
{
    return (all_schedules.head != NULL);
}

#undef FUNCNAME
#define FUNCNAME MPID_Sched_next_tag
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPID_Sched_next_tag(MPID_Comm *comm_ptr, int *tag)
{
    int mpi_errno = MPI_SUCCESS;
    /* TODO there should be an internal accessor/utility macro for getting the
     * TAG_UB value that doesn't require using the attribute interface */
    int tag_ub = MPIR_Process.attrs.tag_ub;
#if defined(HAVE_ERROR_CHECKING)
    int start = MPI_UNDEFINED;
    int end = MPI_UNDEFINED;
    struct MPIDU_Sched *elt = NULL;
#endif

    *tag = comm_ptr->next_sched_tag;
    ++comm_ptr->next_sched_tag;

#if defined(HAVE_ERROR_CHECKING)
    /* Upon entry into the second half of the tag space, ensure there are no
     * outstanding schedules still using the second half of the space.  Check
     * the first half similarly on wraparound. */
    if (comm_ptr->next_sched_tag == (tag_ub / 2)) {
        start = tag_ub / 2;
        end = tag_ub;
    }
    else if (comm_ptr->next_sched_tag == (tag_ub)) {
        start = MPIR_FIRST_NBC_TAG;
        end = tag_ub / 2;
    }
    if (start != MPI_UNDEFINED) {
        MPL_DL_FOREACH(all_schedules.head, elt) {
            if (elt->tag >= start && elt->tag < end) {
                MPIU_ERR_SETANDJUMP(mpi_errno, MPI_ERR_OTHER, "**toomanynbc");
            }
        }
    }
#endif

    /* wrap the tag values around to the start, but don't allow it to conflict
     * with the tags used by the blocking collectives */
    if (comm_ptr->next_sched_tag == tag_ub) {
        comm_ptr->next_sched_tag = MPIR_FIRST_NBC_TAG;
    }

fn_fail:
    return mpi_errno;
}

#undef FUNCNAME
#define FUNCNAME MPIDU_Sched_start_entry
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
/* initiates the schedule entry "e" in the NBC described by "s", where
 * "e" is at "idx" in "s".  This means posting nonblocking sends/recvs,
 * performing reductions, calling callbacks, etc. */
static int MPIDU_Sched_start_entry(struct MPIDU_Sched *s, int idx, struct MPIDU_Sched_entry *e)
{
    int mpi_errno = MPI_SUCCESS;
    int context_offset;
    MPID_Request *r = s->req;
    MPID_Comm *comm;

    MPIU_Assert(e->status == MPIDU_SCHED_ENTRY_STATUS_NOT_STARTED);

    switch (e->type) {
        case MPIDU_SCHED_ENTRY_SEND:
            comm = e->u.send.comm;
            context_offset = (comm->comm_kind == MPID_INTRACOMM) ?
                MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
            if (e->u.send.count_p) {
                /* deferred send */
                /* originally there was no branch and send.count_p was set to
                 * &send.count, but this requires patching up the pointers
                 * during realloc of entries, so this is easier */
                mpi_errno = MPID_Isend(e->u.send.buf, *e->u.send.count_p, e->u.send.datatype,
                                       e->u.send.dest, s->tag, comm, context_offset,
                                       &e->u.send.sreq);
            }
            else {
                if (e->u.send.is_sync) {
                    mpi_errno = MPID_Issend(e->u.send.buf, e->u.send.count, e->u.send.datatype,
                                            e->u.send.dest, s->tag, comm, context_offset,
                                            &e->u.send.sreq);
                }
                else {
                    mpi_errno = MPID_Isend(e->u.send.buf, e->u.send.count, e->u.send.datatype,
                                           e->u.send.dest, s->tag, comm, context_offset,
                                           &e->u.send.sreq);
                }
            }
            if (mpi_errno) MPIU_ERR_POP(mpi_errno);
            e->status = MPIDU_SCHED_ENTRY_STATUS_STARTED;
            break;
        case MPIDU_SCHED_ENTRY_RECV:
            comm = e->u.recv.comm;
            context_offset = (comm->comm_kind == MPID_INTRACOMM) ?
                MPID_CONTEXT_INTRA_COLL : MPID_CONTEXT_INTER_COLL;
            mpi_errno = MPID_Irecv(e->u.recv.buf, e->u.recv.count, e->u.recv.datatype,
                                   e->u.recv.src, s->tag, comm, context_offset,
                                   &e->u.recv.rreq);
            if (mpi_errno) MPIU_ERR_POP(mpi_errno);
            e->status = MPIDU_SCHED_ENTRY_STATUS_STARTED;
            break;
        case MPIDU_SCHED_ENTRY_REDUCE:
            mpi_errno = MPIR_Reduce_local_impl(e->u.reduce.inbuf, e->u.reduce.inoutbuf, e->u.reduce.count,
                                               e->u.reduce.datatype, e->u.reduce.op);
            if (mpi_errno) MPIU_ERR_POP(mpi_errno);
            if (HANDLE_GET_KIND(e->u.reduce.op) != HANDLE_KIND_BUILTIN) {
                MPID_Op *op_ptr = NULL;
                MPID_Op_get_ptr(e->u.reduce.op, op_ptr);
                MPIR_Op_release(op_ptr);
            }
            dtype_release_if_not_builtin(e->u.reduce.datatype);
            e->status = MPIDU_SCHED_ENTRY_STATUS_COMPLETE;
            break;
        case MPIDU_SCHED_ENTRY_COPY:
            mpi_errno = MPIR_Localcopy(e->u.copy.inbuf, e->u.copy.incount, e->u.copy.intype,
                                       e->u.copy.outbuf, e->u.copy.outcount, e->u.copy.outtype);
            if (mpi_errno) MPIU_ERR_POP(mpi_errno);
            dtype_release_if_not_builtin(e->u.copy.intype);
            dtype_release_if_not_builtin(e->u.copy.outtype);
            e->status = MPIDU_SCHED_ENTRY_STATUS_COMPLETE;
            break;
        case MPIDU_SCHED_ENTRY_NOP:
            /* nothing to be done */
            break;
        case MPIDU_SCHED_ENTRY_CB:
            if (e->u.cb.cb_type == MPIDU_SCHED_CB_TYPE_1) {
                mpi_errno = e->u.cb.u.cb_p(r->comm, s->tag, e->u.cb.cb_state);
                if (mpi_errno) {
                    e->status = MPIDU_SCHED_ENTRY_STATUS_FAILED;
                    MPIU_ERR_POP(mpi_errno);
                }
            }
            else if (e->u.cb.cb_type == MPIDU_SCHED_CB_TYPE_2) {
                mpi_errno = e->u.cb.u.cb2_p(r->comm, s->tag, e->u.cb.cb_state, e->u.cb.cb_state2);
                if (mpi_errno) {
                    e->status = MPIDU_SCHED_ENTRY_STATUS_FAILED;
                    MPIU_ERR_POP(mpi_errno);
                }
            }
            else {
                MPIU_Assert_fmt_msg(FALSE, ("unknown callback type, e->u.cb.cb_type=%d", e->u.cb.cb_type));
            }
            e->status = MPIDU_SCHED_ENTRY_STATUS_COMPLETE;
            break;
        default:
            MPIU_Assert_fmt_msg(FALSE, ("unknown entry type, e->type=%d", e->type));
            break;
    }

fn_exit:
    return mpi_errno;
fn_fail:
    e->status = MPIDU_SCHED_ENTRY_STATUS_FAILED;
    if (r)
        r->status.MPI_ERROR = mpi_errno;
    goto fn_exit;
}

/* Posts or performs any NOT_STARTED operations in the given schedule that are
 * permitted to be started.  That is, this routine will respect schedule
 * barriers appropriately. */
#undef FUNCNAME
#define FUNCNAME MPIDU_Sched_continue
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
static int MPIDU_Sched_continue(struct MPIDU_Sched *s)
{
    int mpi_errno = MPI_SUCCESS;
    int i;

    for (i = s->idx; i < s->num_entries; ++i) {
        struct MPIDU_Sched_entry *e = &s->entries[i];

        if (e->status == MPIDU_SCHED_ENTRY_STATUS_NOT_STARTED) {
            mpi_errno = MPIDU_Sched_start_entry(s, i, e);
            if (mpi_errno) MPIU_ERR_POP(mpi_errno);
        }

        /* _start_entry may have completed the operation, but won't update s->idx */
        if (i == s->idx && e->status == MPIDU_SCHED_ENTRY_STATUS_COMPLETE) {
            ++s->idx; /* this is valid even for barrier entries */
        }

        /* watch the indexing, s->idx might have been incremented above, so
         * ||-short-circuit matters here */
        if (e->is_barrier && (e->status != MPIDU_SCHED_ENTRY_STATUS_COMPLETE || (s->idx != i+1))) {
            /* we've hit a barrier but outstanding operations before this
             * barrier remain, so we cannot proceed past the barrier */
            break;
        }
    }
fn_exit:
    return mpi_errno;
fn_fail:
    goto fn_exit;
}

#undef FUNCNAME
#define FUNCNAME MPID_Sched_create
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
/* creates a new opaque schedule object and returns a handle to it in (*sp) */
int MPID_Sched_create(MPID_Sched_t *sp)
{
    int mpi_errno = MPI_SUCCESS;
    struct MPIDU_Sched *s;
    MPIU_CHKPMEM_DECL(2);

    *sp = NULL;

    /* this mem will be freed by the progress engine when the request is completed */
    MPIU_CHKPMEM_MALLOC(s, struct MPIDU_Sched *, sizeof(struct MPIDU_Sched), mpi_errno, "schedule object");

    s->size = MPIDU_SCHED_INITIAL_ENTRIES;
    s->idx = 0;
    s->num_entries = 0;
    s->tag = -1;
    s->req = NULL;
    s->entries = NULL;
    s->next = NULL; /* only needed for sanity checks */
    s->prev = NULL; /* only needed for sanity checks */

    /* this mem will be freed by the progress engine when the request is completed */
    MPIU_CHKPMEM_MALLOC(s->entries, struct MPIDU_Sched_entry *, MPIDU_SCHED_INITIAL_ENTRIES*sizeof(struct MPIDU_Sched_entry), mpi_errno, "schedule entries vector");

    /* TODO in a debug build, defensively mark all entries as status=INVALID */

    MPIU_CHKPMEM_COMMIT();
    *sp = s;
fn_exit:
    return mpi_errno;
fn_fail:
    MPIU_CHKPMEM_REAP();
    goto fn_exit;
}

#undef FUNCNAME
#define FUNCNAME MPID_Sched_clone
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
/* clones orig and returns a handle to the new schedule in (*cloned) */
int MPID_Sched_clone(MPID_Sched_t orig, MPID_Sched_t *cloned)
{
    int mpi_errno = MPI_SUCCESS;
    /* TODO implement this function for real */
    MPIU_Assert_fmt_msg(FALSE, ("clone not yet implemented"));
    MPIU_Assertp(FALSE);
    return mpi_errno;
}

#undef FUNCNAME
#define FUNCNAME MPID_Sched_start
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
/* sets (*sp) to MPID_SCHED_NULL and gives you back a request pointer in (*req).
 * The caller is giving up ownership of the opaque schedule object. */
int MPID_Sched_start(MPID_Sched_t *sp, MPID_Comm *comm, int tag, MPID_Request **req)
{
    int mpi_errno = MPI_SUCCESS;
    MPID_Request *r;
    struct MPIDU_Sched *s = *sp;

    *req = NULL;
    *sp = MPID_SCHED_NULL;

    /* sanity check the schedule */
    MPIU_Assert(s->num_entries <= s->size);
    MPIU_Assert(s->num_entries == 0 || s->idx < s->num_entries);
    MPIU_Assert(s->req == NULL);
    MPIU_Assert(s->next == NULL);
    MPIU_Assert(s->prev == NULL);
    MPIU_Assert(s->entries != NULL);

    /* now create and populate the request */
    r = MPID_Request_create();
    if (!r) MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,"**nomem");
    r->kind = MPID_COLL_REQUEST;
    /* FIXME is this right when comm/datatype GC is used? */
    MPIR_Comm_add_ref(comm);
    r->comm = comm;
    /* req refcount is currently 1, for the user's request.  Increment for the
     * schedule's reference */
    MPIR_Request_add_ref(r);
    s->req = r;
    *req = r;
    /* cc is 1, which is fine b/c we only use it as a signal, rather than
     * incr/decr on every constituent operation */
    s->tag = tag;

    /* Now kick off any initial operations.  Do this before we tell the progress
     * engine about this req+sched, otherwise we have more MT issues to worry
     * about.  Skipping this step will increase latency. */
    mpi_errno = MPIDU_Sched_continue(s);
    if (mpi_errno) MPIU_ERR_POP(mpi_errno);

    /* finally, enqueue in the list of all pending schedules so that the
     * progress engine can make progress on it */
    MPL_DL_APPEND(all_schedules.head, s);

    dprintf(stderr, "started schedule s=%p\n", s);
    MPIDU_Sched_dump(s);

fn_exit:
    return mpi_errno;
fn_fail:
    if (*req)
        *req = NULL;
    if (r) {
        /* overly complicated, but we can't just destroy the req directly
         * because we aren't truly inside the device and don't have access to
         * MPIDI_CH3_Request_destroy (we may not even be CH3) */
        int inuse = TRUE;
        MPIR_Request_release_ref(r, &inuse); /* the schedule's ref */
        MPIU_Assert(inuse);
        MPID_Request_release(r); /* the user's ref */
    }

    goto fn_exit;
}

#undef FUNCNAME
#define FUNCNAME MPIDU_Sched_add_entry
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
/* idx and e are permitted to be NULL */
static int MPIDU_Sched_add_entry(struct MPIDU_Sched *s, int *idx, struct MPIDU_Sched_entry **e)
{
    int mpi_errno = MPI_SUCCESS;
    int i;
    struct MPIDU_Sched_entry *ei;

    MPIU_Assert(s->entries != NULL);
    MPIU_Assert(s->size > 0);

    if (s->num_entries == s->size) {
        /* need to grow the entries array */
        s->entries = MPIU_Realloc(s->entries, 2*s->size*sizeof(struct MPIDU_Sched_entry));
        if (s->entries == NULL) MPIU_ERR_SETANDJUMP(mpi_errno,MPI_ERR_OTHER,"**nomem");
        s->size *= 2;
    }

    i = s->num_entries++;
    ei = &s->entries[i];

    if (idx != NULL)
        *idx = i;
    if (e != NULL)
        *e = ei;
fn_exit:
    return mpi_errno;
fn_fail:
    goto fn_exit;
}

#undef FUNCNAME
#define FUNCNAME MPID_Sched_send
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
/* do these ops need an entry handle returned? */
int MPID_Sched_send(const void *buf, int count, MPI_Datatype datatype, int dest, MPID_Comm *comm, MPID_Sched_t s)
{
    int mpi_errno = MPI_SUCCESS;
    struct MPIDU_Sched_entry *e = NULL;

    mpi_errno = MPIDU_Sched_add_entry(s, NULL, &e);
    if (mpi_errno) MPIU_ERR_POP(mpi_errno);

    e->type = MPIDU_SCHED_ENTRY_SEND;
    e->status = MPIDU_SCHED_ENTRY_STATUS_NOT_STARTED;
    e->is_barrier = FALSE;

    e->u.send.buf = buf;
    e->u.send.count = count;
    e->u.send.count_p = NULL;
    e->u.send.datatype = datatype;
    e->u.send.dest = dest;
    e->u.send.sreq = NULL; /* will be populated by _start_entry */
    e->u.send.comm = comm;
    e->u.send.is_sync = FALSE;

    /* the user may free the comm & type after initiating but before the
     * underlying send is actually posted, so we must add a reference here and
     * release it at entry completion time */
    MPIR_Comm_add_ref(comm);
    dtype_add_ref_if_not_builtin(datatype);

fn_exit:
    return mpi_errno;
fn_fail:
    goto fn_exit;
}

#undef FUNCNAME
#define FUNCNAME MPID_Sched_ssend
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPID_Sched_ssend(const void *buf, int count, MPI_Datatype datatype, int dest, MPID_Comm *comm, MPID_Sched_t s)
{
    int mpi_errno = MPI_SUCCESS;
    struct MPIDU_Sched_entry *e = NULL;

    mpi_errno = MPIDU_Sched_add_entry(s, NULL, &e);
    if (mpi_errno) MPIU_ERR_POP(mpi_errno);

    e->type = MPIDU_SCHED_ENTRY_SEND;
    e->status = MPIDU_SCHED_ENTRY_STATUS_NOT_STARTED;
    e->is_barrier = FALSE;

    e->u.send.buf = buf;
    e->u.send.count = count;
    e->u.send.count_p = NULL;
    e->u.send.datatype = datatype;
    e->u.send.dest = dest;
    e->u.send.sreq = NULL; /* will be populated by _start_entry */
    e->u.send.comm = comm;
    e->u.send.is_sync = TRUE;

    /* the user may free the comm & type after initiating but before the
     * underlying send is actually posted, so we must add a reference here and
     * release it at entry completion time */
    MPIR_Comm_add_ref(comm);
    dtype_add_ref_if_not_builtin(datatype);

fn_exit:
    return mpi_errno;
fn_fail:
    goto fn_exit;
}

#undef FUNCNAME
#define FUNCNAME MPID_Sched_send_defer
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPID_Sched_send_defer(const void *buf, const int *count, MPI_Datatype datatype, int dest, MPID_Comm *comm, MPID_Sched_t s)
{
    int mpi_errno = MPI_SUCCESS;
    struct MPIDU_Sched_entry *e = NULL;

    mpi_errno = MPIDU_Sched_add_entry(s, NULL, &e);
    if (mpi_errno) MPIU_ERR_POP(mpi_errno);

    e->type = MPIDU_SCHED_ENTRY_SEND;
    e->status = MPIDU_SCHED_ENTRY_STATUS_NOT_STARTED;
    e->is_barrier = FALSE;

    e->u.send.buf = buf;
    e->u.send.count = MPI_UNDEFINED;
    e->u.send.count_p = count;
    e->u.send.datatype = datatype;
    e->u.send.dest = dest;
    e->u.send.sreq = NULL; /* will be populated by _start_entry */
    e->u.send.comm = comm;
    e->u.send.is_sync = FALSE;

    /* the user may free the comm & type after initiating but before the
     * underlying send is actually posted, so we must add a reference here and
     * release it at entry completion time */
    MPIR_Comm_add_ref(comm);
    dtype_add_ref_if_not_builtin(datatype);

fn_exit:
    return mpi_errno;
fn_fail:
    goto fn_exit;
}

#undef FUNCNAME
#define FUNCNAME MPID_Sched_recv_status
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPID_Sched_recv_status(void *buf, int count, MPI_Datatype datatype, int src, MPID_Comm *comm, MPI_Status *status, MPID_Sched_t s)
{
    int mpi_errno = MPI_SUCCESS;
    struct MPIDU_Sched_entry *e = NULL;

    mpi_errno = MPIDU_Sched_add_entry(s, NULL, &e);
    if (mpi_errno) MPIU_ERR_POP(mpi_errno);

    e->type = MPIDU_SCHED_ENTRY_RECV;
    e->status = MPIDU_SCHED_ENTRY_STATUS_NOT_STARTED;
    e->is_barrier = FALSE;

    e->u.recv.buf = buf;
    e->u.recv.count = count;
    e->u.recv.datatype = datatype;
    e->u.recv.src = src;
    e->u.recv.rreq = NULL; /* will be populated by _start_entry */
    e->u.recv.comm = comm;
    e->u.recv.status = status;

    MPIR_Comm_add_ref(comm);
    dtype_add_ref_if_not_builtin(datatype);

fn_exit:
    return mpi_errno;
fn_fail:
    goto fn_exit;
}

#undef FUNCNAME
#define FUNCNAME MPID_Sched_recv
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPID_Sched_recv(void *buf, int count, MPI_Datatype datatype, int src, MPID_Comm *comm, MPID_Sched_t s)
{
    int mpi_errno = MPI_SUCCESS;
    struct MPIDU_Sched_entry *e = NULL;

    mpi_errno = MPIDU_Sched_add_entry(s, NULL, &e);
    if (mpi_errno) MPIU_ERR_POP(mpi_errno);

    e->type = MPIDU_SCHED_ENTRY_RECV;
    e->status = MPIDU_SCHED_ENTRY_STATUS_NOT_STARTED;
    e->is_barrier = FALSE;

    e->u.recv.buf = buf;
    e->u.recv.count = count;
    e->u.recv.datatype = datatype;
    e->u.recv.src = src;
    e->u.recv.rreq = NULL; /* will be populated by _start_entry */
    e->u.recv.comm = comm;
    e->u.recv.status = MPI_STATUS_IGNORE;

    MPIR_Comm_add_ref(comm);
    dtype_add_ref_if_not_builtin(datatype);

fn_exit:
    return mpi_errno;
fn_fail:
    goto fn_exit;
}

#undef FUNCNAME
#define FUNCNAME MPID_Sched_reduce
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPID_Sched_reduce(const void *inbuf, void *inoutbuf, int count, MPI_Datatype datatype, MPI_Op op, MPID_Sched_t s)
{
    int mpi_errno = MPI_SUCCESS;
    struct MPIDU_Sched_entry *e = NULL;
    struct MPIDU_Sched_reduce *reduce = NULL;

    mpi_errno = MPIDU_Sched_add_entry(s, NULL, &e);
    if (mpi_errno) MPIU_ERR_POP(mpi_errno);

    e->type = MPIDU_SCHED_ENTRY_REDUCE;
    e->status = MPIDU_SCHED_ENTRY_STATUS_NOT_STARTED;
    e->is_barrier = FALSE;
    reduce = &e->u.reduce;

    reduce->inbuf = inbuf;
    reduce->inoutbuf = inoutbuf;
    reduce->count = count;
    reduce->datatype = datatype;
    reduce->op = op;

    dtype_add_ref_if_not_builtin(datatype);
    if (HANDLE_GET_KIND(op) != HANDLE_KIND_BUILTIN) {
        MPID_Op *op_ptr = NULL;
        MPID_Op_get_ptr(op, op_ptr);
        MPIR_Op_add_ref(op_ptr);
    }

fn_exit:
    return mpi_errno;
fn_fail:
    goto fn_exit;
}

#undef FUNCNAME
#define FUNCNAME MPID_Sched_copy
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
/* Schedules a copy of "incount" copies of "intype" from "inbuf" to "outbuf" as
 * specified by "outcount" and "outtype".  It is erroneous to attempt to copy
 * more data than will fit into the (outbuf,outcount,outtype)-triple.  This
 * corresponds naturally with the buffer sizing rules for send-recv.
 *
 * Packing/unpacking can be accomplished by passing MPI_PACKED as either intype
 * or outtype. */
int MPID_Sched_copy(const void *inbuf,  int incount,  MPI_Datatype intype,
                    void *outbuf, int outcount, MPI_Datatype outtype, MPID_Sched_t s)
{
    int mpi_errno = MPI_SUCCESS;
    struct MPIDU_Sched_entry *e = NULL;
    struct MPIDU_Sched_copy *copy = NULL;

    mpi_errno = MPIDU_Sched_add_entry(s, NULL, &e);
    if (mpi_errno) MPIU_ERR_POP(mpi_errno);

    e->type = MPIDU_SCHED_ENTRY_COPY;
    e->status = MPIDU_SCHED_ENTRY_STATUS_NOT_STARTED;
    e->is_barrier = FALSE;
    copy = &e->u.copy;

    copy->inbuf = inbuf;
    copy->incount = incount;
    copy->intype = intype;
    copy->outbuf = outbuf;
    copy->outcount = outcount;
    copy->outtype = outtype;

    dtype_add_ref_if_not_builtin(intype);
    dtype_add_ref_if_not_builtin(outtype);

    /* some sanity checking up front */
#if defined(HAVE_ERROR_CHECKING) && !defined(NDEBUG)
    {
        int intype_size, outtype_size;
        MPID_Datatype_get_size_macro(intype, intype_size);
        MPID_Datatype_get_size_macro(outtype, outtype_size);
        if (incount * intype_size > outcount * outtype_size) {
            MPIU_Error_printf("truncation: intype=%#x, intype_size=%d, incount=%d, outtype=%#x, outtype_size=%d outcount=%d\n",
                              intype, intype_size, incount, outtype, outtype_size, outcount);
        }
    }
#endif

fn_exit:
    return mpi_errno;
fn_fail:
    goto fn_exit;
}

#undef FUNCNAME
#define FUNCNAME MPID_Sched_barrier
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
/* require that all previously added ops are complete before subsequent ops
 * may begin to execute */
int MPID_Sched_barrier(MPID_Sched_t s)
{
    int mpi_errno = MPI_SUCCESS;

    /* mark the previous entry as a barrier unless we're at the beginning, which
     * would be a pointless barrier */
    if (s->num_entries > 0) {
        s->entries[s->num_entries-1].is_barrier = TRUE;
    }

fn_exit:
    return mpi_errno;
fn_fail:
    goto fn_exit;
}

#undef FUNCNAME
#define FUNCNAME MPID_Sched_cb
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
/* buffer management, fancy reductions, etc */
int MPID_Sched_cb(MPID_Sched_cb_t *cb_p, void *cb_state, MPID_Sched_t s)
{
    int mpi_errno = MPI_SUCCESS;
    struct MPIDU_Sched_entry *e = NULL;
    struct MPIDU_Sched_cb *cb = NULL;

    mpi_errno = MPIDU_Sched_add_entry(s, NULL, &e);
    if (mpi_errno) MPIU_ERR_POP(mpi_errno);

    e->type = MPIDU_SCHED_ENTRY_CB;
    e->status = MPIDU_SCHED_ENTRY_STATUS_NOT_STARTED;
    e->is_barrier = FALSE;
    cb = &e->u.cb;

    cb->cb_type = MPIDU_SCHED_CB_TYPE_1;
    cb->u.cb_p = cb_p;
    cb->cb_state = cb_state;
    cb->cb_state2 = NULL;

fn_exit:
    return mpi_errno;
fn_fail:
    goto fn_exit;
}

#undef FUNCNAME
#define FUNCNAME MPID_Sched_cb2
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
/* buffer management, fancy reductions, etc */
int MPID_Sched_cb2(MPID_Sched_cb2_t *cb_p, void *cb_state, void *cb_state2, MPID_Sched_t s)
{
    int mpi_errno = MPI_SUCCESS;
    struct MPIDU_Sched_entry *e = NULL;
    struct MPIDU_Sched_cb *cb = NULL;

    mpi_errno = MPIDU_Sched_add_entry(s, NULL, &e);
    if (mpi_errno) MPIU_ERR_POP(mpi_errno);

    e->type = MPIDU_SCHED_ENTRY_CB;
    e->status = MPIDU_SCHED_ENTRY_STATUS_NOT_STARTED;
    e->is_barrier = FALSE;
    cb = &e->u.cb;

    cb->cb_type = MPIDU_SCHED_CB_TYPE_2;
    cb->u.cb2_p = cb_p;
    cb->cb_state = cb_state;
    cb->cb_state2 = cb_state2;

fn_exit:
    return mpi_errno;
fn_fail:
    goto fn_exit;
}

/* returns TRUE in (*made_progress) if any of the outstanding schedules in state completed */
#undef FUNCNAME
#define FUNCNAME MPIDU_Sched_progress_state
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
static int MPIDU_Sched_progress_state(struct MPIDU_Sched_state *state, int *made_progress)
{
    int mpi_errno = MPI_SUCCESS;
    int i;
    struct MPIDU_Sched *s;
    struct MPIDU_Sched *tmp;

    if (made_progress)
        *made_progress = FALSE;

    MPL_DL_FOREACH_SAFE(state->head, s, tmp) {
        dprintf(stderr, "making progress on s=%p\n", s);
        /*MPIDU_Sched_dump(s);*/

        for (i = s->idx; i < s->num_entries; ++i) {
            struct MPIDU_Sched_entry *e = &s->entries[i];

            switch (e->type) {
                case MPIDU_SCHED_ENTRY_SEND:
                    if (e->u.send.sreq != NULL && MPID_Request_is_complete(e->u.send.sreq)) {
                        dprintf(stderr, "completed SEND entry %d, sreq=%p\n", i, e->u.send.sreq);
                        e->status = MPIDU_SCHED_ENTRY_STATUS_COMPLETE;
                        mpi_errno = e->u.send.sreq->status.MPI_ERROR;
                        MPID_Request_release(e->u.send.sreq);
                        e->u.send.sreq = NULL;
                        MPIR_Comm_release(e->u.send.comm, /*isDisconnect=*/FALSE);
                        dtype_release_if_not_builtin(e->u.send.datatype);
                        if (mpi_errno) {
                            e->status = MPIDU_SCHED_ENTRY_STATUS_FAILED;
                            MPIU_ERR_POP(mpi_errno);
                        }
                        else {
                            e->status = MPIDU_SCHED_ENTRY_STATUS_COMPLETE;
                        }
                    }
                    break;
                case MPIDU_SCHED_ENTRY_RECV:
                    if (e->u.recv.rreq != NULL && MPID_Request_is_complete(e->u.recv.rreq)) {
                        dprintf(stderr, "completed RECV entry %d, rreq=%p\n", i, e->u.recv.rreq);
                        mpi_errno = e->u.recv.rreq->status.MPI_ERROR;
                        MPIR_Request_extract_status(e->u.recv.rreq, e->u.recv.status);
                        MPID_Request_release(e->u.recv.rreq);
                        e->u.recv.rreq = NULL;
                        MPIR_Comm_release(e->u.recv.comm, /*isDisconnect=*/FALSE);
                        dtype_release_if_not_builtin(e->u.recv.datatype);
                        if (mpi_errno) {
                            e->status = MPIDU_SCHED_ENTRY_STATUS_FAILED;
                            MPIU_ERR_POP(mpi_errno);
                        }
                        else {
                            e->status = MPIDU_SCHED_ENTRY_STATUS_COMPLETE;
                        }
                    }
                    break;
                default:
                    /* all other entry types don't have any sub-requests that
                     * need to be checked */
                    break;
            }

            if (i == s->idx && e->status == MPIDU_SCHED_ENTRY_STATUS_COMPLETE) {
                ++s->idx;
                if (e->is_barrier) {
                    dprintf(stderr, "completed barrier in entry %d\n", i);
                    /* post/perform the next round of operations */
                    mpi_errno = MPIDU_Sched_continue(s);
                    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
                }
            }
            else if (e->is_barrier && e->status != MPIDU_SCHED_ENTRY_STATUS_COMPLETE) {
                /* don't process anything after this barrier entry */
                break;
            }
        }

        if (s->idx == s->num_entries) {
            dprintf(stderr, "completing and dequeuing s=%p r=%p\n", s, s->req);

            /* dequeue this schedule from the state, it's complete */
            MPL_DL_DELETE(state->head, s);

            /* TODO refactor into a sched_complete routine? */
            MPID_REQUEST_SET_COMPLETED(s->req);
            MPID_Request_release(s->req);
            s->req = NULL;
            MPIU_Free(s->entries);
            MPIU_Free(s);

            if (made_progress)
                *made_progress = TRUE;
        }
    }

fn_exit:
    return mpi_errno;
fn_fail:
    goto fn_exit;
}

/* returns TRUE in (*made_progress) if any of the outstanding schedules completed */
#undef FUNCNAME
#define FUNCNAME MPIDU_Sched_progress
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPIDU_Sched_progress(int *made_progress)
{
    return MPIDU_Sched_progress_state(&all_schedules, made_progress);
}

static const char *entry_to_str(enum MPIDU_Sched_entry_type type) ATTRIBUTE((unused,used));
static const char *entry_to_str(enum MPIDU_Sched_entry_type type)
{
    switch(type) {
        case MPIDU_SCHED_ENTRY_SEND:
            return "SEND";
        case MPIDU_SCHED_ENTRY_RECV:
            return "RECV";
        case MPIDU_SCHED_ENTRY_REDUCE:
            return "REDUCE";
        case MPIDU_SCHED_ENTRY_COPY:
            return "COPY";
        case MPIDU_SCHED_ENTRY_NOP:
            return "NOP";
        case MPIDU_SCHED_ENTRY_CB:
            return "CB";
        default:
            return "(out of range)";
    }
}

/* utility function for debugging, dumps the given schedule object to fh */
#undef FUNCNAME
#define FUNCNAME MPIDU_Sched_dump_fh
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
void MPIDU_Sched_dump_fh(struct MPIDU_Sched *s, FILE *fh)
{
    int i;
    dprintf(fh, "--------------------------------\n");
    dprintf(fh, "s=%p\n", s);
    if (s) {
        dprintf(fh, "s->size=%zd\n", s->size);
        dprintf(fh, "s->idx=%zd\n", s->idx);
        dprintf(fh, "s->num_entries=%d\n", s->num_entries);
        dprintf(fh, "s->tag=%d\n", s->tag);
        dprintf(fh, "s->req=%p\n", s->req);
        dprintf(fh, "s->entries=%p\n", s->entries);
        for (i = 0; i < s->num_entries; ++i) {
            dprintf(fh, "&s->entries[%d]=%p\n", i, &s->entries[i]);
            dprintf(fh, "s->entries[%d].type=%s\n", i, entry_to_str(s->entries[i].type));
            dprintf(fh, "s->entries[%d].status=%d\n", i, s->entries[i].status);
            dprintf(fh, "s->entries[%d].is_barrier=%s\n", i, (s->entries[i].is_barrier ? "TRUE" : "FALSE"));
        }
    }
    dprintf(fh, "--------------------------------\n");
    /*
    dprintf(fh, "s->next=%p\n", s->next);
    dprintf(fh, "s->prev=%p\n", s->prev);
    */
}

/* utility function for debugging, dumps the given schedule object to stderr */
#undef FUNCNAME
#define FUNCNAME MPIDU_Sched_dump
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
void MPIDU_Sched_dump(struct MPIDU_Sched *s)
{
    MPIDU_Sched_dump_fh(s, stderr);
}

redpajama_set_name: RedPajamaGithub


text:
<?php

namespace SebastianBergmann\Comparator;

/**
 * Compares doubles for equality.
 *
 * @package    Comparator
 * @author     Bernhard Schussek <bschussek@2bepublished.at>
 * @copyright  Sebastian Bergmann <sebastian@phpunit.de>
 * @license    http://www.opensource.org/licenses/BSD-3-Clause  The BSD 3-Clause License
 * @link       http://www.github.com/sebastianbergmann/comparator
 */
class DoubleComparator extends NumericComparator
{
    /**
     * Smallest value available in PHP.
     *
     * @var float
     */
    const EPSILON = 0.0000000001;

    /**
     * Returns whether the comparator can compare two values.
     *
     * @param  mixed $expected The first value to compare
     * @param  mixed $actual The second value to compare
     * @return boolean
     */
    public function accepts($expected, $actual)
    {
        return (is_double($expected) || is_double($actual)) && is_numeric($expected) && is_numeric($actual);
    }

    /**
     * Asserts that two values are equal.
     *
     * @param  mixed $expected The first value to compare
     * @param  mixed $actual The second value to compare
     * @param  float $delta The allowed numerical distance between two values to
     *                      consider them equal
     * @param  bool  $canonicalize If set to TRUE, arrays are sorted before
     *                             comparison
     * @param  bool  $ignoreCase If set to TRUE, upper- and lowercasing is
     *                           ignored when comparing string values
     * @throws ComparisonFailure Thrown when the comparison
     *                           fails. Contains information layouts the
     *                           specific errors that lead to the failure.
     */
    public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false)
    {
        if ($delta == 0) {
            $delta = self::EPSILON;
        }

        parent::assertEquals($expected, $actual, $delta, $canonicalize, $ignoreCase);
    }
}


text:
package org.elasticsearch.spark.integration;

import scala.collection.mutable.Map;
import scala.collection.mutable.HashMap;

import java.util.Properties;

public class ScalaUtils {
    /*
     * Scala removed scala.collection.JavaConversions.propertiesAsScalaMap() in 2.13, replacing it with an implicit
     * jdk.CollectionConverters.asScala. This is an attempt to get a method that works in 2.10-2.13. It can be removed and replaced with
     * jdk.CollectionConverters once we no longer support scala older than 2.13.
     */
    public static scala.collection.Map<String, String> propertiesAsScalaMap(Properties props) {
        Map scalaMap = new HashMap();
        for (java.util.Map.Entry<Object, Object> entry : props.entrySet()) {
            scalaMap.put(entry.getKey(), entry.getValue());
        }
        return scalaMap;
    }
}


text:
'use strict';

// Load the module dependencies

// Define the routes module' method
module.exports = function(app) {
var device = require(appRoot + '/app/controllers/device.controller');
// var shop = require(appRoot + '/app/controllers/shop.controller');

	// Set up the 'articles' base routes
	app.route('/api/devices4weeks')
	   .get(device.readAll)

	// Set up the 'articles' base routes
	app.route('/api/devices')
	   .get(device.read)
	   // .post(device.create);

	// Set up the 'articles' parameterized routes
	app.route('/api/devices/:panid')
	   .get(device.read)
	   .put(device.update)
	   .delete(device.delete);

	// app.route('/api/shop')
	//    .get(shop.read)
	//    .post(shop.create);

};


text:
%%% Build instructions
%%% pdflatex -shell-escape ceres && bibtex ceres && pdflatex -shell-escape ceres && pdflatex -shell-escape ceres

\documentclass[11pt,letterpaper,oneside]{memoir}
\usepackage{fouriernc}
\usepackage[T1]{fontenc}
\usepackage{minted,amsmath,amssymb,amsthm,url,booktabs}
\usepackage[pdftex]{graphicx}
\usepackage[sort&compress]{natbib}
\usepackage[breaklinks=true,letterpaper=true,colorlinks,bookmarks=false]{hyperref}
\usepackage{algorithm}
\usepackage{algorithmic}

% page dimensions
\addtolength{\textwidth}{1.5in}
\addtolength{\oddsidemargin}{-0.75in}
\addtolength{\evensidemargin}{-0.75in}
\addtolength{\spinemargin}{-0.75in}
\addtolength{\foremargin}{-0.75in}
\setlength{\parindent}{0.0in}
\setlength{\parskip}{0.12in}

% Our pagestyle
\copypagestyle{ceres}{headings}
\makeevenhead{ceres}{\thepage}{}{\scshape\rightmark}
\makeoddhead{ceres}{\scshape\rightmark}{}{\thepage}

%% ceres chapter style
\makechapterstyle{ceres}{%
\renewcommand{\chapterheadstart}{}%
\renewcommand{\printchaptername}{}%
\renewcommand{\chapternamenum}{}%
\renewcommand{\printchapternum}{}%
\renewcommand{\afterchapternum}{}%
\renewcommand{\printchaptertitle}[1]{%
\raggedright\Large\scshape\MakeLowercase{##1}}%
\renewcommand{\afterchaptertitle}{%
\vskip\onelineskip \hrule\vskip\onelineskip}%
}%
\renewcommand{\cftchapterfont}{\normalfont}%
\renewcommand{\cftchapterpagefont}{\normalfont}%
\renewcommand{\cftchapterpresnum}{\bfseries}%
\renewcommand{\cftchapterleader}{}%
\renewcommand{\cftchapterafterpnum}{\cftparfillskip}%

%% Section title style
\setsecheadstyle{\raggedright\scshape\MakeLowercase}%
\setbeforesecskip{-\onelineskip}%
\setaftersecskip{\onelineskip}%

%% Subsection title style

\setsubsecheadstyle{\sethangfrom{\noindent ##1}\raggedright\itshape}%
\setbeforesubsecskip{-\onelineskip}%
\setaftersubsecskip{\onelineskip}%

\captiontitlefont{\small\sffamily}%
\let\caption\legend

\title{\Huge\scshape
\MakeLowercase{Ceres Solver:  Tutorial \& Reference}
}
\author{
\scshape\MakeLowercase{Sameer Agarwal} \\ \texttt{sameeragarwal@google.com}
\and
\scshape\MakeLowercase{Keir Mierle} \\  \texttt{ keir@google.com}
}
\checkandfixthelayout

\pagestyle{ceres}

\newcommand{\ceres}{{Ceres }}
\newcommand{\reals}{\mathbb{R} }
\def\eg{\emph{e.g. }}
\def\ie{\emph{i.e. }}
\newcommand{\glog}{\texttt{google-glog}}
\newcommand{\gflags}{\texttt{gflags}}
\newcommand{\eigen}{\texttt{Eigen3}}
\newcommand{\suitesparse}{\texttt{SuiteSparse}}
\newcommand{\cholmod}{\texttt{CHOLMOD}}
\newcommand{\amd}{\texttt{AMD}}
\newcommand{\colamd}{\texttt{COLAMD}}
\newcommand{\lapack}{\texttt{LAPACK}}
\newcommand{\blas}{\texttt{BLAS}}
\newcommand{\denseschur}{\texttt{DENSE\_SCHUR}}
\newcommand{\sparseschur}{\texttt{SPARSE\_SCHUR}}
\newcommand{\iterativeschur}{\texttt{ITERATIVE\_SCHUR}}
\newcommand{\cmake}{\texttt{cmake}}
\newcommand{\protobuf}{\texttt{protobuf}}
\settocdepth{chapter}

\begin{document}
\chapterstyle{ceres}
\maketitle
\thispagestyle{empty}
\newpage
\pagestyle{ceres}
\tableofcontents
\newpage

\chapter{A Note to the Reader}
Building this pdf from source requires a relatively recent installation of \texttt{LaTeX}~\footnote{\url{http://www.tug.org/texlive/}}, \texttt{minted.sty}\footnote{\url{http://code.google.com/p/minted/}} and \texttt{pygments}\footnote{\url{http://pygments.org/}}.

Despite our best efforts, this manual remains a work in progress and the source code for Ceres Solver remains the ultimate reference.

\input{changes}
\input{introduction}
\input{build}

%% Tutorial
\part{Tutorial}
\label{part:tutorial}
\input{nnlsq}
\input{helloworld}
\input{powell}
\input{curvefitting}
\input{bundleadjustment}

%% Reference
\part{Reference}
\label{part:reference}
\input{reference-overview}
\input{modeling}
\input{solving}

\input{faq}
\input{further}
\bibliographystyle{plain}
\bibliography{ceres}
\end{document}


text:
@import url(http://fonts.googleapis.com/css?family=Oswald);
.save_data_btn {
	height:32px;
	width:32px;
	background:url(../images/submit.png) left -32px no-repeat;
	display:block;
	float:right;
	cursor:pointer;
}
.activation-activate {
	background:url(../images/2.png) left top no-repeat;
	padding-left:70px;
}
.activation-purchase {
	background:url(../images/1.png) left top no-repeat;
	padding-left:70px;
}
#smthemes-btns-float {
	background:url('../images/background2.png') left top repeat;
	padding:5px;
	position:fixed;
	right:0;
	top:40%;
	border:1px solid #d3d3d3;
	border-right:none;
	-webkit-border-top-left-radius: 10px;
	-webkit-border-bottom-left-radius: 10px;
	-moz-border-radius-topleft: 10px;
	-moz-border-radius-bottomleft: 10px;
	border-top-left-radius: 10px;
	border-bottom-left-radius: 10px;
	z-index:999999;
}
#smthemes-btns-float img {
	cursor:pointer;
}
input.activate, input.activate:hover {
	cursor:pointer;
	 -moz-border-bottom-colors: none;
    -moz-border-left-colors: none;
    -moz-border-right-colors: none;
    -moz-border-top-colors: none;
    background-image: linear-gradient(bottom, rgb(32,110,146) 0%, rgb(40,138,183) 100%);
	background-image: -o-linear-gradient(bottom, rgb(32,110,146) 0%, rgb(40,138,183) 100%);
	background-image: -moz-linear-gradient(bottom, rgb(32,110,146) 0%, rgb(40,138,183) 100%);
	background-image: -webkit-linear-gradient(bottom, rgb(32,110,146) 0%, rgb(40,138,183) 100%);
	background-image: -ms-linear-gradient(bottom, rgb(32,110,146) 0%, rgb(40,138,183) 100%);
	background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0, rgb(32,110,146)),color-stop(1, rgb(40,138,183)));
    border-color: #298cba;
    border-image: none;
    border-radius: 5px 5px 5px 5px;
    border-right: 1px solid #298cba;
    border-style: solid;
    border-width: 0 1px 1px;
    box-shadow: 1px 1px 1px #555555;
    color: #FFFFFF;
    float: left;
    font-family: 'Oswald',sans-serif;
    font-size: 10pt;
    line-height: 100%;
    margin-right: 10px;
    padding: 3px 0;
	width:73px;
    text-align: center;
    text-shadow: 1px 1px #555555;
    text-transform: uppercase;
}
input.purchase, input.purchase:hover {
	cursor:pointer;
	 -moz-border-bottom-colors: none;
    -moz-border-left-colors: none;
    -moz-border-right-colors: none;
    -moz-border-top-colors: none;
    background-image: linear-gradient(bottom, rgb(237,111,14) 0%, rgb(250,146,26) 100%);
	background-image: -o-linear-gradient(bottom, rgb(237,111,14) 0%, rgb(250,146,26) 100%);
	background-image: -moz-linear-gradient(bottom, rgb(237,111,14) 0%, rgb(250,146,26) 100%);
	background-image: -webkit-linear-gradient(bottom, rgb(237,111,14) 0%, rgb(250,146,26) 100%);
	background-image: -ms-linear-gradient(bottom, rgb(237,111,14) 0%, rgb(250,146,26) 100%);
	background-image: -webkit-gradient(	linear,	left bottom,	left top,	color-stop(0, rgb(237,111,14)),	color-stop(1, rgb(250,146,26)));
    border-color: #FF9F01;
    border-image: none;
    border-radius: 5px 5px 5px 5px;
    border-right: 1px solid #FF9F01;
    border-style: solid;
    border-width: 0 1px 1px;
    box-shadow: 1px 1px 1px #555555;
    color: #FFFFFF;
    float: left;
    font-family: 'Oswald',sans-serif;
    font-size: 10pt;
    line-height: 100%;
    margin-right: 10px;
    padding: 3px 0;
	width:73px;
    text-align: center;
    text-shadow: 1px 1px #555555;
    text-transform: uppercase;
}
ul.tabs-menu {
	width:231px;
	float:left;
	list-style:none;
	overflow:hidden;
	height:auto;
	padding:0px;
	margin:0px;
	padding-left:10px;
	background:url(../images/menu-background-top.png) left top no-repeat;
}
.okbox{
	background:url('../images/ok.png') left top no-repeat;
	display:block;
	float:left;
	width:48px;
	height:48px;
	margin:10px;
	margin-top:-14px;
}
.badbox{
	background:url('../images/error.png') left top no-repeat;
	display:block;
	float:left;
	width:48px;
	height:48px;
	margin:10px;
	margin-top:-14px;
}
.smthemes-btns {
	clear: both;
	padding: 15px;
	height:20px;
	text-align: right;
	background: #393939;
}
.reset_data_btn {
	margin-right:10px;
}
.ajaxloader {
	float:left;
	display:none;
}
#imgloader {
	display:none;
}
#answer {
	width:300px;
	margin:10px auto;

}
.ajax {
	background:url(../images/img-loader.gif) left top no-repeat !important;
	width:220px;
	height:19px;
}
.bottom-background {
	background:url(../images/top-background.png) left top repeat-y;
	height:50px;
	width:8px;
	margin:-15px;
	float:left;
}
.smthemes-top {
	background:url(../images/top-background.png) left top repeat-y;
	height:120px;
}
.smthemes-top .tt-themename {
	font-size:22pt;
	margin-left:20px;
	font-family:'Oswald';
}
.smthemes-top img {
	margin-left:25px;
	margin-bottom:-40px;
}

.wrap {
	background:url(../images/background1.png) left top repeat;
	margin-top:0px !important;
}
.tabs {

}
.tabs-inner {
	background:url(../images/menu-background.png) left top repeat-y;
}
ul.tabs-menu li {
	color:#393939;
	line-height:35px;
	font-size:12pt;
	text-transform:uppercase;
	padding:2px 10px;
	margin:5px;
	border-top:1px solid #eee;
	margin-top:-1px;
	padding-top:5px;
}
ul.tabs-menu li img{
	margin-bottom:-5px;
	margin-right:10px;
}

ul.tabs-menu li:hover {
	color:#d76f00;
	cursor:pointer;
}

ul.tabs-menu li.active {
	color:#d76f00;
}

ul.tabs-content {

	width:70%;
	float:left;
	list-style:none;
	margin:0px;
	padding:0px;
	padding-left:25px;
}

ul.tabs-content li.content-li {
	display:block;

	margin:0px;
	display:none;
}
.content-li {
	padding:20px;
	background:url('../images/background2.png') left top repeat;
	border:1px solid #d3d3d3;
	-moz-border-radius-topleft:7px; /* top left corner */
	-moz-border-radius-topright:7px; /* top right corner */
	-webkit-border-top-left-radius:7px; /* top left corner */
	-webkit-border-top-right-radius:7px; /* top right corner */
	border-top-right-radius: 7px;
	border-top-left-radius: 7px;
	margin-bottom:20px !important;
}
ul.variants li {
	display:none;
	outline:1px solid #e0e0e0;
	border:9px solid #fff;
	padding:10px 23px;
	background:url('../images/background3.png') left top repeat;
	margin-bottom:20px;
}
.tinput {
	width:100%;
	-webkit-border-radius: 5px !important;
	-moz-border-radius: 5px !important;
	border-radius: 5px !important;
	padding:5px;
	border:1px solid #d2d5d8 !important;
}
.tselect {
	width:150px;
	-webkit-border-radius: 5px !important;
	-moz-border-radius: 5px !important;
	border-radius: 5px !important;
	padding:5px;
	border:1px solid #d2d5d8 !important;
}
.tinput:focus {
	border:1px solid #a7b1ba !important;
}
.tcheck{
	background-image:url(../images/checkbox.png);
	background-position: 0 35px;
	width:86px;
	height:35px;
	display:inline-block;
	cursor:pointer;
}
.tcheck input {
	display:none;
}
.finput {
	width:88%;
}
#server_answer {
	float:left;
	display:none;
	color:#fff;
	margin-left:20px;
}
.adm-form {
	border-collapse:collapse ;
}
.adm-form .item {
	min-height:50px;
	padding-bottom:30px;
}
.adm-form .p_ttl {
	margin-bottom:0px;
	height:21px;
	line-height:21px;
	color:#494949;
	font-weight:bold;
	display:block;
	background-image:url(../images/p_title.png);
	background-repeat:repeat-x;
}
.p_ttl {

	position:relative;
}
.p_ttl .span {
	background:url('../images/background2.png') left top repeat;
	padding-right:15px;
	padding-left:0px;
	font-size:10pt;
}
.p_ttl .hint {
	position:absolute;
	background:url('../images/background2.png') left top repeat;
	right:0;
	cursor:pointer;
}
.p_ttl .hint img {

}
.p_ttl .hint.active {
	right:0;
	background:#fff;
	-webkit-border-radius: 10px;
	-moz-border-radius: 10px;
	border-radius: 10px;
	border:1px solid #f6a033;
	padding:10px;
	font-style:italic;
	font-weight:normal;
	font-size:9pt;
	box-shadow: 1px 1px 1px #aaa;
	width:350px;
	cursor:pointer;

}
.p_ttl .hint.active img {
	float:right;
	margin-top:-17px;
	margin-right:-17px;
	padding:5px;
	box-shadow: 1px 0px 1px #aaa;
	-webkit-border-radius: 13px;
	-moz-border-radius: 13px;
	border-radius: 13px;
	background:#fff;
	border:1px solid #f6a033;
}
.variants .p_ttl span.hint.active span{
	background:#fff;
}
.variants .p_ttl span.hint.active {
	padding:10px;
}
.variants .p_ttl span.hint {
	padding:0px;
}
.variants .p_ttl span {
	background:url('../images/background3.png') left top repeat;
	padding-right:15px;
	padding-left:0px;
}
.custom_slides .finput {
	width:85%;
}
.custom_slides dd.slide_item {
	width:700px;
	height:auto;
	display: none;
	float: left;
	position: fixed;
	top: 50%; left: 50%;
	z-index: 999;
	overflow:hidden;
}
.custom_slides dd.slide_item .transparent {
	background:#000;
	-webkit-border-radius: 10px;
	-moz-border-radius: 10px;
	border-radius: 10px;
	opacity: .20;
	z-index:1;
	width: 100%;
	height:100%;
	position: absolute;
}
.custom_slides dd.slide_item .inner {
	width:89%;
	background:#fff;
	opacity:1.0;
	margin:8px;
	padding:30px;
	z-index:2;
	position:relative;
	-webkit-border-radius: 10px;
	-moz-border-radius: 10px;
	border-radius: 10px;
}
.custom_slides dd.add_dd{
	padding:0px;
	width:100%;
	display:block;
	margin:0px;
}
.slide_ttl {
	cursor:pointer;
	display:block;
	width:56px;
	height:56px;
	float:left;
	background:#fff !important;
	padding:2px;
	border:1px solid #d9d9d9;
	margin:5px;
	margin-bottom:20px;
}
.slide_ttl:hover {
	border:1px solid #ababab;
}
.add_dt {
	clear:left;
	margin-bottom:0px;
	height:21px;
	line-height:21px;
	color:#494949;
	font-weight:bold;
	display:block;
	background-image:url(../images/p_title.png) !important;
	background-repeat:repeat-x;
	background-position:15px;
}
.add_dt span {
	background:url('../images/background3.png') left top repeat;
	padding-right:15px;
	padding-left:0px;
	font-size:10pt;
}

.custom_slides table {
	width:100%;
	border-collapse:collapse;
}
#fade {
	display: none;
	background: #000;
	position: fixed; left: 0; top: 0;
	width: 100%; height: 100%;
	opacity: .50;
	z-index: 99;
}
.group_ttl {
	background:#7f8289;
	color:#fff;
	-webkit-border-radius: 5px !important;
	-moz-border-radius: 5px !important;
	border-radius: 5px !important;
	padding:5px;
	margin-bottom:5px;
	cursor:pointer;
	display:block;
}
.group_ttl:hover {
	background:#8a8e98;
}
.group_box {
	display:none;
	margin:0px 20px;
}
.newdetail {
	width:40%;float:right;
	margin-top:20px;
	outline:1px solid #e0e0e0;
	border:9px solid #fff;
	padding:10px 23px;
	background:url('../images/background3.png') left top repeat;
	margin-bottom:20px;
}
.newdetail p{
	margin-top:0px;
	padding-top:0px;
}
.newdetail .input {
	margin-top:-10px;
}
ul.contact-details {
	list-style:none;
	margin:0px;
	padding:0px;
	float:left;
	margin-top:20px;
	width:45%;
}
ul.contact-details li {
	border-bottom:1px solid #ddd;
	padding-bottom:5px;
	width:100%-25px;
	margin-bottom:5px;
	cursor: move;
	padding-left:40px;
	clear:left;
	height:32px;
	line-height:32px;
}
#detailspreset {
	border:1px solid #ddd;
	display:none;
}
#detailspreset table{
	width:100%;
}
#detailspreset table td {
	text-align:center;
}
#detailspreset img {
	cursor:pointer;
}
.itemdelete {
	margin-left:5px;
	float:right;
	width:16px;
	height:32px;
	cursor:pointer;
	background:url('../images/del.png') left 50% no-repeat;
}
.tableitemdelete {
	margin-left:5px;
	float:right;
	width:16px;
	height:32px;
	cursor:pointer;
	background:url('../images/del.png') left 50% no-repeat;
}
.itemedit {
	margin-left:5px;
	float:right;
	margin-top:2px;
	width:16px;
	height:32px;
	cursor:pointer;
	background:url('../images/edit.png') left 50% no-repeat;
}
.save_detail_btn {
	display:none;
	margin-left:5px;
}
.add_form_btn {
	margin-bottom:10px;
}
.detailsbox {
	overflow:hidden;
}
.detailsbox table {
	width:100%;
	margin:10px 0px;
	clear:right;
}
.detailsbox table .advanced {
	display:none;
}
.detailsbox table th {
	text-align:center;
	white-space:nowrap;
}
.detailsbox table td {
	padding:5px;
	text-align:center;
}
.trdrag {
	width:24px;
	height:24px;
	background:#393939;
	cursor: move;
}
.socialbox {
	overflow:hidden;
}
.socialbox table {
	 border: 0 none;
	 width:100%;
    border-collapse: collapse;
    margin: 16px 0;
}
.socialbox table tr {
    background-color: #F9F9F9;
}
.socialbox table th {
    background: none repeat scroll 0 0 #E5E5E5;
    border: 1px solid #BBBBBB;
    padding: 0.6em;
    text-align: center;
}
.socialbox table td {
    border: 1px solid #DDDDDD;
    padding: 0.6em;
    text-align: center;
}

.window {
	width:400px;
	height:auto;
	display: none;
	float: left;
	position: fixed;
	top: 50%; left: 50%;
	margin-left:-200px;
	margin-top:-200px;
	z-index: 999;
	overflow:hidden;
	padding:8px;
}
.window .transparent {
	background:#000;
	-webkit-border-radius: 10px;
	-moz-border-radius: 10px;
	border-radius: 10px;
	opacity: .20;
	margin:-8px;
	z-index:1;
	width: 100%;
	height:100%;
	position: absolute;
}
.window .inner {
	width:100%;
	background:#fff;
	opacity:1.0;
	z-index:2;
	position:relative;
	-webkit-border-radius: 10px;
	-moz-border-radius: 10px;
	border-radius: 10px;
}
.window .inner .inner2 {
	padding:15px;
}
#new_social table {
	width:100%;
}
.cancel_btn {
	margin-left:20px;
}
.edit_social_btn {
	float:none;
}
.sidebarselector img {
	margin:0 5px;
	cursor:pointer;
	padding-bottom:10px;
}
.sidebarselector img.active {
	border-bottom: 3px solid #C8C8C8;
    padding-bottom: 7px;
}
.sidebarselector select {
	display:none;
}
.rightlinks {
	float:right;
}
.rightlinks li {
	float:left;
	padding:10px;
}


text:
package com.moudle.necromreader.api;

public class Constant
{
    public static final String TAG = "NecromReader";
    public static final String APPKEY = "95873edadc0f7fdcc2ace93758f3da63";
    public static final String NEWS_URL = "http://v.juhe.cn/toutiao/index";
    public static final String URL_NEWS_BASE = "http://v.juhe.cn/toutiao/";

    public static final String URL_GANK_PHOTO_BASE = "http://gank.io/api/data/";

    public static final int REQUEST_WRITE_EXTERNAL_STORAGE = 1000;

    public static final String PIC_PATH = "/NecromReader";

    //下拉刷新标识
    public static final int PULL_TO_REFRESH = 100;
    //上拉加载更多标识
    public static final int UP_TO_LOAD_MORE = 101;
    //下拉刷新无数据标识
    public static final int NO_DATA = 102;
    //上拉加载无数据标识
    public static final int NO_MORE_DATA = 103;

    public static final int NAV_TOP_NEW = 104;
    public static final int NAV_GANK = 105;

}


text:
/**
 * UDT Transport.
 * <p>
 * @see io.netty.example.udt
 *
 * @deprecated The UDT transport is no longer maintained and will be removed.
 */
package io.netty.channel.udt;


text:
package org.apache.ignite.ml.preprocessing.encoding.target;

import java.util.Set;
import org.apache.ignite.ml.math.primitives.vector.VectorUtils;
import org.apache.ignite.ml.preprocessing.Preprocessor;
import org.apache.ignite.ml.preprocessing.encoding.EncoderPreprocessor;
import org.apache.ignite.ml.structures.LabeledVector;

/**
 * Preprocessing function that makes Target encoding.
 *
 * The Target Encoder Preprocessor encodes string values (categories) to double values
 * in range [0.0, 1], where the value will be presented as a regularized mean target value of
 * a category.
 *
 * alpha = 1 / (1 + exp(-(categorySize - min_samples_leaf) / beta))
 * encodedValue = globalTargetMean * (1 - alpha) + categoryTargetMean * alpha
 * if categorySize == 1 then use globalTargetMean
 *
 * min_samples_leaf - minimum samples to take category average into account.
 * beta - smoothing effect to balance categorical average vs prior. Higher value means
 * stronger regularization.
 *
 * ref: https://dl.acm.org/doi/10.1145/507533.507538
 *
 *

 * This preprocessor can transform multiple columns which indices are handled during training process.
 * These indexes could be defined via .withEncodedFeature(featureIndex) call.
 *

 *

 * NOTE: it does not add new column but change data in-place.
 *

 *
 * @param <K> Type of a key in {@code upstream} data.
 * @param <V> Type of a value in {@code upstream} data.
 */
public class TargetEncoderPreprocessor<K, V> extends EncoderPreprocessor<K, V> {
    /** */
    protected static final long serialVersionUID = 6237711236382623481L;

    /** Filling values. */
    protected final TargetEncodingMeta[] targetCounters;

    /**
     * Constructs a new instance of Frequency Encoder preprocessor.
     *
     * @param basePreprocessor Base preprocessor.
     * @param handledIndices Handled indices.
     */
    public TargetEncoderPreprocessor(TargetEncodingMeta[] targetCounters,
                                     Preprocessor<K, V> basePreprocessor, Set<Integer> handledIndices) {
        super(null, basePreprocessor, handledIndices);
        this.targetCounters = targetCounters;
    }

    /**
     * Applies this preprocessor.
     *
     * @param k Key.
     * @param v Value.
     * @return Preprocessed row.
     */
    @Override public LabeledVector apply(K k, V v) {
        LabeledVector tmp = basePreprocessor.apply(k, v);
        double[] res = new double[tmp.size()];

        for (int i = 0; i < res.length; i++) {
            Object tmpObj = tmp.getRaw(i);

            if (handledIndices.contains(i)) {
                if (targetCounters[i].getCategoryMean().containsKey(tmpObj.toString())) {
                    res[i] = targetCounters[i].getCategoryMean().get(tmpObj.toString());
                }
                else {
                    res[i] = targetCounters[i].getGlobalMean();
                }
            }
            else
                res[i] = (double)tmpObj;
        }

        return new LabeledVector(VectorUtils.of(res), tmp.label());
    }
}


text:
package com.yxkang.android.db;

/**
 * Created by yexiaokang on 2016/2/2.
 */
class ColumnInfo {
    String name;
    String type;
    int order;
    boolean primary;
    boolean notNull;
}


text:
Adapter that allows you to use a MongoDB GridFS for storing files.

## Parameters

 * `mongogridfs_id` The id of the service that provides MongoGridFS object instance for adapter *(required)*

## Example

``` yaml
# app/config/config.yml
knp_gaufrette:
    adapters:
        foo:
            gridfs:
                mongogridfs_id: acme_test.gridfs
```

In your AcmeTestBundle, add following service definitions:

``` yaml
# src/Acme/TestBundle/Resources/config/services.yml
parameters:
    acme_test.mongo.server: "mongodb://localhost:27017"
    acme_test.mongo.options:
        connect: true
    acme_test.mongodb.name: "test_database"
    acme_test.gridfs.prefix: "fs" #Default
services:
    acme_test.mongo:
        class: Mongo
        arguments: [%acme_test.mongo.server%, %acme_test.mongo.options%]
    acme_test.mongodb:
        class: MongoDB
        arguments: [@acme_test.mongo, %acme_test.mongodb.name%]
    acme_test.gridfs:
        class: MongoGridFS
        arguments: [@acme_test.mongodb, %acme_test.gridfs.prefix%]
```

Note that it is possible to prepare MongoGridFS service any way you like. This is just one way to do it.


text:
<!DOCTYPE html>

  <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Get a minimum spanning tree subgraph — get_min_spanning_tree • DiagrammeR</title>

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">

<link href="../pkgdown.css" rel="stylesheet">

      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">

      </button>
      DiagrammeR

  Reference

  News

Get a minimum spanning tree subgraph

Get a minimum spanning tree subgraph
for a connected graph of class dgr_graph.

get_min_spanning_tree(graph)

 Arguments

    <colgroup><col class="name" /><col class="desc" /></colgroup>

      graph

a graph object of class
dgr_graph.

Value

a graph object of class dgr_graph.

Examples

# Create a random graph using the
# `add_gnm_graph()` function
graph <-
  create_graph() %>%
  add_gnm_graph(
    n = 10,
    m = 15,
    set_seed = 23)

# Obtain Jaccard similarity
# values for each pair of
# nodes as a square matrix
j_sim_matrix <-
  graph %>%
    get_jaccard_similarity()

# Create a weighted, undirected
# graph from the resultant matrix
# (effectively treating that
# matrix as an adjacency matrix)
graph <-
  j_sim_matrix %>%
  from_adj_matrix(weighted = TRUE)

# The graph in this case is a fully connected graph
# with loops, where jaccard similarity values are
# assigned as edge weights (edge attribute `weight`);
# The minimum spanning tree for this graph is the
# connected subgraph where the edges retained have
# the lowest similarity values possible
min_spanning_tree_graph <-
  graph %>%
  get_min_spanning_tree() %>%
  copy_edge_attrs(
    edge_attr_from = weight,
    edge_attr_to = label) %>%
  set_edge_attrs(
    edge_attr = fontname,
    values = "Helvetica") %>%
  set_edge_attrs(
    edge_attr = color,
    values = "gray85") %>%
  rescale_edge_attrs(
    edge_attr_from = weight,
    to_lower_bound = 0.5,
    to_upper_bound = 4.0,
      edge_attr_to = penwidth)

Contents

Arguments

Value

Examples

Developed by Rich Iannone.

Site built with pkgdown.


text:
package org.springframework.scheduling.annotation;

import java.lang.annotation.Annotation;
import java.util.concurrent.Executor;

import org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.core.task.TaskExecutor;
import org.springframework.util.Assert;

/**
 * Bean post-processor that automatically applies asynchronous invocation
 * behavior to any bean that carries the {@link Async} annotation at class or
 * method-level by adding a corresponding {@link AsyncAnnotationAdvisor} to the
 * exposed proxy (either an existing AOP proxy or a newly generated proxy that
 * implements all of the target's interfaces).
 *
 *
The {@link TaskExecutor} responsible for the asynchronous execution may
 * be provided as well as the annotation type that indicates a method should be
 * invoked asynchronously. If no annotation type is specified, this post-
 * processor will detect both Spring's {@link Async @Async} annotation as well
 * as the EJB 3.1 {@code javax.ejb.Asynchronous} annotation.
 *
 *
Note: The underlying async advisor applies before existing advisors by default,
 * in order to switch to async execution as early as possible in the invocation chain.
 *
 * @author Mark Fisher
 * @author Juergen Hoeller
 * @since 3.0
 * @see Async
 * @see AsyncAnnotationAdvisor
 * @see #setBeforeExistingAdvisors
 */
@SuppressWarnings("serial")
public class AsyncAnnotationBeanPostProcessor extends AbstractAdvisingBeanPostProcessor
		implements BeanFactoryAware {

	private Class<? extends Annotation> asyncAnnotationType;

	private Executor executor;

	public AsyncAnnotationBeanPostProcessor() {
		setBeforeExistingAdvisors(true);
	}

	/**
	 * Set the 'async' annotation type to be detected at either class or method
	 * level. By default, both the {@link Async} annotation and the EJB 3.1
	 * {@code javax.ejb.Asynchronous} annotation will be detected.
	 *
This setter property exists so that developers can provide their own
	 * (non-Spring-specific) annotation type to indicate that a method (or all
	 * methods of a given class) should be invoked asynchronously.
	 * @param asyncAnnotationType the desired annotation type
	 */
	public void setAsyncAnnotationType(Class<? extends Annotation> asyncAnnotationType) {
		Assert.notNull(asyncAnnotationType, "'asyncAnnotationType' must not be null");
		this.asyncAnnotationType = asyncAnnotationType;
	}

	/**
	 * Set the {@link Executor} to use when invoking methods asynchronously.
	 */
	public void setExecutor(Executor executor) {
		this.executor = executor;
	}

	@Override
	public void setBeanFactory(BeanFactory beanFactory) {
		AsyncAnnotationAdvisor advisor = (this.executor != null ?
				new AsyncAnnotationAdvisor(this.executor) : new AsyncAnnotationAdvisor());
		if (this.asyncAnnotationType != null) {
			advisor.setAsyncAnnotationType(this.asyncAnnotationType);
		}
		advisor.setBeanFactory(beanFactory);
		this.advisor = advisor;
	}

}


text:
<?php
/**
 * Created by PhpStorm.
 * User: pierrecassat
 * Date: 22/02/15
 * Time: 19:22
 */

namespace Demo;

use \Library\Event\AbstractObservable;
use \Library\Event\ObservableInterface;

class TestObservable
    extends AbstractObservable
    implements ObservableInterface
{

    public function __construct($name = 'Anonymous')
    {
        parent::__construct();
        $this->setName($name);
    }

    public function setName($name)
    {
        $this->name = $name;
        return $this;
    }
}


text:
#include <string.h>

#include "st_utils.h"
#include "st_log.h"
#include "st_queue.h"

st_queue_t* st_queue_create(st_queue_id_t capacity)
{
    st_queue_t* queue;
    void** data;

    queue = (st_queue_t*)st_malloc(sizeof(st_queue_t));
    if(NULL == queue) {
        ST_ERROR("alloc memory for queue failed");
        return NULL;
    }
    memset(queue, 0, sizeof(st_queue_t));

    queue->capacity = capacity + 1;
    queue->start_idx = 0;
    queue->end_idx = -1;
    data = (void**)st_malloc(sizeof(void*)*queue->capacity);
    if(NULL == data) {
        ST_ERROR("alloc memory for data failed");
        goto FAILED;
    }
    queue->data_arr = data;

    return queue;

FAILED:
    safe_st_queue_destroy(queue);
    return NULL;
}

int st_enqueue(st_queue_t* queue, void* obj)
{
    if(((queue->end_idx + 2) % queue->capacity) == queue->start_idx) {
        return ST_QUEUE_FULL;
    }
    queue->end_idx = ((queue->end_idx + 1) % queue->capacity);
    queue->data_arr[queue->end_idx] = obj;

    return ST_QUEUE_OK;
}

int st_dequeue(st_queue_t* queue, void** obj)
{
    if(((queue->end_idx + 1) % queue->capacity) == queue->start_idx) {
        return ST_QUEUE_EMPTY;
    }
    *obj = queue->data_arr[queue->start_idx];
    queue->start_idx = ((queue->start_idx + 1) % queue->capacity);

    return ST_QUEUE_OK;
}

bool st_queue_empty(st_queue_t* queue)
{
    if(((queue->end_idx + 1) % queue->capacity) == queue->start_idx) {
        return true;
    }
    return false;
}

st_queue_id_t st_queue_size(st_queue_t* queue)
{
    return ((queue->end_idx - queue->start_idx + 1) % queue->capacity);
}

st_queue_id_t st_queue_capacity(st_queue_t* queue)
{
    return queue->capacity - 1;
}

int st_queue_clear(st_queue_t* queue)
{
    queue->start_idx = 0;
    queue->end_idx   = -1;
    return ST_QUEUE_OK;
}

void st_queue_destroy(st_queue_t* queue)
{
    if(queue == NULL) {
        return;
    }

    if(queue->data_arr != NULL) {
        safe_st_free(queue->data_arr);
    }
}


text:
<!DOCTYPE html>

  <title>The Future of Check-Ins Is Not About Location</title>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="skype_toolbar" content="skype_toolbar_parser_compatible">
  <meta name="description" content="In response to an article on Read Write Web titled Life After Death of the Check-In I felt compelled to not only comment on it, but ultimately write the following blog post.">
  <meta name="author" content="Joe McCann">
  <meta property="og:locale" content="en_US">
  <meta property="og:title" content="The Future of Check-Ins Is Not About Location">
  <meta property="og:url" content="http://subprint.com/blog/the-future-of-check-ins-is-not-about-location">
  <meta property="og:site_name" content="subPrint Interactive">
  <meta property="og:type" content="website">
  <meta property="og:description" content="In response to an article on Read Write Web titled Life After Death of the Check-In I felt compelled to not only comment on it, but ultimately write the following blog post.">
  <meta property="og:email" content="connect@subprint.com">
  <meta property="og:phone_number" content="+1 718 577 2343">
  <meta property="og:image" content="http://subprint.com/img/logo-open-graph.png">

  <link href="/css/style-0.0.4-10.min.css" rel="stylesheet">

  <link rel="shortcut icon" href="/ico/favicon.ico">
  <link rel="apple-touch-icon-precomposed" sizes="144x144" href="/ico/apple-touch-icon-144-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/ico/apple-touch-icon-114-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/ico/apple-touch-icon-72-precomposed.png">
  <link rel="apple-touch-icon-precomposed" href="/ico/apple-touch-icon-57-precomposed.png">

  <meta name="msapplication-TileColor" content="#fafafa"/>
  <meta name="msapplication-TileImage" content="/ico/apple-touch-icon-144-precomposed.png"/>

Oooooo, sorry that's the wrong answer. You actually need JavaScript enabled!

Be sure and come back when you have JavaScript enabled - It's 2013!!!!111!1!

04/16/2012

The Future of Check-Ins Is Not About Location

Joe McCann

In response to an article on Read Write Web titled Life After Death of the Check-In I felt compelled to not only comment on it, but ultimately write the following blog post.

The author of the article assumes that check-ins have all to much to do with an actual location.  I disagree.  The best thing that Foursquare (and BrightKite and Gowalla) did with creating the behaviour of checking into a place was getting users familiar with the concept of "checking-in".  However, checking-in's value has little to do with the actual location or a place - checking in is a projection of a user's status to the outside world, a consistent curating of one's online persona.

Take GetGlue for example.  GetGlue is an application that enables one to "check-in" to the TV show one is watching.  9 times out of 10 one will be in the exact same location - their couch - while checking in.  However, GetGlue, one of the top rated and most heavily downloaded apps on the App Store and Google Play, has had massive success with people checking into what they are watching (over 2 million users and over 100 million check-ins).

Suffice it to say, location still plays a role in someone's checking-in (because no matter where you are, you always have a latitude/longitude coordinate pair associated with you) but it is not the essence of checking in.  Check-ins 2.0 (yes I'm calling it that) will have less and less to do with actual location.

Places, things, experiences -- all of these are able to be checked-in to.  And from this we will see the next wave of check-in based applications and networks.

  Tweet

Please enable JavaScript to view the comments powered by Disqus.


text:
using Boards
using Base.Test

# write your own tests here
@test getboard() >= 0


text:
local ModDuplicator = Class.create("ModDuplicator", Entity)
-- local ObjSimpleEmitter = require "objects.ObjSimpleEmitter"
ModDuplicator.dependencies = {"ModPartEmitter", "ModActive"}
local TimedText = require "objects.TimedText"

ModDuplicator.trackFunctions = {"onAttack","onDeath"}
ModDuplicator.removable = true

function ModDuplicator:create()
	-- self:addEmitter("fire" , "assets/spr/fire.png")
	-- self:setRandomDirection("fire" , 3 * 32)
	-- self:setRandRotation("fire",32,0,1)
	-- local fire = self.psystems["fire"]
	-- fire:setParticleLifetime(1, 2);
	-- self:setAreaSpread("fire","normal",8,8)
	-- self.bombCoolDown = 0
	-- self:setFade("fire")
	self:addIcon(require("assets.spr.scripts.IcoDuplicator"))
end

function ModDuplicator:onDeath()
	self:removeModule("ModDuplicator")

	if self:hasModule("ModControllable") then
		self:setHealth(250)
		lume.trace()
		self.isAlive = true
		self.reviving = true
		local newText = TimedText("A clone has replaced you", self.x, self.y, 20)
		Game:add(newText)
		self.textWritten = false
	else
		local selfType = require("objects."..self.type)
		for i=1,4 do
			local newCopy = selfType()
			Game:add(newCopy)
			--Class.include(newCopy,self)
			Game.tagag = newCopy

			newCopy.x = self.x
			newCopy.y = self.y
			-- newCopy.health = 100 --self.max_health
			-- newCopy.max_health = 100
			newCopy:setPosition(self.x,self.y)
			for i,v in ipairs(self:getAllRemovableModules()) do
				newCopy:addModule(require ("modules." .. v))
			end
			newCopy:removeModule("ModDuplicator")
			newCopy.body:setLinearVelocity(math.random(-4,4) * 32, -12 * 32)
		end
	end
	-- local newEmitter = ObjSimpleEmitter(self.x,self.y)
	-- Game:add(newEmitter)
	-- newEmitter:setDestroyAfterEmpty(true)
	-- newEmitter:addEmitter("fire" , "assets/spr/fire.png")
	-- newEmitter:setRandomDirection("fire" , 3 * 32)
	-- newEmitter:setRandRotation("fire",32,0,1)
	-- local fire = newEmitter.psystems["fire"]
	-- fire:setParticleLifetime(1, 2);
	-- newEmitter:setFade("fire")
	-- newEmitter:emit("fire",16)
end

function ModDuplicator:onRemove()
	self:removeIcon("assets/spr/duplicator.png")
end

return ModDuplicator


text:
	<link rel="stylesheet" href="styles.css">
	<link rel="stylesheet" href="card.css">


text:
package com.intellij.codeInsight.completion;

import com.intellij.codeInsight.TailType;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupItem;
import com.intellij.codeInsight.lookup.LookupValueWithUIHint;
import com.intellij.codeInsight.lookup.PresentableLookupValue;
import com.intellij.codeInsight.template.Template;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.paths.PsiDynaReference;
import com.intellij.openapi.project.IndexNotReadyException;
import com.intellij.openapi.util.TextRange;
import com.intellij.patterns.ElementPattern;
import com.intellij.patterns.ObjectPattern;
import com.intellij.psi.*;
import com.intellij.psi.filters.ElementFilter;
import com.intellij.psi.filters.TrueFilter;
import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference;
import com.intellij.psi.meta.PsiMetaData;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.*;

import static com.intellij.patterns.StandardPatterns.character;
import static com.intellij.patterns.StandardPatterns.not;

/**
 * @deprecated see {@link CompletionContributor}
 */
@Deprecated
@SuppressWarnings("deprecation")
public class CompletionData {
  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.completion.CompletionData");
  public static final ObjectPattern.Capture<Character> NOT_JAVA_ID = not(character().javaIdentifierPart());
  private final List<CompletionVariant> myCompletionVariants = new ArrayList<>();

  protected CompletionData(){ }

  private boolean isScopeAcceptable(PsiElement scope){

    for (final CompletionVariant variant : myCompletionVariants) {
      if (variant.isScopeAcceptable(scope)) {
        return true;
      }
    }
    return false;
  }

  /**
   * @deprecated
   * @see CompletionContributor
   */
  @Deprecated
  protected void registerVariant(CompletionVariant variant){
    myCompletionVariants.add(variant);
  }

  public void completeReference(final PsiReference reference, final Set<? super LookupElement> set, @NotNull final PsiElement position, final PsiFile file) {
    final CompletionVariant[] variants = findVariants(position, file);
    boolean hasApplicableVariants = false;
    for (CompletionVariant variant : variants) {
      if (variant.hasReferenceFilter()) {
        variant.addReferenceCompletions(reference, position, set, file, this);
        hasApplicableVariants = true;
      }
    }

    if (!hasApplicableVariants) {
      myGenericVariant.addReferenceCompletions(reference, position, set, file, this);
    }
  }

  public void addKeywordVariants(Set<? super CompletionVariant> set, PsiElement position, final PsiFile file) {
    ContainerUtil.addAll(set, findVariants(position, file));
  }

  void completeKeywordsBySet(final Set<LookupElement> set, Set<? extends CompletionVariant> variants){
    for (final CompletionVariant variant : variants) {
      variant.addKeywords(set, this);
    }
  }

  public String findPrefix(PsiElement insertedElement, int offsetInFile){
    return findPrefixStatic(insertedElement, offsetInFile);
  }

  public CompletionVariant[] findVariants(final PsiElement position, final PsiFile file){
    final List<CompletionVariant> variants = new ArrayList<>();
      PsiElement scope = position;
      if(scope == null){
        scope = file;
      }
      while (scope != null) {
        boolean breakFlag = false;
        if (isScopeAcceptable(scope)){

          for (final CompletionVariant variant : myCompletionVariants) {
            if (variant.isVariantApplicable(position, scope) && !variants.contains(variant)) {
              variants.add(variant);
              if (variant.isScopeFinal(scope)) {
                breakFlag = true;
              }
            }
          }
        }
        if(breakFlag)
          break;
        scope = scope.getContext();
        if (scope instanceof PsiDirectory) break;
      }
      return variants.toArray(new CompletionVariant[0]);
  }

  protected final CompletionVariant myGenericVariant = new CompletionVariant() {
    @Override
    void addReferenceCompletions(PsiReference reference, PsiElement position, Set<? super LookupElement> set, final PsiFile file,
                                 final CompletionData completionData) {
      completeReference(reference, position, set, TailType.NONE, TrueFilter.INSTANCE, this);
    }
  };

  @Nullable
  public static String getReferencePrefix(@NotNull PsiElement insertedElement, int offsetInFile) {
    try {
      PsiReference ref = insertedElement.getContainingFile().findReferenceAt(offsetInFile);
      if (ref != null) {
        PsiElement element = ref.getElement();
        int offsetInElement = offsetInFile - element.getTextRange().getStartOffset();
        for (TextRange refRange : ReferenceRange.getRanges(ref)) {
          if (refRange.contains(offsetInElement)) {
            int beginIndex = refRange.getStartOffset();
            String text = element.getText();
            if (beginIndex > offsetInElement || beginIndex < 0 || offsetInElement < 0 || offsetInElement > text.length() || beginIndex > text.length()) {
              throw new AssertionError("Inconsistent reference range:" +
                                       " ref=" + ref.getClass() +
                                       " element=" + element.getClass() +
                                       " ref.start=" + refRange.getStartOffset() +
                                       " offset=" + offsetInElement +
                                       " psi.length=" + text.length());
            }
            return text.substring(beginIndex, offsetInElement);
          }
        }
      }
    }
    catch (IndexNotReadyException ignored) {
    }
    return null;
  }

  public static String findPrefixStatic(final PsiElement insertedElement, final int offsetInFile, ElementPattern<Character> prefixStartTrim) {
    if(insertedElement == null) return "";

    final Document document = insertedElement.getContainingFile().getViewProvider().getDocument();
    assert document != null;
    LOG.assertTrue(!PsiDocumentManager.getInstance(insertedElement.getProject()).isUncommited(document), "Uncommitted");

    final String prefix = getReferencePrefix(insertedElement, offsetInFile);
    if (prefix != null) return prefix;

    if (insertedElement instanceof PsiPlainText || insertedElement instanceof PsiComment) {
      return CompletionUtil.findJavaIdentifierPrefix(insertedElement, offsetInFile);
    }

    return findPrefixDefault(insertedElement, offsetInFile, prefixStartTrim);
  }

  public static String findPrefixStatic(final PsiElement insertedElement, final int offsetInFile) {
    return findPrefixStatic(insertedElement, offsetInFile, NOT_JAVA_ID);
  }

  public static String findPrefixDefault(final PsiElement insertedElement, final int offset, @NotNull final ElementPattern trimStart) {
    String substr = insertedElement.getText().substring(0, offset - insertedElement.getTextRange().getStartOffset());
    if (substr.length() == 0 || Character.isWhitespace(substr.charAt(substr.length() - 1))) return "";

    substr = substr.trim();

    int i = 0;
    while (substr.length() > i && trimStart.accepts(substr.charAt(i))) i++;
    return substr.substring(i).trim();
  }

  public static LookupElement objectToLookupItem(final @NotNull Object object) {
    if (object instanceof LookupElement) return (LookupElement)object;

    String s = null;
    TailType tailType = TailType.NONE;
    if (object instanceof PsiElement){
      s = PsiUtilCore.getName((PsiElement)object);
    }
    else if (object instanceof PsiMetaData) {
      s = ((PsiMetaData)object).getName();
    }
    else if (object instanceof String) {
      s = (String)object;
    }
    else if (object instanceof Template) {
      s = ((Template) object).getKey();
    }
    else if (object instanceof PresentableLookupValue) {
      s = ((PresentableLookupValue)object).getPresentation();
    }
    if (s == null) {
      throw new AssertionError("Null string for object: " + object + " of class " + object.getClass());
    }

    LookupItem item = new LookupItem(object, s);

    if (object instanceof LookupValueWithUIHint && ((LookupValueWithUIHint) object).isBold()) {
      item.setBold();
    }
    item.setAttribute(LookupItem.TAIL_TYPE_ATTR, tailType);
    return item;
  }

  protected void addLookupItem(Set<? super LookupElement> set, TailType tailType, @NotNull Object completion, final CompletionVariant variant) {
    LookupElement ret = objectToLookupItem(completion);
    if (ret == null) return;
    if (!(ret instanceof LookupItem)) {
      set.add(ret);
      return;
    }

    LookupItem item = (LookupItem)ret;

    final InsertHandler insertHandler = variant.getInsertHandler();
    if(insertHandler != null && item.getInsertHandler() == null) {
      item.setInsertHandler(insertHandler);
      item.setTailType(TailType.UNKNOWN);
    }
    else if (tailType != TailType.NONE) {
      item.setTailType(tailType);
    }
    final Map<Object, Object> itemProperties = variant.getItemProperties();
    for (final Object key : itemProperties.keySet()) {
      item.setAttribute(key, itemProperties.get(key));
    }

    set.add(ret);
  }

  protected void completeReference(PsiReference reference, PsiElement position, Set<? super LookupElement> set, TailType tailType, ElementFilter filter, CompletionVariant variant) {
    if (reference instanceof PsiMultiReference) {
      for (PsiReference ref : getReferences((PsiMultiReference)reference)) {
        completeReference(ref, position, set, tailType, filter, variant);
      }
    }
    else if (reference instanceof PsiDynaReference) {
      for (PsiReference ref : ((PsiDynaReference<?>)reference).getReferences()) {
        completeReference(ref, position, set, tailType, filter, variant);
      }
    }
    else{
      final Object[] completions = reference.getVariants();
      for (Object completion : completions) {
        if (completion == null) {
          LOG.error("Position=" + position + "\n;Reference=" + reference + "\n;variants=" + Arrays.toString(completions));
          continue;
        }
        if (completion instanceof PsiElement) {
          final PsiElement psiElement = (PsiElement)completion;
          if (filter.isClassAcceptable(psiElement.getClass()) && filter.isAcceptable(psiElement, position)) {
            addLookupItem(set, tailType, completion, variant);
          }
        }
        else {
          if (completion instanceof LookupItem) {
            final Object o = ((LookupItem)completion).getObject();
            if (o instanceof PsiElement) {
              if (!filter.isClassAcceptable(o.getClass()) || !filter.isAcceptable(o, position)) continue;
            }
          }
          try {
            addLookupItem(set, tailType, completion, variant);
          }
          catch (AssertionError e) {
            LOG.error("Caused by variant from reference: " + reference.getClass(), e);
          }
        }
      }
    }
  }

  protected static PsiReference[] getReferences(final PsiMultiReference multiReference) {
    final PsiReference[] references = multiReference.getReferences();
    final List<PsiReference> hard = ContainerUtil.findAll(references, object -> !object.isSoft());
    if (!hard.isEmpty()) {
      return hard.toArray(PsiReference.EMPTY_ARRAY);
    }
    return references;
  }

  void addKeywords(Set<LookupElement> set, CompletionVariant variant, Object comp, TailType tailType) {
    if (!(comp instanceof String)) return;

    for (final LookupElement item : set) {
      if (item.getObject().toString().equals(comp)) {
        return;
      }
    }
    addLookupItem(set, tailType, comp, variant);
  }
}


text:
var buManager = require('../managers/BuildManager');

exports.index = function(req, res) {
  var user;
  if (user = res.locals.current_user) {
    var building_sign = req.params.sign;
    var body_sign, is_single;
    if (building_sign) {
      body_sign = building_sign;
      is_single = true;
    } else {
      body_sign = user.bodySign;
      is_single = user.isSingle;
    }

    res.render('index', {
      user_id: user.id,
      user_name: user.name,
      is_single: is_single,
      body_sign: body_sign,
      user_info_str: JSON.stringify({
        user_id: user.id,
        body_sign: body_sign,
        is_single: is_single
      }),
      function_list: res.locals.function_list
    });
  } else {
    res.redirect('/signin');
  }
};

exports.app_index = function(req, res, next) {
  var user,
    building_sign;
  var bm = new buManager();
  if (user = res.locals.current_user) {
    building_sign = req.query.id;
    bm.GetFunctionDetail(req.params.id, function(err, app_info) {
      if (err) {
        return next(err);
      }
      res.render('app_index', {
        user_id: user.id,
        user_name: user.name,
        user_info_str: JSON.stringify({
          user_id: user.id,
          body_sign: user.bodySign,
          is_single: user.isSingle,
          building_sign: building_sign
        }),
        building_sign: building_sign,
        function_list: res.locals.function_list,
        app_info: {
          name: app_info.name,
          url: app_info.property[4].propertyValue
        }
      });
    });
  } else {
    res.redirect('/signin');
  }
};

exports.report_index = function(req, res, next) {
  var user;
  var bm = new buManager();
  if (user = res.locals.current_user) {
    var body_sign = req.query.bodySign;
    bm.DownLoadReport(body_sign, req.params.id, function(err, report) {
      if (err) {
        return next(err);
      }
      res.redirect(report.fileUrl);
    });
  } else {
    res.redirect('/signin');
  }
};


text:
package applications

import (
	"context"
	"fmt"

	"github.com/pkg/errors"

	"github.com/vmware-tanzu/octant/pkg/store"
	"github.com/vmware-tanzu/octant/pkg/view/component"
)

//go:generate mockgen -destination=./fake/mock_summarizer.go -package=fake github.com/vmware-tanzu/octant/internal/modules/applications Summarizer

var (
	applicationListColumns = component.NewTableCols("Name", "Instance", "Version", "State", "Pods")
)

const (
	appLabelName     = "app.kubernetes.io/name"
	appLabelInstance = "app.kubernetes.io/instance"
	appLabelVersion  = "app.kubernetes.io/version"
)

// SummarizerConfig is configuration for Summarize.
type SummarizerConfig interface {
	ObjectStore() store.Store
}

// Summarizer summarizes applications for a namespace. Applications are a group of objects
// labeled with matching application labels. Application labels are:
//   * app.kubernetes.io/name
//   * app.kubernetes.io/instance
//   * app.kubernetes.io/version
type Summarizer interface {
	// Summarize generates a table summary.
	Summarize(ctx context.Context, namespace string, config SummarizerConfig) (*component.Table, error)
}

type summarizer struct{}

// Summarize converts applications in namespace to a table.
func (s *summarizer) Summarize(ctx context.Context, namespace string, config SummarizerConfig) (*component.Table, error) {
	if config == nil {
		return nil, errors.Errorf("config is nil")
	}

	applications, err := listApplications(ctx, config.ObjectStore(), namespace)
	if err != nil {
		return nil, err
	}

	table := component.NewTable("Applications", "applications", applicationListColumns)
	for _, d := range applications {
		table.Add(component.TableRow{
			"Name":     component.NewLink("", d.Name, d.Path("applications", namespace)),
			"Instance": component.NewText(d.Instance),
			"Version":  component.NewText(d.Version),
			"State":    component.NewText("state"),
			"Pods":     component.NewText(fmt.Sprintf("%d", d.PodCount)),
		})
	}

	return table, nil
}


text:
class CFX_DIBitmap;
class CFX_SubstFont;
class CPDF_CIDFont;
class CPDF_Document;
class CPDF_Object;
class CPDF_TrueTypeFont;
class CPDF_Type1Font;
class CPDF_Type3Char;
class CPDF_Type3Font;
class CPDF_ToUnicodeMap;

class CPDF_Font : public Retainable, public Observable {
 public:
  // Callback mechanism for Type3 fonts to get pixels from forms.
  class FormIface {
   public:
    virtual ~FormIface() {}

    virtual void ParseContentForType3Char(CPDF_Type3Char* pChar) = 0;
    virtual bool HasPageObjects() const = 0;
    virtual CFX_FloatRect CalcBoundingBox() const = 0;
    virtual Optional<std::pair<RetainPtr<CFX_DIBitmap>, CFX_Matrix>>
    GetBitmapAndMatrixFromSoleImageOfForm() const = 0;
  };

  // Callback mechanism for Type3 fonts to get new forms from upper layers.
  class FormFactoryIface {
   public:
    virtual ~FormFactoryIface() {}

    virtual std::unique_ptr<FormIface> CreateForm(
        CPDF_Document* pDocument,
        CPDF_Dictionary* pPageResources,
        CPDF_Stream* pFormStream) = 0;
  };

  static constexpr uint32_t kInvalidCharCode = static_cast<uint32_t>(-1);

  // |pFactory| only required for Type3 fonts.
  static RetainPtr<CPDF_Font> Create(CPDF_Document* pDoc,
                                     CPDF_Dictionary* pFontDict,
                                     FormFactoryIface* pFactory);
  static RetainPtr<CPDF_Font> GetStockFont(CPDF_Document* pDoc,
                                           ByteStringView fontname);

  ~CPDF_Font() override;

  virtual bool IsType1Font() const;
  virtual bool IsTrueTypeFont() const;
  virtual bool IsType3Font() const;
  virtual bool IsCIDFont() const;
  virtual const CPDF_Type1Font* AsType1Font() const;
  virtual CPDF_Type1Font* AsType1Font();
  virtual const CPDF_TrueTypeFont* AsTrueTypeFont() const;
  virtual CPDF_TrueTypeFont* AsTrueTypeFont();
  virtual const CPDF_Type3Font* AsType3Font() const;
  virtual CPDF_Type3Font* AsType3Font();
  virtual const CPDF_CIDFont* AsCIDFont() const;
  virtual CPDF_CIDFont* AsCIDFont();

  virtual void WillBeDestroyed();
  virtual bool IsVertWriting() const;
  virtual bool IsUnicodeCompatible() const;
  virtual uint32_t GetNextChar(ByteStringView pString, size_t* pOffset) const;
  virtual size_t CountChar(ByteStringView pString) const;
  virtual int AppendChar(char* buf, uint32_t charcode) const;
  virtual int GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) = 0;
#if defined(OS_MACOSX)
  virtual int GlyphFromCharCodeExt(uint32_t charcode);
#endif
  virtual WideString UnicodeFromCharCode(uint32_t charcode) const;
  virtual uint32_t CharCodeFromUnicode(wchar_t Unicode) const;
  virtual bool HasFontWidths() const;

  ByteString GetBaseFontName() const { return m_BaseFontName; }
  CFX_SubstFont* GetSubstFont() const { return m_Font.GetSubstFont(); }
  bool IsEmbedded() const { return IsType3Font() || m_pFontFile != nullptr; }
  CPDF_Dictionary* GetFontDict() const { return m_pFontDict.Get(); }
  void ClearFontDict() { m_pFontDict = nullptr; }
  bool IsStandardFont() const;
  bool HasFace() const { return !!m_Font.GetFaceRec(); }
  void AppendChar(ByteString* str, uint32_t charcode) const;

  const FX_RECT& GetFontBBox() const { return m_FontBBox; }
  int GetTypeAscent() const { return m_Ascent; }
  int GetTypeDescent() const { return m_Descent; }
  uint32_t GetStringWidth(ByteStringView pString);
  uint32_t FallbackFontFromCharcode(uint32_t charcode);
  int FallbackGlyphFromCharcode(int fallbackFont, uint32_t charcode);
  int GetFontFlags() const { return m_Flags; }
  int GetFontWeight() const;

  virtual uint32_t GetCharWidthF(uint32_t charcode) = 0;
  virtual FX_RECT GetCharBBox(uint32_t charcode) = 0;

  // Can return nullptr for stock Type1 fonts. Always returns non-null for other
  // font types.
  CPDF_Document* GetDocument() const { return m_pDocument.Get(); }

  CFX_Font* GetFont() { return &m_Font; }
  const CFX_Font* GetFont() const { return &m_Font; }

  CFX_Font* GetFontFallback(int position);

 protected:
  CPDF_Font(CPDF_Document* pDocument, CPDF_Dictionary* pFontDict);

  static int TT2PDF(int m, FXFT_FaceRec* face);
  static bool FT_UseTTCharmap(FXFT_FaceRec* face,
                              int platform_id,
                              int encoding_id);
  static const char* GetAdobeCharName(int iBaseEncoding,
                                      const std::vector<ByteString>& charnames,
                                      uint32_t charcode);

  virtual bool Load() = 0;

  void LoadUnicodeMap() const;  // logically const only.
  void LoadFontDescriptor(const CPDF_Dictionary* pFontDesc);
  void CheckFontMetrics();

  UnownedPtr<CPDF_Document> const m_pDocument;
  CFX_Font m_Font;
  std::vector<std::unique_ptr<CFX_Font>> m_FontFallbacks;
  RetainPtr<CPDF_StreamAcc> m_pFontFile;
  RetainPtr<CPDF_Dictionary> m_pFontDict;
  ByteString m_BaseFontName;
  mutable std::unique_ptr<CPDF_ToUnicodeMap> m_pToUnicodeMap;
  mutable bool m_bToUnicodeLoaded = false;
  int m_Flags = 0;
  int m_StemV = 0;
  int m_Ascent = 0;
  int m_Descent = 0;
  int m_ItalicAngle = 0;
  FX_RECT m_FontBBox;
};

#endif  // CORE_FPDFAPI_FONT_CPDF_FONT_H_


text:
/* generic commerce context menu
Designed to be attached to a Rendition.UI.Grid's contextMenuOptions argument,
automaticlly searches the grid and provides common functions for grid records.

Contains most multi order / multi user/ multi item functions
and other critical single item,order,user function as well.
*/

/**
* Status chaning dialog.
* @constructor
* @name Rendition.Commerce.ChangeStatus
*/
Rendition.Commerce.ChangeStatus = function (args) {
	var instance = {}
	if (args === undefined) { return }
	var i = document.createElement('select');
	var buttonOk = document.createElement('button');
	var buttonCancel = document.createElement('button');
	var rteBox = document.createElement('div');
	rteBox.style.height = '175px';
	buttonOk.innerHTML = 'Ok';
	buttonOk.style.margin = '4px';
	buttonOk.style.cssFloat = 'right';
	buttonCancel.innerHTML = 'Cancel';
	buttonCancel.style.margin = '4px';
	buttonCancel.style.cssFloat = 'right';
	instance.flags = Rendition.Commerce.flagTypes;
	var l = instance.flags.length;
	var msg = '';
	if (instance.closed) {
		var d = function () {
			return [[0, 'Comment']]
		}
	} else {
		var d = function (line, shipment, order, pLine, pShipment, pOrder) {
			var options = [];
			for (var x = 0; l > x; x++) {
				if (
			(instance.flags[x].orderFlag === order && order === true) ||
			(instance.flags[x].shipmentFlag === shipment && shipment === true) ||
			(instance.flags[x].lineFlag === line && line === true) ||
			(instance.flags[x].purchaseOrderFlag === pOrder && pOrder === true) ||
			(instance.flags[x].purchaseShipmentFlag === pShipment && pShipment) === true ||
			(instance.flags[x].purchaseLineFlag === pLine && pLine) === true
		) {
					options.push([instance.flags[x].id, instance.flags[x].Name]);
				}
			}
			return options;
		}
	}
	if (args.accountType === 0 || args.accountType === undefined) {
		if (args.callerType === 'line') {
			Rendition.UI.fillSelect(i, d(true, false, false, false, false, false), 0, 1, args.flagId);
			msg = ' selected lines(s)';
		} else if (args.callerType === 'shipment') {
			Rendition.UI.fillSelect(i, d(false, true, false, false, false, false), 0, 1, args.flagId);
			msg = ' selected shipment(s)';
		} else if (args.callerType === 'order') {
			Rendition.UI.fillSelect(i, d(false, false, true, false, false, false), 0, 1, args.flagId);
			msg = ' selected order(s)';
		} else {
			return;
		}
	} else if (args.accountType === 1) {
		if (args.callerType === 'line') {
			Rendition.UI.fillSelect(i, d(false, false, false, true, false, false), 0, 1, args.flagId);
			msg = ' selected lines(s)';
		} else if (args.callerType === 'shipment') {
			Rendition.UI.fillSelect(i, d(false, false, false, false, true, false), 0, 1, args.flagId);
			msg = ' selected shipment(s)';
		} else if (args.callerType === 'order') {
			Rendition.UI.fillSelect(i, d(false, false, false, false, false, true), 0, 1, args.flagId);
			msg = ' selected order(s)';
		} else {
			return;
		}
	}
	instance.changeStatusDialog = Rendition.UI.dialogWindow({
		rect: { x: (document.documentElement.clientWidth / 2) - (520 / 2),
			y: 30, h: 372, w: 520
		},
		title: 'Change Status',
		modal: true
	});
	var c = instance.changeStatusDialog.content;
	var g = Rendition.UI.GroupBox({
		title: 'Change Status of ' + msg,
		childNodes: [Rendition.UI.txt('New Status'), i],
		alwaysExpanded: true
	});
	var h = Rendition.UI.GroupBox({
		title: 'Comments',
		childNodes: [rteBox],
		alwaysExpanded: true
	});
	g.appendTo(c);
	h.appendTo(c);
	c.appendChild(buttonOk);
	c.appendChild(buttonCancel);
	var rte = Rendition.UI.RichTextEditor({
		parentNode: rteBox
	});
	rte.resize();
	buttonCancel.onclick = function () {
		instance.changeStatusDialog.close();
		return;
	}
	buttonOk.onclick = function () {
		this.disabled = true;
		var comments = rte.value();
		var url = Rendition.UI.responderKeyName + '1=' + JSON.stringify([
			"AddFlags",
			[
				String(i.value),
				String(args.callerType),
				args.objectIds,
				String(comments)
			]
		]).toURI();
		instance.statusUpdateDialog = Rendition.UI.UpdateDialog({
			title: 'Updating Status',
			subTitle: 'Updating Status',
			message: 'Please wait, updating one or more statuses.'
		});
		instance.reqEval = Rendition.UI.Ajax(Rendition.UI.clientServerSyncURI + url, function (e) {
			instance.changeStatusDialog.close();
			instance.statusUpdateDialog.close();
			var a = JSON.parse(e.responseText);
			if (a.method1.error !== undefined) {
				alert(a.method1.description);
				return;
			}
			var errors = [];
			var a = a.method1.AddFlags;
			for (var x = 0; a.length > x; x++) {
				if (a[x].error != 0) {
					errors.push("Error " + a[x].error + ":" + a[x].description);
				}
			}
			if (errors.length === 0 && (args.quiet === false || args.quiet === undefined)) {
				var info = Rendition.UI.Info({
					timeout: 5000,
					position: { x: 30, y: 30 },
					title: 'Flag(s) added',
					message: ''
				});
			} else {
				Rendition.UI.ConfirmErrors(errors.join('<br>'), 'Error changing status(es)');
			}
			if (args.callbackProcedure) {
				args.callbackProcedure.apply(this, [a]);
			}
		}, instance, false);
		return;
	}
}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Sydowia 20(1-6): 170 (1968)

#### Original name
Phyllosticta salviae Sandu & Mítítíuc

### Remarks
null


text:
<?php
require_once(dirname(__FILE__) . '/../SpecHelper.php');

class DescribeIndexAction extends KolibriContext {
	public function itShouldReturnXsltResponse () {
		$this->get('/');
		$this->spec($this->response)->should->beAnInstanceOf('XsltResponse');
	}

	public function itShouldHaveModelSetWhenInSession () {
		$item = Models::getModel(new Item());
		$this->get('/', array(), array('model' => $item));
		$this->spec($this->action->model)->should->beAnInstanceOf('ModelProxy');
	}
}
?>