text:
title = »Akka Concurrency« Book Review
speaker = Dominik Gruber
twitter = the_dom
meetupEventId = 145316162
meetupMemberId = 42345022
homepage = "http://www.dominikgruber.com"
slides = "http://www.slideshare.net/dominikgruber/20140220-akka-concurrency"
tags = "Scala,Akka,Concurrency,Book Review"
---
Book review of »Akka Concurrency« by [Derek Wyatt](http://derekwyatt.org). I has been published in May 2013 and was recommended by [Jonas Bonèr](http://jonasboner.com), the creator of Akka and current CTO of Typesafe.


text:
<?php

namespace Zend\Mvc\Service;

class LogWriterManagerFactory extends AbstractPluginManagerFactory
{
    const PLUGIN_MANAGER_CLASS = 'Zend\Log\WriterPluginManager';
}

redpajama_set_name: RedPajamaGithub


text:
package org.apache.hadoop.hbase.metrics.file;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.metrics.ContextFactory;
import org.apache.hadoop.metrics.file.FileContext;
import org.apache.hadoop.metrics.spi.OutputRecord;

/**
 * Add timestamp to {@link org.apache.hadoop.metrics.file.FileContext#emitRecord(String, String, OutputRecord)}.
 */
@Deprecated
@InterfaceAudience.Private
public class TimeStampingFileContext extends FileContext {
  // Copies bunch of FileContext here because writer and file are private in
  // superclass.
  private File file = null;
  private PrintWriter writer = null;
  private final SimpleDateFormat sdf;

  public TimeStampingFileContext() {
    super();
    this.sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
  }

  @Override
  public void init(String contextName, ContextFactory factory) {
    super.init(contextName, factory);
    String fileName = getAttribute(FILE_NAME_PROPERTY);
    if (fileName != null) {
      file = new File(fileName);
    }
  }

  @Override
  public void startMonitoring() throws IOException {
    if (file == null) {
      writer = new PrintWriter(new BufferedOutputStream(System.out));
    } else {
      writer = new PrintWriter(new FileWriter(file, true));
    }
    super.startMonitoring();
  }

  @Override
  public void stopMonitoring() {
    super.stopMonitoring();
    if (writer != null) {
      writer.close();
      writer = null;
    }
  }

  private synchronized String iso8601() {
    return this.sdf.format(new Date());
  }

  @Override
  public void emitRecord(String contextName, String recordName,
      OutputRecord outRec) {
    writer.print(iso8601());
    writer.print(" ");
    writer.print(contextName);
    writer.print(".");
    writer.print(recordName);
    String separator = ": ";
    for (String tagName : outRec.getTagNames()) {
      writer.print(separator);
      separator = ", ";
      writer.print(tagName);
      writer.print("=");
      writer.print(outRec.getTag(tagName));
    }
    for (String metricName : outRec.getMetricNames()) {
      writer.print(separator);
      separator = ", ";
      writer.print(metricName);
      writer.print("=");
      writer.print(outRec.getMetric(metricName));
    }
    writer.println();
  }

  @Override
  public void flush() {
    writer.flush();
  }
}


text:
package org.mongodb.demos.obj;

import com.mongodb.*;

import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;

/**
 * Sample application with basic Java MongoDB Driver code
 *
 */
public class MyAppDriver {

    static DB db = null;
    static DBCollection fooCollection = null;

    static {
        MongoClient mongoClient;
        try {
            mongoClient = new MongoClient();
            db = mongoClient.getDB("jug");
            fooCollection = db.getCollection("persons");

            System.out.println(fooCollection);

        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws UnknownHostException {

        MyAppDriver app = new MyAppDriver();

        app.insertPersons();

        app.findPersons();

        System.out.println("=== === end == === ");

    }

    private void insertPersons() {
        List<DBObject> addresses = new ArrayList<>();

        DBObject address = BasicDBObjectBuilder.start()
                .add("city", "Paris")
                .add("street", "Rue de la Paix")
                .add("zip_code", "75015")
                .get();
        addresses.add(address);

        DBObject person = BasicDBObjectBuilder.start()
                .add("first_name", "John")
                .add("last_name", "Doe")
                .add("addresses", addresses)
                .add("age", 35).get();

        fooCollection.insert(person);

        person = BasicDBObjectBuilder.start()
                .add("first_name", "Jane")
                .add("last_name", "Owy")
                .add("age", 32).get();

        fooCollection.insert(person);

    }

    private void findPersons() {

        System.out.println(" == == == Query == == == ");
        DBObject query = QueryBuilder.start("age").is(35).get();
        System.out.println("\tfilter : "+ query);

        for (DBObject dbo : fooCollection.find(query )) {
            System.out.println( dbo  );
        }

        System.out.println(" == == == ===  == == == ");

    }

}


text:
/*
 * Configuration.h
 *
 *  Created on: Oct 25, 2019
 *      Author: theater
 */

#ifndef CONFIGURATION_H_
#define CONFIGURATION_H_

#include <HardwareSerial.h>
#include <IPAddress.h>
#include <EEPROM.h>

class Configuration {
	private:
		static const unsigned STARTING_ADDRESS = 10;
		static const unsigned MQTT_TOPICS_LENGTH = 60;
	public:
		int serialNumber = 462;

		bool isSimulated = true;

		String ssid = "KLP-IoT";
		String ssidPassword = "#m@6ink@#";

		IPAddress mqttServerAddress = IPAddress((uint8_t) 192, (uint8_t) 168, (uint8_t) 254, (uint8_t) 40);
		int mqttPort = 1883;
		String mqttClientName = "ESP_TMP";

		String fanSpeedMqttTopic = "fan123";
		String mirrorHeatingMqttTopic = "mirror123";
		String humidityMqttTopic = "humidity123";
		String temperatureMqttTopic = "temperature123";
		String modeMqttTopic = "mode123";
		String desiredHumidityMqttTopic = "desiredHumidity123";

		int mode = 2;
		int desiredHumidity = 60;
		int highSpeedThresholdDelta = 15;

		int temperatureCorrection = 0;
		int humidityCorrection = 0;
		int humidityTolerance = 2;

		unsigned sensorsUpdateReocurrenceIntervalMillis = 30000;

		void print();
		/**
		 * @param configProperty = the property to be updated
		 * @param value = the value to which the property will be updated
		 * @param parameterName = description of the property for logging
		 */
		void updateValue(String * configProperty, String value, String parameterName);
		void updateValue(int * configProperty, String value, String parameterName);
		void updateValue(bool * configProperty, String value, String parameterName);
		void loadEprom();
		void saveEprom();
	private:
		String getStringEprom(int* address);
		void putStringEprom(int* address, const String);
};

#endif /* CONFIGURATION_H_ */


text:
package weightedroundrobin

import java.util.concurrent.TimeUnit

import org.specs2.mutable.Specification

import scala.collection.mutable.ListBuffer
import scala.concurrent.duration.FiniteDuration
import scala.concurrent.{Await, Future}

/**
  * Created by tgalappathth on 9/29/17.
  */
class RoundRobinSpec extends Specification {

  sequential

  import RoundRobinUtils._

  val nr1 = NeutralResource("NR1", "1")
  val nr2 = NeutralResource("NR2", "2")
  val nr3 = NeutralResource("NR3", "3")
  val nr4 = NeutralResource("NR4", "4")

  // unused weight resources
  val wr1 = WeightedResource("WR1", "1", 11, 11)
  val wr2 = WeightedResource("WR2", "2", 21, 21)
  val wr3 = WeightedResource("WR3", "3", 100, 100)
  val wr4 = WeightedResource("WR4", "4", 51, 51)

  // consumed weight resources
  val uwr1 = WeightedResource("UWR1", "1", 11, 9)
  val uwr2 = WeightedResource("UWR2", "2", 21, 8)
  val uwr3 = WeightedResource("UWR3", "3", 100, 25)
  val uwr4 = WeightedResource("UWR4", "4", 51, 30)

  val expectedException = new RuntimeException("error while consuming resource")

  "RoundRobin" should {
    "rotate `NeutralResource` list when `forResource` with non failing `fn`" in {
      val neutralResourcePool: ListBuffer[NeutralResource] = ListBuffer[NeutralResource](nr1, nr2, nr3, nr4)

      val rr = new RoundRobin[NeutralResource, Seq] {}

      val syncOriginalWithUpdated: (Seq[NeutralResource]) => ListBuffer[NeutralResource] = syncGlobalWithUpdatedResourcePool(neutralResourcePool)
      val (currentResourcePool, result) = rr.forResource(consumeNeutralResource)(plusOneRewarder, divByFivePenalizer, neutralResourcePool)(syncOriginalWithUpdated)

      val expected = ListBuffer(nr2, nr3, nr4, nr1)
      result.isRight must_== true
      result.right.get must_== nr1.value.toInt
      currentResourcePool must_== expected
    }

    "rotate `NeutralResource` list when `forResource` is  run for three times with non failing `fn`" in {
      val neutralResourcePool: ListBuffer[NeutralResource] = ListBuffer[NeutralResource](nr1, nr2, nr3, nr4)

      val rr = new RoundRobin[NeutralResource, Seq] {}

      val syncOriginalWithUpdated: (Seq[NeutralResource]) => ListBuffer[NeutralResource] = syncGlobalWithUpdatedResourcePool(neutralResourcePool)

      rr.forResource(consumeNeutralResource)(plusOneRewarder, divByFivePenalizer, neutralResourcePool)(syncOriginalWithUpdated)
      rr.forResource(consumeNeutralResource)(plusOneRewarder, divByFivePenalizer, neutralResourcePool)(syncOriginalWithUpdated)
      val (currentResourcePool, result) = rr.forResource(consumeNeutralResource)(plusOneRewarder, divByFivePenalizer, neutralResourcePool)(syncOriginalWithUpdated)

      val expected = ListBuffer(nr4, nr1, nr2, nr3)
      result.isRight must_== true
      result.right.get must_== nr3.value.toInt
      currentResourcePool must_== expected
    }

    "rotate `NeutralResource` list when `forResource` with failing `fn`" in {
      val neutralResourcePool: ListBuffer[NeutralResource] = ListBuffer[NeutralResource](nr1, nr2, nr3, nr4)

      val rr = new RoundRobin[NeutralResource, Seq] {}

      val syncOriginalWithUpdated: (Seq[NeutralResource]) => ListBuffer[NeutralResource] = syncGlobalWithUpdatedResourcePool(neutralResourcePool)

      val (currentResourcePool, result) = rr.forResource(consumeNeutralResourceWithError)(plusOneRewarder, divByFivePenalizer, neutralResourcePool)(syncOriginalWithUpdated)

      val expected = ListBuffer(nr2, nr3, nr4, nr1)
      result.isLeft must_== true
      result.left.get must_== expectedException
      currentResourcePool must_== expected
    }

    "rotate `NeutralResource` list when `forResource` is  run for three times with failing `fn`" in {
      val neutralResourcePool: ListBuffer[NeutralResource] = ListBuffer[NeutralResource](nr1, nr2, nr3, nr4)

      val rr = new RoundRobin[NeutralResource, Seq] {}

      val syncOriginalWithUpdated: (Seq[NeutralResource]) => ListBuffer[NeutralResource] = syncGlobalWithUpdatedResourcePool(neutralResourcePool)

      rr.forResource(consumeNeutralResourceWithError)(plusOneRewarder, divByFivePenalizer, neutralResourcePool)(syncOriginalWithUpdated)
      rr.forResource(consumeNeutralResourceWithError)(plusOneRewarder, divByFivePenalizer, neutralResourcePool)(syncOriginalWithUpdated)
      val (currentResourcePool, result) = rr.forResource(consumeNeutralResourceWithError)(plusOneRewarder, divByFivePenalizer, neutralResourcePool)(syncOriginalWithUpdated)

      val expected = ListBuffer(nr4, nr1, nr2, nr3)
      result.isLeft must_== true
      result.left.get must_== expectedException
      currentResourcePool must_== expected
    }

    "rotate `NeutralResource` list when `forResourceAsync` with non failing `fn`" in {
      val neutralResourcePool: ListBuffer[NeutralResource] = ListBuffer[NeutralResource](nr1, nr2, nr3, nr4)

      val rr = new RoundRobin[NeutralResource, Seq] {}

      val syncOriginalWithUpdated: (Seq[NeutralResource]) => ListBuffer[NeutralResource] = syncGlobalWithUpdatedResourcePool(neutralResourcePool)

      val response = rr.forResourceAsync(consumeNeutralResourceAsync)(plusOneRewarder, divByFivePenalizer, neutralResourcePool)(syncOriginalWithUpdated)
      val currentResourcePool = Await.result(response._1, new FiniteDuration(5, TimeUnit.SECONDS))
      val result = Await.result(response._2, new FiniteDuration(5, TimeUnit.SECONDS))

      val expected = ListBuffer(nr2, nr3, nr4, nr1)

      result.isRight must_== true
      result.right.get must_== nr1.value.toInt
      currentResourcePool must_== expected
    }

    "rotate `NeutralResource` list when `forResourceAsync` is  run for three times with non failing `fn`" in {
      val neutralResourcePool: ListBuffer[NeutralResource] = ListBuffer[NeutralResource](nr1, nr2, nr3, nr4)

      val rr = new RoundRobin[NeutralResource, Seq] {}

      val syncOriginalWithUpdated: (Seq[NeutralResource]) => ListBuffer[NeutralResource] = syncGlobalWithUpdatedResourcePool(neutralResourcePool)

      rr.forResourceAsync(consumeNeutralResourceAsync)(plusOneRewarder, divByFivePenalizer, neutralResourcePool)(syncOriginalWithUpdated)
      rr.forResourceAsync(consumeNeutralResourceAsync)(plusOneRewarder, divByFivePenalizer, neutralResourcePool)(syncOriginalWithUpdated)
      val response = rr.forResourceAsync(consumeNeutralResourceAsync)(plusOneRewarder, divByFivePenalizer, neutralResourcePool)(syncOriginalWithUpdated)
      val currentResourcePool = Await.result(response._1, new FiniteDuration(5, TimeUnit.SECONDS))
      val result = Await.result(response._2, new FiniteDuration(5, TimeUnit.SECONDS))

      val expected = ListBuffer(nr4, nr1, nr2, nr3)

      result.isRight must_== true
      result.right.get must_== nr3.value.toInt
      currentResourcePool must_== expected
    }

    "rotate `NeutralResource` list when `forResourceAsync` with failing `fn`" in {
      val neutralResourcePool: ListBuffer[NeutralResource] = ListBuffer[NeutralResource](nr1, nr2, nr3, nr4)

      val rr = new RoundRobin[NeutralResource, Seq] {}

      val syncOriginalWithUpdated: (Seq[NeutralResource]) => ListBuffer[NeutralResource] = syncGlobalWithUpdatedResourcePool(neutralResourcePool)

      val response = rr.forResourceAsync(consumeNeutralResourceAsyncWithError)(plusOneRewarder, divByFivePenalizer, neutralResourcePool)(syncOriginalWithUpdated)
      val currentResourcePool = Await.result(response._1, new FiniteDuration(5, TimeUnit.SECONDS))
      val result = Await.result(response._2, new FiniteDuration(5, TimeUnit.SECONDS))

      val expected = ListBuffer(nr2, nr3, nr4, nr1)

      result.isLeft must_== true
      result.left.get must_== expectedException
      currentResourcePool must_== expected
    }

    "rotate `NeutralResource` list when `forResourceAsync` is  run for three times with failing `fn`" in {
      val neutralResourcePool: ListBuffer[NeutralResource] = ListBuffer[NeutralResource](nr1, nr2, nr3, nr4)

      val rr = new RoundRobin[NeutralResource, Seq] {}

      val syncOriginalWithUpdated: (Seq[NeutralResource]) => ListBuffer[NeutralResource] = syncGlobalWithUpdatedResourcePool(neutralResourcePool)

      rr.forResourceAsync(consumeNeutralResourceAsyncWithError)(plusOneRewarder, divByFivePenalizer, neutralResourcePool)(syncOriginalWithUpdated)
      rr.forResourceAsync(consumeNeutralResourceAsyncWithError)(plusOneRewarder, divByFivePenalizer, neutralResourcePool)(syncOriginalWithUpdated)
      val response = rr.forResourceAsync(consumeNeutralResourceAsyncWithError)(plusOneRewarder, divByFivePenalizer, neutralResourcePool)(syncOriginalWithUpdated)
      val currentResourcePool = Await.result(response._1, new FiniteDuration(5, TimeUnit.SECONDS))
      val result = Await.result(response._2, new FiniteDuration(5, TimeUnit.SECONDS))

      val expected = ListBuffer(nr4, nr1, nr2, nr3)

      result.isLeft must_== true
      result.left.get must_== expectedException
      currentResourcePool must_== expected
    }

    // weight resources with full weight
    "rotate `WeightedResource` list when `forResource` with non failing `fn`" in {
      val weightedResourcesPool: ListBuffer[WeightedResource] = ListBuffer[WeightedResource](wr1, wr2, wr3, wr4)

      val rr = new RoundRobin[WeightedResource, Seq] {}

      val syncOriginalWithUpdated: (Seq[WeightedResource]) => ListBuffer[WeightedResource] = syncGlobalWithUpdatedResourcePool(weightedResourcesPool)

      val (currentResourcePool, result) = rr.forResource(consumeWeightedResource)(plusOneRewarder, divByFivePenalizer, weightedResourcesPool)(syncOriginalWithUpdated)

      result.isRight must_== true
      result.right.get must_== List(wr1, wr2, wr3, wr4).maxBy(_.currentWeight).value.toInt
      currentResourcePool.sortBy(_.currentWeight) must_== ListBuffer(wr1, wr2, wr3, wr4).sortBy(_.currentWeight)
    }

    "rotate `WeightedResource` list when `forResource` is  run for three times with non failing `fn`" in {
      val weightedResourcesPool: ListBuffer[WeightedResource] = ListBuffer[WeightedResource](wr1, wr2, wr3, wr4)

      val rr = new RoundRobin[WeightedResource, Seq] {}

      val syncOriginalWithUpdated: (Seq[WeightedResource]) => ListBuffer[WeightedResource] = syncGlobalWithUpdatedResourcePool(weightedResourcesPool)

      rr.forResource(consumeWeightedResource)(plusOneRewarder, divByFivePenalizer, weightedResourcesPool)(syncOriginalWithUpdated)
      rr.forResource(consumeWeightedResource)(plusOneRewarder, divByFivePenalizer, weightedResourcesPool)(syncOriginalWithUpdated)
      val (currentResourcePool, result) = rr.forResource(consumeWeightedResource)(plusOneRewarder, divByFivePenalizer, weightedResourcesPool)(syncOriginalWithUpdated)

      result.isRight must_== true
      result.right.get must_== List(wr1, wr2, wr3, wr4).maxBy(_.currentWeight).value.toInt
      currentResourcePool.sortBy(_.currentWeight) must_== ListBuffer(wr1, wr2, wr3, wr4).sortBy(_.currentWeight)
    }

    "rotate `WeightedResource` list when `forResource` with failing `fn`" in {
      val weightedResourcesPool: ListBuffer[WeightedResource] = ListBuffer[WeightedResource](wr1, wr2, wr3, wr4)

      val expectedMaxWeightedResource = weightedResourcesPool.maxBy(_.currentWeight)

      val penalizerFn = divByFivePenalizer _

      val rr = new RoundRobin[WeightedResource, Seq] {}

      val syncOriginalWithUpdated: (Seq[WeightedResource]) => ListBuffer[WeightedResource] = syncGlobalWithUpdatedResourcePool(weightedResourcesPool)

      val (currentResourcePool, result) = rr.forResource(consumeWeightedResourceWithError)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)

      result.isLeft must_== true
      result.left.get must_== expectedException
      currentResourcePool.find(_.key == expectedMaxWeightedResource.key).get.currentWeight must_== penalizerFn(expectedMaxWeightedResource.maxWeight)
    }

    "rotate `WeightedResource` list when `forResource` is  run for three times with failing `fn`" in {
      val weightedResourcesPool: ListBuffer[WeightedResource] = ListBuffer[WeightedResource](wr1, wr2, wr3, wr4)

      val penalizerFn = divByFivePenalizer _

      val expectedWeightResourcesPool = weightedResourcesPool.clone()
      (1 to 3).foreach { _ =>
        val mxwr = expectedWeightResourcesPool.maxBy(_.currentWeight)
        val updatedWR = mxwr.copy(currentWeight = penalizerFn(mxwr.currentWeight))
        expectedWeightResourcesPool.update(expectedWeightResourcesPool.indexOf(mxwr), updatedWR)
      }

      val rr = new RoundRobin[WeightedResource, Seq] {}

      val syncOriginalWithUpdated: (Seq[WeightedResource]) => ListBuffer[WeightedResource] = syncGlobalWithUpdatedResourcePool(weightedResourcesPool)

      rr.forResource(consumeWeightedResourceWithError)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)
      rr.forResource(consumeWeightedResourceWithError)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)
      val (currentResourcePool, result) = rr.forResource(consumeWeightedResourceWithError)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)

      result.isLeft must_== true
      result.left.get must_== expectedException
      currentResourcePool.sortBy(_.currentWeight) must_== expectedWeightResourcesPool.sortBy(_.currentWeight)
    }

    "rotate `WeightedResource` list when `forResourceAsync` with non failing `fn`" in {
      val weightedResourcesPool: ListBuffer[WeightedResource] = ListBuffer[WeightedResource](wr1, wr2, wr3, wr4)

      val rr = new RoundRobin[WeightedResource, Seq] {}

      val syncOriginalWithUpdated: (Seq[WeightedResource]) => ListBuffer[WeightedResource] = syncGlobalWithUpdatedResourcePool(weightedResourcesPool)

      val response = rr.forResourceAsync(consumeWeightedResourceAsync)(plusOneRewarder, divByFivePenalizer, weightedResourcesPool)(syncOriginalWithUpdated)
      val currentResourcePool = Await.result(response._1, new FiniteDuration(5, TimeUnit.SECONDS))
      val result = Await.result(response._2, new FiniteDuration(5, TimeUnit.SECONDS))

      result.isRight must_== true
      result.right.get must_== List(wr1, wr2, wr3, wr4).maxBy(_.currentWeight).value.toInt
      currentResourcePool.find(_.key == wr3.key).get.currentWeight must_== wr3.maxWeight
    }

    "rotate `WeightedResource` list when `forResourceAsync` is  run for three times with non failing `fn`" in {
      val weightedResourcesPool: ListBuffer[WeightedResource] = ListBuffer[WeightedResource](wr1, wr2, wr3, wr4)

      val rr = new RoundRobin[WeightedResource, Seq] {}

      val penalizerFn = divByFivePenalizer _

      val syncOriginalWithUpdated: (Seq[WeightedResource]) => ListBuffer[WeightedResource] = syncGlobalWithUpdatedResourcePool(weightedResourcesPool)

      rr.forResourceAsync(consumeWeightedResourceAsync)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)
      rr.forResourceAsync(consumeWeightedResourceAsync)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)
      val response = rr.forResourceAsync(consumeWeightedResourceAsync)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)
      val currentResourcePool = Await.result(response._1, new FiniteDuration(5, TimeUnit.SECONDS))
      val result = Await.result(response._2, new FiniteDuration(5, TimeUnit.SECONDS))

      result.isRight must_== true
      result.right.get must_== List(wr1, wr2, wr3, wr4).maxBy(_.currentWeight).value.toInt
      currentResourcePool.sortBy(_.currentWeight) must_== ListBuffer(wr1, wr2, wr3, wr4).sortBy(_.currentWeight)
    }

    "rotate `WeightedResource` list when `forResourceAsync` with failing `fn`" in {
      val weightedResourcesPool: ListBuffer[WeightedResource] = ListBuffer[WeightedResource](wr1, wr2, wr3, wr4)

      val rr = new RoundRobin[WeightedResource, Seq] {}

      val penalizerFn = divByFivePenalizer _

      val expectedWeightResourcesPool = weightedResourcesPool.clone()

      val mxwr = expectedWeightResourcesPool.maxBy(_.currentWeight)
      val updatedWR = mxwr.copy(currentWeight = penalizerFn(mxwr.currentWeight))
      expectedWeightResourcesPool.update(expectedWeightResourcesPool.indexOf(mxwr), updatedWR)

      val syncOriginalWithUpdated: (Seq[WeightedResource]) => ListBuffer[WeightedResource] = syncGlobalWithUpdatedResourcePool(weightedResourcesPool)

      val response = rr.forResourceAsync(consumeWeightedResourceAsyncWithError)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)
      val currentResourcePool = Await.result(response._1, new FiniteDuration(5, TimeUnit.SECONDS))
      val result = Await.result(response._2, new FiniteDuration(5, TimeUnit.SECONDS))

      result.isLeft must_== true
      result.left.get must_== expectedException
      currentResourcePool.sortBy(_.currentWeight) must_== expectedWeightResourcesPool.sortBy(_.currentWeight)
    }

    "rotate `WeightedResource` list when `forResourceAsync` is  run for three times with failing `fn`" in {
      val weightedResourcesPool: ListBuffer[WeightedResource] = ListBuffer[WeightedResource](wr1, wr2, wr3, wr4)

      val rr = new RoundRobin[WeightedResource, Seq] {}

      val penalizerFn = divByFivePenalizer _

      val expectedWeightResourcesPool = weightedResourcesPool.clone()
      (1 to 3).foreach { _ =>
        val mxwr = expectedWeightResourcesPool.maxBy(_.currentWeight)
        val updatedWR = mxwr.copy(currentWeight = penalizerFn(mxwr.currentWeight))
        expectedWeightResourcesPool.update(expectedWeightResourcesPool.indexOf(mxwr), updatedWR)
      }

      val syncOriginalWithUpdated: (Seq[WeightedResource]) => ListBuffer[WeightedResource] = syncGlobalWithUpdatedResourcePool(weightedResourcesPool)

      rr.forResourceAsync(consumeWeightedResourceAsyncWithError)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)
      rr.forResourceAsync(consumeWeightedResourceAsyncWithError)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)
      val response = rr.forResourceAsync(consumeWeightedResourceAsyncWithError)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)
      val currentResourcePool = Await.result(response._1, new FiniteDuration(5, TimeUnit.SECONDS))
      val result = Await.result(response._2, new FiniteDuration(5, TimeUnit.SECONDS))

      result.isLeft must_== true
      result.left.get must_== expectedException
      currentResourcePool.sortBy(_.currentWeight) must_== expectedWeightResourcesPool.sortBy(_.currentWeight)
    }

    //weight resources with reduced weights
    "rotate consumed `WeightedResource` list when `forResource` with non failing `fn`" in {
      val weightedResourcesPool: ListBuffer[WeightedResource] = ListBuffer[WeightedResource](uwr1, uwr2, uwr3, uwr4)
      val expectedWeightResourcesPool = weightedResourcesPool.clone()

      val rr = new RoundRobin[WeightedResource, Seq] {}

      val syncOriginalWithUpdated: (Seq[WeightedResource]) => ListBuffer[WeightedResource] = syncGlobalWithUpdatedResourcePool(weightedResourcesPool)

      val (currentResourcePool, result) = rr.forResource(consumeWeightedResource)(plusOneRewarder, divByFivePenalizer, weightedResourcesPool)(syncOriginalWithUpdated)

      val rewarderFn = plusOneRewarder _

      val mxwr = expectedWeightResourcesPool.maxBy(_.currentWeight)
      val updatedWR = mxwr.copy(currentWeight = rewarderFn(mxwr.currentWeight))
      expectedWeightResourcesPool.update(expectedWeightResourcesPool.indexOf(mxwr), updatedWR)

      result.isRight must_== true
      result.right.get must_== List(uwr1, uwr2, uwr3, uwr4).maxBy(_.currentWeight).value.toInt
      currentResourcePool.sortBy(_.currentWeight) must_== expectedWeightResourcesPool.sortBy(_.currentWeight)
    }

    "rotate consumed `WeightedResource` list when `forResource` is  run for three times with non failing `fn`" in {
      val weightedResourcesPool: ListBuffer[WeightedResource] = ListBuffer[WeightedResource](uwr1, uwr2, uwr3, uwr4)
      val expectedWeightResourcesPool = weightedResourcesPool.clone()

      val rr = new RoundRobin[WeightedResource, Seq] {}

      val syncOriginalWithUpdated: (Seq[WeightedResource]) => ListBuffer[WeightedResource] = syncGlobalWithUpdatedResourcePool(weightedResourcesPool)

      rr.forResource(consumeWeightedResource)(plusOneRewarder, divByFivePenalizer, weightedResourcesPool)(syncOriginalWithUpdated)
      rr.forResource(consumeWeightedResource)(plusOneRewarder, divByFivePenalizer, weightedResourcesPool)(syncOriginalWithUpdated)
      val (currentResourcePool, result) = rr.forResource(consumeWeightedResource)(plusOneRewarder, divByFivePenalizer, weightedResourcesPool)(syncOriginalWithUpdated)

      val rewarderFn = plusOneRewarder _

      (1 to 3).foreach { _ =>
        val mxwr = expectedWeightResourcesPool.maxBy(_.currentWeight)
        val updatedWR = mxwr.copy(currentWeight = rewarderFn(mxwr.currentWeight))
        expectedWeightResourcesPool.update(expectedWeightResourcesPool.indexOf(mxwr), updatedWR)
      }

      result.isRight must_== true
      result.right.get must_== List(uwr1, uwr2, uwr3, uwr4).maxBy(_.currentWeight).value.toInt
      currentResourcePool.sortBy(_.currentWeight) must_== expectedWeightResourcesPool.sortBy(_.currentWeight)
    }

    "rotate consumed `WeightedResource` list when `forResource` with failing `fn`" in {
      val weightedResourcesPool: ListBuffer[WeightedResource] = ListBuffer[WeightedResource](uwr1, uwr2, uwr3, uwr4)

      val expectedMaxWeightedResource = weightedResourcesPool.maxBy(_.currentWeight)

      val penalizerFn = divByFivePenalizer _

      val rr = new RoundRobin[WeightedResource, Seq] {}

      val syncOriginalWithUpdated: (Seq[WeightedResource]) => ListBuffer[WeightedResource] = syncGlobalWithUpdatedResourcePool(weightedResourcesPool)

      val (currentResourcePool, result) = rr.forResource(consumeWeightedResourceWithError)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)

      result.isLeft must_== true
      result.left.get must_== expectedException
      currentResourcePool.find(_.key == expectedMaxWeightedResource.key).get.currentWeight must_== penalizerFn(expectedMaxWeightedResource.currentWeight)
    }

    "rotate consumed `WeightedResource` list when `forResource` is  run for three times with failing `fn`" in {
      val weightedResourcesPool: ListBuffer[WeightedResource] = ListBuffer[WeightedResource](uwr1, uwr2, uwr3, uwr4)

      val penalizerFn = divByFivePenalizer _

      val expectedWeightResourcesPool = weightedResourcesPool.clone()
      (1 to 3).foreach { _ =>
        val mxuwr = expectedWeightResourcesPool.maxBy(_.currentWeight)
        val updateduwr = mxuwr.copy(currentWeight = penalizerFn(mxuwr.currentWeight))
        expectedWeightResourcesPool.update(expectedWeightResourcesPool.indexOf(mxuwr), updateduwr)
      }

      val rr = new RoundRobin[WeightedResource, Seq] {}

      val syncOriginalWithUpdated: (Seq[WeightedResource]) => ListBuffer[WeightedResource] = syncGlobalWithUpdatedResourcePool(weightedResourcesPool)

      rr.forResource(consumeWeightedResourceWithError)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)
      rr.forResource(consumeWeightedResourceWithError)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)
      val (currentResourcePool, result) = rr.forResource(consumeWeightedResourceWithError)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)

      result.isLeft must_== true
      result.left.get must_== expectedException
      currentResourcePool.sortBy(_.currentWeight) must_== expectedWeightResourcesPool.sortBy(_.currentWeight)
    }

    "rotate consumed `WeightedResource` list when `forResourceAsync` with non failing `fn`" in {
      val weightedResourcesPool: ListBuffer[WeightedResource] = ListBuffer[WeightedResource](uwr1, uwr2, uwr3, uwr4)
      val expectedWeightResourcesPool = weightedResourcesPool.clone()

      val rr = new RoundRobin[WeightedResource, Seq] {}

      val rewarderFn = plusOneRewarder _

      val syncOriginalWithUpdated: (Seq[WeightedResource]) => ListBuffer[WeightedResource] = syncGlobalWithUpdatedResourcePool(weightedResourcesPool)

      val response = rr.forResourceAsync(consumeWeightedResourceAsync)(rewarderFn, divByFivePenalizer, weightedResourcesPool)(syncOriginalWithUpdated)
      val currentResourcePool = Await.result(response._1, new FiniteDuration(5, TimeUnit.SECONDS))
      val result = Await.result(response._2, new FiniteDuration(5, TimeUnit.SECONDS))

      val mxwr = expectedWeightResourcesPool.maxBy(_.currentWeight)
      val updatedWR = mxwr.copy(currentWeight = rewarderFn(mxwr.currentWeight))
      expectedWeightResourcesPool.update(expectedWeightResourcesPool.indexOf(mxwr), updatedWR)

      result.isRight must_== true
      result.right.get must_== List(uwr1, uwr2, uwr3, uwr4).maxBy(_.currentWeight).value.toInt
      currentResourcePool.sortBy(_.currentWeight) must_== expectedWeightResourcesPool.sortBy(_.currentWeight)
    }

    "rotate consumed `WeightedResource` list when `forResourceAsync` is  run for three times with non failing `fn`" in {
      val weightedResourcesPool: ListBuffer[WeightedResource] = ListBuffer[WeightedResource](uwr1, uwr2, uwr3, uwr4)

      val rr = new RoundRobin[WeightedResource, Seq] {}

      val rewarderFn = plusOneRewarder _

      val expectedWeightResourcesPool = weightedResourcesPool.clone()
      (1 to 3).foreach { _ =>
        val mxwr = expectedWeightResourcesPool.maxBy(_.currentWeight)
        val updatedWR = mxwr.copy(currentWeight = rewarderFn(mxwr.currentWeight))
        expectedWeightResourcesPool.update(expectedWeightResourcesPool.indexOf(mxwr), updatedWR)
      }

      val syncOriginalWithUpdated: (Seq[WeightedResource]) => ListBuffer[WeightedResource] = syncGlobalWithUpdatedResourcePool(weightedResourcesPool)

      rr.forResourceAsync(consumeWeightedResourceAsync)(plusOneRewarder, rewarderFn, weightedResourcesPool)(syncOriginalWithUpdated)
      rr.forResourceAsync(consumeWeightedResourceAsync)(plusOneRewarder, rewarderFn, weightedResourcesPool)(syncOriginalWithUpdated)
      val response = rr.forResourceAsync(consumeWeightedResourceAsync)(plusOneRewarder, rewarderFn, weightedResourcesPool)(syncOriginalWithUpdated)
      val currentResourcePool = Await.result(response._1, new FiniteDuration(5, TimeUnit.SECONDS))
      val result = Await.result(response._2, new FiniteDuration(5, TimeUnit.SECONDS))

      result.isRight must_== true
      result.right.get must_== List(uwr1, uwr2, uwr3, uwr4).maxBy(_.currentWeight).value.toInt
      currentResourcePool.sortBy(_.currentWeight) must_== expectedWeightResourcesPool.sortBy(_.currentWeight)
    }

    "rotate consumed `WeightedResource` list when `forResourceAsync` with failing `fn`" in {
      val weightedResourcesPool: ListBuffer[WeightedResource] = ListBuffer[WeightedResource](uwr1, uwr2, uwr3, uwr4)

      val rr = new RoundRobin[WeightedResource, Seq] {}

      val penalizerFn = divByFivePenalizer _

      val expectedWeightResourcesPool = weightedResourcesPool.clone()

      val mxuwr = expectedWeightResourcesPool.maxBy(_.currentWeight)
      val updateduwr = mxuwr.copy(currentWeight = penalizerFn(mxuwr.currentWeight))
      expectedWeightResourcesPool.update(expectedWeightResourcesPool.indexOf(mxuwr), updateduwr)

      val syncOriginalWithUpdated: (Seq[WeightedResource]) => ListBuffer[WeightedResource] = syncGlobalWithUpdatedResourcePool(weightedResourcesPool)

      val response = rr.forResourceAsync(consumeWeightedResourceAsyncWithError)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)
      val currentResourcePool = Await.result(response._1, new FiniteDuration(5, TimeUnit.SECONDS))
      val result = Await.result(response._2, new FiniteDuration(5, TimeUnit.SECONDS))

      result.isLeft must_== true
      result.left.get must_== expectedException
      currentResourcePool.sortBy(_.currentWeight) must_== expectedWeightResourcesPool.sortBy(_.currentWeight)
    }

    "rotate consumed `WeightedResource` list when `forResourceAsync` is  run for three times with failing `fn`" in {
      val weightedResourcesPool: ListBuffer[WeightedResource] = ListBuffer[WeightedResource](uwr1, uwr2, uwr3, uwr4)

      val rr = new RoundRobin[WeightedResource, Seq] {}

      val penalizerFn = divByFivePenalizer _

      val expectedWeightResourcesPool = weightedResourcesPool.clone()
      (1 to 3).foreach { _ =>
        val mxuwr = expectedWeightResourcesPool.maxBy(_.currentWeight)
        val updateduwr = mxuwr.copy(currentWeight = penalizerFn(mxuwr.currentWeight))
        expectedWeightResourcesPool.update(expectedWeightResourcesPool.indexOf(mxuwr), updateduwr)
      }

      val syncOriginalWithUpdated: (Seq[WeightedResource]) => ListBuffer[WeightedResource] = syncGlobalWithUpdatedResourcePool(weightedResourcesPool)

      rr.forResourceAsync(consumeWeightedResourceAsyncWithError)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)
      rr.forResourceAsync(consumeWeightedResourceAsyncWithError)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)
      val response = rr.forResourceAsync(consumeWeightedResourceAsyncWithError)(plusOneRewarder, penalizerFn, weightedResourcesPool)(syncOriginalWithUpdated)
      val currentResourcePool = Await.result(response._1, new FiniteDuration(5, TimeUnit.SECONDS))
      val result = Await.result(response._2, new FiniteDuration(5, TimeUnit.SECONDS))

      result.isLeft must_== true
      result.left.get must_== expectedException
      currentResourcePool.sortBy(_.currentWeight) must_== expectedWeightResourcesPool.sortBy(_.currentWeight)
    }

  }

  def consumeNeutralResource(r: NeutralResource): Int = {
    r.value.toInt
  }

  def consumeNeutralResourceWithError(r: NeutralResource): Int = {
    throw expectedException
  }

  def consumeNeutralResourceAsync(r: NeutralResource): Future[Int] = {
    Future {
      r.value.toInt
    }
  }

  def consumeNeutralResourceAsyncWithError(r: NeutralResource): Future[Int] = {
    Future[Int] {
      throw expectedException
    }
  }

  def consumeWeightedResource(r: WeightedResource): Int = {
    r.value.toInt
  }

  def consumeWeightedResourceWithError(r: WeightedResource): Int = {
    throw expectedException
  }

  def consumeWeightedResourceAsync(r: WeightedResource): Future[Int] = {
    Future {
      r.value.toInt
    }
  }

  def consumeWeightedResourceAsyncWithError(r: WeightedResource): Future[Int] = {
    Future[Int] {
      throw expectedException
    }
  }
}


