text:
package sorting

import (
	"github.com/kipal/gotools/interfaces"
	"testing"
)

var unsorted = TestUnsortedArray {
	1, 4, 2, 5, 6, 23, 74, 2, 3, 1,
}

var expected = TestUnsortedArray {
	1, 1, 2, 2, 3, 4, 5, 6, 23, 74,
}

func GetUnsortedTestData() TestUnsortedArray {
	tmp := make(TestUnsortedArray, len(unsorted))
	copy(tmp, unsorted)

	return tmp
}

func GetExpectedData() TestUnsortedArray {
	tmp := make(TestUnsortedArray, len(expected))
	copy(tmp, expected)

	return tmp
}

type TestElement int

	func (this TestElement) IsGreaterThan(element interfaces.ArrayElement) bool {

		return this > element.(TestElement)
	}

	func (this TestElement) IsEqual(element interfaces.ArrayElement) bool {

		return this == element.(TestElement)
	}

type TestUnsortedArray []TestElement

	func (this TestUnsortedArray) Element(i int) interfaces.ArrayElement {

		return this[i]
	}

	func (this TestUnsortedArray) Len() int {

		return len(this)
	}

	func (this TestUnsortedArray) Swap(i, j int) {
		tmp := this[i]

		this[i] = this[j]
		this[j] = tmp
	}

	func (this TestUnsortedArray) SetElement(i int, e interfaces.ArrayElement) {
		this[i] = e.(TestElement)
	}

	func (this TestUnsortedArray) Insert(i int, e interfaces.ArrayElement) interfaces.AdjustableArrayKind {

		return append(
			this[:i],
			append(
				TestUnsortedArray{e.(TestElement)},
				this[i:]...
			)...
		)
	}

func Check(t *testing.T, toBeTestedArray interfaces.ArrayKind) {

	interfaces.Foreach(
		toBeTestedArray,
		func (i int, e interfaces.ArrayElement) bool {

			expected := GetExpectedData()

			if !expected[i].IsEqual(e) {
				t.Errorf("\nExpected: %v,\nSorted  : %v (%d, %d)", expected, toBeTestedArray)

				return false
			}

			return true
		},
	)
}

redpajama_set_name: RedPajamaGithub


text:
package org.apache.shardingsphere.proxy.frontend.postgresql.command.query;

import lombok.Getter;
import org.apache.shardingsphere.distsql.parser.statement.rdl.create.AddResourceStatement;
import org.apache.shardingsphere.sharding.distsql.parser.statement.CreateShardingTableRuleStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.AnalyzeTableStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.ResetParameterStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.SetStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dal.VacuumStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterFunctionStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterIndexStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterProcedureStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterSequenceStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterTableStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterTablespaceStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterViewStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateDatabaseStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateFunctionStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateIndexStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateProcedureStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateSequenceStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateTableStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateTablespaceStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateViewStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropDatabaseStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropFunctionStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropIndexStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropProcedureStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropSequenceStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropTableStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropTablespaceStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropViewStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.TruncateStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.CallStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.DeleteStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.DoStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.UpdateStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.BeginTransactionStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.CommitStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.ReleaseSavepointStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.RollbackStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.SavepointStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.SetTransactionStatement;
import org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.StartTransactionStatement;

import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;

/**
 * PostgreSQL command.
 * @see SQL Commands
 */
@Getter
public enum PostgreSQLCommand {

    SELECT(SelectStatement.class),
    INSERT(InsertStatement.class),
    UPDATE(UpdateStatement.class),
    DELETE(DeleteStatement.class),
    CALL(CallStatement.class),
    DO(DoStatement.class),
    ANALYZE(AnalyzeTableStatement.class),
    VACUUM(VacuumStatement.class),
    ALTER_FUNCTION(AlterFunctionStatement.class),
    ALTER_INDEX(AlterIndexStatement.class),
    ALTER_PROCEDURE(AlterProcedureStatement.class),
    ALTER_SEQUENCE(AlterSequenceStatement.class),
    ALTER_TABLESPACE(AlterTablespaceStatement.class),
    ALTER_TABLE(AlterTableStatement.class),
    ALTER_VIEW(AlterViewStatement.class),
    CREATE(AddResourceStatement.class, CreateShardingTableRuleStatement.class),
    CREATE_DATABASE(CreateDatabaseStatement.class),
    CREATE_FUNCTION(CreateFunctionStatement.class),
    CREATE_INDEX(CreateIndexStatement.class),
    CREATE_PROCEDURE(CreateProcedureStatement.class),
    CREATE_SEQUENCE(CreateSequenceStatement.class),
    CREATE_TABLESPACE(CreateTablespaceStatement.class),
    CREATE_TABLE(CreateTableStatement.class),
    CREATE_VIEW(CreateViewStatement.class),
    DROP_DATABASE(DropDatabaseStatement.class),
    DROP_FUNCTION(DropFunctionStatement.class),
    DROP_INDEX(DropIndexStatement.class),
    DROP_PROCEDURE(DropProcedureStatement.class),
    DROP_SEQUENCE(DropSequenceStatement.class),
    DROP_TABLESPACE(DropTablespaceStatement.class),
    DROP_TABLE(DropTableStatement.class),
    DROP_VIEW(DropViewStatement.class),
    TRUNCATE_TABLE(TruncateStatement.class),
    BEGIN(BeginTransactionStatement.class),
    START_TRANSACTION(StartTransactionStatement.class),
    COMMIT(CommitStatement.class),
    SAVEPOINT(SavepointStatement.class),
    ROLLBACK(RollbackStatement.class),
    RELEASE(ReleaseSavepointStatement.class),
    SET(SetStatement.class, SetTransactionStatement.class),
    RESET(ResetParameterStatement.class);

    private static final Map<Class<? extends SQLStatement>, Optional<PostgreSQLCommand>> COMPUTED_CLASSES = new ConcurrentHashMap<>(64, 1);

    private final Collection<Class<? extends SQLStatement>> sqlStatementClasses;

    private final String tag;

    @SafeVarargs
    PostgreSQLCommand(final Class<? extends SQLStatement>... sqlStatementClasses) {
        this.sqlStatementClasses = Arrays.asList(sqlStatementClasses);
        tag = name().replaceAll("_", " ");
    }

    /**
     * Value of PostgreSQL command via SQL statement class.
     *
     * @param sqlStatementClass SQL statement class
     * @return PostgreSQL command
     */
    public static Optional<PostgreSQLCommand> valueOf(final Class<? extends SQLStatement> sqlStatementClass) {
        return getPostgreSQLCommand(sqlStatementClass);
    }

    /**
     * Refer to https://bugs.openjdk.java.net/browse/JDK-8161372.
     *
     * @param sqlStatementClass sql statement class
     * @return optional PostgreSQLCommand
     */
    @SuppressWarnings("OptionalAssignedToNull")
    private static Optional<PostgreSQLCommand> getPostgreSQLCommand(final Class<? extends SQLStatement> sqlStatementClass) {
        Optional<PostgreSQLCommand> result;
        if (null == (result = COMPUTED_CLASSES.get(sqlStatementClass))) {
            result = COMPUTED_CLASSES.computeIfAbsent(sqlStatementClass, target -> Arrays.stream(PostgreSQLCommand.values()).filter(each -> matches(target, each)).findAny());
        }
        return result;
    }

    private static boolean matches(final Class<? extends SQLStatement> sqlStatementClass, final PostgreSQLCommand postgreSQLCommand) {
        return postgreSQLCommand.sqlStatementClasses.stream().anyMatch(each -> each.isAssignableFrom(sqlStatementClass));
    }
}


text:
  <md-sidenav-container>
    <md-sidenav mode="over" align="start" (close-start)="onSidenavClose()" #sidenav>

        <router-outlet></router-outlet>
        <button id="closeSidenavButton" class="lg-primary text-white" md-raised-button
          (click)="sidenav.close()">Close</button>

    </md-sidenav>

      <notice severity="warning"></notice>

Products for {{categoryName}}

            <button class="lg-primary text-white create-btn" md-raised-button
              (click)="openCreateProduct()">Create New Product</button>

{{product.name}}

{{product.categoryName}}

                <button md-icon-button
                  (click)="confirmDelete(product)" *ngIf="isAdmin || product.createdBy === currentUser">
                  <md-icon class="delete-btn">delete_outline</md-icon>
                </button>
                <button md-icon-button [style.color]="product.color"
                  (click)="openEditProduct(product)" *ngIf="isAdmin || (product.createdBy === currentUser)">
                  <md-icon>edit</md-icon>
                </button>
                <button md-icon-button [style.color]="product.color"
                  (click)="openProductDetails(product)" >
                  <md-icon>info_outline</md-icon>
                </button>

  </md-sidenav-container>


text:
/**
 * Obliterator Iterator Class
 * ===========================
 *
 * Simple class representing the library's iterators.
 */

/**
 * Iterator class.
 *
 * @constructor
 * @param {function} next - Next function.
 */
function Iterator(next) {

  // Hiding the given function
  Object.defineProperty(this, '_next', {
    writable: false,
    enumerable: false,
    value: next
  });

  // Is the iterator complete?
  this.done = false;
}

/**
 * Next function.
 *
 * @return {object}
 */
Iterator.prototype.next = function() {
  if (this.done)
    return {done: true};

  var step = this._next();

  if (step.done)
    this.done = true;

  return step;
};

/**
 * If symbols are supported, we add `next` to `Symbol.iterator`.
 */
if (typeof Symbol !== 'undefined')
  Iterator.prototype[Symbol.iterator] = function() {
    return this;
  };

/**
 * Returning an iterator of the given value.
 *
 * @param  {any} value - Value.
 * @return {Iterator}
 */
Iterator.of = function(value) {
  var consumed = false;

  return new Iterator(function() {
    if (consumed)
      return {done: true};

    consumed = true;
    return {value: value};
  });
};

/**
 * Returning an empty iterator.
 *
 * @return {Iterator}
 */
Iterator.empty = function() {
  var iterator = new Iterator(null);
  iterator.done = true;

  return iterator;
};

/**
 * Returning whether the given value is an iterator.
 *
 * @param  {any} value - Value.
 * @return {boolean}
 */
Iterator.is = function(value) {
  if (value instanceof Iterator)
    return true;

  return (
    typeof value === 'object' &&
    value !== null &&
    typeof value.next === 'function'
  );
};

