text:
package org.scalactic.anyvals

import org.scalactic.Equality
import org.scalatest._
import org.scalatest.prop.GeneratorDrivenPropertyChecks
import OptionValues._

import scala.util.{Failure, Success, Try}
import org.scalactic.{Validation, Pass, Fail}
import org.scalactic.{Or, Good, Bad}

trait PosIntSpecSupport {

  implicit def tryEquality[T]: Equality[Try[T]] = new Equality[Try[T]] {
    override def areEqual(a: Try[T], b: Any): Boolean = a match {
      case Success(double: Double) if double.isNaN =>  // This is because in scala.js x/0 results to NaN not ArithmetricException like in jvm, and we need to make sure Success(NaN) == Success(NaN) is true to pass the test.
        b match {
          case Success(bDouble: Double) if bDouble.isNaN => true
          case _ => false
        }
      // I needed this because with GenDrivenPropertyChecks, got:
      // [info] - should offer a '%' method that is consistent with Int *** FAILED ***
      // [info]   Success(NaN) did not equal Success(NaN) (PosIntExperiment.scala:498)
      case Success(float: Float) if float.isNaN =>
        b match {
          case Success(bFloat: Float) if bFloat.isNaN => true
          case _ => false
        }
      case _: Success[_] => a == b
      case Failure(ex) => b match {
        case _: Success[_] => false
        case Failure(otherEx) => ex.getClass == otherEx.getClass && ex.getMessage == otherEx.getMessage
        case _ => false
      }
    }
  }

}

class PosIntSpec extends funspec.AnyFunSpec with matchers.should.Matchers with GeneratorDrivenPropertyChecks with PosIntSpecSupport {