text:
/**
 * Provides methods used for visually flipping a Game Object.
 * Should be applied as a mixin and not used directly.
 *
 * @name Phaser.GameObjects.Components.Flip
 * @since 3.0.0
 */

var Flip = {

    /**
     * The horizontally flipped state of the Game Object.
     * A Game Object that is flipped horizontally will render inversed on the horizontal axis.
     * Flipping always takes place from the middle of the texture and does not impact the scale value.
     *
     * @name Phaser.GameObjects.Components.Flip#flipX
     * @type {boolean}
     * @default false
     * @since 3.0.0
     */
    flipX: false,

    /**
     * The vertically flipped state of the Game Object.
     * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down)
     * Flipping always takes place from the middle of the texture and does not impact the scale value.
     *
     * @name Phaser.GameObjects.Components.Flip#flipY
     * @type {boolean}
     * @default false
     * @since 3.0.0
     */
    flipY: false,

    /**
     * Toggles the horizontal flipped state of this Game Object.
     *
     * @method Phaser.GameObjects.Components.Flip#toggleFlipX
     * @since 3.0.0
     *
     * @return {this} This Game Object instance.
     */
    toggleFlipX: function ()
    {
        this.flipX = !this.flipX;

        return this;
    },

    /**
     * Toggles the vertical flipped state of this Game Object.
     *
     * @method Phaser.GameObjects.Components.Flip#toggleFlipY
     * @since 3.0.0
     *
     * @return {this} This Game Object instance.
     */
    toggleFlipY: function ()
    {
        this.flipY = !this.flipY;

        return this;
    },

    /**
     * Sets the horizontal flipped state of this Game Object.
     *
     * @method Phaser.GameObjects.Components.Flip#setFlipX
     * @since 3.0.0
     *
     * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped.
     *
     * @return {this} This Game Object instance.
     */
    setFlipX: function (value)
    {
        this.flipX = value;

        return this;
    },

    /**
     * Sets the vertical flipped state of this Game Object.
     *
     * @method Phaser.GameObjects.Components.Flip#setFlipY
     * @since 3.0.0
     *
     * @param {boolean} value - The flipped state. `false` for no flip, or `true` to be flipped.
     *
     * @return {this} This Game Object instance.
     */
    setFlipY: function (value)
    {
        this.flipY = value;

        return this;
    },

    /**
     * Sets the horizontal and vertical flipped state of this Game Object.
     *
     * @method Phaser.GameObjects.Components.Flip#setFlip
     * @since 3.0.0
     *
     * @param {boolean} x - The horizontal flipped state. `false` for no flip, or `true` to be flipped.
     * @param {boolean} y - The horizontal flipped state. `false` for no flip, or `true` to be flipped.
     *
     * @return {this} This Game Object instance.
     */
    setFlip: function (x, y)
    {
        this.flipX = x;
        this.flipY = y;

        return this;
    },

    /**
     * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state.
     *
     * @method Phaser.GameObjects.Components.Flip#resetFlip
     * @since 3.0.0
     *
     * @return {this} This Game Object instance.
     */
    resetFlip: function ()
    {
        this.flipX = false;
        this.flipY = false;

        return this;
    }

};