/**
 * Exporting.
 */
module.exports = Iterator;


text:
<!doctype html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title></title>
    <meta name="description" content="">
    <meta name="keywords" content="angular, directive, angular-slick, slick, carousel, slider, jQuery">
    <meta property="og:title" content="angular-slick - directive for the last carousel you'll ever need" />
    <meta name="viewport" content="width=device-width">

    <link rel="stylesheet" href="styles/main.css">
    <link rel="stylesheet" href="bower_components/slick-carousel/slick/slick.css">
    <link rel="stylesheet" href="bower_components/slick-carousel/slick/slick-theme.css">

    <link rel="stylesheet" href="http://yandex.st/highlightjs/8.0/styles/solarized_light.min.css">


text:
package pt.trycatch.jamify.jammer;

import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public class SortableMap {

	public enum ORDER {
		ASCENDING {
			@Override public <K extends Comparable<? super K>, V extends Comparable<? super V>> void sortByValue(List<Map.Entry<K, V>> list) {
				Collections.sort(list, new Comparator<Map.Entry<K, V>>()
				        {
				            public int compare(Map.Entry<K, V> o1, Map.Entry<K, V> o2)
				            {
				                if(o1.getValue().equals(o2.getValue()))
				                	return (o1.getKey()).compareTo(o2.getKey());
				                return (o1.getValue()).compareTo(o2.getValue());
				            }
				        });
			}
		},
		DESCENDING {
			@Override public <K extends Comparable<? super K>, V extends Comparable<? super V>> void sortByValue(List<Map.Entry<K, V>> list) {
				Collections.sort(list, new Comparator<Map.Entry<K, V>>()
				        {
				            public int compare(Map.Entry<K, V> o1, Map.Entry<K, V> o2)
				            {
				            	if(o2.getValue().equals(o1.getValue()))
				                	return (o2.getKey()).compareTo(o1.getKey());
				                return (o2.getValue()).compareTo(o1.getValue());
				            }
				        });
			}
		};

		public abstract <K extends Comparable<? super K>, V extends Comparable<? super V>> void sortByValue(List<Map.Entry<K, V>> list);
	}

	public static <K extends Comparable<? super K>, V extends Comparable<? super V>> Map<K, V> sort(Map<K, V> map, ORDER order) {
		List<Map.Entry<K, V>> list =
            new LinkedList<Map.Entry<K, V>>(map.entrySet());

		order.sortByValue(list);

		Map<K, V> result = new LinkedHashMap<K, V>();
        for (Map.Entry<K, V> entry : list)
        {
            result.put(entry.getKey(), entry.getValue());
        }
        return result;
	}

}


text:
package com.github.jonathanxd.wcommands.ext.reflect.arguments.translators;

import java.util.List;

/**
 * Created by jonathan on 27/02/16.
 */
public interface Translator<T> {

    boolean isAcceptable(List<String> text);

    T translate(List<String> text);

}


text:
<!DOCTYPE html>

	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>jQuery Mobile Docs - List Dividers</title>
	<link rel="stylesheet"  href="../../css/themes/default/jquery.mobile-1.1.1.css" />
	<link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>

List dividers

		Home
		Search

A

Adam Kinkaid

Alex Wickerham

Avery Johnson

B

Bob Cabot

C

Caleb Booth

Christopher Adams

Culver James

D

David Walsh

Drake Alfred

E

Elizabeth Bacon

Emery Parker

Enid Voldon

F

Francis Wall

G

Graham Smith

Greta Peete

H

Harvey Walls

M

Mike Farnsworth

Murray Vanderbuilt

N

Nathan Williams

P

Paul Baker

Pete Mason

R

Rod Tarker

S

Sawyer Wakefield

More in this section

List views

List basics & API

Basic linked list

Nested list

Numbered list

Split button list

List dividers

Count bubble

Thumbnails

Icons

Content formatting

Search filter bar

Inset search filter bar

Search filter bar with dividers

Search filter hidden data

Read-only lists

Read-only inset lists

Lists with forms

Inset lists with forms

Inset styled lists

List performance test

Theming lists

© 2012 jQuery Foundation and other contributors


text:
from __future__ import unicode_literals

import pytest

from prompt_toolkit.document import Document

@pytest.fixture
def document():
    return Document(
        'line 1\n' +
        'line 2\n' +
        'line 3\n' +
        'line 4\n',
        len('line 1\n' + 'lin')
    )

def test_current_char(document):
    assert document.current_char == 'e'

def test_text_before_cursor(document):
    assert document.text_before_cursor == 'line 1\nlin'

def test_text_after_cursor(document):
    assert document.text_after_cursor == 'e 2\n' + \
        'line 3\n' + \
        'line 4\n'

def test_lines(document):
    assert document.lines == [
        'line 1',
        'line 2',
        'line 3',
        'line 4', '']

def test_line_count(document):
    assert document.line_count == 5

def test_current_line_before_cursor(document):
    assert document.current_line_before_cursor == 'lin'

def test_current_line_after_cursor(document):
    assert document.current_line_after_cursor == 'e 2'

def test_current_line(document):
    assert document.current_line == 'line 2'

def test_cursor_position(document):
    assert document.cursor_position_row == 1
    assert document.cursor_position_col == 3

    d = Document('', 0)
    assert d.cursor_position_row == 0
    assert d.cursor_position_col == 0

def test_translate_index_to_position(document):
    pos = document.translate_index_to_position(
        len('line 1\nline 2\nlin'))

    assert pos[0] == 2
    assert pos[1] == 3

    pos = document.translate_index_to_position(0)
    assert pos == (0, 0)


text:
"use strict";

var REF_NAME = "int.json";

module.exports = {
    description: "Issue #126 - do not add UNRESOLVABLE_REFERENCE error when set through setRemoteReference",
    tests: [
        {
            description: "should fail compilation with unresolvable reference",
            setup: function (validator) {
                validator.setRemoteReference(REF_NAME, {
                    "$schema": "http://json-schema.org/draft-04/schema#",
                    "id": REF_NAME,
                    "type": "object",
                    "required": [
                        "number"
                    ],
                    "properties": {
                        "number": {
                            "$ref": "data-types.json#/definitions/number"
                        }
                    }
                });
            },
            schema: {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "id": "ints.json",
                "type": "array",
                "items": {
                    "$ref": REF_NAME
                }
            },
            validateSchemaOnly: true,
            valid: false,
            after: function (err, valid, data, validator) {
                err.forEach(function (e) {
                    if (e.params.indexOf(REF_NAME) !== -1) {
                        expect(e.code).not.toBe("UNRESOLVABLE_REFERENCE");
                    }
                });
                expect(validator.getMissingRemoteReferences().length).toBe(1);
            }
        }
    ]
};


text:
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE

namespace osu.Framework.Audio
{
    internal interface IBassAudio
    {
        void UpdateDevice(int deviceIndex);
    }
}


text:
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/cloud/conformance/storage/v1/tests.proto

package com.google.cloud.conformance.storage.v1;

