text:
namespace performance_monitor {

class PerformanceMonitorUtilTest : public ::testing::Test {
 protected:
  // Helper method in order to access the otherwise-private AggregateInterval
  // method within the aggregation classes, so that we can test specific
  // aggregation methods without the extra burden of interval separation (which
  // is tested separately).
  scoped_ptr<Database::MetricVector> AggregateSingleInterval(
      MetricType type,
      const Database::MetricVector* metrics,
      const base::Time& start,
      const base::TimeDelta& resolution,
      AggregationMethod method) {
    const base::Time kMaxTime = base::Time::FromDoubleT(100);
    Database::MetricVector::const_iterator metric = metrics->begin();
    while (metric != metrics->end() && metric->time < start)
      ++metric;

    scoped_ptr<Aggregator> aggregator;
    switch (method) {
      case AGGREGATION_METHOD_NONE:
        aggregator.reset(new NoAggregation());
        break;
      case AGGREGATION_METHOD_MEDIAN:
        aggregator.reset(new MedianAggregation());
        break;
      case AGGREGATION_METHOD_MEAN:
        aggregator.reset(new MeanAggregation());
        break;
      default:
        NOTREACHED();
        return scoped_ptr<Database::MetricVector>(NULL);
    }
    return aggregator->AggregateInterval(
        type, &metric, metrics->end(), start, kMaxTime, resolution);
  }
};

TEST_F(PerformanceMonitorUtilTest, AggregateMetricEmptyTest) {
  Database::MetricVector metric_vector;
  const base::Time data_time = base::Time::FromDoubleT(1);
  metric_vector.push_back(Metric(METRIC_CPU_USAGE, data_time, 1));

  const base::Time results_time = base::Time::FromDoubleT(3);
  const base::TimeDelta resolution = base::TimeDelta::FromSeconds(1);
  scoped_ptr<Database::MetricVector> aggregated_metric =
      AggregateSingleInterval(METRIC_CPU_USAGE,
                              &metric_vector,
                              results_time,
                              resolution,
                              AGGREGATION_METHOD_MEAN);
  ASSERT_EQ(0u, aggregated_metric->size());
  aggregated_metric = AggregateSingleInterval(METRIC_CPU_USAGE,
                                              &metric_vector,
                                              results_time,
                                              resolution,
                                              AGGREGATION_METHOD_MEDIAN);
  ASSERT_EQ(0u, aggregated_metric->size());
}

TEST_F(PerformanceMonitorUtilTest, AggregateMetricSimpleTest) {
  const base::Time data_time = base::Time::FromDoubleT(2);
  const base::Time results_time = base::Time::FromDoubleT(1);
  const base::TimeDelta results_resolution = base::TimeDelta::FromSeconds(2);

  const double value = 3.14;
  Database::MetricVector metric_vector;
  metric_vector.push_back(Metric(METRIC_CPU_USAGE, data_time, value));
  Database::MetricVector aggregated_metric =
      *AggregateSingleInterval(METRIC_CPU_USAGE,
                               &metric_vector,
                               results_time,
                               results_resolution,
                               AGGREGATION_METHOD_MEAN);

  ASSERT_EQ(1u, aggregated_metric.size());
  EXPECT_EQ(results_time + results_resolution, aggregated_metric[0].time);
  EXPECT_EQ(value, aggregated_metric[0].value);

  aggregated_metric = *AggregateSingleInterval(METRIC_CPU_USAGE,
                                               &metric_vector,
                                               results_time,
                                               results_resolution,
                                               AGGREGATION_METHOD_MEDIAN);
  ASSERT_EQ(1u, aggregated_metric.size());
  EXPECT_EQ(results_time + results_resolution, aggregated_metric[0].time);
  EXPECT_EQ(value, aggregated_metric[0].value);
}

TEST_F(PerformanceMonitorUtilTest, AggregateMetricDenseTest) {
  base::Time current_data_time = base::Time::FromDoubleT(2);
  const base::TimeDelta data_resolution = base::TimeDelta::FromSeconds(1);
  const base::Time results_time = base::Time::FromDoubleT(6);
  const base::TimeDelta results_resolution = base::TimeDelta::FromSeconds(4);
  double current_value = 1;
  int num_points = 12;
  Database::MetricVector metric_vector;

  for (int i = 0; i < num_points; ++i) {
    metric_vector.push_back(Metric(METRIC_CPU_USAGE,
                                   current_data_time,
                                   current_value));
    current_value *= 2;
    current_data_time += data_resolution;
  }
  Database::MetricVector aggregated_metric =
      *AggregateSingleInterval(METRIC_CPU_USAGE,
                               &metric_vector,
                               results_time,
                               results_resolution,
                               AGGREGATION_METHOD_MEAN);
  // The first 4 points get ignored because they are before the start time.
  // The remaining 8 points are aggregated into two data points.
  ASSERT_EQ(2u, aggregated_metric.size());
  EXPECT_EQ(results_time + results_resolution, aggregated_metric[0].time);
  EXPECT_DOUBLE_EQ((32 + 64 + 128 + 256) / 4.0, aggregated_metric[0].value);
  EXPECT_EQ(results_time + (2 * results_resolution),
            aggregated_metric[1].time);
  // Since we don't have data for the time of 14, we stretch out the 2048.
  EXPECT_DOUBLE_EQ((512 + 1024 + 2048 + 2048) / 4.0,
                   aggregated_metric[1].value);

  aggregated_metric = *AggregateSingleInterval(METRIC_CPU_USAGE,
                                               &metric_vector,
                                               results_time,
                                               results_resolution,
                                               AGGREGATION_METHOD_MEDIAN);
  ASSERT_EQ(2u, aggregated_metric.size());
  EXPECT_EQ(results_time + results_resolution, aggregated_metric[0].time);
  EXPECT_EQ(results_time + 2 * results_resolution,
            aggregated_metric[1].time);
  EXPECT_EQ(48, aggregated_metric[0].value);
  EXPECT_EQ(768, aggregated_metric[1].value);
}

TEST_F(PerformanceMonitorUtilTest, AggregateMetricSparseTest) {
  Database::MetricVector metric_vector;

  const base::Time data_time1 = base::Time::FromDoubleT(20);
  const double value1 = 3.14;
  metric_vector.push_back(Metric(METRIC_CPU_USAGE, data_time1, value1));
  const base::Time data_time2 = base::Time::FromDoubleT(40);
  const double value2 = 6.28;
  metric_vector.push_back(Metric(METRIC_CPU_USAGE, data_time2, value2));
  const base::Time data_time3 = base::Time::FromDoubleT(60);
  const double value3 = 9.42;
  metric_vector.push_back(Metric(METRIC_CPU_USAGE, data_time3, value3));

  const base::Time results_time = base::Time::FromDoubleT(19);
  const base::TimeDelta results_resolution = base::TimeDelta::FromSeconds(2);
  Database::MetricVector aggregated_metric =
      *AggregateSingleInterval(METRIC_CPU_USAGE,
                               &metric_vector,
                               results_time,
                               results_resolution,
                               AGGREGATION_METHOD_MEAN);

  // The first aggregation point is split between the first value and the second
  // value. The second is split between the second and third. The third doesn't
  // have any data after it so the aggregation is the same value.
  ASSERT_EQ(3u, aggregated_metric.size());
  EXPECT_EQ(results_time + 1 * results_resolution,
            aggregated_metric[0].time);
  EXPECT_EQ((value1 + value2) / 2, aggregated_metric[0].value);
  EXPECT_EQ(results_time + 11 * results_resolution,
            aggregated_metric[1].time);
  EXPECT_EQ((value2 + value3) / 2, aggregated_metric[1].value);
  EXPECT_EQ(results_time + 21 * results_resolution,
            aggregated_metric[2].time);
  EXPECT_EQ(value3, aggregated_metric[2].value);

  // For median values, we go from [start, end). Thus, since each of these are
  // one window apart, each value will have it's own window.
  aggregated_metric = *AggregateSingleInterval(METRIC_CPU_USAGE,
                                               &metric_vector,
                                               results_time,
                                               results_resolution,
                                               AGGREGATION_METHOD_MEDIAN);
  ASSERT_EQ(3u, aggregated_metric.size());
  EXPECT_EQ(results_time + 1 * results_resolution,
            aggregated_metric[0].time);
  EXPECT_EQ(value1, aggregated_metric[0].value);
  EXPECT_EQ(results_time + 11 * results_resolution,
            aggregated_metric[1].time);
  EXPECT_EQ(value2, aggregated_metric[1].value);
  EXPECT_EQ(results_time + 21 * results_resolution,
            aggregated_metric[2].time);
  EXPECT_EQ(value3, aggregated_metric[2].value);
}

TEST_F(PerformanceMonitorUtilTest, AggregateMetricMultipleIntervals) {
  base::Time current_data_time = base::Time::FromDoubleT(1);
  Database::MetricVector metric_vector;

  const int kNumMetrics = 20;
  for (int i = 0; i < kNumMetrics; ++i) {
    metric_vector.push_back(Metric(METRIC_CPU_USAGE,
                                   current_data_time,
                                   i + 1));
    current_data_time += base::TimeDelta::FromSeconds(1);
  }

  std::vector<TimeRange> time_ranges;
  time_ranges.push_back(TimeRange(base::Time::FromDoubleT(2),
                                  base::Time::FromDoubleT(10)));
  time_ranges.push_back(TimeRange(base::Time::FromDoubleT(12),
                                  base::Time::FromDoubleT(22)));

  std::vector<Database::MetricVector> results =
      *AggregateMetric(METRIC_CPU_USAGE,
                       &metric_vector,
                       base::Time::FromDoubleT(2),
                       time_ranges,
                       base::TimeDelta::FromSeconds(1),
                       AGGREGATION_METHOD_NONE);

  ASSERT_EQ(2u, results.size());
  Database::MetricVector metric_series = results[0];
  ASSERT_EQ(9u, metric_series.size());
  double expected = 2;
  for (Database::MetricVector::const_iterator iter = metric_series.begin();
       iter != metric_series.end(); ++iter) {
    EXPECT_EQ(expected, iter->value);
    EXPECT_EQ(base::Time::FromDoubleT(expected), iter->time);
    ++expected;
  }

  metric_series = results[1];
  ASSERT_EQ(9u, metric_series.size());
  expected = 12;
  for (Database::MetricVector::const_iterator iter = metric_series.begin();
       iter != metric_series.end(); ++iter) {
    EXPECT_EQ(expected, iter->value);
    EXPECT_EQ(base::Time::FromDoubleT(expected), iter->time);
    ++expected;
  }
}

}  // namespace performance_monitor