module.exports = Flip;


text:
namespace Paydock_dotnet_sdk.Models
{
    public class GatewayRequest
    {
        public string type { get; set; }
        public string name { get; set; }
        public string username { get; set; }
        public string password { get; set; }
        public string mode { get; set; }
        public string merchant { get; set; }
        public string key { get; set; }
        public string signature { get; set; }
    }
}


text:
require File.expand_path("spec_helper", File.dirname(__FILE__))

FastGettext.silence_errors

describe GettextI18nRails do
  before do
    GettextI18nRails.translations_are_html_safe = nil
  end

  it "extends all classes with fast_gettext" do
    _('test')
  end

  describe 'translations_are_html_safe' do
    before do
      GettextI18nRails.translations_are_html_safe = nil
    end

    it "makes translations not html_safe by default" do
      _('x').html_safe?.should == false
      s_('x').html_safe?.should == false
      n_('x','y',2).html_safe?.should == false
      String._('x').html_safe?.should == false
      String.s_('x').html_safe?.should == false
      String.n_('x','y',2).html_safe?.should == false
    end

    it "makes instance translations html_safe when wanted" do
      GettextI18nRails.translations_are_html_safe = true
      _('x').html_safe?.should == true
      s_('x').html_safe?.should == true
      n_('x','y',2).html_safe?.should == true
    end

    it "makes class translations html_safe when wanted" do
      GettextI18nRails.translations_are_html_safe = true
      String._('x').html_safe?.should == true
      String.s_('x').html_safe?.should == true
      String.n_('x','y',2).html_safe?.should == true
    end

    it "does not make everything html_safe" do
      'x'.html_safe?.should == false
    end
  end

  it "sets up out backend" do
    I18n.backend.is_a?(GettextI18nRails::Backend).should be_true
  end

  it "has a VERSION" do
    GettextI18nRails::VERSION.should =~ /^\d+\.\d+\.\d+$/
  end

  describe 'FastGettext I18n interaction' do
    before do
      FastGettext.available_locales = nil
      FastGettext.locale = 'de'
    end

    it "links FastGettext with I18n locale" do
      FastGettext.locale = 'xx'
      I18n.locale.should == :xx
    end

    it "does not set an not-accepted locale to I18n.locale" do
      FastGettext.available_locales = ['de']
      FastGettext.locale = 'xx'
      I18n.locale.should == :de
    end

    it "links I18n.locale and FastGettext.locale" do
      I18n.locale = :yy
      FastGettext.locale.should == 'yy'
    end

    it "does not set a non-available locale though I18n.locale" do
      FastGettext.available_locales = ['de']
      I18n.locale = :xx
      FastGettext.locale.should == 'de'
      I18n.locale.should == :de
    end
  end