/** Protobuf type {@code google.cloud.conformance.storage.v1.PolicyConditions} */
public final class PolicyConditions extends com.google.protobuf.GeneratedMessageV3
    implements
    // @@protoc_insertion_point(message_implements:google.cloud.conformance.storage.v1.PolicyConditions)
    PolicyConditionsOrBuilder {
  private static final long serialVersionUID = 0L;
  // Use PolicyConditions.newBuilder() to construct.
  private PolicyConditions(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }

  private PolicyConditions() {
    contentLengthRange_ = emptyIntList();
    startsWith_ = com.google.protobuf.LazyStringArrayList.EMPTY;
  }

  @java.lang.Override
  @SuppressWarnings({"unused"})
  protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
    return new PolicyConditions();
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet getUnknownFields() {
    return this.unknownFields;
  }

  private PolicyConditions(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    this();
    if (extensionRegistry == null) {
      throw new java.lang.NullPointerException();
    }
    int mutable_bitField0_ = 0;
    com.google.protobuf.UnknownFieldSet.Builder unknownFields =
        com.google.protobuf.UnknownFieldSet.newBuilder();
    try {
      boolean done = false;
      while (!done) {
        int tag = input.readTag();
        switch (tag) {
          case 0:
            done = true;
            break;
          case 8:
            {
              if (!((mutable_bitField0_ & 0x00000001) != 0)) {
                contentLengthRange_ = newIntList();
                mutable_bitField0_ |= 0x00000001;
              }
              contentLengthRange_.addInt(input.readInt32());
              break;
            }
          case 10:
            {
              int length = input.readRawVarint32();
              int limit = input.pushLimit(length);
              if (!((mutable_bitField0_ & 0x00000001) != 0) && input.getBytesUntilLimit() > 0) {
                contentLengthRange_ = newIntList();
                mutable_bitField0_ |= 0x00000001;
              }
              while (input.getBytesUntilLimit() > 0) {
                contentLengthRange_.addInt(input.readInt32());
              }
              input.popLimit(limit);
              break;
            }
          case 18:
            {
              java.lang.String s = input.readStringRequireUtf8();
              if (!((mutable_bitField0_ & 0x00000002) != 0)) {
                startsWith_ = new com.google.protobuf.LazyStringArrayList();
                mutable_bitField0_ |= 0x00000002;
              }
              startsWith_.add(s);
              break;
            }
          default:
            {
              if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
                done = true;
              }
              break;
            }
        }
      }
    } catch (com.google.protobuf.InvalidProtocolBufferException e) {
      throw e.setUnfinishedMessage(this);
    } catch (java.io.IOException e) {
      throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this);
    } finally {
      if (((mutable_bitField0_ & 0x00000001) != 0)) {
        contentLengthRange_.makeImmutable(); // C
      }
      if (((mutable_bitField0_ & 0x00000002) != 0)) {
        startsWith_ = startsWith_.getUnmodifiableView();
      }
      this.unknownFields = unknownFields.build();
      makeExtensionsImmutable();
    }
  }

  public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
    return com.google.cloud.conformance.storage.v1.Tests
        .internal_static_google_cloud_conformance_storage_v1_PolicyConditions_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.cloud.conformance.storage.v1.Tests
        .internal_static_google_cloud_conformance_storage_v1_PolicyConditions_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.cloud.conformance.storage.v1.PolicyConditions.class,
            com.google.cloud.conformance.storage.v1.PolicyConditions.Builder.class);
  }

  public static final int CONTENTLENGTHRANGE_FIELD_NUMBER = 1;
  private com.google.protobuf.Internal.IntList contentLengthRange_;
  /**
   * repeated int32 contentLengthRange = 1;
   *
   * @return A list containing the contentLengthRange.
   */
  @java.lang.Override
  public java.util.List<java.lang.Integer> getContentLengthRangeList() {
    return contentLengthRange_;
  }
  /**
   * repeated int32 contentLengthRange = 1;
   *
   * @return The count of contentLengthRange.
   */
  public int getContentLengthRangeCount() {
    return contentLengthRange_.size();
  }
  /**
   * repeated int32 contentLengthRange = 1;
   *
   * @param index The index of the element to return.
   * @return The contentLengthRange at the given index.
   */
  public int getContentLengthRange(int index) {
    return contentLengthRange_.getInt(index);
  }

  private int contentLengthRangeMemoizedSerializedSize = -1;

  public static final int STARTSWITH_FIELD_NUMBER = 2;
  private com.google.protobuf.LazyStringList startsWith_;
  /**
   * repeated string startsWith = 2;
   *
   * @return A list containing the startsWith.
   */
  public com.google.protobuf.ProtocolStringList getStartsWithList() {
    return startsWith_;
  }
  /**
   * repeated string startsWith = 2;
   *
   * @return The count of startsWith.
   */
  public int getStartsWithCount() {
    return startsWith_.size();
  }
  /**
   * repeated string startsWith = 2;
   *
   * @param index The index of the element to return.
   * @return The startsWith at the given index.
   */
  public java.lang.String getStartsWith(int index) {
    return startsWith_.get(index);
  }
  /**
   * repeated string startsWith = 2;
   *
   * @param index The index of the value to return.
   * @return The bytes of the startsWith at the given index.
   */
  public com.google.protobuf.ByteString getStartsWithBytes(int index) {
    return startsWith_.getByteString(index);
  }

  private byte memoizedIsInitialized = -1;

  @java.lang.Override
  public final boolean isInitialized() {
    byte isInitialized = memoizedIsInitialized;
    if (isInitialized == 1) return true;
    if (isInitialized == 0) return false;

    memoizedIsInitialized = 1;
    return true;
  }

  @java.lang.Override
  public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
    getSerializedSize();
    if (getContentLengthRangeList().size() > 0) {
      output.writeUInt32NoTag(10);
      output.writeUInt32NoTag(contentLengthRangeMemoizedSerializedSize);
    }
    for (int i = 0; i < contentLengthRange_.size(); i++) {
      output.writeInt32NoTag(contentLengthRange_.getInt(i));
    }
    for (int i = 0; i < startsWith_.size(); i++) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 2, startsWith_.getRaw(i));
    }
    unknownFields.writeTo(output);
  }

  @java.lang.Override
  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    {
      int dataSize = 0;
      for (int i = 0; i < contentLengthRange_.size(); i++) {
        dataSize +=
            com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(
                contentLengthRange_.getInt(i));
      }
      size += dataSize;
      if (!getContentLengthRangeList().isEmpty()) {
        size += 1;
        size += com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(dataSize);
      }
      contentLengthRangeMemoizedSerializedSize = dataSize;
    }
    {
      int dataSize = 0;
      for (int i = 0; i < startsWith_.size(); i++) {
        dataSize += computeStringSizeNoTag(startsWith_.getRaw(i));
      }
      size += dataSize;
      size += 1 * getStartsWithList().size();
    }
    size += unknownFields.getSerializedSize();
    memoizedSize = size;
    return size;
  }

  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof com.google.cloud.conformance.storage.v1.PolicyConditions)) {
      return super.equals(obj);
    }
    com.google.cloud.conformance.storage.v1.PolicyConditions other =
        (com.google.cloud.conformance.storage.v1.PolicyConditions) obj;

    if (!getContentLengthRangeList().equals(other.getContentLengthRangeList())) return false;
    if (!getStartsWithList().equals(other.getStartsWithList())) return false;
    if (!unknownFields.equals(other.unknownFields)) return false;
    return true;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptor().hashCode();
    if (getContentLengthRangeCount() > 0) {
      hash = (37 * hash) + CONTENTLENGTHRANGE_FIELD_NUMBER;
      hash = (53 * hash) + getContentLengthRangeList().hashCode();
    }
    if (getStartsWithCount() > 0) {
      hash = (37 * hash) + STARTSWITH_FIELD_NUMBER;
      hash = (53 * hash) + getStartsWithList().hashCode();
    }
    hash = (29 * hash) + unknownFields.hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.cloud.conformance.storage.v1.PolicyConditions parseFrom(
      java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.conformance.storage.v1.PolicyConditions parseFrom(
      java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.conformance.storage.v1.PolicyConditions parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.conformance.storage.v1.PolicyConditions parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.conformance.storage.v1.PolicyConditions parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.conformance.storage.v1.PolicyConditions parseFrom(
      byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.conformance.storage.v1.PolicyConditions parseFrom(
      java.io.InputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.cloud.conformance.storage.v1.PolicyConditions parseFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.cloud.conformance.storage.v1.PolicyConditions parseDelimitedFrom(
      java.io.InputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
  }

  public static com.google.cloud.conformance.storage.v1.PolicyConditions parseDelimitedFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.cloud.conformance.storage.v1.PolicyConditions parseFrom(
      com.google.protobuf.CodedInputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.cloud.conformance.storage.v1.PolicyConditions parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  @java.lang.Override
  public Builder newBuilderForType() {
    return newBuilder();
  }

  public static Builder newBuilder() {
    return DEFAULT_INSTANCE.toBuilder();
  }

  public static Builder newBuilder(
      com.google.cloud.conformance.storage.v1.PolicyConditions prototype) {
    return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  }

  @java.lang.Override
  public Builder toBuilder() {
    return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this);
  }

  @java.lang.Override
  protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
    Builder builder = new Builder(parent);
    return builder;
  }
  /** Protobuf type {@code google.cloud.conformance.storage.v1.PolicyConditions} */
  public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
      implements
      // @@protoc_insertion_point(builder_implements:google.cloud.conformance.storage.v1.PolicyConditions)
      com.google.cloud.conformance.storage.v1.PolicyConditionsOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return com.google.cloud.conformance.storage.v1.Tests
          .internal_static_google_cloud_conformance_storage_v1_PolicyConditions_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.cloud.conformance.storage.v1.Tests
          .internal_static_google_cloud_conformance_storage_v1_PolicyConditions_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.cloud.conformance.storage.v1.PolicyConditions.class,
              com.google.cloud.conformance.storage.v1.PolicyConditions.Builder.class);
    }

    // Construct using com.google.cloud.conformance.storage.v1.PolicyConditions.newBuilder()
    private Builder() {
      maybeForceBuilderInitialization();
    }

    private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
      maybeForceBuilderInitialization();
    }

    private void maybeForceBuilderInitialization() {
      if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {}
    }

    @java.lang.Override
    public Builder clear() {
      super.clear();
      contentLengthRange_ = emptyIntList();
      bitField0_ = (bitField0_ & ~0x00000001);
      startsWith_ = com.google.protobuf.LazyStringArrayList.EMPTY;
      bitField0_ = (bitField0_ & ~0x00000002);
      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
      return com.google.cloud.conformance.storage.v1.Tests
          .internal_static_google_cloud_conformance_storage_v1_PolicyConditions_descriptor;
    }

    @java.lang.Override
    public com.google.cloud.conformance.storage.v1.PolicyConditions getDefaultInstanceForType() {
      return com.google.cloud.conformance.storage.v1.PolicyConditions.getDefaultInstance();
    }

    @java.lang.Override
    public com.google.cloud.conformance.storage.v1.PolicyConditions build() {
      com.google.cloud.conformance.storage.v1.PolicyConditions result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    @java.lang.Override
    public com.google.cloud.conformance.storage.v1.PolicyConditions buildPartial() {
      com.google.cloud.conformance.storage.v1.PolicyConditions result =
          new com.google.cloud.conformance.storage.v1.PolicyConditions(this);
      int from_bitField0_ = bitField0_;
      if (((bitField0_ & 0x00000001) != 0)) {
        contentLengthRange_.makeImmutable();
        bitField0_ = (bitField0_ & ~0x00000001);
      }
      result.contentLengthRange_ = contentLengthRange_;
      if (((bitField0_ & 0x00000002) != 0)) {
        startsWith_ = startsWith_.getUnmodifiableView();
        bitField0_ = (bitField0_ & ~0x00000002);
      }
      result.startsWith_ = startsWith_;
      onBuilt();
      return result;
    }

    @java.lang.Override
    public Builder clone() {
      return super.clone();
    }

    @java.lang.Override
    public Builder setField(
        com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
      return super.setField(field, value);
    }

    @java.lang.Override
    public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) {
      return super.clearField(field);
    }

    @java.lang.Override
    public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) {
      return super.clearOneof(oneof);
    }

    @java.lang.Override
    public Builder setRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) {
      return super.setRepeatedField(field, index, value);
    }

    @java.lang.Override
    public Builder addRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
      return super.addRepeatedField(field, value);
    }

    @java.lang.Override
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.google.cloud.conformance.storage.v1.PolicyConditions) {
        return mergeFrom((com.google.cloud.conformance.storage.v1.PolicyConditions) other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.cloud.conformance.storage.v1.PolicyConditions other) {
      if (other == com.google.cloud.conformance.storage.v1.PolicyConditions.getDefaultInstance())
        return this;
      if (!other.contentLengthRange_.isEmpty()) {
        if (contentLengthRange_.isEmpty()) {
          contentLengthRange_ = other.contentLengthRange_;
          bitField0_ = (bitField0_ & ~0x00000001);
        } else {
          ensureContentLengthRangeIsMutable();
          contentLengthRange_.addAll(other.contentLengthRange_);
        }
        onChanged();
      }
      if (!other.startsWith_.isEmpty()) {
        if (startsWith_.isEmpty()) {
          startsWith_ = other.startsWith_;
          bitField0_ = (bitField0_ & ~0x00000002);
        } else {
          ensureStartsWithIsMutable();
          startsWith_.addAll(other.startsWith_);
        }
        onChanged();
      }
      this.mergeUnknownFields(other.unknownFields);
      onChanged();
      return this;
    }

    @java.lang.Override
    public final boolean isInitialized() {
      return true;
    }

    @java.lang.Override
    public Builder mergeFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      com.google.cloud.conformance.storage.v1.PolicyConditions parsedMessage = null;
      try {
        parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        parsedMessage =
            (com.google.cloud.conformance.storage.v1.PolicyConditions) e.getUnfinishedMessage();
        throw e.unwrapIOException();
      } finally {
        if (parsedMessage != null) {
          mergeFrom(parsedMessage);
        }
      }
      return this;
    }

    private int bitField0_;

    private com.google.protobuf.Internal.IntList contentLengthRange_ = emptyIntList();

    private void ensureContentLengthRangeIsMutable() {
      if (!((bitField0_ & 0x00000001) != 0)) {
        contentLengthRange_ = mutableCopy(contentLengthRange_);
        bitField0_ |= 0x00000001;
      }
    }
    /**
     * repeated int32 contentLengthRange = 1;
     *
     * @return A list containing the contentLengthRange.
     */
    public java.util.List<java.lang.Integer> getContentLengthRangeList() {
      return ((bitField0_ & 0x00000001) != 0)
          ? java.util.Collections.unmodifiableList(contentLengthRange_)
          : contentLengthRange_;
    }
    /**
     * repeated int32 contentLengthRange = 1;
     *
     * @return The count of contentLengthRange.
     */
    public int getContentLengthRangeCount() {
      return contentLengthRange_.size();
    }
    /**
     * repeated int32 contentLengthRange = 1;
     *
     * @param index The index of the element to return.
     * @return The contentLengthRange at the given index.
     */
    public int getContentLengthRange(int index) {
      return contentLengthRange_.getInt(index);
    }
    /**
     * repeated int32 contentLengthRange = 1;
     *
     * @param index The index to set the value at.
     * @param value The contentLengthRange to set.
     * @return This builder for chaining.
     */
    public Builder setContentLengthRange(int index, int value) {
      ensureContentLengthRangeIsMutable();
      contentLengthRange_.setInt(index, value);
      onChanged();
      return this;
    }
    /**
     * repeated int32 contentLengthRange = 1;
     *
     * @param value The contentLengthRange to add.
     * @return This builder for chaining.
     */
    public Builder addContentLengthRange(int value) {
      ensureContentLengthRangeIsMutable();
      contentLengthRange_.addInt(value);
      onChanged();
      return this;
    }
    /**
     * repeated int32 contentLengthRange = 1;
     *
     * @param values The contentLengthRange to add.
     * @return This builder for chaining.
     */
    public Builder addAllContentLengthRange(
        java.lang.Iterable<? extends java.lang.Integer> values) {
      ensureContentLengthRangeIsMutable();
      com.google.protobuf.AbstractMessageLite.Builder.addAll(values, contentLengthRange_);
      onChanged();
      return this;
    }
    /**
     * repeated int32 contentLengthRange = 1;
     *
     * @return This builder for chaining.
     */
    public Builder clearContentLengthRange() {
      contentLengthRange_ = emptyIntList();
      bitField0_ = (bitField0_ & ~0x00000001);
      onChanged();
      return this;
    }

    private com.google.protobuf.LazyStringList startsWith_ =
        com.google.protobuf.LazyStringArrayList.EMPTY;

    private void ensureStartsWithIsMutable() {
      if (!((bitField0_ & 0x00000002) != 0)) {
        startsWith_ = new com.google.protobuf.LazyStringArrayList(startsWith_);
        bitField0_ |= 0x00000002;
      }
    }
    /**
     * repeated string startsWith = 2;
     *
     * @return A list containing the startsWith.
     */
    public com.google.protobuf.ProtocolStringList getStartsWithList() {
      return startsWith_.getUnmodifiableView();
    }
    /**
     * repeated string startsWith = 2;
     *
     * @return The count of startsWith.
     */
    public int getStartsWithCount() {
      return startsWith_.size();
    }
    /**
     * repeated string startsWith = 2;
     *
     * @param index The index of the element to return.
     * @return The startsWith at the given index.
     */
    public java.lang.String getStartsWith(int index) {
      return startsWith_.get(index);
    }
    /**
     * repeated string startsWith = 2;
     *
     * @param index The index of the value to return.
     * @return The bytes of the startsWith at the given index.
     */
    public com.google.protobuf.ByteString getStartsWithBytes(int index) {
      return startsWith_.getByteString(index);
    }
    /**
     * repeated string startsWith = 2;
     *
     * @param index The index to set the value at.
     * @param value The startsWith to set.
     * @return This builder for chaining.
     */
    public Builder setStartsWith(int index, java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }
      ensureStartsWithIsMutable();
      startsWith_.set(index, value);
      onChanged();
      return this;
    }
    /**
     * repeated string startsWith = 2;
     *
     * @param value The startsWith to add.
     * @return This builder for chaining.
     */
    public Builder addStartsWith(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }
      ensureStartsWithIsMutable();
      startsWith_.add(value);
      onChanged();
      return this;
    }
    /**
     * repeated string startsWith = 2;
     *
     * @param values The startsWith to add.
     * @return This builder for chaining.
     */
    public Builder addAllStartsWith(java.lang.Iterable<java.lang.String> values) {
      ensureStartsWithIsMutable();
      com.google.protobuf.AbstractMessageLite.Builder.addAll(values, startsWith_);
      onChanged();
      return this;
    }
    /**
     * repeated string startsWith = 2;
     *
     * @return This builder for chaining.
     */
    public Builder clearStartsWith() {
      startsWith_ = com.google.protobuf.LazyStringArrayList.EMPTY;
      bitField0_ = (bitField0_ & ~0x00000002);
      onChanged();
      return this;
    }
    /**
     * repeated string startsWith = 2;
     *
     * @param value The bytes of the startsWith to add.
     * @return This builder for chaining.
     */
    public Builder addStartsWithBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);
      ensureStartsWithIsMutable();
      startsWith_.add(value);
      onChanged();
      return this;
    }

    @java.lang.Override
    public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.setUnknownFields(unknownFields);
    }

    @java.lang.Override
    public final Builder mergeUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.mergeUnknownFields(unknownFields);
    }

    // @@protoc_insertion_point(builder_scope:google.cloud.conformance.storage.v1.PolicyConditions)
  }

  // @@protoc_insertion_point(class_scope:google.cloud.conformance.storage.v1.PolicyConditions)
  private static final com.google.cloud.conformance.storage.v1.PolicyConditions DEFAULT_INSTANCE;

  static {
    DEFAULT_INSTANCE = new com.google.cloud.conformance.storage.v1.PolicyConditions();
  }

  public static com.google.cloud.conformance.storage.v1.PolicyConditions getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<PolicyConditions> PARSER =
      new com.google.protobuf.AbstractParser<PolicyConditions>() {
        @java.lang.Override
        public PolicyConditions parsePartialFrom(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException {
          return new PolicyConditions(input, extensionRegistry);
        }
      };

  public static com.google.protobuf.Parser<PolicyConditions> parser() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.protobuf.Parser<PolicyConditions> getParserForType() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.cloud.conformance.storage.v1.PolicyConditions getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }
}


