text:
import React, { Component } from 'react';
import { Button, Table, Modal, Input, ButtonInput } from 'react-bootstrap';
import { validate, TEAM_SIZE_MIN, TEAM_SIZE_MAX } from '../utils/Validation';
import { VALIDATION } from '../utils/Constants';

require('../styles/leagues.scss');

export default class NewLeagueModal extends Component {
  constructor(props, context) {
    super(props, context);

    this.state = {
      name: '',
      teamSize: ''
    };
  }

  render() {
    return (
      <Modal show={ this.props.show } onHide={ this.props.hideNewLeagueModal }>
        <form onSubmit={ this._onSubmit.bind(this) }>
          <Modal.Header closeButton>
            <Modal.Title>Add New League</Modal.Title>
          </Modal.Header>
          <Modal.Body>
          <Input
            width={ 200 }
            type="text"
            label="Name"
            name="name"
            ref="name"
            value={ this.state.name }
            onChange={ this._updateState.bind(this, 'name') }
            autoFocus={ true }
            bsStyle={ this._validate('name') }
          />
          <Input
            width={ 200 }
            type="number"
            min={ TEAM_SIZE_MIN }
            max={ TEAM_SIZE_MAX }
            label="Players Per Team"
            name="teamSize"
            ref="teamSize"
            value={ this.state.teamSize }
            onChange={ this._updateState.bind(this, 'teamSize') }
            bsStyle={ this._validate('teamSize') }
          />
          <Input
            width={ 200 }
            type="select"
            name="sport"
            ref="sport"
            label="Sport">
              { this._getSportsOptions() }
          </Input>
          </Modal.Body>
          <Modal.Footer>
            <ButtonInput
              bsStyle="success"
              className="submit-button"
              type="submit"
              value="Submit"
            />
            <Button onClick={ this.props.hideNewLeagueModal }>Cancel</Button>
          </Modal.Footer>
        </form>
      </Modal>
    );
  }

  _updateState(ref) {
    this.setState({
      [ref]: this.refs[ref].getValue()
    });
  }

  _validate(ref) {
    if (validate(ref, this.state[ref])) {
      return VALIDATION.SUCCESS;
    }

    return VALIDATION.ERROR;
  }

  _isAllDataValid() {
    return this._validate('name') && this._validate('teamSize');
  }

  _onSubmit(e) {
    e.preventDefault();

    if (this._isAllDataValid()) {
      this.props.createLeague({
        name: this.refs.name.getValue(),
        teamSize: this.refs.teamSize.getValue(),
        sport: this.refs.sport.getValue()
      });

      this.props.hideNewLeagueModal();
    }
  }

  _getSportsOptions() {
    return this.props.sports.map((sport) => {
      const id = sport.get('_id');
      return (
        <option value={ id } key={ id }>
          { sport.get('name') }
        </option>
      );
    }).toJS();
  }
}


text:
webpackJsonp([20956934260092],{473:function(t,n){t.exports={pathContext:{tag:"programming"}}}});
//# sourceMappingURL=path---tags-programming-d31e926ce7cd6f93ebd3.js.map

redpajama_set_name: RedPajamaGithub


