text:
package etw

import (
	"sync"
)

// Because the provider callback function needs to be able to access the
// provider data when it is invoked by ETW, we need to keep provider data stored
// in a global map based on an index. The index is passed as the callback
// context to ETW.
type providerMap struct {
	m    map[uint]*Provider
	i    uint
	lock sync.Mutex
	once sync.Once
}

var providers = providerMap{
	m: make(map[uint]*Provider),
}

func (p *providerMap) newProvider() *Provider {
	p.lock.Lock()
	defer p.lock.Unlock()

	i := p.i
	p.i++

	provider := &Provider{
		index: i,
	}

	p.m[i] = provider
	return provider
}

func (p *providerMap) removeProvider(provider *Provider) {
	p.lock.Lock()
	defer p.lock.Unlock()

	delete(p.m, provider.index)
}

func (p *providerMap) getProvider(index uint) *Provider {
	p.lock.Lock()
	defer p.lock.Unlock()

	return p.m[index]
}

var providerCallbackOnce sync.Once
var globalProviderCallback uintptr

redpajama_set_name: RedPajamaGithub


text:
package com.appdynamics.extensions.process.processdata;

public class ProcessData {
	public String name;
	//public int numOfInstances;
	public float memPercent;
	public float CPUPercent;

	public ProcessData(String name, float CPUPercent, float memPercent){
		this.name = name;
		//this.numOfInstances = 1;
		this.memPercent = memPercent;
		this.CPUPercent = CPUPercent;
	}
}


text:
/*
 * buffer_node.h: VLIB buffer handling node helper macros/inlines
 *
 * Copyright (c) 2008 Eliot Dresselhaus
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#ifndef included_vlib_buffer_node_h
#define included_vlib_buffer_node_h

/** \file
    vlib buffer/node functions
*/

/** \brief Finish enqueueing two buffers forward in the graph.
 Standard dual loop boilerplate element. This is a MACRO,
 with MULTIPLE SIDE EFFECTS. In the ideal case,
 next_index == next0 == next1,
 which means that the speculative enqueue at the top of the dual loop
 has correctly dealt with both packets. In that case, the macro does
 nothing at all.

 @param vm vlib_main_t pointer, varies by thread
 @param node current node vlib_node_runtime_t pointer
 @param next_index speculated next index used for both packets
 @param to_next speculated vector pointer used for both packets
 @param n_left_to_next number of slots left in speculated vector
 @param bi0 first buffer index
 @param bi1 second buffer index
 @param next0 actual next index to be used for the first packet
 @param next1 actual next index to be used for the second packet

 @return @c next_index -- speculative next index to be used for future packets
 @return @c to_next -- speculative frame to be used for future packets
 @return @c n_left_to_next -- number of slots left in speculative frame
*/

#define vlib_validate_buffer_enqueue_x2(vm,node,next_index,to_next,n_left_to_next,bi0,bi1,next0,next1) \
do {									\
  int enqueue_code = (next0 != next_index) + 2*(next1 != next_index);	\
									\
  if (PREDICT_FALSE (enqueue_code != 0))				\
    {									\
      switch (enqueue_code)						\
	{								\
	case 1:								\
	  /* A B A */							\
	  to_next[-2] = bi1;						\
	  to_next -= 1;							\
	  n_left_to_next += 1;						\
	  vlib_set_next_frame_buffer (vm, node, next0, bi0);		\
	  break;							\
									\
	case 2:								\
	  /* A A B */							\
	  to_next -= 1;							\
	  n_left_to_next += 1;						\
	  vlib_set_next_frame_buffer (vm, node, next1, bi1);		\
	  break;							\
									\
	case 3:								\
	  /* A B B or A B C */						\
	  to_next -= 2;							\
	  n_left_to_next += 2;						\
	  vlib_set_next_frame_buffer (vm, node, next0, bi0);		\
	  vlib_set_next_frame_buffer (vm, node, next1, bi1);		\
	  if (next0 == next1)						\
	    {								\
	      vlib_put_next_frame (vm, node, next_index,		\
				   n_left_to_next);			\
	      next_index = next1;					\
	      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); \
	    }								\
	}								\
    }									\
} while (0)

/** \brief Finish enqueueing four buffers forward in the graph.
 Standard quad loop boilerplate element. This is a MACRO,
 with MULTIPLE SIDE EFFECTS. In the ideal case,
 next_index == next0 == next1 == next2 == next3,
 which means that the speculative enqueue at the top of the quad loop
 has correctly dealt with all four packets. In that case, the macro does
 nothing at all.

 @param vm vlib_main_t pointer, varies by thread
 @param node current node vlib_node_runtime_t pointer
 @param next_index speculated next index used for both packets
 @param to_next speculated vector pointer used for both packets
 @param n_left_to_next number of slots left in speculated vector
 @param bi0 first buffer index
 @param bi1 second buffer index
 @param bi2 third buffer index
 @param bi3 fourth buffer index
 @param next0 actual next index to be used for the first packet
 @param next1 actual next index to be used for the second packet
 @param next2 actual next index to be used for the third packet
 @param next3 actual next index to be used for the fourth packet

 @return @c next_index -- speculative next index to be used for future packets
 @return @c to_next -- speculative frame to be used for future packets
 @return @c n_left_to_next -- number of slots left in speculative frame
*/

#define vlib_validate_buffer_enqueue_x4(vm,node,next_index,to_next,n_left_to_next,bi0,bi1,bi2,bi3,next0,next1,next2,next3) \
do {                                                                    \
  /* After the fact: check the [speculative] enqueue to "next" */       \
  u32 fix_speculation = (next_index ^ next0) | (next_index ^ next1)     \
    | (next_index ^ next2) | (next_index ^ next3);                      \
  if (PREDICT_FALSE(fix_speculation))                                   \
    {                                                                   \
      /* rewind... */                                                   \
      to_next -= 4;                                                     \
      n_left_to_next += 4;                                              \
                                                                        \
      /* If bi0 belongs to "next", send it there */                     \
      if (next_index == next0)                                          \
        {                                                               \
          to_next[0] = bi0;                                             \
          to_next++;                                                    \
          n_left_to_next --;                                            \
        }                                                               \
      else              /* send it where it needs to go */              \
        vlib_set_next_frame_buffer (vm, node, next0, bi0);              \
                                                                        \
      if (next_index == next1)                                          \
        {                                                               \
          to_next[0] = bi1;                                             \
          to_next++;                                                    \
          n_left_to_next --;                                            \
        }                                                               \
      else                                                              \
        vlib_set_next_frame_buffer (vm, node, next1, bi1);              \
                                                                        \
      if (next_index == next2)                                          \
        {                                                               \
          to_next[0] = bi2;                                             \
          to_next++;                                                    \
          n_left_to_next --;                                            \
        }                                                               \
      else                                                              \
        vlib_set_next_frame_buffer (vm, node, next2, bi2);              \
                                                                        \
      if (next_index == next3)                                          \
        {                                                               \
          to_next[0] = bi3;                                             \
          to_next++;                                                    \
          n_left_to_next --;                                            \
        }                                                               \
      else                                                              \
        {                                                               \
          vlib_set_next_frame_buffer (vm, node, next3, bi3);            \
                                                                        \
          /* Change speculation: last 2 packets went to the same node*/ \
          if (next2 == next3)                                           \
            {                                                           \
              vlib_put_next_frame (vm, node, next_index, n_left_to_next); \
              next_index = next3;                                       \
              vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); \
            }                                                           \
	}                                                               \
    }                                                                   \
 } while(0);

/** \brief Finish enqueueing one buffer forward in the graph.
 Standard single loop boilerplate element. This is a MACRO,
 with MULTIPLE SIDE EFFECTS. In the ideal case,
 next_index == next0,
 which means that the speculative enqueue at the top of the single loop
 has correctly dealt with the packet in hand. In that case, the macro does
 nothing at all.

 @param vm vlib_main_t pointer, varies by thread
 @param node current node vlib_node_runtime_t pointer
 @param next_index speculated next index used for both packets
 @param to_next speculated vector pointer used for both packets
 @param n_left_to_next number of slots left in speculated vector
 @param bi0 first buffer index
 @param next0 actual next index to be used for the first packet

 @return @c next_index -- speculative next index to be used for future packets
 @return @c to_next -- speculative frame to be used for future packets
 @return @c n_left_to_next -- number of slots left in speculative frame
*/
#define vlib_validate_buffer_enqueue_x1(vm,node,next_index,to_next,n_left_to_next,bi0,next0) \
do {									\
  if (PREDICT_FALSE (next0 != next_index))				\
    {									\
      vlib_put_next_frame (vm, node, next_index, n_left_to_next + 1);	\
      next_index = next0;						\
      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); \
									\
      to_next[0] = bi0;							\
      to_next += 1;							\
      n_left_to_next -= 1;						\
    }									\
} while (0)

always_inline uword
generic_buffer_node_inline (vlib_main_t * vm,
			    vlib_node_runtime_t * node,
			    vlib_frame_t * frame,
			    uword sizeof_trace,
			    void *opaque1,
			    uword opaque2,
			    void (*two_buffers) (vlib_main_t * vm,
						 void *opaque1,
						 uword opaque2,
						 vlib_buffer_t * b0,
						 vlib_buffer_t * b1,
						 u32 * next0, u32 * next1),
			    void (*one_buffer) (vlib_main_t * vm,
						void *opaque1, uword opaque2,
						vlib_buffer_t * b0,
						u32 * next0))
{
  u32 n_left_from, *from, *to_next;
  u32 next_index;

  from = vlib_frame_vector_args (frame);
  n_left_from = frame->n_vectors;
  next_index = node->cached_next_index;

  if (node->flags & VLIB_NODE_FLAG_TRACE)
    vlib_trace_frame_buffers_only (vm, node, from, frame->n_vectors,
				   /* stride */ 1, sizeof_trace);

  while (n_left_from > 0)
    {
      u32 n_left_to_next;

      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);

      while (n_left_from >= 4 && n_left_to_next >= 2)
	{
	  vlib_buffer_t *p0, *p1;
	  u32 pi0, next0;
	  u32 pi1, next1;

	  /* Prefetch next iteration. */
	  {
	    vlib_buffer_t *p2, *p3;

	    p2 = vlib_get_buffer (vm, from[2]);
	    p3 = vlib_get_buffer (vm, from[3]);

	    vlib_prefetch_buffer_header (p2, LOAD);
	    vlib_prefetch_buffer_header (p3, LOAD);

	    CLIB_PREFETCH (p2->data, 64, LOAD);
	    CLIB_PREFETCH (p3->data, 64, LOAD);
	  }

	  pi0 = to_next[0] = from[0];
	  pi1 = to_next[1] = from[1];
	  from += 2;
	  to_next += 2;
	  n_left_from -= 2;
	  n_left_to_next -= 2;

	  p0 = vlib_get_buffer (vm, pi0);
	  p1 = vlib_get_buffer (vm, pi1);

	  two_buffers (vm, opaque1, opaque2, p0, p1, &next0, &next1);

	  vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
					   to_next, n_left_to_next,
					   pi0, pi1, next0, next1);
	}

      while (n_left_from > 0 && n_left_to_next > 0)
	{
	  vlib_buffer_t *p0;
	  u32 pi0, next0;

	  pi0 = from[0];
	  to_next[0] = pi0;
	  from += 1;
	  to_next += 1;
	  n_left_from -= 1;
	  n_left_to_next -= 1;

	  p0 = vlib_get_buffer (vm, pi0);

	  one_buffer (vm, opaque1, opaque2, p0, &next0);

	  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
					   to_next, n_left_to_next,
					   pi0, next0);
	}

      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
    }

  return frame->n_vectors;
}