text:
Infrastructure
==============

Ansible playbooks and Dockerfile to setup the Customer Service infrastructure. Tested on Debian 8 server accessible via SSH.

Description of the playbooks:

* `bootstrap` installs Docker on the host.
* `run-nginx-proxy` runs jwilder/nginx-proxy, this allows to proxy any subdomain to another Docker container. Requires a wildcard DNS record pointing to the host. It also supports htpasswd protection and SSL.
* `run-jenkins` runs a Jenkins CI server. The original Jenkins Docker image is extended to pre-install Java, Maven and additional plugins and to create an intitial seed job.
* `run-postgres` runs a PostgreSQL database that is used by the later deployed Customer Service.

Setup
-----

Configure `hosts` inventory file.

Test ad-hoc commands:

    ansible -m ping hostname
    ansible -m setup hostname

Play the books:

    ansible-playbook bootstrap.yml
    ansible-playbook run-nginx-proxy.yml
    ansible-playbook run-jenkins.yml
    ansible-playbook run-postgres.yml


text:
namespace Google.Cloud.Dialogflow.V2.Snippets
{
    // [START dialogflow_v2_generated_EntityTypes_GetEntityType_async_flattened1]
    using Google.Cloud.Dialogflow.V2;
    using System.Threading.Tasks;

    public sealed partial class GeneratedEntityTypesClientSnippets
    {
        /// <summary>Snippet for GetEntityTypeAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task GetEntityType1Async()
        {
            // Create client
            EntityTypesClient entityTypesClient = await EntityTypesClient.CreateAsync();
            // Initialize request argument(s)
            string name = "projects/[PROJECT]/agent/entityTypes/[ENTITY_TYPE]";
            // Make the request
            EntityType response = await entityTypesClient.GetEntityTypeAsync(name);
        }
    }
    // [END dialogflow_v2_generated_EntityTypes_GetEntityType_async_flattened1]
}


text:
package cn.com.esrichina.adapter.commons;

public class ComputeResource {
	private int cpuNum;
	private int coreNumPerCpu;
	private int memory;

	public int getCpuNum() {
		return cpuNum;
	}

	public void setCpuNum(int cpuNum) {
		this.cpuNum = cpuNum;
	}

	public int getCoreNumPerCpu() {
		return coreNumPerCpu;
	}

	public void setCoreNumPerCpu(int coreNumPerCpu) {
		this.coreNumPerCpu = coreNumPerCpu;
	}

	public int getMemory() {
		return memory;
	}

	public void setMemory(int memory) {
		this.memory = memory;
	}

}


text:
package com.thinkaurelius.titan.util.datastructures;

import com.carrotsearch.hppc.LongArrayList;
import com.google.common.base.Preconditions;

/**
 * Utility class for merging and sorting lists of longs
 *
 * @author Matthias Broecheler (me@matthiasb.com)
 */
public class AbstractLongListUtil {

    public static boolean isSorted(LongArrayList l, final boolean unique) {
        for (int i = 1; i < l.size(); i++) {
            if (l.get(i) < l.get(i - 1) || (unique && l.get(i) == l.get(i - 1))) return false;
        }
        return true;
    }

    public static boolean isSorted(LongArrayList l) {
        return isSorted(l, false);
    }

