text:
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/**
 * @fileoverview Fake implementation of chrome.bluetooth for testing.
 */
cr.define('settings', function() {
  /**
   * Fake of the chrome.bluetooth API.
   * @constructor
   * @implements {Bluetooth}
   */
  function FakeBluetooth() {
    /** @type {!chrome.bluettoth.AdapterState} */ this.adapterState = {
      address: '00:11:22:33:44:55:66',
      name: 'Fake Adapter',
      powered: false,
      available: true,
      discovering: false
    };

    /** @type {!Array<!chrome.bluetooth.Device>} */ this.devices = [];
  }

  FakeBluetooth.prototype = {
    // Public testing methods.
    /**
     * @param {boolean} enabled
     */
    setEnabled: function(enabled) {
      this.adapterState.powered = enabled;
      this.onAdapterStateChanged.callListeners(this.adapterState);
    },

    /**
     * @param {!Array<!chrome.bluetooth.Device>} devices
     */
    setDevicesForTest: function(devices) {
      for (var d of this.devices)
        this.onDeviceRemoved.callListeners(d);
      this.devices = devices;
      for (var d of this.devices)
        this.onDeviceAdded.callListeners(d);
    },

    // Bluetooth overrides.
    /** @override */
    getAdapterState: function(callback) {
      setTimeout(function() {
        callback(this.adapterState);
      }.bind(this));
    },

    /** @override */
    getDevice: assertNotReached,

    /** @override */
    getDevices: function(callback) {
      setTimeout(function() {
        callback(this.devices);
      }.bind(this));
    },

    /** @override */
    startDiscovery: assertNotReached,

    /** @override */
    stopDiscovery: assertNotReached,

    /** @override */
    onAdapterStateChanged: new FakeChromeEvent(),

    /** @override */
    onDeviceAdded: new FakeChromeEvent(),

    /** @override */
    onDeviceChanged: new FakeChromeEvent(),

    /** @override */
    onDeviceRemoved: new FakeChromeEvent(),
  };

  return {FakeBluetooth: FakeBluetooth};
});


text:
package com.grunka.random.fortuna.accumulator;

import com.grunka.random.fortuna.Pool;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

public class Accumulator {
    private final AtomicInteger sourceCount = new AtomicInteger(0);
    private final List<ScheduledFuture<?>> entropyFutures = new ArrayList<>();
    private final Pool[] pools;
    private final ScheduledExecutorService scheduler;

    public Accumulator(Pool[] pools, ScheduledExecutorService scheduler) {
        this.pools = pools;
        this.scheduler = scheduler;
    }

    public Pool[] getPools() {
        return pools;
    }

    public void addSource(EntropySource entropySource) {
        int sourceId = sourceCount.getAndIncrement();
        EventAdder eventAdder = new EventAdderImpl(sourceId, pools);
        AtomicBoolean scheduled = new AtomicBoolean();
        entropySource.schedule(((delay, timeUnit) -> {
            entropyFutures.add(scheduler.scheduleWithFixedDelay(() -> entropySource.event(eventAdder), 0, delay, timeUnit));
            scheduled.set(true);
        }));
        if (!scheduled.get()) {
            throw new IllegalStateException("Entropy source " + entropySource.getClass().getName() + " was not scheduled to run");
        }
    }

    public void shutdownSources() {
        entropyFutures.forEach(f -> f.cancel(false));
        entropyFutures.clear();
    }
}

redpajama_set_name: RedPajamaGithub


text:
<?php

namespace Behat\Reporter\Context;

use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Behat\Tester\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;
use \PHPUnit_Framework_Assert as Assert;

class BehatContext implements SnippetAcceptingContext
{
    /**
     * @var Filesystem
     */
    private static $fileSystem;
    /**
     * @var string
     */
    private static $testDir;
    /**
     * @var string
     */
    private $workingDir;
    /**
     * @var string
     */
    private $phpBin;
    /**
     * @var Process
     */
    private $process;

    /**
     * @BeforeSuite
     */
    public static function prepareTestDirecotory()
    {
        self::$fileSystem = new Filesystem();
        self::$testDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'behat-reporter';

        if (self::$fileSystem->exists(self::$testDir)) {
            self::$fileSystem->remove(self::$testDir);
        } else {
            self::$fileSystem->mkdir(self::$testDir);
        }
    }

    /**
     * @BeforeScenario
     */
    public function prepareTestEnvironment()
    {
        $phpFinder = new PhpExecutableFinder();
        if (false === $php = $phpFinder->find()) {
            throw new \RuntimeException('Unable to find the PHP executable.');
        }

        $this->workingDir = self::$testDir . DIRECTORY_SEPARATOR . md5(microtime() * rand(0, 10000));
        self::$fileSystem->mkdir($this->workingDir . '/features/bootstrap');

        $this->phpBin = $php;
        $this->process = new Process(null);
    }

    /**
     * @Given there is config file with:
     * @param PyStringNode $string
     */
    public function thereIsConfigFileWith(PyStringNode $string)
    {
        $config = $this->workingDir . '/behat.yml';
        self::$fileSystem->dumpFile($config, $string->getRaw());
    }