end


text:
class CMFCToolBarsCommandsListBox : public CListBox
{
// Construction
public:
	CMFCToolBarsCommandsListBox();

// Attributes
protected:
	CSize m_sizeButton;

// Operations
public:

// Overrides
public:
	virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
	virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);

protected:
	virtual void PreSubclassWindow();

// Implementation
public:
	virtual ~CMFCToolBarsCommandsListBox();

protected:
	//{{AFX_MSG(CMFCToolBarsCommandsListBox)
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};

#ifdef _AFX_MINREBUILD
#pragma component(minrebuild, on)
#endif

#ifdef _AFX_PACKING
#pragma pack(pop)
#endif


text:
'use strict';

/* set environment to test */
process.env.NODE_ENV = 'test';
process.env.MONGODB_URI = 'mongodb://localhost/open311-test';


text:
<TITLE>Review for Flirting with Disaster (1996)</TITLE>
<LINK REL="STYLESHEET" TYPE="text/css" HREF="/ramr.css">

Flirting with Disaster (1996)

reviewed by
James Berardinelli

                              FLIRTING WITH DISASTER
                       A film review by James Berardinelli
                        Copyright 1996 James Berardinelli

RATING (0 TO 10): 8.0
Alternative Scale: ***1/2 out of ****

United States, 1996
U.S. Release Date: 3/29/96 (wide)
Running Length: 1:32
MPAA Classification: R (Sex, profanity, mature themes)
Theatrical Aspect Ratio: 1.85:1

Cast: Ben Stiller, Patricia Arquette, Tea Leoni, Mary Tyler Moore,
      George Segal, Alan Alda, Lily Tomlin, Richard Jenkins,
      Josh Brolin, Celia Weston
Director: David O. Russell
Producer: Dean Silvers
Screenplay: David O. Russell
Cinematography: Eric Edwards
Music: Stephen Endleman
U.S. Distributor: Miramax Films

     Different parts of the female anatomy fascinate various men.  Some
are drawn to legs, others to breasts, and others to hips.  But Tony, one
of the many characters to join the bizarre cross-country trek chronicled
in FLIRTING WITH DISASTER, is an arm-pit man, and that says something
about writer/director David O. Russell's flamboyant, irreverent sense of
humor.  This is one director who has not been afflicted with the
infamous "sophomore jinx."  In fact, although FLIRTING WITH DISASTER is
not as corrosive as Russell's debut feature, SPANKING THE MONKEY, it's
just as wild, just as strange, and even funnier.

     Ben Stiller, who has been looking for a worthy comic outlet (it
certainly wasn't his last feature, IF LUCY FELL), finally found a
suitable role.  His neurotic Mel Copland is going through a mid-life
crisis long before mid-life.  A control freak no longer in control, Mel,
who was adopted as a baby, is on a quest for his biological parents.  In
fact, he's so hung up on the issue of his "true identity" that he hasn't
been able to name his 4-month old son.

     Mel's long-suffering wife, Nancy (Patricia Arquette), is trying to
be supportive, but, as Mel's obsession deepens, it becomes more
difficult.  Finally, one day, the adoption agency locates Mel's mother:
a middle-aged woman living in San Diego.  With Tina Kalb (Tia Leoni), a
leggy counselor-in-training from the agency, in tow, Mel and Nancy head
west.  And that's where the disasters, which start with a mistaken
identity and end with a flight across the border into Mexico, begin.
Before it's all over, Mel will have become acquainted with four parents,
two gay federal officers, and a brother who tries to send him on a bad
acid trip.  All the while, he'll be trying to figure out who he is,
whether he wants Tina or Nancy, and why he bothered searching for his
roots in the first place.

     David O. Russell takes the traditional road picture and does some
really strange things with it.  With a view of middle America that David
Lynch would applaud, Russell peels back the layers of normalcy to reveal
the twisted and absurd things that go on underneath.  However, where
Lynch makes his case through violence and mysticism, Russell uses
outrageous humor and parody.  The results are no less telling, however.

     FLIRTING WITH DISASTER is populated with a band of deliciously
offbeat characters.  In addition to the main trio, we meet Mel's adopted
parents, played by a low-key George Segal and a high-strung Mary Tyler
Moore, Mel's real parents (Alan Alda and Lily Tomlin), and the two Feds
(Josh Brolin as Tony and Richard Jenkins as Paul) who join the entourage
midway through their trek from New York to California to Michigan to New
Mexico.

     Each new port of call offers a surprise.  If it's not a false lead,
it likely involves some time in handcuffs.  Russell delights in
stringing us along with Mel as his search becomes increasingly more
surreal.  Like the main character in SPANKING THE MONKEY, Mel is trapped
by circumstances beyond his control.  But if there's one lesson he
learns, it's that sometimes it's better to appreciate what you have
instead of yearning for what you don't.  To be sure, Mel grows from his
experience, but if he had it to do over again, he'd probably stay home.

     Russell has paced his film perfectly, gradually building from the
relatively normal to the extremely strange, and heightening the humor
with each new twist.  FLIRTING WITH DISASTER has its tongue firmly
planted in its cheek the entire way; there's no opportunity for serious
introspection.  By the time the ninety-minute film has expired, you'll
be glad you joined Mel and company on this hilariously eccentric
journey.

- James Berardinelli
e-mail: berardin@bc.cybernex.net
web: http://www.cybernex.net/~berardin

The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).