  describe("A PosInt") {

    describe("should offer a from factory method that") {
      it("returns Some[PosInt] if the passed Int is greater than 0") {
        PosInt.from(50).value.value shouldBe 50
        PosInt.from(100).value.value shouldBe 100
      }

      it("returns None if the passed Int is NOT greater than 0") {
        PosInt.from(0) shouldBe None
        PosInt.from(-1) shouldBe None
        PosInt.from(-99) shouldBe None
      }
    }
    describe("should offer an ensuringValid factory method that") {
      it("returns PosInt if the passed Int is greater than 0") {
        PosInt.ensuringValid(50).value shouldBe 50
        PosInt.ensuringValid(100).value shouldBe 100
      }

      it("throws AssertionError if the passed Int is NOT greater than 0") {
        an [AssertionError] should be thrownBy PosInt.ensuringValid(0)
        an [AssertionError] should be thrownBy PosInt.ensuringValid(-1)
        an [AssertionError] should be thrownBy PosInt.ensuringValid(-99)
      }
    }
    describe("should offer a tryingValid factory method that") {
      import TryValues._
      it("returns a PosInt wrapped in a Success if the passed Int is greater than 0") {
        PosInt.tryingValid(50).success.value.value shouldBe 50
        PosInt.tryingValid(100).success.value.value shouldBe 100
      }

      it("returns an AssertionError wrapped in a Failure if the passed Int is NOT greater than 0") {
        PosInt.tryingValid(0).failure.exception shouldBe an [AssertionError]
        PosInt.tryingValid(-1).failure.exception shouldBe an [AssertionError]
        PosInt.tryingValid(-99).failure.exception shouldBe an [AssertionError]
      }
    }
    describe("should offer a passOrElse factory method that") {
      it("returns a Pass if the given Int is greater than 0") {
        PosInt.passOrElse(50)(i => i) shouldBe Pass
        PosInt.passOrElse(100)(i => i) shouldBe Pass
      }
      it("returns an error value produced by passing the given Int to the given function if the passed Int is NOT greater than 0, wrapped in a Fail") {
        PosInt.passOrElse(0)(i => s"$i did not taste good") shouldBe Fail("0 did not taste good")
        PosInt.passOrElse(-1)(i => i) shouldBe Fail(-1)
        PosInt.passOrElse(-99)(i => i.toLong + 3L) shouldBe Fail(-96L)
      }
    }
    describe("should offer a goodOrElse factory method that") {
      it("returns a PosInt wrapped in a Good if the given Int is greater than 0") {
        PosInt.goodOrElse(50)(i => i) shouldBe Good(PosInt(50))
        PosInt.goodOrElse(100)(i => i) shouldBe Good(PosInt(100))
      }
      it("returns an error value produced by passing the given Int to the given function if the passed Int is NOT greater than 0, wrapped in a Bad") {
        PosInt.goodOrElse(0)(i => s"$i did not taste good") shouldBe Bad("0 did not taste good")
        PosInt.goodOrElse(-1)(i => i) shouldBe Bad(-1)
        PosInt.goodOrElse(-99)(i => i.toLong + 3L) shouldBe Bad(-96L)
      }
    }
    describe("should offer a rightOrElse factory method that") {
      it("returns a PosInt wrapped in a Right if the given Int is greater than 0") {
        PosInt.rightOrElse(50)(i => i) shouldBe Right(PosInt(50))
        PosInt.rightOrElse(100)(i => i) shouldBe Right(PosInt(100))
      }
      it("returns an error value produced by passing the given Int to the given function if the passed Int is NOT greater than 0, wrapped in a Left") {
        PosInt.rightOrElse(0)(i => s"$i did not taste good") shouldBe Left("0 did not taste good")
        PosInt.rightOrElse(-1)(i => i) shouldBe Left(-1)
        PosInt.rightOrElse(-99)(i => i.toLong + 3L) shouldBe Left(-96L)
      }
    }
    describe("should offer an isValid predicate method that") {
      it("returns true if the passed Int is greater than 0") {
        PosInt.isValid(50) shouldBe true
        PosInt.isValid(100) shouldBe true
        PosInt.isValid(0) shouldBe false
        PosInt.isValid(-0) shouldBe false
        PosInt.isValid(-1) shouldBe false
        PosInt.isValid(-99) shouldBe false
      }
    }
    describe("should offer a fromOrElse factory method that") {
      it("returns a PosInt if the passed Int is greater than 0") {
        PosInt.fromOrElse(50, PosInt(42)).value shouldBe 50
        PosInt.fromOrElse(100, PosInt(42)).value shouldBe 100
      }
      it("returns a given default if the passed Int is NOT greater than 0") {
        PosInt.fromOrElse(0, PosInt(42)).value shouldBe 42
        PosInt.fromOrElse(-1, PosInt(42)).value shouldBe 42
        PosInt.fromOrElse(-99, PosInt(42)).value shouldBe 42
      }
    }
    it("should offer MaxValue and MinValue factory methods") {
      PosInt.MaxValue shouldEqual PosInt.from(Int.MaxValue).get
      PosInt.MinValue shouldEqual PosInt(1)
    }

    it("should be sortable") {
      val xs = List(PosInt(2), PosInt(4), PosInt(1), PosInt(3))
      xs.sorted shouldEqual List(PosInt(1), PosInt(2), PosInt(3), PosInt(4))
    }

    describe("when created with apply method") {

      it("should compile when 8 is passed in") {
        "PosInt(8)" should compile
        PosInt(8).value shouldEqual 8
      }

      it("should not compile when 0 is passed in") {
        "PosInt(0)" shouldNot compile
      }

      it("should not compile when -8 is passed in") {
        "PosInt(-8)" shouldNot compile
      }

      it("should not compile when x is passed in") {
        val x: Int = -8
        "PosInt(x)" shouldNot compile
      }
    }

    describe("when specified as a plain-old Int") {

      def takesPosInt(pos: PosInt): Int = pos.value

      it("should compile when 8 is passed in") {
        "takesPosInt(8)" should compile
        takesPosInt(8) shouldEqual 8
      }

      it("should not compile when 0 is passed in") {
        "takesPosInt(0)" shouldNot compile
      }

      it("should not compile when -8 is passed in") {
        "takesPosInt(-8)" shouldNot compile
      }

      it("should not compile when x is passed in") {
        val x: Int = -8
        "takesPosInt(x)" shouldNot compile
      }
    }

    it("should offer a unary ~ method that is consistent with Int") {
      forAll { (pint: PosInt) =>
        (~pint) shouldEqual (~(pint.toInt))
      }
    }

    it("should offer a unary + method that is consistent with Int") {
      forAll { (p: PosInt) =>
        (+p).toInt shouldEqual (+(p.toInt))
      }
    }

    it("should offer a unary - method that returns NegInt") {
      forAll { (p: PosInt) =>
        (-p) shouldEqual (NegInt.ensuringValid(-(p.toInt)))
      }
    }

    it("should offer << methods that are consistent with Int") {
      forAll { (pint: PosInt, shift: Int) =>
        pint << shift shouldEqual pint.toInt << shift
      }
      forAll { (pint: PosInt, shift: Long) =>
        pint << shift shouldEqual pint.toInt << shift
      }
    }

    it("should offer >>> methods that are consistent with Int") {
      forAll { (pint: PosInt, shift: Int) =>
        pint >>> shift shouldEqual pint.toInt >>> shift
      }
      forAll { (pint: PosInt, shift: Long) =>
        pint >>> shift shouldEqual pint.toInt >>> shift
      }
    }

    it("should offer >> methods that are consistent with Int") {
      forAll { (pint: PosInt, shift: Int) =>
        pint >> shift shouldEqual pint.toInt >> shift
      }
      forAll { (pint: PosInt, shift: Long) =>
        pint >> shift shouldEqual pint.toInt >> shift
      }
    }

    it("should offer a '|' method that is consistent with Int") {
      forAll { (pint: PosInt, byte: Byte) =>
        (pint | byte) shouldEqual (pint.toInt | byte)
      }
      forAll { (pint: PosInt, short: Short) =>
        (pint | short) shouldEqual (pint.toInt | short)
      }
      forAll { (pint: PosInt, char: Char) =>
        (pint | char) shouldEqual (pint.toInt | char)
      }
      forAll { (pint: PosInt, int: Int) =>
        (pint | int) shouldEqual (pint.toInt | int)
      }
      forAll { (pint: PosInt, long: Long) =>
        (pint | long) shouldEqual (pint.toInt | long)
      }
    }

    it("should offer an '&' method that is consistent with Int") {
      forAll { (pint: PosInt, byte: Byte) =>
        (pint & byte) shouldEqual (pint.toInt & byte)
      }
      forAll { (pint: PosInt, short: Short) =>
        (pint & short) shouldEqual (pint.toInt & short)
      }
      forAll { (pint: PosInt, char: Char) =>
        (pint & char) shouldEqual (pint.toInt & char)
      }
      forAll { (pint: PosInt, int: Int) =>
        (pint & int) shouldEqual (pint.toInt & int)
      }
      forAll { (pint: PosInt, long: Long) =>
        (pint & long) shouldEqual (pint.toInt & long)
      }
    }

    it("should offer an '^' method that is consistent with Int") {
      forAll { (pint: PosInt, byte: Byte) =>
        (pint ^ byte) shouldEqual (pint.toInt ^ byte)
      }
      forAll { (pint: PosInt, char: Char) =>
        (pint ^ char) shouldEqual (pint.toInt ^ char)
      }
      forAll { (pint: PosInt, short: Short) =>
        (pint ^ short) shouldEqual (pint.toInt ^ short)
      }
      forAll { (pint: PosInt, int: Int) =>
        (pint ^ int) shouldEqual (pint.toInt ^ int)
      }
      forAll { (pint: PosInt, long: Long) =>
        (pint ^ long) shouldEqual (pint.toInt ^ long)
      }
    }

    it("should offer 'min' and 'max' methods that are consistent with Int") {
      forAll { (pint1: PosInt, pint2: PosInt) =>
        pint1.max(pint2).toInt shouldEqual pint1.toInt.max(pint2.toInt)
        pint1.min(pint2).toInt shouldEqual pint1.toInt.min(pint2.toInt)
      }
    }

    it("should offer a 'toBinaryString' method that is consistent with Int") {
      forAll { (pint: PosInt) =>
        pint.toBinaryString shouldEqual pint.toInt.toBinaryString
      }
    }

    it("should offer a 'toHexString' method that is consistent with Int") {
      forAll { (pint: PosInt) =>
        pint.toHexString shouldEqual pint.toInt.toHexString
      }
    }

    it("should offer a 'toOctalString' method that is consistent with Int") {
      forAll { (pint: PosInt) =>
        pint.toOctalString shouldEqual pint.toInt.toOctalString
      }
    }

    it("should offer 'to' and 'until' methods that are consistent with Int") {
      forAll { (pint: PosInt, end: Int, step: Int) =>
        // The reason we need this is that in Scala 2.10, the equals check (used by shouldEqual below) will call range.length
        // and it'll cause IllegalArgumentException to be thrown when we do the Try(x) shouldEqual Try(y) assertion below,
        // while starting from scala 2.11 the equals call implementation does not call .length.
        // To make the behavior consistent for all scala versions, we explicitly call .length for all returned Range, and
        // shall it throws IllegalArgumentException, it will be wrapped as Failure for the Try.
        def ensuringValid(range: Range): Range = {
          range.length  // IllegalArgumentException will be thrown if it is an invalid range, this will turn the Success to Failure for Try
          range
        }

        Try(ensuringValid(pint.to(end))) shouldEqual Try(ensuringValid(pint.toInt.to(end)))
        Try(ensuringValid(pint.to(end, step))) shouldEqual Try(ensuringValid(pint.toInt.to(end, step)))
        Try(ensuringValid(pint.until(end))) shouldEqual Try(ensuringValid(pint.toInt.until(end)))
        Try(ensuringValid(pint.until(end, step))) shouldEqual Try(ensuringValid(pint.toInt.until(end, step)))
      }
    }

    it("should offer an ensuringValid method that takes an Int => Int, throwing AssertionError if the result is invalid") {
      PosInt(33).ensuringValid(_ + 1) shouldEqual PosInt(34)
      an [AssertionError] should be thrownBy { PosInt.MaxValue.ensuringValid(_ + 1) }
    }
  }
}