static_always_inline void
vlib_buffer_enqueue_to_next (vlib_main_t * vm, vlib_node_runtime_t * node,
			     u32 * buffers, u16 * nexts, uword count)
{
  u32 *to_next, n_left_to_next, max;
  u16 next_index;

  next_index = nexts[0];
  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
  max = clib_min (n_left_to_next, count);

  while (count)
    {
      u32 n_enqueued;
      if ((nexts[0] != next_index) || n_left_to_next == 0)
	{
	  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
	  next_index = nexts[0];
	  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
	  max = clib_min (n_left_to_next, count);
	}
#if defined(CLIB_HAVE_VEC512)
      u16x32 next32 = CLIB_MEM_OVERFLOW_LOAD (u16x32_load_unaligned, nexts);
      next32 = (next32 == u16x32_splat (next32[0]));
      u64 bitmap = u16x32_msb_mask (next32);
      n_enqueued = count_trailing_zeros (~bitmap);
#elif defined(CLIB_HAVE_VEC256)
      u16x16 next16 = CLIB_MEM_OVERFLOW_LOAD (u16x16_load_unaligned, nexts);
      next16 = (next16 == u16x16_splat (next16[0]));
      u64 bitmap = u8x32_msb_mask ((u8x32) next16);
      n_enqueued = count_trailing_zeros (~bitmap) / 2;
#elif defined(CLIB_HAVE_VEC128) && defined(CLIB_HAVE_VEC128_MSB_MASK)
      u16x8 next8 = CLIB_MEM_OVERFLOW_LOAD (u16x8_load_unaligned, nexts);
      next8 = (next8 == u16x8_splat (next8[0]));
      u64 bitmap = u8x16_msb_mask ((u8x16) next8);
      n_enqueued = count_trailing_zeros (~bitmap) / 2;
#else
      u16 x = 0;
      if (count + 3 < max)
	{
	  x |= next_index ^ nexts[1];
	  x |= next_index ^ nexts[2];
	  x |= next_index ^ nexts[3];
	  n_enqueued = (x == 0) ? 4 : 1;
	}
      else
	n_enqueued = 1;
#endif

      if (PREDICT_FALSE (n_enqueued > max))
	n_enqueued = max;

#ifdef CLIB_HAVE_VEC512
      if (n_enqueued >= 32)
	{
	  vlib_buffer_copy_indices (to_next, buffers, 32);
	  nexts += 32;
	  to_next += 32;
	  buffers += 32;
	  n_left_to_next -= 32;
	  count -= 32;
	  max -= 32;
	  continue;
	}
#endif

#ifdef CLIB_HAVE_VEC256
      if (n_enqueued >= 16)
	{
	  vlib_buffer_copy_indices (to_next, buffers, 16);
	  nexts += 16;
	  to_next += 16;
	  buffers += 16;
	  n_left_to_next -= 16;
	  count -= 16;
	  max -= 16;
	  continue;
	}
#endif

#ifdef CLIB_HAVE_VEC128
      if (n_enqueued >= 8)
	{
	  vlib_buffer_copy_indices (to_next, buffers, 8);
	  nexts += 8;
	  to_next += 8;
	  buffers += 8;
	  n_left_to_next -= 8;
	  count -= 8;
	  max -= 8;
	  continue;
	}
#endif

      if (n_enqueued >= 4)
	{
	  vlib_buffer_copy_indices (to_next, buffers, 4);
	  nexts += 4;
	  to_next += 4;
	  buffers += 4;
	  n_left_to_next -= 4;
	  count -= 4;
	  max -= 4;
	  continue;
	}

      /* copy */
      to_next[0] = buffers[0];

      /* next */
      nexts += 1;
      to_next += 1;
      buffers += 1;
      n_left_to_next -= 1;
      count -= 1;
      max -= 1;
    }
  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}

static_always_inline void
vlib_buffer_enqueue_to_single_next (vlib_main_t * vm,
				    vlib_node_runtime_t * node, u32 * buffers,
				    u16 next_index, u32 count)
{
  u32 *to_next, n_left_to_next, n_enq;

  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);

  if (PREDICT_TRUE (n_left_to_next >= count))
    {
      vlib_buffer_copy_indices (to_next, buffers, count);
      n_left_to_next -= count;
      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
      return;
    }

  n_enq = n_left_to_next;
next:
  vlib_buffer_copy_indices (to_next, buffers, n_enq);
  n_left_to_next -= n_enq;

  if (PREDICT_FALSE (count > n_enq))
    {
      count -= n_enq;
      buffers += n_enq;

      vlib_put_next_frame (vm, node, next_index, n_left_to_next);
      vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
      n_enq = clib_min (n_left_to_next, count);
      goto next;
    }
  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}

static_always_inline u32
vlib_buffer_enqueue_to_thread (vlib_main_t * vm, u32 frame_queue_index,
			       u32 * buffer_indices, u16 * thread_indices,
			       u32 n_packets, int drop_on_congestion)
{
  vlib_thread_main_t *tm = vlib_get_thread_main ();
  vlib_frame_queue_main_t *fqm;
  vlib_frame_queue_per_thread_data_t *ptd;
  u32 n_left = n_packets;
  u32 drop_list[VLIB_FRAME_SIZE], *dbi = drop_list, n_drop = 0;
  vlib_frame_queue_elt_t *hf = 0;
  u32 n_left_to_next_thread = 0, *to_next_thread = 0;
  u32 next_thread_index, current_thread_index = ~0;
  int i;

  fqm = vec_elt_at_index (tm->frame_queue_mains, frame_queue_index);
  ptd = vec_elt_at_index (fqm->per_thread_data, vm->thread_index);

  while (n_left)
    {
      next_thread_index = thread_indices[0];

      if (next_thread_index != current_thread_index)
	{
	  if (drop_on_congestion &&
	      is_vlib_frame_queue_congested
	      (frame_queue_index, next_thread_index, fqm->queue_hi_thresh,
	       ptd->congested_handoff_queue_by_thread_index))
	    {
	      dbi[0] = buffer_indices[0];
	      dbi++;
	      n_drop++;
	      goto next;
	    }

	  if (hf)
	    hf->n_vectors = VLIB_FRAME_SIZE - n_left_to_next_thread;

	  hf = vlib_get_worker_handoff_queue_elt (frame_queue_index,
						  next_thread_index,
						  ptd->handoff_queue_elt_by_thread_index);

	  n_left_to_next_thread = VLIB_FRAME_SIZE - hf->n_vectors;
	  to_next_thread = &hf->buffer_index[hf->n_vectors];
	  current_thread_index = next_thread_index;
	}

      to_next_thread[0] = buffer_indices[0];
      to_next_thread++;
      n_left_to_next_thread--;

      if (n_left_to_next_thread == 0)
	{
	  hf->n_vectors = VLIB_FRAME_SIZE;
	  vlib_put_frame_queue_elt (hf);
	  vlib_mains[current_thread_index]->check_frame_queues = 1;
	  current_thread_index = ~0;
	  ptd->handoff_queue_elt_by_thread_index[next_thread_index] = 0;
	  hf = 0;
	}

      /* next */
    next:
      thread_indices += 1;
      buffer_indices += 1;
      n_left -= 1;
    }

  if (hf)
    hf->n_vectors = VLIB_FRAME_SIZE - n_left_to_next_thread;

  /* Ship frames to the thread nodes */
  for (i = 0; i < vec_len (ptd->handoff_queue_elt_by_thread_index); i++)
    {
      if (ptd->handoff_queue_elt_by_thread_index[i])
	{
	  hf = ptd->handoff_queue_elt_by_thread_index[i];
	  /*
	   * It works better to let the handoff node
	   * rate-adapt, always ship the handoff queue element.
	   */
	  if (1 || hf->n_vectors == hf->last_n_vectors)
	    {
	      vlib_put_frame_queue_elt (hf);
	      vlib_mains[i]->check_frame_queues = 1;
	      ptd->handoff_queue_elt_by_thread_index[i] = 0;
	    }
	  else
	    hf->last_n_vectors = hf->n_vectors;
	}
      ptd->congested_handoff_queue_by_thread_index[i] =
	(vlib_frame_queue_t *) (~0);
    }

  if (drop_on_congestion && n_drop)
    vlib_buffer_free (vm, drop_list, n_drop);

  return n_packets - n_drop;
}

#endif /* included_vlib_buffer_node_h */

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */


text:
using System.Collections.Generic;
using System.Linq;
using Nwazet.Commerce.Services;
using Orchard.ContentManagement;
using Orchard.Environment.Extensions;

namespace Nwazet.Commerce.Models {
    [OrchardFeature("Nwazet.Shipping")]
    public class SizeBasedShippingMethodPart : ContentPart<SizeBasedShippingMethodPartRecord>, IShippingMethod {
        public string Name { get { return Record.Name; } set { Record.Name = value; } }
        public string ShippingCompany { get { return Record.ShippingCompany; } set { Record.ShippingCompany = value; } }
        public double Price { get { return Record.Price; } set { Record.Price = value; } }
        public string Size { get { return Record.Size; } set { Record.Size = value; } }
        public int Priority { get { return Record.Priority; } set { Record.Priority = value; } }
        public string IncludedShippingAreas { get { return Record.IncludedShippingAreas; } set { Record.IncludedShippingAreas = value; } }
        public string ExcludedShippingAreas { get { return Record.ExcludedShippingAreas; } set { Record.ExcludedShippingAreas = value; } }

