text:
package ca.hoogit.powerhour.Selection;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;

import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
import com.squareup.otto.Subscribe;

import java.util.List;

import butterknife.Bind;
import ca.hoogit.powerhour.About.AboutActivity;
import ca.hoogit.powerhour.About.TourActivity;
import ca.hoogit.powerhour.BaseActivity;
import ca.hoogit.powerhour.Configure.ConfigureGameFragment;
import ca.hoogit.powerhour.Configure.GameOptions;
import ca.hoogit.powerhour.Game.Action;
import ca.hoogit.powerhour.Game.Engine;
import ca.hoogit.powerhour.Game.GameEvent;
import ca.hoogit.powerhour.Game.GameModel;
import ca.hoogit.powerhour.Game.State;
import ca.hoogit.powerhour.Game.WearData;
import ca.hoogit.powerhour.GameOver.GameOver;
import ca.hoogit.powerhour.Notifications.Constants;
import ca.hoogit.powerhour.R;
import ca.hoogit.powerhour.Screen.GameScreen;
import ca.hoogit.powerhour.Util.BusProvider;
import ca.hoogit.powerhour.Util.PowerHourUtils;
import ca.hoogit.powerhour.Util.SharedPrefs;
import ca.hoogit.powerhour.Util.StatusBarUtil;
import ca.hoogit.powerhour.Views.GameTypeItem;
import ca.hoogit.powerhourshared.DataLayer.Consts;
import io.fabric.sdk.android.Fabric;

public class MainActivity extends BaseActivity {

    private static final int REQUEST_RESOLVE_ERROR = 1000;
    private final String TAG = MainActivity.class.getSimpleName();

    @Bind({R.id.type_power_hour, R.id.type_century_club, R.id.type_spartan, R.id.type_custom})
    List<GameTypeItem> mGameTypes;

    private FragmentManager mFragmentManager;

    private WearData mWearData;
    private boolean mResolvingError = false;

    private boolean mChosen;

    @Override
    protected int getToolbarColor() {
        return getResources().getColor(R.color.primary);
    }

    @Override
    protected int getLayoutResource() {
        return R.layout.activity_main;
    }

    @Override
    protected int getMenuResource() {
        return R.menu.menu_main;
    }

    @Override
    protected boolean getDisplayHomeAsUpEnabled() {
        return false;
    }

    @Override
    protected boolean getEventBusEnabled() {
        return true;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Fabric.with(this, new Crashlytics());
        mFragmentManager = getSupportFragmentManager();
        mWearData = new WearData(this);

        super.onCreate(savedInstanceState);

        SharedPrefs prefs = SharedPrefs.get(this);

        if (prefs.isFirstRun()) {
            prefs.setFirstRun(false);
            startActivity(new Intent(this, TourActivity.class));
        }

        setupListeners();
    }

    @Override
    protected void onStart() {
        super.onStart();
        mWearData.connect();
    }

    @Override
    protected void onStop() {
        mWearData.disconnect();
        super.onStop();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.action_help:
                startActivity(new Intent(this, TourActivity.class));
                return true;
            case R.id.action_about:
                startActivity(new Intent(this, AboutActivity.class));
                return true;
            case android.R.id.home:
                reset();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    @Override
    public void onBackPressed() {
        if (mFragmentManager.getBackStackEntryCount() != 0) {
            reset();
        } else if (Engine.initialized && !Engine.started()) {
            BusProvider.getInstance().post(new GameEvent(Action.STOP));
        } else {
            super.onBackPressed();
        }
    }

    int count = 0;

    @Subscribe
    public void onGameEvent(final GameEvent event) {
        switch (event.action) {
            case PRODUCE:
                if (findFragment("gameScreen") == null && !mChosen) {
                    launchGameScreen(event.game, false);
                    Log.i(TAG, "Game already exists, resuming game");
                } else {
                    Log.d(TAG, "Game already active");
                }
                break;
            case UPDATE:
                count += 100;
                if (event.game.is(State.NEW_ROUND)) {
                    mWearData.sendMessage(Consts.Paths.GAME_SHOT, "");
                } else if (count >= Consts.Game.WEAR_UPDATE_INTERVAL_IN_MILLISECONDS) {
                    mWearData.sendGameInformation(event.game);
                    count = 0;
                }
                break;
            case STOP:
                if (event.game != null && event.game.hasStarted()) {
                    Intent gameOver = new Intent(getApplication(), GameOver.class);
                    gameOver.putExtra("game", event.game);
                    mWearData.sendFinish(event.game);
                    startActivity(gameOver);
                    finish();
                } else {
                    Fragment fragment = findFragment("gameScreen");
                    mFragmentManager.beginTransaction().remove(fragment).commitAllowingStateLoss();
                    reset();
                    mWearData.sendMessage(Consts.Paths.GAME_STOP, Consts.Game.FLAG_GAME_STOP);
                }
                Log.i(TAG, "Game was stopped early");
                break;
            case FINISH:
                PowerHourUtils.delay(500, new PowerHourUtils.OnDelay() {
                    @Override
                    public void run() {
                        Intent gameOver = new Intent(getApplication(), GameOver.class);
                        gameOver.putExtra("game", event.game);
                        mWearData.sendFinish(event.game);
                        reset();
                        startActivity(gameOver);
                        finish();
                    }
                });
                Log.i(TAG, "Game has been completed");
                break;
        }
    }

    private void setupListeners() {
        for (GameTypeItem item : mGameTypes) {
            final GameOptions options = item.getOptions();

            // Has configure button
            if (item.hasButton()) {
                item.setConfigureOnClick(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (!mChosen) {
                            Log.d(TAG, "Configure button for " + options.getType().name() + " was pressed");
                            Answers.getInstance().logCustom(new CustomEvent("Configuring Game")
                                    .putCustomAttribute("Type", options.getType().name()));
                            configureGame(options);
                            mChosen = true;
                        } else {
                            Log.d(TAG, "Someones been tapping too fast");
                        }
                    }
                });
            }
            item.setItemOnClick(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (!mChosen) {
                        Log.d(TAG, options.getType().name() + " mode was selected");
                        Answers.getInstance().logCustom(new CustomEvent("Game Chosen")
                                .putCustomAttribute("Type", options.getType().name()));
                        if (options.getType() == GameOptions.Type.CUSTOM) {
                            configureGame(options);
                        } else {
                            launchGame(options, true);
                        }
                        mChosen = true;
                    } else {
                        Log.d(TAG, "Someones been tapping too fast");
                    }
                }
            });
        }
    }

    private void configureGame(GameOptions options) {
        Log.i(TAG, "Configuring  " + options.getType().name());
        Fragment configure = findFragment("configure");
        if (configure == null) {
            configure = ConfigureGameFragment.newInstance(options);
        }
        mFragmentManager.beginTransaction()
                .setCustomAnimations(R.anim.slide_in_right, 0, 0, R.anim.slide_out_right)
                .replace(R.id.container, configure)
                .addToBackStack("configure")
                .commit();
    }

    private void reset() {
        mFragmentManager.popBackStack();
        StatusBarUtil.getInstance().resetColor(this);
        mChosen = false;
    }

    /**
     * Otto event
     * Called from {@link ConfigureGameFragment#launchGame()}
     *
     * @param options game settings
     */
    @Subscribe
    public void onStartGame(GameOptions options) {
        launchGame(options, true);
    }

    private void launchGame(GameOptions options, boolean animate) {
        GameModel gameModel = new GameModel(options);
        if (!Engine.initialized) {
            Intent initEngine = new Intent(this, Engine.class);
            initEngine.setAction(Constants.ACTION.INITIALIZE_GAME);
            initEngine.putExtra("game", gameModel);
            startService(initEngine);
            Log.d(TAG, "Starting new game");
        }
        Log.i(TAG, "Launching game in " + options.getType().name() + " mode");
        launchGameScreen(gameModel, animate);
    }

    /**
     * Launch the game given the options
     *
     * @param animate whether or not to animate the transition
     */
    private void launchGameScreen(GameModel gameModel, boolean animate) {
        Fragment gameScreen = findFragment("gameScreen");
        if (gameScreen == null) {
            gameScreen = GameScreen.newInstance(gameModel);
        }
        FragmentTransaction ft = mFragmentManager.beginTransaction();
        if (animate) {
            ft.setCustomAnimations(R.anim.slide_in_right, 0, 0, R.anim.slide_out_right);
        }
        ft.replace(R.id.container, gameScreen, "gameScreen");
        ft.commit();

        mWearData.sendStartActivity();
        mWearData.sendGameInformation(gameModel);
    }

    public Fragment findFragment(String name) {
        if (mFragmentManager == null) {
            mFragmentManager = getSupportFragmentManager();
        }
        return mFragmentManager.findFragmentByTag(name);
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putBoolean("chosen", mChosen);
    }

    @Override
    protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        mChosen = savedInstanceState.getBoolean("chosen");
    }
}