text:
class RemoveAccountingTables < ActiveRecord::Migration
  def self.up
    drop_table :accounts
    drop_table :account_transactions
    drop_table :journal_entries

  end

  def self.down
    # This migration is destructive, it can't be reversed
  end
end

redpajama_set_name: RedPajamaGithub


text:
<!--
  ~ Copyright 2013 Google Inc. All Rights Reserved.
  ~ 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.
  -->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.google.appengine.tck</groupId>
    <artifactId>appengine-tck</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>GAE Test Compatability Kit</name>
    <description>GAE Test Compatability Kit</description>

    <modules>
        <module>common</module>
        <module>core</module>
        <module>env</module>
        <module>ext</module>
        <module>tests</module>
        <module>utils</module>
    </modules>

    <properties>
        <!-- GAE -->
        <version.com.google.gae.api>1.9.17a</version.com.google.gae.api>
        <version.com.google.gae.plugin>1.9.17a</version.com.google.gae.plugin>

        <!-- Ext -->
        <version.metainf>1.1</version.metainf>

        <!-- CapeDwarf -->
        <version.jboss.wildfly>8.1.0.CR2</version.jboss.wildfly>
        <version.org.jboss.xnio>3.2.2.Final</version.org.jboss.xnio>

        <!-- Testing -->
        <version.javax.servlet>2.5</version.javax.servlet>
        <version.junit>4.11</version.junit>
        <version.arquillian>1.1.5.Final</version.arquillian>
        <version.arquillian.gae>1.0.0.Beta10</version.arquillian.gae>
        <version.org.jboss.arquillian.graphene2>2.0.3.Final</version.org.jboss.arquillian.graphene2>

        <!-- Byteman -->
        <version.org.jboss.byteman>2.2.0.1</version.org.jboss.byteman>
        <version.org.jboss.arquillian.byteman>1.0.0.Alpha3</version.org.jboss.arquillian.byteman>

        <!-- Utils -->
        <version.org.javassist>3.18.1-GA</version.org.javassist>
        <version.org.jboss.maven.transformer.plugin>1.0.0.Beta5</version.org.jboss.maven.transformer.plugin>

        <!--UnderTow / JSP -->
        <version.io.undertow>1.0.14.Final</version.io.undertow>
        <version.io.undertow.jastow>1.0.0.Final</version.io.undertow.jastow>
        <version.javax.servlet.3.1>3.1.0</version.javax.servlet.3.1>
        <version.javax.servlet.jsp>2.3.1</version.javax.servlet.jsp>
        <version.org.eclipse.jdt.core.compiler.ecj>4.2.2</version.org.eclipse.jdt.core.compiler.ecj>
        <version.org.glassfish.javax.el>3.0.0</version.org.glassfish.javax.el>

        <!-- TestUtils -->
        <version.org.apache.httpcomponents>4.3.1</version.org.apache.httpcomponents>
        <version.org.apache.commons.validator>1.4.0</version.org.apache.commons.validator>

        <!-- Maven -->
        <version.maven>3.1.1</version.maven>
        <version.maven.min>3.1</version.maven.min>

        <!-- Site -->
        <version.org.jetbrains.teamcity>9.0</version.org.jetbrains.teamcity>
        <version.com.google.api-client>1.17.0-rc</version.com.google.api-client>
        <version.com.google.http-client>1.17.0-rc</version.com.google.http-client>
        <version.com.google.oauth-client>1.16.0-rc</version.com.google.oauth-client>
        <version.com.appspot.cloud_test_compatibility_kit.reports>v1-1.19.0-SNAPSHOT</version.com.appspot.cloud_test_compatibility_kit.reports>
        <version.javax.inject>1</version.javax.inject>

        <!-- Ext -->

        <!-- DataNucleus -->
        <version.com.google.gae.dn>2.1.3-SNAPSHOT</version.com.google.gae.dn>
        <version.javax.jdo>3.0.1</version.javax.jdo>
        <version.javax.jpa>1.0</version.javax.jpa>
        <version.org.datanucleus>3.1.3</version.org.datanucleus>
        <version.org.log4j>1.2.16</version.org.log4j>
        <version.org.easymock>2.4</version.org.easymock>
        <!-- MapReduce -->
        <version.com.google.gae.mapreduce>0.7.1</version.com.google.gae.mapreduce>
        <version.com.google.gae.pipeline>0.2.8</version.com.google.gae.pipeline>
        <version.com.google.guava>15.0</version.com.google.guava>
        <version.fastutil>6.5.12</version.fastutil>
        <version.charts4j>1.3</version.charts4j>
        <version.commons-logging>1.1.1</version.commons-logging>
        <version.org.json>20090211</version.org.json>
        <!-- Google Cloud Storage Client -->
        <version.com.google.appengine.tools.cloudstorage>0.3.13</version.com.google.appengine.tools.cloudstorage>
        <version.com.google.api-services>v1-rev1-1.18.0-rc</version.com.google.api-services>
        <version.joda>2.3</version.joda>
        <version.com.fasterxml.jackson-core>2.1.3</version.com.fasterxml.jackson-core>
        <!-- Benchmark -->
        <version.objectify>5.0.2</version.objectify>
        <!--- Sonar -->
        <sonar.language>java</sonar.language>

        <!-- Plugins -->
        <version.compiler.plugin>3.1</version.compiler.plugin>
        <version.surefire.plugin>2.12.4</version.surefire.plugin>
        <version.release.plugin>2.4.1</version.release.plugin>
        <version.jar.plugin>2.4</version.jar.plugin>
        <version.war.plugin>2.4</version.war.plugin>
        <version.assembly.plugin>2.4</version.assembly.plugin>
        <version.dependency.plugin>2.8</version.dependency.plugin>
        <version.checkstyle.plugin>2.10</version.checkstyle.plugin>
        <version.enforcer.plugin>1.3.1</version.enforcer.plugin>
        <!-- Compiler configuration -->
        <!-- Cross plugins settings -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- maven-compiler-plugin -->
        <maven.compiler.target>1.7</maven.compiler.target>
        <maven.compiler.source>1.7</maven.compiler.source>

        <!--
            Options to override the compiler arguments directly on the compiler arument line to separate between what
            the IDE understands as the source level and what the Maven compiler actually use.
        -->
        <maven.compiler.argument.target>${maven.compiler.target}</maven.compiler.argument.target>
        <maven.compiler.argument.source>${maven.compiler.source}</maven.compiler.argument.source>

    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>${version.enforcer.plugin}</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${version.surefire.plugin}</version>
                    <dependencies>
                        <dependency>
                            <groupId>org.apache.maven.surefire</groupId>
                            <artifactId>surefire-junit47</artifactId>
                            <version>${version.surefire.plugin}</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <redirectTestOutputToFile>true</redirectTestOutputToFile>
                        <includes>
                            <include>com/google/appengine/tck/**/*Test.java</include>
                        </includes>
                    </configuration>
                </plugin>

                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>${version.assembly.plugin}</version>
                    <configuration>
                        <descriptors>
                            <descriptor>src/assemble/bin.xml</descriptor>
                        </descriptors>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>${version.war.plugin}</version>
                </plugin>

                <plugin>
                    <groupId>com.google.appengine</groupId>
                    <artifactId>appengine-maven-plugin</artifactId>
                    <version>${version.com.google.gae.plugin}</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>enforce-versions</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>${version.maven.min}</version>
                                </requireMavenVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${version.compiler.plugin}</version>
                <configuration>
                    <showDeprecation>true</showDeprecation>
                    <showWarnings>true</showWarnings>
                    <encoding>UTF8</encoding>
                    <compilerArguments>
                        <source>${maven.compiler.argument.source}</source>
                        <target>${maven.compiler.argument.target}</target>
                    </compilerArguments>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>${version.release.plugin}</version>
                <configuration>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${version.jar.plugin}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>${version.checkstyle.plugin}</version>
                <configuration>
                    <configLocation>src/main/build-config/checkstyle.xml</configLocation>
                    <consoleOutput>true</consoleOutput>
                    <failsOnError>true</failsOnError>
                    <violationSeverity>error</violationSeverity>
                    <includeTestSourceDirectory>true</includeTestSourceDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>check-style</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>checkstyle</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

    <repositories>
        <repository>
            <id>jboss-public-repository-group</id>
            <name>JBoss Public Maven Repository Group</name>
            <url>https://repository.jboss.org/nexus/content/groups/public</url>
            <layout>default</layout>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
                <updatePolicy>never</updatePolicy>
            </snapshots>
        </repository>
        <repository>
            <id>jetbrains-all</id>
            <name>JetBrains Maven Repository</name>
            <url>http://repository.jetbrains.com/all</url>
        </repository>
        <!-- repository>
            <id>jboss-staging-repository-group</id>
            <name>JBoss Staging Repository Group</name>
            <url>https://repository.jboss.org/nexus/content/groups/staging</url>
            <layout>default</layout>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
            </snapshots>
        </repository -->
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>jboss-public-repository-group</id>
            <name>JBoss Public Maven Repository Group</name>
            <url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
            <layout>default</layout>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
            </releases>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
            </snapshots>
        </pluginRepository>
        <!-- pluginRepository>
            <id>jboss-staging-repository-group</id>
            <name>JBoss Staging Repository Group</name>
            <url>https://repository.jboss.org/nexus/content/groups/staging</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository -->
    </pluginRepositories>

    <dependencyManagement>
        <!-- The parent pom manages the inter-dependencies of the modules. -->
        <dependencies>

            <!-- The TCK common -->

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-base</artifactId>
                <version>${project.version}</version>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-login</artifactId>
                <version>${project.version}</version>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-multisuite</artifactId>
                <version>${project.version}</version>
            </dependency>

            <!-- The TCK env -->

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appspot-env</artifactId>
                <version>${project.version}</version>
            </dependency>

            <dependency>
                <groupId>org.jboss.capedwarf.tck</groupId>
                <artifactId>gae-tck</artifactId>
                <version>${project.version}</version>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>sdk-env</artifactId>
                <version>${project.version}</version>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>gcloud-env</artifactId>
                <version>${project.version}</version>
            </dependency>

            <!-- The TCK tests -->
            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-appidentity</artifactId>
                <version>${project.version}</version>
                <type>test-jar</type>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-capability</artifactId>
                <version>${project.version}</version>
                <type>test-jar</type>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-channel</artifactId>
                <version>${project.version}</version>
                <type>test-jar</type>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-datastore</artifactId>
                <version>${project.version}</version>
                <type>test-jar</type>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-logservice</artifactId>
                <version>${project.version}</version>
                <type>test-jar</type>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-mail</artifactId>
                <version>${project.version}</version>
                <type>test-jar</type>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-memcache</artifactId>
                <version>${project.version}</version>
                <type>test-jar</type>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-oauth</artifactId>
                <version>${project.version}</version>
                <type>test-jar</type>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-prospectivesearch</artifactId>
                <version>${project.version}</version>
                <type>test-jar</type>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-search</artifactId>
                <version>${project.version}</version>
                <type>test-jar</type>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-sockets</artifactId>
                <version>${project.version}</version>
                <type>test-jar</type>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-taskqueue</artifactId>
                <version>${project.version}</version>
                <type>test-jar</type>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-urlfetch</artifactId>
                <version>${project.version}</version>
                <type>test-jar</type>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-users</artifactId>
                <version>${project.version}</version>
                <type>test-jar</type>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-xmpp</artifactId>
                <version>${project.version}</version>
                <type>test-jar</type>
            </dependency>

            <!-- The TCK Core -->

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>misc</artifactId>
                <version>${project.version}</version>
                <type>test-jar</type>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>sql</artifactId>
                <version>${project.version}</version>
                <type>test-jar</type>
            </dependency>

            <!-- The TCK Ext -->

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>datanucleus</artifactId>
                <version>${project.version}</version>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>mapreduce</artifactId>
                <version>${project.version}</version>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>gcs-client</artifactId>
                <version>${project.version}</version>
            </dependency>

            <!-- The TCK Utils -->

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-coverage</artifactId>
                <version>${project.version}</version>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>appengine-tck-transformers</artifactId>
                <version>${project.version}</version>
            </dependency>

            <!-- GAE API -->

            <dependency>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-api-1.0-sdk</artifactId>
                <version>${version.com.google.gae.api}</version>
            </dependency>

            <!-- GAE Tools -->

            <dependency>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-tools-sdk</artifactId>
                <version>${version.com.google.gae.api}</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-endpoints</artifactId>
                <version>${version.com.google.gae.api}</version>
            </dependency>

            <dependency>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-api-labs</artifactId>
                <version>${version.com.google.gae.api}</version>
            </dependency>

            <!-- Site -->

            <dependency>
                <groupId>org.jetbrains.teamcity</groupId>
                <artifactId>server-api</artifactId>
                <version>${version.org.jetbrains.teamcity}</version>
                <scope>provided</scope>
            </dependency>

            <dependency>
                <groupId>org.jetbrains.teamcity</groupId>
                <artifactId>tests-support</artifactId>
                <version>${version.org.jetbrains.teamcity}</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tck</groupId>
                <artifactId>teamcity-server</artifactId>
                <version>${project.version}</version>
            </dependency>

            <dependency>
                <groupId>javax.inject</groupId>
                <artifactId>javax.inject</artifactId>
                <version>${version.javax.inject}</version>
            </dependency>

            <dependency>
                <groupId>com.google.api-client</groupId>
                <artifactId>google-api-client</artifactId>
                <version>${version.com.google.api-client}</version>
            </dependency>

            <dependency>
                <groupId>com.google.http-client</groupId>
                <artifactId>google-http-client</artifactId>
                <version>${version.com.google.http-client}</version>
            </dependency>

            <dependency>
                <groupId>com.google.http-client</groupId>
                <artifactId>google-http-client-appengine</artifactId>
                <version>${version.com.google.http-client}</version>
            </dependency>

            <dependency>
                <groupId>com.google.http-client</groupId>
                <artifactId>google-http-client-jackson2</artifactId>
                <version>${version.com.google.http-client}</version>
            </dependency>

            <dependency>
                <groupId>com.google.oauth-client</groupId>
                <artifactId>google-oauth-client-java7</artifactId>
                <version>${version.com.google.oauth-client}</version>
            </dependency>

            <dependency>
                <groupId>com.appspot.cloud_test_compatibility_kit</groupId>
                <artifactId>reports</artifactId>
                <version>${version.com.appspot.cloud_test_compatibility_kit.reports}</version>
            </dependency>

            <!-- Ext -->

            <dependency>
                <groupId>org.kohsuke.metainf-services</groupId>
                <artifactId>metainf-services</artifactId>
                <version>${version.metainf}</version>
            </dependency>

            <!-- CapeDwarf -->

            <dependency>
                <groupId>org.wildfly</groupId>
                <artifactId>wildfly-arquillian-container-remote</artifactId>
                <version>${version.jboss.wildfly}</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>org.wildfly</groupId>
                <artifactId>wildfly-arquillian-container-managed</artifactId>
                <version>${version.jboss.wildfly}</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>org.jboss.xnio</groupId>
                <artifactId>xnio-nio</artifactId>
                <version>${version.org.jboss.xnio}</version>
            </dependency>

            <!-- Testing -->

            <dependency>
                <groupId>org.jboss.arquillian.graphene</groupId>
                <artifactId>graphene-webdriver</artifactId>
                <version>${version.org.jboss.arquillian.graphene2}</version>
                <type>pom</type>
            </dependency>

            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
                <version>${version.javax.servlet}</version>
            </dependency>

            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${version.junit}</version>
            </dependency>

            <dependency>
                <groupId>org.jboss.arquillian</groupId>
                <artifactId>arquillian-bom</artifactId>
                <type>pom</type>
                <scope>import</scope>
                <version>${version.arquillian}</version>
            </dependency>

            <dependency>
                <groupId>org.jboss.arquillian.protocol</groupId>
                <artifactId>arquillian-protocol-modules</artifactId>
                <version>${version.arquillian.gae}</version>
            </dependency>

            <dependency>
                <groupId>org.jboss.arquillian.container</groupId>
                <artifactId>arquillian-gae-local</artifactId>
                <version>${version.arquillian.gae}</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>org.jboss.arquillian.container</groupId>
                <artifactId>arquillian-gae-tools</artifactId>
                <version>${version.arquillian.gae}</version>
                <exclusions>
                    <exclusion>
                        <groupId>com.google.appengine</groupId>
                        <artifactId>appengine-tools-sdk</artifactId>
                    </exclusion>
                </exclusions>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>org.jboss.arquillian.container</groupId>
                <artifactId>arquillian-appscale-remote</artifactId>
                <version>${version.arquillian.gae}</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>org.jboss.arquillian.container</groupId>
                <artifactId>arquillian-gae-gcloud</artifactId>
                <version>${version.arquillian.gae}</version>
                <scope>test</scope>
            </dependency>

            <!-- Byteman -->

            <dependency>
                <groupId>org.jboss.byteman</groupId>
                <artifactId>byteman</artifactId>
                <version>${version.org.jboss.byteman}</version>
            </dependency>

            <dependency>
                <groupId>org.jboss.byteman</groupId>
                <artifactId>byteman-submit</artifactId>
                <version>${version.org.jboss.byteman}</version>
            </dependency>

            <dependency>
                <groupId>org.jboss.arquillian.extension</groupId>
                <artifactId>arquillian-extension-byteman</artifactId>
                <version>${version.org.jboss.arquillian.byteman}</version>
            </dependency>

            <!-- Utils -->

            <dependency>
                <groupId>org.javassist</groupId>
                <artifactId>javassist</artifactId>
                <version>${version.org.javassist}</version>
            </dependency>

            <dependency>
                <groupId>org.jboss.maven.plugins</groupId>
                <artifactId>maven-transformer-plugin</artifactId>
                <version>${version.org.jboss.maven.transformer.plugin}</version>
            </dependency>

            <!-- UnderTow -->

            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>${version.javax.servlet.3.1}</version>
            </dependency>

            <dependency>
                <groupId>io.undertow</groupId>
                <artifactId>undertow-core</artifactId>
                <version>${version.io.undertow}</version>
            </dependency>

            <dependency>
                <groupId>io.undertow</groupId>
                <artifactId>undertow-servlet</artifactId>
                <version>${version.io.undertow}</version>
            </dependency>

            <dependency>
                <groupId>io.undertow</groupId>
                <artifactId>undertow-core</artifactId>
                <version>${version.io.undertow}</version>
                <type>test-jar</type>
            </dependency>

            <dependency>
                <groupId>io.undertow.jastow</groupId>
                <artifactId>jastow</artifactId>
                <version>${version.io.undertow.jastow}</version>
            </dependency>

            <dependency>
                <groupId>javax.servlet.jsp</groupId>
                <artifactId>javax.servlet.jsp-api</artifactId>
                <version>${version.javax.servlet.jsp}</version>
            </dependency>

            <dependency>
                <groupId>org.eclipse.jdt.core.compiler</groupId>
                <artifactId>ecj</artifactId>
                <version>${version.org.eclipse.jdt.core.compiler.ecj}</version>
            </dependency>

            <dependency>
                <groupId>org.glassfish</groupId>
                <artifactId>javax.el</artifactId>
                <version>${version.org.glassfish.javax.el}</version>
            </dependency>

            <!-- TestUtils -->

            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>${version.org.apache.httpcomponents}</version>
            </dependency>

            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpmime</artifactId>
                <version>${version.org.apache.httpcomponents}</version>
            </dependency>

            <dependency>
                <groupId>commons-validator</groupId>
                <artifactId>commons-validator</artifactId>
                <version>${version.org.apache.commons.validator}</version>
            </dependency>

            <!-- Maven -->

            <dependency>
                <groupId>org.apache.maven</groupId>
                <artifactId>maven-plugin-api</artifactId>
                <version>${version.maven}</version>
            </dependency>

            <dependency>
                <groupId>org.apache.maven</groupId>
                <artifactId>maven-core</artifactId>
                <version>${version.maven}</version>
            </dependency>

            <!-- Ext -->

            <dependency>
                <groupId>com.google.appengine.orm</groupId>
                <artifactId>datanucleus-appengine</artifactId>
                <version>${version.com.google.gae.dn}</version>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.orm</groupId>
                <artifactId>datanucleus-appengine</artifactId>
                <version>${version.com.google.gae.dn}</version>
                <type>test-jar</type>
            </dependency>

            <dependency>
                <groupId>org.datanucleus</groupId>
                <artifactId>datanucleus-core</artifactId>
                <version>${version.org.datanucleus}</version>
            </dependency>

            <dependency>
                <groupId>org.datanucleus</groupId>
                <artifactId>datanucleus-api-jdo</artifactId>
                <version>${version.org.datanucleus}</version>
            </dependency>

            <dependency>
                <groupId>org.datanucleus</groupId>
                <artifactId>datanucleus-api-jpa</artifactId>
                <version>${version.org.datanucleus}</version>
            </dependency>

            <dependency>
                <groupId>javax.jdo</groupId>
                <artifactId>jdo-api</artifactId>
                <version>${version.javax.jdo}</version>
            </dependency>

            <dependency>
                <groupId>org.apache.geronimo.specs</groupId>
                <artifactId>geronimo-jpa_2.0_spec</artifactId>
                <version>${version.javax.jpa}</version>
            </dependency>

            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>${version.org.log4j}</version>
            </dependency>

            <dependency>
                <groupId>org.easymock</groupId>
                <artifactId>easymock</artifactId>
                <version>${version.org.easymock}</version>
            </dependency>

            <dependency>
                <groupId>org.easymock</groupId>
                <artifactId>easymockclassextension</artifactId>
                <version>${version.org.easymock}</version>
            </dependency>

            <dependency>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-api-stubs</artifactId>
                <version>${version.com.google.gae.api}</version>
            </dependency>

            <dependency>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-testing</artifactId>
                <version>${version.com.google.gae.api}</version>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tools</groupId>
                <artifactId>appengine-mapreduce</artifactId>
                <version>${version.com.google.gae.mapreduce}</version>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tools</groupId>
                <artifactId>appengine-pipeline</artifactId>
                <version>${version.com.google.gae.pipeline}</version>
            </dependency>

            <dependency>
                <groupId>it.unimi.dsi</groupId>
                <artifactId>fastutil</artifactId>
                <version>${version.fastutil}</version>
            </dependency>

            <dependency>
                <groupId>com.googlecode.charts4j</groupId>
                <artifactId>charts4j</artifactId>
                <version>${version.charts4j}</version>
            </dependency>

            <dependency>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
                <version>${version.commons-logging}</version>
            </dependency>

            <dependency>
                <groupId>org.json</groupId>
                <artifactId>json</artifactId>
                <version>${version.org.json}</version>
            </dependency>

            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>${version.com.google.guava}</version>
            </dependency>

            <dependency>
                <groupId>com.google.appengine.tools</groupId>
                <artifactId>appengine-gcs-client</artifactId>
                <version>${version.com.google.appengine.tools.cloudstorage}</version>
            </dependency>

            <dependency>
                <groupId>joda-time</groupId>
                <artifactId>joda-time</artifactId>
                <version>${version.joda}</version>
            </dependency>

            <dependency>
                <groupId>com.google.api-client</groupId>
                <artifactId>google-api-client-appengine</artifactId>
                <version>${version.com.google.api-client}</version>
            </dependency>

            <dependency>
                <groupId>com.google.apis</groupId>
                <artifactId>google-api-services-storage</artifactId>
                <version>${version.com.google.api-services}</version>
            </dependency>

            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
                <version>${version.com.fasterxml.jackson-core}</version>
            </dependency>

            <dependency>
                <groupId>com.googlecode.objectify</groupId>
                <artifactId>objectify</artifactId>
                <version>${version.objectify}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <profiles>

        <profile>
            <id>dist</id>
            <activation>
                <property>
                    <name>dist</name>
                </property>
            </activation>

            <modules>
                <module>dist</module>
            </modules>
        </profile>

        <profile>
            <id>site</id>
            <activation>
                <property>
                    <name>site</name>
                </property>
            </activation>

            <modules>
                <module>site</module>
            </modules>
        </profile>

    </profiles>

