text:
<?xml version="1.0" encoding="utf-8"?>
<!-- # Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) 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/maven-v4_0_0.xsd">

    <parent>
        <groupId>org.wso2.carbon.apimgt</groupId>
        <artifactId>apimgt</artifactId>
        <version>6.6.49-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>org.wso2.carbon.apimgt.impl</artifactId>
    <packaging>bundle</packaging>
    <name>WSO2 Carbon - API Management Implementation</name>

    <dependencies>

        <dependency>
            <groupId>org.wso2.carbon.analytics-common</groupId>
            <artifactId>org.wso2.carbon.event.output.adapter.core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.analytics-common</groupId>
            <artifactId>org.wso2.carbon.event.output.adapter.email</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>wsdl4j</groupId>
                    <artifactId>wsdl4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>wsdl4j.wso2</groupId>
                    <artifactId>wsdl4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.wso2.carbon.analytics-common</groupId>
            <artifactId>org.wso2.carbon.event.output.adapter.sms</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.woden.wso2</groupId>
            <artifactId>woden</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.user.core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.governance</groupId>
            <artifactId>org.wso2.carbon.governance.api</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>jboss</groupId>
                    <artifactId>javassist</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>wsdl4j.wso2</groupId>
                    <artifactId>wsdl4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.registry</groupId>
            <artifactId>org.wso2.carbon.registry.ws.client</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-jdk14</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.poi.wso2</groupId>
            <artifactId>poi-ooxml</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.wsdl4j</groupId>
            <artifactId>wsdl4j.wso2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.core</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>wsdl4j.wso2</groupId>
                    <artifactId>wsdl4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.apimgt</groupId>
            <artifactId>org.wso2.carbon.apimgt.api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.apimgt</groupId>
            <artifactId>org.wso2.carbon.apimgt.keymgt.client</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>wsdl4j.wso2</groupId>
                    <artifactId>wsdl4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.identity.framework</groupId>
            <artifactId>org.wso2.carbon.identity.core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
            <artifactId>org.wso2.carbon.identity.oauth</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.identity.framework</groupId>
            <artifactId>org.wso2.carbon.captcha.mgt</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.identity.governance</groupId>
            <artifactId>org.wso2.carbon.identity.recovery</artifactId>
            <version>${carbon.identity.governance.version}</version>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.governance</groupId>
            <artifactId>org.wso2.carbon.governance.registry.extensions</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>wsdl4j</groupId>
                    <artifactId>wsdl4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>wsdl4j.wso2</groupId>
                    <artifactId>wsdl4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>xalan</groupId>
                    <artifactId>xalan</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.h2database.wso2</groupId>
            <artifactId>h2-database-engine</artifactId>
            <version>1.2.140.wso2v3</version>
            <exclusions>
                <exclusion>
                    <groupId>org.eclipse.osgi</groupId>
                    <artifactId>org.eclipse.osgi</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.apimgt</groupId>
            <artifactId>org.wso2.carbon.apimgt.handlers.security.stub</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon</groupId>
            <artifactId>org.wso2.carbon.utils</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.commons</groupId>
            <artifactId>org.wso2.carbon.event.core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.registry</groupId>
            <artifactId>org.wso2.carbon.registry.indexing</artifactId>
        </dependency>
        <dependency>
            <groupId>com.googlecode.json-simple.wso2</groupId>
            <artifactId>json-simple</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.apimgt</groupId>
            <artifactId>org.wso2.carbon.apimgt.keymgt.stub</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.apimgt</groupId>
            <artifactId>org.wso2.carbon.apimgt.gateway.stub</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.identity.inbound.auth.oauth2</groupId>
            <artifactId>org.wso2.carbon.identity.oauth.stub</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.identity.framework</groupId>
            <artifactId>org.wso2.carbon.identity.application.mgt.stub</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.identity.framework</groupId>
            <artifactId>org.wso2.carbon.identity.mgt.stub</artifactId>
        </dependency>

        <dependency>
            <groupId>org.wso2.carbon.identity.user.ws</groupId>
            <artifactId>org.wso2.carbon.um.ws.api.stub</artifactId>
        </dependency>

        <dependency>
            <groupId>org.wso2.carbon.identity.framework</groupId>
            <artifactId>org.wso2.carbon.user.mgt.stub</artifactId>
        </dependency>

        <dependency>
            <groupId>org.wso2.carbon.analytics-common</groupId>
            <artifactId>org.wso2.carbon.databridge.agent</artifactId>
        </dependency>

        <dependency>
            <groupId>org.wso2.carbon.apimgt</groupId>
            <artifactId>org.wso2.carbon.apimgt.statsupdate.stub</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.governance</groupId>
            <artifactId>org.wso2.carbon.governance.custom.lifecycles.checklist</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.apimgt</groupId>
            <artifactId>org.wso2.carbon.apimgt.tier.cache.stub</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.apimgt</groupId>
            <artifactId>org.wso2.carbon.apimgt.registry.cache.stub</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.pdfbox</groupId>
            <artifactId>pdfbox</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.governance</groupId>
            <artifactId>org.wso2.carbon.governance.lcm</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.event-processing</groupId>
            <artifactId>org.wso2.carbon.event.processor.stub</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.orbit.io.swagger</groupId>
            <artifactId>swagger-codegen</artifactId>
        </dependency>
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-models</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.orbit.io.swagger</groupId>
            <artifactId>swagger-inflector</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.orbit.io.swagger</groupId>
            <artifactId>swagger-parser</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.orbit.org.openapitools</groupId>
            <artifactId>openapi-generator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.orbit.org.openapitools.swagger.parser</groupId>
            <artifactId>swagger-parser</artifactId>
        </dependency>
        <dependency>
            <groupId>xerces.wso2</groupId>
            <artifactId>xercesImpl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.identity.framework</groupId>
            <artifactId>org.wso2.carbon.identity.user.profile.stub</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.identity.framework</groupId>
            <artifactId>org.wso2.carbon.identity.user.registration.stub</artifactId>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jacoco</groupId>
            <artifactId>org.jacoco.agent</artifactId>
            <classifier>runtime</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-yaml</artifactId>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wso2.carbon.apimgt</groupId>
            <artifactId>org.wso2.carbon.apimgt.localentry.stub</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.scr.ds-annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wso2.orbit.graphQL</groupId>
            <artifactId>graphQL</artifactId>
            <version>${graphql.java.version}</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>*</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>create-test-database</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <path id="h2.classpath">
                                    <path refid="maven.compile.classpath" />
                                </path>
                                <echo message="########### Create Test Database ##############" />
                                <sql autocommit="true" driver="org.h2.Driver" onerror="continue" password="wso2carbon" url="jdbc:h2:${basedir}/target/repository/database/WSO2AM_DB" userid="wso2carbon">
                                    <classpath>
                                        <path refid="h2.classpath" />
                                    </classpath>
                                    <fileset file="${basedir}/src/test/resources/dbscripts/h2.sql" />
                                    <fileset file="${basedir}/src/test/resources/dbscripts/h2-sample-data.sql" />
                                </sql>
                                <echo message="##################### END ########################" />
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>1.8</version>
                <configuration>
                    <!--Uncomment the following in order to debug the aspectJ weaving-->
                    <!--<showWeaveInfo>true</showWeaveInfo>-->
                    <source>1.8</source>
                    <target>1.8</target>
                    <complianceLevel>1.8</complianceLevel>
                    <excludes>
                        <!--The following class have been excluded from aspectj weaving, to avoid build failures-->
                        <exclude>**/thrift/*Service.java</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemProperties>
                        <property>
                            <name>APIManagerDBConfigurationPath</name>
                            <value>${basedir}/src/test/resources/amConfig.xml</value>
                        </property>
                        <property>
                            <name>IdentityConfigurationPath</name>
                            <value>${basedir}/src/test/resources/identity.xml</value>
                        </property>
                        <property>
                            <name>axis2.repo</name>
                            <value>${basedir}/src/test/resources</value>
                        </property>
                        <property>
                            <name>carbon.config.dir.path</name>
                            <value>${basedir}/src/test/resources/repository/conf</value>
                        </property>
                        <property>
                            <name>axis2.xml</name>
                            <value>${basedir}/src/test/resources/axis2_client.xml</value>
                        </property>
                        <property>
                            <name>carbon.home</name>
                            <value>${basedir}/src/test/resources</value>
                        </property>
                    </systemProperties>
                    <classpathDependencyExcludes>
                        <classpathDependencyExclude>org.ops4j.pax.logging</classpathDependencyExclude>
                    </classpathDependencyExcludes>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-junit47</artifactId>
                        <version>${maven.surefire.plugin.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                        <Bundle-Name>${project.artifactId}</Bundle-Name>
                        <Private-Package>
                            org.wso2.carbon.apimgt.impl.internal.*
                        </Private-Package>
                        <Export-Package>
                            !org.apache.commons.codec.*,
                            !org.wso2.carbon.apimgt.impl.dto.xsd;version="${carbon.apimgt.version}",
                            org.wso2.carbon.apimgt.impl.*;version="${carbon.apimgt.version}",
                            !org.apache.commons.collections4.*
                        </Export-Package>
                        <Import-Package>
                            org.wso2.carbon.governance.api.*,
                            org.wso2.carbon.registry.ws.client.*,
                            org.apache.woden.*,
                            org.wso2.carbon.apimgt.keymgt.client.*;version="${carbon.apimgt.imp.pkg.version}",
                            org.wso2.carbon.apimgt.handlers.security.stub.*;version="${carbon.apimgt.imp.pkg.version}",
                            org.wso2.carbon.apimgt.api.*;version="${carbon.apimgt.imp.pkg.version}",
                            org.wso2.carbon.apimgt.api.model.xsd.*;version="${carbon.apimgt.imp.pkg.version}",
                            !org.wso2.carbon.apimgt.api.model.xsd.*,
                            javax.servlet;version="${javax.servlet.imp.pkg.version}",
                            javax.servlet.http;version="${javax.servlet.imp.pkg.version}",
                            javax.servlet.resources;version="${javax.servlet.imp.pkg.version}",
                            org.eclipse.equinox.http.helper,
                            com.google.gson,
                            org.apache.axis2.*; version="${imp.pkg.version.axis2}",
                            org.apache.commons.*,
                            org.apache.http.*,
                            org.osgi.framework.*;version="${imp.package.version.osgi.framework}",
                            org.osgi.util.*;version="${imp.package.version.osgi.util}",
                            org.osgi.service.*;version="${imp.package.version.osgi.service}",
                            org.apache.axiom.*; version="${imp.pkg.version.axiom}",
                            org.wso2.carbon.utils; version="${carbon.platform.package.import.version.range}",
                            org.wso2.carbon.registry.core.*; version="${carbon.registry.imp.pkg.version}",
                            org.wso2.carbon.registry.common.*,
                            org.wso2.carbon.registry.indexing.*;
                            version="${carbon.registry.package.import.version.range}",
                            org.apache.pdfbox.*; version="${pdfbox.version}",
                            org.apache.poi.*,
                            org.apache.neethi.*,
                            org.apache.velocity.*,
                            org.apache.solr.common,
                            javax.cache,
                            javax.naming,
                            javax.sql,
                            javax.wsdl.*,
                            javax.xml.*;version="0.0.0",
                            org.json.simple.*,
                            org.json.*;version="${org.json.version.range}",
                            org.slf4j,
                            org.w3c.dom,
                            com.ibm.wsdl.*; version="${wsdl4j.version.range}";resolution:=optional,
                            net.sf.saxon.*,
                            org.wso2.carbon.identity.oauth.*;version="${carbon.identity-inbound-auth-oauth.imp.pkg.version}",
                            org.wso2.carbon.identity.oauth2.*;version="${carbon.identity-inbound-auth-oauth.imp.pkg.version}",
                            org.wso2.carbon.identity.recovery.*;version="${carbon.identity.recovery.pkg.version}",
                            org.wso2.carbon.identity.*;version="${carbon.identity.imp.pkg.version}",
                            org.wso2.carbon.apimgt.keymgt.stub.*;version="${carbon.apimgt.imp.pkg.version}",
                            org.wso2.carbon.apimgt.statsupdate.stub.*;version="${carbon.apimgt.imp.pkg.version}",
                            org.wso2.carbon.apimgt.gateway.stub.*;version="${carbon.apimgt.imp.pkg.version}",
                            org.wso2.carbon.apimgt.tier.cache.stub.*;version="${carbon.apimgt.imp.pkg.version}",
                            org.wso2.carbon.apimgt.gateway.dto.stub.*;version="${carbon.apimgt.imp.pkg.version}",
                            org.wso2.carbon.apimgt.api.dto.xsd.*;version="${carbon.apimgt.imp.pkg.version}",
                            org.wso2.carbon.utils.*; version="${carbon.platform.package.import.version.range}",
                            org.wso2.carbon.authenticator.stub.*;version="${carbon.platform.package.import.version.range}",
                            org.wso2.carbon.base;version="${imp.pkg.version.org.wso2.carbon.base}",
                            org.wso2.carbon.context;version="${carbon.platform.package.import.version.range}",
                            org.wso2.carbon.core.*;version="${carbon.platform.package.import.version.range}",
                            org.wso2.carbon.user.core.*;version="${carbon.platform.package.import.version.range}",
                            org.wso2.carbon.user.api;version="${imp.pkg.version.org.wso2.carbon.user.api}",
                            org.wso2.carbon.user.mgt.stub.*;version="${carbon.identity.imp.pkg.version}",
                            org.wso2.carbon.user.mgt.*;version="${carbon.identity.imp.pkg.version}",
                            org.xml.sax,
                            org.wso2.carbon.um.ws.api.stub,
                            org.wso2.carbon.apimgt.localentry.stub.*;version="${carbon.apimgt.imp.pkg.version}",
                            org.wso2.securevault.*,
                            org.wso2.carbon.registry.*;version="${carbon.registry.imp.pkg.version}",
                            *;resolution:=optional
                        </Import-Package>
                        <DynamicImport-Package>*</DynamicImport-Package>
                    </instructions>
                </configuration>
            </plugin>

        </plugins>
    </build>
</project>


text:
<?xml version='1.0' encoding='UTF-8'?>
<description xmlns="http://openoffice.org/extensions/description/2006"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:d="http://openoffice.org/extensions/description/2006">
<identifier value="mytools.mri" />
<version value="1.3.4" />
<dependencies>
<OpenOffice.org-minimal-version value="3.4" d:name="OpenOffice.org 3.4" />
</dependencies>
<registration>
<simple-license accept-by="admin" default-license-id="this" suppress-on-update="true" suppress-if-required="true">
<license-text xlink:href="LICENSE" lang="en" license-id="this" />
</simple-license>
</registration>
<display-name>
<name lang="en">MRI - UNO Object Inspection Tool</name>
</display-name>
<icon>
<default xlink:href="icons/mri.png"/>
<high-contrast xlink:href="icons/mri_hc.png"/>
</icon>
<extension-description>
<src lang="en" xlink:href="descriptions/desc.en"/>
</extension-description>
<update-information>
<src xlink:href="https://github.com/hanya/MRI/raw/master/files/MRI.update.xml"/>
</update-information>
</description>

redpajama_set_name: RedPajamaGithub


text:
var _ = require('underscore');

function Upload(file, emitter) {
  if (!(this instanceof Upload)) return new Upload(file, emitter);
  this.emitter = emitter;
  this.file = file;
  file.slice = file.slice || file.webkitSlice;
}
module.exports = Upload;

/**
 * Upload to the given `path`.
 *
 * @param {String} path
 * @param {Function} [fn]
 * @api public
 */

