text:
<?xml version="1.0" encoding="UTF-8"?>
<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>tech.redroma.google</groupId>
    <artifactId>google-places-api</artifactId>
    <version>1.1-SNAPSHOT</version>
    <name>GooglePlacesAPI</name>
    <packaging>jar</packaging>

    <url>https://github.com/RedRoma/GooglePlacesJavaClient</url>
    <description>
        A simple Java Client for interfacing with the Google Places API.
    </description>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <organization>
        <name>RedRoma, Inc.</name>
        <url>http://RedRoma.tech/</url>
    </organization>

    <developers>
        <developer>
            <name>Wellington Moreno</name>
            <email>wellington@redroma.tech</email>
            <id>SirWellington</id>
            <organizationUrl>https://github.com/RedRoma</organizationUrl>
            <roles>
                <role>owner</role>
                <role>developer</role>
            </roles>
        </developer>
    </developers>

    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <issueManagement>
        <system>GitHub Issues</system>
        <url>https://github.com/RedRoma/YelpJavaClient/issues</url>
    </issueManagement>

    <scm>
        <connection>scm:git:git@github.com:RedRoma/GooglePlacesJavaClient.git</connection>
        <developerConnection>scm:git:git@github.com:RedRoma/GooglePlacesJavaClient.git</developerConnection>
        <url>git@github.com:RedRoma/GooglePlacesJavaClient.git</url>
    </scm>

    <inceptionYear>2016</inceptionYear>

    <prerequisites>
        <maven>3.0.3</maven>
    </prerequisites>

    <!--REPOSITORIES-->
    <distributionManagement>

        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>

        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>

    </distributionManagement>

    <repositories>

        <repository>
            <id>ossrh-snapshot</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </repository>

    </repositories>

    <!-- END OF POM METADATA -->

    <dependencies>

        <!--=======================-->
        <!--UNIT TESTING-->
        <!--=======================-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>2.23.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>

        <!--=======================-->
        <!--ALCHEMY-->
        <!--=======================-->
        <dependency>
            <groupId>tech.sirwellington.alchemy</groupId>
            <artifactId>alchemy-annotations</artifactId>
            <version>2.1.3</version>
        </dependency>

        <dependency>
            <groupId>tech.sirwellington.alchemy</groupId>
            <artifactId>alchemy-arguments</artifactId>
            <version>2.2.3</version>
        </dependency>

        <dependency>
            <groupId>tech.sirwellington.alchemy</groupId>
            <artifactId>alchemy-collections</artifactId>
            <version>2.0</version>
        </dependency>

        <dependency>
            <groupId>tech.sirwellington.alchemy</groupId>
            <artifactId>alchemy-generator</artifactId>
            <version>2.3.7</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>tech.sirwellington.alchemy</groupId>
            <artifactId>alchemy-http</artifactId>
            <version>3.2</version>
        </dependency>

        <dependency>
            <groupId>tech.sirwellington.alchemy</groupId>
            <artifactId>alchemy-http-mock</artifactId>
            <version>3.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>tech.sirwellington.alchemy</groupId>
            <artifactId>alchemy-test</artifactId>
            <version>2.5</version>
            <scope>test</scope>
        </dependency>

        <!--=======================-->
        <!--LOGGING-->
        <!--=======================-->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.25</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.25</version>
            <scope>test</scope>
        </dependency>

        <!--Disables Logging during unit testing-->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-nop</artifactId>
            <version>1.7.25</version>
            <scope>test</scope>
        </dependency>

        <!--=======================-->
        <!--GUAVA-->
        <!--=======================-->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>24.1.1-jre</version>
        </dependency>

        <!--=======================-->
        <!--GSON-->
        <!--=======================-->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.5</version>
        </dependency>

        <!--=======================-->
        <!--GUICE-->
        <!--=======================-->
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>4.2.2</version>
        </dependency>

    </dependencies>

    <build>

        <plugins>

            <!--Download Javadoc Stylesheet-->
            <plugin>
                <groupId>com.googlecode.maven-download-plugin</groupId>
                <artifactId>download-maven-plugin</artifactId>
                <version>1.3.0</version>
                <executions>
                    <execution>
                        <id>download-javadoc-stylesheet</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>wget</goal>
                        </goals>
                        <configuration>
                            <url>https://raw.githubusercontent.com/SirWellington/alchemy/master/javadoc-style-sheet.css</url>
                            <outputDirectory>${project.build.directory}/resources/css</outputDirectory>
                            <failOnError>false</failOnError>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!--Javadoc-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <failOnError>false</failOnError>
                    <linksource>true</linksource>
                    <links>
                        <link>http://docs.oracle.com/javase/8/docs/api/</link>
                    </links>
                    <stylesheetfile>${project.build.directory}/resources/css/javadoc-style-sheet.css</stylesheetfile>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--Sources-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--Code Coverage-->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.2</version>
                <configuration>
                    <excludes>
                        <!--Exclude Exceptions-->
                        <exclude>**/*Exception.*</exclude>
                    </excludes>
                </configuration>

                <executions>
                    <execution>
                        <id>default-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>

                    <execution>
                        <id>default-report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>

                    <execution>
                        <id>default-check</id>
                        <goals>
                            <goal>check</goal>
                        </goals>

                        <configuration>
                            <rules>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>

            <build>
                <plugins>

                    <!--Code Signing-->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <configuration>
                            <gpgArguments>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <!--Release Plugin-->
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.8</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>

                </plugins>
            </build>

        </profile>
    </profiles>
</project>

redpajama_set_name: RedPajamaGithub


text:
package com.disbrain.dbmslayer.exceptions;

import com.disbrain.dbmslayer.descriptors.QueryGenericArgument;

public abstract class DbmsException extends RuntimeException {

    protected StackTraceElement trace[] = Thread.currentThread().getStackTrace();
    protected Exception error = null;
    protected String extraInfo = "";
    protected String real_message = null;
    private QueryGenericArgument original_request;
    private int code = -1;

    protected DbmsException() {

    }

    protected DbmsException(Exception ex) {
        trace = Thread.currentThread().getStackTrace();
        error = ex;
    }

    protected DbmsException(Exception ex, String extra_msg) {
        error = ex;
        extraInfo = extra_msg;
    }

    protected DbmsException(String extra_msg) {
        extraInfo = extra_msg;
    }

    protected String getVerboseMessage() {
        if (error != null)
            extraInfo += String.format("\nClass: %s\nCause: %s\nMessage: %s\nStack Trace:\n", error.getClass(), error.getCause(), error.getMessage());
        for (StackTraceElement element : trace)
            extraInfo += element.toString() + "\n";
        return extraInfo;
    }

    public DbmsException setOriginalRequest(QueryGenericArgument request) {
        original_request = request;
        return this;
    }

    public QueryGenericArgument getOriginalRequest() {
        return original_request;
    }

    public String getRealMessage() {
        if (error != null)
            real_message = error.getMessage();
        return real_message;
    }

    public int getErrorCode() {
        return code;
    }
}


text:
<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>Document</title>

div2


text:
/**
 *
 * @author Rinde van Lon
 */
@javax.annotation.ParametersAreNonnullByDefault
package com.github.rinde.vanlon15prima;


text:
clear;
model = Off2Patch('m60.off');
value = max(model.vertices);
max_x = value(1);
max_y = value(2);
max_z = value(3);
value = min(model.vertices);
min_x = value(1);
min_y = value(2);
min_z = value(3);
center_x = (max_x + min_x)/2;
center_y = (max_y + min_y)/2;
center_z = (max_z + min_z)/2;
coeff = 1.5;
radius = sqrt(((max_x - min_x)/2)^2 + ((max_y - min_y)/2)^2 + ((max_z - min_z)/2)^2);
[vertices, faces] = platonic_solid(4, radius*coeff);
vertices(:, 1) = vertices(:, 1) + center_x;
vertices(:, 2) = vertices(:, 2) + center_y;
vertices(:, 3) = vertices(:, 3) + center_z;
tempVertices = vertices';
tempFaces = faces'
[tempVertices, tempFaces] = loopSubdivision(tempVertices, tempFaces);
%[tempVertices, tempFaces] = loopSubdivision(tempVertices, tempFaces);

tempVertices = tempVertices';
tempFaces = tempFaces';
tempFaces = tempFaces + 1606;
graph = patch('faces',[model.faces; tempFaces], 'vertices',[model.vertices; tempVertices]);
%graph = patch('faces',model.faces, 'vertices',model.vertices);

set(graph,'FaceAlpha',0);

%view(tempVertices(1, :));


text:
const DrawCard = require('../../drawcard.js');

class TheScorpionsSting extends DrawCard {
    setupCardAbilities() {
        this.reaction({
            when: {
                afterChallenge: ({challenge}) => (
                    challenge.loser === this.controller &&
                    this.controller.getNumberOfUsedPlots() >= 1 &&
                    this.hasMartellCharacter())
            },
            handler: () => {
                this.game.promptForSelect(this.controller, {
                    numCards: this.controller.getNumberOfUsedPlots(),
                    multiSelect: true,
                    activePromptTitle: 'Select up to ' + this.controller.getNumberOfUsedPlots() + ' characters',
                    source: this,
                    cardCondition: card => card.isFaction('martell') && card.getType() === 'character',
                    onSelect: (player, cards) => this.targetsSelected(player, cards)
                });
            }
        });
    }

    targetsSelected(player, cards) {
        this.untilEndOfPhase(ability => ({
            match: card => cards.includes(card),
            effect: ability.effects.addKeyword('renown')
        }));

        this.game.addMessage('{0} plays {1} to give {2} renown until the end of the phase',
            player, this, cards);

        return true;
    }

    hasMartellCharacter() {
        return this.controller.anyCardsInPlay(card => card.isFaction('martell') && card.getType() === 'character');
    }
}

TheScorpionsSting.code = '04056';

module.exports = TheScorpionsSting;


text:
package org.eclipse.jetty.server;

import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;

import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;

import javax.servlet.AsyncContext;
import javax.servlet.ServletException;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.toolchain.test.http.SimpleHttpResponse;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