text:
<?php

declare(strict_types=1);

namespace Akeneo\CouplingDetector\Domain;

/**
 * A node is an item that will be parsed to check if it respects the coupling rules.
 * It could be PHP class file or a Symfony YAML service definition for example.
 *
 * @author  Julien Janvier <j.janvier@gmail.com>
 * @license http://opensource.org/licenses/MIT MIT
 */
class Node implements NodeInterface
{
    /** @var string */
    private $subject;

    /** @var string */
    private $filepath;

    /** @var array */
    private $tokens = array();

    /** @var string */
    private $type;

    /**
     * Node constructor.
     *
     * @param array  $tokens
     * @param string $subject
     * @param string $filepath
     * @param string $type
     */
    public function __construct(array $tokens, $subject, $filepath, $type)
    {
        $this->tokens = $tokens;
        $this->subject = $subject;
        $this->filepath = $filepath;
        $this->type = $type;
    }

    /**
     * {@inheritdoc}
     */
    public function getSubject()
    {
        return $this->subject;
    }

    /**
     * {@inheritdoc}
     */
    public function getFilepath()
    {
        return $this->filepath;
    }

    /**
     * {@inheritdoc}
     */
    public function getTokens()
    {
        return $this->tokens;
    }

    /**
     * {@inheritdoc}
     */
    public function getType()
    {
        return $this->type;
    }
}

redpajama_set_name: RedPajamaGithub


text:
namespace Microsoft.AspNetCore.Mvc.Razor;

/// <summary>
/// Defines methods that are used for creating <see cref="IRazorPage"/> instances at a given path.
/// </summary>
public interface IRazorPageFactoryProvider
{
    /// <summary>
    /// Creates a <see cref="IRazorPage"/> factory for the specified path.
    /// </summary>
    /// <param name="relativePath">The path to locate the page.</param>
    /// <returns>The <see cref="RazorPageFactoryResult"/> instance.</returns>
    RazorPageFactoryResult CreateFactory(string relativePath);
}


text:
package com.facebook.buck.rules.modern.builders;

import build.bazel.remote.execution.v2.ExecutedActionMetadata;
import com.facebook.buck.core.build.engine.BuildResult;
import com.facebook.buck.core.build.engine.BuildRuleStatus;
import com.facebook.buck.core.build.engine.BuildStrategyContext;
import com.facebook.buck.core.exceptions.ThrowableCauseIterable;
import com.facebook.buck.core.rules.BuildRule;
import com.facebook.buck.core.rules.build.strategy.BuildRuleStrategy;
import com.facebook.buck.core.util.log.Logger;
import com.facebook.buck.event.BuckEventBus;
import com.facebook.buck.remoteexecution.event.LocalFallbackEvent;
import com.facebook.buck.remoteexecution.event.LocalFallbackEvent.Result;
import com.facebook.buck.remoteexecution.event.RemoteExecutionActionEvent.State;
import com.facebook.buck.remoteexecution.util.MultiThreadedBlobUploader;
import com.facebook.buck.step.StepFailedException;
import com.google.common.base.Preconditions;
import com.google.common.base.Stopwatch;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
import io.grpc.Status;
import io.grpc.StatusRuntimeException;
import java.io.IOException;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

/** Strategy that makes sure failed remote builds fallback to be executed locally. */
public class LocalFallbackStrategy implements BuildRuleStrategy {
  private static final Logger LOG = Logger.get(LocalFallbackStrategy.class);

  private final BuildRuleStrategy mainBuildRuleStrategy;
  private final BuckEventBus eventBus;
  private final boolean localFallbackEnabled;
  private final boolean localFallbackDisabledOnCorruptedArtifacts;
  private final boolean localFallbackEnabledForCompletedAction;

  public LocalFallbackStrategy(
      BuildRuleStrategy mainBuildRuleStrategy,
      BuckEventBus eventBus,
      boolean localFallbackEnabled,
      boolean localFallbackDisabledOnCorruptedArtifacts,
      boolean localFallbackEnabledForCompletedAction) {
    this.mainBuildRuleStrategy = mainBuildRuleStrategy;
    this.eventBus = eventBus;
    this.localFallbackEnabled = localFallbackEnabled;
    this.localFallbackDisabledOnCorruptedArtifacts = localFallbackDisabledOnCorruptedArtifacts;
    this.localFallbackEnabledForCompletedAction = localFallbackEnabledForCompletedAction;
  }

  @Override
  public void close() throws IOException {
    mainBuildRuleStrategy.close();
  }

  @Override
  public StrategyBuildResult build(BuildRule rule, BuildStrategyContext strategyContext) {
    return new FallbackStrategyBuildResult(
        rule.getFullyQualifiedName(),
        mainBuildRuleStrategy.build(rule, strategyContext),
        strategyContext,
        eventBus,
        localFallbackEnabled,
        localFallbackDisabledOnCorruptedArtifacts,
        localFallbackEnabledForCompletedAction);
  }

  @Override
  public boolean canBuild(BuildRule instance) {
    return mainBuildRuleStrategy.canBuild(instance);
  }

  /** Thrown when execution needs to be halted because of cancellation */
  public static class RemoteActionCancelledException extends Exception {
    RemoteActionCancelledException(String message) {
      super(message);
    }
  }

  /** Thrown when execution failed remotely and cannot be retried locally */
  public static class RemoteActionFailedException extends Exception {
    RemoteActionFailedException(String message) {
      super(message);
    }
  }
  /**
   * Contains the combined result of running the remote execution and local execution if necessary.
   */
  static class FallbackStrategyBuildResult implements StrategyBuildResult {
    private final String buildTarget;
    private final StrategyBuildResult remoteStrategyBuildResult;
    private final SettableFuture<Optional<BuildResult>> combinedFinalResult;
    private final BuildStrategyContext strategyContext;
    private final Object lock;
    private final BuckEventBus eventBus;
    private final LocalFallbackEvent.Started startedEvent;
    private final Stopwatch remoteExecutionTimer;
    private final boolean localFallbackEnabled;
    private final boolean localFallbackDisabledOnCorruptedArtifacts;
    private final boolean localFallbackEnabledForCompletedAction;

    private Optional<ListenableFuture<Optional<BuildResult>>> localStrategyBuildResult;
    private boolean hasCancellationBeenRequested;
    private Optional<LocalFallbackEvent.Result> remoteBuildResult;
    private Optional<String> remoteBuildErrorMessage;
    private Status remoteGrpcStatus;
    private State lastNonTerminalState;
    private OptionalInt exitCode;
    private Optional<ExecutedActionMetadata> executedActionMetadata;

    public FallbackStrategyBuildResult(
        String buildTarget,
        StrategyBuildResult remoteStrategyBuildResult,
        BuildStrategyContext strategyContext,
        BuckEventBus eventBus,
        boolean localFallbackEnabled,
        boolean localFallbackDisabledOnCorruptedArtifacts,
        boolean localFallbackEnabledForCompletedAction) {
      this.lock = new Object();
      this.localStrategyBuildResult = Optional.empty();
      this.buildTarget = buildTarget;
      this.remoteStrategyBuildResult = remoteStrategyBuildResult;
      this.strategyContext = strategyContext;
      this.combinedFinalResult = SettableFuture.create();
      this.hasCancellationBeenRequested = false;
      this.eventBus = eventBus;
      this.startedEvent = LocalFallbackEvent.createStarted(buildTarget);
      this.remoteBuildResult = Optional.empty();
      this.remoteExecutionTimer = Stopwatch.createStarted();
      this.remoteBuildErrorMessage = Optional.empty();
      this.localFallbackEnabled = localFallbackEnabled;
      this.localFallbackDisabledOnCorruptedArtifacts = localFallbackDisabledOnCorruptedArtifacts;
      this.localFallbackEnabledForCompletedAction = localFallbackEnabledForCompletedAction;
      this.remoteGrpcStatus = Status.fromCode(Status.Code.OK);
      this.lastNonTerminalState = State.WAITING;
      this.exitCode = OptionalInt.empty();
      this.executedActionMetadata = Optional.empty();

      this.eventBus.post(this.startedEvent);
      this.remoteStrategyBuildResult
          .getBuildResult()
          .addListener(
              () -> onMainBuildFinished(remoteStrategyBuildResult.getBuildResult()),
              MoreExecutors.directExecutor());
    }