Upload.prototype.to = function(path, fn){
  // TODO: x-browser
  var self = this;
  fn = fn || function(){};
  var req = this.req = new XMLHttpRequest;
  req.open('POST', path);
  req.onload = this.onload.bind(this);
  req.onerror = this.onerror.bind(this);
  req.upload.onprogress = this.onprogress.bind(this);
  req.onreadystatechange = function(){
    if (4 == req.readyState) {
      var type = req.status / 100 | 0;
      if (2 == type) return fn(null, req);
      var err = new Error(req.statusText + ': ' + req.response);
      err.status = req.status;
      fn(err);
    }
  };
  var body = new FormData;
  body.append('file', this.file);
  req.send(body);
};

/**
 * Abort the XHR.
 *
 * @api public
 */

Upload.prototype.abort = function() {
  this.emitter.trigger('abort');
  this.req.abort();
};

/**
 * Error handler.
 *
 * @api private
 */

Upload.prototype.onerror = function(e){
  this.emitter.trigger('error', e);
};

/**
 * Onload handler.
 *
 * @api private
 */

Upload.prototype.onload = function(e){
  this.emitter.trigger('end', this.req);
};

/**
 * Progress handler.
 *
 * @api private
 */

Upload.prototype.onprogress = function(e){
  e.percent = e.loaded / e.total * 100;
  this.emitter.trigger('progress', e);
};