        public double ComputePrice(IEnumerable<ShoppingCartQuantityProduct> productQuantities, IEnumerable<IShippingMethod> shippingMethods) {
            // Get all size-based shipping methods
            var sizePriorities = shippingMethods
                .Where(m => m.GetType() == typeof (SizeBasedShippingMethodPart))
                .Cast<SizeBasedShippingMethodPart>()
                .Where(m => !string.IsNullOrWhiteSpace(m.Size))
                .GroupBy(m => m.Size)
                .ToDictionary(g => g.Key, g => g.Min(m => m.Priority));
            var quantities = productQuantities.ToList();
            var fixedCost = quantities
                .Where(pq => pq.Product.ShippingCost != null && pq.Product.ShippingCost >= 0 && !pq.Product.IsDigital)
            // ReSharper disable PossibleInvalidOperationException
                .Sum(pq => pq.Quantity * (double)pq.Product.ShippingCost);
            // ReSharper restore PossibleInvalidOperationException
            var relevantQuantities = quantities
                .Where(pq => (pq.Product.ShippingCost == null || pq.Product.ShippingCost < 0) && !pq.Product.IsDigital)
                .ToList();
            // If all products have fixed shipping cost, just return that
            if (relevantQuantities.Count == 0) return fixedCost;
            // If this is the default size method and no product have a specific size constraint, apply
            if (string.IsNullOrWhiteSpace(Size) &&
                relevantQuantities.All(pq => string.IsNullOrWhiteSpace(pq.Product.Size))) return fixedCost + Price;
            // If all products have no specific size or there is a product with a size that has higher priority, pass
            if (relevantQuantities.Any(pq => !string.IsNullOrWhiteSpace(pq.Product.Size) &&
                pq.Product.Size != Size &&
                sizePriorities.ContainsKey(pq.Product.Size) &&
                sizePriorities[pq.Product.Size] > Priority)) return -1;
            // If no product has the size required by this method, pass
            if (relevantQuantities.All(pq => pq.Product.Size != Size)) return -1;
            return fixedCost + Price;
        }
    }
}


text:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                      http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.neo4j.WL</groupId>
  <artifactId>WL</artifactId>
  <version>1.0.0</version>

  <packaging>jar</packaging>
  <name>Neo4j Procedure Template</name>
  <description>A template project for building a Neo4j Procedure</description>

  <properties>
    <neo4j.version>3.2.2</neo4j.version>
  </properties>

  <dependencies>
    <dependency>
      <!-- This gives us the Procedure API our runtime code uses.
           We have a `provided` scope on it, because when this is
           deployed in a Neo4j Instance, the API will be provided
           by Neo4j. If you add non-Neo4j dependencies to this
           project, their scope should normally be `compile` -->
      <groupId>org.neo4j</groupId>
      <artifactId>neo4j</artifactId>
      <version>${neo4j.version}</version>
      <scope>provided</scope>
    </dependency>

    <!-- the below removed for nwo as it seems to report errors no longer valid in 3.2>
    <dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>procedure-compiler</artifactId>
    <version>${neo4j.version}</version>
    <scope>compile</scope>
    <optional>true</optional>
   </dependency>