//TODO: reset buffer tests
//TODO: add protocol specific tests for connection: close and/or chunking
@RunWith(value = Parameterized.class)
public class HttpManyWaysToAsyncCommitTest extends AbstractHttpTest
{
    private final String CONTEXT_ATTRIBUTE = getClass().getName() + ".asyncContext";
    private boolean dispatch; // if true we dispatch, otherwise we complete

    @Parameterized.Parameters
    public static Collection<Object[]> data()
    {
        Object[][] data = new Object[][]
            {
            {HttpVersion.HTTP_1_0.asString(), true},
            {HttpVersion.HTTP_1_1.asString(), true},
            {HttpVersion.HTTP_1_0.asString(), false},
            {HttpVersion.HTTP_1_1.asString(), false}
            };
        return Arrays.asList(data);
    }

    public HttpManyWaysToAsyncCommitTest(String httpVersion, boolean dispatch)
    {
        super(httpVersion);
        this.httpVersion = httpVersion;
        this.dispatch = dispatch;
    }

    @Test
    public void testHandlerDoesNotSetHandled() throws Exception
    {
        DoesNotSetHandledHandler handler = new DoesNotSetHandledHandler(false);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        assertThat("response code is 404", response.getCode(), is("404"));
        assertThat("no exceptions", handler.failure(), is(nullValue()));
    }

    @Test
    public void testHandlerDoesNotSetHandledAndThrow() throws Exception
    {
        DoesNotSetHandledHandler handler = new DoesNotSetHandledHandler(true);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        assertThat("response code is 500", response.getCode(), is("500"));
        assertThat("no exceptions", handler.failure(), is(nullValue()));
    }

    private class DoesNotSetHandledHandler extends ThrowExceptionOnDemandHandler
    {
        private DoesNotSetHandledHandler(boolean throwException)
        {
            super(throwException);
        }

        @Override
        public void handle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
        {
            if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
            {
                final AsyncContext asyncContext = baseRequest.startAsync();
                request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
                new Thread(new Runnable()
                {
                    @Override
                    public void run()
                    {
                        if (dispatch)
                            asyncContext.dispatch();
                        else
                            asyncContext.complete();
                    }
                }).run();
            }
            super.handle(target, baseRequest, request, response);
        }
    }

    @Test
    public void testHandlerSetsHandledTrueOnly() throws Exception
    {
        OnlySetHandledHandler handler = new OnlySetHandledHandler(false);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        assertThat("response code is 200", response.getCode(), is("200"));
        assertHeader(response, "content-length", "0");
        assertThat("no exceptions", handler.failure(), is(nullValue()));
    }

    @Test
    public void testHandlerSetsHandledTrueOnlyAndThrow() throws Exception
    {
        OnlySetHandledHandler handler = new OnlySetHandledHandler(true);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        assertThat("response code is 500", response.getCode(), is("500"));
        assertThat("no exceptions", handler.failure(), is(nullValue()));
    }

    private class OnlySetHandledHandler extends ThrowExceptionOnDemandHandler
    {
        private OnlySetHandledHandler(boolean throwException)
        {
            super(throwException);
        }

        @Override
        public void handle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
        {
            if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
            {
                final AsyncContext asyncContext = baseRequest.startAsync();
                request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
                new Thread(new Runnable()
                {
                    @Override
                    public void run()
                    {
                        if (dispatch)
                            asyncContext.dispatch();
                        else
                            asyncContext.complete();
                    }
                }).run();
            }
            baseRequest.setHandled(true);
            super.handle(target, baseRequest, request, response);
        }
    }

    @Test
    public void testHandlerSetsHandledAndWritesSomeContent() throws Exception
    {
        SetHandledWriteSomeDataHandler handler = new SetHandledWriteSomeDataHandler(false);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        assertThat("response code is 200", response.getCode(), is("200"));
        assertHeader(response, "content-length", "6");
        assertThat("no exceptions", handler.failure(), is(nullValue()));
    }

    @Test
    public void testHandlerSetsHandledAndWritesSomeContentAndThrow() throws Exception
    {
        SetHandledWriteSomeDataHandler handler = new SetHandledWriteSomeDataHandler(true);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        assertThat("response code is 500", response.getCode(), is("500"));
        assertThat("no exceptions", handler.failure(), is(nullValue()));
    }

    private class SetHandledWriteSomeDataHandler extends ThrowExceptionOnDemandHandler
    {
        private SetHandledWriteSomeDataHandler(boolean throwException)
        {
            super(throwException);
        }

        @Override
        public void handle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
        {
            if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
            {
                final AsyncContext asyncContext = baseRequest.startAsync();
                request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
                new Thread(new Runnable()
                {
                    @Override
                    public void run()
                    {
                        try
                        {
                            asyncContext.getResponse().getWriter().write("foobar");
                            if (dispatch)
                                asyncContext.dispatch();
                            else
                                asyncContext.complete();
                        }
                        catch (IOException e)
                        {
                            markFailed(e);
                        }
                    }
                }).run();
            }
            baseRequest.setHandled(true);
            super.handle(target, baseRequest, request, response);
        }
    }

    @Test
    public void testHandlerExplicitFlush() throws Exception
    {
        ExplicitFlushHandler handler = new ExplicitFlushHandler(false);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        assertThat("response code is 200", response.getCode(), is("200"));
        assertThat("no exceptions", handler.failure(), is(nullValue()));
        if (!"HTTP/1.0".equals(httpVersion))
            assertHeader(response, "transfer-encoding", "chunked");
    }

    @Test
    public void testHandlerExplicitFlushAndThrow() throws Exception
    {
        ExplicitFlushHandler handler = new ExplicitFlushHandler(true);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        assertThat("response code is 200", response.getCode(), is("200"));
        assertThat("no exceptions", handler.failure(), is(nullValue()));
        if (!"HTTP/1.0".equals(httpVersion))
            assertHeader(response, "transfer-encoding", "chunked");
    }

    private class ExplicitFlushHandler extends ThrowExceptionOnDemandHandler
    {
        private ExplicitFlushHandler(boolean throwException)
        {
            super(throwException);
        }

        @Override
        public void handle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
        {
            if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
            {
                final AsyncContext asyncContext = baseRequest.startAsync();
                request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
                new Thread(new Runnable()
                {
                    @Override
                    public void run()
                    {
                        try
                        {
                            ServletResponse asyncContextResponse = asyncContext.getResponse();
                            asyncContextResponse.getWriter().write("foobar");
                            asyncContextResponse.flushBuffer();
                            if (dispatch)
                                asyncContext.dispatch();
                            else
                                asyncContext.complete();
                        }
                        catch (IOException e)
                        {
                            markFailed(e);
                        }
                    }
                }).run();
            }
            baseRequest.setHandled(true);
            super.handle(target, baseRequest, request, response);
        }
    }

    @Test
    public void testHandledAndFlushWithoutContent() throws Exception
    {
        SetHandledAndFlushWithoutContentHandler handler = new SetHandledAndFlushWithoutContentHandler(false);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        assertThat("response code is 200", response.getCode(), is("200"));
        assertThat("no exceptions", handler.failure(), is(nullValue()));
        if (!"HTTP/1.0".equals(httpVersion))
            assertHeader(response, "transfer-encoding", "chunked");
    }

    @Test
    public void testHandledAndFlushWithoutContentAndThrow() throws Exception
    {
        SetHandledAndFlushWithoutContentHandler handler = new SetHandledAndFlushWithoutContentHandler(true);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        assertThat("response code is 200", response.getCode(), is("200"));
        assertThat("no exceptions", handler.failure(), is(nullValue()));
        if (!"HTTP/1.0".equals(httpVersion))
            assertHeader(response, "transfer-encoding", "chunked");
    }

    private class SetHandledAndFlushWithoutContentHandler extends ThrowExceptionOnDemandHandler
    {
        private SetHandledAndFlushWithoutContentHandler(boolean throwException)
        {
            super(throwException);
        }

        @Override
        public void handle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
        {
            if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
            {
                final AsyncContext asyncContext = baseRequest.startAsync();
                request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
                new Thread(new Runnable()
                {
                    @Override
                    public void run()
                    {
                        try
                        {
                            asyncContext.getResponse().flushBuffer();
                            if (dispatch)
                                asyncContext.dispatch();
                            else
                                asyncContext.complete();
                        }
                        catch (IOException e)
                        {
                            markFailed(e);
                        }
                    }
                }).run();
            }
            baseRequest.setHandled(true);
            super.handle(target, baseRequest, request, response);
        }
    }

    @Test
    public void testWriteFlushWriteMore() throws Exception
    {
        WriteFlushWriteMoreHandler handler = new WriteFlushWriteMoreHandler(false);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        assertThat("response code is 200", response.getCode(), is("200"));
        assertThat("no exceptions", handler.failure(), is(nullValue()));
        if (!"HTTP/1.0".equals(httpVersion))
            assertHeader(response, "transfer-encoding", "chunked"); // HTTP/1.0 does not do chunked.  it will just send content and close
    }

    @Test
    public void testWriteFlushWriteMoreAndThrow() throws Exception
    {
        WriteFlushWriteMoreHandler handler = new WriteFlushWriteMoreHandler(true);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        assertThat("response code is 200", response.getCode(), is("200"));
        assertThat("no exceptions", handler.failure(), is(nullValue()));
        if (!"HTTP/1.0".equals(httpVersion))
            assertHeader(response, "transfer-encoding", "chunked");
    }

    private class WriteFlushWriteMoreHandler extends ThrowExceptionOnDemandHandler
    {
        private WriteFlushWriteMoreHandler(boolean throwException)
        {
            super(throwException);
        }