    public static LongArrayList mergeSort(LongArrayList a, LongArrayList b) {
        int posa=0, posb=0;
        LongArrayList result = new LongArrayList(a.size()+b.size());
        while (posa<a.size() || posb<b.size()) {
            long next;
            if (posa>=a.size()) {
                next=b.get(posb++);
            } else if (posb>=b.size()) {
                next=a.get(posa++);
            } else if (a.get(posa)<=b.get(posb)) {
                next=a.get(posa++);
            } else {
                next=b.get(posb++);
            }
            Preconditions.checkArgument(result.isEmpty() || result.get(result.size()-1)<=next,
                    "The input lists are not sorted");
            result.add(next);
        }
        return result;
    }

    public static LongArrayList mergeJoin(LongArrayList a, LongArrayList b, final boolean unique) {
        assert isSorted(a) : a.toString();
        assert isSorted(b) : b.toString();
        int counterA = 0, counterB = 0;
        int sizeA = a.size();
        int sizeB = b.size();
        LongArrayList merge = new LongArrayList(Math.min(sizeA, sizeB));
        int resultSize = 0;
        while (counterA < sizeA && counterB < sizeB) {
            if (a.get(counterA) == b.get(counterB)) {
                long value = a.get(counterA);
                if (!unique) {
                    merge.add(value);
                    resultSize++;
                } else {
                    if (resultSize <= 0 || merge.get(resultSize - 1) != value) {
                        merge.add(value);
                        resultSize++;
                    }
                }
                counterA++;
                counterB++;
            } else if (a.get(counterA) < b.get(counterB)) {
                counterA++;
            } else {
                assert a.get(counterA) > b.get(counterB);
                counterB++;
            }
        }
        return merge;
    }

    public static LongArrayList singleton(long el) {
        LongArrayList l = new LongArrayList(1);
        l.add(el);
        return l;
    }

}


text:
package main

import (
	"github.com/pinzolo/csvutil"
)

var cmdAddress = &Command{
	Run:       runAddress,
	UsageLine: "address [OPTIONS...] [FILE]",
	Short:     "住所生成",
	Long: `DESCRIPTION
        指定した列にダミーの住所を出力します。
        郵便番号、都道府県、都市、町は同じ列を指定すれば追記されます。
        都市と町の区分は厳格なものではなく、都市→町→番地の順に記載されるもの程度の扱いです。

ARGUMENTS
        FILE
            ソースとなる CSV ファイルのパスを指定します。
            パスが指定されていない場合、標準入力が対象となりパイプでの使用ができます。

OPTIONS
        -w, --overwrite
            指定されたCSVファイルを実行結果で上書きします。
            ファイルパスが渡されていない場合には無視されます。

        -H, --no-header
            ソースとなるCSVの1行目をヘッダー列として扱いません。

        -b, --backup
            処理が成功した場合に、指定されたCSVファイルをバックアップします。
            --overwrite オプションと同時に使用されることを想定しているため、ファイルパスが渡されていない場合には無視されます。

        -e, --encoding ENCODING
            ソースとなるCSVの文字エンコーディングを指定します。
            このオプションが指定されていない場合、csvutil はUTF-8とみなして処理を行います。
            UTF-8であった場合、BOMのあるなしは自動的に判別されます。
            対応している値:
                sjis : Shift_JISとして扱います
                eucjp: EUC_JPとして扱います

        -oe, --output-encoding ENCODING
            出力するCSVの文字エンコーディングを指定します。
            このオプションが指定されていない場合 --encoding オプションで指定されたエンコーディングとして出力します。
            対応している値:
                utf8    : UTF-8として出力します(BOMは出力しません)
                utf8bom : UTF-8として出力します(BOMは出力します)
                sjis    : Shift_JISとして出力します
                eucjp   : EUC_JPとして出力します

        -z, --zip-code COLUMN_SYMBOL
            郵便番号を出力する列のシンボルを指定します。

        -p, --prefecture COLUMN_SYMBOL
            都道府県を出力する列のシンボルを指定します。

        -pc, --prefecture-code
            このオプションを指定すると都道府県を都道府県コードとして出力します。
            都道府県コードは 01 の用にゼロ埋めされています。

        -c, --city COLUMN_SYMBOL
            都市を出力する列のシンボルを指定します。

        -t, --town COLUMN_SYMBOL
            町を出力する列のシンボルを指定します。

        -bn, --block-number
            このオプションを指定すると --town オプションに対して、ダミーの番地を出力します。

        -nw, --number-width NUMBER
            このオプションに 1 を渡すと半角で、2 を渡すと全角で番地を出力します。
            初期値は 1 です。
	`,
}

type cmdAddressOption struct {
	csvutil.AddressOption
	Overwrite bool
	Backup    bool
}

var addressOpt = cmdAddressOption{}

func init() {
	cmdAddress.Flag.BoolVar(&addressOpt.Overwrite, "overwrite", false, "Overwrite to source.")
	cmdAddress.Flag.BoolVar(&addressOpt.Overwrite, "w", false, "Overwrite to source.")
	cmdAddress.Flag.BoolVar(&addressOpt.NoHeader, "no-header", false, "Source file does not have header line.")
	cmdAddress.Flag.BoolVar(&addressOpt.NoHeader, "H", false, "Source file does not have header line.")
	cmdAddress.Flag.BoolVar(&addressOpt.Backup, "backup", false, "Backup source file.")
	cmdAddress.Flag.BoolVar(&addressOpt.Backup, "b", false, "Backup source file.")
	cmdAddress.Flag.StringVar(&addressOpt.Encoding, "encoding", "utf8", "Encoding of source file")
	cmdAddress.Flag.StringVar(&addressOpt.Encoding, "e", "utf8", "Encoding of source file")
	cmdAddress.Flag.StringVar(&addressOpt.OutputEncoding, "output-encoding", "", "Encoding for output")
	cmdAddress.Flag.StringVar(&addressOpt.OutputEncoding, "oe", "", "Encoding for output")
	cmdAddress.Flag.StringVar(&addressOpt.ZipCode, "zip-code", "", "Zip code column symbol")
	cmdAddress.Flag.StringVar(&addressOpt.ZipCode, "z", "", "Zip code column symbol")
	cmdAddress.Flag.StringVar(&addressOpt.Prefecture, "prefecture", "", "Prefecture column symbol")
	cmdAddress.Flag.StringVar(&addressOpt.Prefecture, "p", "", "Prefecture column symbol")
	cmdAddress.Flag.BoolVar(&addressOpt.PrefectureCode, "prefecture-code", false, "Output prefecture code instead of prefecture name")
	cmdAddress.Flag.BoolVar(&addressOpt.PrefectureCode, "pc", false, "Output prefecture code instead of prefecture name")
	cmdAddress.Flag.StringVar(&addressOpt.City, "city", "", "City column symbol")
	cmdAddress.Flag.StringVar(&addressOpt.City, "c", "", "City column symbol")
	cmdAddress.Flag.StringVar(&addressOpt.Town, "town", "", "Town column symbol")
	cmdAddress.Flag.StringVar(&addressOpt.Town, "t", "", "Town column symbol")
	cmdAddress.Flag.BoolVar(&addressOpt.BlockNumber, "block-number", false, "Output block number after town")
	cmdAddress.Flag.BoolVar(&addressOpt.BlockNumber, "bn", false, "Output block number after town")
	cmdAddress.Flag.IntVar(&addressOpt.NumberWidth, "number-width", 1, "Block number character width")
	cmdAddress.Flag.IntVar(&addressOpt.NumberWidth, "nw", 1, "Block number character width")
}

// runAddress executes address command and return exit code.
func runAddress(args []string) int {
	success := false
	w, wf, r, rf, err := prepare(args, addressOpt.Overwrite)
	if wf != nil {
		defer wf(&success, addressOpt.Backup)
	}
	if rf != nil {
		defer rf()
	}
	if err != nil {
		return handleError(err)
	}

	err = csvutil.Address(r, w, addressOpt.AddressOption)
	if err != nil {
		return handleError(err)
	}

	success = true
	return 0
}


text:
<!--
http://moz.com/blog/meta-data-templates-123
http://scotch.io/quick-tips/all-search-and-social-media-meta-tags-starter-template
-->
<html>

<!-- Place this data between the <head> tags of your website -->
<title>Page Title. Maximum length 60-70 characters</title>
<meta name="description" content="Page description. No longer than 155 characters." />

<!-- Schema.org markup for Google+ -->
<meta itemprop="name" content="The Name or Title Here">
<meta itemprop="description" content="This is the page description">
<meta itemprop="image" content="http://www.example.com/image.jpg">

<!-- Twitter Card data -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@publisher_handle">
<meta name="twitter:title" content="Page Title">
<meta name="twitter:description" content="Page description less than 200 characters">
<meta name="twitter:creator" content="@author_handle">
<!-- Twitter summary card with large image must be at least 280x150px -->
<meta name="twitter:image:src" content="http://www.example.com/image.html">

<!-- Open Graph data -->
<meta property="og:title" content="Title Here" />
<meta property="og:type" content="article" />
<meta property="og:url" content="http://www.example.com/" />
<meta property="og:image" content="http://example.com/image.jpg" />
<meta property="og:description" content="Description Here" />
<meta property="og:site_name" content="Site Name, i.e. Moz" />
<meta property="article:published_time" content="2013-09-17T05:59:00+01:00" />
<meta property="article:modified_time" content="2013-09-16T19:08:47+01:00" />
<meta property="article:section" content="Article Section" />
<meta property="article:tag" content="Article Tag" />
<meta property="fb:admins" content="Facebook numberic ID" />

<link rel="canonical" href="http://scotch.io/bar-talk/bootstrap-3-tips-and-tricks-you-might-not-know">


text:
package weixin.popular.bean.datacube.getcardmembercardinfo;

import java.util.List;

import weixin.popular.bean.BaseResult;

/**
 * 拉取会员卡数据接口-响应对象
 *
 * @author Moyq5
 *
 */
public class MemberCardInfoResult extends BaseResult {

	List<MemberCardInfoResultInfo> list;

	public List<MemberCardInfoResultInfo> getList() {
		return list;
	}

	public void setList(List<MemberCardInfoResultInfo> list) {
		this.list = list;
	}
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<Tokens version="1.0">
	<File path="Classes/XCTestObservationCenter.html">

		<Token>
			<TokenIdentifier>//apple_ref/occ/cl/XCTestObservationCenter</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/clm/XCTestObservationCenter/sharedTestObservationCenter</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>+ (id)sharedTestObservationCenter</Declaration>