    /**
     * @Given there is feature context
     */
    public function thereIsContext()
    {
        $file = $this->workingDir . '/features/bootstrap/FeatureContext.php';
        self::$fileSystem->dumpFile($file, $this->getFeatureContext());
        Assert::assertTrue(self::$fileSystem->exists($file));
    }

    /**
     * @Given there is feature :feature with:
     * @param string $feature
     * @param PyStringNode $string
     */
    public function thereIsFeatureWith($feature, PyStringNode $string)
    {
        $file = $this->workingDir . '/features/' . $feature . '.feature';
        self::$fileSystem->dumpFile($file, $string->getRaw());
        Assert::assertTrue(self::$fileSystem->exists($file));
    }

    /**
     * @When I run behat with :args
     * @param string $args
     */
    public function iRunBehatWith($args)
    {
        $argumentsString = strtr($args, array('\'' => '"'));

        $this->process->setWorkingDirectory($this->workingDir);
        $this->process->setCommandLine(
            sprintf(
                '%s %s %s %s',
                $this->phpBin,
                escapeshellarg(BEHAT_BIN_PATH),
                $argumentsString,
                strtr('--format-settings=\'{"timer": false}\'', array('\'' => '"', '"' => '\"'))
            )
        );
        $this->process->start();
        $this->process->wait();
    }

    /**
     * @Then the :file file should exists
     * @param string $file
     */
    public function theReportHtmlFileShouldExists($file)
    {
        $file = $this->workingDir . DIRECTORY_SEPARATOR . $file;
        Assert::assertTrue(self::$fileSystem->exists($file));
    }

    /**
     * @Then it should pass
     */
    public function itShouldPass()
    {
        if (0 !== $this->process->getExitCode()) {
            echo $this->process->getCommandLine();
            echo 'Actual output:' . PHP_EOL . PHP_EOL . $this->getOutput();
        }

        Assert::assertSame(0, $this->process->getExitCode());
    }

    private function getOutput()
    {
        $output = $this->process->getErrorOutput() . $this->process->getOutput();

        // Normalize the line endings in the output
        if ("\n" !== PHP_EOL) {
            $output = str_replace(PHP_EOL, "\n", $output);
        }

        // Replace wrong warning message of HHVM
        $output = str_replace('Notice: Undefined index: ', 'Notice: Undefined offset: ', $output);

        return trim(preg_replace("/ +$/m", '', $output));
    }

    private function getFeatureContext()
    {
        return <<<'TAG'
<?php

class FeatureContext implements \Behat\Behat\Context\Context
{
    private $apples = 0;

    /**
     * @Given I have :count apple(s)
     */
    public function iHaveApples($count) {
        $this->apples = (int) $count;
    }

    /**
     * @When I ate :count apple(s)
     */
    public function iAteApples($count) {
        $this->apples -= $count;
    }

    /**
     * @When I found :count apple(s)
     */
    public function iFoundApples($count) {
        $this->apples += $count;
    }

    /**
     * @Then I should have :count apple(s)
     */
    public function iShouldHaveApples($count) {
        \PHPUnit_Framework_Assert::assertEquals($count, $this->apples);
    }
}

TAG;
    }
}


text:
class CreateJoinTableCheckToDirectionStatus < ActiveRecord::Migration[5.1]
  def change
    create_join_table :checks, :direction_statuses do |t|
      # t.index [:check_id, :direction_status_id]
      # t.index [:direction_status_id, :check_id]
    end
  end
end


text:
import { Mongo } from 'meteor/mongo';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';

export const Profiles = new Mongo.Collection('Profile');

export const ProfileSchema = new SimpleSchema({
  first: {
    label: 'first',
    type: String,
    optional: false,
    max: 50,
  },
  last: {
    label: 'last',
    type: String,
    optional: false,
    max: 50,
  },
  interest: {
    label: 'interest',
    type: String,
    optional: false,
    max: 1000,
  },
  major: {
    label: 'major',
    type: String,
    optional: false,
    max: 100,
  },
  agreedToS: {
    label: 'agreedToS',
    type: Boolean,
    optional: false,
  },
  username: {
    label: 'username',
    type: String,
    optional: false,
    max: 100,
  },
});

Profiles.attachSchema(ProfileSchema);


text:
using System;
using Crow;
using Crow.IML;
using NUnit.Framework;

namespace unitTests
{
	[TestFixture]
	public class Instantiator
	{

		[Test]
		public void Widget ()
			=> Assert.DoesNotThrow (()
				=> Crow.IML.Instantiator.CreateFromImlFragment (null, @"<Widget/>")
				, "test itor failed");

		[Test]
		public void Label ()
			=> Assert.DoesNotThrow (()
				=> Crow.IML.Instantiator.CreateFromImlFragment (null, @"<Label Text='this is a test'/>")
				, "test itor failed");

		[Test]
		public void TemplatedControl ()
			=> Assert.DoesNotThrow (()
				=> Crow.IML.Instantiator.CreateFromImlFragment (null, @"<CheckBox IsChecked='false'/>")
				, "test itor failed");

		[Test]
		public void SimpleBinding ()
			=> Assert.DoesNotThrow (()
				=> Crow.IML.Instantiator.CreateFromImlFragment (null, @"<Widget Background='Blue' Tag='{test}'/>")
				, "test itor failed");

	}
}