        @Override
        public void handle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
        {
            if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
            {
                final AsyncContext asyncContext = baseRequest.startAsync();
                request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
                new Thread(new Runnable()
                {
                    @Override
                    public void run()
                    {
                        try
                        {
                            ServletResponse asyncContextResponse = asyncContext.getResponse();
                            asyncContextResponse.getWriter().write("foo");
                            asyncContextResponse.flushBuffer();
                            asyncContextResponse.getWriter().write("bar");
                            if (dispatch)
                                asyncContext.dispatch();
                            else
                                asyncContext.complete();
                        }
                        catch (IOException e)
                        {
                            markFailed(e);
                        }
                    }
                }).run();
            }
            baseRequest.setHandled(true);
            super.handle(target, baseRequest, request, response);
        }
    }

    @Test
    public void testBufferOverflow() throws Exception
    {
        OverflowHandler handler = new OverflowHandler(false);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        assertThat("response code is 200", response.getCode(), is("200"));
        assertResponseBody(response, "foobar");
        if (!"HTTP/1.0".equals(httpVersion))
            assertHeader(response, "transfer-encoding", "chunked");
        assertThat("no exceptions", handler.failure(), is(nullValue()));
    }

    @Test
    public void testBufferOverflowAndThrow() throws Exception
    {
        OverflowHandler handler = new OverflowHandler(true);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        // Buffer size is too small, so the content is written directly producing a 200 response
        assertThat("response code is 200", response.getCode(), is("200"));
        assertResponseBody(response, "foobar");
        if (!"HTTP/1.0".equals(httpVersion))
            assertHeader(response, "transfer-encoding", "chunked");
        assertThat("no exceptions", handler.failure(), is(nullValue()));
    }

    private class OverflowHandler extends ThrowExceptionOnDemandHandler
    {
        private OverflowHandler(boolean throwException)
        {
            super(throwException);
        }

        @Override
        public void handle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
        {
            if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
            {
                final AsyncContext asyncContext = baseRequest.startAsync();
                request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
                new Thread(new Runnable()
                {
                    @Override
                    public void run()
                    {
                        try
                        {
                            ServletResponse asyncContextResponse = asyncContext.getResponse();
                            asyncContextResponse.setBufferSize(3);
                            asyncContextResponse.getWriter().write("foobar");
                            if (dispatch)
                                asyncContext.dispatch();
                            else
                                asyncContext.complete();
                        }
                        catch (IOException e)
                        {
                            markFailed(e);
                        }
                    }
                }).run();
            }
            baseRequest.setHandled(true);
            super.handle(target, baseRequest, request, response);
        }
    }

    @Test
    public void testSetContentLengthAndWriteExactlyThatAmountOfBytes() throws Exception
    {
        SetContentLengthAndWriteThatAmountOfBytesHandler handler = new SetContentLengthAndWriteThatAmountOfBytesHandler(false);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        assertThat("response code is 200", response.getCode(), is("200"));
        assertThat("response body is foo", response.getBody(), is("foo"));
        assertHeader(response, "content-length", "3");
        assertThat("no exceptions", handler.failure(), is(nullValue()));
    }

    @Test
    public void testSetContentLengthAndWriteExactlyThatAmountOfBytesAndThrow() throws Exception
    {
        SetContentLengthAndWriteThatAmountOfBytesHandler handler = new SetContentLengthAndWriteThatAmountOfBytesHandler(true);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        //TODO: should we expect 500 here?
        assertThat("response code is 200", response.getCode(), is("200"));
        assertThat("response body is foo", response.getBody(), is("foo"));
        assertHeader(response, "content-length", "3");
        assertThat("no exceptions", handler.failure(), is(nullValue()));
    }

    private class SetContentLengthAndWriteThatAmountOfBytesHandler extends ThrowExceptionOnDemandHandler
    {
        private SetContentLengthAndWriteThatAmountOfBytesHandler(boolean throwException)
        {
            super(throwException);
        }

        @Override
        public void handle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
        {
            if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
            {
                final AsyncContext asyncContext = baseRequest.startAsync();
                request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
                new Thread(new Runnable()
                {
                    @Override
                    public void run()
                    {
                        try
                        {
                            ServletResponse asyncContextResponse = asyncContext.getResponse();
                            asyncContextResponse.setContentLength(3);
                            asyncContextResponse.getWriter().write("foo");
                            if (dispatch)
                                asyncContext.dispatch();
                            else
                                asyncContext.complete();
                        }
                        catch (IOException e)
                        {
                            markFailed(e);
                        }
                    }
                }).run();
            }
            baseRequest.setHandled(true);
            super.handle(target, baseRequest, request, response);
        }
    }

    @Test
    public void testSetContentLengthAndWriteMoreBytes() throws Exception
    {
        SetContentLengthAndWriteMoreBytesHandler handler = new SetContentLengthAndWriteMoreBytesHandler(false);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        assertThat("response code is 200", response.getCode(), is("200"));
        // jetty truncates the body when content-length is reached.! This is correct and desired behaviour?
        assertThat("response body is foo", response.getBody(), is("foo"));
        assertHeader(response, "content-length", "3");
        assertThat("no exceptions", handler.failure(), is(nullValue()));
    }

    @Test
    public void testSetContentLengthAndWriteMoreAndThrow() throws Exception
    {
        SetContentLengthAndWriteMoreBytesHandler handler = new SetContentLengthAndWriteMoreBytesHandler(true);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        // TODO: we throw before response is committed. should we expect 500?
        assertThat("response code is 200", response.getCode(), is("200"));
        assertThat("response body is foo", response.getBody(), is("foo"));
        assertHeader(response, "content-length", "3");
        assertThat("no exceptions", handler.failure(), is(nullValue()));
    }

    private class SetContentLengthAndWriteMoreBytesHandler extends ThrowExceptionOnDemandHandler
    {
        private SetContentLengthAndWriteMoreBytesHandler(boolean throwException)
        {
            super(throwException);
        }

        @Override
        public void handle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
        {
            if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
            {
                final AsyncContext asyncContext = baseRequest.startAsync();
                request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
                new Thread(new Runnable()
                {
                    @Override
                    public void run()
                    {
                        try
                        {
                            ServletResponse asyncContextResponse = asyncContext.getResponse();
                            asyncContextResponse.setContentLength(3);
                            asyncContextResponse.getWriter().write("foobar");
                            if (dispatch)
                                asyncContext.dispatch();
                            else
                                asyncContext.complete();
                        }
                        catch (IOException e)
                        {
                            markFailed(e);
                        }
                    }
                }).run();
            }
            baseRequest.setHandled(true);
            super.handle(target, baseRequest, request, response);
        }
    }

    @Test
    public void testWriteAndSetContentLength() throws Exception
    {
        WriteAndSetContentLengthHandler handler = new WriteAndSetContentLengthHandler(false);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        assertThat("response code is 200", response.getCode(), is("200"));
        assertThat("no exceptions", handler.failure(), is(nullValue()));
        //TODO: jetty ignores setContentLength and sends transfer-encoding header. Correct?
    }

    @Test
    public void testWriteAndSetContentLengthAndThrow() throws Exception
    {
        WriteAndSetContentLengthHandler handler = new WriteAndSetContentLengthHandler(true);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        assertThat("response code is 200", response.getCode(), is("200"));
        assertThat("no exceptions", handler.failure(), is(nullValue()));
    }

    private class WriteAndSetContentLengthHandler extends ThrowExceptionOnDemandHandler
    {
        private WriteAndSetContentLengthHandler(boolean throwException)
        {
            super(throwException);
        }

        @Override
        public void handle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
        {
            if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
            {
                final AsyncContext asyncContext = baseRequest.startAsync();
                request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
                new Thread(new Runnable()
                {
                    @Override
                    public void run()
                    {
                        try
                        {
                            ServletResponse asyncContextResponse = asyncContext.getResponse();
                            asyncContextResponse.getWriter().write("foo");
                            asyncContextResponse.setContentLength(3); // This should commit the response
                            if (dispatch)
                                asyncContext.dispatch();
                            else
                                asyncContext.complete();
                        }
                        catch (IOException e)
                        {
                            markFailed(e);
                        }
                    }
                }).run();
            }
            baseRequest.setHandled(true);
            super.handle(target, baseRequest, request, response);
        }
    }

    @Test
    public void testWriteAndSetContentLengthTooSmall() throws Exception
    {
        WriteAndSetContentLengthTooSmallHandler handler = new WriteAndSetContentLengthTooSmallHandler(false);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        // Setting a content-length too small throws an IllegalStateException
        assertThat("response code is 500", response.getCode(), is("500"));
        assertThat("no exceptions", handler.failure(), is(nullValue()));
    }

    @Test
    public void testWriteAndSetContentLengthTooSmallAndThrow() throws Exception
    {
        WriteAndSetContentLengthTooSmallHandler handler = new WriteAndSetContentLengthTooSmallHandler(true);
        server.setHandler(handler);
        server.start();

        SimpleHttpResponse response = executeRequest();

        // Setting a content-length too small throws an IllegalStateException
        assertThat(response.getCode(), is("500"));
        assertThat("no exceptions", handler.failure(), is(nullValue()));
    }

    private class WriteAndSetContentLengthTooSmallHandler extends ThrowExceptionOnDemandHandler
    {
        private WriteAndSetContentLengthTooSmallHandler(boolean throwException)
        {
            super(throwException);
        }