</project>


text:
'use strict';

const mocha = require('mocha');
const describe = mocha.describe;
const it = mocha.it;
const afterEach = mocha.afterEach;
const chai = require('chai');
const chaiHttp = require('chai-http');
const should = chai.should();
const server = require('../server');
const model = require('./user').model;
const val = require('joi');
const User = require('./user.model');
const apiKey = 'Bearer 58d7af7071cd95261d483498';
const headerName = 'Authorization';

chai.use(chaiHttp);

describe('Users', function() {

    // Setup
    User.collection.remove({});
    afterEach(function(done) {
        User.collection.remove();
        done();
    });

    it('should add a valid user on /api/users POST', function(done) {
        var user = {
            name: 'Sebastian',
            avatar: 'https://placehold.it/128.png'
        };
        chai.request(server).post('/api/users').set(headerName, apiKey).send(user).end(function(err, res) {
            //console.log(JSON.stringify(err)); //eslint-disable-line
            should.not.exist(err);
            res.should.have.status(200);
            res.should.be.json;
            res.body.should.be.a('object');
            res.body.should.have.property('success');
            res.body.success.should.equal(true);
            res.body.should.have.property('user');
            res.body.user.should.be.a('object');
            res.body.user.should.have.property('name');
            res.body.user.should.have.property('avatar');
            res.body.user.should.have.property('_id');
            should.not.equal(res.body.user._id, null);
            val.validate(res.body.user, model).catch(function(err) {
                should.not.exist(err);
                done();
            });
            done();
        });
    });
    it('should NOT add a user on /api/users POST with invalid user input', function(done) {
        var user = {
            name: null,
            avatar: null
        };
        chai.request(server).post('/api/users').set(headerName, apiKey).send(user).end(function(err, res) {
            res.should.have.status(400);
            res.should.be.json;
            should.exist(err);
            err.should.be.a('error');
            res.body.should.have.property('success');
            res.body.success.should.equal(false);
            res.body.should.have.property('error');
            done();
        });
    });
});