    @Override
    public void cancel(Throwable cause) {
      synchronized (lock) {
        hasCancellationBeenRequested = true;
        if (isLocalBuildAlreadyRunning()) {
          // Don't interrupt ongoing local builds to avoid leaving buck-out in a bad state.
          localStrategyBuildResult.get().cancel(/* mayInterruptIfRunning */ false);
        } else {
          remoteStrategyBuildResult.cancel(cause);
        }

        combinedFinalResult.cancel(false);
      }
    }

    @Override
    public boolean cancelIfNotComplete(Throwable reason) {
      synchronized (lock) {
        if (!isLocalBuildAlreadyRunning()
            && remoteStrategyBuildResult.cancelIfNotComplete(reason)) {
          hasCancellationBeenRequested = true;
          return true;
        }
      }

      return false;
    }

    @Override
    public ListenableFuture<Optional<BuildResult>> getBuildResult() {
      return combinedFinalResult;
    }

    private void onMainBuildFinished(ListenableFuture<Optional<BuildResult>> mainBuildResult) {
      synchronized (lock) {
        remoteExecutionTimer.stop();
        try {
          Optional<BuildResult> result = mainBuildResult.get();
          Preconditions.checkState(result.isPresent());
          if (result.get().isSuccess()) {
            // Remote build worked flawlessly first time. :)
            completeCombinedFuture(result, Result.SUCCESS, Result.NOT_RUN);
          } else {
            handleRemoteBuildFailedWithActionError(result);
          }
        } catch (InterruptedException e) {
          if (hasCancellationBeenRequested) {
            completeCombinedFutureWithException(e, Result.INTERRUPTED, Result.NOT_RUN);
            return;
          }
          handleRemoteBuildFailedWithException(e);
        } catch (StatusRuntimeException | ExecutionException e) {
          handleRemoteBuildFailedWithException(e.getCause());
        }
      }
    }

    private void handleRemoteBuildFailedWithActionError(Optional<BuildResult> result) {
      if (result.get().getStatus() == BuildRuleStatus.CANCELED || hasCancellationBeenRequested) {
        LOG.warn("Remote build cancelled: [%s]", result.get().toString());
        remoteBuildResult = Optional.of(Result.CANCELLED);
      } else {
        LOG.warn(
            "Remote build failed so trying locally. The error was: [%s]", result.get().toString());
        remoteBuildResult = Optional.of(Result.FAIL);
      }
      remoteBuildErrorMessage = Optional.of(result.toString());
      if (localFallbackEnabled
          && (!localFallbackDisabledOnCorruptedArtifacts
              || !(MultiThreadedBlobUploader.CorruptArtifactException.isCause(
                  ThrowableCauseIterable.of(result.get().getFailure()))))) {
        fallbackBuildToLocalStrategy();
      } else {
        completeCombinedFuture(result, remoteBuildResult.get(), Result.NOT_RUN);
      }
    }

    private void handleRemoteBuildFailedWithException(Throwable t) {
      remoteBuildResult =
          Optional.of(t instanceof InterruptedException ? Result.INTERRUPTED : Result.EXCEPTION);
      if (t instanceof StepFailedException) {
        StepFailedException exc = (StepFailedException) t;
        exitCode = exc.getExitCode();
        executedActionMetadata = exc.getExecutedActionMetadata();
      }
      remoteGrpcStatus = exitCode.isPresent() ? Status.OK : Status.fromThrowable(t);

      if (remoteStrategyBuildResult
          instanceof RemoteExecutionStrategy.RemoteExecutionStrategyBuildResult) {
        lastNonTerminalState =
            ((RemoteExecutionStrategy.RemoteExecutionStrategyBuildResult) remoteStrategyBuildResult)
                .getRuleContext()
                .lastNonTerminalState;
      }

      remoteBuildErrorMessage = Optional.of(t.toString());
      boolean fallbackEnabledForCurrentResult =
          localFallbackEnabled
              && (localFallbackEnabledForCompletedAction || remoteGrpcStatus != Status.OK);
      if (fallbackEnabledForCurrentResult
          && (!localFallbackDisabledOnCorruptedArtifacts
              || !(MultiThreadedBlobUploader.CorruptArtifactException.isCause(
                  ThrowableCauseIterable.of(t))))) {
        LOG.warn(
            t, "Remote build failed for a build rule so trying locally now for [%s].", buildTarget);
        fallbackBuildToLocalStrategy();
      } else {
        completeCombinedFutureWithException(t, remoteBuildResult.get(), Result.NOT_RUN);
      }
    }

    private void fallbackBuildToLocalStrategy() {
      if (hasCancellationBeenRequested) {
        completeCombinedFutureWithException(
            new RemoteActionCancelledException(
                "Unable to fall back to Local Strategy, execution has been cancelled"),
            Result.CANCELLED,
            Result.NOT_RUN);
        return;
      }
      ListenableFuture<Optional<BuildResult>> future =
          Futures.submitAsync(
              strategyContext::runWithDefaultBehavior, strategyContext.getExecutorService());
      localStrategyBuildResult = Optional.of(future);
      future.addListener(() -> onLocalBuildFinished(future), MoreExecutors.directExecutor());
    }

    private void onLocalBuildFinished(ListenableFuture<Optional<BuildResult>> future) {
      synchronized (lock) {
        try {
          // Remote build failed but local build finished.
          Optional<BuildResult> result = future.get();
          result =
              Optional.of(
                  BuildResult.builder()
                      .from(result.get())
                      .setStrategyResult(
                          "local fallback - "
                              + (result.get().getSuccessOptional().isPresent()
                                  ? "success"
                                  : "fail"))
                      .build());
          completeCombinedFuture(
              result,
              remoteBuildResult.get(),
              result.get().isSuccess() ? Result.SUCCESS : Result.FAIL);
        } catch (InterruptedException e) {
          if (hasCancellationBeenRequested) {
            completeCombinedFutureWithException(e, remoteBuildResult.get(), Result.INTERRUPTED);
            return;
          }
          handleLocalBuildFailedWithException(e);
        } catch (ExecutionException e) {
          handleLocalBuildFailedWithException(e.getCause());
        }
      }
    }

    private void handleLocalBuildFailedWithException(Throwable t) {
      LOG.warn(t, "Local fallback for one build rule failed as well for [%s].", buildTarget);
      completeCombinedFutureWithException(t, remoteBuildResult.get(), Result.EXCEPTION);
    }

    private boolean isLocalBuildAlreadyRunning() {
      return localStrategyBuildResult.isPresent();
    }

    private void completeCombinedFuture(Optional<BuildResult> result, Result remote, Result local) {
      combinedFinalResult.set(result);
      eventBus.post(
          startedEvent.createFinished(
              remote,
              local,
              remoteExecutionTimer.elapsed(TimeUnit.MILLISECONDS),
              remoteBuildErrorMessage,
              remoteGrpcStatus,
              lastNonTerminalState,
              exitCode,
              executedActionMetadata));
    }

    private void completeCombinedFutureWithException(
        Throwable throwable, Result remote, Result local) {
      combinedFinalResult.setException(throwable);
      eventBus.post(
          startedEvent.createFinished(
              remote,
              local,
              remoteExecutionTimer.elapsed(TimeUnit.MILLISECONDS),
              remoteBuildErrorMessage,
              remoteGrpcStatus,
              lastNonTerminalState,
              exitCode,
              executedActionMetadata));
    }
  }
}


text:
// NOTE: Before running, this script requires that testrpc be restarted so that the start block and end blocks required match up for the unit test

// Load contracts
var rocketPoolToken = artifacts.require("./contract/RocketPoolToken.sol");
var rocketPoolCrowdsale = artifacts.require("./contract/RocketPoolCrowdsale.sol");

// Show events
var displayEvents = false;

// Display events triggered during the tests
if(displayEvents) {
    rocketPoolCrowdsale.deployed().then(function (rocketPoolCrowdsaleInstance) {
        var eventWatch = rocketPoolCrowdsaleInstance.allEvents({
            fromBlock: 0,
            toBlock: 'latest',
        }).watch(function (error, result) {
            // Print the event to console
            var printEvent = function(type, result, colour) {
                console.log("\n");
                console.log(colour, '*** '+type.toUpperCase()+' EVENT: ' + result.event + ' *******************************');
                console.log("\n");
                console.log(result.args);
                console.log("\n");
            }
            // This will catch all events, regardless of how they originated.
            if (error == null) {
                // Print the event
                printEvent('rocket', result, '\x1b[33m%s\x1b[0m:');
            }
        });
    });
}

// Print nice titles for each unit test
var printTitle = function(user, desc) {
    return '\x1b[33m'+user+'\033[00m\: \033[01;34m'+desc;
}