text:
(function(){
    //ckeditor
    //jQuery('textarea').ckeditor();

    //iCheck
    $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
        checkboxClass: 'icheckbox_minimal-blue',
        radioClass: 'iradio_minimal-blue'
    });

    //select2
    $(".select2").select2();

    var editImage = $('#edit-image'),
        imageBox = $('#image_box'),
        thumbs = $('#thumbs');

    $("div#upload").dropzone({ url: "/_root/multiupload"});

    //image-edit
    imageBox.on('click', '.fa-pencil', function(){
        var id = $(this).closest('.ui-sortable-handle').find('img').attr('data-id');
        $.post('/_root/gallery/image-edit/' + id, function(data){
            $('#edit-image').html(data);
            $('input[type="checkbox"].minimal').iCheck({ checkboxClass: 'icheckbox_minimal-blue' });
        });
    });

    //image-remove
    imageBox.on('click', '.fa-trash', function(){
        var item = $(this);
        if(confirm('Вы уверены, что хотите удалить?')){
            var url = $(this).attr('data-url');
            $.post(url, function(){
                item.closest('.ui-sortable-handle').remove();
            });
        }
    });

    //image-save-change
    editImage.on('click', '#edit_image_button', function(e){
        e.preventDefault();
        var form = $(this).closest('#edit-image').find('form');
        $.ajax({
            url: form.attr('action'),
            type: "POST",
            dataType: "json",
            data: form.serialize(),
            success: function(data) {
                editImage.modal('hide');
                imageBox.html(data);
            }
        });
    });

})();


text:
<?php

return array(

	/*
	|--------------------------------------------------------------------------
	| Database Connections
	|--------------------------------------------------------------------------
	|
	| Here are each of the database connections setup for your application.
	| Of course, examples of configuring each database platform that is
	| supported by Laravel is shown below to make development simple.
	|
	|
	| All database work in Laravel is done through the PHP PDO facilities
	| so make sure you have the driver for your particular database of
	| choice installed on your machine before you begin development.
	|
	*/

	'default' => 'sqlite',

	'connections' => array(
		'sqlite' => array(
			'driver'   => 'sqlite',
			'database' => __DIR__.'/../../database/production.sqlite',
			'prefix'   => '',
		),

		'mysql' => array(
			'driver'    => 'mysql',
			'host'      => 'localhost',
			'database'  => 'homestead',
			'username'  => 'homestead',
			'password'  => 'secret',
			'charset'   => 'utf8',
			'collation' => 'utf8_unicode_ci',
			'prefix'    => '',
		),

		'pgsql' => array(
			'driver'   => 'pgsql',
			'host'     => 'localhost',
			'database' => 'homestead',
			'username' => 'homestead',
			'password' => 'secret',
			'charset'  => 'utf8',
			'prefix'   => '',
			'schema'   => 'public',
		),

	),

);


text:
require 'rails_helper'

describe "admin/commands/index.html.erb" do
  before do
    assign(:invalid_commands, [])
  end

  it "should render html output for list of commands" do
    render

    expect(response.body).to have_selector("input[class='lookup_command'][type='text'][placeholder='Enter command name or keyword']")
    expect(response.body).to have_selector("label[for='lookup_command']", :text => "Lookup Commands")
  end

  it "should show Invalid Command Snippets when loading task dropdown" do
    assign(:invalid_commands, [CommandSnippetMother.invalidSnippetWithEmptyCommand("bad0"), CommandSnippetMother.invalidSnippetWithInvalidContentInArg("bad1")])

    render

    Capybara.string(response.body).find('.invalid_snippets').tap do |invalid_snippets|
      expect(invalid_snippets).to have_selector(".warnings span", :text => "2 invalid commands found. Details")
      expect(invalid_snippets).to have_selector(".warnings span a[href='#'][class='show_snippets']", :text => "Details")
      invalid_snippets.find(".snippets.hidden").tap do |hidden|
        expect(hidden).to have_selector("h5", :text => "Invalid Commands")
        hidden.find("ul").tap do |ul|
          expect(ul).to have_selector("li span.command_name", :text => "bad0")
          expect(ul).to have_selector("li span.message", :text => "Reason: Command attribute cannot be blank in a command snippet.")
          expect(ul).to have_selector("li span.command_name", :text => "bad1")
          expect(ul).to have_selector("li span.message", :text => "Reason: Invalid content was found starting with element 'hello'. One of '{arg}' is expected.")
        end
      end
    end
  end

  it "should have markup for snippet details to be shown when a snippet is selected" do
    render

    Capybara.string(response.body).find('.snippet_details').tap do |snippet_details|
      snippet_details.find(".name").tap do |name|
        expect(name).to have_selector(".value")
      end
      snippet_details.find(".description").tap do |description|
        expect(description).to have_selector("span", :text => "Description")
        expect(description).to have_selector(".value")
      end
      snippet_details.find(".author").tap do |author|
        expect(author).to have_selector(".key", :text => "author:")
        expect(author).to have_selector(".value")
        expect(author).to have_selector(".value-with-link a[target='_blank']")
      end
      snippet_details.find(".more-info").tap do |more_info|
        expect(more_info).to have_selector(".value-with-link a[target='_blank']", :text => "more info")
      end
    end
  end

  it "should show message about old style args" do
    render

    expect(response.body).to have_selector("div.gist_based_auto_complete div.error-message-for-old-args", :text =>
        "The lookup feature is only available for the new style of custom commands.", :visible => false)
    expect(response.body).to have_selector("div.gist_based_auto_complete div.error-message-for-old-args a[href='#{docs_url '/advanced_usage/command_repository.html#args-style-commands'}']", :text =>
        "new style", :visible => false)
  end

end


text:
import { async, ComponentFixture, TestBed, fakeAsync } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
import { AssessmentDetailsPage } from './assessment-details';
import { IonicModule, NavController } from 'ionic-angular';
import { AssessmentService } from '../../services/assessment/assessment.service';
import { TestCenterData } from '../../providers/testcenter-data';
import { MockBackend } from '@angular/http/testing';
import { BaseRequestOptions, Http } from '@angular/http';