The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.

Please direct comments/criticisms of the review to relevant newsgroups.

Broken URLs inthe reviews are the responsibility of the author.

The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.

Related links: index of all rec.arts.movies.reviews reviews


text:
FROM ubuntu:14.04

MAINTAINER Istvan Szenasi <szeist@gmail.com>

ENV DEBIAN_FRONTEND noninteractive

RUN echo "deb http://archive.ubuntu.com/ubuntu trusty main restricted universe" > /etc/apt/sources.list ;\
    echo "deb http://security.ubuntu.com/ubuntu trusty-security main restricted universe" >> /etc/apt/sources.list ;\
    apt-get update -q ;\
    apt-get upgrade -y -q ;\
    apt-get dist-upgrade -y -q

RUN apt-get install -y -q php5-dev php5-mcrypt php5-curl php5-pgsql php5-mysql php5-sqlite php5-mongo php5-memcached php5-xdebug php-apc php5-imagick php5-gd php5-geoip gcc git libpcre3-dev

RUN git clone --depth=1 git://github.com/phalcon/cphalcon.git /usr/local/src/cphalcon
RUN cd /usr/local/src/cphalcon/build && ./install ;\
    echo "extension=phalcon.so" > /etc/php5/mods-available/phalcon.ini ;\
    php5enmod phalcon

RUN apt-get clean

ENV DEBIAN_FRONTEND dialog


text:
package edu.usc.irds.sparkler;

import org.apache.commons.io.IOUtils;
import org.yaml.snakeyaml.Yaml;

import java.io.InputStream;
import java.util.Map;
import java.util.UUID;

/**
 * A static container for all the constants
 * (NOTE: interface is used to make all the fields as public static final )
 */
public interface Constants {

    interface key { //config key name

        //ID for config
        @ConfigKey
        String UUID_KEY = "sparkler.conf.uuid";

        // General Properties
        @ConfigKey
        String CRAWLDB = "crawldb.uri";

        // Apache Spark Properties
        @ConfigKey
        String SPARK_MASTER = "spark.master";

        // Apache Kafka Properties
        @ConfigKey
        String KAFKA_ENABLE = "kafka.enable";

        @ConfigKey
        String KAFKA_LISTENERS = "kafka.listeners";

        @ConfigKey
        String KAFKA_TOPIC = "kafka.topic";

        // HTTP Properties

        // Database Properties

        // Generator Properties
        @ConfigKey(type = int.class)
        String GENERATE_TOPN = "generate.topn";

        @ConfigKey(type = int.class)
        String GENERATE_TOP_GROUPS = "generate.top.groups";

        @ConfigKey
        String GENERATE_SORTBY = "generate.sortby";

        @ConfigKey
        String GENERATE_GROUPBY = "generate.groupby";

        // Fetcher Properties
        @ConfigKey(type = int.class)
        String FETCHER_SERVER_DELAY = "fetcher.server.delay";

        // Parser Properties

        // Plugin Properties
        @ConfigKey
        String PLUGINS_BUNDLE_DIRECTORY = "plugins.bundle.directory";

        @ConfigKey
        String PLUGINS = "plugins";

        @ConfigKey
        String ACTIVE_PLUGINS = "plugins.active";

        @ConfigKey
        String FETCHER_HEADERS = "fetcher.headers";

        @ConfigKey
        String FETCHER_USER_AGENTS = "fetcher.user.agents";
    }

    abstract class defaults {
        /**
         * Create configuration instance for Sparkler
         */
        public static SparklerConfiguration newDefaultConfig(){
            //FIXME: needs rework!
            Yaml yaml = new Yaml();
            InputStream input = null;
            SparklerConfiguration sparklerConf = null;
            try {
                input = Constants.class.getClassLoader().getResourceAsStream(file.SPARKLER_DEFAULT);
                Map<String,Object> yamlMap = (Map<String, Object>) yaml.load(input);
                sparklerConf = new SparklerConfiguration(yamlMap);

                //input = Constants.class.getClassLoader().getResourceAsStream(file.SPARKLER_SITE);
                //if(sparklerSite != null)
                //    sparklerConf.mask(sparklerSite);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                IOUtils.closeQuietly(input);
            }

            if (sparklerConf != null) {
                sparklerConf.put(key.UUID_KEY, UUID.randomUUID().toString());
            }

            return sparklerConf;
        }
    }

    interface file {
        String SPARKLER_DEFAULT = "sparkler-default.yaml";
        String SPARKLER_SITE = "sparkler-site.yaml";
        String CONF_DIR = "conf";

        /**
         * Apache Felix Framework Factory META file
         */
        String FELIX_FRAMEWORK_FACTORY = "META-INF/services/org.osgi.framework.launch.FrameworkFactory";
        /**
         * Specifying Apache Felix bundle directory.
         * TODO:Should come from Sparkler Config
         **/
        //String FELIX_BUNDLE_DIR = key.PLUGINS_BUNDLE_DIRECTORY;
        //String FELIX_BUNDLE_DIR = "../bundles";
        //String FELIX_BUNDLE_DIR = "/Users/karanjeetsingh/git_workspace/madhav-sparkler/sparkler-app/bundles";

        /**
         * Apache Felix configuration properties file
         * TODO:Should come from Sparler Config
         */
        String FELIX_CONFIG = "felix-config.properties";
    }

    interface solr { // Solr Fields
        String ID = "id";
        String CRAWL_ID = "crawl_id";
        String URL = "url";
        String GROUP = "group";
        String FETCH_TIMESTAMP = "fetch_timestamp";
        String RETRIES_SINCE_FETCH = "retries_since_fetch";
        String NUM_FETCHES = "numFetches";
        String DISCOVER_DEPTH = "discover_depth";
        String FETCH_DEPTH = "fetch_depth";
        String SCORE = "score";
        String STATUS = "status";
        String LAST_UPDATED_AT = "last_updated_at";
        String EXTRACTED_TEXT = "extracted_text";
        String CONTENT_TYPE = "content_type";
        String FETCH_STATUS_CODE = "fetch_status_code";
        String SIGNATURE = "signature";
        String OUTLINKS = "outlinks";
        String RELATIVE_PATH = "relative_path";
        String DEDUPE_ID = "dedupe_id";
        String MD_SUFFIX = "_md";
        String HDR_SUFFIX = "_hd";
    }

}


text:
package commandsloader_test