// Checks to see if a throw was triggered
var checkThrow = function (error) {
    if(error.toString().indexOf("VM Exception") == -1) {
        // Didn't throw like we expected
        return assert(false, error.toString());
    }
    // Always show out of gas errors
    if(error.toString().indexOf("out of gas") != -1) {
        return assert(false, error.toString());
    }
}

// Start the token and crowdsale tests now
contract('rocketPoolCrowdsale', function (accounts) {

    // Set our crowdsale units
    var exponent = 0;
    var totalSupply = 0;
    var totalSupplyCap = 0;
    // Token price for crowdsale is calculated as maxTargetEth / tokensLimit
    var tokenPriceInEther = 0;
    var totalContributions = 0;

    // Set our crowdsale addresses
    var depositAddress = 0;

    // Our contributers
    var owner = accounts[0];
    var userFirst = accounts[1];
    var userSecond = accounts[2];
    var userThird = accounts[3];
    var userFourth = accounts[4];
    var userFifth = accounts[5];
    var userSixth = accounts[6];

    // Our sales contracts
    var saleContracts = {
        // Type of contract ie crowdsale, crowdsale, quarterly
        'crowdsale': {
            // The min amount to raise to consider the sale a success
            targetEthMin: 0,
            // The max amount the sale agent can raise
            targetEthMax: 0,
            // Maximum tokens the contract can distribute
            tokensLimit: 0,
            // Min ether allowed per deposit
            minDeposit: 0,
            // Max ether allowed per deposit
            maxDeposit: 0,
            // Start block
            fundingStartBlock: 0,
            // End block
            fundingEndBlock: 0,
            // Deposit address that will be allowed to withdraw the crowdsales ether - this is overwritten with the coinbase address for testing here
            depositAddress: 0,
        }
    }

    // Load our token contract settings
    it(printTitle('contractToken', 'load token contract settings'), function () {
        // crowdsale contract
        return rocketPoolToken.deployed().then(function (rocketPoolTokenInstance) {
            // Set the exponent
            return rocketPoolTokenInstance.exponent.call().then(function(result) {
                exponent = result.valueOf();
                // Set the total supply currently in existance
                return rocketPoolTokenInstance.totalSupply.call().then(function(result) {
                    totalSupply = result.valueOf();
                    // Set the total supply cap
                    return rocketPoolTokenInstance.totalSupplyCap.call().then(function(result) {
                        totalSupplyCap = result.valueOf();
                    });
                });
            });
        });
    });

    // Load our crowdsale contract settings
    it(printTitle('contractCrowdsale', 'load crowdsale contract settings'), function () {
        // Token contract
        return rocketPoolToken.deployed().then(function (rocketPoolTokenInstance) {
            // crowdsale contract
            return rocketPoolCrowdsale.deployed().then(function (rocketPoolCrowdsaleInstance) {
                // Get the contract details
                return rocketPoolTokenInstance.getSaleContractTargetEtherMin.call(rocketPoolCrowdsaleInstance.address).then(function(result) {
                    saleContracts.crowdsale.targetEthMin = result.valueOf();
                    return rocketPoolTokenInstance.getSaleContractTargetEtherMax.call(rocketPoolCrowdsaleInstance.address).then(function(result) {
                        saleContracts.crowdsale.targetEthMax = result.valueOf();
                        return rocketPoolTokenInstance.getSaleContractTokensLimit.call(rocketPoolCrowdsaleInstance.address).then(function(result) {
                            saleContracts.crowdsale.tokensLimit = result.valueOf();
                            return rocketPoolTokenInstance.getSaleContractStartBlock.call(rocketPoolCrowdsaleInstance.address).then(function(result) {
                                saleContracts.crowdsale.fundingStartBlock = result.valueOf();
                                return rocketPoolTokenInstance.getSaleContractEndBlock.call(rocketPoolCrowdsaleInstance.address).then(function(result) {
                                    saleContracts.crowdsale.fundingEndBlock = result.valueOf();
                                    return rocketPoolTokenInstance.getSaleContractDepositEtherMin.call(rocketPoolCrowdsaleInstance.address).then(function(result) {
                                        saleContracts.crowdsale.minDeposit = result.valueOf();
                                        return rocketPoolTokenInstance.getSaleContractDepositEtherMax.call(rocketPoolCrowdsaleInstance.address).then(function (result) {
                                            saleContracts.crowdsale.maxDeposit = result.valueOf();
                                            return rocketPoolTokenInstance.getSaleContractDepositAddress.call(rocketPoolCrowdsaleInstance.address).then(function (result) {
                                                saleContracts.crowdsale.depositAddress = result.valueOf();
                                                // Set the token price in ether now - minTargetEth / tokensLimit
                                                tokenPriceInEther = saleContracts.crowdsale.targetEthMin / saleContracts.crowdsale.tokensLimit;
                                                // Log it
                                                console.log("\n");
                                                console.log(printTitle('Sale Agent Details', '--------------------------'));
                                                console.log("\n");
                                                console.log(printTitle(' Target Ether Min', web3.fromWei(saleContracts.crowdsale.targetEthMin, 'ether')));
                                                console.log(printTitle(' Target Ether Max', web3.fromWei(saleContracts.crowdsale.targetEthMax, 'ether')));
                                                console.log(printTitle(' Start Block', saleContracts.crowdsale.fundingStartBlock));
                                                console.log(printTitle(' End Block', saleContracts.crowdsale.fundingEndBlock));
                                                console.log(printTitle(' Min Deposit', web3.fromWei(saleContracts.crowdsale.minDeposit, 'ether')));
                                                console.log(printTitle(' Max Deposit', web3.fromWei(saleContracts.crowdsale.maxDeposit, 'ether')));
                                                console.log(printTitle(' Deposit Address', saleContracts.crowdsale.depositAddress));
                                                console.log(printTitle(' Token Price in Ether', tokenPriceInEther));
                                                console.log("\n");
                                                return saleContracts.crowdsale.depositAddress != 0 ? true : false;
                                            }).then(function (result) {
                                                assert.isTrue(result, "rocketPoolPresaleInstance depositAddress verified.");
                                            });
                                        });
                                    });
                                });
                            });
                        });
                    });
                });
            });
        });
    });

    /*** Tests Start ***********************************/

    it(printTitle('userFirst', 'fail to deposit without depositAddress being verified with sale agent'), function () {
        // Token contract
        return rocketPoolToken.deployed().then(function (rocketPoolTokenInstance) {
            // Crowdsale contract
            return rocketPoolCrowdsale.deployed().then(function (rocketPoolCrowdsaleInstance) {
                // Contribute amount = 1 ether
                var sendAmount = web3.toWei('1', 'ether');
                // Get the contract details
                return rocketPoolCrowdsaleInstance.sendTransaction({ from: userFirst, to: rocketPoolCrowdsaleInstance.address, value: sendAmount, gas: 250000 }).then(function (result) {
                    return result;
                }).then(function(result) {
                    assert(false, "Expect throw but didn't.");
                }).catch(function (error) {
                    return checkThrow(error);
                });
            });
        });
    });

    it(printTitle('depositAddress', 'verify depositAddress with sale agent'), function () {
        // Token contract
        return rocketPoolToken.deployed().then(function (rocketPoolTokenInstance) {
            // Crowdsale contract
            return rocketPoolCrowdsale.deployed().then(function (rocketPoolCrowdsaleInstance) {
                // Get the contract details
                return rocketPoolCrowdsaleInstance.setDepositAddressVerify({ from: saleContracts.crowdsale.depositAddress, gas: 250000 }).then(function (result) {
                    // Token contract, verify our reservefund contract has been verified
                    return rocketPoolTokenInstance.getSaleContractDepositAddressVerified.call(rocketPoolCrowdsaleInstance.address, { from: saleContracts.crowdsale.depositAddress }).then(function (result) {
                        var verified = result.valueOf();
                        return verified == true;
                    }).then(function (result) {
                        assert.isTrue(result, "rocketPoolCrowdsaleInstance depositAddress verified.");
                    });
                });
            });
        });
    });

    // Begin Tests

    it(printTitle('userFirst', 'fails to deposit before the crowdsale begins'), function () {
        // Token contract
        return rocketPoolToken.deployed().then(function (rocketPoolTokenInstance) {
            // Crowdsale contract
            return rocketPoolCrowdsale.deployed().then(function (rocketPoolCrowdsaleInstance) {
                // Contribute amount
                var sendAmount = web3.toWei('1', 'ether');
                // Transaction
                return rocketPoolCrowdsaleInstance.sendTransaction({ from: userFirst, to: rocketPoolCrowdsaleInstance.address, value: sendAmount, gas: 250000 }).then(function (result) {
                    return result;
                }).then(function (result) {
                    assert(false, "Expect throw but didn't.");
                }).catch(function (error) {
                    return checkThrow(error);
                });
            });
        });
    }); // End Test

    // Owner allows sales to begin
    it(printTitle('owner', 'allows deposits to begin'), function () {
        // Token contract
        return rocketPoolToken.deployed().then(function (rocketPoolTokenInstance) {
            // Crowdsale contract
            return rocketPoolCrowdsale.deployed().then(function (rocketPoolCrowdsaleInstance) {
                // Transaction
                return rocketPoolCrowdsaleInstance.setSaleDepositsAllowed(true, { from: owner, to: rocketPoolCrowdsaleInstance.address, gas: 250000 }).then(function (result) {
                    // Get the contribution balance of their account now
                    return rocketPoolCrowdsaleInstance.saleDepositsAllowed.call().then(function (result) {
                        return result.valueOf();
                    }).then(function (result) {
                        assert.isTrue(result, "Deposits allowed to begin successfully.");
                    });
                });
            });
        });
    }); // End Test

    // START OF SALES

    it(printTitle('userFirst', 'makes successful deposit to crowdsale of 0.1 ether'), function () {
        // Crowdsale contract
        return rocketPoolCrowdsale.deployed().then(function (rocketPoolCrowdsaleInstance) {
            // Contribute amount
            var sendAmount = Number(web3.toWei('0.1', 'ether'));
            // Get the contribution balance of their account now
            return rocketPoolCrowdsaleInstance.getContributionOf.call(userFirst).then(function (result) {
                // Original contribution amount
                var contributionTotal = Number(result.valueOf());
                // Transaction
                return rocketPoolCrowdsaleInstance.sendTransaction({ from: userFirst, to: rocketPoolCrowdsaleInstance.address, value: sendAmount, gas: 250000 }).then(function (result) {
                    // Get the contribution balance of their account now
                    return rocketPoolCrowdsaleInstance.getContributionOf.call(userFirst).then(function (result) {
                        return result.valueOf() == contributionTotal + sendAmount ? true : false;
                    });
                }).then(function (result) {
                    assert.isTrue(result, "Contribution made successfully.");
                });
            });
        });
    }); // End Test

    it(printTitle('userSecond', 'makes successful deposit to crowdsale of 0.1 ether'), function () {
        // Crowdsale contract
        return rocketPoolCrowdsale.deployed().then(function (rocketPoolCrowdsaleInstance) {
            // Contribute amount
            var sendAmount = Number(web3.toWei('0.1', 'ether'));
            // Get the contribution balance of their account now
            return rocketPoolCrowdsaleInstance.getContributionOf.call(userSecond).then(function (result) {
                // Original contribution amount
                var contributionTotal = Number(result.valueOf());
                // Transaction
                return rocketPoolCrowdsaleInstance.sendTransaction({ from: userSecond, to: rocketPoolCrowdsaleInstance.address, value: sendAmount, gas: 250000 }).then(function (result) {
                    // Get the contribution balance of their account now
                    return rocketPoolCrowdsaleInstance.getContributionOf.call(userSecond).then(function (result) {
                        return result.valueOf() == contributionTotal + sendAmount ? true : false;
                    });
                }).then(function (result) {
                    assert.isTrue(result, "Contribution made successfully.");
                });
            });
        });
    }); // End Test

    it(printTitle('userSecond', 'makes successful deposit to crowdsale of 0.1 ether'), function () {
        // Crowdsale contract
        return rocketPoolCrowdsale.deployed().then(function (rocketPoolCrowdsaleInstance) {
            // Contribute amount
            var sendAmount = Number(web3.toWei('0.1', 'ether'));
            // Get the contribution balance of their account now
            return rocketPoolCrowdsaleInstance.getContributionOf.call(userSecond).then(function (result) {
                // Original contribution amount
                var contributionTotal = Number(result.valueOf());
                // Transaction
                return rocketPoolCrowdsaleInstance.sendTransaction({ from: userSecond, to: rocketPoolCrowdsaleInstance.address, value: sendAmount, gas: 250000 }).then(function (result) {
                    // Get the contribution balance of their account now
                    return rocketPoolCrowdsaleInstance.getContributionOf.call(userSecond).then(function (result) {
                        return result.valueOf() == contributionTotal + sendAmount ? true : false;
                    });
                }).then(function (result) {
                    assert.isTrue(result, "Contribution made successfully.");
                });
            });
        });
    }); // End Test

    it(printTitle('userSixth', 'makes successful deposit to crowdsale of 0.14532349 ether'), function () {
        // Crowdsale contract
        return rocketPoolCrowdsale.deployed().then(function (rocketPoolCrowdsaleInstance) {
            // Contribute amount
            var sendAmount = Number(web3.toWei('0.14532349', 'ether'));
            // Get the contribution balance of their account now
            return rocketPoolCrowdsaleInstance.getContributionOf.call(userSixth).then(function (result) {
                // Original contribution amount
                var contributionTotal = Number(result.valueOf());
                // Transaction
                return rocketPoolCrowdsaleInstance.sendTransaction({ from: userSixth, to: rocketPoolCrowdsaleInstance.address, value: sendAmount, gas: 250000 }).then(function (result) {
                    // Get the contribution balance of their account now
                    return rocketPoolCrowdsaleInstance.getContributionOf.call(userSixth).then(function (result) {
                        return result.valueOf() == contributionTotal + sendAmount ? true : false;
                    });
                }).then(function (result) {
                    assert.isTrue(result, "Contribution made successfully.");
                });
            });
        });
    }); // End Test

    // Owner ends public sale
    it(printTitle('owner', 'closes deposits and allows token withdrawals + refunds to begin'), function () {
        // Token contract
        return rocketPoolToken.deployed().then(function (rocketPoolTokenInstance) {
            // Crowdsale contract
            return rocketPoolCrowdsale.deployed().then(function (rocketPoolCrowdsaleInstance) {
                // Transaction
                return rocketPoolCrowdsaleInstance.setSaleDepositsAllowed(false, { from: owner, to: rocketPoolCrowdsaleInstance.address, gas: 250000 }).then(function (result) {
                    // Get the contribution balance of their account now
                    return rocketPoolCrowdsaleInstance.saleDepositsAllowed.call().then(function (result) {
                        return result.valueOf();
                    }).then(function (result) {
                        assert.isFalse(result, "Deposits closed successfully.");
                    });
                });
            });
        });
    }); // End Test

     // ******* Crowdsale closes **************

     it(printTitle('userFourth', 'fails to make deposit to crowdsale of 0.1 ether as crowdsale end block is hit'), function () {
        // Token contract
        return rocketPoolToken.deployed().then(function (rocketPoolTokenInstance) {
            // Crowdsale contract
            return rocketPoolCrowdsale.deployed().then(function (rocketPoolCrowdsaleInstance) {
                // Contribute amount
                var sendAmount = web3.toWei('0.1', 'ether');
                // Transaction
                return rocketPoolCrowdsaleInstance.sendTransaction({ from: userFourth, to: rocketPoolCrowdsaleInstance.address, value: sendAmount, gas: 250000 }).then(function (result) {
                    return result;
                }).then(function (result) {
                    assert(false, "Expect throw but didn't.");
                }).catch(function (error) {
                    return checkThrow(error);
                });
            });
        });
    }); // End Test

   it(printTitle('owner', 'confirm targetEther was not sent'), function () {
        // Crowdsale contract
        return rocketPoolCrowdsale.deployed().then(function (rocketPoolCrowdsaleInstance) {
            // Transaction
            return rocketPoolCrowdsaleInstance.targetEthSent.call().then(function(result) {
                   return result.valueOf();
            }).then(function (result) {
                assert.isFalse(result, "TargetEther not sent.");
            });
        });
     }); // End Test

    it(printTitle('userFirst', 'claims his refund and has a 0 token balance'), function () {
        // Token contract
        return rocketPoolToken.deployed().then(function (rocketPoolTokenInstance) {
            // Crowdsale contract
            return rocketPoolCrowdsale.deployed().then(function (rocketPoolCrowdsaleInstance) {
                // Get the users current ether balance
                var userFirstBalance = Number(web3.eth.getBalance(userFirst).valueOf());
                // Get the contribution balance of their account now
                return rocketPoolCrowdsaleInstance.getContributionOf.call(userFirst).then(function (result) {
                    // Contribution
                    var firstUsercontributionTotal = parseFloat(result.valueOf());
                    // Transaction
                    return rocketPoolCrowdsaleInstance.claimTokensAndRefund({ from: userFirst, to: rocketPoolCrowdsaleInstance.address, gas: 250000 }).then(function (result) {
                        // Get the events
                        var refund = 0;
                        for(var i=0; i < result.logs.length; i++) {
                            if(result.logs[i].event == 'Refund') {
                                refund = result.logs[i].args._value.valueOf();
                            }
                        };
                        // Get the total tokens allowed to be made by this agent
                        return rocketPoolTokenInstance.getSaleContractTokensLimit.call(rocketPoolCrowdsaleInstance.address).then(function (result) {
                            // Total tokens available
                            var totalTokensAvailable = parseFloat(result.valueOf());
                            // Get the contribution balance of their account now after withdrawing
                            return rocketPoolCrowdsaleInstance.getContributionOf.call(userFirst).then(function (result) {
                                // Contributions total now
                                var firstUsercontributionTotalAfter = parseFloat(result.valueOf());
                                // Get the contribution balance of their account now after withdrawing
                                return rocketPoolTokenInstance.balanceOf.call(userFirst).then(function (result) {
                                    // Token total now
                                    var tokenTotalAfter = parseFloat(result.valueOf());
                                    // Get the users current ether balance after withdrawing tokens, should have the refund
                                    var userFirstBalanceAfter = web3.eth.getBalance(userFirst).valueOf();
                                    // Calculate tokens were not given out and the user received their refund
                                    //console.log(refund);
                                    //console.log(firstUsercontributionTotal);
                                         // Calculate tokens were not given out and the user received their refund
                                        return tokenTotalAfter == 0 &&
                                               Number(refund) == Number(firstUsercontributionTotal) ? true : false;
                                }).then(function (result) {
                                    assert.isTrue(result, "Withdrawn refund.");
                                });
                            });
                        });
                    });
                });
            });
        });
   }); // End Test

   it(printTitle('userSecond', 'claims his refund and has a 0 token balance'), function () {
        // Token contract
        return rocketPoolToken.deployed().then(function (rocketPoolTokenInstance) {
            // Crowdsale contract
            return rocketPoolCrowdsale.deployed().then(function (rocketPoolCrowdsaleInstance) {
                // Get the users current ether balance
                var userSecondBalance = Number(web3.eth.getBalance(userSecond).valueOf());
                // Get the contribution balance of their account now
                return rocketPoolCrowdsaleInstance.getContributionOf.call(userSecond).then(function (result) {
                    // Contribution
                    var userSecondcontributionTotal = parseFloat(result.valueOf());
                    // Transaction
                    return rocketPoolCrowdsaleInstance.claimTokensAndRefund({ from: userSecond, to: rocketPoolCrowdsaleInstance.address, gas: 250000 }).then(function (result) {
                        // Get the events
                        var refund = 0;
                        for(var i=0; i < result.logs.length; i++) {
                            if(result.logs[i].event == 'Refund') {
                                refund = result.logs[i].args._value.valueOf();
                            }
                        };
                        // Get the total tokens allowed to be made by this agent
                        return rocketPoolTokenInstance.getSaleContractTokensLimit.call(rocketPoolCrowdsaleInstance.address).then(function (result) {
                            // Total tokens available
                            var totalTokensAvailable = parseFloat(result.valueOf());
                            // Get the contribution balance of their account now after withdrawing
                            return rocketPoolCrowdsaleInstance.getContributionOf.call(userSecond).then(function (result) {
                                // Contributions total now
                                var userSecondcontributionTotalAfter = parseFloat(result.valueOf());
                                // Get the contribution balance of their account now after withdrawing
                                return rocketPoolTokenInstance.balanceOf.call(userSecond).then(function (result) {
                                    // Token total now
                                    var tokenTotalAfter = parseFloat(result.valueOf());
                                    // Get the users current ether balance after withdrawing tokens, should have the refund
                                    var userSecondBalanceAfter = web3.eth.getBalance(userSecond).valueOf();
                                         // Calculate tokens were not given out and the user received their refund
                                         //console.log(refund);
                                         //console.log(userSecondcontributionTotal);
                                        return tokenTotalAfter == 0 && Number(refund) == Number(userSecondcontributionTotal) ? true : false;
                                }).then(function (result) {
                                    assert.isTrue(result, "Withdrawn refund.");
                                });
                            });
                        });
                    });
                });
            });
        });
    }); // End Test

    it(printTitle('userSixth', 'claims his refund and has a 0 token balance'), function () {
        // Token contract
        return rocketPoolToken.deployed().then(function (rocketPoolTokenInstance) {
            // Crowdsale contract
            return rocketPoolCrowdsale.deployed().then(function (rocketPoolCrowdsaleInstance) {
                // Get the users current ether balance
                var userSixthBalance = Number(web3.eth.getBalance(userSixth).valueOf());
                // Get the contribution balance of their account now
                return rocketPoolCrowdsaleInstance.getContributionOf.call(userSixth).then(function (result) {
                    // Contribution
                    var userSixthcontributionTotal = parseFloat(result.valueOf());
                    // Transaction
                    return rocketPoolCrowdsaleInstance.claimTokensAndRefund({ from: userSixth, to: rocketPoolCrowdsaleInstance.address, gas: 250000 }).then(function (result) {
                        // Get the events
                        var refund = 0;
                        for(var i=0; i < result.logs.length; i++) {
                            if(result.logs[i].event == 'Refund') {
                                refund = result.logs[i].args._value.valueOf();
                            }
                        };
                        // Get the total tokens allowed to be made by this agent
                        return rocketPoolTokenInstance.getSaleContractTokensLimit.call(rocketPoolCrowdsaleInstance.address).then(function (result) {
                            // Total tokens available
                            var totalTokensAvailable = parseFloat(result.valueOf());
                            // Get the contribution balance of their account now after withdrawing
                            return rocketPoolCrowdsaleInstance.getContributionOf.call(userSixth).then(function (result) {
                                // Contributions total now
                                var userSixthcontributionTotalAfter = parseFloat(result.valueOf());
                                // Get the contribution balance of their account now after withdrawing
                                return rocketPoolTokenInstance.balanceOf.call(userSixth).then(function (result) {
                                    // Token total now
                                    var tokenTotalAfter = parseFloat(result.valueOf());
                                    // Get the users current ether balance after withdrawing tokens, should have the refund
                                    var userSixthBalanceAfter = web3.eth.getBalance(userSixth).valueOf();
                                    // Calculate tokens were not given out and the user received their refund
                                    //console.log(tokenTotalAfter);
                                    //console.log(Number(web3.fromWei(userSixthBalanceAfter, 'ether')).toFixed(2));
                                    //console.log(Number(web3.fromWei(userSixthBalance + userSixthcontributionTotal, 'ether')).toFixed(2));
                                         // Calculate tokens were not given out and the user received their refund
                                         return tokenTotalAfter == 0 && Number(refund) == Number(userSixthcontributionTotal) ? true : false;
                                }).then(function (result) {
                                    assert.isTrue(result, "Withdrawn refund.");
                                });
                            });
                        });
                    });
                });
            });
        });
    }); // End Test

    it(printTitle('userFourth', 'fails to make deposit to crowdsale of 0.1 ether as crowdsale target was not met and is over'), function () {
        // Token contract
        return rocketPoolToken.deployed().then(function (rocketPoolTokenInstance) {
            // Crowdsale contract
            return rocketPoolCrowdsale.deployed().then(function (rocketPoolCrowdsaleInstance) {
                // Contribute amount
                var sendAmount = web3.toWei('0.1', 'ether');
                // Transaction
                return rocketPoolCrowdsaleInstance.sendTransaction({ from: userFourth, to: rocketPoolCrowdsaleInstance.address, value: sendAmount, gas: 250000 }).then(function (result) {
                    return result;
                }).then(function (result) {
                    assert(false, "Expect throw but didn't.");
                }).catch(function (error) {
                    return checkThrow(error);
                });
            });
        });
    }); // End Test

     it(printTitle('crowdsaleContract', 'minted tokens = 0 and sale agent balance = 0'), function () {
        // Token contract
        return rocketPoolToken.deployed().then(function (rocketPoolTokenInstance) {
            // Crowdsale contract
            return rocketPoolCrowdsale.deployed().then(function (rocketPoolCrowdsaleInstance) {
                // Get the users current ether balance
                var userFirstBalance = Number(web3.eth.getBalance(userFirst).valueOf());
                // Get the contribution balance of their account now
                return rocketPoolTokenInstance.getSaleContractTokensMinted.call(rocketPoolCrowdsaleInstance.address).then(function (result) {
                    // Check the amount of ether the contract still holds
                    var contractEther = web3.eth.getBalance(rocketPoolCrowdsaleInstance.address).valueOf();
                    // No tokens minted?
                    return parseFloat(result.valueOf()) == 0 && contractEther == 0 ? true : false;
                }).then(function (result) {
                    assert.isTrue(result, "Crowdsale minted tokens = 0.");
                });
            });
        });
   }); // End Test

   /** REGISTER ANOTHER SALE AGENT CROWDSALE */

   // Begin Tests
    it(printTitle('owner', 'register another crowdsale agent since the first was not successfull'), function () {
        // Contract
        return rocketPoolToken.deployed().then(function (rocketPoolTokenInstance) {
            // Transaction
            return rocketPoolTokenInstance.setSaleAgentContract(
                userFirst,
                'nextcrowdsalecontract',
                1,          // Min target ether
                100,        // Max target ether
                saleContracts.crowdsale.tokensLimit, // Token limit
                0,          // Min deposit
                100,        // Max deposit
                0,          // Start block
                5000,       // End block
                saleContracts.crowdsale.depositAddress,
                { from: owner, gas: 550000 }).then(function (result) {
                    // Check its registered
                    return rocketPoolTokenInstance.getSaleContractTokensLimit.call(userFirst).then(function (result) {
                        // Check the token total was registered
                        return result.valueOf() == saleContracts.crowdsale.tokensLimit ? true : false;
                    }).then(function (result) {
                        assert.isTrue(result, "New crowdsale contract deployed.");
                    });
                });
        });
     }); // End Test

});