fdescribe('Page.AssessmentDetailsPage', () => {
  let component: AssessmentDetailsPage;
  let fixture: ComponentFixture<AssessmentDetailsPage>;

  beforeAll(async(() => {
    TestBed.configureTestingModule({
      declarations: [AssessmentDetailsPage],
      imports: [
        IonicModule.forRoot(AssessmentDetailsPage),
        TranslateModule.forRoot(),
        CUSTOM_ELEMENTS_SCHEMA,
      ],
      providers: [
        MockBackend, BaseRequestOptions,
        {
          provide: Http, useFactory: (mockBackend: MockBackend, options: BaseRequestOptions) => {
            return new Http(mockBackend, options);
          }, deps: [MockBackend, BaseRequestOptions],
        },
        TestCenterData, AssessmentService,
      ],
    });
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(AssessmentDetailsPage);
    component = fixture.componentInstance;
  });

  it('should create component', () => expect(component).toBeDefined());

  it('should define title for page', () => {
    const title = fixture.debugElement.query(By.css('ion-title')).nativeElement;

    expect(title).toBeDefined();
  });

});


text:
from django.db import models, migrations
from libya_elections.constants import SPLIT_CENTER_SUBCONSTITUENCY_ID

from libya_elections.constants import NO_NAMEDTHING

def create_no_namedthing_objects(apps, schema_editor):
    Office = apps.get_model("register", "Office")
    no_office, _ = Office.objects.get_or_create(
        id=NO_NAMEDTHING,
        defaults={
            'name_english': 'No Office',
            'name_arabic': 'من غير اللجنة الانتخابية',
        }
    )

    Constituency = apps.get_model("register", "Constituency")
    no_con, _ = Constituency.objects.get_or_create(
        id=NO_NAMEDTHING,
        defaults={
            'name_english': 'No Constituency',
            'name_arabic': 'من غير الدائرة الانتخابية الرئيسية',
        }
    )

    SubConstituency = apps.get_model("register", "SubConstituency")
    no_subcon, _ = SubConstituency.objects.get_or_create(
        id=NO_NAMEDTHING,
        defaults={
            'name_english': 'No Subconstituency',
            'name_arabic': 'من غير الدائرة الفرعية',
        }
    )

def no_op(apps, schema_editor):
    pass

def create_split_center_subconstituency(apps, schema_editor):
    SubConstituency = apps.get_model("register", "SubConstituency")
    SubConstituency.objects.get_or_create(
        id=SPLIT_CENTER_SUBCONSTITUENCY_ID,
        defaults={
            'name_english': 'Split Center Subconstituency',
            'name_arabic': 'مركز انقسام الفرعية',
        }
    )

class Migration(migrations.Migration):

    dependencies = [
        ('register', '0002_add_indices'),
    ]

    operations = [
        migrations.RunPython(create_split_center_subconstituency, reverse_code=no_op),
        migrations.RunPython(create_no_namedthing_objects, reverse_code=no_op),
    ]


text:
class ChromeMainDelegateChromeShellAndroid : public ChromeMainDelegateAndroid {
 public:
  ChromeMainDelegateChromeShellAndroid();
  virtual ~ChromeMainDelegateChromeShellAndroid();

  virtual bool BasicStartupComplete(int* exit_code) OVERRIDE;

 private:
  DISALLOW_COPY_AND_ASSIGN(ChromeMainDelegateChromeShellAndroid);
};

#endif  // CHROME_ANDROID_SHELL_CHROME_MAIN_DELEGATE_CHROME_SHELL_ANDROID_H_


text:
Execute
=======

The two ways to execute the notebook with parameters are: (1) through the
Python API and (2) through the command line interface.

Execute via the Python API
~~~~~~~~~~~~~~~~~~~~~~~~~~

The `execute_notebook` function can be called to execute an input notebook
when passed a dictionary of parameters:

.. code-block:: python

   execute_notebook(<input notebook>, <output notebook>, <dictionary of parameters>)

.. code-block:: python

   import papermill as pm

   pm.execute_notebook(
      'path/to/input.ipynb',
      'path/to/output.ipynb',
      parameters=dict(alpha=0.6, ratio=0.1)
   )

Execute via CLI
~~~~~~~~~~~~~~~

To execute a notebook using the CLI, enter the ``papermill`` command in the
terminal with the input notebook, location for output notebook, and options.

.. seealso::

    :doc:`CLI reference <./usage-cli>`

Execute a notebook with parameters
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Here's an example of a local notebook being executed and output to an
Amazon S3 account:

.. code-block:: bash

   $ papermill local/input.ipynb s3://bkt/output.ipynb -p alpha 0.6 -p l1_ratio 0.1

In the above example, two parameters are set: ``alpha`` and ``l1_ratio`` using ``-p`` (``--parameters`` also works).
Parameter values that look like booleans or numbers will be interpreted as such.

Here are the different ways users may set parameters:

Using raw strings as parameters
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Using ``-r`` or ``--parameters_raw``, users can set parameters one by one. However, unlike ``-p``, the parameter will
remain a string, even if it may be interpreted as a number or boolean.

.. code-block:: bash

    $ papermill local/input.ipynb s3://bkt/output.ipynb -r version 1.0

Using a parameters file
^^^^^^^^^^^^^^^^^^^^^^^

Using ``-f`` or ``--parameters_file``, users can provide a YAML file from which parameter values should be read.

.. code-block:: bash

    $ papermill local/input.ipynb s3://bkt/output.ipynb -f parameters.yaml

Using a YAML string for parameters
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Using ``-y`` or ``--parameters_yaml``, users can directly provide a YAML string containing parameter values.

.. code-block:: bash

    $ papermill local/input.ipynb s3://bkt/output.ipynb -y "
    x:
        - 0.0
        - 1.0
        - 2.0
        - 3.0
    linear_function:
        slope: 3.0
        intercept: 1.0"

Using ``-b`` or ``--parameters_base64``, users can provide a YAML string, base64-encoded, containing parameter values.

.. code-block:: bash

    $ papermill local/input.ipynb s3://bkt/output.ipynb -b YWxwaGE6IDAuNgpsMV9yYXRpbzogMC4xCg==

Note about using YAML
^^^^^^^^^^^^^^^^^^^^^

When using YAML to pass arguments, through ``-y``, ``-b`` or ``-f``, parameter values can be arrays or dictionaries:

.. code-block:: bash

    $ papermill local/input.ipynb s3://bkt/output.ipynb -y "
    x:
        - 0.0
        - 1.0
        - 2.0
        - 3.0
    linear_function:
        slope: 3.0
        intercept: 1.0"

Note about using with multiple account credentials
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If you use multiple AWS accounts and are accessing S3 files, you can
`configure your AWS credentials <https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html>`__,
to specify which account to use by setting the `AWS_PROFILE` environment
variable at the command-line. For example:

.. code-block:: bash

    $ AWS_PROFILE=dev_account papermill local/input.ipynb s3://bkt/output.ipynb -p alpha 0.6 -p l1_ratio 0.1

A similar pattern may be needed for other types of remote storage accounts.

Tracking the Execution with Cell Descriptions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If you want to keep track of the execution in a closer way, you can add cell descriptions to the notebook being executed that will be injected to the TQDM progress bar.

Here is an example of the TQDM output during the execution of a 4-cells notebook without cell descriptions:

.. code-block:: bash

    10:10 # papermill input_notebook.ipynb output_notebook.ipynb
    Input Notebook:  input_notebook.ipynb
    Output Notebook: output_notebook.ipynb
    Executing:   0%|                                                                    | 0/4 [00:00<?, ?cell/s]Executing
    Executing:  25%|█████████                                                           | 1/4 [00:00<?, ?cell/s]Executing
    [...]

You can inject cell descriptions by adding a comment with the following formatting at the very beginning of each cell you are interested in:

.. code-block:: bash

    #papermill_description=TQDM_DESCRIPTION

In this way, when the execution will reach the cell tagged with the description, the TQDM progress bar will show the string TQDM_DESCRIPTION. Please be careful: the comment must not contain any space, otherwise it will be ignored.

Taking back our previous example, if we add the description 'FirstCell' to cell 0 and the description 'SecondCell' to the cell 1 we will get the TQDM to display the following information:

.. code-block:: bash

    10:12 # papermill input_notebook.ipynb output_notebook.ipynb
    Input Notebook:  input_notebook.ipynb
    Output Notebook: output_notebook.ipynb
    Executing FirstCell:   0%|                                                          | 0/4 [00:00<?, ?cell/s]Executing
    Executing SecondCell:  25%|█████████                                                 | 1/4 [00:00<?, ?cell/s]Executing
    [...]


text: Simplifies argument parsing for PHP CLI apps


text:
//
//  XGSMarkdownElement.h
//  TextKitPlayground
//
//  Created by Julien Grimault on 13/10/13.
//  Copyright (c) 2013 XiaoGouSoftware. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "XGSMarkdownTagType.h"

/**
 This is the base class providing common data for all MarkdownTag implementation.
 Subclass can add extra property and should override `attributes` to suit their needs.
 */
@interface XGSMarkdownTag : NSObject<NSCopying>

@property (nonatomic, readonly) XGSMarkdownTagType type;

@property (nonatomic, readonly, copy) NSString *name;

//the pattern of the tag-  all the partial patterns put together
@property (nonatomic, readonly) NSString *pattern;

// array of NSString * holding the different parts of the tag
@property (nonatomic, readonly, copy) NSArray *partialPatterns;

/// the regex used to match this markdown element
@property (nonatomic, readonly, copy) NSString *regex;

// /!\ abstract property, subclass must implement this
@property (nonatomic, readonly) NSDictionary *attributes;

@end


text:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SPM.Bootstrapper
{
    static class Program
    {
        const string spmAppFolder = "SPM";
        const string spmExecutableName = "SPM.Shell";

        [LoaderOptimization(LoaderOptimization.MultiDomainHost)]
        [STAThread]
        static void Main(params string[] args)
        {
            var localAppFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

            var appDirectory = Directory.CreateDirectory(Path.Combine(localAppFolder, "SPM"));

            var cachePath = Path.Combine(appDirectory.FullName, "assemblyCache");
            var config = Path.Combine(appDirectory.FullName, "App", $"{spmExecutableName}.exe.config");
            var executable = Path.Combine(appDirectory.FullName, "App", $"{spmExecutableName}.exe");

            AppDomainSetup setup = new AppDomainSetup
            {
                ApplicationName = "SPM",
                ShadowCopyFiles = "true",
                CachePath = cachePath,
                ConfigurationFile = config
            };

            AppDomain domain = AppDomain.CreateDomain(
                "SPM",
                AppDomain.CurrentDomain.Evidence,
                setup);

            domain.ExecuteAssembly(executable, args);

            AppDomain.Unload(domain);
        }
    }
}


text:
import unittest

from quickbooks import QuickBooks
from quickbooks.objects.term import Term

class TermTests(unittest.TestCase):
    def test_unicode(self):
        term = Term()
        term.Name = "test"

        self.assertEquals(str(term), "test")

    def test_valid_object_name(self):
        obj = Term()
        client = QuickBooks()
        result = client.isvalid_object_name(obj.qbo_object_name)

        self.assertTrue(result)

    def test_to_ref(self):
        term = Term()
        term.Name = "test"
        term.Id = 100

        ref = term.to_ref()

        self.assertEquals(ref.name, "test")
        self.assertEquals(ref.type, "Term")
        self.assertEquals(ref.value, 100)


text:
@interface UIColor (BZObjectStore)
- (NSString *)stringHEXValue;
@end

#elif TARGET_OS_MAC && !TARGET_OS_IPHONE

#import <AppKit/AppKit.h>
@interface NSColor (BZObjectStore)
- (NSString *)stringHEXValue;
@end

#endif


text:
<?php
namespace ViewComponents\ViewComponents\Data;

trait DataAggregateTrait
{
    private $data;

    /**
     * Sets custom data.
     *
     * @param $data
     * @return $this
     */
    public function setData($data)
    {
        $this->data = $data;
        return $this;
    }

    /**
     * Returns data.
     *
     * @return mixed
     */
    public function getData()
    {
        return $this->data;
    }
}


text:
package jp.wizcorp.phonegap.plugin.wizViewManager;

import android.view.ViewGroup;
import android.webkit.WebResourceResponse;
import android.widget.LinearLayout;
import org.apache.cordova.*;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;
import android.view.View;
import android.webkit.WebView;

import java.io.ByteArrayInputStream;

public class WizViewManagerPlugin extends CordovaPlugin {

    // The following files can be open natively by the WebView
    public static String[] whitelist = {
        ".txt", ".md",
        ".php", ".java", ".html", ".htm", ".xml", ".css", ".js",
        ".jpg", ".png", ".jpeg", ".gif", ".tif", "."
    };
    // The following files can be opened with the helper prefix in a WebView;
    // http://docs.google.com/a/wizcorp.jp/gview?embedded=true&url=
    public static String[] helperList = {
        ".docx", ".doc",
        ".xls", ".xlsx",
        ".ppt", ".pptx",
        ".pdf", ".pages",
        ".ai", ".psd",
        ".h", ".m", ".c", ".cc", ".cpp",
        ".webm", ".mpeg4", ".3gpp", ".mov", ".avi", ".mpegps", ".wmv", ".flv"
    };
    private String TAG = "WizViewManagerPlugin";

    static JSONObject viewList = new JSONObject();
    static CordovaInterface _cordova;
    static CordovaWebView _webView;

    @Override
    public void initialize(CordovaInterface cordova, final CordovaWebView webView) {
        _cordova = cordova;
        _webView = webView;
        Log.d(TAG, "Initialize Plugin");
        // By default, get a pointer to mainView and add mainView to the viewList as it always exists (hold phonegap's view)
        if (!viewList.has("mainView")) {
            // Cordova view is not in the viewList so add it.
            try {
                viewList.put("mainView", webView);
                // To avoid "method was called on thread 'JavaBridge'" error we use a runnable
                webView.post(new Runnable() {
                    @Override
                    public void run() {
                        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
                            // Only for Kitkat and newer versions
                            webView.evaluateJavascript("window.name = 'mainView';", null);
                        } else {
                            webView.loadUrl("javascript:window.name = 'mainView';");
                        }
                    }
                });
            } catch (JSONException e) {
                // Error handle (this should never happen!)
                Log.e(TAG, "Critical error. Failed to retrieve Cordova's view");
            }
        }
        super.initialize(cordova, webView);
        webView.post(new Runnable() {
            @Override
            public void run() {
                webView.getSettings().setDomStorageEnabled(true);
                webView.getSettings().setLoadWithOverviewMode(true);
                webView.getSettings().setUseWideViewPort(true);
            }
        });
    }

    @android.annotation.TargetApi(11)
    public WebResourceResponse shouldInterceptRequest(String url) {
        ByteArrayInputStream stream = new ByteArrayInputStream(url.getBytes());
        this.onOverrideUrlLoading(url);
        return new WebResourceResponse("text/plain", "UTF-8", stream);
    }

    @Override
    public boolean onOverrideUrlLoading(String url) {

        Log.d(TAG, "[Override URL] ****** "+ url);

        String[] urlArray;
        String splitter = "://";

        // Split url by only 2 in the event "://" occurs elsewhere (SHOULD be impossible because you string encoded right!?)
        urlArray = url.split(splitter,2);

        if (urlArray[0].equalsIgnoreCase("wizpostmessage")) {

            String[] msgData;
            splitter = "\\?";

            // Split url by only 2 again to make sure we only spit at the first "?"
            msgData = urlArray[1].split(splitter);
            // target View = msgData[0] and message = msgData[1]
            // Get webview list from View Manager
            JSONObject viewList = WizViewManagerPlugin.getViews();

            if (viewList.has(msgData[1]) ) {

                WebView targetView;
                try {
                    targetView = (WebView) viewList.get(msgData[1]);

                    // send data to mainView
                    String data2send = msgData[2];

                    Log.d(TAG, "[wizMessage] targetView ****** is " + msgData[1] + " -> " + targetView + " with data -> " + data2send);
                    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
                        // Only for Kitkat and newer versions
                        webView.evaluateJavascript("wizViewMessenger.__triggerMessageEvent(\"" + msgData[0] + "\", \"" + msgData[1] + "\", \"" + data2send + "\", \"" + msgData[3] + "\");", null);
                    } else {
                        targetView.loadUrl("javascript:wizViewMessenger.__triggerMessageEvent(\"" + msgData[0] + "\", \"" + msgData[1] + "\", \"" + data2send + "\", \"" + msgData[3] + "\");");
                    }
                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            // app will handle this url, don't change the browser url
            return true;
        }

        if (urlArray[0].equalsIgnoreCase("wizmessageview") ) {

            String[] msgData;
            splitter = "\\?";

            // Split url by only 2 again to make sure we only spit at the first "?"
            msgData = urlArray[1].split(splitter);

            // target View = msgData[0] and message = msgData[1]

            // Get webview list from View Manager
            JSONObject viewList = WizViewManagerPlugin.getViews();

            if (viewList.has(msgData[0]) ) {

                WebView targetView;
                try {
                    targetView = (WebView) viewList.get(msgData[0]);

                    // send data to mainView
                    String data2send = msgData[1];
                    data2send = data2send.replace("'", "\\'");
                    Log.d(TAG, "[wizMessage] targetView ****** is " + msgData[0]+ " -> " + targetView + " with data -> "+data2send );
                    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
                        // Only for Kitkat and newer versions
                        webView.evaluateJavascript("wizMessageReceiver('"+data2send+"');", null);
                    } else {
                        targetView.loadUrl("javascript:(wizMessageReceiver('"+data2send+"'))");
                    }

                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            // app will handle this url, don't change the browser url
            return true;
        }

        return super.onOverrideUrlLoading(url);
    }

    /*
    @Override
    public void onPageFinished(WebView wView, String url) {
        WizViewManagerPlugin.updateViewList();
    }
     */
    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {

        Log.d(TAG, "[action] ****** " + action );

        if (action.equals("createView")) {
            // Create a new view
            Log.d(TAG, "[createView] ****** " + args.toString() );

            final String viewName;
            final JSONObject settings;
            try {
                // Get view name
                viewName = args.getString(0);
                settings = args.optJSONObject(1);
                Log.d(TAG, "Create view with settings : " + settings);

            } catch (Exception e) {
                Log.e(TAG, "Exception: " + e);
                callbackContext.error("Cannot create view. Missing view name parameter");
                return true;
            }

            // Create a final link so we can run on UI thread
            Log.d(TAG, "list: " + viewList.names().toString());

            // Create link to callback
            final CallbackContext create_cb = callbackContext;

            cordova.getActivity().runOnUiThread(
                    new Runnable() {
                        @Override
                        public void run() {
                            WizWebView wizWebView = new WizWebView(viewName, settings, cordova.getActivity(), create_cb);
                            // Put our new View into viewList
                            try {
                                viewList.put(viewName, wizWebView);
                                updateViewList();
                            } catch (JSONException e) {
                                // Error handle
                                e.printStackTrace();
                            }
                        }
                    }
                    );

            // Wait for callback
            PluginResult res = new PluginResult(PluginResult.Status.NO_RESULT);
            res.setKeepCallback(true);
            callbackContext.sendPluginResult(res);

            // Clean up
            callbackContext = null;

            return true;

        } else if (action.equals("removeView")) {
            // TODO: Async callback
            // Remove a view from the application
            Log.d(TAG, "[removeView] ****** " + args.toString() );

            final String viewName;
            try {
                // Get view name
                viewName = args.getString(0);
            } catch (Exception e) {
                Log.e(TAG, "Cannot remove view. Missing view name parameter");
                callbackContext.error("Cannot remove view. Missing view name parameter");
                return true;
            }

            // Find WebView by this name and remove it
            if (viewList.has(viewName) ) {
                final WizWebView targetView = (WizWebView) viewList.get(viewName);

                cordova.getActivity().runOnUiThread(
                        new Runnable() {
                            @Override
                            public void run() {
                                ViewGroup viewGroup = (ViewGroup) targetView.getParent();
                                viewGroup.removeView(targetView);
                                viewGroup = null;
                            }
                        });

                viewList.remove(viewName);
                updateViewList();

                // Remove is running on a different thread, but for now assume view was removed
                callbackContext.success();
                        return true;
            } else {
                // Cannot find view
                Log.e(TAG, "Cannot remove view. View not found");
                callbackContext.error("Cannot remove view. View not found");
                return true;
            }

        } else if (action.equals("hideView")) {
            // TODO: Async callback
            // TODO: animations like iOS

            // Hide a particular view...
            Log.d(TAG, "[hideView] ****** " + args.toString() );

            final String viewName;

            // set defaults for animations
            long animDuration = 500;
            String animType = "none";

            try {
                viewName = args.getString(0);
                // analyse settings object
                try {

                    JSONObject settings = (JSONObject) args.get(1);

                    if (settings.has("animation")) {
                        JSONObject animation = settings.getJSONObject("animation");

                        if (animation.has("duration")) {
                            animDuration = (long)animation.getInt("duration");
                        }

                        if (animation.has("type")) {
                            animType = animation.getString("type");
                        }
                    }

                } catch (Exception e) {
                    // no settings, use default

                }

                // Find WebView by this name and hide it
                if (viewList.has(viewName) ) {

                    final WebView targetView = (WebView) viewList.get(viewName);

                    final long duration = animDuration;
                    final String type = animType;

                    cordova.getActivity().runOnUiThread(
                            new Runnable() {
                                @Override
                                public void run() {
                                    /*
                                    hideCallbackId = callbackId;
                                    result = new PluginResult(Status.NO_RESULT);
                                    result.setKeepCallback(true);
                                     */

                                    // get current layout view then add our 999 buffer to bring back to view
                                    // final RelativeLayout layouter = (RelativeLayout) targetView.getParent();

                                    if (targetView.getPaddingLeft() == 0) {

                                        targetView.setVisibility(View.INVISIBLE);
                                        targetView.setPadding(999, 0, 0, 0);
                                        /*
                                        Animation animation;
                                        if (type.equals("none")) {

                                            targetView.setVisibility(View.INVISIBLE);
                                            // layouter.setPadding(layouter.getPaddingLeft()+999, 0, 0, 0);

                                        } else if (type.equals("fadeOut")) {

                                            animation = AnimationUtils.loadAnimation(cordova.getActivity(), R.anim.view_fadeout);
                                            animation.setFillAfter(true);
                                            animation.setFillEnabled(true);
                                            animation.setDuration((long) duration);
                                            animation.setAnimationListener(new AnimationListener() {

                                                public void onAnimationEnd(Animation animation) {
                                                    Log.d(TAG, "[hide - layouter.getPaddingLeft()] ****** " + layouter.getPaddingLeft());

                                                    layouter.setPadding(layouter.getPaddingLeft()+999, 0, 0, 0);
                                                    Log.d(TAG, "[hide - layouter.getPaddingLeft()] ****** " + layouter.getPaddingLeft());

                                                    targetView.setVisibility(View.INVISIBLE);
                                                    Log.d(TAG, "[hide - layouter.getPaddingLeft()] ****** " + layouter.getPaddingLeft());

                                                }

                                                public void onAnimationRepeat(Animation animation) {

                                                }

                                                public void onAnimationStart(Animation animation) {

                                                }

                                            });

                                            targetView.startAnimation(animation);

                                        } else if (type.equals("zoomOut")) {

                                            animation = AnimationUtils.loadAnimation(cordova.getActivity(), R.anim.view_zoomout);
                                            animation.setFillAfter(true);
                                            animation.setFillEnabled(true);
                                            animation.setDuration((long) duration);
                                            animation.setAnimationListener(new AnimationListener() {

                                                public void onAnimationEnd(Animation animation) {
                                                    targetView.setVisibility(View.INVISIBLE);
                                                    layouter.setPadding(layouter.getPaddingLeft()+999, 0, 0, 0);

                                                }

                                                public void onAnimationRepeat(Animation animation) {

                                                }

                                                public void onAnimationStart(Animation animation) {

                                                }

                                            });

                                            targetView.startAnimation(animation);
                                        }
                                         */

                                    } else {
                                        // already hidden, just callback
                                        Log.d(TAG, "[hide - view already invisible]");

                                    }
                                }
                            }
                            );

                    callbackContext.success();
                    return true;

                } else {
                    // Error handle
                    callbackContext.error("cannot find view");
                    return true;
                }

            } catch (JSONException e) {
                // Error handle
                callbackContext.error("missing view name parameter");
                return true;
            }

            // callbackContext.success();
            // return true;

        } else if (action.equals("showView")) {
            // TODO: Async callback
            // TODO: animations like iOS
            // Show a particular view...
            Log.d(TAG, "[showView] ****** " + args.toString() );

            String viewName;

            // Set defaults for animations
            long animDuration = 500;
            String animType = "none";

            try {
                viewName = args.getString(0);

                /*
                // Analyse settings object
                try {
                    JSONObject settings = (JSONObject) args.get(1);

                    if (settings.has("animation")) {
                        JSONObject animation = settings.getJSONObject("animation");

                        if (animation.has("duration")) {
                            animDuration = (long)animation.getInt("duration");
                        }

                        if (animation.has("type")) {
                            animType = animation.getString("type");
                        }
                    }

                } catch (Exception e) {
                    // No settings, use default
                    Log.d(TAG, "Do options set, using defaults");
                }
                 */

                // Find WebView by this name and show it
                if (viewList.has(viewName) ) {
                    Log.d(TAG, "Get WebView in view list");
                    final WebView targetView = (WebView) viewList.get(viewName);
                    Log.d(TAG, targetView.toString());
                    long duration = animDuration;

                    cordova.getActivity().runOnUiThread(
                            new Runnable() {
                                @Override
                                public void run() {
                                    if (targetView.getVisibility() == View.INVISIBLE) {

                                        // Get current layout view then minus our 999 buffer to bring back to view
                                        // final RelativeLayout layouter = (RelativeLayout) targetView.getParent();
                                        targetView.getPaddingLeft();
                                        Log.d(TAG, "[show - targetView.getPaddingLeft()] ****** " + targetView.getPaddingLeft());

                                        if (targetView.getPaddingLeft() == 999) {
                                            /*
                                            Animation animation;

                                            if (animType.equals("none")) {

                                                Log.d(TAG, "[show - layouter.getPaddingLeft()] ****** " + layouter.getPaddingLeft());

                                                layouter.setPadding(layouter.getPaddingLeft()-999, 0, 0, 0);
                                                targetView.setVisibility(View.VISIBLE);

                                                Log.d(TAG, "[show - layouter.getPaddingLeft()] ****** " + layouter.getPaddingLeft());

                                            } else if (animType.equals("fadeIn")) {

                                                animation = AnimationUtils.loadAnimation(cordova.getActivity(), R.anim.view_fadein);
                                                animation.setFillAfter(true);
                                                animation.setFillEnabled(true);
                                                animation.setDuration((long) duration);

                                                animation.setAnimationListener(new AnimationListener() {

                                                    public void onAnimationEnd(Animation animation) {

                                                    }

                                                    public void onAnimationRepeat(Animation animation) {

                                                    }

                                                    public void onAnimationStart(Animation animation) {
                                                        layouter.setPadding(layouter.getPaddingLeft()-999, 0, 0, 0);
                                                        targetView.setVisibility(View.VISIBLE);
                                                    }

                                                });

                                                targetView.startAnimation(animation);

                                            } else if (animType.equals("zoomIn")) {

                                                animation = AnimationUtils.loadAnimation(cordova.getActivity(), R.anim.view_zoomin);
                                                animation.setFillAfter(true);
                                                animation.setFillEnabled(true);
                                                animation.setDuration((long) duration);

                                                animation.setAnimationListener(new AnimationListener() {

                                                    public void onAnimationEnd(Animation animation) {

                                                    }

                                                    public void onAnimationRepeat(Animation animation) {

                                                    }

                                                    public void onAnimationStart(Animation animation) {
                                                        layouter.setPadding(layouter.getPaddingLeft()-999, 0, 0, 0);
                                                        targetView.setVisibility(View.VISIBLE);
                                                    }

                                                });

                                                targetView.startAnimation(animation);

                                            }
                                             */
                                            // callbackContext.success();
                                            // return true;
                                            // No animations
                                            targetView.setVisibility(View.VISIBLE);
                                            targetView.setPadding(0, 0, 0, 0);
                                            Log.d(TAG, "[show - targetView.getPaddingLeft()] ****** " + targetView.getPaddingLeft());
                                        } else {
                                            // already shown, just callback
                                            Log.d(TAG, "[show - view already visible]");

                                        }
                                    }
                                }
                            }
                            );

                    callbackContext.success();
                    return true;

                } else {
                    // Error handle
                    Log.e(TAG, "Cannot show. Cannot find view");
                    callbackContext.error("Cannot show. Cannot find view");
                    return true;
                }

            } catch (JSONException e) {
                // Error handle
                Log.e(TAG, "Cannot show. Missing view name parameter");
                callbackContext.error("Cannot show. Missing view name parameter");
                return true;
            }

        } else if (action.equals("setLayout")) {

            try {
                String viewName = args.getString(0);
                final JSONObject options = args.getJSONObject(1);

                if (viewName.equals("mainView")) {
                    final CordovaWebView targetView = (CordovaWebView) viewList.get(viewName);

                    cordova.getActivity().runOnUiThread(
                            new Runnable() {
                                @Override
                                public void run() {
                                    WizViewManagerPlugin.setLayout(targetView, options);
                                }
                            }
                            );
                } else {
                    final WizWebView targetView = (WizWebView) viewList.get(viewName);

                    cordova.getActivity().runOnUiThread(
                            new Runnable() {
                                @Override
                                public void run() {
                                    targetView.setLayout(options, null);
                                }
                            }
                            );
                }

            } catch (Exception e) {
                Log.e(TAG, "Error: " + e);
            }

            callbackContext.success();

            return true;

        } else if (action.equals("load")) {
            Log.d(TAG, "[load] ****** ");

            String viewName;
            try {
                viewName = args.getString(0);
            } catch (JSONException e) {
                Log.e(TAG, "Cannot load into view. Missing view name parameter");
                callbackContext.error("Cannot load into view. Missing view name parameter");
                return true;
            }

            // Find WebView by this name and show it
            if (viewList.has(viewName) ) {
                final WizWebView targetView = (WizWebView) viewList.get(viewName);
                JSONObject options = args.getJSONObject(1);

                if (options.has("src")) {
                    final String url = options.getString("src");
                    Log.d(TAG, "[load] url>> " + url);
                    final CallbackContext load_cb = callbackContext;
                    cordova.getActivity().runOnUiThread(
                            new Runnable() {
                                public void run() {
                                    targetView.load(url, load_cb);
                                }
                            }
                            );
                } else {
                    Log.e(TAG, "Cannot load into view. No source to load.");
                    callbackContext.error("Cannot load into view.  No source to load.");
                    return true;
                }

                // Wait for callback
                PluginResult res = new PluginResult(PluginResult.Status.NO_RESULT);
                res.setKeepCallback(true);
                callbackContext.sendPluginResult(res);

                // Clean up
                callbackContext = null;
                return true;

            } else {
                Log.e(TAG, "Cannot update view. Missing view name parameter");
                callbackContext.error("Cannot update view. Missing view name parameter");
                return true;
            }
        }
        return false;
    }

    public static JSONObject getViews() {
        return viewList;
    }

    public static void updateViewList() {
        CordovaWebView targetView = null;
        String jsString = "";
        try {
            // Build JS execution String form all view names in viewList
            targetView = (CordovaWebView) viewList.get("mainView");
            JSONArray viewListNameArray = viewList.names();
            jsString += "window.wizViewManager.updateViewList(" + viewListNameArray.toString() + "); ";
            Log.d("wizViewManager", "Execute JS: " + jsString);
            Log.d("wizViewManager", "Updated view list");
        } catch (JSONException ex) {
            return;
        }
        final CordovaWebView _targetView = targetView;
        final String _jsString = jsString;

        _cordova.getActivity().runOnUiThread(
                new Runnable() {
                    public void run() {
                        if (_targetView != null) {
                            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
                                // Only for Kitkat and newer versions
                                _targetView.evaluateJavascript(_jsString, null);
                            } else {
                                _targetView.loadUrl("javascript:" + _jsString);
                            }
                        }
                    }
                }
                );

        // Clean up references
        targetView = null;
        jsString = null;
    }

    public static void setLayout(CordovaWebView webView, JSONObject settings) {

        Log.d("WizViewManager", "Setting up mainView layout...");
        Log.d("WizViewManager", webView.toString());

        String url;
        // Size
        int _height = webView.getHeight();
        int _width = webView.getWidth();
        // Margins
        int _x = 0;
        int _y = 0;
        int _top = 0;
        int _bottom = 0;

        int _right = 0;
        int _left = 0;

        if (settings.has("height")) {
            try {
                _height = settings.getInt("height");
            } catch (JSONException e) {
                // default
                _height = ViewGroup.LayoutParams.MATCH_PARENT;
            }
        }

        if (settings.has("width")) {
            try {
                _width = settings.getInt("width");
            } catch (JSONException e) {
                // default
                _width = ViewGroup.LayoutParams.MATCH_PARENT;
            }
        }

        if (settings.has("x")) {
            try {
                _x = settings.getInt("x");
            } catch (JSONException e) {
                // default
                _x = 0;
            }
        }

        if (settings.has("y")) {
            try {
                _y = settings.getInt("y");
            } catch (JSONException e) {
                // default
                _y = 0;
            }
        }

        if (settings.has("left")) {
            try {
                _left = _x + settings.getInt("left");
                _width -= _left;
            } catch (JSONException e) {
                // default
                _left = _x;
            }
        }

        if (settings.has("right")) {
            try {
                _right = settings.getInt("right");
                _width += _right;
            } catch (JSONException e) {
                // default
                _right = 0;
            }
        }

        if (settings.has("top")) {
            try {
                _top = _y + settings.getInt("top");
            } catch (JSONException e) {
                // default
                _top = _y;
            }
        }
        if (settings.has("bottom")) {
            try {
                _bottom = settings.getInt("bottom") - _y;
            } catch (JSONException e) {
                // default
                _bottom = 0 - _y;
            }
        }
        /*
        ViewGroup.MarginLayoutParams marginParams = (ViewGroup.MarginLayoutParams) webView.getLayoutParams();
        Log.d("WizViewManager", marginParams.toString());
        marginParams.setMargins(_left, _top, _right, _bottom);

        webView.setLayoutParams(marginParams);
         */
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) webView.getLayoutParams();
        Log.d("WizViewManager", layoutParams.toString());
        layoutParams.setMargins(_left, _top, _right, _bottom);
        layoutParams.height = _height;
        layoutParams.width = _width;

        webView.setLayoutParams(layoutParams);

        Log.d("WizViewManager", "new layout -> width: " + layoutParams.width + " - height: " + layoutParams.height + " - margins: " + layoutParams.leftMargin + "," + layoutParams.topMargin + "," + layoutParams.rightMargin + "," + layoutParams.bottomMargin);
    }
}