import (
	"fmt"
	"os"
	"path/filepath"
	"strings"

	"github.com/cloudfoundry/cli/cf/commandregistry"
	"github.com/cloudfoundry/cli/commandsloader"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("CommandsLoader", func() {
	It("references all command packages so all commands can be registered in commandregistry", func() {
		commandsloader.Load()

		count := walkDirAndCountCommand("../cf/commands")
		Expect(commandregistry.Commands.TotalCommands()).To(Equal(count))
	})
})

func walkDirAndCountCommand(path string) int {
	cmdCount := 0

	filepath.Walk(path, func(p string, info os.FileInfo, err error) error {
		if err != nil {
			fmt.Println("Error walking commands directories:", err)
			return err
		}

		dir := filepath.Dir(p)

		if !info.IsDir() && !strings.HasSuffix(dir, "fakes") {
			if strings.HasSuffix(info.Name(), ".go") && !strings.HasSuffix(info.Name(), "_test.go") {
				cmdCount += 1
			}
		}
		return nil
	})

	return cmdCount
}


text:
// apitouch.js
// Touch a function of all loaded apis
// © Harald Rudell 2013 MIT License

var rqsm = require('./rqs')
var apierror = require('./apierror')

exports.touchApis = touchApis

var time1s = 1e3
var defaultTimeout = time1s
/*
Invoke a function on all registered apis
opts: object
.apiMap: object, the map of apis
.timeout: optional number, default 1000, the timeout to use for each call
.fName: string, the function name to invoke
cb(err) function

errors are emitted by apierror
*/
function touchApis(opts, cb) {
	if (!opts) opts = {}
	var isError
	// we need our own rqs, because we shut it down
	var id = (apierror.init(true) || apierror.init()).id
	var rqsTouch = rqsm.getRqs(apierror.emitError, id + ' ' + opts.fName, opts.timeout != null ? opts.timeout : defaultTimeout)
	var cbCounter = 1

	// iterate over all known apis
	for (var apiName in opts.apiMap) {
		var fn = opts.apiMap[apiName][opts.fName]
		if (typeof fn == 'function') {
			cbCounter++
			invokeApi(fn, apiName, end)
		}
	}
	end()

	function invokeApi(fn, apiName) {
		var timer = rqsTouch.addRq(apiName)
		fn(checkResult)

		function checkResult(err) {
			timer.clear()
			end(err)
		}
	}

	function end(err) {
		if (!--cbCounter) rqsTouch.shutdown()
		if (!err) {
			if (!cbCounter && !isError) cb()
		} else {
			apierror.emitError.apply(this, Array.prototype.slice.call(arguments))
			if (!isError) {
				isError = true
				cb(err)
			}
		}
	}
}


text:
namespace mojo {
namespace test {

namespace {

using MapTest = testing::Test;

MAP_COMMON_TEST(Map, NullAndEmpty)
MAP_COMMON_TEST(Map, InsertWorks)
MAP_COMMON_TEST(Map, TestIndexOperator)
MAP_COMMON_TEST(Map, TestIndexOperatorAsRValue)
MAP_COMMON_TEST(Map, TestIndexOperatorMoveOnly)
MAP_COMMON_TEST(Map, MapArrayClone)
MAP_COMMON_TEST(Map, ArrayOfMap)

TEST_F(MapTest, ConstructedFromArray) {
  Array<String> keys(kStringIntDataSize);
  Array<int> values(kStringIntDataSize);
  for (size_t i = 0; i < kStringIntDataSize; ++i) {
    keys[i] = kStringIntData[i].string_data;
    values[i] = kStringIntData[i].int_data;
  }

  Map<String, int> map(std::move(keys), std::move(values));

  for (size_t i = 0; i < kStringIntDataSize; ++i) {
    EXPECT_EQ(kStringIntData[i].int_data,
              map.at(mojo::String(kStringIntData[i].string_data)));
  }
}

TEST_F(MapTest, DecomposeMapTo) {
  Array<String> keys(kStringIntDataSize);
  Array<int> values(kStringIntDataSize);
  for (size_t i = 0; i < kStringIntDataSize; ++i) {
    keys[i] = kStringIntData[i].string_data;
    values[i] = kStringIntData[i].int_data;
  }

  Map<String, int> map(std::move(keys), std::move(values));
  EXPECT_EQ(kStringIntDataSize, map.size());

  Array<String> keys2;
  Array<int> values2;
  map.DecomposeMapTo(&keys2, &values2);
  EXPECT_EQ(0u, map.size());

  EXPECT_EQ(kStringIntDataSize, keys2.size());
  EXPECT_EQ(kStringIntDataSize, values2.size());

  for (size_t i = 0; i < kStringIntDataSize; ++i) {
    // We are not guaranteed that the copies have the same sorting as the
    // originals.
    String key = kStringIntData[i].string_data;
    int value = kStringIntData[i].int_data;

    bool found = false;
    for (size_t j = 0; j < keys2.size(); ++j) {
      if (keys2[j] == key) {
        EXPECT_EQ(value, values2[j]);
        found = true;
        break;
      }
    }

    EXPECT_TRUE(found);
  }
}

TEST_F(MapTest, Insert_Copyable) {
  ASSERT_EQ(0u, CopyableType::num_instances());
  mojo::Map<mojo::String, CopyableType> map;
  std::vector<CopyableType*> value_ptrs;

  for (size_t i = 0; i < kStringIntDataSize; ++i) {
    const char* key = kStringIntData[i].string_data;
    CopyableType value;
    value_ptrs.push_back(value.ptr());
    map.insert(key, value);
    ASSERT_EQ(i + 1, map.size());
    ASSERT_EQ(i + 1, value_ptrs.size());
    EXPECT_EQ(map.size() + 1, CopyableType::num_instances());
    EXPECT_TRUE(map.at(key).copied());
    EXPECT_EQ(value_ptrs[i], map.at(key).ptr());
    map.at(key).ResetCopied();
    EXPECT_TRUE(map);
  }

  // std::map doesn't have a capacity() method like std::vector so this test is
  // a lot more boring.

  map = nullptr;
  EXPECT_EQ(0u, CopyableType::num_instances());
}

TEST_F(MapTest, Insert_MoveOnly) {
  ASSERT_EQ(0u, MoveOnlyType::num_instances());
  mojo::Map<mojo::String, MoveOnlyType> map;
  std::vector<MoveOnlyType*> value_ptrs;

  for (size_t i = 0; i < kStringIntDataSize; ++i) {
    const char* key = kStringIntData[i].string_data;
    MoveOnlyType value;
    value_ptrs.push_back(value.ptr());
    map.insert(key, std::move(value));
    ASSERT_EQ(i + 1, map.size());
    ASSERT_EQ(i + 1, value_ptrs.size());
    EXPECT_EQ(map.size() + 1, MoveOnlyType::num_instances());
    EXPECT_TRUE(map.at(key).moved());
    EXPECT_EQ(value_ptrs[i], map.at(key).ptr());
    map.at(key).ResetMoved();
    EXPECT_TRUE(map);
  }

  // std::map doesn't have a capacity() method like std::vector so this test is
  // a lot more boring.

  map = nullptr;
  EXPECT_EQ(0u, MoveOnlyType::num_instances());
}

TEST_F(MapTest, IndexOperator_MoveOnly) {
  ASSERT_EQ(0u, MoveOnlyType::num_instances());
  mojo::Map<mojo::String, MoveOnlyType> map;
  std::vector<MoveOnlyType*> value_ptrs;

  for (size_t i = 0; i < kStringIntDataSize; ++i) {
    const char* key = kStringIntData[i].string_data;
    MoveOnlyType value;
    value_ptrs.push_back(value.ptr());
    map[key] = std::move(value);
    ASSERT_EQ(i + 1, map.size());
    ASSERT_EQ(i + 1, value_ptrs.size());
    EXPECT_EQ(map.size() + 1, MoveOnlyType::num_instances());
    EXPECT_TRUE(map.at(key).moved());
    EXPECT_EQ(value_ptrs[i], map.at(key).ptr());
    map.at(key).ResetMoved();
    EXPECT_TRUE(map);
  }

  // std::map doesn't have a capacity() method like std::vector so this test is
  // a lot more boring.

  map = nullptr;
  EXPECT_EQ(0u, MoveOnlyType::num_instances());
}

TEST_F(MapTest, STLToMojo) {
  std::map<std::string, int> stl_data;
  for (size_t i = 0; i < kStringIntDataSize; ++i)
    stl_data[kStringIntData[i].string_data] = kStringIntData[i].int_data;

  Map<String, int32_t> mojo_data = Map<String, int32_t>::From(stl_data);
  for (size_t i = 0; i < kStringIntDataSize; ++i) {
    EXPECT_EQ(kStringIntData[i].int_data,
              mojo_data.at(kStringIntData[i].string_data));
  }
}

TEST_F(MapTest, MojoToSTL) {
  Map<String, int32_t> mojo_map;
  for (size_t i = 0; i < kStringIntDataSize; ++i)
    mojo_map.insert(kStringIntData[i].string_data, kStringIntData[i].int_data);

  std::map<std::string, int> stl_map =
      mojo_map.To<std::map<std::string, int>>();
  for (size_t i = 0; i < kStringIntDataSize; ++i) {
    auto it = stl_map.find(kStringIntData[i].string_data);
    ASSERT_TRUE(it != stl_map.end());
    EXPECT_EQ(kStringIntData[i].int_data, it->second);
  }
}

TEST_F(MapTest, MoveFromAndToSTLMap_Copyable) {
  std::map<int32_t, CopyableType> map1;
  map1.insert(std::make_pair(123, CopyableType()));
  map1[123].ResetCopied();

  Map<int32_t, CopyableType> mojo_map(std::move(map1));
  ASSERT_EQ(1u, mojo_map.size());
  ASSERT_NE(mojo_map.end(), mojo_map.find(123));
  ASSERT_FALSE(mojo_map[123].copied());

  std::map<int32_t, CopyableType> map2(mojo_map.PassStorage());
  ASSERT_EQ(1u, map2.size());
  ASSERT_NE(map2.end(), map2.find(123));
  ASSERT_FALSE(map2[123].copied());

  ASSERT_EQ(0u, mojo_map.size());
  ASSERT_TRUE(mojo_map.is_null());
}

TEST_F(MapTest, MoveFromAndToSTLMap_MoveOnly) {
  std::map<int32_t, MoveOnlyType> map1;
  map1.insert(std::make_pair(123, MoveOnlyType()));

  Map<int32_t, MoveOnlyType> mojo_map(std::move(map1));
  ASSERT_EQ(1u, mojo_map.size());
  ASSERT_NE(mojo_map.end(), mojo_map.find(123));

  std::map<int32_t, MoveOnlyType> map2(mojo_map.PassStorage());
  ASSERT_EQ(1u, map2.size());
  ASSERT_NE(map2.end(), map2.find(123));

  ASSERT_EQ(0u, mojo_map.size());
  ASSERT_TRUE(mojo_map.is_null());
}

}  // namespace
}  // namespace test
}  // namespace mojo


text:
using System;
using System.Collections.Generic;

namespace Quidjibo.Exceptions
{
    public class QuidjiboBuilderException : Exception
    {
        public List<string> Errors;

        public QuidjiboBuilderException(List<string> errors, string message) : base(message)
        {
            Errors = errors;
        }
    }
}


text:
package org.modelio.juniper;

import java.io.IOException;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

import mpi.MPI;

import org.modelio.juniper.data.MethodInvocation;
import org.modelio.juniper.data.MethodReturn;
import org.modelio.juniper.data.partitioning.BroadcastDataPartitioner;
import org.modelio.juniper.data.partitioning.DataPartitioner;
import org.modelio.juniper.data.partitioning.DataPartitioningStrategy;
import org.modelio.juniper.platform.JuniperProgram;

import eu.juniper.platform.models.ApplicationModel;
import eu.juniper.platform.models.auxiliary.CloudNode;
import eu.juniper.platform.models.auxiliary.DataConnection;
import eu.juniper.platform.models.auxiliary.Program;

/**
 * The communication toolkit that abstracts MPI communication details from JUNIPER programs.
 *
 * @author marcos.almeida@softeam.fr
 */
public class CommunicationToolkit {

	private ExecutionLogger logger;
	private CommunicationSubsystem<String>  platformCommunicationSubsystem;

	/**
	 * @param juniperProgram the juniper program associated with this toolkit object
	 */
	public CommunicationToolkit(JuniperProgram juniperProgram) {
		this.thisProgram = juniperProgram;
		this.platformCommunicationSubsystem = new JuniperPlatformCommunicationSubsystem(thisProgram);
	}

	/**
	 * @param proxy
	 * @return
	 */
	public int getGroupSize(Object proxy) {
		ProxyFor proxyFor = this.requiredProxies.get(proxy);
		try {
			String dataConnectionName = getOutboundDataConnectionForProgram(proxyFor.getProgram());
			return getPartitionSizeForDataConnection(dataConnectionName);
		} catch (Exception e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}
	}

	// XXX: The proxies generated by this interface are probably not synchronized!
	/**
	 * Generates a proxy to the given interface that implements method calls as MPI communication.
	 *
	 * IMPORTANT: void methods are implemented as asynchronous method calls, whereas other methods are implemented as synchronous method calls.
	 *
	 * @param program The target JUNIPER program.
	 * @param iface   The interface provided by the target program.
	 * @return the proxy
	 */
	@SuppressWarnings("rawtypes")
	public Object getProxyToInterface(final Class program, final Class iface) {

		try {
			Object proxy = Proxy.newProxyInstance(program.getClassLoader(),
					new Class[] { iface }, new InvocationHandler() {

						public Object invoke(Object obj, Method m, Object[] args)
								throws Throwable {
							if ("hashCode".equals(m.getName())) {
								return program.hashCode() + iface.hashCode();
							}

							if (args == null) {
								args = new Object[0];
							}
							String dataConnectionName = getOutboundDataConnectionForProgram(program);
							int    nbPartitions = getPartitionSizeForDataConnection(dataConnectionName);
							Serializable token = logger.logSendBefore(program, m);

							if (isOneToAllDataConnection(dataConnectionName)) {
								DataPartitioner partitioner = null;
								if (m.isAnnotationPresent(DataPartitioningStrategy.class)) {
									DataPartitioningStrategy partitioningStrategy = m.getAnnotation(DataPartitioningStrategy.class);
									partitioner = (DataPartitioner) partitioningStrategy.partitioner().newInstance();
								} else {
									partitioner = new BroadcastDataPartitioner();
								}

								ArrayList<Serializable> toSend = new ArrayList<Serializable>(nbPartitions);
								Object argument = args[0];
								if (argument instanceof Collection) {
									for(Collection collection : partitioner.partition(nbPartitions, (Collection) argument)) {
										toSend.add(
												new MethodInvocation(iface.getName(),
																	 m.getName(),
																	 new Serializable[]{(Serializable) collection},
																	 token));
									}
								} else {
									for(int i=0;i<nbPartitions; ++i) {
										toSend.add(
												new MethodInvocation(iface.getName(),
																	 m.getName(),
																	 new Serializable[]{(Serializable) argument},
																	 token));
									}
								}
								platformCommunicationSubsystem.sendObjects(dataConnectionName, toSend);
							} else {
								platformCommunicationSubsystem.sendObject(dataConnectionName,
										new MethodInvocation(iface.getName(), m.getName(), Arrays.copyOf(args, args.length, Serializable[].class), token));
							}

							if (!Void.TYPE.equals(m.getReturnType())) {
								MethodReturn mr = (MethodReturn) platformCommunicationSubsystem.receiveReturnValue(dataConnectionName);
								Object ret = mr.getValue();

								logger.logSendAfter(program, m, token);
								return ret;
							} else {
								logger.logSendAfter(program, m, token);
								return null;
							}
						}
					});
			registerProxy(proxy, program, iface);
			return proxy;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	protected boolean isOneToAllDataConnection(String dataConnectionName) {
		ApplicationModel model = this.thisProgram.getJuniperPlatform().getApplicationModel();
		DataConnection dataConnection = model.getCommunicationModel().getDataConnectionByName(dataConnectionName);
		return "one_to_all".equals(dataConnection.getType());
	}

	private class ProxyFor {
		private Class program;
		private Class iface;
		public ProxyFor(Class program, Class iface) {
			super();
			this.program = program;
			this.iface = iface;
		}
		public Class getProgram() {
			return program;
		}
		public Class getIface() {
			return iface;
		}

	}

	@SuppressWarnings("rawtypes")
	private HashMap<Object, ProxyFor> requiredProxies = new HashMap<Object, ProxyFor>();

	private void registerProxy(Object proxy, Class program, Class iface) {
		requiredProxies.put(proxy, new ProxyFor(program, iface));
	}

	private String getOutboundDataConnectionForProgram(Class program) throws Exception {
		ApplicationModel model = this.thisProgram.getJuniperPlatform().getApplicationModel();
		int otherRank = getRank(program);
		ArrayList<String> otherGroups = model.getGroupModel().getGroupsOfMpiRank(otherRank);

		for(String dataConnectionName : this.thisProgram.getOutboundConnections()) {
			DataConnection dataConnection = model.getCommunicationModel().getDataConnectionByName(dataConnectionName);
			if (otherGroups.contains(dataConnection.getReceiverGroup())) {
				return dataConnectionName;
			}
		}
		throw new RuntimeException("Outbound data connection for " + program.getSimpleName() + " not found!");
	}

	private int getPartitionSizeForDataConnection(String dataConnectionName) throws Exception {
		ApplicationModel model = this.thisProgram.getJuniperPlatform().getApplicationModel();
		DataConnection dataConnection = model.getCommunicationModel().getDataConnectionByName(dataConnectionName);
		return model.getGroupModel().getGroupSize(dataConnection.getReceiverGroup());
	}

	private Class getSourceProgramClassForInboundDataConnection(String dataConnectionName) throws ClassNotFoundException {
		ApplicationModel model = this.thisProgram.getJuniperPlatform().getApplicationModel();
		DataConnection dataConnection = model.getCommunicationModel().getDataConnectionByName(dataConnectionName);

		String rank = model.getGroupModel().getMpiglobalranksByGroupName(dataConnection.getSenderGroup()).get(0);
		String programName = model.getGroupModel().getProgramNameForGlobalRank(rank);

		return Class.forName(model.getProgramModel().getProgramByName(programName).getJavaClass());
	}

	@SuppressWarnings("rawtypes")
	private HashMap<Class, Set<Object>> providedInterfaces = new HashMap<Class, Set<Object>>();
	private JuniperProgram thisProgram;

	public JuniperProgram getJuniperProgram() {
		return thisProgram;
	}

	/**
	 * Initializes communication interfaces for a given JUNIPER program
	 *
	 * @param program the JUNIPER program
	 */
	public void initProgramCommunication() {
		System.out.println("[ "+ this.thisProgram.getClass().getSimpleName() + "] init");
		logger = new ExecutionLogger(this.thisProgram);
	}

	/**
	 * Initializes communication interfaces for a given JUNIPER program
	 *
	 * @param exclusionList file containing the list of excluded attributes at communication
	 * @throws IOException if there is an error reading the exclusion list
	 */
	private void initProgramCommunication(String exclusionListFileName) throws IOException {
		initProgramCommunication();
	}

	/**
	 * Initializes a provided interface of the JUNIPER program calling this method.
	 *
	 * @param target the JUNIPER program that requires this interface.
	 * @param impl   an implementation to the provided interface provided by the JUNIPER program calling this method.
	 */
	public void initProvidedInterface(
			@SuppressWarnings("rawtypes") final Class target, final Object impl) {
		Set<Object> interfaces = providedInterfaces.get(target);
		if (interfaces == null) {
			interfaces = new HashSet<Object>();
			providedInterfaces.put(target, interfaces);
		}

		interfaces.add(impl);
	}

	// TODO: Delete
	private int getRank(@SuppressWarnings("rawtypes") Class program)
			throws Exception {
		String rankStr = System.getProperty(program.getName()+"_rank");
		if (rankStr != null) {
			return Integer.parseInt(rankStr);
		} else {
			try {
				Field rankField = program.getDeclaredField("RANK");
				rankField.setAccessible(true);
				int ret = (Integer) rankField.get(null);
				return ret;
			} catch(Exception e) {
				if (thisProgram instanceof JuniperProgram) {
					Integer rank = getRankFromApplicationModel(((JuniperProgram)thisProgram).getApplicationModel(), program.getName());
					if (rank != null) {
						return rank;
					}
				}
				throw new RuntimeException("Can't run without a rank for: "+ program.getName());
			}
		}
	}

	private Integer getRankFromApplicationModel(
			ApplicationModel applicationModel, String programClassName) throws Exception {
		Program program = applicationModel.getProgramModel().getProgramByJavaClassName(programClassName);
		for(int i=0;i<MPI.COMM_WORLD.getSize();++i) {
			CloudNode node = applicationModel.getDeploymentModel().getCloudNodeByMpiglobalrank(i);
			String programName = applicationModel.getGroupModel().getProgramNameForGlobalRank(""+i);
			if (programName.equals(program.getName())) {
				return i;
			}
		}
		return null;
	}

	/**
	 * Fetches MPI messages and distributes them to the interface implementations provided to initProvidedInterface
	 *
         * @return a number of (received and) processed messages
	 * @throws Exception If a network error occurs at MPI level
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public int processReceivedMessages() throws Exception {
                int processedMessages = 0;
		for(String dataConnectionName : this.thisProgram.getInboundConnections()) {
			if (platformCommunicationSubsystem.hasObject(dataConnectionName)) {
				Serializable message = platformCommunicationSubsystem.receiveObject(dataConnectionName);
				MethodInvocation mi = null;
				if (message instanceof MethodInvocation) {
					mi = (MethodInvocation) message;
				} else if (message instanceof ArrayList) {
					ArrayList<Object> messages = (ArrayList<Object>) message;
					mi = (MethodInvocation) messages.get(0); // TODO support multiple method calls!

					// initializes the collection with the values in the first message
					Collection cmi = ((Collection)mi.getParameters()[0]);

					// adds the values from the other messages to cmi
					for (int i=1;i<messages.size();++i) {
						MethodInvocation mib = (MethodInvocation) messages.get(i);
						Collection cmib = ((Collection)mib.getParameters()[0]);
						cmi.addAll(cmib);
					}

					// since it modifies cmi and cmi is the parameters of message 1...
					// it will call the method of message 1 with the parameters of all messages
				}

				Class sourceProgramClass = getSourceProgramClassForInboundDataConnection(dataConnectionName);
				for(Object proxy : providedInterfaces.get(sourceProgramClass)) {
					if (implementsInterface(proxy, mi.getInterfaceName())) {
						for (Method m : proxy.getClass().getMethods()) {
							if (m.getName().equals(mi.getMethodName())) {
								if (!m.isAccessible()) {
									m.setAccessible(true);
								}

								logger.logReceive(sourceProgramClass, m, mi.getToken());
								Object ret = m.invoke(proxy, mi.getParameters());
								if (!Void.TYPE.equals(m.getReturnType())) {
									// TODO: add this to generator!
									platformCommunicationSubsystem.sendReturnValue(dataConnectionName, new MethodReturn(ret));
								}
							}
						}
					}
				}

                processedMessages++;
			} else {
				Thread.yield();
			}
		}
                return processedMessages;
	}

	private static boolean implementsInterface(Object proxy,
			String interfaceName) {
		for(@SuppressWarnings("rawtypes") Class iface : proxy.getClass().getInterfaces()) {
			if (iface.getName().equals(interfaceName)) {
				return true;
			}
		}
		return false;
	}

}


text:
from unittest.case import TestCase
from unittest.mock import patch

from huaula.tombola import Tombola

class TombolaTestes(TestCase):
    def test_carregar(self):
        tombola = Tombola()
        tombola.carregar([1, 2])
        self.assertListEqual([1, 2], tombola._elementos)
        tombola.carregar([3, 4])
        self.assertListEqual([1, 2, 3, 4, ], tombola._elementos)

    @patch('huaula.tombola.random')
    def test_misturar(self, random_mock):
        random_mock.shuffle = shuffle_mock
        tombola = Tombola()
        items = [1, 2]
        tombola.carregar(items)
        tombola.misturar()
        self.assertEqual([2, 1], tombola._elementos)

    @patch('huaula.tombola.random')
    def test_sortear(self, random_mock):
        random_mock.shuffle = shuffle_mock
        tombola_obj = Tombola()
        items = [1, 2]
        tombola_obj.carregar(items)
        tombola_obj.misturar()
        valor_sorteado = tombola_obj.sortear()
        self.assertEqual(1, valor_sorteado)
        valor_sorteado = tombola_obj()
        self.assertEqual(2, valor_sorteado)

def shuffle_mock(lista):
    lista.reverse()


text:
class Solution {
    public String largestMerge(String w1, String w2) {
        StringBuilder ans = new StringBuilder();
        int m = w1.length(), n = w2.length();
        int i = 0, j = 0;
        while (i < m && j < n) // 字符串比较lexicographically大小,用compareTo()方法!!!
            ans.append(w1.substring(i).compareTo(w2.substring(j)) > 0 ? w1.charAt(i++) : w2.charAt(j++));
        ans.append(w1.substring(i));
        ans.append(w2.substring(j));
        return ans.toString();
    }
}


text:
namespace LemonStorage.Classes.PeripheralDevices
{
    using LemonStorage.Interfaces;
    using LemonStorage.Enumerations;

    public abstract class PeripheralDevice : Product, IPeripheralDevices, IProduct, ISavable
    {
        public PeripheralDevice(decimal price, string brand, string model, string color)
            : base(price, brand, model, color)
        {

        }
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <LinearLayout
                android:id="@+id/qq5_float_hide_layout"
                android:layout_width="45dp"
                android:layout_height="45dp"
                android:layout_marginLeft="10dp"
                android:background="@drawable/qq5_float_icon_action"
                android:gravity="center"
                android:orientation="vertical" >

                <ImageView
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:src="@drawable/qq5_dialog_float_hide" />
            </LinearLayout>

            <TextView
                android:background="@drawable/qq5_float_icon_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginLeft="5dp"
                android:layout_marginTop="3dp"
                android:paddingLeft="4dp"
                android:paddingRight="4dp"
                android:text="隐藏"
                android:textColor="#ffffff"
                android:textSize="14sp" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <LinearLayout
                android:id="@+id/qq5_float_strategy_layout"
                android:layout_width="45dp"
                android:layout_height="45dp"
                android:layout_marginLeft="10dp"
                android:background="@drawable/qq5_float_icon_action"
                android:gravity="center"
                android:orientation="vertical" >

                <ImageView
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:src="@drawable/qq5_dialog_float_strategy" />
            </LinearLayout>

            <TextView
                android:background="@drawable/qq5_float_icon_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginLeft="5dp"
                android:layout_marginTop="3dp"
                android:paddingLeft="4dp"
                android:paddingRight="4dp"
                android:text="攻略"
                android:textColor="#ffffff"
                android:textSize="14sp" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <LinearLayout
                android:id="@+id/qq5_float_gift_layout"
                android:layout_width="45dp"
                android:layout_height="45dp"
                android:layout_marginLeft="10dp"
                android:background="@drawable/qq5_float_icon_action"
                android:gravity="center"
                android:orientation="vertical" >

                <ImageView
                    android:layout_width="20dp"
                    android:layout_height="20dp"
                    android:src="@drawable/qq5_dialog_float_gift" />
            </LinearLayout>

            <TextView
                android:background="@drawable/qq5_float_icon_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginLeft="5dp"
                android:layout_marginTop="3dp"
                android:paddingLeft="4dp"
                android:paddingRight="4dp"
                android:text="礼包"
                android:textColor="#ffffff"
                android:textSize="14sp" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dp"
            android:orientation="vertical" >

            <LinearLayout
                android:id="@+id/qq5_float_home_layout"
                android:layout_width="45dp"
                android:layout_height="45dp"
                android:layout_marginLeft="10dp"
                android:background="@drawable/qq5_float_icon_action"
                android:gravity="center"
                android:orientation="vertical" >

                <ImageView
                    android:layout_width="25dp"
                    android:layout_height="25dp"
                    android:src="@drawable/qq5_dialog_float_main" />
            </LinearLayout>

            <TextView
                android:background="@drawable/qq5_float_icon_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="3dp"
                android:layout_marginLeft="5dp"
                android:paddingLeft="4dp"
                android:paddingRight="4dp"
                android:text="主页"
                android:textColor="#ffffff"
                android:textSize="14sp" />
        </LinearLayout>
    </LinearLayout>

</FrameLayout>


text:
package me.littlepanda.dadbear.example.log;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @author 张静波 myplaylife@icloud.com
 *
 */
public interface LogManager {

	/**
	 * @return 获取所有日志类别和日志文件名的列表
	 */
	abstract public Map<String, List<String>> getAllLogs();

	/**
	 * @param log_name 日志类别
	 * @return 获取某个日志类别的日志文件名称列表
	 */
	abstract public List<String> getLogsByLogName(String log_name);

	/**
	 * @param log_name 日志类别
	 * @param pattern 查询字符串
	 * @return 根据日志类别和关键字获取具有该关键字的日志文件名称的列表
	 */
	abstract public Map<String, Collection<String>> findLogs(List<String> log_names, String pattern);

	/**
	 * @param log_name 日志类别
	 * @param file_name 文件名称
	 * @return 根据日志类别和文件名称获取一个日志文件的内容
	 */
	abstract public byte[] getLog(String log_name, String file_name);
}


text:
var v = require("../lib/wrap-vector");

describe("wrap-vector", function() {

	beforeEach(function() {

		this.target = [0, 0, 0];
		this.primesA = [2, 3, 5];
		this.primesB = [7, 11, 13];

		this.$target = v( this.target );
		this.$primesA = v( this.primesA );
		this.$primesB = v( this.primesB );

	});

	describe("wrapping", function() {

		it("creates n length vectors filled with 0s when called with a number", function() {

			var v0 = v(0);
			var v1 = v(1);
			var v2 = v(2);
			var v5 = v(5);

			expect( v0.value ).toEqual( [] );
			expect( v1.value ).toEqual( [0] );
			expect( v2.value ).toEqual( [0,0] );
			expect( v5.value ).toEqual( [0,0,0,0,0] );

		});

		it("creates an empty vector when called with no argument", function() {

			var vEmpty = v();
			expect( vEmpty.value ).toEqual( [] );

		});

		it("sets the .value to the passed array", function() {

			var v1 = v( this.primesA );

			expect( v1.value ).toEqual( [2, 3, 5] );

		});

	});

	describe("add", function() {

		it("can add two vectors and set to a target", function(){

			var target = [0, 1, 2];
			var $target = v( target );

			$target.add( this.primesA, this.primesB );

			expect( $target.value ).toBe( target );
			expect( $target.value ).toEqual( [9, 14, 18] );
			expect( this.primesA ).toEqual( [2, 3, 5] );
			expect( this.primesB ).toEqual( [7, 11, 13] );

		});

		it("can add n vectors and set to a target", function(){

			var primesC = [17, 19, 23];
			var target = [0, 1, 2];
			var $target = v( target );

			$target.add( this.primesA, this.primesB, primesC );

			expect( $target.value ).toBe( target );
			expect( $target.value ).toEqual( [26, 33, 41] );
			expect( this.primesA ).toEqual( [2, 3, 5] );
			expect( this.primesB ).toEqual( [7, 11, 13] );
			expect( primesC ).toEqual( [17, 19, 23] );

		});

		it("sets the target dimensions to the dimensions of the first passed vector", function() {

			var target1 = [0, 1];
			var target1Wrapped = v( target1 );

			var target2 = [0, 1];
			var target2Wrapped = v( target2 );

			var threeDimensionsArray = this.primesA;
			var fourDimensionsArray = [7, 11, 13, 17];

			target1Wrapped.add( threeDimensionsArray, fourDimensionsArray );
			target2Wrapped.add( fourDimensionsArray, threeDimensionsArray );

			expect( target1Wrapped.value.length ).toEqual( 3 );
			expect( target2Wrapped.value.length ).toEqual( 4 );

		});

		it("correctly mutates a self referential target during addition only after the operation", function() {

			this.$target.add( this.$target.value, this.primesA );

			expect( this.$target.value ).toEqual( [2, 3, 5] );

			this.$target.add( this.$target.value, this.primesA );

			expect( this.$target.value ).toEqual( [4, 6, 10] );

			this.$target.add( this.$target.value, this.primesA, this.primesA );

			expect( this.$target.value ).toEqual( [8, 12, 20] );

		});

		it("returns wrap", function() {
			expect( this.$primesA.add( this.primesB ) ).toBe( this.$primesA );
		});

	});

	describe("multiply", function() {

		it("can multiply two vectors and set to a target", function(){

			var target = [0, 1, 2];
			var $target = v( target );

			$target.multiply( this.primesA, this.primesB );

			expect( $target.value ).toBe( target );
			expect( $target.value ).toEqual( [14, 33, 65] );
			expect( this.primesA ).toEqual( [2, 3, 5] );
			expect( this.primesB ).toEqual( [7, 11, 13] );

		});

		it("can multiply n vectors and set to a target", function(){

			var primesC = [17, 19, 23];
			var target = [0, 1, 2];
			var $target = v( target );

			$target.multiply( this.primesA, this.primesB, primesC );

			expect( $target.value ).toBe( target );
			expect( $target.value ).toEqual( [238, 627, 1495] );
			expect( this.primesA ).toEqual( [2, 3, 5] );
			expect( this.primesB ).toEqual( [7, 11, 13] );
			expect( primesC ).toEqual( [17, 19, 23] );

		});

		it("sets the target dimensions to the dimensions of the first passed vector", function() {

			var target1 = [0, 1];
			var target1Wrapped = v( target1 );

			var target2 = [0, 1];
			var target2Wrapped = v( target2 );

			var threeDimensionsArray = this.primesA;
			var fourDimensionsArray = [7, 11, 13, 17];

			target1Wrapped.multiply( threeDimensionsArray, fourDimensionsArray );
			target2Wrapped.multiply( fourDimensionsArray, threeDimensionsArray );

			expect( target1Wrapped.value.length ).toEqual( 3 );
			expect( target2Wrapped.value.length ).toEqual( 4 );

		});

		it("correctly mutates a self referential target during multiplication only after the operation", function() {

			var target = [1,1,1];
			var $target = v(target);

			$target.multiply( $target.value, this.primesA );

			expect( $target.value ).toEqual( [2, 3, 5] );

			$target.multiply( $target.value, this.primesA );

			expect( $target.value ).toEqual( [4, 9, 25] );

			$target.multiply( $target.value, this.primesA, this.primesA );

			expect( $target.value ).toEqual( [16, 81, 625] );

		});

		it("returns wrap", function() {
			expect( this.$primesA.multiply( this.primesB ) ).toBe( this.$primesA );
		});

	});

	describe("defineProperties", function() {

		beforeEach(function() {
			this.v4 = [2, 3, 5, 7];
			this.v4Wrapped = v( this.v4 );
		});

		describe("get", function() {

			it("should get the x component", function() {
				expect( this.v4Wrapped.x ).toBe( this.v4[0] );
				expect( this.v4Wrapped.x ).toBe( 2 );
			});

			it("should get the y component", function() {
				expect( this.v4Wrapped.y ).toBe( this.v4[1] );
				expect( this.v4Wrapped.y ).toBe( 3 );
			});

			it("should get the z component", function() {
				expect( this.v4Wrapped.z ).toBe( this.v4[2] );
				expect( this.v4Wrapped.z ).toBe( 5 );
			});

			it("should get the w component", function() {
				expect( this.v4Wrapped.w ).toBe( this.v4[3] );
				expect( this.v4Wrapped.w ).toBe( 7 );
			});

		});

		describe("set", function() {

			it("should get the x component", function() {
				this.v4Wrapped.x = 11;
				expect( this.v4Wrapped.x ).toBe( this.v4[0] );
				expect( this.v4Wrapped.x ).toBe( 11 );
			});

			it("should get the y component", function() {
				this.v4Wrapped.y = 11;
				expect( this.v4Wrapped.y ).toBe( this.v4[1] );
				expect( this.v4Wrapped.y ).toBe( 11 );
			});

			it("should get the z component", function() {
				this.v4Wrapped.z = 11;
				expect( this.v4Wrapped.z ).toBe( this.v4[2] );
				expect( this.v4Wrapped.z ).toBe( 11 );
			});

			it("should get the w component", function() {
				this.v4Wrapped.w = 11;
				expect( this.v4Wrapped.w ).toBe( this.v4[3] );
				expect( this.v4Wrapped.w ).toBe( 11 );
			});

		});

	});

	describe("addOn", function() {

		it("adds on a vector to the wrapped value", function() {

			this.$primesA.addOn( this.primesB );
			expect( this.primesA ).toEqual( [9, 14, 18] );

		});

		it("returns wrap", function() {
			expect( this.$primesA.addOn( this.primesB ) ).toBe( this.$primesA );
		});

	});

	describe("set", function() {

		it("sets the current wrapped value", function() {

			this.$primesA.set( 1, 2, 3 );
			expect( this.primesA ).toEqual( [1, 2, 3] );

		});

		it("sets only the values passed", function() {

			this.$primesA.set( 1, 2 );
			expect( this.primesA ).toEqual( [1, 2, 5] );

		});

		it("grows an array if the set arguments have more dimensions", function() {

			this.$primesA.set( 1, 2, 3, 4, 5 );
			expect( this.primesA ).toEqual( [1, 2, 3, 4, 5] );

		});

		it("returns wrap", function() {
			expect( this.$primesA.set( this.primesB ) ).toBe( this.$primesA );
		});

	});

	describe("copy", function() {

		it("should copy an array", function() {

			this.$target.copy( this.primesA );
			expect( this.target ).toEqual( [2, 3, 5] );

		});

		it("should correct size the new copied array", function() {

			this.$target.copy( [2, 3] );
			expect( this.target ).toEqual( [2, 3] );

			this.$target.copy( [2, 3, 4, 5] );
			expect( this.target ).toEqual( [2, 3, 4, 5] );

		});

		it("copies only the specified n dimensions", function() {

			this.$target.copy( this.primesA, 2 );
			expect( this.target ).toEqual( [2, 3] );

			this.$target.copy( this.primesA, 4 );
			expect( this.target ).toEqual( [2, 3, 5, undefined] );

		});

		it("returns wrap", function() {
			expect( this.$primesA.copy( this.primesB ) ).toBe( this.$primesA );
		});

	});

	describe("dot", function() {

		it("performs a dot product", function() {

			expect( this.$primesA.dot( this.primesB ) ).toEqual( 112 );

		});

	});

	describe("addScalar", function() {

		it("adds a number to each component", function() {

			expect( this.$primesA.addScalar( 5 ).value ).toEqual( [7, 8, 10] );

		});

		it("returns wrap", function() {
			expect( this.$primesA.addScalar( this.primesB ) ).toBe( this.$primesA );
		});

	});

	describe("multiplyScalar", function() {

		it("multiply a number to each component", function() {

			expect( this.$primesA.multiplyScalar( 5 ).value ).toEqual( [10, 15, 25] );

		});

		it("returns wrap", function() {
			expect( this.$primesA.multiplyScalar( this.primesB ) ).toBe( this.$primesA );
		});

	});

});


text:
(function () {

    "use-strict";

    angular.module('app.content.education', [])
        .directive('resumeEducation', resumeEducationDirective);

    resumeEducationDirective.$inject = [];

    function resumeEducationDirective() {
        return {
            restrict: 'EA',
            templateUrl: 'static/app/templates/base/content/education/education.directive.html',
            controllerAs: 'vm',
            controller: resumeEducationController,
            scope: {},
            transclude: true,
            bind: {},
        };
    }

    resumeEducationController.$inject = ['$state'];

    function resumeEducationController($state) {
        var vm = this;

        vm.redirectToSref = redirectToSref;

        function redirectToSref(stateName) {
            $state.go(stateName);
        }
    }
})();


text:
using System;
namespace Learning
{
		public class Experience
		{
			public int beforeStateId;
			public int afterStateId;
			public int action;
			public double reward;
			public bool special;

				public Experience ( int _beforeID, int _action, int _afterID, double _reward, bool _special )
				{
					beforeStateId = _beforeID;
					afterStateId = _afterID;
					action = _action;
					reward = _reward;
					special = _special;
				}
		}
}


text:
require_relative '../../../spec_helper'
require 'logger'

module Seahorse
  module  Client
    module Logging
      describe Handler do

        class LogNullDevice
          attr_reader :messages
          def write(msg)
            @messages ||= ''
            @messages << msg
          end
          def close; end
        end

        class TestFormatter
          def format(response)
            'test-formatter-log-msg'
          end
        end

        def handle!
          @log_dev ||= LogNullDevice.new
          @logger ||= Logger.new(@log_dev)
          @log_level ||= :info
          @formatter ||= TestFormatter.new
          @config ||= double('config',
            logger: @logger,
            log_level: @log_level,
            log_formatter: @formatter)
          @handler ||= Handler.new(lambda { |context|
            context.http_response.signal_done(
              status_code: 200,
              headers: {},
              body: ''
            )
            Response.new(context: context)
          })
          @handler.call(RequestContext.new(config: @config))
        end

        it 'populates the request context with timing information' do
          resp = handle!
          expect(resp.context[:logging_started_at]).to be_kind_of(Time)
          expect(resp.context[:logging_completed_at]).to be_kind_of(Time)
          expect(resp.context[:logging_started_at]).to be <= resp.context[:logging_completed_at]
        end

        it 'sends the formatted message to the logger' do
          handle!
          expect(@log_dev.messages).to match(/test-formatter-log-msg/)
        end

        it 'sends the message at the right log level' do
          @log_dev = LogNullDevice.new
          @logger = Logger.new(@log_dev)
          @logger.level = Logger::WARN
          handle!
          expect(@log_dev.messages).to be(nil)
        end

      end
    end
  end
end