-->

    <!-- Test Dependencies -->
    <dependency>
      <!-- This is used for a utility that lets us start Neo4j with
           a specific Procedure, which is nice for writing tests. -->
      <groupId>org.neo4j.test</groupId>
      <artifactId>neo4j-harness</artifactId>
      <version>${neo4j.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <!-- Used to send cypher statements to our procedure. -->
      <groupId>org.neo4j.driver</groupId>
      <artifactId>neo4j-java-driver</artifactId>
      <version>1.2.0</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <!-- Neo4j Procedures require Java 8 -->
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <!-- This generates a jar-file with our procedure code,
             plus any dependencies marked as `compile` scope.
             This should then be deployed in the `plugins` directory
             of each Neo4j instance in your deployment.
             After a restart, the procedure is available for calling. -->
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.4.3</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>


text:
from .extdocker import *
from .helpers import *


text: <b>This is a Sample Page</b>


text:
import re

from keystonemiddleware import auth_token

from magnum.common import exception
from magnum.common import utils
from magnum.openstack.common._i18n import _
from magnum.openstack.common import log

LOG = log.getLogger(__name__)

class AuthTokenMiddleware(auth_token.AuthProtocol):
    """A wrapper on Keystone auth_token middleware.

    Does not perform verification of authentication tokens
    for public routes in the API.

    """
    def __init__(self, app, conf, public_api_routes=[]):
        route_pattern_tpl = '%s(\.json|\.xml)?$'

        try:
            self.public_api_routes = [re.compile(route_pattern_tpl % route_tpl)
                                      for route_tpl in public_api_routes]
        except re.error as e:
            msg = _('Cannot compile public API routes: %s') % e

            LOG.error(msg)
            raise exception.ConfigInvalid(error_msg=msg)

        super(AuthTokenMiddleware, self).__init__(app, conf)

    def __call__(self, env, start_response):
        path = utils.safe_rstrip(env.get('PATH_INFO'), '/')

        # The information whether the API call is being performed against the
        # public API is required for some other components. Saving it to the
        # WSGI environment is reasonable thereby.
        env['is_public_api'] = any(map(lambda pattern: re.match(pattern, path),
                                       self.public_api_routes))

        if env['is_public_api']:
            return self._app(env, start_response)

        return super(AuthTokenMiddleware, self).__call__(env, start_response)


text:
namespace NoiseLab.PolyGen.Core.FluentConfiguration.Relationships
{
    public class ToRelationshipEntityBuilder : RelationshipEntityBuilderBase
    {
        public ReferenceBuilder Reference(
            string foreignKeyPropertyName,
            string primaryKeyPropertyName)
        {
            return RelationshipBuilder.Reference(foreignKeyPropertyName, primaryKeyPropertyName);
        }

        internal ToRelationshipEntityBuilder(
            RelationshipBuilder relationshipBuilder,
            string entityNamespace,
            string entityName)
            : base(relationshipBuilder, entityNamespace, entityName)
        {
        }
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="tab_1">首页</string>
    <string name="tab_2">下单</string>
    <string name="app_name">供鲜生重构</string>
    <string name="tab_3">库存</string>
    <string name="tab_4">消息</string>
    <string name="tab_5">更多</string>
    <string name="action_settings">设置</string>
    <string name="dialog_action_ok">OK</string>
    <string name="dialog_action_cancel">Cancel</string>
    <string name="dialog_error_title">Sorry</string>

    <string name="empty_ribots">There aren\'t any ribots</string>
    <string name="error_loading_ribots">There was a problem loading the ribots</string>
    <string name="fragment_home_page">首页</string>
    <string name="fragment_palce_order">下单</string>
    <string name="fragment_stock">库存</string>
    <string name="fragment_message">消息</string>
    <string name="fragment_more">更多</string>
    <string name="toast_order_empty">订单列表为空!</string>
    <string name="toast_return_order_empty">退货订单列表为空!</string>
    <string name="toast_get_order_list_error">获取订单列表出错!</string>
    <string name="toast_get_return_order_list_error">获取退货订单列表出错!</string>
    <string name="tag_meal_side">餐户端</string>
    <string name="toast_get_banner_error">获取广告轮播图出错!</string>
    <string name="toast_get_dashboard_error">获取仪表板数据出错!</string>
    <string name="toast_refreshing">正在刷新</string>
    <string name="toast_logout_fail">登出失败</string>
    <string name="last_week_purchase_amount">上周采购量(件)</string>
    <string name="advent_food_amount">临期食材(件)</string>
    <string name="expire_food_amount">到期食材(件)</string>
    <string name="toast_estimated_turnover_empty">你还没填写预估营业额!</string>
    <string name="toast_safety_factor_empty">你还没选择安全系数!</string>
    <string name="color_titile_safe_dialog">#F3F9EF</string>
    <string name="color_cancle_text_safe_dialog">#2E2E2E</string>
    <string name="color_submit_text_safe_dialog">#2E2E2E</string>
    <string name="dialog_title_safe_factor">选择安全系数</string>
    <string name="dialog_title_tip">提示</string>
    <string name="dialog_message_cancel_order">确认取消订单?</string>
    <string name="dialog_message_tallying">正在点货</string>
    <string name="dialog_btn_i_know">我知道了</string>
    <string name="dialog_message_the_goods_have_been_ordered">您已经点过货了,应由其他人完成收货</string>
    <string name="toast_finish_return_order_success">退货成功</string>
    <string name="toast_cancel_order_success">取消订单成功</string>

    <!-- TODO: Remove or change this placeholder text -->
    <string name="hello_blank_fragment">Hello blank fragment</string>
    <string name="no_exist_order">没有对应订单</string>
    <string name="toast_product_without_batch">该产品无批次追踪</string>
    <string name="order_submited">订单已提交</string>
    <string name="tag_order_num">订单号:</string>
    <string name="order_confirmed">订单已确认</string>
    <string name="select_product_for_you">正在为您挑拣商品</string>
    <string name="order_deliveryed">订单已发货</string>
    <string name="expect_reach_time">预计发达时间:</string>
    <string name="order_take_over">订单已收货</string>
    <string name="returned">已退货</string>
    <string name="order_returned">订单已退货</string>
    <string name="tag_product_money">商品金额</string>
    <string name="order_rated">订单已评价</string>
    <string name="tag_thanks_for_your_rate_life_happy">感谢您的评价,供鲜生祝您生活愉快!</string>
    <string name="order_cancel">订单已取消</string>
    <string name="order_success">您的订单已取消成功</string>
    <string name="first_payment_after_delivery">先付款后收货</string>
    <string name="single_settlement">单次结算</string>
    <string name="title_frament_stock">库存</string>
    <string name="title_activity_product_list">价目表</string>
    <string name="title_order_detail">订单详情</string>
    <string name="tag_return_order_num">退货单号:</string>
    <string name="color_return_order_num">#2F96D8</string>
    <string name="tip_order_done_any_question_please_contact_service">配送已完成,如有问题请联系客服</string>
    <string name="no_payment_certificate">未有支付凭证</string>
    <string name="upload_certificate">上传凭证</string>
    <string name="already_upload_payment_certificate">已上传支付凭证</string>
    <string name="check_certificate">查看凭证</string>
    <string name="category_all">全部</string>
    <string name="piece">件</string>
    <string name="textColorThird">#999999</string>
    <string name="modify">修改</string>
    <string name="apply_for_after_sale">申请售后</string>
    <string name="one_click_place_order">一键下单</string>
    <string name="titile_intelligent_place_order">智能下单</string>
    <string name="titile_eidt">编辑</string>
    <string name="title_edit">编辑</string>
    <string name="titile_finish">完成</string>
    <string name="color_btn_delete_ok">#FF3B30</string>
    <string name="color_btn_delete_no_ok">#E3E3E3</string>
    <string name="title_modify_order_success">修改成功</string>
    <string name="title_place_order_success">下单成功</string>
    <string name="toast_no_procument_permission">没有自采权限</string>
    <string name="toast_no_transfer_permission">没有门店调拨权限</string>
    <string name="toast_cancel_order_fail">取消订单失败</string>
    <string name="title_order_list">订单列表</string>
    <string name="fragment_title_order_all">全部</string>
    <string name="fragment_title_order_this_week">本周</string>
    <string name="fragment_title_order_last_week">上周</string>
    <string name="fragment_title_order_earlier">更早</string>
    <string name="system_upgrading_toast">系统更新中,%1$s后才能使用哦!</string>
    <string name="title_person_info">个人信息</string>
    <string name="menu_logout">退出登录</string>
    <string name="title_return_record">退货记录</string>
    <string name="title_statement_account">对账单</string>
    <string name="toast_no_data">没有数据</string>
    <string name="toast_cancel_make_inventory_success">取消盘点成功!</string>
    <string name="toast_get_make_inventory_list_fail">获取盘点列表失败</string>
    <string name="title_make_inventory">盘点记录</string>
    <string name="toast_session_expired">登录失效</string>

</resources>


text:
'use strict';

const lighthouse = require('../lighthouse-core/index.js');
const RawProtocol = require('../lighthouse-core/gather/connections/raw.js');
const log = require('lighthouse-logger');
const {registerLocaleData, lookupLocale} = require('../lighthouse-core/lib/i18n/i18n.js');
const desktopDense4G = require('../lighthouse-core/config/constants.js').throttling.desktopDense4G;

/** @typedef {import('../lighthouse-core/gather/connections/connection.js')} Connection */

/**
 * Returns a config, which runs only certain categories.
 * Varies the config to use based on device.
 * If `lighthouse-plugin-publisher-ads` is in the list of
 * `categoryIDs` the plugin will also be run.
 * Counterpart to the CDT code that sets flags.
 * @see https://cs.chromium.org/chromium/src/third_party/devtools-frontend/src/front_end/lighthouse/LighthouseController.js?type=cs&q=%22const+RuntimeSettings%22+f:lighthouse+-f:out&g=0&l=250
 * @param {Array<string>} categoryIDs
 * @param {string} device
 * @return {LH.Config.Json}
 */
function createConfig(categoryIDs, device) {
  /** @type {LH.SharedFlagsSettings} */
  const settings = {
    onlyCategories: categoryIDs,
  };
  if (device === 'desktop') {
    settings.throttling = desktopDense4G;
  }

  return {
    extends: 'lighthouse:default',
    plugins: ['lighthouse-plugin-publisher-ads'],
    settings,
  };
}

/**
 * @param {RawProtocol.Port} port
 * @returns {RawProtocol}
 */
function setUpWorkerConnection(port) {
  return new RawProtocol(port);
}

/** @param {(status: [string, string, string]) => void} listenCallback */
function listenForStatus(listenCallback) {
  log.events.addListener('status', listenCallback);
}

// For the bundle smoke test.
if (typeof module !== 'undefined' && module.exports) {
  // Ideally this could be exposed via browserify's `standalone`, but it doesn't
  // work for LH because of https://github.com/browserify/browserify/issues/968
  // Instead, since this file is only ever run in node for testing, expose a
  // bundle entry point as global.
  // @ts-ignore
  global.runBundledLighthouse = lighthouse;
}

// Expose only in DevTools' worker
// @ts-ignore
if (typeof self !== 'undefined') {
  // TODO: refactor and delete `global.isDevtools`.
  global.isDevtools = true;

  // @ts-ignore
  self.setUpWorkerConnection = setUpWorkerConnection;
  // @ts-ignore
  self.runLighthouse = lighthouse;
  // @ts-ignore
  self.createConfig = createConfig;
  // @ts-ignore
  self.listenForStatus = listenForStatus;
  // @ts-ignore
  self.registerLocaleData = registerLocaleData;
  // @ts-ignore
  self.lookupLocale = lookupLocale;
}


text:
package test.dataportal.functional;

/**
 * Unit test for login service at ciclope
 */
public class LoginTest extends AbstractFunctionalTest {

	private Services services;

	@Override
	protected void setUp() throws Exception {
		super.setUp();
		services = new Services();
	}

	public void testLoginFailed() throws Exception {
		assertFalse(services.login("wronguser", "wrongpass"));
	}

	public void testRegisterTwice() throws Exception {
		// Register foo
		String userName = "foo@foo.foo";
		assertTrue(services.register(userName, "testpass"));

		// Register foo again
		assertFalse(services.register(userName, "testpass"));

		// Activate
		assertTrue(services.activate(userName));

		// Register foo again after foo is activated
		assertFalse(services.register(userName, "testpass"));
	}

	public void testRegister() throws Exception {
		String userName = "foo@foo.foo";
		assertTrue(services.register(userName, "testpass"));
		assertTrue(services.activate(userName));
	}
}


text:
<ExtensionImage xmlns="http://schemas.microsoft.com/windowsazure">
<ProviderNameSpace>Microsoft.Loves.Linux</ProviderNameSpace>
<Type>SampleExtension</Type>
<Version>1.0.0.0</Version>
<Label>Microsoft loves Linux</Label>
<HostingResources>VmRole</HostingResources>
<MediaLink>Storage blob location of the Zip file</MediaLink>
<Description>Microsoft loves Linux</Description>
<IsInternalExtension>false</IsInternalExtension>
<Eula>https://github.com/Azure/azure-linux-extensions/blob/1.0/LICENSE-2_0.txt</Eula>
<PrivacyUri>https://github.com/Azure/azure-linux-extensions/blob/1.0/LICENSE-2_0.txt</PrivacyUri>
<HomepageUri>https://github.com/Azure/azure-linux-extensions</HomepageUri>
<IsJsonExtension>true</IsJsonExtension>
<SupportedOS>Linux</SupportedOS>
<CompanyName>Microsoft</CompanyName>
</ExtensionImage>


text:
require 'spec_helper'

describe CachedResource do

  def read_from_cache(key)
    Thing.send(:cache_read, key)
  end

  before(:each) do
    class Thing < ActiveResource::Base
      self.site = "http://api.thing.com"
      cached_resource
    end

    @thing = {:thing => {:id => 1, :name => "Ada"}}
    @other_thing = {:thing => {:id => 1, :name => "Ari"}}
    @thing2 = {:thing => {:id => 2, :name => "Joe"}}
    @other_thing2 = {:thing => {:id => 2, :name => "Jeb"}}
    @thing3 = {:thing => {:id => 3, :name => "Stu"}}
    @string_thing = {:thing => {:id => "fded", :name => "Lev"}}
    @other_string_thing = {:thing => {:id => "fded", :name => "Lon"}}
    @thing_json = @thing.to_json
    @other_thing_json = @other_thing.to_json
    @string_thing_json = @string_thing.to_json
    @other_string_thing_json = @other_string_thing.to_json
  end

  after(:each) do
    Thing.cached_resource.cache.clear
    Object.send(:remove_const, :Thing)
  end

  describe "when enabled" do
    before(:each) do
      # it's on by default, but lets call the method
      # to make sure it works
      Thing.cached_resource.cache.clear
      Thing.cached_resource.on!

      ActiveResource::HttpMock.reset!
      ActiveResource::HttpMock.respond_to do |mock|
        mock.get "/things/1.json", {}, @thing_json
        mock.get "/things/1.json?foo=bar", {}, @thing_json
        mock.get "/things/fded.json", {}, @string_thing_json
      end
    end

    it "should cache a response" do
      result = Thing.find(1)

      read_from_cache("thing/1").should == result
    end

    it "should cache a response for a string primary key" do
      result = Thing.find("fded")
      read_from_cache("thing/fded").should == result
    end

    it "should cache without whitespace in keys" do
      result = Thing.find(1, :from => 'path', :params => { :foo => 'bar' })
      read_from_cache('thing/1/{:from=>"path",:params=>{:foo=>"bar"}}').should == result
    end

    it "should empty the cache when clear_cache is called" do
      result = Thing.find(1)
      Thing.clear_cache
      read_from_cache("thing/1").should == nil
    end

    it "should cache a response with the same persistence" do
      result1 = Thing.find(1)
      result2 = Thing.find(1)
      result1.persisted?.should == result2.persisted?
    end

    it "should read a response when the request is made again" do
      # make a request
      Thing.find(1)
      # make the same request
      Thing.find(1)
      # only one request should have happened
      ActiveResource::HttpMock.requests.length.should == 1
    end

    it "should read a response when the request is made again for a string primary key" do
      # make a request
      Thing.find("fded")
      # make the same request
      Thing.find("fded")
      # only one request should have happened
      ActiveResource::HttpMock.requests.length.should == 1
    end

    it "should remake a request when reloaded" do
      # make a request
      Thing.find(1)
      # make the same request, but reload it
      Thing.find(1, :reload => true)
      # we should get two requests
      ActiveResource::HttpMock.requests.length.should == 2
    end

    it "should remake a request when reloaded for a string primary key" do
      # make a request
      Thing.find("fded")
      # make the same request, but reload it
      Thing.find("fded", :reload => true)
      # we should get two requests
      ActiveResource::HttpMock.requests.length.should == 2
    end

    it "should rewrite the cache when the request is reloaded" do
      # make a request
      Thing.find(1)
      # get the cached result of the request
      old_result = read_from_cache("thing/1")

      # change the response
      ActiveResource::HttpMock.reset!
      ActiveResource::HttpMock.respond_to do |mock|
        mock.get "/things/1.json", {}, @other_thing_json
      end

      Thing.find(1, :reload => true)
      new_result = read_from_cache("thing/1")
      # since active resources are equal if and only if they
      # are the same object or an instance of the same class,
      # not new?, and have the same id.
      new_result.name.should_not == old_result.name
    end

    it "should remake the request when the ttl expires" do
      # set cache time to live to 1 second
      Thing.cached_resource.ttl = 1
      # make a request
      Thing.find(1)
      # wait for the cache to expire
      sleep(1.5)
      # make the same request
      Thing.find(1)
      ActiveResource::HttpMock.requests.length.should == 2
    end

    it "should not return a frozen object on first request" do
      result1 = Thing.find(1)
      result1.should_not be_frozen
    end

    it "should not return frozen object on a subsequent request" do
      result1 = Thing.find(1)
      result2 = Thing.find(1)
      result2.should_not be_frozen
    end

    it "should not freeze first requested object on a subsequent request" do
      result1 = Thing.find(1)
      result2 = Thing.find(1)
      result1.should_not be_frozen
    end

    shared_examples "collection_return_type" do
      if ActiveResource::VERSION::MAJOR >= 4
        it "should return an ActiveResource::Collection" do
          cached = read_from_cache("thing/all")
          cached.should be_instance_of(ActiveResource::Collection)
        end

        it "should return an instance of the collection_parser" do
          Thing.cached_resource.cache.clear
          class CustomCollection < ActiveResource::Collection; end
          Thing.collection_parser = CustomCollection
          Thing.all
          cached = read_from_cache("thing/all")
          cached.should be_instance_of(CustomCollection)
        end
      else
        it "should return an Array" do
          cached = read_from_cache("thing/all")
          cached.should be_instance_of(Array)
        end
      end
    end

    shared_examples "collection_freezing" do
      it "should not return a frozen collection on first request" do
        Thing.cached_resource.cache.clear
        collection1 = Thing.all
        collection1.should_not be_frozen
      end

      it "should not return a frozen collection on a subsequent request" do
        Thing.cached_resource.cache.clear
        collection1 = Thing.all
        collection2 = Thing.all
        collection2.should_not be_frozen
      end

      it "should not freeze first requested collection on a subsequent request" do
        Thing.cached_resource.cache.clear
        result1 = Thing.all
        result2 = Thing.all
        result1.should_not be_frozen
      end

      it "should not return frozen members on first request" do
        Thing.cached_resource.cache.clear
        collection1 = Thing.all
        collection1.first.should_not be_frozen
      end

      it "should not return frozen members on a subsequent request" do
        Thing.cached_resource.cache.clear
        collection1 = Thing.all
        collection2 = Thing.all
        collection2.first.should_not be_frozen
      end

      it "should not freeze members on a subsequent request" do
        Thing.cached_resource.cache.clear
        collection1 = Thing.all
        member1 = Thing.find(1)
        collection1.first.should_not be_frozen
      end

    end

    shared_examples "collection_cache_clearing" do
      it "should empty the cache when clear_cache is called" do
        Thing.clear_cache
        read_from_cache("thing/all").should == nil
        read_from_cache("thing/1").should == nil
      end

    end

    describe "when collection synchronize is enabled" do
      before(:each) do
        Thing.cached_resource.cache.clear
        Thing.cached_resource.collection_synchronize = true

        ActiveResource::HttpMock.reset!
        ActiveResource::HttpMock.respond_to do |mock|
          mock.get "/things/1.json", {}, @thing_json
          mock.get "/things/fded.json", {}, @string_thing_json
          mock.get "/things.json", {}, [@thing[:thing], @string_thing[:thing]].to_json(:root => :thing)
        end

        # make a request for all things
        Thing.all
      end

      include_examples "collection_return_type"

      include_examples "collection_freezing"

      it "should write cache entries for its members" do
        result = Thing.find(1)
        string_result = Thing.find("fded")
        # only the all request should have been made
        ActiveResource::HttpMock.requests.length.should == 1
        # the result should be cached with the appropriate key
        read_from_cache("thing/1").should == result
        read_from_cache("thing/fded").should == string_result
      end

      include_examples "collection_cache_clearing"

      it "should rewrite cache entries for its members when reloaded" do
        # get the soon to be stale result so that we have a cache entry
        old_result = Thing.find(1)
        old_string_result = Thing.find("fded")
        # change the server
        ActiveResource::HttpMock.respond_to do |mock|
          mock.get "/things/1.json", {}, @other_thing_json
          mock.get "/things/fded.json", {}, @other_string_thing_json
          mock.get "/things.json", {}, [@other_thing[:thing], @other_string_thing[:thing]].to_json(:root => :thing)
        end
        # reload the collection
        Thing.all(:reload => true)
        # get the updated result, read from the cache
        result = Thing.find(1)
        read_from_cache("thing/all")[0].should == result
        read_from_cache("thing/all")[0].name.should == result.name
        string_result = Thing.find("fded")
        read_from_cache("thing/all")[1].should == string_result
        read_from_cache("thing/all")[1].name.should == string_result.name
      end

      it "should update the collection when an individual request is reloaded" do
        # change the server
        ActiveResource::HttpMock.respond_to do |mock|
          mock.get "/things/1.json", {}, @other_thing_json
          mock.get "/things/fded.json", {}, @other_string_thing_json
          mock.get "/things.json", {}, [@other_thing[:thing], @other_string_thing[:thing]].to_json(:root => :thing)
        end

        # reload the individual
        result = Thing.find(1, :reload => true)
        read_from_cache("thing/all")[0].should == result
        read_from_cache("thing/all")[0].name.should == result.name
        string_result = Thing.find("fded", :reload => true)
        read_from_cache("thing/all")[1].should == string_result
        read_from_cache("thing/all")[1].name.should == string_result.name
      end

      it "should update both the collection and the member cache entries when a subset of the collection is retrieved" do
        # create cache entries for 1 and all
        old_individual = Thing.find(1)
        old_collection = Thing.all

        # change the server
        ActiveResource::HttpMock.respond_to do |mock|
          mock.get "/things.json?name=Ari", {}, [@other_thing[:thing]].to_json(:root => :thing)
          mock.get "/things.json?name=Lon", {}, [@other_string_thing[:thing]].to_json(:root => :thing)
        end

        # make a request for a subset of the "mother" collection
        result = Thing.find(:all, :params => {:name => "Ari"})
        # the collection should be updated to reflect the server change
        read_from_cache("thing/all")[0].should == result[0]
        read_from_cache("thing/all")[0].name.should == result[0].name
        # the individual should be updated to reflect the server change
        read_from_cache("thing/1").should == result[0]
        read_from_cache("thing/1").name.should == result[0].name

        # make a request for a subset of the "mother" collection
        result = Thing.find(:all, :params => {:name => "Lon"})
        # the collection should be updated to reflect the server change
        read_from_cache("thing/all")[1].should == result[0]
        read_from_cache("thing/all")[1].name.should == result[0].name
        # the individual should be updated to reflect the server change
        read_from_cache("thing/fded").should == result[0]
        read_from_cache("thing/fded").name.should == result[0].name
      end

      it "should maintain the order of the collection when updating it" do
        # change the server to return a longer collection
        ActiveResource::HttpMock.respond_to do |mock|
          mock.get "/things.json", {}, [@thing[:thing], @thing3[:thing], @thing2[:thing], @string_thing[:thing]].to_json(:root => :thing)
        end

        # create cache entry for the collection (we reload because in before block we make an all request)
        old_collection = Thing.all(:reload => true)

        # change the server's response for the thing with id 2
        ActiveResource::HttpMock.respond_to do |mock|
          mock.get "/things/2.json", {}, @other_thing2.to_json(:root => :thing)
          mock.get "/things/fded.json", {}, @other_string_thing.to_json(:root => :thing)
        end

        # get thing 2, thereby updating the collection
        result = Thing.find(2, :reload => true)
        # get the updated collection from the cache
        updated_collection = Thing.all
        # name should have changed to "Jeb"
        updated_collection[2].name.should == result.name
        # the updated collection should have the elements in the same order
        old_collection.each_with_index do |thing, i|
          updated_collection[i].id.should == thing.id
        end

        # get string thing, thereby updating the collection
        string_result = Thing.find("fded", :reload => true)
        # get the updated collection from the cache
        updated_collection = Thing.all
        # name should have changed to "Lon"
        updated_collection[3].name.should == string_result.name
        # the updated collection should have the elements in the same order
        old_collection.each_with_index do |thing, i|
          updated_collection[i].id.should == thing.id
        end
      end
    end

    describe "when collection synchronize is disabled" do
      before(:each) do
        Thing.cached_resource.cache.clear
        Thing.cached_resource.collection_synchronize = false

        ActiveResource::HttpMock.reset!
        ActiveResource::HttpMock.respond_to do |mock|
          mock.get "/things/1.json", {}, @thing_json
          mock.get "/things/fded.json", {}, @string_thing_json
          mock.get "/things.json", {}, [@thing[:thing], @string_thing[:thing]].to_json(:root => :thing)
        end

        # make a request for all things
        Thing.all
      end

      include_examples "collection_return_type"

      include_examples "collection_freezing"

      it "should not write cache entries for its members" do
        result = Thing.find(1)
        result = Thing.find("fded")
        # both the all in the before each and this request should have been made
        ActiveResource::HttpMock.requests.length.should == 3
      end

      include_examples "collection_cache_clearing"

      it "should not update the collection when an individual request is reloaded" do
        # change the server
        ActiveResource::HttpMock.respond_to do |mock|
          mock.get "/things/1.json", {}, @other_thing_json
          mock.get "/things/fded.json", {}, @other_string_thing_json
          mock.get "/things.json", {}, [@other_thing[:thing], @other_string_thing[:thing]].to_json(:root => :thing)
        end

        # reload the individual
        result = Thing.find(1, :reload => true)
        # the ids are the same, but the names should be different
        read_from_cache("thing/all")[0].name.should_not == result.name

        # reload the individual
        string_result = Thing.find("fded", :reload => true)
        # the ids are the same, but the names should be different
        read_from_cache("thing/all")[1].name.should_not == string_result.name
      end
    end

    describe "when ttl randomization is enabled" do
      before(:each) do
        @ttl = 1
        Thing.cached_resource.ttl = @ttl
        Thing.cached_resource.ttl_randomization = true
        Thing.cached_resource.send(:sample_range, 1..2, @ttl)
        # next ttl 1.72032449344216
      end

      it "should generate a random ttl" do
        Thing.cached_resource.cache.should_receive(:write)
        Thing.cached_resource.cache.stub(:write) do |key, value, options|
          # we know the ttl should not be the same as the set ttl
          options[:expires_in].should_not == @ttl
        end

        Thing.find(1)
      end

    end
  end

  describe "when disabled" do
    before(:each) do
      Thing.cached_resource.cache.clear
      Thing.cached_resource.off!

      ActiveResource::HttpMock.reset!
      ActiveResource::HttpMock.respond_to do |mock|
        mock.get "/things/1.json", {}, @thing_json
        mock.get "/things/fded.json", {}, @string_thing_json
      end
    end

    it "should cache a response" do
      result = Thing.find(1)
      read_from_cache("thing/1").should == result
    end

    it "should cache a response for a string primary key" do
      result = Thing.find("fded")
      read_from_cache("thing/fded").should == result
    end

    it "should always remake the request" do
      Thing.find(1)
      ActiveResource::HttpMock.requests.length.should == 1
      Thing.find(1)
      ActiveResource::HttpMock.requests.length.should == 2
    end

    it "should always remake the request for a string primary key" do
      Thing.find("fded")
      ActiveResource::HttpMock.requests.length.should == 1
      Thing.find("fded")
      ActiveResource::HttpMock.requests.length.should == 2
    end

    it "should rewrite the cache for each request" do
      Thing.find(1)
      old_result = read_from_cache("thing/1")

      # change the response
      ActiveResource::HttpMock.reset!
      ActiveResource::HttpMock.respond_to do |mock|
        mock.get "/things/1.json", {}, @other_thing_json
      end

      Thing.find(1)
      new_result = read_from_cache("thing/1")
      # since active resources are equal if and only if they
      # are the same object or an instance of the same class,
      # not new?, and have the same id.
      new_result.name.should_not == old_result.name
    end

    it "should rewrite the cache for each request for a string primary key" do
      Thing.find("fded")
      old_result = read_from_cache("thing/fded")

      # change the response
      ActiveResource::HttpMock.reset!
      ActiveResource::HttpMock.respond_to do |mock|
        mock.get "/things/fded.json", {}, @other_string_thing_json
      end

      Thing.find("fded")
      new_result = read_from_cache("thing/fded")
      # since active resources are equal if and only if they
      # are the same object or an instance of the same class,
      # not new?, and have the same id.
      new_result.name.should_not == old_result.name
    end
  end
end


text:
namespace agency
{

// this case handles executors which have .sync_execute()
__agency_exec_check_disable__
template<class E, class Function,
         __AGENCY_REQUIRES(detail::SynchronousExecutor<E>())
        >
__AGENCY_ANNOTATION
detail::result_of_t<detail::decay_t<Function>()>
  sync_execute(E& exec, Function&& f)
{
  return exec.sync_execute(std::forward<Function>(f));
}

// this case handles executors which are SimpleExecutors but do not have .sync_execute()
__agency_exec_check_disable__
template<class E, class Function,
         __AGENCY_REQUIRES(!detail::SynchronousExecutor<E>()),
         __AGENCY_REQUIRES(detail::SimpleExecutor<E>())
        >
__AGENCY_ANNOTATION
detail::result_of_t<detail::decay_t<Function>()>
  sync_execute(E& exec, Function&& f)
{
  return agency::async_execute(exec, std::forward<Function>(f)).get();
}

namespace detail
{

template<class Function>
struct sync_execute_functor
{
  mutable Function f;

  template<class Index, class Result>
  __AGENCY_ANNOTATION
  void operator()(const Index&, Result& result, unit) const
  {
    result = invoke_and_return_unit_if_void_result(f);
  }
};

} // end detail

// this case handles executors which have no way to create single-agent synchrony
__agency_exec_check_disable__
template<class E, class Function,
         __AGENCY_REQUIRES(!detail::SimpleExecutor<E>()),
         __AGENCY_REQUIRES(detail::BulkExecutor<E>())>
__AGENCY_ANNOTATION
detail::result_of_t<detail::decay_t<Function>()>
  sync_execute(E& exec, Function f)
{
  using result_of_function = detail::result_of_t<Function()>;

  // if f returns void, then return a unit from bulk_sync_execute()
  using result_type = typename std::conditional<
    std::is_void<result_of_function>::value,
    detail::unit,
    result_of_function
  >::type;

  // XXX should really move f into this functor, but it's not clear how to make move-only
  //     parameters to CUDA kernels
  auto execute_me = detail::sync_execute_functor<Function>{f};

  using shape_type = executor_shape_t<E>;

  // call bulk_async_execute() and cast to the expected result, which handles void result
  return static_cast<result_of_function>(agency::bulk_sync_execute(exec,
    execute_me,                        // the functor to execute
    detail::shape_cast<shape_type>(1), // create only a single agent
    detail::construct<result_type>(),  // a factory for creating f's result
    detail::unit_factory()             // a factory for creating a unit shared parameter which execute_me will ignore
  ));
}

} // end agency


text:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class LocatariosUsuarios extends MY_Controller {

    public function __construct()
    {
        parent::__construct();
        $this->load->model('template/Template_model', 'locUser');
        $this->locUser->setTable('usuariosLocatarios', 'usuarioLocatarioID');
        $this->load->model('template/Template_model', 'loc');
        $this->loc->setTable('locatarios', 'locatarioID');
    }

    public function listar($id)
    {
        # Dados do locatário
        $locatarioID = (int) strip_tags(trim($id));

        $data['locatario'] = $this->loc->get_by_id($locatarioID);
        # Fim dados do locatário

        $data['titulo'] = 'Steel4Web - Listar Usuários Locatários';
        $pagina = 'locatariosusuarios-listar';
        $data['locatariosUsuarios'] = $this->locUser->get_by_field('locatarioID', $locatarioID);
        $this->render($data, $pagina);
    }

    public function cadastrar($id)
    {
         # Dados do locatário
        $locatarioID = (int) strip_tags(trim($id));
        $data['locatario'] = $this->loc->get_by_id($locatarioID);
        # Fim dados do locatário

        $data['titulo'] = 'Steel4Web - Cadastrar Usuário do Locatário';
        $pagina = 'locatariousuario-cadastro';
        $this->render($data, $pagina);
    }

    public function editar($id)
    {
        $data['titulo'] = 'Steel4Web - Editar Usuário do Locatário';
        $pagina = 'locatariousuario-cadastro';
        $data['usuarioLocatarioID'] = strip_tags(trim($id));
        $data['usuarioLocatario'] = $this->locUser->get_by_id($data['usuarioLocatarioID']);
        $data['locatario'] = $this->loc->get_by_id($data['usuarioLocatario']->locatarioID);
        $data['edicao'] = true;
        $this->render($data, $pagina);
    }

    public function gravar()
    {
        header('Access-Control-Allow-Origin: *');
        if($_POST){
            $dados['nome']          = ucwords(strip_tags(trim($this->input->post('nome'))));
            $dados['email']         = strip_tags(trim($this->input->post('email')));
            $dados['senha']         = strip_tags(trim($this->input->post('senha')));
            $dados['locatarioID']   = $this->input->post('locatarioID');
            $dados['tipoUsuarioID'] = $this->input->post('tipoUsuarioID');

            if(isset($dados['nome']) && isset($dados['email']) && isset($dados['senha']) && isset($dados['locatarioID']) && isset($dados['tipoUsuarioID'])) {

                $attributes = array(
                    'nome'          => $dados['nome'],
                    'email'         => $dados['email'],
                    'senha'         => sha1('web3d@' . $dados['senha'] . '@web3d'),
                    'status'        => 1,
                    'locatarioID'   => $dados['locatarioID'],
                    'tipoUsuarioID' => $dados['tipoUsuarioID']
                );

                $locatarioUsuarioID = $this->locUser->insert($attributes);

                if($locatarioUsuarioID){
                    die('sucesso');
                }
            }
            die('erro');
        }
    }

    public function gravarEdicao()
    {
        header('Access-Control-Allow-Origin: *');
        if($_POST){
            $dados['nome']               = ucwords(strip_tags(trim($this->input->post('nome'))));
            $dados['email']              = strip_tags(trim($this->input->post('email')));
            $dados['senha']              = strip_tags(trim($this->input->post('senha')));
            $dados['locatarioID']        = $this->input->post('locatarioID');
            $dados['usuarioLocatarioID'] = $this->input->post('usuarioLocatarioID');
            $dados['tipoUsuarioID']      = $this->input->post('tipoUsuarioID');

            if(isset($dados['nome']) && isset($dados['email']) && isset($dados['senha']) && isset($dados['locatarioID']) && isset($dados['usuarioLocatarioID']) && isset($dados['tipoUsuarioID'])) {

                $attributes = array(
                    'nome'          => $dados['nome'],
                    'email'         => $dados['email'],
                    'senha'         => sha1('web3d@' . $dados['senha'] . '@web3d'),
                    'status'        => 1,
                    'locatarioID'   => $dados['locatarioID'],
                    'tipoUsuarioID' => $dados['tipoUsuarioID']
                );

                $locatarioUsuarioID = $this->locUser->update($dados['usuarioLocatarioID'], $attributes);

                if($locatarioUsuarioID){
                    die('sucesso');
                }
            }
            die('erro');
        }
    }

    public function editarStatus($locatarioID, $id, $status)
    {
        $status = strip_tags(trim($status));

        if ($status == 'ativar') {
            $codStatus = 1;
        } else {
            $codStatus = 0;
        }

        $attributes = array(
            'status'  => $codStatus
        );

        $mudancaStatus = $this->locUser->update($id, $attributes);
        redirect('sistema/locatariosUsuarios/listar/' . $locatarioID);
    }

    public function excluir($locatarioID,$id)
    {
        $mudancaStatus = $this->locUser->delete($id);
        redirect('sistema/locatariosUsuarios/listar/' . $locatarioID);
    }

    private function render($data, $pagina)
    {
        $this->load->view('sistema/includes/header', $data, FALSE);
        $this->load->view('sistema/includes/menus-adm', $data, FALSE);
        $this->load->view('sistema/paginas-admin/' . $pagina, $data, FALSE);
        $this->load->view('sistema/includes/footer', $data, FALSE);
    }
}


text:
package com.ltsllc.miranda.cluster.messages;

import com.ltsllc.miranda.Message;
import com.ltsllc.miranda.clientinterface.basicclasses.NodeElement;

import java.util.concurrent.BlockingQueue;

/**
 * Created by Clark on 2/20/2017.
 */
public class DropNodeMessage extends Message {
    private NodeElement droppedNode;

    public DropNodeMessage(BlockingQueue<Message> senderQueue, Object sender, NodeElement droppedNode) {
        super(Subjects.DropNode, senderQueue, sender);

        this.droppedNode = droppedNode;
    }

    public NodeElement getDroppedNode() {
        return droppedNode;
    }
}


text:
package org.mapdb.list;

import org.mapdb.ser.ArrayListSerializer;
import org.mapdb.ser.Serializer;
import org.mapdb.store.Store;

import java.util.*;

public class MonolithList<E>
        extends AbstractList<E>
        implements List<E>, RandomAccess {

    public static class Maker<E> {
        private final Store store;
        private final Serializer<E> ser;
        private final long recid;

        public Maker(Store store, long recid, Serializer<E> ser) {
            this.store = store;
            this.recid = recid;
            this.ser = ser;
        }

        public static <E> Maker<E> newList(Store store, Serializer<E> ser) {
            long recid = store.put(new ArrayList(), new ArrayListSerializer(ser));
            return new Maker(store, recid, ser);
        }

        public MonolithList<E> make(){
            return new MonolithList<E>(store, recid, ser);
        }
    }

    private final Store store;
    private final long recid;
    private final Serializer<E> ser;
    private final Serializer<ArrayList<E>> listSer;

    public MonolithList(Store store, long recid, Serializer<E> ser) {
        this.store = store;
        this.recid = recid;
        this.ser = ser;
        this.listSer = new ArrayListSerializer(ser);
    }

    @Override
    public E get(int index) {
        ArrayList<E> list = store.get(recid, listSer);
        return list.get(index);
    }

    @Override
    public int size() {
        ArrayList<E> list = store.get(recid, listSer);
        return list.size();
    }

    @Override
    public boolean add(E e) {
        ArrayList<E> list = getClone();
        list.add(e);
        store(list);
        return true;
    }

    @Override
    public E set(int index, E element) {
        ArrayList<E> list = getClone();
        E e=list.set(index,element);
        store(list);
        return e;
    }

    @Override
    public void add(int index, E element) {
        ArrayList<E> list = getClone();
        list.add(index,element);
        store(list);
    }

    @Override
    public boolean addAll(int index, Collection<? extends E> c) {
        ArrayList<E> list = getClone();
        list.addAll(index, c);
        store(list);
        return true;
    }

    @Override
    public boolean addAll(Collection<? extends E> c) {
        ArrayList<E> list = getClone();
        list.addAll(c);
        store(list);
        return true;
    }

    @Override
    public E remove(int index) {
        ArrayList<E> list = getClone();
        E e=list.remove(index);
        store(list);
        return e;
    }

    protected ArrayList<E> getClone() {
        return (ArrayList<E>) store.get(recid, listSer).clone();
    }

    protected void store(ArrayList<E> list) {
        store.update(recid, listSer, list);
    }

}


text:
class IconbarTheme: public FbTk::Theme, public FbTk::ThemeProxy<IconbarTheme> {
public:
    IconbarTheme(int screen_num, const std::string &name, const std::string &altname);
    virtual ~IconbarTheme();

    void reconfigTheme();
    bool fallback(FbTk::ThemeItem_base &item);

    FbTk::TextTheme &text()  { return m_text; }
    const FbTk::BorderTheme &border() const { return m_border; }
    const FbTk::Texture &texture() const { return *m_texture; }
    const FbTk::Texture &emptyTexture() const { return *m_empty_texture; }

    virtual FbTk::Subject &reconfigSig() { return FbTk::Theme::reconfigSig(); }
    virtual const FbTk::Subject &reconfigSig() const { return FbTk::Theme::reconfigSig(); }

    virtual IconbarTheme &operator *() { return *this; }
    virtual const IconbarTheme &operator *() const { return *this; }

private:
    FbTk::ThemeItem<FbTk::Texture> m_texture, m_empty_texture;
    FbTk::BorderTheme m_border;
    FbTk::TextTheme m_text;
    std::string m_name, m_altname;
};

#endif  // ICONBARTHEME_HH


text:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/iv_icon"
        android:background="@mipmap/ic_launcher"
        android:layout_width="45dp"
        android:layout_height="45dp"/>
    <TextView
        android:layout_toRightOf="@+id/iv_icon"
        android:id="@+id/tv_name"
        android:text="应用名称"
        android:textSize="18sp"
        android:layout_centerVertical="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
    <ImageView
        android:id="@+id/iv_lock"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:background="@drawable/lock"
        android:layout_width="25dp"
        android:layout_height="25dp"/>

</RelativeLayout>


text:
import IPython.core.display
import matplotlib as mpl

def clean():
    # set mpl defaults for nice display
    mpl.rcParams['font.size'] = 12
    mpl.rcParams['figure.figsize'] = (18, 6)
    mpl.rcParams['lines.linewidth'] = 1

    return IPython.core.display.HTML("""
    <style type="text/css">
    div.input {
    width: 105ex; /* about 80 chars + buffer */
    }

    div.text_cell {
    width: 105ex /* instead of 100%, */
    }

    div.text_cell_render {
    font-family: Cambria, Candara, serif;
    font-size: 14pt
    line-height: 145%; /* added for some line spacing of text. */
    width: 105ex; /* instead of 'inherit' for shorter lines */
    }

    /* Set the size of the headers */
    div.text_cell_render h1 {
    font-size: 20pt;
    }

    div.text_cell_render h2 {
    font-size: 18pt;
    }

    .CodeMirror {
    font-family: Consolas, monospace;
    width: 105ex;
    }

    .rendered_html ol {list-style:decimal; margin: 1em 2em;}

    </style>""")


text:
package mslcli.common.entityauth;

import com.netflix.msl.entityauth.EntityAuthenticationData;
import com.netflix.msl.entityauth.EntityAuthenticationFactory;
import com.netflix.msl.entityauth.EntityAuthenticationScheme;
import com.netflix.msl.entityauth.UnauthenticatedAuthenticationData;
import com.netflix.msl.entityauth.UnauthenticatedAuthenticationFactory;
import com.netflix.msl.util.AuthenticationUtils;

import mslcli.common.CmdArguments;
import mslcli.common.IllegalCmdArgumentException;
import mslcli.common.util.AppContext;
import mslcli.common.util.ConfigurationException;

/**
 * <p>
 * Plugin implementation for generating unauthenticated entity authentication data and factory
 * </p>
 *
 * @author Vadim Spector <vspector@netflix.com>
 */

public class UnauthenticatedEntityAuthenticationHandle extends EntityAuthenticationHandle {
    /**
     * ctor
     */
    public UnauthenticatedEntityAuthenticationHandle() {
        super(EntityAuthenticationScheme.NONE);
    }

    @Override
    public EntityAuthenticationData getEntityAuthenticationData(final AppContext appCtx, final CmdArguments args)
        throws IllegalCmdArgumentException
    {
        return new UnauthenticatedAuthenticationData(args.getEntityId());
    }

    @Override
    public EntityAuthenticationFactory getEntityAuthenticationFactory(final AppContext appCtx, final CmdArguments args, final AuthenticationUtils authutils)
        throws ConfigurationException, IllegalCmdArgumentException
    {
        return new UnauthenticatedAuthenticationFactory(authutils);
    }
}


text:
package org.kuali.rice.kew.plugin;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.io.File;

import javax.xml.namespace.QName;

import org.apache.commons.io.FileUtils;
import org.junit.Test;
import org.kuali.rice.core.api.config.CoreConfigHelper;
import org.kuali.rice.kew.test.KEWTestCase;
import org.kuali.rice.kew.test.TestUtilities;

/**
 * Tests the HotDeployer and Reloader which handle hot deployment and hot reloading
 * of Plugins.
 *
 * @author Kuali Rice Team (rice.collab@kuali.org)
 */
public class HotDeployTest extends KEWTestCase {

	private File pluginDir;

	@Override
	public void setUp() throws Exception {
        super.setUp();
		TestUtilities.initializePluginDirectories();
		this.pluginDir = TestUtilities.getPluginsDirectory();
	}

	@Override
	public void tearDown() throws Exception {
		super.tearDown();
		TestUtilities.cleanupPluginDirectories();
	}

	@Test public void testHotDeploy() throws Exception {
		// Grab the ServerPluginRegistry
		PluginRegistry theRegistry = PluginUtils.getPluginRegistry();
		assertNotNull("PluginRegistry should exist.", theRegistry);
		assertTrue(theRegistry instanceof ServerPluginRegistry);
		ServerPluginRegistry registry = (ServerPluginRegistry)theRegistry;

		// Let's shut down the asynchronous reloader and hot deployer because we want to do this synchronously.
		HotDeployer hotDeployer = registry.getHotDeployer();
		Reloader reloader = registry.getReloader();
		registry.stopHotDeployer();
		registry.stopReloader();

		// Assert that there are currently no plugins
		assertEquals("There should be no plugins.", 0, registry.getPluginEnvironments().size());
		assertEquals("Resource loader should have no children.", 0, registry.getResourceLoaders().size());

		// query the hot deployer directly about it's added and removed plugins
		assertEquals("There should be no plugins added.", 0, hotDeployer.getAddedPlugins().size());
		assertEquals("There should be no plugins removed.", 0, hotDeployer.getRemovedPlugins().size());
		hotDeployer.run();
		assertEquals("There should still be no plugins.", 0, registry.getPluginEnvironments().size());

		// now let's copy a plugin over and run the hot deployer
        String pluginZipFileLocation = getBaseDir() + "/src/test/resources/org/kuali/rice/kew/plugin/ziptest.zip";
		File pluginZipFile = new File(pluginZipFileLocation);
		assertTrue("Plugin file '" + pluginZipFileLocation + "' should exist", pluginZipFile.exists());
		assertTrue("Plugin file '" + pluginZipFileLocation + "' should be a file", pluginZipFile.isFile());
		FileUtils.copyFileToDirectory(pluginZipFile, pluginDir);

		assertEquals("There should be one plugin added.", 1, hotDeployer.getAddedPlugins().size());
		assertEquals("There should be no plugins removed.", 0, hotDeployer.getRemovedPlugins().size());

		hotDeployer.run();

		// the plugin should have been hot deployed
		assertEquals("Plugin should have been hot deployed.", 1, registry.getPluginEnvironments().size());

		// check added plugins again, it should now indicate no new added plugins
		assertEquals("There should be no plugins added.", 0, hotDeployer.getAddedPlugins().size());
		assertEquals("There should be no plugins removed.", 0, hotDeployer.getRemovedPlugins().size());

		// verify that the resource loading and the registry are sane and properly set up with the new plugin
		assertEquals("Resource loader should have 1 plugin child.", 1, registry.getResourceLoaders().size());
		Plugin plugin = (Plugin)registry.getResourceLoaders().get(0);
		assertEquals("Plugin has wrong name.", new QName(CoreConfigHelper.getApplicationId(), "ziptest"), plugin.getName());
		assertTrue("Plugin should be started.", plugin.isStarted());
		assertEquals("Plugin in resource loader and environment should be the same.", plugin, registry.getPluginEnvironment(plugin.getName().getLocalPart()).getPlugin());

		// The reloader should have a reference to the environment
		assertEquals("Reloader should have a reference to environment.", 1, reloader.getReloadables().size());

		// now remove the plugin and ensure that it goes away
		FileUtils.forceDelete(new File(pluginDir, "ziptest.zip"));
		assertEquals("There should be no plugins added.", 0, hotDeployer.getAddedPlugins().size());
		assertEquals("There should be one plugin removed.", 1, hotDeployer.getRemovedPlugins().size());
		hotDeployer.run();

		// verify that the resource loading and the registry no longer contain the plugin
		assertEquals("No plugins should be deployed.", 0, registry.getPluginEnvironments().size());
		assertEquals("Resource loader should have 0 plugin children.", 0, registry.getResourceLoaders().size());

		// also assert that the reloader no longer has a reference to the environment
		assertEquals("Reloader should no longer have reference to environment.", 0, reloader.getReloadables().size());

	}

	@Test public void testReloader() throws Exception {
		// Grab the ServerPluginRegistry
		PluginRegistry theRegistry = PluginUtils.getPluginRegistry();
		assertNotNull("PluginRegistry should exist.", theRegistry);
		assertTrue(theRegistry instanceof ServerPluginRegistry);
		ServerPluginRegistry registry = (ServerPluginRegistry)theRegistry;

		// Let's shut down the asynchronous reloader and hot deployer because we want to do this synchronously.
		HotDeployer hotDeployer = registry.getHotDeployer();
		Reloader reloader = registry.getReloader();
		registry.stopHotDeployer();
		registry.stopReloader();

		// Assert that there are currently no plugins
		assertEquals("There should be no plugins.", 0, registry.getPluginEnvironments().size());
		assertEquals("Resource loader should have no children.", 0, registry.getResourceLoaders().size());

        // now let's copy a plugin over and run the hot deployer
        String pluginZipFileLocation = getBaseDir() + "/src/test/resources/org/kuali/rice/kew/plugin/ziptest.zip";
        File pluginZipFile = new File(pluginZipFileLocation);
        assertTrue("Plugin file '" + pluginZipFileLocation + "' should exist", pluginZipFile.exists());
        assertTrue("Plugin file '" + pluginZipFileLocation + "' should be a file", pluginZipFile.isFile());
        FileUtils.copyFileToDirectory(pluginZipFile, pluginDir);

		// update pluginZipFile to point to the copy
		pluginZipFile = new File(pluginDir, pluginZipFile.getName());
		assertTrue(pluginZipFile.exists());

		// execute a hot deploy
		hotDeployer.run();

		// the plugin should have been hot deployed
		assertEquals("Plugin should have been hot deployed.", 1, registry.getPluginEnvironments().size());
		assertEquals("Resource loader should have 1 plugin child.", 1, registry.getResourceLoaders().size());
		PluginEnvironment environment = registry.getPluginEnvironments().get(0);
		Plugin plugin = environment.getPlugin();
		assertTrue(environment.isReloadable());
		assertFalse(environment.isReloadNeeded());

		// let's attempt to execute a Reload
		reloader.run();

		// a reload should not have occurred here since nothing was updated
		assertTrue("Original plugin should still be running.", plugin.isStarted());
		assertEquals("Plugin should not have changed.", plugin, registry.getPluginEnvironments().get(0).getPlugin());

		// touch the plugin file and then reload
		FileUtils.touch(pluginZipFile);
		assertTrue("A reload should be needed now.", environment.isReloadNeeded());
		reloader.run();

		// the original plugin should now be stopped
		assertTrue("original plugin should be stopped.", !plugin.isStarted());
		assertEquals("There should only be one Plugin.", 1, registry.getResourceLoaders().size());

		PluginEnvironment newPluginEnvironment = registry.getPluginEnvironments().get(0);
		Plugin newPlugin = newPluginEnvironment.getPlugin();
		assertEquals("There should still only be one environment.", 1, registry.getPluginEnvironments().size());
		assertEquals("The plugin environments should still be the same.", environment, registry.getPluginEnvironments().get(0));

		assertFalse("The old and new plugins should be different.", newPlugin.equals(plugin));

		// verify that the resource loader was updated
		assertEquals("The resource loaders should have been updated with the new plugin.", newPlugin, registry.getResourceLoaders().get(0));

	}

}


text:
module Artsy
  module Client
    module API
      module OrderedSet
        include Artsy::Client::API::Parse

        # Retrieves an ordered_set.
        #
        # @return [Artsy::Client::Domain::OrderedSet]
        def ordered_set(id)
          object_from_response(self, Artsy::Client::Domain::OrderedSet, :get, "/api/v1/set/#{id}", {})
        end

        # Creates an ordered_set.
        #
        # @return [Artsy::Client::Domain::OrderedSet]
        def create_ordered_set(params = {})
          object_from_response(self, Artsy::Client::Domain::OrderedSet, :post, "/api/v1/set", params)
        end

        # Adds an item to an ordered_set.
        #
        # @return [Artsy::Client::Domain::OrderedSet]
        def add_to_ordered_set(id, params = {})
          set = ordered_set(id)
          # Ruby 1.9.3 cannot handle const_get for nested Classes (Ruby 2.0 can).
          type_class = "Artsy::Client::Domain::#{set[:item_type]}".split("::").reduce(Object) { |a, e| a.const_get e }
          object_from_response(self, type_class, :post, "/api/v1/set/#{id}/item", params)
        end
      end
    end
  end
end


text:
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>W29182_text</title>
        <link rel="stylesheet" type="text/css" href="style.css" />

                «

    <p class="styleSans725.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">


text:
module Stacks::Services::SharedAppLikeThing
  attr_accessor :use_ha_mysql_ordering
  attr_accessor :ha_mysql_ordering_exclude
  attr_accessor :application
  alias_method :database_application_name, :application

  def self.extended(object)
    object.configure
  end

  def configure
    @use_ha_mysql_ordering = false
    @ha_mysql_ordering_exclude = []
  end

  def database_username
    if @kubernetes
      @environment.short_name + @short_name
    else
      @application
    end
  end
end


text:
<?xml version="1.0"?>

<config>
    <sections>
        <tax>
            <groups>
                <weee translate="label">
                    Fixed Product Taxes
                    <sort_order>100</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <enable translate="label">
                            Enable FPT
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>1</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </enable>
                        <display_list translate="label">
                            Display Prices In Product Lists
                            <frontend_type>select</frontend_type>
                            <source_model>weee/config_source_display</source_model>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </display_list>
                        <display translate="label">
                            Display Prices On Product View Page
                            <frontend_type>select</frontend_type>
                            <source_model>weee/config_source_display</source_model>
                            <sort_order>20</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </display>
                        <display_sales translate="label">
                            Display Prices In Sales Modules
                            <frontend_type>select</frontend_type>
                            <source_model>weee/config_source_display</source_model>
                            <sort_order>30</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </display_sales>
                        <display_email translate="label">
                            Display Prices In Emails
                            <frontend_type>select</frontend_type>
                            <source_model>weee/config_source_display</source_model>
                            <sort_order>40</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </display_email>
                        <discount translate="label">
                            Apply Discounts To FPT
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>50</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </discount>
                        <apply_vat translate="label">
                            FPT Tax Configuration
                            <frontend_type>select</frontend_type>
                            <source_model>weee/config_source_fpt_tax</source_model>
                            <sort_order>60</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </apply_vat>
                        <include_in_subtotal translate="label">
                            Include FPT In Subtotal
                            <frontend_type>select</frontend_type>
                            <source_model>adminhtml/system_config_source_yesno</source_model>
                            <sort_order>70</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </include_in_subtotal>
                    </fields>
                </weee>
            </groups>
        </tax>
        <sales>
            <groups>
                <totals_sort>
                    <fields>
                        <weee translate="label">
                            Fixed Product Tax
                            <frontend_type>text</frontend_type>
                            <sort_order>4</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>0</show_in_store>
                        </weee>
                    </fields>
                </totals_sort>
            </groups>
        </sales>
    </sections>
</config>


text:
void find_next_train(int count, TrainTime *times, TrainTime **nb, TrainTime **sb) {
  TrainTime *best[2] = {NULL, NULL};

  const time_t timestamp = time(NULL);
  const uint16_t minute = current_minute();
  const uint8_t day = current_day();

  for(int i = 0; i < count; ++i) {
    TrainTime *train_time = &times[i];
    TrainTrip trip;
    trip_get(train_time->trip, &trip);
    //APP_LOG(APP_LOG_LEVEL_INFO, "%d) %p time: %d, stop: %d, direction: %d", i, train_time, train_time->time, train_time->stop, trip.direction);

    // Make sure this trip is actually running today
    TrainCalendar *cal = calendar_get(trip.service);
    if((cal->days & day) == 0 || cal->start > timestamp || cal->end < timestamp) {
      continue;
    }

    // If it's better than the best we have so far, use it.
    if(train_time->time > minute) {
      if(best[trip.direction] == NULL || train_time->time < best[trip.direction]->time) {
        best[trip.direction] = train_time;
      }
    }
  }
  *nb = best[TrainDirectionNorthbound];
  *sb = best[TrainDirectionSouthbound];
}

uint16_t get_future_trains(uint8_t station, TrainDirection direction, TrainTime **trains) {
  uint16_t time_count = stop_times_count(station);
  uint16_t pointer = 0;

  TrainTime *times = malloc(time_count * sizeof(TrainTime));
  time_count = stop_get_times(station, time_count, times);

  *trains = malloc(time_count * sizeof(TrainTime));

  const time_t timestamp = time(NULL);
  const uint16_t minute = current_minute();
  const uint8_t day = current_day();

  for(int i = 0; i < time_count; ++i) {
    TrainTime *train_time = &times[i];
    TrainTrip trip;
    trip_get(train_time->trip, &trip);

    if(trip.direction != direction) {
      continue;
    }

    TrainCalendar *cal = calendar_get(trip.service);
    if((cal->days & day) == 0 || cal->start > timestamp || cal->end < timestamp) {
      continue;
    }

    if(train_time->time > minute) {
      memcpy(&((*trains)[pointer++]), train_time, sizeof(TrainTime));
    }

  }
  free(times);
  return pointer;
}

void next_train_at_station(uint8_t station, TrainTime *northbound, TrainTime *southbound) {
  uint16_t time_count = stop_times_count(station);
  TrainTime *times = malloc(time_count * sizeof(TrainTime));
  time_count = stop_get_times(station, time_count, times);

  TrainTime *north, *south;
  find_next_train(time_count, times, &north, &south);

  if(north != NULL) {
    memcpy(northbound, north, sizeof(TrainTime));
  } else {
    northbound->time = INVALID_TIME;
  }
  if(south != NULL) {
    memcpy(southbound, south, sizeof(TrainTime));
  } else {
    southbound->time = INVALID_TIME;
  }

  free(times);
}