			<Anchor>//api/name/sharedTestObservationCenter</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/_addLegacyTestObserver:</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (void)_addLegacyTestObserver:(id)arg1</Declaration>

			<Anchor>//api/name/_addLegacyTestObserver:</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/_instantiateObserversFromObserverClassNames:</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (void)_instantiateObserversFromObserverClassNames:(id)arg1</Declaration>

			<Anchor>//api/name/_instantiateObserversFromObserverClassNames:</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/_observeTestExecutionForBlock:</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (void)_observeTestExecutionForBlock:(CDUnknownBlockType)arg1</Declaration>

			<Anchor>//api/name/_observeTestExecutionForBlock:</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/_resumeObservation</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (void)_resumeObservation</Declaration>

			<Anchor>//api/name/_resumeObservation</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/_suspendObservation</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (void)_suspendObservation</Declaration>

			<Anchor>//api/name/_suspendObservation</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/_suspendObservationForBlock:</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (void)_suspendObservationForBlock:(CDUnknownBlockType)arg1</Declaration>

			<Anchor>//api/name/_suspendObservationForBlock:</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/_testCase:didFinishActivity:</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (void)_testCase:(id)arg1 didFinishActivity:(id)arg2</Declaration>

			<Anchor>//api/name/_testCase:didFinishActivity:</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/_testCase:didMeasureValues:forPerformanceMetricID:name:unitsOfMeasurement:baselineName:baselineAverage:maxPercentRegression:maxPercentRelativeStandardDeviation:maxRegression:maxStandardDeviation:file:line:</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (void)_testCase:(id)arg1 didMeasureValues:(id)arg2 forPerformanceMetricID:(id)arg3 name:(id)arg4 unitsOfMeasurement:(id)arg5 baselineName:(id)arg6 baselineAverage:(id)arg7 maxPercentRegression:(id)arg8 maxPercentRelativeStandardDeviation:(id)arg9 maxRegression:(id)arg10 maxStandardDeviation:(id)arg11 file:(id)arg12 line:(unsigned long long)arg13</Declaration>

			<Anchor>//api/name/_testCase:didMeasureValues:forPerformanceMetricID:name:unitsOfMeasurement:baselineName:baselineAverage:maxPercentRegression:maxPercentRelativeStandardDeviation:maxRegression:maxStandardDeviation:file:line:</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/_testCase:willStartActivity:</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (void)_testCase:(id)arg1 willStartActivity:(id)arg2</Declaration>

			<Anchor>//api/name/_testCase:willStartActivity:</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/_testCaseDidFail:withDescription:inFile:atLine:</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (void)_testCaseDidFail:(id)arg1 withDescription:(id)arg2 inFile:(id)arg3 atLine:(unsigned long long)arg4</Declaration>

			<Anchor>//api/name/_testCaseDidFail:withDescription:inFile:atLine:</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/_testCaseDidStart:</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (void)_testCaseDidStart:(id)arg1</Declaration>

			<Anchor>//api/name/_testCaseDidStart:</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/_testCaseDidStop:</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (void)_testCaseDidStop:(id)arg1</Declaration>

			<Anchor>//api/name/_testCaseDidStop:</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/_testSuiteDidFail:withDescription:inFile:atLine:</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (void)_testSuiteDidFail:(id)arg1 withDescription:(id)arg2 inFile:(id)arg3 atLine:(unsigned long long)arg4</Declaration>

			<Anchor>//api/name/_testSuiteDidFail:withDescription:inFile:atLine:</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/_testSuiteDidStart:</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (void)_testSuiteDidStart:(id)arg1</Declaration>

			<Anchor>//api/name/_testSuiteDidStart:</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/_testSuiteDidStop:</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (void)_testSuiteDidStop:(id)arg1</Declaration>

			<Anchor>//api/name/_testSuiteDidStop:</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/addTestObserver:</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (void)addTestObserver:(id)arg1</Declaration>

			<Anchor>//api/name/addTestObserver:</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/description</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (id)description</Declaration>

			<Anchor>//api/name/description</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/init</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (id)init</Declaration>

			<Anchor>//api/name/init</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/setObservers:</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>@property (readonly) NSMutableSet *observers</Declaration>

			<Anchor>//api/name/observers</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/observers</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>@property (readonly) NSMutableSet *observers</Declaration>

			<Anchor>//api/name/observers</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instp/XCTestObservationCenter/observers</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>@property (readonly) NSMutableSet *observers</Declaration>

			<Anchor>//api/name/observers</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/removeTestObserver:</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>- (void)removeTestObserver:(id)arg1</Declaration>

			<Anchor>//api/name/removeTestObserver:</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/setSuspended:</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>@property _Bool suspended</Declaration>

			<Anchor>//api/name/suspended</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instm/XCTestObservationCenter/suspended</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>@property _Bool suspended</Declaration>

			<Anchor>//api/name/suspended</Anchor>
            <NodeRef refid="32"/>
		</Token>

		<Token>
			<TokenIdentifier>//apple_ref/occ/instp/XCTestObservationCenter/suspended</TokenIdentifier>
			<Abstract type="html"></Abstract>
			<DeclaredIn>XCTestObservationCenter.h</DeclaredIn>

			<Declaration>@property _Bool suspended</Declaration>

			<Anchor>//api/name/suspended</Anchor>
            <NodeRef refid="32"/>
		</Token>

	</File>
</Tokens>


text:
Collections and their document structure are listed below

---

##user
  * email - String
  * password - String
  * name - String


text:
id: 5900f4231000cf542c50ff36
title: 'Problem 183: Maximum product of parts'
challengeType: 5
forumTopicId: 301819
dashedName: problem-183-maximum-product-of-parts
---

# --description--

Let $N$ be a positive integer and let $N$ be split into $k$ equal parts, $r = \frac{N}{k}$, so that $N = r + r + \cdots + r$.

Let $P$ be the product of these parts, $P = r × r × \cdots × r = r^k$.

For example, if 11 is split into five equal parts, 11 = 2.2 + 2.2 + 2.2 + 2.2 + 2.2, then $P = {2.2}^5 = 51.53632$.

Let $M(N) = P_{max}$ for a given value of $N$.

It turns out that the maximum for $N = 11$ is found by splitting eleven into four equal parts which leads to $P_{max} = {(\frac{11}{4})}^4$; that is, $M(11) = \frac{14641}{256} = 57.19140625$, which is a terminating decimal.

However, for $N = 8$ the maximum is achieved by splitting it into three equal parts, so $M(8) = \frac{512}{27}$, which is a non-terminating decimal.

Let $D(N) = N$ if $M(N)$ is a non-terminating decimal and $D(N) = -N$ if $M(N)$ is a terminating decimal.

For example, $\sum D(N)$ for $5 ≤ N ≤ 100$ is 2438.

Find $\sum D(N)$ for $5 ≤ N ≤ 10000$.

# --hints--

`maximumProductOfParts()` should return `48861552`.

```js
assert.strictEqual(maximumProductOfParts(), 48861552);
```

# --seed--

## --seed-contents--

```js
function maximumProductOfParts() {

  return true;
}

maximumProductOfParts();
```

# --solutions--

```js
// solution required
```


text:
============
Introduction
============

Welcome! `Dataverse <http://dataverse.org>`_ is an `open source <https://github.com/IQSS/dataverse/blob/master/LICENSE.md>`_ project that loves `contributors <https://github.com/IQSS/dataverse/blob/master/CONTRIBUTING.md>`_!

Intended Audience
-----------------

This guide is intended primarily for developers who want to work on the main Dataverse code base at https://github.com/IQSS/dataverse

To get started, you'll want to set up your :doc:`/developers/dev-environment` and make sure you understand the :doc:`/developers/branching-strategy`. Thorough :doc:`/developers/testing` is encouraged (and expected). Opinions about :doc:`/developers/coding-style` are welcome!

If you have any questions at all, please reach out to other developers per https://github.com/IQSS/dataverse/blob/master/CONTRIBUTING.md

Roadmap
-------

For the Dataverse development roadmap, please see https://github.com/IQSS/dataverse/milestones

The `Contributing to Dataverse <https://github.com/IQSS/dataverse/blob/master/CONTRIBUTING.md>`_ document in the root of the source tree provides guidance on:

- the use of `labels <https://github.com/IQSS/dataverse/labels>`_ to organize and prioritize `issues <https://github.com/IQSS/dataverse/issues>`_
- making pull requests
- how to contact the development team

Related Guides
--------------

If you are a developer who wants to make use of Dataverse APIs, please see the :doc:`/api/index`.

If you are a sysadmin who likes to code, you may be interested in hacking on installation scripts mentioned in the :doc:`/installation/index`. We validate the installation scripts with :doc:`/developers/tools` such as `Vagrant <http://vagrantup.com>`_.

Related Projects
----------------

As a developer, you also may be interested in these projects related to Dataverse:

- `Zelig <http://zeligproject.org>`_ (R) - run statistical models on files uploaded to Dataverse: https://github.com/IQSS/Zelig
- `TwoRavens <http://datascience.iq.harvard.edu/about-tworavens>`_ (Javascript) - a `d3.js <http://d3js.org>`_ interface for exploring data and running Zelig models: https://github.com/IQSS/TwoRavens
- :doc:`/developers/unf/index` (Java) -  a Universal Numerical Fingerprint: https://github.com/IQSS/UNF
- `DataTags <https://github.com/IQSS/DataTags>`_ (Java and Scala) - tag datasets with privacy levels: https://github.com/IQSS/DataTags
- GeoConnect (Python) - create a map by uploading files to Dataverse: https://github.com/IQSS/geoconnect
- Dataverse API client libraries - use Dataverse APIs from various languages: :doc:`/api/client-libraries`
- Third party apps - make use of Dataverse APIs: :doc:`/api/apps`
- [Your project here] :)


text:
//-----------------------------------------------------------------------------
// Copyright (c) 2013 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------

#include "console/console.h"
#include "platform/platformInput.h"

//------------------------------------------------------------------------------
/*! Use the activateKeyboard function to enable directInput polling of the keyboard.
    @return Returns a true if polling was successfully enabled.
    @sa deactivateKeyboard
*/
ConsoleFunctionWithDocs( activateKeyboard, ConsoleBool, 1, 1, ())
{
	return Input::activateKeyboard();
}

