text:
using System;
using System.Collections.Generic;
using FluentAssertions;
using NUnit.Framework;
using Shapeshifter.Core;
using Shapeshifter.Core.Serialization;

namespace Shapeshifter.Tests.Unit.Core.Serialization
{
    [TestFixture]
    public class SerializerCollectionTests
    {
        [Test]
        public void ResolveForNotAddedType_Thrown()
        {
            var serializerCollection = (SerializerCollection)SerializerCollection.New;

            Action action = () => serializerCollection.ResolveSerializer(typeof(int));
            action.ShouldThrow<ShapeshifterException>().Where(i => i.Id == Exceptions.SerializerResolutionFailedId);
        }

        [Test]
        public void Add_Resolve_Success()
        {
            var mySerializer = new CustomSerializer(typeof(int), null, 1, null);

            var serializerCollection = (SerializerCollection) SerializerCollection.New.Add(mySerializer);

            serializerCollection.ResolveSerializer(typeof(int)).Should().Be(mySerializer);
        }

        [Test]
        public void AddCustomAndDefaultSerializer_InAnyOrder_Resolve_CustomSerializerIsReturned()
        {
            var myDefaultSerializer = new DefaultSerializer(new SerializableTypeInfo(typeof(int), "MyInt", 1, new List<FieldOrPropertyMemberInfo>()));
            var myCustomSerializer = new CustomSerializer(typeof(int), null, 1, null);

            {
                var serializerCollection = (SerializerCollection) SerializerCollection.New
                    .Add(myDefaultSerializer)
                    .Add(myCustomSerializer);

                serializerCollection.ResolveSerializer(typeof(int)).Should().Be(myCustomSerializer);
            }
            {
                var serializerCollection = (SerializerCollection)SerializerCollection.New
                    .Add(myCustomSerializer)
                    .Add(myDefaultSerializer);

                serializerCollection.ResolveSerializer(typeof(int)).Should().Be(myCustomSerializer);
            }
        }

        [Test]
        public void AddTwoCustomSerializers_Throws()
        {
            var myCustomSerializer1 = new CustomSerializer(typeof(int), null, 1, null);
            var myCustomSerializer2 = new CustomSerializer(typeof(int), null, 1, null);

            Action action = () =>
            {
                var serializerCollection = (SerializerCollection) SerializerCollection.New
                    .Add(myCustomSerializer1)
                    .Add(myCustomSerializer2);
            };
            action.ShouldThrow<ShapeshifterException>().Where(i => i.Id == Exceptions.SerializerAlreadyExistsId);
        }

        [Test]
        public void AddTwoDefaultSerializers_Throws()
        {
            var myDefaultSerializer1 = new DefaultSerializer(new SerializableTypeInfo(typeof(int), "MyInt", 1, new List<FieldOrPropertyMemberInfo>()));
            var myDefaultSerializer2 = new DefaultSerializer(new SerializableTypeInfo(typeof(int), "MyInt", 1, new List<FieldOrPropertyMemberInfo>()));

            Action action = () =>
            {
            var serializerCollection = (SerializerCollection) SerializerCollection.New
                .Add(myDefaultSerializer1)
                .Add(myDefaultSerializer2);
            };
            action.ShouldThrow<ShapeshifterException>().Where(i => i.Id == Exceptions.SerializerAlreadyExistsId);
        }

        [Test]
        public void AddCustomSerializerForDerivedType_OverridesCustomSerializerCreatedFromBaseTypeForAllDescendants_WorksInAnyOrder()
        {
            var explicitSerializer = new CustomSerializer(typeof (int), null, 1, null, CustomSerializerCreationReason.Explicit);
            var implicitSerializer = new CustomSerializer(typeof (int), null, 1, null, CustomSerializerCreationReason.ImplicitByBaseType);

            {
                var serializerCollection = (SerializerCollection) SerializerCollection.New
                    .Add(explicitSerializer)
                    .Add(implicitSerializer);

                serializerCollection.ResolveSerializer(typeof (int)).Should().Be(explicitSerializer);
            }
            {
                var serializerCollection = (SerializerCollection) SerializerCollection.New
                    .Add(implicitSerializer)
                    .Add(explicitSerializer);

                serializerCollection.ResolveSerializer(typeof (int)).Should().Be(explicitSerializer);
            }
        }
    }
}