        @Override
        public void handle(String target, Request baseRequest, final HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
        {
            if (request.getAttribute(CONTEXT_ATTRIBUTE) == null)
            {
                final AsyncContext asyncContext = baseRequest.startAsync();
                request.setAttribute(CONTEXT_ATTRIBUTE, asyncContext);
                new Thread(new Runnable()
                {
                    @Override
                    public void run()
                    {
                        try
                        {
                            ServletResponse asyncContextResponse = asyncContext.getResponse();
                            asyncContextResponse.getWriter().write("foobar");
                            asyncContextResponse.setContentLength(3);
                            if (dispatch)
                                asyncContext.dispatch();
                            else
                                asyncContext.complete();
                        }
                        catch (IOException e)
                        {
                            markFailed(e);
                        }
                    }
                }).run();
            }
            baseRequest.setHandled(true);
            super.handle(target, baseRequest, request, response);
        }
    }
}


text:
"use strict";
bcdui.component.cube.rankingEditor = Object.assign(bcdui.component.cube.rankingEditor,
/** @lends bcdui.component.cube.rankingEditor */
{
  /**
   * @private
   */
  _rankingUrl: bcdui.config.jsLibPath+"component/cube/rankingEditor/rendering.xslt",

  /**
   * @private
   */
  _renderRankingArea: function(args) {
    return (args.isRanking ? "

" +
        "
" +
          "

" +
        "
" : "");
  },

  /**
   * @private
   */
  _initRanking: function(args, targetModelId) {}
});


text:
#include <casper/kernel.h>
#include <casper/cp/int.h>
#include <casper/util/options.h>

#include <iostream>

using namespace Casper;
using namespace Casper::CP;
using namespace std;

void golomb(uint n,uint m,uint g, bool minimize, const Util::ExampleOptions& opt)
{
	// define the Solver object
	Solver solver;

	// create an array for storing n marks, each one with the domain [0,m]
    IntVarArray	marks(solver,n,0,m);

	IntRef	i1(solver,0);
	IntRef	i2(solver,0);
	if (g == 0)
		solver.post(distinct(all(Casper::pair(i2,i1),range(0,n-1),i1>i2,
									cache(marks[i1]-marks[i2],(int)1,(int)m))),postValFilter);
	else
	if (g == 1)
		solver.post(distinct(all(Casper::pair(i2,i1),range(0,n-1),i1>i2,
									cache(marks[i1]-marks[i2],(int)1,(int)m))),postBndFilter);
	else
	if (g == 2)
		solver.post(distinct(all(Casper::pair(i2,i1),range(0,n-1),i1>i2,
									cache(marks[i1]-marks[i2],(int)1,(int)m))),postDomFilter);

	// break some symmetries
    for (uint i = 0; i < n-1; i++)
    	solver.post(marks[i] < marks[i+1]);

    marks[0].domain() = 0;

	// setup branch and bound
	if (minimize)
		solver.setExplorer(bbMinimize(solver,marks[n-1]));
	else
		marks[n-1].domain() = m;

	// search
	uint nbSolutions = 0;
	bool found = solver.solve(label(solver,marks,selectVarLex(solver,marks)));

	while (found)
	{
		// show values for marks
		cout << marks << endl;

		if (!minimize and ++nbSolutions == opt.nbSolutions())
			break;

		found = solver.next();
	}

    // show statistics
	if (opt.showStats())
		cout << solver.getStats() << endl;
	if (opt.showRuntime())
		cout << solver.getCPUTimer() << endl;
}

int main(int argc, char** argv)
{
	uint n = 10,l = 1000,dcons = 1;
	bool minimize = true;

	Util::ExampleOptions opt("Golomb Ruler");
	opt.addPosParam("n",&n,"number of marks");
	opt.addPosParam("l",&l,"maximum length");
	opt.addOptParam("minimize,m",&minimize,"try to minimize l");
	opt.addOptParam("distinct",&dcons,
			"consistency for distinct constraint (0=Val,1=Bnd,2=Dom)");

	if (!opt.parse(argc,argv))
		return 1;

	golomb(n,l,dcons,minimize,opt);

	return 0;
}


text:
package de.darwinspl.feature.graphical.editor.commands.version;

import org.eclipse.gef.commands.Command;
import org.eclipse.jface.dialogs.MessageDialog;

import de.darwinspl.feature.graphical.base.editor.DwGraphicalFeatureModelViewer;
import eu.hyvar.feature.HyVersion;

public class DwVersionDeleteCommand extends Command {
	private HyVersion version;

	private DwGraphicalFeatureModelViewer editor;
	private HyVersion parentVersion;

	public DwVersionDeleteCommand(HyVersion version, DwGraphicalFeatureModelViewer editor)  {
		this.editor = editor;
		this.parentVersion = version;
	}

	public HyVersion getVersion() {
		return version;
	}
	public void setVersion(HyVersion version) {
		this.version = version;
	}

	private void removeAllChildren(HyVersion parent){

		for(HyVersion child : parent.getSupersedingVersions()){

			child.getFeature().getVersions().remove(child);

			removeAllChildren(child);
		}

		parent.getSupersedingVersions().clear();
	}

	@Override
	public void execute(){
		boolean hasChildren = version.getSupersedingVersions().size() > 0;
		MessageDialog dialog = null;
		if(version.getSupersedingVersions().size() > 0){
			dialog = new MessageDialog(null, "What do you want to do?", null,
					"The version you want to delete has children. You have the following options:\n"
							+ "Delete Children:\tThis will delete the selected version with all its children\n"
							+ "Keep Children:\tDelete the selected version all its children will be added to the parent version of the selected version.\n\n"
							+ "Deleting will remove the version(s) in all variants of the FM.", MessageDialog.QUESTION, new String[] { "Delete Children",
									"Keep Children", "Cancel" }, 0);
		}else{
			dialog = new MessageDialog(null, "What do you want to do?", null,
					"Deleting will permantly remove the version(s) in all variants of the FM. Do you really want to delete it?", MessageDialog.QUESTION, new String[] {
							"Permanently Delete Version", "Cancel" }, 0);
		}

		int result = dialog.open();
		if(result != -1){
			if(hasChildren){
				if(result == 0){
					removeAllChildren(version);
					version.getFeature().getVersions().remove(version);
					version.getSupersededVersion().getSupersedingVersions().remove(version);
				}else if(result == 1){

					HyVersion parent = version.getSupersededVersion();

					version.getFeature().getVersions().remove(version);
					version.getSupersededVersion().getSupersedingVersions().remove(version);
					for(HyVersion child : version.getSupersedingVersions()){
						int count = parent.getSupersedingVersions().size();
						for(HyVersion parentChilds : parent.getSupersedingVersions()){
							if(parentChilds.getNumber().equals(child.getNumber())){
								child.setNumber("C"+count);
							}
						}
						parent.getSupersedingVersions().add(child);
						child.setSupersededVersion(parent);
					}

				}
			}else{
				if(result == 0){
					version.getFeature().getVersions().remove(version);
				}
			}
		}
	}

	@Override
	public boolean canExecute() {
		return editor.isLastDateSelected();
	}
}


text:
<?xml version="1.0" encoding="utf-8"?>

<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="cl.monsoon.s1next.view.adapter.delegate.FavouriteAdapterDelegate">

    <data>

        <variable
            name="favouriteViewModel"
            type="cl.monsoon.s1next.viewmodel.FavouriteViewModel" />

    </data>

    <!-- May change this TextView padding or height after because we
    can't find any spec in the material design guidelines whose line count
    is not sure (less than 4) and each line are all primary.
    We set top/bottom padding to 14.5dp because `includeFontPadding`
    doesn't remove all extra space. -->
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/selectableItemBackground"
        android:clickable="true"
        android:ellipsize="end"
        android:gravity="center_vertical"
        android:includeFontPadding="false"
        android:lineSpacingMultiplier="@dimen/line_spacing_multiplier"
        android:maxLines="@integer/list_max_line"
        android:paddingBottom="14.5dp"
        android:paddingEnd="@dimen/item_padding"
        android:paddingLeft="@dimen/item_padding"
        android:paddingRight="@dimen/item_padding"
        android:paddingStart="@dimen/item_padding"
        android:paddingTop="14.5dp"
        android:text="@{favouriteViewModel.favourite.title}"
        android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
        app:onClickListener="@{favouriteViewModel.goToThisFavourite()}" />

</layout>


text:
package com.wookler.server.common.config;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Annotation to be used to define configuration mapping for auto-wired
 * configuration elements.
 * Created by subho on 16/11/15.
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD })
public @interface CParam {
	/**
	 * Get the configuration element name. By default it maps to defined
	 * parameters. For mapping to attributes prefix the name with @.
	 *
	 * @return - Mapping element name.
	 */
	String name();

	/**
	 * Is this element required, will raise an exception if element is not found
	 * in the configuration. By default all elements are assumed to be required
	 * unless specified.
	 *
	 * @return - Is mandatory?
	 */
	boolean required() default true;

	/**
	 * This field refers to a nested configuration definitions?
	 *
	 * @return - Is nested?
	 */
	boolean nested() default false;
}