text:
import rimraf from 'rimraf';

export default function rm(target) {
	return new Promise((resolve, reject) => {
		rimraf(target, {}, error => {
			if (error) {
				reject(error);
			} else {
				resolve();
			}
		});
	});
}

redpajama_set_name: RedPajamaGithub


text:
package models.daos

import java.sql.Timestamp
import java.util.{ Date, UUID }
import javax.inject.Inject

import models.{ Prediction, TaggingImage }
import models.tables.PredictionTable
import play.api.db.slick.DatabaseConfigProvider
import slick.backend.DatabaseConfig
import slick.driver.JdbcProfile
import slick.jdbc.JdbcBackend
import slick.lifted.TableQuery

import scala.concurrent.Future

/**
 * Created by jlzie on 28.04.2017.
 */
class PredictionDAOImpl @Inject() (protected val dbConfigProvider: DatabaseConfigProvider) extends PredictionDAO {

  val dbConfig: DatabaseConfig[JdbcProfile] = dbConfigProvider.get[JdbcProfile]
  val db: JdbcBackend#DatabaseDef = dbConfig.db

  import dbConfig.driver.api._
  import PredictionDAOImpl._
  import play.api.libs.concurrent.Execution.Implicits.defaultContext
  override def create(predictions: Seq[Prediction]): Future[Seq[Prediction]] = {
    val query = predictionsTable.returning(predictionsTable.map(_.predictionId)).into((prediction, id) => prediction.copy(predictionId = id)) ++= predictions
    db.run(query).map(_.seq)
  }