text:
<?php

namespace Vinala\Kernel\Storage;

use Vinala\Kernel\Config\Config;
use Vinala\Kernel\Storage\Exception\NotFoundStorageDiskException;
use Whoops\Exception\ErrorException;

/**
 * Storage class.
 */
class Storage
{
    public $disk;
    protected $storagePath;
    protected $basePath;

    /**
     * Main Path where storage folder in.
     *
     * @var string
     */
    protected $path = 'storage/file/';

    public function __construct($disk = null)
    {
        if (empty($disk)) {
            exception_if(!$this->checkDiskExiste(config('storage.default')), NotFoundStorageDiskException::class, config('storage.default'));

            $this->disk = config('storage.default');
        } else {
            exception_if(!$this->checkDiskExiste($disk), NotFoundStorageDiskException::class, $disk);

            $this->disk = $disk;
        }

        $this->basePath = $this->path;
        $this->storagePath = $this->basePath.'/'.$this->disk;
    }

    protected function checkDiskExiste($value)
    {
        return is_dir($this->path.$value);
    }

    protected function isDir($value)
    {
        return is_dir($this->storagePath.'/'.$value);
    }

    protected function path($value)
    {
        return $this->path.$this->disk.'/'.$value;
    }

    public static function disk($name)
    {
        $self = new self($name);

        return $self;
    }