text:
package tuwien.inso.mnsa.clitestclient;

import java.net.InetSocketAddress;
import java.security.Security;
import java.util.List;

import javax.smartcardio.ATR;
import javax.smartcardio.Card;
import javax.smartcardio.CardChannel;
import javax.smartcardio.CardException;
import javax.smartcardio.CardTerminal;
import javax.smartcardio.CardTerminals;
import javax.smartcardio.CommandAPDU;
import javax.smartcardio.ResponseAPDU;
import javax.smartcardio.TerminalFactory;

import tuwien.inso.mnsa.nokiaprovider.NokiaProvider;

@SuppressWarnings("restriction")
public class Main {

	public static void main(String[] args) throws Exception {
		Security.addProvider(new NokiaProvider());

		TerminalFactory terminalFactory = TerminalFactory.getInstance("NokiaProvider", new InetSocketAddress("localhost", 7989));

		CardTerminals cardTerminals = terminalFactory.terminals();
		List<CardTerminal> cardTerminalList = cardTerminals.list();

		out("Connected NokiaTerminals (" + cardTerminalList.size() + "): " + cardTerminalList);

		for (CardTerminal ct : cardTerminalList) {
			out("Connection to card" + ct.getName());
			Card card = ct.connect("*");

			out("Requesting ATR");
			ATR atr = card.getATR();
			out("ATR: " + new String(atr.getBytes()));

			CardChannel channel = card.getBasicChannel();
			CommandAPDU command = new CommandAPDU(new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x04, (byte) 0x00 });
			out("sending SELECT " + bytesToHex(command.getData()));
			ResponseAPDU response = channel.transmit(command);
			out(response.toString() + ": " + bytesToHex(response.getData()));
			out("Card present: " + ct.isCardPresent());

			out("Remove card now (you have 2 sec)");
			Thread.sleep(2000);
			out("Rechecking...");

			command = new CommandAPDU(new byte[] { (byte) 0x00, (byte) 0xA4, (byte) 0x04, (byte) 0x00 });
			out("sending SELECT " + bytesToHex(command.getData()));
			try {
				response = channel.transmit(command);
				out(response.toString() + ": " + bytesToHex(response.getData()));
			} catch (CardException ex) {
				out("Caught IOException: " + ex);
			}
			out("Card present: " + ct.isCardPresent());

			card.disconnect(true);
			out("Disconnected.");
		}

	}

	private static void out(String out) {
		System.out.println(out);
	}

	// From http://stackoverflow.com/questions/9655181/convert-from-byte-array-to-hex-string-in-java
	private final static char[] hexArray = "0123456789ABCDEF".toCharArray();

	private static String bytesToHex(byte[] bytes) {
		char[] hexChars = new char[bytes.length * 2];
		int v;
		for (int j = 0; j < bytes.length; j++) {
			v = bytes[j] & 0xFF;
			hexChars[j * 2] = hexArray[v >>> 4];
			hexChars[j * 2 + 1] = hexArray[v & 0x0F];
		}
		return new String(hexChars);
	}

}

redpajama_set_name: RedPajamaGithub


text:
<?php

/*
 * GENERATED CODE WARNING
 * This file was automatically generated - do not edit!
 */

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START logging_v2_generated_MetricsServiceV2_UpdateLogMetric_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\Logging\V2\LogMetric;
use Google\Cloud\Logging\V2\MetricsServiceV2Client;

/**
 * Creates or updates a logs-based metric.
 *
 * @param string $formattedMetricName The resource name of the metric to update:
 *
 *                                    "projects/[PROJECT_ID]/metrics/[METRIC_ID]"
 *
 *                                    The updated metric must be provided in the request and it's
 *                                    `name` field must be the same as `[METRIC_ID]` If the metric
 *                                    does not exist in `[PROJECT_ID]`, then a new metric is created. Please see
 *                                    {@see MetricsServiceV2Client::logMetricName()} for help formatting this field.
 * @param string $metricName          The client-assigned metric identifier.
 *                                    Examples: `"error_count"`, `"nginx/requests"`.
 *
 *                                    Metric identifiers are limited to 100 characters and can include only the
 *                                    following characters: `A-Z`, `a-z`, `0-9`, and the special characters
 *                                    `_-.,+!*',()%/`. The forward-slash character (`/`) denotes a hierarchy of
 *                                    name pieces, and it cannot be the first character of the name.
 *
 *                                    The metric identifier in this field must not be
 *                                    [URL-encoded](https://en.wikipedia.org/wiki/Percent-encoding).
 *                                    However, when the metric identifier appears as the `[METRIC_ID]` part of a
 *                                    `metric_name` API parameter, then the metric identifier must be
 *                                    URL-encoded. Example: `"projects/my-project/metrics/nginx%2Frequests"`.
 * @param string $metricFilter        An [advanced logs
 *                                    filter](https://cloud.google.com/logging/docs/view/advanced_filters) which
 *                                    is used to match log entries. Example:
 *
 *                                    "resource.type=gae_app AND severity>=ERROR"
 *
 *                                    The maximum length of the filter is 20000 characters.
 */