text:
GPU-Accelerated Computer Vision (cuda module) {#tutorial_table_of_content_gpu}
=============================================

Squeeze out every little computation power from your system by using the power of your video card to
run the OpenCV algorithms.

-   @subpage tutorial_gpu_basics_similarity

    *Compatibility:* \> OpenCV 2.0

    *Author:* Bernát Gábor

    This will give a good grasp on how to approach coding on the GPU module, once you already know
    how to handle the other modules. As a test case it will port the similarity methods from the
    tutorial @ref tutorial_video_input_psnr_ssim to the GPU.


text:
package com.hctrom.romcontrol.diagnostic;

/**
 * Created by Palleiro on 28/11/2015.
 */
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

public class DiagnosticViewPagerAdapter extends FragmentStatePagerAdapter {

    CharSequence Titles[]; // This will Store the Titles of the Tabs which are Going to be passed when ViewPagerAdapterADSE is created
    int NumbOfTabs; // Store the number of tabs, this will also be passed when the ViewPagerAdapterADSE is created

    // Build a Constructor and assign the passed Values to appropriate values in the class
    public DiagnosticViewPagerAdapter(FragmentManager fm, CharSequence mTitles[], int mNumbOfTabsumb) {
        super(fm);

        this.Titles = mTitles;
        this.NumbOfTabs = mNumbOfTabsumb;

    }

    //This method return the fragment for the every position in the View Pager
    @Override
    public Fragment getItem(int position) {

        switch (position){
            case 0:
                Tab1CpuSpy tab1 = new Tab1CpuSpy();
                return tab1;
            case 1:
                Tab2Battery tab2 = new Tab2Battery();
                return tab2;
            case 2:
                Tab3AppInfo tab3 = new Tab3AppInfo();
                return tab3;
        }
        return getItem(position);
    }

    // This method return the titles for the Tabs in the Tab Strip

    @Override
    public CharSequence getPageTitle(int position) {
        return Titles[position];
    }

    // This method return the Number of tabs for the tabs Strip

    @Override
    public int getCount() {
        return NumbOfTabs;
    }
}


text:
' Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

Imports System.Collections.Immutable
Imports System.Composition
Imports System.Threading
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.CodeActions
Imports Microsoft.CodeAnalysis.CodeFixes
Imports Microsoft.CodeAnalysis.Completion
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax

Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.Spellcheck

    <ExportCodeFixProvider(LanguageNames.VisualBasic, Name:=PredefinedCodeFixProviderNames.SpellCheck), [Shared]>
    <ExtensionOrder(After:=PredefinedCodeFixProviderNames.RemoveUnnecessaryCast)>
    Partial Friend Class SpellcheckCodeFixProvider
        Inherits CodeFixProvider

        ''' <summary>
        ''' Type xxx is not defined
        ''' </summary>
        Friend Const BC30002 = "BC30002"

        ''' <summary>
        ''' Error 'x' is not declared
        ''' </summary>
        Friend Const BC30451 = "BC30451"

        ''' <summary>
        ''' xxx is not a member of yyy
        ''' </summary>
        Friend Const BC30456 = "BC30456"

        ''' <summary>
        ''' 'A' has no type parameters and so cannot have type arguments.
        ''' </summary>
        Friend Const BC32045 = "BC32045"

        Private Const s_maxMatches As Integer = 3
        Private Const s_maximumEditDistancePercentage = 0.8
        Private Const s_minimumLongestCommonSubsequencePercentage = 0.2

        Public NotOverridable Overrides ReadOnly Property FixableDiagnosticIds As ImmutableArray(Of String)
            Get
                Return ImmutableArray.Create(BC30002, BC30451, BC30456, BC32045)
            End Get
        End Property

        Public NotOverridable Overrides Async Function RegisterCodeFixesAsync(context As CodeFixContext) As Task
            Dim document = context.Document
            Dim span = context.Span
            Dim cancellationToken = context.CancellationToken

            Dim syntaxRoot = Await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(False)
            Dim errorNode = syntaxRoot.FindNode(span)
            If errorNode.Span <> span Then
                Return
            End If

            If errorNode IsNot Nothing Then
                Dim semanticModel = Await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(False)

                For Each node In errorNode.DescendantNodesAndSelf().OfType(Of SimpleNameSyntax)()
                    If Not node.IsMissing AndAlso node.Identifier.ValueText.Length >= 3 Then
                        Dim symbolInfo = semanticModel.GetSymbolInfo(node, cancellationToken)
                        If symbolInfo.Symbol Is Nothing Then
                            Dim actions = Await CreateSpellCheckCodeIssueAsync(document, node, cancellationToken).ConfigureAwait(False)

                            If actions IsNot Nothing Then
                                context.RegisterFixes(actions, context.Diagnostics)
                            End If

                            Exit For
                        End If
                    End If
                Next
            End If
        End Function

        Private Async Function CreateSpellCheckCodeIssueAsync(document As Document, identifierName As SimpleNameSyntax, cancellationToken As CancellationToken) As Task(Of IEnumerable(Of CodeAction))
            ' TODO(DustinCa): This isn't quite right. Using all default completion providers means that we might
            ' show items that don't make sense (like snippets)
            Dim completionService = document.GetLanguageService(Of ICompletionService)()
            Dim providers = completionService.GetDefaultCompletionProviders()

            Dim completionList = Await completionService.GetCompletionListAsync(document, identifierName.SpanStart, CompletionTriggerInfo.CreateInvokeCompletionTriggerInfo(), providers, cancellationToken).ConfigureAwait(False)
            If completionList Is Nothing Then
                Return Nothing
            End If

            Dim completionRules = completionService.GetCompletionRules()
            Dim onlyConsiderGenerics = TryCast(identifierName, GenericNameSyntax) IsNot Nothing

            Dim results = New List(Of SpellcheckResult)()
            Dim identifierText = identifierName.Identifier.ValueText

            For Each item In completionList.Items
                If Not item.Glyph.HasValue OrElse
                   item.Glyph.Value = Glyph.Error OrElse
                   item.Glyph.Value = Glyph.Namespace OrElse
                   (onlyConsiderGenerics AndAlso Not item.DisplayText.Contains("(Of")) Then

                    Continue For
                End If

                Dim name = GetUnescapedName(GetReasonableName(item.DisplayText))
                Dim distance = EditDistance.GetEditDistance(name, identifierText)
                Dim longestCommonSequence = EditDistance.GetLongestCommonSubsequenceLength(name, identifierText)

                ' Completion gave us the unbound identifier, so it's obviously okay. Bail.
                If distance = 0 Then
                    Return Nothing
                End If

                ' The old IDE code uses this as a metric of how well a string matches,
                ' in addition to the edit distance and longest common substring length percentages.
                Dim goodness = identifierText.Length - longestCommonSequence + distance

                ' Calculate ED and LCS% against the longer of the two strings.
                Dim maxLength = Math.Max(name.Length, identifierText.Length)

                Dim editDistancePercentage = distance / maxLength
                Dim longestCommonPercentage = longestCommonSequence / maxLength

                ' If it's within tolerances, keep it.
                If editDistancePercentage <= s_maximumEditDistancePercentage AndAlso longestCommonPercentage >= s_minimumLongestCommonSubsequencePercentage Then
                    results.Add(New SpellcheckResult(name, GetReasonableName(completionRules.GetTextChange(item).NewText), goodness))
                End If
            Next

            If Not results.Any() Then
                Return Nothing
            End If

            results.Sort(
                Function(r1, r2)
                    Dim goodnessComparisan = r1.Goodness.CompareTo(r2.Goodness)
                    If goodnessComparisan <> 0 Then
                        Return goodnessComparisan
                    End If

                    ' Try to order by name. Note that this is unescaped version of the name.
                    Dim nameCompare = String.Compare(r1.Name, r2.Name, StringComparison.CurrentCultureIgnoreCase)
                    If nameCompare <> 0 Then
                        Return nameCompare
                    End If

                    ' Prefer escaped identifiers ahead of non-escaped
                    Dim r1StartsWithEscape = r1.ReplacementText.Length > 0 AndAlso r1.ReplacementText(0) = "["c
                    Dim r2StartsWithEscape = r2.ReplacementText.Length > 0 AndAlso r2.ReplacementText(0) = "["c

                    If r1StartsWithEscape Then
                        Return -1
                    ElseIf r2StartsWithEscape
                        Return 1
                    End If

                    Return String.Compare(r1.ReplacementText, r2.ReplacementText, StringComparison.CurrentCultureIgnoreCase)
                End Function)

            Return results _
                .Select(Function(result) result.ReplacementText) _
                .Distinct() _
                .Take(s_maxMatches) _
                .Select(Function(name) New SpellCheckCodeAction(document, identifierName, name))
        End Function

        Private Structure SpellcheckResult
            Public ReadOnly Name As String
            Public ReadOnly Goodness As Integer
            Public ReadOnly ReplacementText As String

            Public Sub New(name As String, replacementText As String, goodness As Integer)
                Me.Name = name
                Me.ReplacementText = replacementText
                Me.Goodness = goodness
            End Sub

            Public Overrides Function ToString() As String
                Return $"{{{NameOf(Name)} = {Name}, {NameOf(Goodness)} = {Goodness}, {NameOf(ReplacementText)} = {ReplacementText}}}"
            End Function
        End Structure

        Private Shared Function GetReasonableName(name As String) As String
            ' Note: Because we're using completion items rather than looking up available symbols,
            ' We need to trim the display text to a valid identifier. That way, we suggest List
            ' (as Dev11 did) rather than List(Of ...). However, we don't want to remove escaping characters.

            Dim start = 0

            ' If the first character is a starting escape character, we want to skip it when processing
            ' the name for valid identifier characters.
            If name.Length > 0 AndAlso name(0) = "["c Then
                start = 1
            End If

            Dim length = name.Length
            For i = start To name.Length - 1
                If Not SyntaxFacts.IsIdentifierPartCharacter(name(i)) Then
                    length = i

                    ' If this is a closing escape character and the first character was a starting escape
                    ' character, we increase the length to ensure that the name we return includes both
                    ' escape characters.
                    If name(i) = "]"c AndAlso name(0) = "["c Then
                        length += 1
                    End If

                    Exit For
                End If
            Next

            Return name.Substring(0, length)
        End Function

        Private Shared Function GetUnescapedName(name As String) As String
            If name IsNot Nothing AndAlso name.Length > 2 AndAlso name(0) = "["c AndAlso name(name.Length - 1) = "]"c Then
                Return name.Substring(1, name.Length - 2)
            End If

            Return name
        End Function

    End Class
End Namespace


text:
[![Build Status](https://travis-ci.org/orlando/puppet-slack.png?branch=master)](https://travis-ci.org/orlando/puppet-slack)

Installs [Slack](http://www.slack.com), a chat application for making your working life simpler, more pleasant and more productive.

## Usage

```puppet
include slack
```

## Required Puppet Modules

* `boxen`

## Development

Write code. Run `script/cibuild` to test it. Check the `script` directory for other useful tools.


text:
var teams = [
  'Brazil',
  'Germany',
  'Italy',
  'France',
];

/*var result = teams.filter(function (value) {
 return value == 'Italy';
 });*/

//module.exports = result;

module.exports = function () {
  console.log(teams);
};


text:
import { NgModule } from '@angular/core';

import { GoogleLibphonenumberService } from './src/google-libphonenumber.service';

export * from './src/google-libphonenumber.service';

@NgModule({
  imports: [],
  exports: [],
  declarations: [],
  providers: [GoogleLibphonenumberService],
})
export class GoogleLibphonenumberModule { }


text:
window.requestAnimationFrame(function () {
  var maxValue = 4;
  var game = new GameManager(4, KeyboardInputManager, HTMLActuator, LocalScoreManager);
  game.move = function (direction) {
    var self = this;
    if (this.over || this.won) return;
    var cell, tile;
    var vector     = this.getVector(direction);
    var traversals = this.buildTraversals(vector);
    var moved      = false;
    this.prepareTiles();
    traversals.x.forEach(function (x) {
      traversals.y.forEach(function (y) {
        cell = { x: x, y: y };
        tile = self.grid.cellContent(cell);
        if (tile) {
          var positions = self.findFarthestPosition(cell, vector);
          var next      = self.grid.cellContent(positions.next);
          if (next && !next.mergedFrom && next.value === tile.value) {
            var merged = new Tile(positions.next, tile.value + next.value);
            merged.mergedFrom = [tile, next];
            self.grid.insertTile(merged);
            self.grid.removeTile(tile);
            tile.updatePosition(positions.next);
            self.score += merged.value;
            if (merged.value > maxValue) {
              maxValue = merged.value;
            }
            if (merged.value === 4096) self.won = true;
          } else {
            self.moveTile(tile, positions.farthest);
          }
          if (!self.positionsEqual(cell, tile)) {
            moved = true;
          }
        }
      });
    });
    if (moved) {
      this.addRandomTile();
      if (!this.movesAvailable()) {
        this.over = true;
      }
      this.actuate();
    }
  };
  game.inputManager.events["move"] = [];
  game.inputManager.on("move", game.move.bind(game));
  game.actuator.addTile = function (tile) {
    var self = this;
    var wrapper   = document.createElement("div");
    var inner     = document.createElement("div");
    var position  = tile.previousPosition || { x: tile.x, y: tile.y };
    positionClass = this.positionClass(position);
    var classes = ["tile", "tile-" + tile.value, positionClass];
    this.applyClasses(wrapper, classes);
    inner.classList.add("tile-inner");
    switch (tile.value) {
    case 2:
      inner.textContent = "魔法时代";
      break;
    case 4:
      inner.textContent = "黄金时代";
      break;
    case 8:
      inner.textContent = "危机纪元";
      break;
    case 16:
      inner.textContent = "威摄纪元";
      break;
    case 32:
      inner.textContent = "威摄后";
      break;
    case 64:
      inner.textContent = "广播纪元";
      break;
    case 128:
      inner.textContent = "掩体纪元";
      break;
    case 256:
      inner.textContent = "银河纪元";
      break;
    case 512:
      inner.textContent = "黑域纪元";
      break;
    case 1024:
      inner.textContent = "647宇宙";
      break;
    case 2048:
      inner.textContent = "死神永生";
      break;
    case 4096:
      inner.textContent = "";
      break;
    }
    if (tile.previousPosition) {
      window.requestAnimationFrame(function () {
        classes[2] = self.positionClass({ x: tile.x, y: tile.y });
        self.applyClasses(wrapper, classes);
      });
    } else if (tile.mergedFrom) {
      classes.push("tile-merged");
      this.applyClasses(wrapper, classes);
      tile.mergedFrom.forEach(function (merged) {
        self.addTile(merged);
      });
    } else {
      classes.push("tile-new");
      this.applyClasses(wrapper, classes);
    }
    wrapper.appendChild(inner);
    this.tileContainer.appendChild(wrapper);
    };
    game.actuator.message = function (won) {
      var type    = won ? "game-won" : "game-over";
      var message = "";
      switch (maxValue) {
      case 4:
        message = "程心的祖先活了下来";
        break;
      case 8:
        message = "程心毕业了";
        break;
      case 16:
        message = "程心没按按钮";
        break;
      case 32:
        message = "程心被土著保护";
        break;
      case 64:
        message = "程心听云天明讲故事";
        break;
      case 128:
        message = "程心成功离开太阳系";
        break;
      case 256:
        message = "程心发现死线";
        break;
      case 512:
        message = "程心在黑域中活了下来";
        break;
      case 1024:
        message = "程心保留了鱼缸";
        break;
      case 2048:
        message = "程心永生";
        break;
      case 4096:
        message = "死神永生";
        break;
      }
      this.messageContainer.classList.add(type);
      this.messageContainer.getElementsByTagName("p")[0].textContent = message;
    };
    game.restart = function () {
      maxValue = 4;
      this.actuator.restart();
      this.setup();
    };
    game.restart();
});


text:
CREATE TABLE [dbo].[QueueMessages]
(
    [ID] UNIQUEIDENTIFIER NOT NULL PRIMARY KEY,
    [RowVersion] ROWVERSION NOT NULL,
    [QueueName] NVARCHAR(80) NOT NULL,
    [Body] NVARCHAR(256) NOT NULL,
    [SentTimestamp] DATETIME NOT NULL,
    [ApproximateReceiveCount] INT NOT NULL,
    [ApproximateFirstReceiveTimestamp] DATETIME NOT NULL,
    [LastAccessTimestamp] DATETIME NULL,
    CONSTRAINT [FK_QueueMessages_ToMsgQueue] FOREIGN KEY ([QueueName]) REFERENCES [MessageQueue]([Name]) ON DELETE CASCADE
)


text:
class UNIX_IdentityContextFixture :
	public CIMFixtureBase
{
public:
	UNIX_IdentityContextFixture();
	~UNIX_IdentityContextFixture();
	virtual void Run();

};


text:
![](https://travis-ci.org/a-warner/drb_queue.png)

Simple separate-process queue system using DRb

## Motivation
Typical ruby web apps run background jobs with a separate-process / separate-server system like [Delayed Job](https://github.com/collectiveidea/delayed_job) or [Resque](https://github.com/resque/resque).  This strategy is convenient because there are many types of tasks that we don't want to or don't do during the course of a web request.

If you don't want the overhead of managing a separate queue process / server / etc, then you can easily run background jobs in the same process as your webserver, but on a background thread, using something like [Girl Friday](https://github.com/mperham/girl_friday) or [Sucker Punch](https://github.com/brandonhilkert/sucker_punch).

Both of these libraries are optimized for truly concurrent rubies such as JRuby and Rubinius.  On MRI, every thread is competing for the [Global VM Lock](http://en.wikipedia.org/wiki/Global_Interpreter_Lock), and so you might have a background process or thread locking up a web request while it's doing some processing.

drb_queue basically has the same goal as `girl_friday`: execute background jobs within the same logical web server, for convenience, but it spins up a separate process for queue processing.  This strategy gives the queue and the web server each their own "global vm lock", so background jobs can't directly lock up web requests.  drb_queue uses DRb to simplify the inter-process interaction.

## Installation

Add this line to your application's Gemfile:

    gem 'drb_queue'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install drb_queue

## Usage

```ruby
# config/initializers/drb_queue.rb

Rails.configuration.after_initialize do
  require 'drb_queue/store/redis'

  DRbQueue.configure do |c|
    c.num_workers = (ENV['NUM_WORKERS'] || 0).to_i

    # what to do when a background job throws an error
    c.on_error { |e| do_something_with_a_drb_queue_error(e) }

    # drb_queue will store unfinished jobs in redis if you set a store
    c.store DRbQueue::Store::Redis, :redis => lambda { Redis.new }
  end

  DRbQueue.start!
end
```

See [Resque](https://github.com/resque/resque) for examples of workers; drb_queue workers are meant to work in exactly the same way. (except without queue names for the moment)

```ruby
# app/workers/user_registration_email_worker.rb
class UserRegistrationEmailWorker
  def self.perform(user_id)
    UserMailer.registration_email(User.find(user_id)).deliver
  end
end
```

And to queue up a job:

```ruby
DRbQueue.enqueue(UserRegistrationEmailWorker, user.id)
```

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

### LICENSE
MIT


text:
using CAESAR.Chess.Positions;
using CAESAR.Chess.Core;
using Xunit;

namespace CAESAR.Chess.Tests.Positions
{
    public class PositionTests
    {
        private readonly IPosition _position = Position.EmptyPosition;

        [Theory]
        [InlineData("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR")]
        public void FenStringSetsPiecePlacementOnPosition(string fen, string piecePlacement)
        {
            // Arrange

            // Act
            _position.SetPosition(fen);
            var actual = _position.ToFenString().PiecePlacement;

            // Assert
            Assert.Equal(piecePlacement, actual);
        }

        [Theory]
        [InlineData("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", CastlingRights.WhiteShort | CastlingRights.WhiteLong | CastlingRights.BlackShort | CastlingRights.BlackLong)]
        public void FenStringSetsCastlingRightsOnPosition(string fen, CastlingRights castlingRights)
        {
            // Arrange

            // Act
            _position.SetPosition(fen);
            var actual = _position.CastlingRights;

            // Assert
            Assert.Equal(castlingRights, actual);
        }

        [Theory]
        [InlineData("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", Side.White)]
        public void FenStringSetsSideToMoveOnPosition(string fen, Side side)
        {
            // Arrange

            // Act
            _position.SetPosition(fen);
            var actual = _position.SideToMove;

            // Assert
            Assert.Equal(side, actual);
        }

        [Theory]
        [InlineData("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq e6 0 1", "e6")]
        public void FenStringSetsEnPassantSquareOnPosition(string fen, string enPassantSquare)
        {
            // Arrange

            // Act
            _position.SetPosition(fen);
            var actual = _position.EnPassantSquare.Name;

            // Assert
            Assert.Equal(enPassantSquare, actual);
        }

        [Theory]
        [InlineData("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 49 1", (byte)49)]
        public void FenStringSetsHalfMoveClockOnPosition(string fen, byte halfMoveClock)
        {
            // Arrange

            // Act
            _position.SetPosition(fen);
            var actual = _position.HalfMoveClock;

            // Assert
            Assert.Equal(halfMoveClock, actual);
        }

        [Theory]
        [InlineData("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 15", (ushort)15)]
        public void FenStringSetsFullMoveNumberOnPosition(string fen, ushort fullMoveNumber)
        {
            // Arrange

            // Act
            _position.SetPosition(fen);
            var actual = _position.FullMoveNumber;

            // Assert
            Assert.Equal(fullMoveNumber, actual);
        }
    }
}


text:
"""
gargoyle
~~~~~~~~

:copyright: (c) 2010 DISQUS.
:license: Apache License 2.0, see LICENSE for more details.
"""

__all__ = ('gargoyle', 'ConditionSet', 'autodiscover', 'VERSION')

try:
    VERSION = __import__('pkg_resources') \
        .get_distribution('gargoyle').version
except Exception, e:
    VERSION = 'unknown'

from gargoyle.manager import gargoyle

def autodiscover():
    """
    Auto-discover INSTALLED_APPS admin.py modules and fail silently when
    not present. This forces an import on them to register any admin bits they
    may want.
    """
    import copy
    from django.conf import settings
    from django.utils.importlib import import_module

    for app in settings.INSTALLED_APPS:
        # Attempt to import the app's gargoyle module.
        before_import_registry = copy.copy(gargoyle._registry)
        try:
            import_module('%s.gargoyle' % app)
        except:
            # Reset the model registry to the state before the last import as
            # this import will have to reoccur on the next request and this
            # could raise NotRegistered and AlreadyRegistered exceptions
            gargoyle._registry = before_import_registry

    # load builtins
    __import__('gargoyle.builtins')

default_app_config = 'gargoyle.apps.GargoyleAppConfig'


text:
package com.zuowei.utils.handlers;

import com.zuowei.utils.bridge.constant.EaterAction;
import com.zuowei.utils.bridge.handler.ToolKit;
import com.zuowei.utils.bridge.params.LightParam;
import com.zuowei.utils.bridge.params.LoginParam;
import com.zuowei.utils.bridge.params.ParamWrap;
import com.zuowei.utils.helper.HiTalkHelper;
import com.zuowei.utils.helper.LoginHelper;

import java.util.concurrent.CopyOnWriteArrayList;

/**
 * Created by zuowei on 16-7-18.
 */
public class LoginHandler extends AbstractHandler<LoginParam>{

    private static LoginHandler sInstance;
    public interface OnLoginListener{
        void onSuccess();
        void onError(int code,String message);
    }

    public interface  OnRegisterListener{
        void onRegisterSuccess();
        void onRegisterError(int code,String message);
    }

    public interface OnVerifyListener{
        void onVerifySuccess();
        void onVerifyError(int code,String message);
    }

    public interface OnRequestVerifyListener{
        void onRequestVerifySuccess();
        void onRequestVerifyError(int code,String message);
    }

    private CopyOnWriteArrayList<OnLoginListener> mOnLoginListeners;
    private CopyOnWriteArrayList<OnRegisterListener> mOnRegisterListeners;
    private CopyOnWriteArrayList<OnVerifyListener> onVerifyListeners_;
    private CopyOnWriteArrayList<OnRequestVerifyListener> onRequestVerifyListeners_;

    public static LoginHandler getInstance(){
        if (sInstance == null){
            synchronized (LoginHandler.class){
                if (sInstance == null){
                    sInstance = new LoginHandler();
                }
            }
        }
        return sInstance;
    }

    private LoginHandler(){
        mOnLoginListeners = new CopyOnWriteArrayList<>();
        mOnRegisterListeners = new CopyOnWriteArrayList<>();
        onVerifyListeners_ = new CopyOnWriteArrayList<>();
        onRequestVerifyListeners_ = new CopyOnWriteArrayList<>();
    }

    @Override
    public boolean isParamAvailable(LightParam param) {
        return param != null && EaterAction.ACTION_DO_LOGIN.equals(param.getAction());
    }

    @Override
    public void doJobWithParam(ParamWrap<LoginParam> paramWrap) {
        LightParam param = paramWrap.getParam();
        int type = param.getData().getInt("type");
        String userName = param.getData().getString("userName");
        String password = param.getData().getString("password");
        String phoneNumber = param.getData().getString("mobilePhoneNumber");
        String code = param.getData().getString("code");
        switch (type){
            case LoginParam.TYPE_LOGIN:
                doLogin(userName,password);
                break;
            case LoginParam.TYPE_REGISTER:
                doRegister(userName,password,phoneNumber);
                break;
            case LoginParam.TYPE_REQUEST_VERIFY:
                doRequestVerify(phoneNumber);
                break;
            case LoginParam.TYPE_VERIFY:
                doVerify(code,phoneNumber);
                break;
            case LoginParam.TYPE_LOGOUT:
                doLogout();
                break;
        }
    }

    private void doLogout() {
        LoginHelper.getInstance().logout();
    }

    private void doVerify(String code,String phoneNumber) {
        LoginHelper.getInstance().verifyMobilePhone(code,phoneNumber);
    }

    private void doRequestVerify(String phoneNumber) {
        LoginHelper.getInstance().requestVerifyMobilePhone(phoneNumber);
    }

    private void doRegister(String userName, String password, String phoneNumber) {
        LoginHelper.getInstance().register(userName,password,phoneNumber);
    }

    private void doLogin(String userName, String password) {
        HiTalkHelper.getInstance().getModel().setCurrentUserName(userName);
        //do login
        LoginHelper.getInstance().login(userName,password);
    }

    public void addLoginListener(OnLoginListener onLoginListener){
        mOnLoginListeners.add(onLoginListener);
    }

    public void removeLoginListener(OnLoginListener onLoginListener){
        mOnLoginListeners.remove(onLoginListener);
    }
    public void addRegisterListener(OnRegisterListener onRegisterListener){
        mOnRegisterListeners.add(onRegisterListener);
    }

    public void removeRegisterListener(OnRegisterListener onRegisterListener){
        mOnRegisterListeners.remove(onRegisterListener);
    }

    public void addRequestVerifyListener(OnRequestVerifyListener onRequestVerifyListener){
        onRequestVerifyListeners_.add(onRequestVerifyListener);
    }

    public void removeRequestVerifyListener(OnRequestVerifyListener onRequestVerifyListener){
        onRequestVerifyListeners_.remove(onRequestVerifyListener);
    }

    public void addVerifyListener(OnVerifyListener onVerifyListener){
        onVerifyListeners_.add(onVerifyListener);
    }

    public void removeVerifyListener(OnVerifyListener onVerifyListener){
        onVerifyListeners_.remove(onVerifyListener);
    }

    public void loginSuccess(){
        ToolKit.runOnMainThreadAsync(() -> {
            for (OnLoginListener loginListener : mOnLoginListeners){
                loginListener.onSuccess();
            }
        });
    }

    public void loginError(final int code, final String message){
        ToolKit.runOnMainThreadAsync(() -> {
            for (OnLoginListener loginListener : mOnLoginListeners){
                loginListener.onError(code,message);
            }
        });
    }

    public void registerSuccess(){
        ToolKit.runOnMainThreadAsync(() -> {
            for (OnRegisterListener registerListener : mOnRegisterListeners){
                registerListener.onRegisterSuccess();
            }
        });
    }

    public void registerError(final int code, final String message){
        ToolKit.runOnMainThreadAsync(() -> {
            for (OnRegisterListener registerListener : mOnRegisterListeners){
                registerListener.onRegisterError(code,message);
            }
        });
    }

    public void requestSuccess(){
        ToolKit.runOnMainThreadAsync(() -> {
            for (OnRequestVerifyListener onRequestVerifyListener : onRequestVerifyListeners_){
                onRequestVerifyListener.onRequestVerifySuccess();
            }
        });
    }

    public void requestError(final int code, final String message){
        ToolKit.runOnMainThreadAsync(() -> {
            for (OnRequestVerifyListener onRequestVerifyListener : onRequestVerifyListeners_){
                onRequestVerifyListener.onRequestVerifyError(code,message);
            }
        });
    }

    public void verifySuccess(){
        ToolKit.runOnMainThreadAsync(() -> {
            for (OnVerifyListener onVerifyListener : onVerifyListeners_){
                onVerifyListener.onVerifySuccess();
            }
        });
    }

    public void verifyError(final int code, final String message){
        ToolKit.runOnMainThreadAsync(() -> {
            for (OnVerifyListener onVerifyListener : onVerifyListeners_){
                onVerifyListener.onVerifyError(code,message);
            }
        });
    }
}


text:
@import Foundation;

@interface NSString (html)
- (NSString *)stringByDecodingXMLEntities;
@end


text:
--- ScrollPanel module

--- ScrollPanel fields.
-- Inherits from Control.
-- @see control.Control
-- @table ScrollPanel
-- @int[opt=12] scrollBarSize size of the scrollbar
-- @int[opt=0] scrollPosX position of the scrollbar
-- @int[opt=0] scrollPosY position of the scrollbar
-- @bool[opt=true] verticalScrollbar the vertical scroll bar is enabled
-- @bool[opt=true] horizontalScrollbar the horizontal scroll bar is enabled
-- @bool[opt=true] smoothScroll smooth scroll is enabled
-- @bool[opt=false] verticalSmartScroll if control is scrolled to bottom, keep scroll when layout changes
-- @number[opt=0.7] smoothScrollTime time of the smooth scroll, in seconds
-- @bool[opt=false] ignoreMouseWheel mouse wheel scrolling is enabled
ScrollPanel = Control:Inherit{
  classname     = "scrollpanel",
  padding       = {0,0,0,0},
  backgroundColor = {0,0,0,0},
  scrollbarSize = 12,
  scrollPosX    = 0,
  scrollPosY    = 0,
  verticalScrollbar   = true,
  horizontalScrollbar = true,
  verticalSmartScroll = false,
  smoothScroll     = true,
  smoothScrollTime = 0.7,
  ignoreMouseWheel = false,
}

local this = ScrollPanel
local inherited = this.inherited

--//=============================================================================

local function smoothstep(x)
  return x*x*(3 - 2*x)
end

--//=============================================================================

--- Sets the scroll position
-- @int x x position
-- @int y y position
function ScrollPanel:SetScrollPos(x,y,inview,smoothscroll)
  local dosmooth = self.smoothScroll and (smoothscroll or (smoothscroll == nil))
  if dosmooth then
    self._oldScrollPosX = self.scrollPosX
    self._oldScrollPosY = self.scrollPosY
  end

  if (x) then
    if (inview) then
      x = x - self.clientArea[3] * 0.5
    end
    self.scrollPosX = x
    if (self.contentArea) then
      self.scrollPosX = clamp(0, self.contentArea[3] - self.clientArea[3], self.scrollPosX)
    end
  end
  if (y) then
    if (inview) then
      y = y - self.clientArea[4] * 0.5
    end
    self.scrollPosY = y
    if (self.contentArea) then
      self.scrollPosY = clamp(0, self.contentArea[4] - self.clientArea[4], self.scrollPosY)
    end
  end

  if dosmooth then
    if (self._oldScrollPosX ~= self.scrollPosX)or(self._oldScrollPosY ~= self.scrollPosY) then
      self._smoothScrollEnd = Spring.GetTimer()
      self._newScrollPosX = self.scrollPosX
      self._newScrollPosY = self.scrollPosY
      self.scrollPosX = self._oldScrollPosX
      self.scrollPosY = self._oldScrollPosY
    end
  end

  self:InvalidateSelf()
end

function ScrollPanel:Update(...)
	local trans = 1
	if self.smoothScroll and self._smoothScrollEnd then
		local trans = Spring.DiffTimers(Spring.GetTimer(), self._smoothScrollEnd)
		trans = trans / self.smoothScrollTime

		if (trans >= 1) then
			self.scrollPosX = self._newScrollPosX
			self.scrollPosY = self._newScrollPosY
			self._smoothScrollEnd = nil
		else
			for n=1,3 do trans = smoothstep(trans) end
			self.scrollPosX = self._oldScrollPosX * (1 - trans) + self._newScrollPosX * trans
			self.scrollPosY = self._oldScrollPosY * (1 - trans) + self._newScrollPosY * trans
			self:InvalidateSelf()
		end
	end

	inherited.Update(self, ...)
end

--//=============================================================================

function ScrollPanel:LocalToClient(x,y)
  local ca = self.clientArea
  return x - ca[1] + self.scrollPosX, y - ca[2] + self.scrollPosY
end

function ScrollPanel:ClientToLocal(x,y)
  local ca = self.clientArea
  return x + ca[1] - self.scrollPosX, y + ca[2] - self.scrollPosY
end

function ScrollPanel:ParentToClient(x,y)
  local ca = self.clientArea
  return x - self.x - ca[1] + self.scrollPosX, y - self.y - ca[2] + self.scrollPosY
end

function ScrollPanel:ClientToParent(x,y)
  local ca = self.clientArea
  return x + self.x + ca[1] - self.scrollPosX, y + self.y + ca[2] - self.scrollPosY
end

--//=============================================================================

function ScrollPanel:GetCurrentExtents()
  local left = self.x
  local top  = self.y
  local right  = self.x + self.width
  local bottom = self.y + self.height

  if (left   < minLeft)   then minLeft   = left end
  if (top    < minTop )   then minTop    = top end

  if (right  > maxRight)  then maxRight  = right end
  if (bottom > maxBottom) then maxBottom = bottom end

  return minLeft, minTop, maxRight, maxBottom
end

--//=============================================================================

function ScrollPanel:_DetermineContentArea()
  local minLeft, minTop, maxRight, maxBottom = self:GetChildrenCurrentExtents()

  self.contentArea = {
    0,
    0,
    maxRight,
    maxBottom,
  }

  local contentArea = self.contentArea
  local clientArea = self.clientArea

  if (self.verticalScrollbar) then
    if (contentArea[4]>clientArea[4]) then
      if (not self._vscrollbar) then
        self.padding[3] = self.padding[3] + self.scrollbarSize
      end
      self._vscrollbar = true
    else
      if (self._vscrollbar) then
        self.padding[3] = self.padding[3] - self.scrollbarSize
      end
      self._vscrollbar = false
    end
  end

  if (self.horizontalScrollbar) then
    if (contentArea[3]>clientArea[3]) then
      if (not self._hscrollbar) then
        self.padding[4] = self.padding[4] + self.scrollbarSize
      end
      self._hscrollbar = true
    else
      if (self._hscrollbar) then
        self.padding[4] = self.padding[4] - self.scrollbarSize
      end
      self._hscrollbar = false
    end
  end

  self:UpdateClientArea()

  local contentArea = self.contentArea
  local clientArea = self.clientArea
  if (contentArea[4] < clientArea[4]) then
    contentArea[4] = clientArea[4]
  end
  if (contentArea[3] < clientArea[3]) then
    contentArea[3] = clientArea[3]
  end
end

--//=============================================================================

function ScrollPanel:UpdateLayout()
  --self:_DetermineContentArea()
  self:RealignChildren()
  local before = ((self._vscrollbar and 1) or 0) + ((self._hscrollbar and 2) or 0)
  self:_DetermineContentArea()
  local now = ((self._vscrollbar and 1) or 0) + ((self._hscrollbar and 2) or 0)
  if (before ~= now) then
    self:RealignChildren()
  end

  self.scrollPosX = clamp(0, self.contentArea[3] - self.clientArea[3], self.scrollPosX)

  local oldClamp = self.clampY or 0
  self.clampY = self.contentArea[4] - self.clientArea[4]

  if self.verticalSmartScroll and self.scrollPosY >= oldClamp then
    self.scrollPosY = self.clampY
  else
    self.scrollPosY = clamp(0, self.clampY, self.scrollPosY)
  end

  return true;
end

--//=============================================================================

function ScrollPanel:IsRectInView(x,y,w,h)
	if (not self.parent) then
		return false
	end

	if self._inrtt then
		return true
	end

	--//FIXME 1. don't create tables 2. merge somehow into Control:IsRectInView
	local cx = x - self.scrollPosX
	local cy = y - self.scrollPosY

	local rect1 = {cx,cy,w,h}
	local rect2 = {0,0,self.clientArea[3],self.clientArea[4]}
	local inview = AreRectsOverlapping(rect1,rect2)

	if not(inview) then
		return false
	end

	local px,py = self:ClientToParent(x,y)
	return (self.parent):IsRectInView(px,py,w,h)
end

--//=============================================================================

function ScrollPanel:DrawControl()
  --// gets overriden by the skin/theme
end

function ScrollPanel:_DrawInClientArea(fnc,...)
	local clientX,clientY,clientWidth,clientHeight = unpack4(self.clientArea)

	gl.PushMatrix()
	gl.Translate(clientX - self.scrollPosX, clientY - self.scrollPosY, 0)

	local sx,sy = self:LocalToScreen(clientX,clientY)
	sy = select(2,gl.GetViewSizes()) - (sy + clientHeight)

	if PushLimitRenderRegion(self, sx, sy, clientWidth, clientHeight) then
		fnc(...)
		PopLimitRenderRegion(self, sx, sy, clientWidth, clientHeight)
	end

	gl.PopMatrix()
end

--//=============================================================================

function ScrollPanel:IsAboveHScrollbars(x,y)
  if (not self._hscrollbar) then return false end
  return y >= (self.height - self.scrollbarSize) --FIXME
end

function ScrollPanel:IsAboveVScrollbars(x,y)
  if (not self._vscrollbar) then return false end
  return x >= (self.width - self.scrollbarSize) --FIXME
end

function ScrollPanel:HitTest(x, y)
  if self:IsAboveVScrollbars(x,y) then
    return self
  end
  if self:IsAboveHScrollbars(x,y) then
    return self
  end

  return inherited.HitTest(self, x, y)
end

function ScrollPanel:MouseDown(x, y, ...)
  if self:IsAboveVScrollbars(x,y) then
    self._vscrolling  = true
    local clientArea = self.clientArea
    local cy = y - clientArea[2]
    self:SetScrollPos(nil, (cy/clientArea[4])*self.contentArea[4], true, false)
    return self
  end
  if self:IsAboveHScrollbars(x,y) then
    self._hscrolling  = true
    local clientArea = self.clientArea
    local cx = x - clientArea[1]
    self:SetScrollPos((cx/clientArea[3])*self.contentArea[3], nil, true, false)
    return self
  end

  return inherited.MouseDown(self, x, y, ...)
end

function ScrollPanel:MouseMove(x, y, dx, dy, ...)
  if self._vscrolling then
    local clientArea = self.clientArea
    local cy = y - clientArea[2]
    self:SetScrollPos(nil, (cy/clientArea[4])*self.contentArea[4], true, false)
    return self
  end
  if self._hscrolling then
    local clientArea = self.clientArea
    local cx = x - clientArea[1]
    self:SetScrollPos((cx/clientArea[3])*self.contentArea[3], nil, true, false)
    return self
  end

  local old = (self._hHovered and 1 or 0) + (self._vHovered and 2 or 0)
  self._hHovered = self:IsAboveHScrollbars(x,y)
  self._vHovered = self:IsAboveVScrollbars(x,y)
  local new = (self._hHovered and 1 or 0) + (self._vHovered and 2 or 0)
  if (new ~= old) then
    self:InvalidateSelf()
  end

  return inherited.MouseMove(self, x, y, dx, dy, ...)
end

function ScrollPanel:MouseUp(x, y, ...)
  if self._vscrolling then
    self._vscrolling = nil
    local clientArea = self.clientArea
    local cy = y - clientArea[2]
    self:SetScrollPos(nil, (cy/clientArea[4])*self.contentArea[4], true, false)
    return self
  end
  if self._hscrolling then
    self._hscrolling = nil
    local clientArea = self.clientArea
    local cx = x - clientArea[1]
    self:SetScrollPos((cx/clientArea[3])*self.contentArea[3], nil, true, false)
    return self
  end

  return inherited.MouseUp(self, x, y, ...)
end

function ScrollPanel:MouseWheel(x, y, up, value, ...)
  if self._vscrollbar and not self.ignoreMouseWheel then
    self:SetScrollPos(nil, self.scrollPosY - value*30, false, false)
    return self
  end

  return inherited.MouseWheel(self, x, y, up, value, ...)
end

function ScrollPanel:MouseOut(...)
	inherited.MouseOut(self, ...)
	self._hHovered = false
	self._vHovered = false
	self:InvalidateSelf()
end