  override def getPredictions(images: Seq[UUID]): Future[Seq[Prediction]] = {
    val query = predictionsTable.filter(_.imageId inSet images).result
    db.run(query)
  }
}

object PredictionDAOImpl {
  val predictionsTable = TableQuery[PredictionTable]
}


text:
/* These functions and macros rely on Multi-Byte nodes */

#include <string.h>
#include "ebtree.h"
#include "ebpttree.h"

/* These functions and macros rely on Pointer nodes and use the <key> entry as
 * a pointer to an indirect key. Most operations are performed using ebpt_*.
 */

/* The following functions are not inlined by default. They are declared
 * in ebistree.c, which simply relies on their inline version.
 */
extern struct ebpt_node *ebis_lookup(struct eb_root *root, const char *x);
extern struct ebpt_node *ebis_lookup_len(struct eb_root *root, const char *x, unsigned int len);
extern struct ebpt_node *ebis_insert(struct eb_root *root, struct ebpt_node *new);


text:
package org.postgresql.ds.jdbc4;

import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;

import org.postgresql.ds.jdbc23.AbstractJdbc23SimpleDataSource;

public abstract class AbstractJdbc4SimpleDataSource extends AbstractJdbc23SimpleDataSource
{
    public boolean isWrapperFor(Class<?> iface) throws SQLException
    {
        return iface.isAssignableFrom(getClass());
    }

    public <T> T unwrap(Class<T> iface) throws SQLException
    {
        if (iface.isAssignableFrom(getClass()))
        {
            return iface.cast(this);
        }
        throw new SQLException("Cannot unwrap to " + iface.getName());
    }

    public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedException
    {
        throw org.postgresql.Driver.notImplemented(this.getClass(), "getParentLogger()");
    }

}


text:
<?php

namespace Pablo\AdjWebBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class PabloAdjWebBundle extends Bundle
{
}