    public static function createDisk($name)
    {
        $self = new self();
        if (!$self->checkDiskExiste($name)) {
            mkdir($self->basePath.'/'.$name, 0777, true);
        }
        $self = new self($name);

        return $self;
    }

    protected function putNonStatic($name, $content)
    {
        $myfile = fopen($this->storagePath.'/'.$name, 'w');
        fwrite($myfile, $content);
        fclose($myfile);
    }

    protected static function putStatic($name, $content)
    {
        $self = new self();
        $myfile = fopen($self->storagePath.'/'.$name, 'w');
        fwrite($myfile, $content);
        fclose($myfile);
    }

    protected function existsNonStatic($name)
    {
        return file_exists($this->storagePath.'/'.$name);
    }

    protected static function existsStatic($name, $content)
    {
        $self = new self();

        return file_exists($self->storagePath.'/'.$name);
    }

    protected function getNonStatic($name)
    {
        return file_get_contents($this->storagePath.'/'.$name);
    }

    protected static function getStatic($name)
    {
        $self = new self();

        return file_get_contents($self->storagePath.'/'.$name);
    }

    protected function prependNonStatic($name, $content)
    {
        if ($this->exists($name)) {
            $oldContent = $this->get($name);
            $this->put($name, ($content.$oldContent));
        } else {
            throw new \InvalidArgumentException("There is no file calls $name to prepend");
        }
    }