text:
class Allegiance < ActiveRecord::Base
    has_many :systems, inverse_of: :allegiance
    has_many :stations, inverse_of: :allegiance

    validates :name, presence: true, uniqueness: true
end


text:
<?php
/**
 * This is the configuration for generating message translations
 * for the Yii framework. It is used by the 'yiic message' command.
 */
return array(
	'sourcePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'messagePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'messages',
	'languages'=>array('fi','zh_cn','zh_tw','ca','de','el','es','sv','he','nl','pt','pt_br','ru','it','fr','ja','pl','hu','ro','id','vi','bg','lv','sk','uk','ko_kr','kk','cs'),
	'fileTypes'=>array('php'),
	'overwrite'=>true,
	'exclude'=>array(
		'.svn',
		'.gitignore',
		'yiilite.php',
		'yiit.php',
		'/i18n/data',
		'/messages',
		'/vendors',
		'/web/js',
	),
);


text:
const globals = {};
globals.amphtmlRegex = new RegExp('(^\\s*)amphtml(\\s*$)');
globals.ampCaches = [
  {
    'getAmpHref': function() {
      if (window.location.pathname.startsWith('/a/s') ||
          window.location.pathname.startsWith('/c/s') ||
          window.location.pathname.startsWith('/v/s')) {
        return 'https://' + window.location.pathname.slice(5);
      } else if (window.location.pathname.startsWith('/c')) {
        return 'http://' + window.location.pathname.slice(3);
      } else {
        return '';
      }
    },
    'isAmpCache': function() {
      return window.location.hostname.endsWith('cdn.ampproject.org'); // lgtm [js/incomplete-url-substring-sanitization]
    },
  },
];