text:
module Hanami
  module Model
    module Adapters
      module Sql
        # Execute a command for the given query.
        #
        # @see Hanami::Model::Adapters::Sql::Query
        #
        # @api private
        # @since 0.1.0
        class Command
          # @api private
          # @since 0.6.1
          SEQUEL_TO_HANAMI_ERROR_MAPPING = {
            'Sequel::UniqueConstraintViolation'     => Hanami::Model::UniqueConstraintViolationError,
            'Sequel::ForeignKeyConstraintViolation' => Hanami::Model::ForeignKeyConstraintViolationError,
            'Sequel::NotNullConstraintViolation'    => Hanami::Model::NotNullConstraintViolationError,
            'Sequel::CheckConstraintViolation'      => Hanami::Model::CheckConstraintViolationError
          }.freeze

          # Initialize a command
          #
          # @param query [Hanami::Model::Adapters::Sql::Query]
          #
          # @api private
          # @since 0.1.0
          def initialize(query)
            @collection = query.scoped
          end

          # Creates a record for the given entity.
          #
          # @param entity [Object] the entity to persist
          #
          # @see Hanami::Model::Adapters::Sql::Collection#insert
          #
          # @return the primary key of the just created record.
          #
          # @api private
          # @since 0.1.0
          def create(entity)
            _handle_database_error { @collection.insert(entity) }
          end

          # Updates the corresponding record for the given entity.
          #
          # @param entity [Object] the entity to persist
          #
          # @see Hanami::Model::Adapters::Sql::Collection#update
          #
          # @api private
          # @since 0.1.0
          def update(entity)
            _handle_database_error { @collection.update(entity) }
          end

          # Deletes all the records for the current query.
          #
          # It's used to delete a single record or an entire database table.
          #
          # @see Hanami::Model::Adapters::SqlAdapter#delete
          # @see Hanami::Model::Adapters::SqlAdapter#clear
          #
          # @api private
          # @since 0.1.0
          def delete
            _handle_database_error { @collection.delete }
          end

          alias_method :clear, :delete

          private

          # Handles any possible Adapter's Database Error
          #
          # @api private
          # @since 0.6.1
          def _handle_database_error
            yield
          rescue Sequel::DatabaseError => e
            error_class = SEQUEL_TO_HANAMI_ERROR_MAPPING.fetch(e.class.name, Hanami::Model::InvalidCommandError)
            raise error_class, e.message
          end
        end
      end
    end
  end
end


text:
namespace ash {
class UserCreationScreen;
}

namespace chromeos {

// Interface for dependency injection between UserCreationScreen and its
// WebUI representation.
class UserCreationView {
 public:
  constexpr static StaticOobeScreenId kScreenId{"user-creation"};

  virtual ~UserCreationView() {}

  // Shows the contents of the screen.
  virtual void Show() = 0;

  // Binds `screen` to the view.
  virtual void Bind(ash::UserCreationScreen* screen) = 0;

  // Unbinds the screen from the view.
  virtual void Unbind() = 0;

  virtual void SetIsBackButtonVisible(bool value) = 0;
};

class UserCreationScreenHandler : public UserCreationView,
                                  public BaseScreenHandler {
 public:
  using TView = UserCreationView;

  explicit UserCreationScreenHandler(JSCallsContainer* js_calls_container);

  ~UserCreationScreenHandler() override;

  UserCreationScreenHandler(const UserCreationScreenHandler&) = delete;
  UserCreationScreenHandler& operator=(const UserCreationScreenHandler&) =
      delete;

 private:
  void Show() override;
  void Bind(ash::UserCreationScreen* screen) override;
  void Unbind() override;
  void SetIsBackButtonVisible(bool value) override;

  // BaseScreenHandler:
  void DeclareLocalizedValues(
      ::login::LocalizedValuesBuilder* builder) override;
  void Initialize() override;

  ash::UserCreationScreen* screen_ = nullptr;
};

}  // namespace chromeos

// TODO(https://crbug.com/1164001): remove after the //chrome/browser/chromeos
// source migration is finished.
namespace ash {
using ::chromeos::UserCreationScreenHandler;
using ::chromeos::UserCreationView;
}

#endif  // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_USER_CREATION_SCREEN_HANDLER_H_


text:
package oreilly.ch02;