//------------------------------------------------------------------------------
/*! Use the deactivateKeyboard function to disable directInput polling of the keyboard.
    @return No return value.
    @sa activateKeyboard
*/
ConsoleFunctionWithDocs( deactivateKeyboard, ConsoleVoid, 1, 1, ())
{
	Input::deactivateKeyboard();
}

//------------------------------------------------------------------------------
/*! Use the enableMouse function to enable mouse input.
    @return No return value.
    @sa disableMouse
*/
ConsoleFunctionWithDocs( enableMouse, ConsoleVoid, 1, 1, ())
{
	Input::enableMouse();
}

//------------------------------------------------------------------------------
/*! Use the disableMouse function to disable mouse input.
    @return No return value.
    @sa enableMouse
*/
ConsoleFunctionWithDocs( disableMouse, ConsoleVoid, 1, 1, ())
{
	Input::disableMouse();
}

//------------------------------------------------------------------------------
/*! Use the enableJoystick function to enable joystick input if it is present.
    @return Will return true if the joystick is present and was successfully enabled, false otherwise.
    @sa disableJoystick, getJoystickAxes, isJoystickDetected
*/
ConsoleFunctionWithDocs( enableJoystick, ConsoleBool, 1, 1, ())
{
	return Input::enableJoystick();
}

//------------------------------------------------------------------------------
/*! Use the disableJoystick function to disable joystick input.
    @return No return value.
    @sa enableJoystick, getJoystickAxes, isJoystickEnabled
*/
ConsoleFunctionWithDocs( disableJoystick, ConsoleVoid, 1, 1, ())
{
	Input::disableJoystick();
}

//------------------------------------------------------------------------------
/*! Use the echoInputState function to dump the input state of the mouse, keyboard, and joystick to the console.
    @return No return value.
    @sa activateDirectInput, deactivateDirectInput, activateKeyboard, deactivateKeyboard, disableJoystick, enableJoystick, enableMouse, disableMouse
*/
ConsoleFunctionWithDocs( echoInputState, ConsoleVoid, 1, 1, ())
{
	Input::echoInputState();
}

/*!	Enables XInput for Xbox 360 controllers.
	@return No return value.
*/
ConsoleFunctionWithDocs( enableXInput, ConsoleBool, 1, 1, ())

{
   return( DInputManager::enableXInput() );
}

/*! Disables XInput for Xbox 360 controllesr
	@return No return value.
*/

ConsoleFunctionWithDocs( disableXInput, ConsoleVoid, 1, 1, ())
{
   DInputManager::disableXInput();
}

/*!	Rebuilds the XInput section of the InputManager.
     @return No return value.
*/
ConsoleFunctionWithDocs( resetXInput, ConsoleVoid, 1, 1, ())
{
   // This function requests a full "refresh" of events for all controllers the
   // next time we go through the input processing loop. This is useful to call
   // at the beginning of your game code after your actionMap is set up to hook
   // all of the appropriate events

   DInputManager* mgr = dynamic_cast<DInputManager*>( Input::getManager() );
   if ( mgr && mgr->isEnabled() )
      mgr->resetXInput();
}

/*!	Checks to see if an Xbox 360 controller is connected
	@param controllerID Zero-based index of the controller to check.
	@return 1 if the controller is connected, 0 if it isn't, and 205 if XInput
	hasn't been initialized.
*/

ConsoleFunctionWithDocs( isXInputConnected, ConsoleBool, 2, 2, ( int controllerID ))
{
   DInputManager* mgr = dynamic_cast<DInputManager*>( Input::getManager() );
   if ( mgr && mgr->isEnabled() ) return mgr->isXInputConnected( atoi( argv[1] ) );
   return false;
}

/*!	Queries the current state of a connected Xbox 360 controller.
	@param controllerID Zero-based index of the controller to return information about.
    @param property Name of input action being queried, such as \"XI_THUMBLX\".
    @param current True checks current device in action.
    @return Button queried - 1 if the button is pressed, 0 if it's not.
    @return Thumbstick queried - Int representing displacement from rest position.
    @return %Trigger queried - Int from 0 to 255 representing how far the trigger is displaced.
*/