text:
// This file is part of the dune-gdt project:
//   http://users.dune-project.org/projects/dune-gdt
// Copyright holders: Felix Schindler
// License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)

#ifndef DUNE_GDT_TESTS_LINEARELLIPTIC_DISCRETIZERS_CG_HH
#define DUNE_GDT_TESTS_LINEARELLIPTIC_DISCRETIZERS_CG_HH

#include <dune/stuff/common/timedlogging.hh>
#include <dune/stuff/common/memory.hh>
#include <dune/stuff/grid/boundaryinfo.hh>
#include <dune/stuff/grid/layers.hh>
#include <dune/stuff/grid/provider.hh>
#include <dune/stuff/la/container.hh>

#include <dune/gdt/assembler/system.hh>
#include <dune/gdt/discretizations/default.hh>
#include <dune/gdt/discretefunction/default.hh>
#include <dune/gdt/functionals/l2.hh>
#include <dune/gdt/operators/projections.hh>
#include <dune/gdt/playground/operators/elliptic-cg.hh>
#include <dune/gdt/spaces/cg.hh>
#include <dune/gdt/spaces/constraints.hh>

#include "../problems/interface.hh"
#include "base.hh"

namespace Dune {
namespace GDT {
namespace LinearElliptic {

/**
 * \brief Discretizes a linear elliptic PDE using a continuous Galerkin Finite Element method.
 * \tparam GG GridType
 * \tparam ll layer
 * \tparam ss space_backend
 * \tparam la la_backend
 * \tparam pp polOrder
 * \tparam RR RangeFieldType
 * \tparam rr dimRange
 */
template< class GridType,
          Stuff::Grid::ChooseLayer layer = Stuff::Grid::ChooseLayer::leaf,
          ChooseSpaceBackend space_backend = Spaces::default_cg_backend,
          Stuff::LA::ChooseBackend la_backend = Stuff::LA::default_sparse_backend,
          int pol = 1,
          class RangeFieldType = double,
          size_t dimRange = 1 >
class CGDiscretizer
{
public:
  typedef ProblemInterface< typename GridType::template Codim< 0 >::Entity,
                            typename GridType::ctype,
                            GridType::dimension,
                            RangeFieldType,
                            dimRange > ProblemType;
  typedef Spaces::CGProvider< GridType, layer, space_backend, pol, RangeFieldType, dimRange > SpaceProvider;
  typedef typename SpaceProvider::Type                                                        SpaceType;
  typedef typename Stuff::LA::Container< RangeFieldType, la_backend >::MatrixType             MatrixType;
  typedef typename Stuff::LA::Container< RangeFieldType, la_backend >::VectorType             VectorType;
  typedef Discretizations::StationaryContainerBasedDefault
      < ProblemType, SpaceType, MatrixType, VectorType, SpaceType >                           DiscretizationType;
  static const constexpr ChooseDiscretizer type = ChooseDiscretizer::cg;
  static const int polOrder = pol;