/**
 * Returns the AMP page href from an AMP Cache. Otherwise returns empty string.
 *
 * @return {string}
 * @private
 */
function getAmpCacheHref() {
  for (const index in globals.ampCaches) {
    const ampCache = globals.ampCaches[index];
    if (ampCache.isAmpCache()) {
      return ampCache.getAmpHref();
    }
  }
  return '';
}

/**
 * Determine if <link rel="amphtml" href="..."> exists in the page and
 * return the href's value if it does. Otherwise returns empty string.
 *
 * @return {string}
 * @private
 */
function getAmpHtmlLinkHref() {
  let ampHtmlLinkHref = '';
  const headLinks = document.head.getElementsByTagName('link');
  if (headLinks.length > 0) {
    for (const index in headLinks) {
      const link = headLinks[index];
      if (link instanceof HTMLLinkElement &&
          link.hasAttribute('rel') &&
          globals.amphtmlRegex.test(link.getAttribute('rel')) &&
          link.hasAttribute('href')) {
        ampHtmlLinkHref = link.getAttribute('href');
        break;
      }
    }
  }
  return ampHtmlLinkHref;
}

/**
 * Determine if the page is from an AMP Cache.
 *
 * @return {boolean}
 * @private
 */
function isAmpCache() {
  for (const index in globals.ampCaches) {
    const ampCache = globals.ampCaches[index];
    if (ampCache.isAmpCache()) {
      return true;
    }
  }
  return false;
}