text:
<!--Programming Page Index-->
<?php
    require_once('../theme/template.php');
    $TITLE = "Programming";
    $variables = array(
        'TITLE' => $TITLE
    );
    renderLayoutWithContentFile("../Programming/programming.php", $variables);
?>


text:
import posixpath

from panda3d.core import *
from direct.particles.ParticleEffect import ParticleEffect
from direct.interval.MetaInterval import Sequence
from direct.interval.FunctionInterval import *

class ParticleManager:
  """Simple particle system wrapper - put here in the hope that latter on a better way of doing things will exist and this will make the swap out easy."""
  def __init__(self,manager,xml):
    # Get the particle system path...
    self.basePath = manager.get('paths').getConfig().find('particles').get('path')

    # Enable the particle system...
    base.enableParticles()

    self.reload(manager,xml)

  def reload(self,manager,xml):
    # Generate a database of particle effects from the xml - this consists of a name to request the effect by, a configuration file to load and how long to let it live before destroying it. (If omited it will live until a stop.)
    self.pdb = dict()
    for effect in xml.findall('effect'):
      new = dict()
      new['name'] = effect.get('name')
      self.pdb[new['name']] = new

      new['file'] = posixpath.join(self.basePath,effect.get('file'))
      new['life'] = effect.get('lifetime',None)

    # This stores all current particle effects, indexed by their id - used by stop to end it all...
    self.effects = dict()

  def stop(self):
    # Kill all running effects - as these are meant to be 'fire once' particle effects this makes sense...
    for key,pn in self.effects.iteritems():
      pn[0].cleanup()
      pn[0].remove_node()
      pn[1].removeNode()

  def doEffect(self,name,source,track = False,pos = None,quat = None):
    """Creates the particle effect with the given name. source is the node to appear at - if track is false its initialised here and then remains fixed in world space, otherwise it moves with the source node. pos and quat are offset's in source's local coordinate sytem for the origin."""

    # Create node to store the particle effect in...
    if track:
      n = source.attachNewNode('')
      self.prepNode(n)
    else:
      n = render.attachNewNode('')
      self.prepNode(n)

      n.setPos(render,source.getPos(render))
      n.setQuat(render,source.getQuat(render))

    # Handle local offset/rotation...
    if pos!=None:
      n.setPos(n,pos)
    if quat!=None:
      n.setQuat(n,quat)

    # Create the particle effect...
    p = ParticleEffect()
    p.loadConfig(Filename(self.pdb[name]['file']))
    p.start(n)

    # Store effect in the effect database...
    self.effects[id(p)] = (p,n)

    # If the effect has a finite life arrange for it to be terminated...
    if self.pdb[name]['life']!=None:
      def kill(p):
        if self.effects.has_key(id(p)):
          pn = self.effects[id(p)]
          pn[0].cleanup()
          pn[0].remove_node()
          pn[1].removeNode()
          del self.effects[id(p)]
      s = Sequence(Wait(float(self.pdb[name]['life'])),Func(kill,p))
      s.start()

  def prepNode(self,node):
    """Internal use only really - given a node this prepares it to be the parent of a paricle system."""
    node.setBin('fixed',0)
    node.setDepthWrite(False)
    node.setLightOff()
    node.setShaderOff()


text:
require 'eventmachine'

module PeriodicChecker
  def self.error_handler(*args, &block)
    EventMachine.error_handler(*args, &block)
  end

  def self.run(&block)
    EventMachine.run { Group.start(&block) }
  end
end

require "periodic_checker/version" unless PeriodicChecker.const_defined?(:VERSION)
require 'periodic_checker/watch'
require 'periodic_checker/group'


text:
package org.papoose.core;

import org.osgi.service.condpermadmin.ConditionalPermissionInfo;

/**
 *
 */
public interface PermissionChangeListener
{
    void added(ConditionalPermissionInfo info);

    void replaced(ConditionalPermissionInfo info);

    void removed(ConditionalPermissionInfo info);
}


text:
void demo(void) {

    NSError *continuationsError =
    [BCLContinuations untilError:

     nil];

    NSLog(@"error: %@", continuationsError);
}

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        demo();
    }
    return 0;
}


text:
package com.handu.open.dubbo.monitor.domain;

import java.io.Serializable;

public class ApplicationService implements Serializable {

    /**
	 *
	 */
	private static final long serialVersionUID = -5468082346847524044L;

	private Long id;
    private String name ;
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}
}