text:
require "spec_helper"

describe "percona::toolkit" do
  let(:centos_package) do
    "Percona-Server-shared-compat"
  end

  let(:toolkit_package) do
    "percona-toolkit"
  end

  describe "Ubuntu" do
    let(:chef_run) do
      ChefSpec::SoloRunner.new.converge(described_recipe)
    end

    specify do
      expect(chef_run).to_not install_package(centos_package)

      expect(chef_run).to install_package(toolkit_package)
    end
  end

  describe "CentOS" do
    describe "when `version` is 5.5" do
      let(:chef_run) do
        env_options = { platform: "centos", version: "6.5" }
        ChefSpec::SoloRunner.new(env_options) do |node|
          node.set["percona"]["version"] = "5.5"
        end.converge(described_recipe)
      end

      specify do
        expect(chef_run).to install_package(centos_package)
        expect(chef_run).to install_package(toolkit_package)
      end
    end

    describe "when `version` is 5.6" do
      let(:chef_run) do
        env_options = { platform: "centos", version: "6.5" }
        ChefSpec::SoloRunner.new(env_options) do |node|
          node.set["percona"]["version"] = "5.6"
        end.converge(described_recipe)
      end

      specify do
        expect(chef_run).to_not install_package(centos_package)

        expect(chef_run).to install_package(toolkit_package)
      end
    end
  end
end


text:
module Taobao
  class Item < Model
    def self.attr_names
      [:detail_url, :num_iid, :title, :nick, :type, :desc, :skus, :props_name, :created, :promoted_service, :is_lightning_consignment,
       :is_fenxiao, :auction_point, :property_alias, :volumn, :template_id, :after_sale_id, :is_xinpin, :sub_stock, :cid, :seller_cids,
       :props, :input_pids, :input_str, :pic_url, :num, :valid_thru, :list_time, :delist_time, :stuff_status, :location, :price, :post_fee,
       :express_fee, :ems_fee, :has_discount, :freight_payer, :has_invoice, :has_warranty, :has_showcase, :modified, :increment, :approve_status,
       :postage_id, :product_id, :item_imgs, :prop_imgs, :outer_id, :is_virtual, :is_taobao, :is_ex, :is_timing, :videos, :is_3D, :score,
       :one_station, :second_kill, :auto_fill, :violation, :is_prepay, :ww_status, :wap_desc, :wap_detail_url, :cod_postage_id, :sell_promise]
    end
    attr_names.each do |attr_name|
      attr_accessor attr_name
    end
  end
end

redpajama_set_name: RedPajamaGithub


text:
package com.hunantv.fw.tests;

import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map;

public class KeysetEnum<T> implements Enumeration<T> {

	private Iterator<T> keysIter;

	public KeysetEnum(Map<T, Object> map) {
		keysIter = map.keySet().iterator();
	}

	@Override
	public boolean hasMoreElements() {
		return keysIter.hasNext();
	}

	@Override
	public T nextElement() {
		return keysIter.next();
	}
}


text:
/* globals $ */

// eslint-disable-next-line no-unused-vars
function addFormListeners() {
  $('.scenario').hide();
  $('.load').addClass('dim');
  resizeTextarea();
  $('.cancel').click(restore);
}

function resizeTextarea() {
  $('textarea').height('auto');
  $('textarea').height($('textarea').prop('scrollHeight'));
}

function restore() {
  $('form').remove();
  $('.scenario').show();
  $('.load').removeClass('dim');
}

$(function() {
  $('.featured.tooltip').qtip();

  if (!document.getElementById('unfeature')) {
    return;
  }

  $('#unfeature .check .save').on('click', function(event) {
    event.stopPropagation();
    $('#unfeature .check').hide();
    $('#unfeature .confirm').show();
  });

  resizeTextarea();
});


text:
package org.elasticsearch.cluster.routing;

import org.elasticsearch.ElasticSearchIllegalStateException;
import org.elasticsearch.cluster.node.DiscoveryNode;

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

import static com.google.common.collect.Lists.newArrayList;

/**
 * A {@link RoutingNode} represents a cluster node associated with a single {@link DiscoveryNode} including all shards
 * that are hosted on that nodes. Each {@link RoutingNode} has a unique node id that can be used to identify the node.
 */
public class RoutingNode implements Iterable<MutableShardRouting> {

    private final String nodeId;