    protected static function prependStatic($name, $content)
    {
        $self = new self();
        if ($self->exists($name)) {
            $oldContent = $self->get($name);
            $self->put($name, ($content.$oldContent));
        } else {
            throw new \InvalidArgumentException("There is no file calls $name");
        }
    }

    protected function appendNonStatic($name, $content)
    {
        if ($this->exists($name)) {
            $oldContent = $this->get($name);
            $this->put($name, ($oldContent.$content));
        } else {
            throw new \InvalidArgumentException("There is no file calls $name");
        }
    }

    protected static function appendStatic($name, $content)
    {
        $self = new self();
        if ($self->exists($name)) {
            $oldContent = $self->get($name);
            $self->put($name, ($oldContent.$content));
        } else {
            throw new \InvalidArgumentException("There is no file calls $name");
        }
    }

    protected function sizeNonStatic($name)
    {
        if ($this->exists($name)) {
            return filesize($this->path($name));
        } else {
            throw new \InvalidArgumentException("There is no file calls $name");
        }
    }

    protected static function sizeStatic($name)
    {
        $self = new self();
        if ($self->exists($name)) {
            return filesize($self->path($name));
        } else {
            throw new \InvalidArgumentException("There is no file calls $name");
        }
    }

    protected function deleteNonStatic($name)
    {
        if ($this->exists($name)) {
            return unlink($this->path($name));
        } else {
            throw new \InvalidArgumentException("There is no file calls $name");
        }
    }

    protected static function deleteStatic($name)
    {
        $self = new self();
        //
        if ($self->exists($name)) {
            return unlink($self->path($name));
        } else {
            throw new \InvalidArgumentException("There is no file calls $name");
        }
    }

    protected function copyNonStatic($name1, $name2)
    {
        if ($this->exists($name)) {
            $content = $this->get($name1);

            return $this->put($name2, $content);
        } else {
            throw new \InvalidArgumentException("There is no file calls $name");
        }
    }

    protected static function copyStatic($name1, $name2)
    {
        $self = new self();
        if ($self->exists($name)) {
            $content = $self->get($name1);

            return $self->put($name2, $content);
        } else {
            throw new \InvalidArgumentException("There is no file calls $name");
        }
    }

    protected function moveNonStatic($name1, $name2)
    {
        if ($this->exists($name1)) {
            $content = $this->get($name1);
            $this->put($name2, $content);
            $this->delete($name1);
        } else {
            throw new \InvalidArgumentException("There is no file calls $name");
        }
    }

    protected static function moveStatic($name1, $name2)
    {
        $self = new self();
        if ($self->exists($name)) {
            $content = $self->get($name1);
            $self->put($name2, $content);
            $self->delete($name1);
        } else {
            throw new \InvalidArgumentException("There is no file calls $name");
        }
    }

    protected function lasteditNonStatic($name)
    {
        if ($this->exists($name)) {
            return filemtime($this->path($name));
        } else {
            throw new \InvalidArgumentException("There is no file calls $name");
        }
    }

    protected static function lasteditStatic($name)
    {
        $self = new self();
        if ($self->exists($name)) {
            return filemtime($self->path($name));
        } else {
            throw new \InvalidArgumentException("There is no file calls $name");
        }
    }

    protected function filesNonStatic($name = '')
    {
        if ($this->isDir($name)) {
            $files = [];
            $r = scandir($this->path($name));
            foreach ($r as $key => $value) {
                if (is_file($this->storagePath.'/'.$value)) {
                    $files[] = $value;
                }
            }

            return $files;
        } else {
            throw new \InvalidArgumentException("There is no directory calls $name");
        }
    }

    protected static function filesStatic($name = '')
    {
        $self = new self();
        if ($self->isDir($name)) {
            $files = [];
            $r = scandir($self->path($name));
            foreach ($r as $key => $value) {
                if (is_file($self->storagePath.'/'.$value)) {
                    $files[] = $value;
                }
            }

            return $files;
        } else {
            throw new \InvalidArgumentException("There is no directory calls $name");
        }
    }

    protected function directorysNonStatic($name = '')
    {
        if ($this->isDir($name)) {
            $files = [];
            $r = scandir($this->path($name));
            foreach ($r as $key => $value) {
                if (is_dir($this->storagePath.'/'.$value)) {
                    $files[] = $value;
                }
            }

            return $files;
        } else {
            throw new \InvalidArgumentException("There is no directory calls $name");
        }
    }

    protected static function directorysStatic($name = '')
    {
        $self = new self();
        if ($self->isDir($name)) {
            $files = [];
            $r = scandir($self->path($name));
            foreach ($r as $key => $value) {
                if (is_dir($self->storagePath.'/'.$value)) {
                    $files[] = $value;
                }
            }

            return $files;
        } else {
            throw new \InvalidArgumentException("There is no directory calls $name");
        }
    }

    protected function makeDirNonStatic($name)
    {
        if ($this->isDir($name)) {
            return mkdir($this->storagePath.'/'.$name);
        }
    }

    protected static function makeDirStatic($name = '')
    {
        $self = new self();

        return mkdir($self->storagePath.'/'.$name);
    }

    protected function deleteDirNonStatic($name = '')
    {
        if ($this->isDir($name)) {
            return rmdir($self->storagePath.'/'.$name);
        } else {
            throw new \InvalidArgumentException("There is no directory calls $name");
        }
    }

    protected static function deleteDirStatic($name = '')
    {
        $self = new self();
        if ($self->isDir($name)) {
            return rmdir($self->storagePath.'/'.$name);
        } else {
            throw new \InvalidArgumentException("There is no directory calls $name");
        }
    }