  static std::string static_id()
  {                                                                                // int() needed, otherwise we get a linker error
    return std::string("gdt.linearelliptic.discretization.cg.order_") + DSC::toString(int(polOrder));
  }

  static DiscretizationType discretize(Stuff::Grid::ProviderInterface< GridType >& grid_provider,
                                       const ProblemType& problem,
                                       const int level = 0)
  {
    auto logger = Stuff::Common::TimedLogger().get(static_id());
    logger.info() << "Creating space... " << std::endl;
    auto space = SpaceProvider::create(grid_provider, level);
    logger.debug() << "grid has " << space.grid_view().indexSet().size(0) << " elements" << std::endl;
    typedef typename SpaceType::GridViewType    GridViewType;
    typedef typename GridViewType::Intersection IntersectionType;
    auto boundary_info = Stuff::Grid::BoundaryInfoProvider< IntersectionType >::create(problem.boundary_info_cfg());
    logger.info() << "Assembling... " << std::endl;
    VectorType rhs_vector(space.mapper().size(), 0.0);
    auto elliptic_operator = Operators::make_elliptic_cg< MatrixType >(problem.diffusion_factor(),
                                                                       problem.diffusion_tensor(),
                                                                       space);
    auto l2_force_functional = Functionals::make_l2_volume(problem.force(), rhs_vector, space);
    auto l2_neumann_functional
        = Functionals::make_l2_face(problem.neumann(),
                                    rhs_vector,
                                    space,
                                    new Stuff::Grid::ApplyOn::NeumannIntersections< GridViewType >(*boundary_info));
    // prepare the dirichlet projection
    auto dirichlet_function = make_discrete_function< VectorType >(space, "dirichlet values");
    auto dirichlet_projection = Operators::make_localizable_dirichlet_projection(space.grid_view(),
                                                                                *boundary_info,
                                                                                problem.dirichlet(),
                                                                                dirichlet_function);
    Spaces::DirichletConstraints< IntersectionType > dirichlet_constraints(*boundary_info, space.mapper().size());
    // register everything for assembly in one grid walk
    SystemAssembler< SpaceType > assembler(space);
    assembler.add(*elliptic_operator);
    assembler.add(*l2_force_functional);
    assembler.add(*l2_neumann_functional);
    assembler.add(dirichlet_projection);
    assembler.add(dirichlet_constraints);
    assembler.assemble();
    // assemble the dirichlet shift
    auto& system_matrix = elliptic_operator->matrix();
    auto& dirichlet_shift = dirichlet_function.vector();
    rhs_vector -= system_matrix * dirichlet_shift;
    dirichlet_constraints.apply(system_matrix, rhs_vector);
    // create the discretization (no copy of the containers done here, bc. of cow)
    return DiscretizationType(problem, space, system_matrix, rhs_vector, dirichlet_shift);
  } // ... discretize(...)
}; // class CGDiscretizer

} // namespace LinearElliptic
} // namespace GDT
} // namespace Dune

