text:
class Task < ActiveRecord::Base
  belongs_to :project
  attr_accessible :name, :complete
end


text:
namespace dawgdic {

class RankedCompleterCandidate {
 public:
  RankedCompleterCandidate() : node_index_(0), value_(-1) {}

  void set_node_index(BaseType node_index) {
    node_index_ = node_index;
  }
  void set_value(ValueType value) {
    value_ = value;
  }

  BaseType node_index() const {
    return node_index_;
  }
  ValueType value() const {
    return value_;
  }

  template <typename VALUE_COMPARER_TYPE>
  class Comparer {
   public:
    typedef VALUE_COMPARER_TYPE ValueComparerType;

    explicit Comparer(ValueComparerType value_comparer)
      : value_comparer_(value_comparer) {}

    bool operator()(const RankedCompleterCandidate &lhs,
                    const RankedCompleterCandidate &rhs) const {
      if (lhs.value() != rhs.value()) {
        return value_comparer_(lhs.value(), rhs.value());
      }
      return lhs.node_index() > rhs.node_index();
    }

   private:
    ValueComparerType value_comparer_;
  };

  template <typename VALUE_COMPARER_TYPE>
  static Comparer<VALUE_COMPARER_TYPE> MakeComparer(
      VALUE_COMPARER_TYPE value_comparer) {
    return Comparer<VALUE_COMPARER_TYPE>(value_comparer);
  }

 private:
  BaseType node_index_;
  ValueType value_;

  // Copyable.
};

}  // namespace dawgdic

#endif  // DAWGDIC_RANKED_COMPLETER_CANDIDATE_H

redpajama_set_name: RedPajamaGithub


text:
require 'spec_helper'

describe Card::Annotation do
  it_behaves_like 'Card', :annotation
  it_behaves_like 'Orderable', :annotation
  it_behaves_like 'Orderable Scoped incrementation', [:annotation], :annotatable

  describe '.ordered_by_position' do
    let(:annotation) { FactoryGirl.create(:annotation) }
    it { expect(Card::Annotation).to be_respond_to(:ordered_by_position) }
  end

  describe '#is_taggable?' do
    let(:annotation) { FactoryGirl.create(:annotation) }
    subject { annotation.is_taggable? }
    it { is_expected.to be false }
  end

  describe '#to_state!(recipe)' do
    let!(:annotation) { FactoryGirl.create(:annotation) }
    let!(:recipe) { FactoryGirl.create(:recipe) }
    describe '内容を維持してStateとして作りなおす' do
      subject!(:new_state) { annotation.to_state!(recipe) }
      it { expect(new_state).to be_an_instance_of(Card::State) }
      it { expect(new_state.title).to eq(annotation.title) }
      it { expect(annotation).to be_destroyed }
    end
    it 'recipeのstatesに追加する' do
      expect do
        annotation.to_state!(recipe)
      end.to change { recipe.states(true).count }
    end
  end
end


text:
@implementation MWEyeSamplePlotElement

- (instancetype)initWithTime:(NSTimeInterval)time position:(NSPoint)position {
    return [self initWithTime:time position:position saccading:NO];
}

- (instancetype)initWithTime:(NSTimeInterval)time position:(NSPoint)position saccading:(BOOL)saccading {
    self = [super init];
    if (self) {
		_position = position;
		_time = time;
        _saccading = saccading;
    }
    return self;
}

@end


text:
  PlaceAutocompleteStructuredFormat

      Field
      Required
      Type
      Description

          main_text

      required
      string

            Contains the main text of a prediction, usually the name of the
            place.

          main_text_matched_substrings

      required

        Array<PlaceAutocompleteMatchedSubstring>

            Contains an array with offset value and
            length. These describe the location of the entered term
            in the prediction result text, so that the term can be highlighted
            if desired.

            See
            PlaceAutocompleteMatchedSubstring
            for more information.

          secondary_text

      required
      string

            Contains the secondary text of a prediction, usually the location of
            the place.

          secondary_text_matched_substrings

      optional

        Array<PlaceAutocompleteMatchedSubstring>

            Contains an array with offset value and
            length. These describe the location of the entered term
            in the prediction result text, so that the term can be highlighted
            if desired.

            See
            PlaceAutocompleteMatchedSubstring
            for more information.

  Generated from the
  OpenAPI specification.
  edit Edit
  bug_report Report bug


text:
package com.nextBook.controller;import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
@WebServlet(
    name = "adminAddUser",
    urlPatterns = "/admin/addUser")
public class UserManagementAdd extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
        String url = "/next_book/admin/user-management-add.jsp";

        RequestDispatcher dispatcher =
            getServletContext().getRequestDispatcher(url);

        dispatcher.forward(request, response);
    }

}


text:
<?php

namespace PHPUnit\Framework\Constraint;

use PHPUnit\Framework\ExpectationFailedException;
use SebastianBergmann\Comparator\ComparisonFailure;

/**
 * Constraint that asserts that the array it is evaluated for has a specified subset.
 *
 * Uses array_replace_recursive() to check if a key value subset is part of the
 * subject array.
 */
class ArraySubset extends Constraint
{
    /**
     * @var array|\Traversable
     */
    protected $subset;

    /**
     * @var bool
     */
    protected $strict;

    /**
     * @param array|\Traversable $subset
     * @param bool               $strict Check for object identity
     */
    public function __construct($subset, $strict = false)
    {
        parent::__construct();

        $this->strict = $strict;
        $this->subset = $subset;
    }

    /**
     * Evaluates the constraint for parameter $other
     *
     * If $returnResult is set to false (the default), an exception is thrown
     * in case of a failure. null is returned otherwise.
     *
     * If $returnResult is true, the result of the evaluation is returned as
     * a boolean value instead: true in case of success, false in case of a
     * failure.
     *
     * @param mixed  $other        Value or object to evaluate.
     * @param string $description  Additional information about the test
     * @param bool   $returnResult Whether to return a result or throw an exception
     *
     * @return mixed
     *
     * @throws ExpectationFailedException
     */
    public function evaluate($other, $description = '', $returnResult = false)
    {
        //type cast $other & $this->subset as an array to allow
        //support in standard array functions.
        $other        = $this->toArray($other);
        $this->subset = $this->toArray($this->subset);

        $patched = \array_replace_recursive($other, $this->subset);

        if ($this->strict) {
            $result = $other === $patched;
        } else {
            $result = $other == $patched;
        }

        if ($returnResult) {
            return $result;
        }

        if (!$result) {
            $f = new ComparisonFailure(
                $patched,
                $other,
                \var_export($patched, true),
                \var_export($other, true)
            );

            $this->fail($other, $description, $f);
        }
    }

    /**
     * Returns a string representation of the constraint.
     *
     * @return string
     */
    public function toString()
    {
        return 'has the subset ' . $this->exporter->export($this->subset);
    }

    /**
     * Returns the description of the failure
     *
     * The beginning of failure messages is "Failed asserting that" in most
     * cases. This method should return the second part of that sentence.
     *
     * @param mixed $other Evaluated value or object.
     *
     * @return string
     */
    protected function failureDescription($other)
    {
        return 'an array ' . $this->toString();
    }

    /**
     * @param array|\Traversable $other
     *
     * @return array
     */
    private function toArray($other)
    {
        if (\is_array($other)) {
            return $other;
        }

        if ($other instanceof \ArrayObject) {
            return $other->getArrayCopy();
        }

        if ($other instanceof \Traversable) {
            return \iterator_to_array($other);
        }

        // Keep BC even if we know that array would not be the expected one
        return (array) $other;
    }
}