    public function __call($name, $args)
    {
        switch ($name) {
            case 'put': return call_user_func_array([$this, 'putNonStatic'], $args); break;
            case 'exists': return call_user_func_array([$this, 'existsNonStatic'], $args); break;
            case 'get': return call_user_func_array([$this, 'getNonStatic'], $args); break;
            case 'prepend': return call_user_func_array([$this, 'prependNonStatic'], $args); break;
            case 'append': return call_user_func_array([$this, 'appendNonStatic'], $args); break;
            case 'size': return call_user_func_array([$this, 'sizeNonStatic'], $args); break;
            case 'delete': return call_user_func_array([$this, 'deleteNonStatic'], $args); break;
            case 'copy': return call_user_func_array([$this, 'copyNonStatic'], $args); break;
            case 'move': return call_user_func_array([$this, 'moveNonStatic'], $args); break;
            case 'lastModified': return call_user_func_array([$this, 'lasteditNonStatic'], $args); break;
            case 'files': return call_user_func_array([$this, 'filesNonStatic'], $args); break;
            case 'directories': return call_user_func_array([$this, 'directorysNonStatic'], $args); break;
            case 'makeDirectory': return call_user_func_array([$this, 'makeDirNonStatic'], $args); break;
            case 'deleteDirectory': return call_user_func_array([$this, 'deleteDirNonStatic'], $args); break;
            default: throw new Whoops\Exception\ErrorException("Call to undefined method Storage::$name()");
        }
    }

    public static function __callStatic($name, $args)
    {
        switch ($name) {
            case 'put': return call_user_func_array(['Storage', 'putStatic'], $args); break;
            case 'exists': return call_user_func_array(['Storage', 'existsStatic'], $args); break;
            case 'get': return call_user_func_array(['Storage', 'getStatic'], $args); break;
            case 'prepend': return call_user_func_array(['Storage', 'prependStatic'], $args); break;
            case 'append': return call_user_func_array(['Storage', 'appendStatic'], $args); break;
            case 'size': return call_user_func_array(['Storage', 'sizeStatic'], $args); break;
            case 'delete': return call_user_func_array(['Storage', 'deleteStatic'], $args); break;
            case 'copy': return call_user_func_array(['Storage', 'copyStatic'], $args); break;
            case 'move': return call_user_func_array(['Storage', 'moveStatic'], $args); break;
            case 'lastModified': return call_user_func_array(['Storage', 'lasteditStatic'], $args); break;
            case 'files': return call_user_func_array(['Storage', 'filesStatic'], $args); break;
            case 'directories': return call_user_func_array(['Storage', 'directorysStatic'], $args); break;
            case 'makeDirectory': return call_user_func_array(['Storage', 'makeDirStatic'], $args); break;
            case 'deleteDirectory': return call_user_func_array(['Storage', 'deleteDirStatic'], $args); break;
            default: throw new ErrorException("Call to undefined method Storage::$name()");
        }
    }
}


text:
<?php

/**
 * CurrencyAdminController class file.
 *
 * This class is a controller for all admin features that may be used with
 * an graphical user interface.
 *
 * @author Anastaszor
 */
abstract class CurrencyAdminController extends CurrencyModuleController
{

	/**
	 * The admin-level layout
	 *
	 * @var string
	 */
	public $layout = '/admin';

	/**
	 * Context menu items. This property will be assigned to {@link CMenu::items}.
	 *
	 * @var string[]
	 */
	public $adminmenu = array();

	/**
	 * {@inheritDoc}
	 * @see CurrencyModuleController::beforeAction()
	 */
	public function beforeAction($action)
	{
		$before = parent::beforeAction($action);
		if(!$before) return false;

		$this->adminmenu = array_merge($this->adminmenu, array(
			array(
				'label' => Yii::t('CurrencyModule.CurrencyAdminController', 'Currencies'),
				'url' => array('/'.$this->module->id.'/admin/currency/index'),
				'active' => $this->id === 'admin/currency',
				'visible' => $this->checkAccessMenu(CurrencyRoleManager::OPER_CURRENCY_INDEX),
			),
			array(
				'label' => Yii::t('CurrencyModule.CurrencyAdminController', 'Rates'),
				'url' => array('/'.$this->module->id.'/admin/rate/index'),
				'active' => $this->id === 'admin/rate',
				'visible' => $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_INDEX),
			),
			array(
				'label' => Yii::t('CurrencyModule.CurrencyAdminController', 'Rates From'),
				'url' => '#',
				'active' => strpos($this->id, 'admin/rateFrom') === 0,
				'visible' => $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_FROM_CHF_INDEX)
						|| $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_FROM_EUR_INDEX)
						|| $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_FROM_GBP_INDEX)
						|| $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_FROM_JPY_INDEX)
						|| $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_FROM_USD_INDEX),
				'items' => array(
					array(
						'label' => Yii::t('CurrencyModule.CurrencyAdminController', 'Rate From CHF'),
						'url' => array('/'.$this->module->id.'/admin/rateFromChf/index'),
						'active' => $this->id === 'admin/rateFromChf',
						'visible' => $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_FROM_CHF_INDEX),
					),
					array(
						'label' => Yii::t('CurrencyModule.CurrencyAdminController', 'Rate From EUR'),
						'url' => array('/'.$this->module->id.'/admin/rateFromEur/index'),
						'active' => $this->id === 'admin/rateFromEur',
						'visible' => $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_FROM_EUR_INDEX),
					),
					array(
						'label' => Yii::t('CurrencyModule.CurrencyAdminController', 'Rate From GBP'),
						'url' => array('/'.$this->module->id.'/admin/rateFromGbp/index'),
						'active' => $this->id === 'admin/rateFromGbp',
						'visible' => $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_FROM_GBP_INDEX),
					),
					array(
						'label' => Yii::t('CurrencyModule.CurrencyAdminController', 'Rate From JPY'),
						'url' => array('/'.$this->module->id.'/admin/rateFromJpy/index'),
						'active' => $this->id === 'admin/rateFromJpy',
						'visible' => $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_FROM_JPY_INDEX),
					),
					array(
						'label' => Yii::t('CurrencyModule.CurrencyAdminController', 'Rate From USD'),
						'url' => array('/'.$this->module->id.'/admin/rateFromUsd/index'),
						'active' => $this->id === 'admin/rateFromUsd',
						'visible' => $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_FROM_USD_INDEX),
					),
				),
			),
			array(
				'label' => Yii::t('CurrencyModule.CurrencyAdminController', 'Rates To'),
				'url' => '#',
				'active' => strpos($this->id, 'admin/rateTo') === 0,
				'visible' => $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_TO_CHF_INDEX)
						|| $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_TO_EUR_INDEX)
						|| $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_TO_GBP_INDEX)
						|| $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_TO_JPY_INDEX)
						|| $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_TO_USD_INDEX),
				'items' => array(
					array(
						'label' => Yii::t('CurrencyModule.CurrencyAdminController', 'Rate To CHF'),
						'url' => array('/'.$this->module->id.'/admin/rateToChf/index'),
						'active' => $this->id === 'admin/rateToChf',
						'visible' => $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_TO_CHF_INDEX),
					),
					array(
						'label' => Yii::t('CurrencyModule.CurrencyAdminController', 'Rate To EUR'),
						'url' => array('/'.$this->module->id.'/admin/rateToEur/index'),
						'active' => $this->id === 'admin/rateToEur',
						'visible' => $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_TO_EUR_INDEX),
					),
					array(
						'label' => Yii::t('CurrencyModule.CurrencyAdminController', 'Rate To GBP'),
						'url' => array('/'.$this->module->id.'/admin/rateToGbp/index'),
						'active' => $this->id === 'admin/rateToGbp',
						'visible' => $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_TO_GBP_INDEX),
					),
					array(
						'label' => Yii::t('CurrencyModule.CurrencyAdminController', 'Rate To JPY'),
						'url' => array('/'.$this->module->id.'/admin/rateToJpy/index'),
						'active' => $this->id === 'admin/rateToJpy',
						'visible' => $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_TO_JPY_INDEX),
					),
					array(
						'label' => Yii::t('CurrencyModule.CurrencyAdminController', 'Rate To USD'),
						'url' => array('/'.$this->module->id.'/admin/rateToUsd/index'),
						'active' => $this->id === 'admin/rateToUsd',
						'visible' => $this->checkAccessMenu(CurrencyRoleManager::OPER_RATE_TO_USD_INDEX),
					),
				),
			),
		));

		return true;
	}

}