#endif // DUNE_GDT_TESTS_LINEARELLIPTIC_DISCRETIZERS_CG_HH


text:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/default_background_colour">

    <ImageView
        android:id="@+id/ivFinalImage"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="20dp"
        android:background="@color/default_background_colour"
        android:contentDescription="@null" />

    <com.github.clans.fab.FloatingActionButton
        android:id="@+id/fabSave"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:src="@drawable/ic_launcher"
        fab:fab_colorNormal="@color/default_text_colour"
        fab:fab_colorPressed="@color/white"
        fab:fab_colorRipple="@color/default_transparency" />

    <com.github.clans.fab.FloatingActionMenu
        android:id="@+id/fabMenu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        fab:menu_animationDelayPerItem="50"
        fab:menu_backgroundColor="@android:color/transparent"
        fab:menu_buttonSpacing="0dp"
        fab:menu_colorNormal="@color/default_ab_background_colour"
        fab:menu_colorPressed="@color/black"
        fab:menu_colorRipple="#99FFFFFF"
        fab:menu_fab_label="Share"
        fab:menu_fab_size="normal"
        fab:menu_icon="@drawable/ic_launcher"
        fab:menu_labels_colorNormal="#333333"
        fab:menu_labels_colorPressed="#444444"
        fab:menu_labels_colorRipple="#66FFFFFF"
        fab:menu_labels_cornerRadius="3dp"
        fab:menu_labels_ellipsize="none"
        fab:menu_labels_margin="0dp"
        fab:menu_labels_maxLines="-1"
        fab:menu_labels_paddingBottom="4dp"
        fab:menu_labels_paddingLeft="8dp"
        fab:menu_labels_paddingRight="8dp"
        fab:menu_labels_paddingTop="4dp"
        fab:menu_labels_position="left"
        fab:menu_labels_showShadow="true"
        fab:menu_labels_singleLine="false"
        fab:menu_labels_textColor="#FFFFFF"
        fab:menu_labels_textSize="14sp"
        fab:menu_openDirection="up"
        fab:menu_shadowColor="#66000000"
        fab:menu_shadowRadius="4dp"
        fab:menu_shadowXOffset="1dp"
        fab:menu_shadowYOffset="3dp"
        fab:menu_showShadow="true">

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/fabOdnoklassniki"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"
            fab:fab_colorNormal="@color/default_text_colour"
            fab:fab_colorPressed="@color/white"
            fab:fab_colorRipple="@color/default_transparency"
            fab:fab_label="Odnoklassniki" />

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/fabInstagram"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"
            fab:fab_colorNormal="@color/default_text_colour"
            fab:fab_colorPressed="@color/white"
            fab:fab_colorRipple="@color/default_transparency"
            fab:fab_label="Instagram" />

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/fabTwitter"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"
            fab:fab_colorNormal="@color/default_text_colour"
            fab:fab_colorPressed="@color/white"
            fab:fab_colorRipple="@color/default_transparency"
            fab:fab_label="Twitter" />

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/fabFacebook"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"
            fab:fab_colorNormal="@color/default_text_colour"
            fab:fab_colorPressed="@color/white"
            fab:fab_colorRipple="@color/default_transparency"
            fab:fab_label="Facebook" />

        <com.github.clans.fab.FloatingActionButton
            android:id="@+id/fabVk"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:src="@drawable/ic_launcher"
            fab:fab_colorNormal="@color/default_text_colour"
            fab:fab_colorPressed="@color/white"
            fab:fab_colorRipple="@color/default_transparency"
            fab:fab_label="VK" />

    </com.github.clans.fab.FloatingActionMenu>