    private final DiscoveryNode node;

    private final List<MutableShardRouting> shards;

    public RoutingNode(String nodeId, DiscoveryNode node) {
        this(nodeId, node, new ArrayList<MutableShardRouting>());
    }

    public RoutingNode(String nodeId, DiscoveryNode node, List<MutableShardRouting> shards) {
        this.nodeId = nodeId;
        this.node = node;
        this.shards = shards;
    }

    @Override
    public Iterator<MutableShardRouting> iterator() {
        return shards.iterator();
    }

    /**
     * Returns the nodes {@link DiscoveryNode}.
     *
     * @return discoveryNode of this node
     */
    public DiscoveryNode node() {
        return this.node;
    }

    /**
     * Get the id of this node
     * @return id of the node
     */
    public String nodeId() {
        return this.nodeId;
    }

    /**
     * Get a list of shards hosted on this node
     * @return list of shards
     */
    public List<MutableShardRouting> shards() {
        return this.shards;
    }

    /**
     * Add a new shard to this node
     * @param shard Shard to crate on this Node
     */
    public void add(MutableShardRouting shard) {
        for (MutableShardRouting shardRouting : shards) {
            if (shardRouting.shardId().equals(shard.shardId())) {
                throw new ElasticSearchIllegalStateException("Trying to add a shard [" + shard.shardId().index().name() + "][" + shard.shardId().id() + "] to a node [" + nodeId + "] where it already exists");
            }
        }
        shards.add(shard);
        shard.assignToNode(node.id());
    }

    /**
     * Remove a shard from this node
     * @param shardId id of the shard to remove
     */
    public void removeByShardId(int shardId) {
        for (Iterator<MutableShardRouting> it = shards.iterator(); it.hasNext(); ) {
            MutableShardRouting shard = it.next();
            if (shard.id() == shardId) {
                it.remove();
            }
        }
    }

    /**
     * Determine the number of shards with a specific state
     * @param states set of states which should be counted
     * @return number of shards
     */
    public int numberOfShardsWithState(ShardRoutingState... states) {
        int count = 0;
        for (MutableShardRouting shardEntry : this) {
            for (ShardRoutingState state : states) {
                if (shardEntry.state() == state) {
                    count++;
                }
            }
        }
        return count;
    }

    /**
     * Determine the shards with a specific state
     * @param states set of states which should be listed
     * @return List of shards
     */
    public List<MutableShardRouting> shardsWithState(ShardRoutingState... states) {
        List<MutableShardRouting> shards = newArrayList();
        for (MutableShardRouting shardEntry : this) {
            for (ShardRoutingState state : states) {
                if (shardEntry.state() == state) {
                    shards.add(shardEntry);
                }
            }
        }
        return shards;
    }

    /**
     * Determine the shards of an index with a specific state
     * @param index id of the index
     * @param states set of states which should be listed
     * @return a list of shards
     */
    public List<MutableShardRouting> shardsWithState(String index, ShardRoutingState... states) {
        List<MutableShardRouting> shards = newArrayList();

        for (MutableShardRouting shardEntry : this) {
            if (!shardEntry.index().equals(index)) {
                continue;
            }
            for (ShardRoutingState state : states) {
                if (shardEntry.state() == state) {
                    shards.add(shardEntry);
                }
            }
        }
        return shards;
    }

    /**
     * Get the number of shard that not match the given states
     * @param state set states to exclude
     * @return number of shards which state is listed
     */
    public int numberOfShardsNotWithState(ShardRoutingState state) {
        int count = 0;
        for (MutableShardRouting shardEntry : this) {
            if (shardEntry.state() != state) {
                count++;
            }
        }
        return count;
    }

    /**
     * The number of shards on this node that will not be eventually relocated.
     */
    public int numberOfOwningShards() {
        int count = 0;
        for (MutableShardRouting shardEntry : this) {
            if (shardEntry.state() != ShardRoutingState.RELOCATING) {
                count++;
            }
        }

        return count;
    }

    public String prettyPrint() {
        StringBuilder sb = new StringBuilder();
        sb.append("-----node_id[").append(nodeId).append("][" + (node == null ? "X" : "V") + "]\n");
        for (MutableShardRouting entry : shards) {
            sb.append("--------").append(entry.shortSummary()).append('\n');
        }
        return sb.toString();
    }
}