function update_log_metric_sample(
    string $formattedMetricName,
    string $metricName,
    string $metricFilter
): void {
    // Create a client.
    $metricsServiceV2Client = new MetricsServiceV2Client();

    // Prepare any non-scalar elements to be passed along with the request.
    $metric = (new LogMetric())
        ->setName($metricName)
        ->setFilter($metricFilter);

    // Call the API and handle any network failures.
    try {
        /** @var LogMetric $response */
        $response = $metricsServiceV2Client->updateLogMetric($formattedMetricName, $metric);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedMetricName = MetricsServiceV2Client::logMetricName('[PROJECT]', '[METRIC]');
    $metricName = '[NAME]';
    $metricFilter = '[FILTER]';

    update_log_metric_sample($formattedMetricName, $metricName, $metricFilter);
}
// [END logging_v2_generated_MetricsServiceV2_UpdateLogMetric_sync]


text:
module PiggyJob
  class RetryPoller
    include PiggyJob::Utils

    NUM = 5

    ##
    ## @brief      init
    ##
    ## @param      queues           The queues
    ## @param      max_threads      Number of max threads in manager's pool
    ## @param      polling_timeout  The polling timeout
    ##
    def initialize(queues, max_threads, polling_timeout)
      @queues = queues
      @timeout = NUM + (queues.length << 2) * polling_timeout / max_threads.to_f
    end

    ##
    ## @brief      start retry pooler
    ##
    def start
      setup_watcher(@timeout, @timeout * NUM) do
        setup_retry
      end
    end

    ##
    ## ==================================================================== private
    ##
    private

      ##
      ## @brief      Setup retry job pooler, get 50% of the retry jobs with
      ##             minimum of 5 (if exists) from each queue and put them back
      ##             into job queue. This way they will be picked like normal
      ##             jobs
      ##
      def setup_retry
        @queues.each do |queue|
          logger.debug "Picking up jobs from retry queue"

          retry_size = (queue.retry_size >> 2)

          next if retry_size.zero?

          retry_size = 5 if retry_size < 5
          retry_jids = queue.get_retries(5)

          logger.debug "Moving #{queue.name} retry jobs #{retry_jids} into job queue"
          queue.requeue_jids(retry_jids)
        end
      end
  end
end


text:
require 'makers_styles/helpers/component_classes_helper'

class ComponentClassesHelperWrapper
  include ComponentClassesHelper
end

describe ComponentClassesHelperWrapper do
  it "constructs component classes" do
    locals = {
      parent: "cta-block",
      modifiers: ["mod-1", "mod-2"]
    }
    expect(subject.component_classes("cta", locals)).to eq "cta cta--mod-1 cta--mod-2 cta-block__cta"
  end

  context "in the absence of a parent component" do
    it "constructs component classes without block-level classes" do
      locals = {
        parent: nil,
        modifiers: ["mod-1", "mod-2"]
      }
      expect(subject.component_classes("cta", locals)).to eq "cta cta--mod-1 cta--mod-2"
    end
  end

  context "in the absence of modifiers" do
    it "constructs component classes without modifier classes" do
      locals = {
        parent: "cta-block",
        modifiers: []
      }
      expect(subject.component_classes("cta", locals)).to eq "cta cta-block__cta"
    end
  end

  context "in the absence of both parent components and modifiers" do
    it "constructs component classes without modifier or block-level classes" do
      locals = {
        parent: nil,
        modifiers: []
      }
      expect(subject.component_classes("cta", locals)).to eq "cta"
    end
  end
end