</RelativeLayout>


text:
/**
 * This code was generated by
 * \ / _    _  _|   _  _
 *  | (_)\/(_)(_|\/| |(/_  v1.0.0
 *       /       /
 */

import Version = require('../../base/Version');
import Video = require('../Video');
import { CompositionHookList } from './v1/compositionHook';
import { CompositionHookListInstance } from './v1/compositionHook';
import { CompositionList } from './v1/composition';
import { CompositionListInstance } from './v1/composition';
import { CompositionSettingsList } from './v1/compositionSettings';
import { CompositionSettingsListInstance } from './v1/compositionSettings';
import { RecordingList } from './v1/recording';
import { RecordingListInstance } from './v1/recording';
import { RecordingSettingsList } from './v1/recordingSettings';
import { RecordingSettingsListInstance } from './v1/recordingSettings';
import { RoomList } from './v1/room';
import { RoomListInstance } from './v1/room';

declare class V1 extends Version {
  /**
   * Initialize the V1 version of Video
   *
   * @param domain - The twilio domain
   */
  constructor(domain: Video);

  readonly compositionHooks: CompositionHookListInstance;
  readonly compositionSettings: CompositionSettingsListInstance;
  readonly compositions: CompositionListInstance;
  readonly recordingSettings: RecordingSettingsListInstance;
  readonly recordings: RecordingListInstance;
  readonly rooms: RoomListInstance;
}

export = V1;


text:
<?php

namespace DigitalOceanV2\Entity;

/**
 * @author Antoine Corcy <contact@sbin.dk>
 * @author Graham Campbell <graham@alt-three.com>
 */
final class Account extends AbstractEntity
{
    /**
     * @var int
     */
    public $dropletLimit;

    /**
     * @var int
     */
    public $floatingIpLimit;

    /**
     * @var string
     */
    public $email;

    /**
     * @var string
     */
    public $uuid;

    /**
     * @var bool
     */
    public $emailVerified;

    /**
     * @var string
     */
    public $status;

    /**
     * @var string
     */
    public $statusMessage;
}


text:
using System;
using System.Windows.Forms;

namespace Winbot.Entities
{
    [Serializable]
    public class MouseUp : UserAction
    {
        public MouseButtons Button { get; set; }
        public int X { get; set; }
        public int Y { get; set; }
        public override string Description => $"Mouse {Button.ToString().ToLower()} button up, X: {X}, Y:{Y}";
    }
}


text:
package com.dubboclub.monitor;

import java.util.List;

import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.monitor.MonitorService;

/**
 * Created by bieber on 2015/6/1.
 *
 * @author bieber
 * @author shevawen
 *
 */
public class DubboKeeperMonitorService implements MonitorService {

	private static final String POISON_PROTOCOL = "poison";

	public DubboKeeperMonitorService() {

	}

	@Override
	public void collect(URL statistics) {

	}

	@Override
	public List<URL> lookup(URL url) {
		return null;
	}
}


text:
import styled from 'styled-components'
import { assertUnreachable } from '../../common/assert-unreachable'
import { RaceChar } from '../../common/races'

/* Primary color */
export const blue50 = '#e3f2fd'
export const blue100 = '#bbdefb'
export const blue200 = '#90caf9'
export const blue300 = '#64b5f6'
export const blue400 = '#42a5f5'
export const blue500 = '#2196f3'
export const blue600 = '#1e88e5'
export const blue700 = '#1976d2'
export const blue800 = '#1565c0'
export const blue900 = '#0d47a1'

/* Accent color */
export const amberA100 = '#ffe57f'
export const amberA200 = '#ffd740'
export const amberA400 = '#ffc400'
export const amberA700 = '#ffab00'

/* Greys (for backgrounds) */
/** @deprecated */
export const grey700 = '#505762'
/** @deprecated */
export const grey800 = '#353D45'
/** @deprecated */
export const grey850 = '#252A31'
/** @deprecated */
export const grey900 = '#1B1E22'

/** Colors used for backgrounds (a muted grey-blue palette) */
export const background50 = '#7B97BA'
export const background100 = '#6584AA'
export const background200 = '#577598'
export const background300 = '#466180'
export const background400 = '#30455F'
export const background500 = '#243951'
export const background600 = '#1D2F44'
export const background700 = '#142539'
export const background800 = '#0E1B2A'
export const background900 = '#091320'

/** Background colors used for accenting particularly prominent UI. */
export const backgroundSaturatedLight = '#02498C'
export const backgroundSaturatedDark = '#034078'

export const alphaDividers = 0.12
export const alphaDisabled = 0.5

export const colorText = '#ffffff'

export const colorDividers = `rgba(255, 255, 255, ${alphaDividers})`
export const colorTextFaint = '#8998a9'
export const colorTextSecondary = '#cdddee'
export const colorTextPrimary = '#ffffff'
export const colorTextInvert = 'rgba(0, 0, 0, 0.87)'
export const colorTextInvertSecondary = 'rgba(0, 0, 0, 0.6)'

export const colorBackground = background800
export const colorError = '#ff6e6e'
export const colorSuccess = '#66bb6a'

/** Color used to indicate something positive (e.g. winning). */
export const colorPositive = '#69f0ae'
/** Color used to indicate something negative (e.g. losing). */
export const colorNegative = '#e66060'

export const colorZerg = '#c1a3f5'
export const colorProtoss = '#ffe57f'
export const colorTerran = '#89bbf5'
export const colorRandom = '#f5a63d'

export function getRaceColor(race: RaceChar) {
  switch (race) {
    case 'z':
      return colorZerg
    case 'p':
      return colorProtoss
    case 't':
      return colorTerran
    case 'r':
      return colorRandom
    default:
      return assertUnreachable(race)
  }
}

export const dialogScrim = background900

export const CardLayer = styled.div`
  background-color: ${background400};
`


text:
{{ partial "new-head" . }}

{{ if (eq (trim .Site.Params.provider " " | lower) "github") | and (isset .Site.Params "repo_url") }}
	{{ $repo_id := replace .Site.Params.repo_url "https://github.com/" ""}}
	{{ .Scratch.Set "repo_id" $repo_id }}
{{ end }}

			menu

			Jetprobe

Documentation

Github

Introduction

Getting Started

Roadmap

License

		{{ partial "drawer.html" (dict "page" . "menuName" "sidebar") }}

{{ .Title }} {{ if .IsDraft }} (Draft){{ end }}

			{{ .Content }}

{{ partial "footer" .}}
{{ partial "footer_js" . }}