// ToolbarFrame3.java
// The Swing-ified button example. The buttons in this toolbar all carry images
// but no text.
//
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ToolbarFrame3 extends Frame {

  JButton cutButton, copyButton, pasteButton;
  JButton javaButton, macButton, motifButton, winButton;

  public ToolbarFrame3() {
    //super("Toolbar Example (Swing no text)");
    setSize(450, 250);

/*
    addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        System.exit(0);
      }
    });
*/

    // JPanel works much like Panel does, so we'll use it
    JPanel toolbar = new JPanel();
    //toolbar.setLayout(new FlowLayout(FlowLayout.LEFT));

    CCPHandler handler = new CCPHandler();

    cutButton = new JButton("Cut", new ImageIcon("cut.gif"));
    cutButton.setActionCommand(CCPHandler.CUT);
    cutButton.addActionListener(handler);
    toolbar.add(cutButton);

    copyButton = new JButton("Copy", new ImageIcon("copy.gif"));
    copyButton.setActionCommand(CCPHandler.COPY);
    copyButton.addActionListener(handler);
    toolbar.add(copyButton);

    pasteButton = new JButton("Paste", new ImageIcon("paste.gif"));
    pasteButton.setActionCommand(CCPHandler.PASTE);
    pasteButton.addActionListener(handler);
    toolbar.add(pasteButton);

    //add(toolbar, BorderLayout.NORTH);
    add(toolbar);

    // Add the look-and-feel controls
    JPanel lnfPanel = new JPanel();
    LnFListener lnfListener = new LnFListener(this);
    macButton = new JButton("Mac", null);
    macButton.addActionListener(lnfListener);
    lnfPanel.add(macButton);
    javaButton = new JButton("Metal", null);
    javaButton.addActionListener(lnfListener);
    lnfPanel.add(javaButton);
    motifButton = new JButton("Motif", null);
    motifButton.addActionListener(lnfListener);
    lnfPanel.add(motifButton);
    winButton = new JButton("Windows", null);
    winButton.addActionListener(lnfListener);
    lnfPanel.add(winButton);
    //add(lnfPanel, BorderLayout.SOUTH);
    add(lnfPanel);
  }

  public static void main(String args[]) {
    ToolbarFrame3 tf3 = new ToolbarFrame3();
    tf3.setVisible(true);
  }
}


text:
package org.apereo.cas;

import lombok.NoArgsConstructor;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration;
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.config.server.EnableConfigServer;

/**
 * This is {@link CasConfigurationServerWebApplication}.
 *
 * @author Misagh Moayyed
 * @since 5.1.0
 */
@SpringBootApplication(exclude = {
    HibernateJpaAutoConfiguration.class,
    JerseyAutoConfiguration.class,
    GroovyTemplateAutoConfiguration.class,
    JmxAutoConfiguration.class,
    DataSourceAutoConfiguration.class,
    RedisAutoConfiguration.class,
    MongoAutoConfiguration.class,
    MongoDataAutoConfiguration.class,
    CassandraAutoConfiguration.class,
    DataSourceTransactionManagerAutoConfiguration.class,
    RedisRepositoriesAutoConfiguration.class
})
@EnableConfigServer
@NoArgsConstructor
public class CasConfigurationServerWebApplication {

    /**
     * Main.
     *
     * @param args the args
     */
    public static void main(final String[] args) {
        new SpringApplicationBuilder(CasConfigurationServerWebApplication.class).banner(new CasConfigurationServerBanner()).logStartupInfo(true).run(args);
    }
}


text:
/* eslint-env mocha */

import PropTypes from '../src/propTypes';
import { expect } from 'chai';

describe('PropTypes', () => {
  it('is an object', () => {
    expect(PropTypes)
    .to.be.a('object');
  });

  describe('non generic types', () => {
    context('when given a correct type', () => {
      it('returns true', () => {
        expect(PropTypes.String({test: ''}, 'test', 'componentName'))
          .to.be.true;
      });
    });

    context('when given an incorrect type', () => {
      it('returns an Error', () => {
        expect(PropTypes.String({test: 1}, 'test', 'componentName'))
          .to.be.a('Error');
      });

      it('returns an Error with a detailed message', () => {
        const error = PropTypes.String({test: 1}, 'test', 'componentName');

        expect(error.message)
          .to.equal('test is not a String. Check render method of componentName');
      });
    });
  });

  describe('generic types', () => {
    context('when given a correct type', () => {
      it('returns true', () => {
        const result = PropTypes.Array(PropTypes.String)({test: ['']}, 'test', 'componentName');

        expect(result)
          .to.be.true;
      });
    });

    context('when given an incorrect type', () => {
      it('returns an Error', () => {
        const StringArray = PropTypes.Array(PropTypes.String);
        const result = StringArray({test: [1]}, 'test', 'componentName');

        expect(result)
          .to.be.a('Error');
      });

      it('returns an Error with a detailed message', () => {
        const ObjectType = PropTypes.Object({ a: PropTypes.String });
        const error = ObjectType({test: {a: 1}}, 'test', 'componentName');

        expect(error.message)
          .to.equal(`test is not [\n    {\n        "a": "String"\n    }\n]. It is {\n    "a": 1\n}. Check render method of componentName`);
      });
    });
  });
});