//------------------------------------------------------------------------------
ConsoleFunctionWithDocs( getXInputState, ConsoleInt, 3, 4, ( int controllerID, string property, bool current ) )
{
   DInputManager* mgr = dynamic_cast<DInputManager*>( Input::getManager() );

   if ( !mgr || !mgr->isEnabled() )
      return -1;

   // Use a little bit of macro magic to simplify this otherwise monolothic
   // block of code.
#define GET_XI_STATE(constName) \
   if (!dStricmp(argv[2], #constName)) \
      return mgr->getXInputState( dAtoi( argv[1] ), constName, ( dAtoi ( argv[3] ) == 1) );

   GET_XI_STATE(XI_THUMBLX);
   GET_XI_STATE(XI_THUMBLY);
   GET_XI_STATE(XI_THUMBRX);
   GET_XI_STATE(XI_THUMBRY);
   GET_XI_STATE(XI_LEFT_TRIGGER);
   GET_XI_STATE(XI_RIGHT_TRIGGER);
   GET_XI_STATE(SI_UPOV);
   GET_XI_STATE(SI_DPOV);
   GET_XI_STATE(SI_LPOV);
   GET_XI_STATE(SI_RPOV);
   GET_XI_STATE(XI_START);
   GET_XI_STATE(XI_BACK);
   GET_XI_STATE(XI_LEFT_THUMB);
   GET_XI_STATE(XI_RIGHT_THUMB);
   GET_XI_STATE(XI_LEFT_SHOULDER);
   GET_XI_STATE(XI_RIGHT_SHOULDER);
   GET_XI_STATE(XI_A);
   GET_XI_STATE(XI_B);
   GET_XI_STATE(XI_X);
   GET_XI_STATE(XI_Y);
#undef GET_XI_STATE

   return -1;
}

/*!	Activates the vibration motors in the specified controller.
    The controller will constantly at it's xRumble and yRumble intensities until
    changed or told to stop.

	 Valid inputs for xRumble/yRumble are [0 - 1].

	 @param device Name of the device to rumble.
      @param xRumble Intensity to apply to the left motor.
      @param yRumble Intensity to apply to the right motor.

	 @note in an Xbox 360 controller, the left motor is low-frequency,
     while the right motor is high-frequency.

*/

ConsoleFunctionWithDocs( rumble, ConsoleVoid, 4, 4, (string device, float xRumble, float yRumble) )
{
   DInputManager* mgr = dynamic_cast<DInputManager*>( Input::getManager() );
   if ( mgr && mgr->isEnabled() )
   {
      mgr->rumble(argv[1], dAtof(argv[2]), dAtof(argv[3]));
   }
   else
   {
      Con::printf( "DirectInput/XInput is not enabled." );
   }
}


text:
/*!
 @header    UITableViewCellEx.h
 @abstract  封装下划线及Cell的点击效果
 @author    dasmaster
 @version   2.1.0 2012/11/02 Creation
 */

#import <UIKit/UIKit.h>

#define kExCellIdentifier (@"UITableViewCellEx")

/*!
 @class
 @abstract  封装下划线及Cell的点击效果
 */
@interface UITableViewCellEx : UITableViewCell

@property (nonatomic,assign) float preferWidth;

- (void)drawCellDefault;
- (void)drawCellStyleThick;
@end


text:
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.trino.cli;

import org.jline.reader.EOFError;
import org.testng.annotations.Test;

import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.jline.reader.Parser.ParseContext.ACCEPT_LINE;
import static org.jline.reader.Parser.ParseContext.COMPLETE;
import static org.testng.Assert.assertNotNull;

public class TestInputParser
{
    @Test
    public void testParseIncompleteStatements()
    {
        InputParser instance = new InputParser();
        // assert an incomplete statement throws an error if the ParseContext is not COMPLETE
        assertThatThrownBy(() -> instance.parse("show", 4, ACCEPT_LINE)).isInstanceOf(EOFError.class);
        assertNotNull(instance.parse("show", 4, COMPLETE));
    }
}


text:
class NoiseEffector : public EffectorData
{
public:
	Float size;

	virtual Bool InitEffector(GeListNode* node);

	virtual void InitPoints(BaseObject* op, BaseObject* gen, BaseDocument* doc, EffectorDataStruct* data, MoData* md, BaseThread* thread);

	virtual void CalcPointValue(BaseObject* op, BaseObject* gen, BaseDocument* doc, EffectorDataStruct* data, Int32 index, MoData* md, const Vector& globalpos, Float fall_weight);
	virtual Vector CalcPointColor(BaseObject* op, BaseObject* gen, BaseDocument* doc, EffectorDataStruct* data, Int32 index, MoData* md, const Vector& globalpos, Float fall_weight);

	static NodeData* Alloc() { return NewObjClear(NoiseEffector); }
};

// Called when effector is first created
Bool NoiseEffector::InitEffector(GeListNode* node)
{
	BaseObject* op = (BaseObject*)node;
	if (!op)
		return false;

	BaseContainer* bc = op->GetDataInstance();
	if (!bc)
		return false;

	bc->SetFloat(ID_MG_BASEEFFECTOR_MINSTRENGTH, -1.0);
	bc->SetBool(ID_MG_BASEEFFECTOR_POSITION_ACTIVE, true);
	bc->SetVector(ID_MG_BASEEFFECTOR_POSITION, Vector(50.0));
	bc->SetFloat(NOISEEFFECTOR_SCALE, 0.01);

	return true;
}

// Called just before points calculation
void NoiseEffector::InitPoints(BaseObject* op, BaseObject* gen, BaseDocument* doc, EffectorDataStruct* data, MoData* md, BaseThread* thread)
{
	BaseContainer* bc = op->GetDataInstance();
	if (!bc)
		return;

	size = bc->GetFloat(NOISEEFFECTOR_SCALE);
}

// This example shows two methods to setting the values that drive the effector
// change this value to 1 to try the second method
const Int32 EffectorMethod = 0;

void NoiseEffector::CalcPointValue(BaseObject* op, BaseObject* gen,	BaseDocument* doc, EffectorDataStruct* data, Int32 index, MoData* md, const Vector& globalpos, Float fall_weight)
{
	switch (EffectorMethod)
	{
		case 0:
		{
			// First Method, this one just iterates through the "blends" which are the raw driver values and is slightly faster
			Int32	 i = 0;
			Float* buf = data->strengths;
			for (i = 0; i < BLEND_COUNT; i++, buf++)
			{
				(*buf) = Noise((globalpos + (i * 20.0)) * size);
			}
			break;
		}

		case 1:
		{
			// Method 2, this casts the the more user friendly EffectorStrengths structure for setting of values
			EffectorStrengths* es = (EffectorStrengths*)data->strengths;
			// Position
			es->pos = Vector(Noise(globalpos * size),
									Noise((globalpos + Vector(10.0)) * size),
									Noise((globalpos - Vector(10.0)) * size));
			// Rotation
			es->rot = Vector(Noise((globalpos + Vector(20.0, 60.0, -90.0)) * size),
									Noise((globalpos + Vector(-20.0, 60.0, 90.0)) * size),
									Noise((globalpos + Vector(20.0, -60.0, 90.0)) * size));
			// Scale
			es->scale = Vector(Noise((globalpos + Vector(120.0, -160.0, -190.0)) * size),
										Noise((globalpos + Vector(100.0, 160.0, 190.0)) * size),
										Noise((globalpos + Vector(160.0, 160.0, 190.0)) * size));
			// Color opacity
			es->col = Vector(Noise(globalpos * size));
			// Others, x = U, y = V, z = Visibility
			es->other = Vector(Noise((globalpos + Vector(40.0, 70.0, -10.0)) * size),
										Noise((globalpos + Vector(-40.0, 70.0, 10.0)) * size),
										Noise((globalpos + Vector(40.0, -70.0, 10.0)) * size));
			// Others2, x = weight, y = clone index, z = time
			es->other2 = Vector(Noise((globalpos + Vector(90.0, 20.0, -50.0)) * size),
										 Noise((globalpos + Vector(-90.0, 20.0, 50.0)) * size),
										 Noise((globalpos + Vector(90.0, -20.0, 50.0)) * size));
			// Others3 <reserved>
			es->other3 = Vector(Noise((globalpos + Vector(90.0, 20.0, -50.0)) * size),
										 Noise((globalpos + Vector(-90.0, 20.0, 50.0)) * size),
										 Noise((globalpos + Vector(90.0, -20.0, 50.0)) * size));
			break;
		}

		default:
			break;
	}
}

// Calculcate the effector color
Vector NoiseEffector::CalcPointColor(BaseObject* op, BaseObject* gen, BaseDocument* doc, EffectorDataStruct* data, Int32 index, MoData* md, const Vector& globalpos, Float fall_weight)
{
	return Vector(Noise(globalpos), Noise(globalpos + 20), Noise(globalpos - 20));
}

// be sure to use a unique ID obtained from www.plugincafe.com
#define ID_NOISEEFFECTOR 1019570

Bool RegisterNoiseEffector()
{
	return RegisterEffectorPlugin(ID_NOISEEFFECTOR, GeLoadString(IDS_NOISEEFFECTOR), OBJECT_CALL_ADDEXECUTION, NoiseEffector::Alloc, "oenoise", AutoBitmap("noiseeffector.tif"), 0);
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         version="3.0"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
 <servlet>
    <servlet-name>org.kie.server.remote.rest.common.KieServerApplication</servlet-name>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>org.kie.server.remote.rest.common.KieServerApplication</servlet-name>
    <url-pattern>/rest/*</url-pattern>
  </servlet-mapping>
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>REST web resources</web-resource-name>
      <url-pattern>/rest/*</url-pattern>
      <http-method>GET</http-method>
      <http-method>PUT</http-method>
      <http-method>POST</http-method>
      <http-method>DELETE</http-method>
    </web-resource-collection>
    <auth-constraint>
      <role-name>employees</role-name>
    </auth-constraint>
  </security-constraint>
  <login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>KIE Server</realm-name>
  </login-config>
  <security-role>
    <role-name>employees</role-name>
  </security-role>

</web-app>


text:
package com.baomidou.mybatisplus.test;

import com.baomidou.mybatisplus.annotation.DbType;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
 * @author nieqiuqiu
 */
class DbTypeTest {

    @Test
    void testGetDbType() {
        Assertions.assertEquals(DbType.MYSQL, DbType.getDbType("mysql"));
        Assertions.assertEquals(DbType.MYSQL, DbType.getDbType("Mysql"));
        Assertions.assertEquals(DbType.OTHER, DbType.getDbType("other"));
        Assertions.assertEquals(DbType.OTHER, DbType.getDbType("unknown"));
    }
}


text:
"""
Hydropy package
@author: Stijn Van Hoey
from: https://github.com/stijnvanhoey/hydropy/tree/master/hydropy
for a better and more up to date copy of this script go to the original repo.
"""
from __future__ import absolute_import, division, print_function, unicode_literals
import pandas as pd
import numpy as np
from scipy.optimize import curve_fit

def get_baseflow_chapman(flowserie, recession_time):
    """
    Parameters
    ----------
    flowserie :  pd.TimeSeries
        River discharge flowserie
    recession_time : float [0-1]
        recession constant
    Notes
    ------
    $$Q_b(i) = \frac{k}{2-k}Q_b(i-1) + \frac{1-k}{2-k}Q(i)$$
    """

    secterm = (1.-recession_time)*flowserie/(2.-recession_time)

    baseflow = np.empty(flowserie.shape[0])
    for i, timestep in enumerate(baseflow):
        if i == 0:
            baseflow[i] = 0.0
        else:
            baseflow[i] = recession_time*baseflow[i-1]/(2.-recession_time) + \
                            secterm.values[i]
    baseflow = pd.DataFrame(baseflow, index=flowserie.index)
    return baseflow

def get_baseflow_boughton(flowserie, recession_time, baseflow_index):
    """
    Parameters
    ----------
    flowserie :  pd.TimeSeries
        River discharge flowserie
    recession_time : float [0-1]
        recession constant
    baseflow_index : float
    Notes
    ------
    $$Q_b(i) = \frac{k}{1+C}Q_b(i-1) + \frac{C}{1+C}Q(i)$$
    """

    parC = baseflow_index

    secterm = parC*flowserie/(1 + parC)

    baseflow = np.empty(flowserie.shape[0])
    for i, timestep in enumerate(baseflow):
        if i == 0:
            baseflow[i] = 0.0
        else:
            baseflow[i] = recession_time*baseflow[i-1]/(1 + parC) + \
                            secterm.values[i]
    return pd.DataFrame(baseflow, index=flowserie.index)

def get_baseflow_ihacres(flowserie, recession_time, baseflow_index, alfa):
    """
    Parameters
    ----------
    flowserie :  pd.TimeSeries
        River discharge flowserie
    recession_time : float [0-1]
        recession constant
    Notes
    ------
    $$Q_b(i) = \frac{k}{1+C}Q_b(i-1) + \frac{C}{1+C}[Q(i)+\alpha Q(i-1)]$$
    $\alpha$ < 0.
    """

    parC = baseflow_index

    secterm = parC/(1 + parC)

    baseflow = np.empty(flowserie.shape[0])
    for i, timestep in enumerate(baseflow):
        if i == 0:
            baseflow[i] = 0.0
        else:
            baseflow[i] = recession_time * baseflow[i-1]/(1 + parC) + \
                            secterm * (flowserie.values[i] +
                                       alfa * flowserie.values[i-1])
    return pd.DataFrame(baseflow, index=flowserie.index)

def exp_curve(x, a, b):
    """Exponential curve used for rating curves"""
    return (a * x**b)

def ratingCurve(discharge, stage):
    """Computes rating curve based on discharge measurements coupled with stage
    readings.
    discharge = array of measured discharges;
    stage = array of corresponding stage readings;
    Returns coefficients a, b for the rating curve in the form y = a * x**b
    """

    popt, pcov = curve_fit(exp_curve, stage, discharge)

    def r_squ():
        a = 0.0
        b = 0.0
        for i, j in zip(discharge, stage):
            a += (i - exp_curve(j, popt[0], popt[1]))**2
            b += (i - np.mean(discharge))**2
        return 1 - a / b

    return popt, r_squ()

def RB_Flashiness(series):
    """Richards-Baker Flashiness Index for a series of daily mean discharges.
    https://github.com/hydrogeog/hydro"""
    Qsum = np.sum(series)           # sum of daily mean discharges
    Qpath = 0.0
    for i in range(len(series)):
        if i == 0:
            Qpath = series[i]       # first entry only
        else:
            Qpath += np.abs(series[i] - series[i-1])    # sum the absolute differences of the mean discharges
    return Qpath/Qsum

def flow_duration(series):
    """Creates the flow duration curve for a discharge dataset. Returns a pandas
    series whose index is the discharge values and series is exceedance probability.
    https://github.com/hydrogeog/hydro"""
    fd = pd.Series(series).value_counts()               # frequency of unique values
    fd.sort_index(inplace=True)                         # sort in order of increasing discharges
    fd = fd.cumsum()                                    # cumulative sum of frequencies
    fd = fd.apply(lambda x: 100 - x/fd.max() * 100)     # normalize
    return fd

def Lyne_Hollick(series, alpha=.925, direction='f'):
    """Recursive digital filter for baseflow separation. Based on Lyne and Hollick, 1979.
    series = array of discharge measurements
    alpha = filter parameter
    direction = (f)orward or (r)everse calculation
    https://github.com/hydrogeog/hydro
    """
    series = np.array(series)
    f = np.zeros(len(series))
    if direction == 'f':
        for t in np.arange(1,len(series)):
            f[t] = alpha * f[t-1] + (1 + alpha)/2 * (series[t] - series[t-1])
            if series[t] - f[t] > series[t]:
                f[t] = 0
    elif direction == 'r':
        for t in np.arange(len(series)-2, 1, -1):
            f[t] = alpha * f[t+1] + (1 + alpha)/2 * (series[t] - series[t+1])
            if series[t] - f[t] > series[t]:
                f[t] = 0
    return np.array(series - f)

def Eckhardt(series, alpha=.98, BFI=.80):
    """Recursive digital filter for baseflow separation. Based on Eckhardt, 2004.
    series = array of discharge measurements
    alpha = filter parameter
    BFI = BFI_max (maximum baseflow index)
    https://github.com/hydrogeog/hydro
    """
    series = np.array(series)
    f = np.zeros(len(series))
    f[0] = series[0]
    for t in np.arange(1,len(series)):
        f[t] = ((1 - BFI) * alpha * f[t-1] + (1 - alpha) * BFI * series[t]) / (1 - alpha * BFI)
        if f[t] > series[t]:
            f[t] = series[t]
    return f