/**
 * Determine if the page is an AMP page.
 *
 * @return {boolean}
 * @private
 */
function isAmpDocument() {
  return (document.documentElement.hasAttribute('amp') ||
      document.documentElement.hasAttribute('⚡'));
}

/**
 * Listener for requests from the extension.
 *
 * Requests for getAmpDetails. Return to the extension:
 * - isAmp: Is the page marked as an AMP page.
 * - fromAmpCache: Is the page from an AMP Cache.
 * - ampHref: the href to an AMP page if the page is not an AMP page but there
 *   is an <link rel="amphtml"> or if the page is from an AMP Cache.
 * - userAgent: Tab's current userAgent, which may have been modified by
 *   device emulation.
 *
 * Requests for loadAmp and has ampHref, then redirects the browser to ampHref.
 */
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
  if (request.getAmpDetails) {
    const isAmp = isAmpDocument();
    const fromAmpCache = isAmpCache();
    let ampHref = '';
    if (!isAmp) {ampHref = getAmpHtmlLinkHref();}
    if (fromAmpCache) {ampHref = getAmpCacheHref();}
    sendResponse({
      'isAmp': isAmp, 'fromAmpCache': fromAmpCache, 'ampHref': ampHref,
      'userAgent': navigator.userAgent,
    });
  }
  if (request.loadAmp && request.ampHref) {
    window.location = request.ampHref;
  }
});


text:
sample-groups
=============

Application folder structure
----------------------------
-- artifacts/<iaas>/ IaaS specific artifacts
-- scripts/common/ Common scripts for all iaases
-- scripts/<iaas> IaaS specific scripts

How to run
----------
cd scripts/<iaas>/
./deploy.sh


text: Brain dump notes from various meetups attended in the Portland metro area