text:
Getting setup with psiturk.org
==========================================

**psiturk.org** is a cloud-based system which provides
users with information about their hits (who has accepted
the hit, where they are located, etc...) and which
provides a SSL-signed secure Ad server (ensuring that
the majority of Workers can access your task).  It is
offered as a free service to anyone who uses **psiTurk**.

.. note::

  To do anything beyond local testing a psiturk.org
  account is currently required.

Creating a psiturk.org account
----------------------------------

The first step in using psiturk.org is to sign up with
your email address.  A free account can be created at
`https://psiturk.org/register <https://psiturk.org/register>`__.

Obtaining psiturk.org API credentials
--------------------------------------

To prevent your email and password from being
passed repeatedly over the Internet when using
psiturk.org, you access the psiturk.org API services
using an API key (similar to how you interface with
`Amazon Mechanical Turk <amt_setup.html>`__). To obtain your personal API keys
login to psiturk.org (`https://psiturk.org/login <https://psiturk.org/login>`__).
On the main dashboard page, select the blue dropdown
menu on the top right hand side of the page (shows your
email address) and select "API Keys".
Copy these keys into your ``~/.psiturkconfig`` file.

.. image:: images/docs_psiturk_api_keys.png
	:align: center

At any time you can regenerate these keys on the same page by
pressing the "Regenerate API Keys" button.

.. image:: images/docs_psiturk_regen_api_keys.png
	:align: center

At that point any old keys will no longer work, and you will
need to update your ``~/.psiturkconfig`` file again.  This
way


text:
Software
########
:slug: software

.. contents::
    :backlinks: none

apt
===

I run my own APT repository with custom builds of;

- nginx (1.7.6 with pagespeed 1.9.32.1, naxsi 0.53-2)
- haproxy (1.6-dev0)

and several of my own packages;

- `vagrant-bash-completion </vagrant-bash-completion/>`__
- `go-bash-completion </go-bash-completion/>`__
- `denyhosts-unban </denyhosts-unban/>`__

A detailed guide on how to use this repository can be found
`here </apt.kura.io/>`__.

Software
========

Yarg
----

Yarg is a PyPI client, it was written for `pypip.in
<https://pypip.in>`_ and can search packages as well as read the RSS feeds
from PyPI for new packages and new package version releases.

`/yarg </yarg>`_

Blackhole
---------

Blackhole is a fake MTA (mail transfer agent) that is designed blindly accept,
bounce or reject all inbound and outbound email without actually processing or
storing any of the data. This makes it safe for handling large volumes of
email messages.

Blackhole is designed mostly for testing purposes and can be used to test numerous things suchs as;

- Email send rates, if you need to test how much mail you can send per minute, hour etc
- Email integration testing and finally
- if you work in the real world, chances are you'll need work on a copy of production
  data from time to time. You can try to anonymous all the data but there is always a chance
  you'll miss something. Configuring blackhole as your applications default SMTP gateway
  will remove any chance of a real person receiving an email they shouldn't have received.

It is available as source and as SaaS.

`https://blackhole.io <https://blackhole.io/>`__

Am I Secure
-----------

Am I Secure is a relatively simple Python script that will check *some* of your
server configuration and report on security and configuration issues.

`/amisecure </amisecure/>`__

pypipin
-------

pypipin is a SaaS that provides shields for your GitHub repository, documentation
or website powered by information directly from PyPI.

`https://pypip.in <https://pypip.in/>`__

Deiman
------

Deiman is a Python utility class for daemonizing a process. It has start and
stop methods as well as a method for retrieving a process status information.
It can also detect stale PIDs and remove them.

`/deiman </deiman/>`__

PyBozo
------

PyBozo is a Python implementation of BozoCrack for using Google to crack
unsalted MD5 passwords.

`/pybozo </pybozo/>`__

Pelican [YouTube/Vimeo]
-----------------------

Pelican YouTube and Vimeo are a set of plugins that enable you to embed videos
in to your pages and articles.

`/pelican-youtube </pelican-youtube/>`__
`/pelican-vimeo </pelican-vimeo/>`__

Pelican FontAwesome
-------------------

Pelican FontAwesome allows you to embed FontAwesome icons in your RST documents.

`/pelican-fontawesome </pelican-fontawesome>`__

Pelican GitHub Projects
-----------------------

Pelican GitHub Projects allows you to embed a list of your public GitHub
projects in your pages.

`/pelican-githubprojects </pelican-githubprojects>`_

apt-security
------------

A simple set of commands to allow you to update to the security releases
without updating your entire operating system.

`/apt-security </apt-security/>`__

rabbitmq-nagios
---------------

A set of plugins for Nagios to monitor RabbitMQ using *rabbitmqctl*.

`/rabbitmq-nagios </rabbitmq-nagios/>`__

denyhosts-unban
---------------

Tool for unbanning people from DenyHosts without having to manually edit half a
dozen files.

`/denyhosts-unban </denyhosts-unban/>`__

Bash completion
---------------

- `go-bash-completion </go-bash-completion/>`__
- `vagrant-bash-completion </vagrant-bash-completion/>`__
- `tugboat-bash-completion </tugboat-bash-completion>`__

Pelican Themes
==============

Ghastly
-------

A clean and minimal, lightweight theme for the
`Pelican <http://getpelican.com>`__ blogging platform. Ghastly is based
heavily off of Casper, the default theme for `Ghost <https://ghost.org>`__.

`/ghastly </ghastly/>`__

Hauntr
------

Hauntr is a minimal, lightweight and clean theme for the
`Pelican <http://getpelican.com>`__ blogging platform.

It is named after the Pokemon 'Haunter' because it is a modified version
(you might say evolved) of my previous theme, `Ghastly
<https://kura.io/ghastly/>`__.

`/hauntr </hauntr/>`__


text:
layout: post
title: Upcoming identity work from Google announcement
permalink: /2012/10/upcoming-identity-work-from-google/
tags: [oauth]
---

[Tim Bray](http://www.tbray.org/), a developer at Google who I [disagreed with in a previous post](http://linkey.blogs.lincoln.ac.uk/2012/07/13/how-oauth-2-0-works/) has just [posted on his blog](http://www.tbray.org/ongoing/When/201x/2012/10/11/Lets-talk) that the team he is currently working in is going to shortly be announcing some of their early work and thinkings soon.

He says problems they've identified and they want to try and solve include:

> * The username/password dance sucks and doesn't scale, particularly on mobile.
> * People putting up apps and sites regard identity — getting people signed up & signed in — purely as a tax; something they gotta do, but unrelated to what they care about.
> * Most developers don't understand identity standards like OAuth, or the related crypto and signing technologies, don't want to learn them, and shouldn't have to.
> * If you can get new arrivals signed up quicker with less work, that's a good thing.
> * If you can get people you know signed in quicker, ideally with one click, that's a good thing.
> * People are paranoid and really don't want to be in the headlines for next week's embarrassing password leak.
> * People don't want to think about privacy and tracking and transparency, but the risk of not doing so (just) exceeds the pain.
> * People like the notion of outsourcing the icky identity work, but are nervous about putting all their eggs in the Facebook's or Google's or Yahoo's or whoever's basket.
> * On the other hand, having a cluster of Sign in with... buttons on your landing page dilutes your brand and feels like watching NASCAR on TV.

I'm looking forward to seeing what they come up with.