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>

  <parent>
    <groupId>org.glowroot</groupId>
    <artifactId>glowroot-parent</artifactId>
    <version>0.14.0-beta.4-SNAPSHOT</version>
  </parent>

  <artifactId>glowroot-central</artifactId>
  <!-- need to use default jar packaging, otherwise jar gets installed with war extension and
    webdriver tests cannot find it -->

  <name>Glowroot Central Collector</name>
  <description>Glowroot Central Collector</description>

  <dependencies>
    <dependency>
      <groupId>org.glowroot</groupId>
      <artifactId>glowroot-wire-api</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.glowroot</groupId>
      <artifactId>glowroot-common</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.glowroot</groupId>
      <artifactId>glowroot-common2</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.glowroot</groupId>
      <artifactId>glowroot-ui</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <!-- this is used to instrument central itself -->
      <groupId>org.glowroot</groupId>
      <artifactId>glowroot-agent-api</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>31.0.1-jre</version>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-netty</artifactId>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-tcnative-boringssl-static</artifactId>
      <!-- need to stick to version known to work with gRPC 1.44.1,
        see table at https://github.com/grpc/grpc-java/blob/master/SECURITY.md#netty -->
      <version>2.0.46.Final</version>
    </dependency>
    <dependency>
      <groupId>com.datastax.cassandra</groupId>
      <artifactId>cassandra-driver-core</artifactId>
      <version>3.7.2</version>
    </dependency>
    <dependency>
      <groupId>org.infinispan</groupId>
      <artifactId>infinispan-core</artifactId>
      <version>13.0.8.Final</version>
    </dependency>
    <!-- jgroups-kubernetes specifies that it requires 4.2.x -->
    <dependency>
      <groupId>org.jgroups</groupId>
      <artifactId>jgroups</artifactId>
      <version>4.2.18.Final</version>
    </dependency>
    <dependency>
      <groupId>org.jgroups.kubernetes</groupId>
      <artifactId>jgroups-kubernetes</artifactId>
      <version>1.0.16.Final</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <!-- not using AsyncHttpClient because it introduces another dependency on netty which already
        needs to be kept in sync with grpc version -->
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpasyncclient</artifactId>
      <version>4.1.4</version>
    </dependency>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-api</artifactId>
      <version>3.141.59</version>
    </dependency>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-support</artifactId>
      <version>3.141.59</version>
    </dependency>
    <dependency>
      <groupId>com.machinepublishers</groupId>
      <artifactId>jbrowserdriver</artifactId>
      <version>1.0.1</version>
      <exclusions>
        <exclusion>
          <!-- a later version of jna with a different groupId is already included by selenium -->
          <groupId>com.sun.jna</groupId>
          <artifactId>jna</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.immutables</groupId>
      <artifactId>value</artifactId>
      <!-- immutables is only needed at compile time -->
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.immutables</groupId>
      <artifactId>serial</artifactId>
      <version>${immutables.version}</version>
      <!-- immutables is only needed at compile time -->
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.datatype</groupId>
      <artifactId>jackson-datatype-guava</artifactId>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jul-to-slf4j</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
    </dependency>
    <dependency>
      <groupId>org.codehaus.janino</groupId>
      <artifactId>janino</artifactId>
      <version>3.1.0</version>
    </dependency>
    <dependency>
      <!-- this is to resolve maven enforcer RequireUpperBoundDeps error -->
      <groupId>net.bytebuddy</groupId>
      <artifactId>byte-buddy</artifactId>
      <version>1.10.7</version>
    </dependency>
    <dependency>
      <!-- this is to resolve maven enforcer RequireUpperBoundDeps error -->
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <version>4.5.11</version>
    </dependency>
    <dependency>
      <!-- this is to resolve maven enforcer RequireUpperBoundDeps error -->
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpcore</artifactId>
      <version>4.4.13</version>
    </dependency>
    <dependency>
      <groupId>org.checkerframework</groupId>
      <artifactId>checker-qual</artifactId>
      <!-- don't need this dependency at runtime since only annotations -->
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-params</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.rauschig</groupId>
      <artifactId>jarchivelib</artifactId>
      <version>1.0.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>com.github.os72</groupId>
        <artifactId>protoc-jar-maven-plugin</artifactId>
        <configuration>
          <protocVersion>${protoc.version}</protocVersion>
          <outputTargets>
            <outputTarget>
              <type>java</type>
              <outputDirectory>target/generated-sources/protobuf-java</outputDirectory>
            </outputTarget>
          </outputTargets>
        </configuration>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <!-- checking against jdk 1.6 signatures is inherited from glowroot-parent -->
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>animal-sniffer-maven-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <configuration>
          <properties>
            <property>
              <!-- this is just a test performance optimization -->
              <name>listener</name>
              <value>org.glowroot.central.repo.SharedSetupRunListener</value>
            </property>
          </properties>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <!-- maven-war-plugin needs to execute before maven-jar-plugin, otherwise it messes up the
          jar's manifest -->
        <artifactId>maven-war-plugin</artifactId>
        <version>3.2.2</version>
        <executions>
          <execution>
            <goals>
              <goal>war</goal>
            </goals>
            <configuration>
              <classifier>dist</classifier>
              <archive>
                <manifestEntries>
                  <Implementation-Title>${project.name}</Implementation-Title>
                  <Implementation-Version>${project.version}</Implementation-Version>
                  <Build-Commit>${glowroot.build.commit}</Build-Commit>
                </manifestEntries>
              </archive>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <forceCreation>true</forceCreation>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
              <classpathPrefix>lib</classpathPrefix>
            </manifest>
            <manifestEntries>
              <Build-Time>${maven.build.timestamp}</Build-Time>
              <Main-Class>org.glowroot.central.Main</Main-Class>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <configuration>
              <descriptors>
                <descriptor>dist.xml</descriptor>
              </descriptors>
            </configuration>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>de.dentrassi.maven</groupId>
        <artifactId>rpm</artifactId>
        <version>1.8.0</version>
        <configuration>
          <skipSigning>true</skipSigning>
        </configuration>
        <executions>
          <execution>
            <id>rpm</id>
            <goals>
              <goal>rpm</goal>
            </goals>
            <configuration>
              <attach>false</attach> <!-- don't attach RPM -->
              <group>Applications/System</group>
              <license>/usr/share/doc/glowroot-central/LICENSE</license>
              <url>https://github.com/glowroot/glowroot</url>
              <description>Glowroot Central Collector</description>
              <prerequisites>
                <prerequisite>systemd</prerequisite>
                <prerequisite>/usr/sbin/useradd</prerequisite>
                <prerequisite>/usr/sbin/groupadd</prerequisite>
                <prerequisite>/usr/sbin/userdel</prerequisite>
                <prerequisite>/usr/sbin/groupdel</prerequisite>
                <prerequisite>/usr/bin/getent</prerequisite>
              </prerequisites>
              <requires>
                <require>jre >= 1.8</require>
              </requires>
              <provides>
                <provide>user(glowroot)</provide>
                <provide>group(glowroot)</provide>
              </provides>
              <!-- create glowroot user and group -->
              <beforeInstallation>
                getent group glowroot > /dev/null || groupadd -r glowroot
                getent passwd glowroot > /dev/null || useradd -g glowroot -M -r glowroot -d /var/run/glowroot-central
                if [ $1 -eq 2 ] ; then systemctl stop glowroot-central.service; fi
              </beforeInstallation>
              <!-- (re)start the collector upon upgrade assuming that it's already correctly configured -->
              <afterInstallation>
                systemctl daemon-reload
                systemd-tmpfiles --create /usr/lib/tmpfiles.d/glowroot-central.conf
                if [ $1 -eq 2 ] ; then systemctl start glowroot-central.service; fi
              </afterInstallation>
              <beforeRemoval>
                systemctl stop glowroot-central.service
              </beforeRemoval>
              <!-- remove glowroot user and group upon un-installation -->
              <afterRemoval>
                if [ $1 -eq 0 ] ; then userdel glowroot && groupdel glowroot 2> /dev/null; fi
                systemctl daemon-reload
              </afterRemoval>
              <rulesets>
                <ruleset>
                  <id>gc-default</id>
                  <rules>
                    <rule>
                      <user>root</user>
                      <group>root</group>
                    </rule>
                    <rule>
                      <when>
                        <type>directory</type>
                      </when>
                      <mode>0755</mode>
                    </rule>
                    <rule>
                      <when>
                        <type>file</type>
                      </when>
                      <mode>0644</mode>
                    </rule>
                    <rule>
                      <when>
                        <type>file</type>
                        <prefix>/etc/</prefix>
                      </when>
                      <configuration>true</configuration>
                      <noreplace>true</noreplace>
                      <mode>0640</mode>
                      <user>root</user>
                      <group>glowroot</group>
                    </rule>
                    <rule>
                      <when>
                        <type>file</type>
                        <prefix>/usr/share/doc/</prefix>
                      </when>
                      <documentation>true</documentation>
                    </rule>
                  </rules>
                </ruleset>
              </rulesets>
              <entries>
                <entry>
                  <name>/etc/glowroot-central</name>
                  <directory>true</directory>
                  <ruleset>gc-default</ruleset>
                </entry>
                <entry>
                  <name>/usr/share/doc/glowroot-central</name>
                  <directory>true</directory>
                  <ruleset>gc-default</ruleset>
                </entry>
                <entry>
                  <name>/usr/lib/glowroot-central</name>
                  <directory>true</directory>
                  <ruleset>gc-default</ruleset>
                </entry>
                <entry>
                  <name>/usr/lib/glowroot-central/lib</name>
                  <directory>true</directory>
                  <ruleset>gc-default</ruleset>
                </entry>
                <entry>
                  <name>/etc/glowroot-central/glowroot-central.properties</name>
                  <file>src/main/conf/glowroot-central.properties</file>
                  <ruleset>gc-default</ruleset>
                </entry>
                <entry>
                  <name>/usr/share/doc/glowroot-central/NOTICE</name>
                  <file>src/main/webapp/META-INF/NOTICE</file>
                  <ruleset>gc-default</ruleset>
                </entry>
                <entry>
                  <name>/usr/share/doc/glowroot-central/LICENSE</name>
                  <file>src/main/webapp/META-INF/LICENSE</file>
                  <ruleset>gc-default</ruleset>
                </entry>
                <entry>
                  <name>/usr/lib/glowroot-central/glowroot-central.properties</name>
                  <file>src/main/rpm/glowroot-central.properties</file>
                  <ruleset>gc-default</ruleset>
                </entry>
                <entry>
                  <name>/usr/lib/glowroot-central/${project.build.finalName}.jar</name>
                  <file>target/${project.build.finalName}.jar</file>
                  <ruleset>gc-default</ruleset>
                </entry>
                <entry>
                  <name>/usr/lib/glowroot-central/glowroot-central.jar</name>
                  <linkTo>${project.build.finalName}.jar</linkTo>
                  <ruleset>gc-default</ruleset>
                </entry>
                <entry>
                  <name>/usr/lib/glowroot-central/lib</name>
                  <collect>
                    <from>target/${project.build.finalName}-dist/glowroot-central/lib</from>
                  </collect>
                  <ruleset>gc-default</ruleset>
                </entry>
                <entry>
                  <name>/usr/lib/systemd/system/glowroot-central.service</name>
                  <file>src/main/rpm/glowroot-central.service</file>
                  <ruleset>gc-default</ruleset>
                  <configuration>true</configuration>
                </entry>
                <entry>
                  <name>/usr/lib/tmpfiles.d/glowroot-central.conf</name>
                  <file>src/main/rpm/glowroot-central.conf</file>
                  <ruleset>gc-default</ruleset>
                  <configuration>true</configuration>
                </entry>
              </entries>
            </configuration>
          </execution>
          <execution>
            <id>yum-repository</id>
            <goals>
              <goal>yum-repository</goal>
            </goals>
            <configuration>
              <directories>
                <directory>${project.build.directory}</directory>
              </directories>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>de.dentrassi.maven</groupId>
            <artifactId>rpm</artifactId>
            <version>1.8.0</version>
            <configuration>
              <signature>
                <keyringFile>${user.home}/.gnupg/secring.gpg</keyringFile>
              </signature>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
              <execution>
                <id>copy-yum-repo-file</id>
                <phase>package</phase>
                <goals>
                  <goal>copy-resources</goal>
                </goals>
                <configuration>
                  <outputDirectory>${project.build.directory}/yum</outputDirectory>
                  <resources>
                    <resource>
                      <directory>src/main/rpm</directory>
                      <includes>
                        <include>glowroot.repo</include>
                      </includes>
                      <filtering>true</filtering>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.6.0</version>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
                <configuration>
                  <executable>gpg</executable>
                  <arguments>
                    <argument>--armor</argument>
                    <argument>--out</argument>
                    <argument>target/yum/RPM-GPG-KEY-${gpg.key.id}</argument>
                    <argument>--yes</argument> <!-- overwrite without asking -->
                    <argument>--export</argument>
                    <argument>${gpg.key.id}</argument>
                  </arguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>


text:
require 'rake/tasklib'
require 'ansible-ruby'
require 'ansible/ruby/rake/task_util'

module Ansible
  module Ruby
    module Rake
      class Compile < ::Rake::TaskLib
        include TaskUtil

        # :reek:Attribute - Rake DSL gets ugly if we don't use a block
        attr_accessor :files

        def initialize(parameters = :default)
          self.class.load_rule
          name, deps = parse_params parameters
          yield self if block_given?
          raise 'You did not supply any files!' unless files && [*files].any?

          deps ||= []
          yml_filenames = yaml_filenames([*files])
          deps = [*deps] + yml_filenames
          task name => deps
        end

        class << self
          def load_rule
            return if @rule_done

            ::Rake.application.create_rule '.yml' => '.rb' do |filename|
              puts "Updating Ansible file #{filename.name} from #{filename.source}..."
              file_builder = Ansible::Ruby::DslBuilders::FileLevel.new
              exception = file_builder._handled_eval filename.source
              # Avoid lengthy stack trace
              raise exception if exception

              playbook = file_builder._result
              yml = Ansible::Ruby::Serializer.serialize playbook.to_h
              File.write filename.name, yml
            end
            @rule_done = true
          end
        end
      end
    end
  end
end

redpajama_set_name: RedPajamaGithub


text:
package me.aikin.refactoring.decorator.pattern;

public abstract class Beverage {
    private  boolean milk;
    private  boolean mocha;

    protected Beverage(boolean milk, boolean mocha) {
        this.milk = milk;
        this.mocha = mocha;
    }

    public boolean isMilk() {
        return milk;
    }

    public boolean isMocha() {
        return mocha;
    }

    public String getDescription() {
        return "";
    }

    public abstract double cost();
}


text:
const log = require('../util/log');
const MathUtil = require('../util/math-util');
const Target = require('../engine/target');

/**
 * Rendered target: instance of a sprite (clone), or the stage.
 * @param {!Sprite} sprite Reference to the parent sprite.
 * @param {Runtime} runtime Reference to the runtime.
 * @constructor
 */
class RenderedTarget extends Target {
    constructor (sprite, runtime) {
        super(sprite.blocks);
        this.runtime = runtime;
        /**
         * Reference to the sprite that this is a render of.
         * @type {!Sprite}
         */
        this.sprite = sprite;
        /**
         * Reference to the global renderer for this VM, if one exists.
         * @type {?RenderWebGLWorker}
         */
        this.renderer = null;
        if (this.runtime) {
            this.renderer = this.runtime.renderer;
        }
        /**
         * ID of the drawable for this rendered target,
         * returned by the renderer, if rendered.
         * @type {?Number}
         */
        this.drawableID = null;

        /**
         * Drag state of this rendered target. If true, x/y position can't be
         * changed by blocks.
         * @type {boolean}
         */
        this.dragging = false;

        /**
         * Map of current graphic effect values.
         * @type {!Object.<string, number>}
         */
        this.effects = {
            color: 0,
            fisheye: 0,
            whirl: 0,
            pixelate: 0,
            mosaic: 0,
            brightness: 0,
            ghost: 0
        };

        /**
         * Whether this represents an "original" non-clone rendered-target for a sprite,
         * i.e., created by the editor and not clone blocks.
         * @type {boolean}
         */
        this.isOriginal = true;

        this.isplug = false;

        /**
         * Whether this rendered target represents the Scratch stage.
         * @type {boolean}
         */
        this.isStage = false;

        /**
         * Scratch X coordinate. Currently should range from -240 to 240.
         * @type {Number}
         */
        this.x = 0;

        /**
         * Scratch Y coordinate. Currently should range from -180 to 180.
         * @type {number}
         */
        this.y = 0;

        /**
         * Scratch direction. Currently should range from -179 to 180.
         * @type {number}
         */
        this.direction = 90;

        /**
         * Whether the rendered target is draggable on the stage
         * @type {boolean}
         */
        this.draggable = false;

        /**
         * Whether the rendered target is currently visible.
         * @type {boolean}
         */
        this.visible = true;

        /**
         * Size of rendered target as a percent of costume size.
         * @type {number}
         */
        this.size = 100;

        /**
         * Currently selected costume index.
         * @type {number}
         */
        this.currentCostume = 0;

        /**
         * Current rotation style.
         * @type {!string}
         */
        this.rotationStyle = RenderedTarget.ROTATION_STYLE_ALL_AROUND;
    }

    /**
     * Create a drawable with the this.renderer.
     */
    initDrawable () {
        if (this.renderer) {
            this.drawableID = this.renderer.createDrawable();
        }
        // If we're a clone, start the hats.
        if (!this.isOriginal) {
            this.runtime.startHats(
                'control_start_as_clone', null, this
            );
        }

        /**
        * Audio player
        */
        this.audioPlayer = null;
        if (this.runtime && this.runtime.audioEngine) {
            this.audioPlayer = this.runtime.audioEngine.createPlayer();
        }
    }

    /**
     * Event which fires when a target moves.
     * @type {string}
     */
    static get EVENT_TARGET_MOVED () {
        return 'TARGET_MOVED';
    }

    /**
     * Rotation style for "all around"/spinning.
     * @type {string}
     */
    static get ROTATION_STYLE_ALL_AROUND () {
        return 'all around';
    }

    /**
     * Rotation style for "left-right"/flipping.
     * @type {string}
     */
    static get ROTATION_STYLE_LEFT_RIGHT () {
        return 'left-right';
    }

    /**
     * Rotation style for "no rotation."
     * @type {string}
     */
    static get ROTATION_STYLE_NONE () {
        return "don't rotate";
    }

    /**
     * Set the X and Y coordinates.
     * @param {!number} x New X coordinate, in Scratch coordinates.
     * @param {!number} y New Y coordinate, in Scratch coordinates.
     * @param {?boolean} force Force setting X/Y, in case of dragging
     */
    setXY (x, y, force) {
        if (this.isStage) return;
        if (this.dragging && !force) return;
        const oldX = this.x;
        const oldY = this.y;
        if (this.renderer) {
            const position = this.renderer.getFencedPositionOfDrawable(this.drawableID, [x, y]);
            this.x = position[0];
            this.y = position[1];

            this.renderer.updateDrawableProperties(this.drawableID, {
                position: position
            });
            if (this.visible) {
                this.runtime.requestRedraw();
            }
        } else {
            this.x = x;
            this.y = y;
        }
        this.emit(RenderedTarget.EVENT_TARGET_MOVED, this, oldX, oldY);
        this.runtime.requestTargetsUpdate(this);
    }

    //直接位置
    setPosition (x, y) {
        if (this.isStage) return;
        const oldX = this.x;
        const oldY = this.y;

        this.x = x;
        this.y = y;

        this.renderer.updateDrawableProperties(this.drawableID, {
            position: [x,y]
        });

        this.runtime.requestRedraw();

        this.emit(RenderedTarget.EVENT_TARGET_MOVED, this, oldX, oldY);
        this.runtime.requestTargetsUpdate(this);
    }
    /**
     * Get the rendered direction and scale, after applying rotation style.
     * @return {object<string, number>} Direction and scale to render.
     */
    _getRenderedDirectionAndScale () {
        // Default: no changes to `this.direction` or `this.scale`.
        let finalDirection = this.direction;
        let finalScale = [this.size, this.size];
        if (this.rotationStyle === RenderedTarget.ROTATION_STYLE_NONE) {
            // Force rendered direction to be 90.
            finalDirection = 90;
        } else if (this.rotationStyle === RenderedTarget.ROTATION_STYLE_LEFT_RIGHT) {
            // Force rendered direction to be 90, and flip drawable if needed.
            finalDirection = 90;
            const scaleFlip = (this.direction < 0) ? -1 : 1;
            finalScale = [scaleFlip * this.size, this.size];
        }
        return {direction: finalDirection, scale: finalScale};
    }

    /**
     * Set the direction.
     * @param {!number} direction New direction.
     */
    setDirection (direction) {
        if (this.isStage) {
            return;
        }
        // Keep direction between -179 and +180.
        this.direction = MathUtil.wrapClamp(direction, -179, 180);
        if (this.renderer) {
            const renderedDirectionScale = this._getRenderedDirectionAndScale();
            this.renderer.updateDrawableProperties(this.drawableID, {
                direction: renderedDirectionScale.direction,
                scale: renderedDirectionScale.scale
            });
            if (this.visible) {
                this.runtime.requestRedraw();
            }
        }
        this.runtime.requestTargetsUpdate(this);
    }

    /**
     * Set draggability; i.e., whether it's able to be dragged in the player
     * @param {!boolean} draggable True if should be draggable.
     */
    setDraggable (draggable) {
        if (this.isStage) return;
        this.draggable = !!draggable;
        this.runtime.requestTargetsUpdate(this);
    }

    /**
     * Set a say bubble.
     * @param {?string} type Type of say bubble: "say", "think", or null.
     * @param {?string} message Message to put in say bubble.
     */
    setSay (type, message) {
        if (this.isStage) {
            return;
        }
        // @todo: Render to stage.
        if (!type || !message) {
            log.info('Clearing say bubble');
            return;
        }
        log.info('Setting say bubble:', type, message);
    }

    /**
     * Set visibility; i.e., whether it's shown or hidden.
     * @param {!boolean} visible True if should be shown.
     */
    setVisible (visible) {
        if (this.isStage) {
            return;
        }
        this.visible = !!visible;
        if (this.renderer) {
            this.renderer.updateDrawableProperties(this.drawableID, {
                visible: this.visible
            });
            if (this.visible) {
                this.runtime.requestRedraw();
            }
        }
        this.runtime.requestTargetsUpdate(this);
    }

    /**
     * Set size, as a percentage of the costume size.
     * @param {!number} size Size of rendered target, as % of costume size.
     */
    setSize (size) {
        if (this.isStage) {
            return;
        }
        if (this.renderer) {
            // Clamp to scales relative to costume and stage size.
            // See original ScratchSprite.as:setSize.
            const costumeSize = this.renderer.getSkinSize(this.drawableID);
            const origW = costumeSize[0];
            const origH = costumeSize[1];
            const minScale = Math.min(1, Math.max(5 / origW, 5 / origH));
            const maxScale = Math.min(
                (1.5 * this.runtime.constructor.STAGE_WIDTH) / origW,
                (1.5 * this.runtime.constructor.STAGE_HEIGHT) / origH
            );
            this.size = MathUtil.clamp(size / 100, minScale, maxScale) * 100;
            const renderedDirectionScale = this._getRenderedDirectionAndScale();
            this.renderer.updateDrawableProperties(this.drawableID, {
                direction: renderedDirectionScale.direction,
                scale: renderedDirectionScale.scale
            });
            if (this.visible) {
                this.runtime.requestRedraw();
            }
            this.runtime.requestTargetsUpdate(this);
        }
    }

    /**
     * Set size, as a percentage of the costume size.
     * @param {!number} size Size of rendered target, as % of costume size.
     */
    setRotationCenter (x,y) {
        if (this.isStage) {
            return;
        }
        if (this.renderer) {
            // // Clamp to scales relative to costume and stage size.
            // // See original ScratchSprite.as:setSize.
            // const costumeSize = this.renderer.getSkinSize(this.drawableID);
            // const origW = costumeSize[0];
            // const origH = costumeSize[1];
            // const minScale = Math.min(1, Math.max(5 / origW, 5 / origH));
            // const maxScale = Math.min(
            //     (1.5 * this.runtime.constructor.STAGE_WIDTH) / origW,
            //     (1.5 * this.runtime.constructor.STAGE_HEIGHT) / origH
            // );
            // this.size = MathUtil.clamp(size / 100, minScale, maxScale) * 100;
            // const renderedDirectionScale = this._getRenderedDirectionAndScale();
            console.log('getBounds:',this.renderer.getBounds(this.drawableID));
            var rotationCenter = this.renderer.getSkinRotationCenter(this.drawableID)
            var x0 = this.x;
            var y0 = this.y;
            this.renderer.updateDrawableProperties(this.drawableID, {
                // rotationCenter: [x-bounds.left,bounds.top-y],
                rotationCenter: [x-(x0-rotationCenter[0]),y0+rotationCenter[1]-y]
            });
            // this.setPosition()

            if (this.visible) {
                this.runtime.requestRedraw();
            }
            this.runtime.requestTargetsUpdate(this);
        }
    }
    /**
     * Set a particular graphic effect value.
     * @param {!string} effectName Name of effect (see `RenderedTarget.prototype.effects`).
     * @param {!number} value Numerical magnitude of effect.
     */
    setEffect (effectName, value) {
        if (!this.effects.hasOwnProperty(effectName)) return;
        this.effects[effectName] = value;
        if (this.renderer) {
            const props = {};
            props[effectName] = this.effects[effectName];
            this.renderer.updateDrawableProperties(this.drawableID, props);
            if (this.visible) {
                this.runtime.requestRedraw();
            }
        }
    }

    /**
     * Clear all graphic effects on this rendered target.
     */
    clearEffects () {
        for (const effectName in this.effects) {
            if (!this.effects.hasOwnProperty(effectName)) continue;
            this.effects[effectName] = 0;
        }
        if (this.renderer) {
            this.renderer.updateDrawableProperties(this.drawableID, this.effects);
            if (this.visible) {
                this.runtime.requestRedraw();
            }
        }
    }

    /**
     * Set the current costume.
     * @param {number} index New index of costume.
     */
    setCostume (index) {
        // Keep the costume index within possible values.
        index = Math.round(index);
        this.currentCostume = MathUtil.wrapClamp(
            index, 0, this.sprite.costumes.length - 1
        );
        if (this.renderer) {
            const costume = this.sprite.costumes[this.currentCostume];
            const drawableProperties = {
                skinId: costume.skinId,
                costumeResolution: costume.bitmapResolution
            };
            if (
                typeof costume.rotationCenterX !== 'undefined' &&
                typeof costume.rotationCenterY !== 'undefined'
            ) {
                const scale = costume.bitmapResolution || 1;
                drawableProperties.rotationCenter = [
                    costume.rotationCenterX / scale,
                    costume.rotationCenterY / scale
                ];
            }
            this.renderer.updateDrawableProperties(this.drawableID, drawableProperties);
            if (this.visible) {
                this.runtime.requestRedraw();
            }
        }
        this.runtime.requestTargetsUpdate(this);
    }

    /**
     * Delete a costume by index.
     * @param {number} index Costume index to be deleted
     */
    deleteCostume (index) {
        const originalCostumeCount = this.sprite.costumes.length;
        if (originalCostumeCount === 1) return;

        this.sprite.costumes = this.sprite.costumes
            .slice(0, index)
            .concat(this.sprite.costumes.slice(index + 1));

        if (index === this.currentCostume && index === originalCostumeCount - 1) {
            this.setCostume(index - 1);
        } else if (index < this.currentCostume) {
            this.setCostume(this.currentCostume - 1);
        } else {
            this.setCostume(this.currentCostume);
        }

        this.runtime.requestTargetsUpdate(this);
    }

    /**
     * Delete a sound by index.
     * @param {number} index Sound index to be deleted
     */
    deleteSound (index) {
        this.sprite.sounds = this.sprite.sounds
            .slice(0, index)
            .concat(this.sprite.sounds.slice(index + 1));
        this.runtime.requestTargetsUpdate(this);
    }

    /**
     * Update the rotation style.
     * @param {!string} rotationStyle New rotation style.
     */
    setRotationStyle (rotationStyle) {
        if (rotationStyle === RenderedTarget.ROTATION_STYLE_NONE) {
            this.rotationStyle = RenderedTarget.ROTATION_STYLE_NONE;
        } else if (rotationStyle === RenderedTarget.ROTATION_STYLE_ALL_AROUND) {
            this.rotationStyle = RenderedTarget.ROTATION_STYLE_ALL_AROUND;
        } else if (rotationStyle === RenderedTarget.ROTATION_STYLE_LEFT_RIGHT) {
            this.rotationStyle = RenderedTarget.ROTATION_STYLE_LEFT_RIGHT;
        }
        if (this.renderer) {
            const renderedDirectionScale = this._getRenderedDirectionAndScale();
            this.renderer.updateDrawableProperties(this.drawableID, {
                direction: renderedDirectionScale.direction,
                scale: renderedDirectionScale.scale
            });
            if (this.visible) {
                this.runtime.requestRedraw();
            }
        }
        this.runtime.requestTargetsUpdate(this);
    }

    /**
     * Get a costume index of this rendered target, by name of the costume.
     * @param {?string} costumeName Name of a costume.
     * @return {number} Index of the named costume, or -1 if not present.
     */
    getCostumeIndexByName (costumeName) {
        for (let i = 0; i < this.sprite.costumes.length; i++) {
            if (this.sprite.costumes[i].name === costumeName) {
                return i;
            }
        }
        return -1;
    }

    /**
     * Get a costume of this rendered target by id.
     * @return {object} current costume
     */
    getCurrentCostume () {
        return this.sprite.costumes[this.currentCostume];
    }

    /**
     * Get full costume list
     * @return {object[]} list of costumes
     */
    getCostumes () {
        return this.sprite.costumes;
    }

    /**
     * Get full sound list
     * @return {object[]} list of sounds
     */
    getSounds () {
        return this.sprite.sounds;
    }

    /**
     * Update all drawable properties for this rendered target.
     * Use when a batch has changed, e.g., when the drawable is first created.
     */
    updateAllDrawableProperties () {
        if (this.renderer) {
            const renderedDirectionScale = this._getRenderedDirectionAndScale();
            const costume = this.sprite.costumes[this.currentCostume];
            const bitmapResolution = costume.bitmapResolution || 1;
            const props = {
                position: [this.x, this.y],
                direction: renderedDirectionScale.direction,
                draggable: this.draggable,
                scale: renderedDirectionScale.scale,
                visible: this.visible,
                skinId: costume.skinId,
                costumeResolution: bitmapResolution,
                rotationCenter: [
                    costume.rotationCenterX / bitmapResolution,
                    costume.rotationCenterY / bitmapResolution
                ]
            };
            for (const effectName in this.effects) {
                if (!this.effects.hasOwnProperty(effectName)) continue;
                props[effectName] = this.effects[effectName];
            }
            this.renderer.updateDrawableProperties(this.drawableID, props);
            if (this.visible) {
                this.runtime.requestRedraw();
            }
        }
        this.runtime.requestTargetsUpdate(this);
    }

    /**
     * Return the human-readable name for this rendered target, e.g., the sprite's name.
     * @override
     * @returns {string} Human-readable name.
     */
    getName () {
        return this.sprite.name;
    }

    /**
     * Return whether this rendered target is a sprite (not a clone, not the stage).
     * @return {boolean} True if not a clone and not the stage.
     */
    isSprite () {
        return !this.isStage && this.isOriginal;
    }

    /**
     * Return the rendered target's tight bounding box.
     * Includes top, left, bottom, right attributes in Scratch coordinates.
     * @return {?object} Tight bounding box, or null.
     */
    getBounds () {
        if (this.renderer) {
            return this.runtime.renderer.getBounds(this.drawableID);
        }
        return null;
    }

    /**
     * Return whether touching a point.
     * @param {number} x X coordinate of test point.
     * @param {number} y Y coordinate of test point.
     * @return {boolean} True iff the rendered target is touching the point.
     */
    isTouchingPoint (x, y) {
        if (this.renderer) {
            // @todo: Update once pick is in Scratch coordinates.
            // Limits test to this Drawable, so this will return true
            // even if the clone is obscured by another Drawable.
            const pickResult = this.runtime.renderer.pick(
                x + (this.runtime.constructor.STAGE_WIDTH / 2),
                -y + (this.runtime.constructor.STAGE_HEIGHT / 2),
                null, null,
                [this.drawableID]
            );
            return pickResult === this.drawableID;
        }
        return false;
    }

    /**
     * Return whether touching a stage edge.
     * @return {boolean} True iff the rendered target is touching the stage edge.
     */
    isTouchingEdge () {
        if (this.renderer) {
            const stageWidth = this.runtime.constructor.STAGE_WIDTH;
            const stageHeight = this.runtime.constructor.STAGE_HEIGHT;
            const bounds = this.getBounds();
            if (bounds.left < -stageWidth / 2 ||
                bounds.right > stageWidth / 2 ||
                bounds.top > stageHeight / 2 ||
                bounds.bottom < -stageHeight / 2) {
                return true;
            }
        }
        return false;
    }

    /**
     * Return whether touching any of a named sprite's clones.
     * @param {string} spriteName Name of the sprite.
     * @return {boolean} True iff touching a clone of the sprite.
     */
    isTouchingSprite (spriteName) {
        const firstClone = this.runtime.getSpriteTargetByName(spriteName);
        if (!firstClone || !this.renderer) {
            return false;
        }
        const drawableCandidates = firstClone.sprite.clones.map(clone => clone.drawableID);
        return this.renderer.isTouchingDrawables(
            this.drawableID, drawableCandidates);
    }

    /**
     * Return whether touching a color.
     * @param {Array.<number>} rgb [r,g,b], values between 0-255.
     * @return {Promise.<boolean>} True iff the rendered target is touching the color.
     */
    isTouchingColor (rgb) {
        if (this.renderer) {
            return this.renderer.isTouchingColor(this.drawableID, rgb);
        }
        return false;
    }

    /**
     * Return whether rendered target's color is touching a color.
     * @param {object} targetRgb {Array.<number>} [r,g,b], values between 0-255.
     * @param {object} maskRgb {Array.<number>} [r,g,b], values between 0-255.
     * @return {Promise.<boolean>} True iff the color is touching the color.
     */
    colorIsTouchingColor (targetRgb, maskRgb) {
        if (this.renderer) {
            return this.renderer.isTouchingColor(
                this.drawableID,
                targetRgb,
                maskRgb
            );
        }
        return false;
    }

    /**
     * Move to the front layer.
     */
    goToFront () {
        if (this.renderer) {
            this.renderer.setDrawableOrder(this.drawableID, Infinity);
        }
    }

    /**
     * Move back a number of layers.
     * @param {number} nLayers How many layers to go back.
     */
    goBackLayers (nLayers) {
        if (this.renderer) {
            this.renderer.setDrawableOrder(this.drawableID, -nLayers, true, 1);
        }
    }

    /**
     * Move behind some other rendered target.
     * @param {!RenderedTarget} other Other rendered target to move behind.
     */
    goBehindOther (other) {
        if (this.renderer) {
            const otherLayer = this.renderer.setDrawableOrder(
                other.drawableID, 0, true);
            this.renderer.setDrawableOrder(this.drawableID, otherLayer);
        }
    }

    /**
     * Keep a desired position within a fence.
     * @param {number} newX New desired X position.
     * @param {number} newY New desired Y position.
     * @param {object=} optFence Optional fence with left, right, top bottom.
     * @return {Array.<number>} Fenced X and Y coordinates.
     */
    keepInFence (newX, newY, optFence) {
        let fence = optFence;
        if (!fence) {
            fence = {
                left: -this.runtime.constructor.STAGE_WIDTH / 2,
                right: this.runtime.constructor.STAGE_WIDTH / 2,
                top: this.runtime.constructor.STAGE_HEIGHT / 2,
                bottom: -this.runtime.constructor.STAGE_HEIGHT / 2
            };
        }
        const bounds = this.getBounds();
        if (!bounds) return;
        // Adjust the known bounds to the target position.
        bounds.left += (newX - this.x);
        bounds.right += (newX - this.x);
        bounds.top += (newY - this.y);
        bounds.bottom += (newY - this.y);
        // Find how far we need to move the target position.
        let dx = 0;
        let dy = 0;
        if (bounds.left < fence.left) {
            dx += fence.left - bounds.left;
        }
        if (bounds.right > fence.right) {
            dx += fence.right - bounds.right;
        }
        if (bounds.top > fence.top) {
            dy += fence.top - bounds.top;
        }
        if (bounds.bottom < fence.bottom) {
            dy += fence.bottom - bounds.bottom;
        }
        return [newX + dx, newY + dy];
    }

    /**
     * Make a clone, copying any run-time properties.
     * If we've hit the global clone limit, returns null.
     * @return {RenderedTarget} New clone.
     */
    makeClone () {
        if (!this.runtime.clonesAvailable() || this.isStage) {
            return null; // Hit max clone limit, or this is the stage.
        }
        this.runtime.changeCloneCounter(1);
        const newClone = this.sprite.createClone();
        // Copy all properties.
        newClone.x = this.x;
        newClone.y = this.y;
        newClone.direction = this.direction;
        newClone.draggable = this.draggable;
        newClone.visible = this.visible;
        newClone.size = this.size;
        newClone.currentCostume = this.currentCostume;
        newClone.rotationStyle = this.rotationStyle;
        newClone.effects = JSON.parse(JSON.stringify(this.effects));
        newClone.variables = JSON.parse(JSON.stringify(this.variables));
        newClone.lists = JSON.parse(JSON.stringify(this.lists));
        newClone._customState = JSON.parse(JSON.stringify(this._customState));
        newClone.initDrawable();
        newClone.updateAllDrawableProperties();
        // Place behind the current target.
        newClone.goBehindOther(this);
        return newClone;
    }

    /**
     * Called when the project receives a "green flag."
     * For a rendered target, this clears graphic effects.
     */
    onGreenFlag () {
        this.clearEffects();
    }

    /**
     * Called when the project receives a "stop all"
     * Stop all sounds and clear graphic effects.
     */
    onStopAll () {
        this.clearEffects();
        if (this.audioPlayer) {
            this.audioPlayer.stopAllSounds();
            this.audioPlayer.clearEffects();
        }
    }

    /**
     * Post/edit sprite info.
     * @param {object} data An object with sprite info data to set.
     */
    postSpriteInfo (data) {
        const force = data.hasOwnProperty('force') ? data.force : null;
        if (data.hasOwnProperty('x')) {
            this.setXY(data.x, this.y, force);
        }
        if (data.hasOwnProperty('y')) {
            this.setXY(this.x, data.y, force);
        }
        if (data.hasOwnProperty('direction')) {
            this.setDirection(data.direction);
        }
        if (data.hasOwnProperty('draggable')) {
            this.setDraggable(data.draggable);
        }
        if (data.hasOwnProperty('rotationStyle')) {
            this.setRotationStyle(data.rotationStyle);
        }
        if (data.hasOwnProperty('visible')) {
            this.setVisible(data.visible);
        }
        if (data.hasOwnProperty('size')) {
            this.setSize(data.size);
        }
    }

    /**
     * Put the sprite into the drag state. While in effect, setXY must be forced
     */
    startDrag () {
        this.dragging = true;
    }

    /**
     * Remove the sprite from the drag state.
     */
    stopDrag () {
        this.dragging = false;
    }

    /**
     * Serialize sprite info, used when emitting events about the sprite
     * @returns {object} Sprite data as a simple object
     */
    toJSON () {
        const costumes = this.getCostumes();
        return {
            id: this.id,
            name: this.getName(),
            isStage: this.isStage,
            x: this.x,
            y: this.y,
            size: this.size,
            direction: this.direction,
            draggable: this.draggable,
            currentCostume: this.currentCostume,
            costume: costumes[this.currentCostume],
            costumeCount: costumes.length,
            visible: this.visible,
            rotationStyle: this.rotationStyle,
            blocks: this.blocks._blocks,
            variables: this.variables,
            messages: this.messages,
            lists: this.lists,
            costumes: costumes,
            sounds: this.getSounds()
        };
    }

    /**
     * Dispose, destroying any run-time properties.
     */
    dispose () {
        this.runtime.changeCloneCounter(-1);
        this.runtime.stopForTarget(this);
        this.sprite.removeClone(this);
        if (this.renderer && this.drawableID !== null) {
            this.renderer.destroyDrawable(this.drawableID);
            if (this.visible) {
                this.runtime.requestRedraw();
            }
        }
    }
}

module.exports = RenderedTarget;


text:
define(["lodash", "untar", "../build/dist/untar"], function(_, untarDev, untarDist) {

    function loadFile(path) {
        return new Promise(function(resolve, reject) {
            var r = new XMLHttpRequest();

            r.onload = function(e) {
                if (r.status >= 200 && r.status < 400) {
                    var buffer = r.response;
                    resolve(buffer);
                } else {
                    reject(r.status + " " + r.statusText);
                }
            };

            r.open("GET", path);
            r.responseType = "arraybuffer";
            r.send();
        });
    }

    function loadTestBuffer() {
        return loadFile("base/spec/data/test.tar");
    }

    function loadPaxTestBuffer() {
        return loadFile("base/spec/data/test-pax.tar");
    }

    function loadTestFile(filename) {
        return loadFile("base/spec/data/" + filename);
    }

    var fileNames = [
        "1.txt",
        "2.txt",
        "3.txt",
        "511.txt",
        "512.txt",
        "513.txt",
        "directory/",
        "directory/1.txt",
        "directory/2.txt",
        "directory/3.txt",
        "object.json"
    ];

    var fileContent = [
        function(ct) { return ct === "one"; },
        function(ct) { return ct === "two"; },
        function(ct) { return ct === "three"; },
        function(ct) { return ct.length === 511; },
        function(ct) { return ct.length === 512; },
        function(ct) { return ct.length === 513; },
        function(ct) { return ct === ""; },
        function(ct) { return ct === "one"; },
        function(ct) { return ct === "two"; },
        function(ct) { return ct === "three"; },
        function(ct) { return ct === '{"prop":"value"}'; }
    ];

	var tests = function(untar) {

		return function() {
			it("should unpack 4 specific files and a directory with 3 specific files", function(done) {
				expect(typeof untar).toBe("function");

				var i = 0;

				loadTestBuffer().then(function(buffer) {
					untar(buffer).then(
						function(files) {
                            //console.log(files.map(function(f) { return f.name; }));
							expect(i).toBe(fileNames.length);
							expect(files.length).toBe(fileNames.length);
							done();
						},
						function(err) {
							done.fail(err.message);
						},
						function(file) {
							expect(file).toBeDefined();
							expect(file.name).toBe(fileNames[i]);
							i += 1;
						}
					);
				}, done.fail);
			}, 20000);

			it("should throw when not called with an ArrayBuffer", function() {
				expect(untar).toThrow();
				expect(function() { untar("test"); }).toThrow();
			});

			it("should support PAX headers", function(done) {
				loadPaxTestBuffer().then(
				    function(buffer) {
                        return untar(buffer)
                            .then(function(files) {
                                expect(files.length).toBe(1);
                                expect(files[0].name).toBe("é.txt");
                            })
                            .then(done, done.fail);
				    },
                    done.fail
                );
			}, 10000);

			it("should support USTAR format", function(done) {
				loadTestFile("test-ustar.tar").then(
				    function(buffer) {
                        return untar(buffer)
                            .then(function(files) {
                                expect(files.length).toBe(1);
                                expect(files[0].name).toBe("foo");
                            })
                            .then(done, done.fail);
				    },
                    done.fail
                );
			}, 10000);

			it("should support USTAR format with long names", function(done) {
				loadTestFile("test-ustar-with-prefix.tar").then(
				    function(buffer) {
                        return untar(buffer)
                            .then(function(files) {
                                expect(files.length).toBe(1);
                                expect(files[0].name).toBe(
                                    "directory-000/directory-001/directory-002/directory-003/directory-004/directory-005/directory-006/foo.txt"
                                );
                            })
                            .then(done, done.fail);
				    },
                    done.fail
                );
			}, 10000);

			describe("UntarFile", function() {

				describe("readAsString()", function() {
					it("should read contents as a string", function(done) {
						var i = 0;

						loadTestBuffer().then(function(buffer) {
							untar(buffer)
							.progress(function(file) {
								expect(fileContent[i++](file.readAsString())).toBe(true);
							})
							.then(done);
						});
					});
				});

				describe("readAsJSON()", function() {
					it("should read file contents as a JSON object", function(done) {
						loadTestBuffer().then(function(buffer) {
							untar(buffer)
							.progress(function(file) {
								if (/\.json$/.test(file.name)) {
									var o;
									expect(function() { o = file.readAsJSON(); }).not.toThrow();
									expect(o).toEqual({ prop: "value" });
								}
							})
							.then(done);
						});
					});
				});

				describe("getBlobUrl()", function() {
					it("should return a unique ObjectURL for each file.", function(done) {
						return loadTestBuffer().then(function(buffer) {
							return untar(buffer)
							.then(function(files) {
								//console.debug("'getBlobUrl() should return a unique ObjectURL for each file' loaded and untar'ed the test buffer.");

								var urls = _.map(files, function(file) { return file.getBlobUrl(); });

								expect(_.some(urls, function(url) { return url === null; } )).toBe(false);

								expect(_.uniq(urls).length).toBe(urls.length);

								urlsCopy = _.map(files, function(file) { return file.getBlobUrl(); });
								expect(urlsCopy).toEqual(urls);

								//console.debug("'getBlobUrl() should return a unique ObjectURL for each file' ran all expectations");
							});
						})
						.then(done)
						.catch(done.fail);
					});
				});

			});
		};
	};

	describe("untarDev", tests(untarDev));
	describe("untarDist", tests(untarDist));

});


text:
struct SkeletonManager final
{
  static dart::dynamics::Skeleton* create(const std::string& name);
  // TODO(JS): Make as a template

  static void destroy(dart::dynamics::Skeleton* skel);

  static void destroy(void* skel);

  static dart::dynamics::SkeletonPtr asShared(dart::dynamics::Skeleton* skel);

  static dart::dynamics::SkeletonPtr asShared(void* skel);

  static std::unordered_map<dart::dynamics::Skeleton*,
                            dart::dynamics::SkeletonPtr>
      mMap;
};


text:
layout: page
category: projects
hidden: true
modal-id: 9
date: 2017-01-09
img: techtutoring.png
alt: Tech-Tutoring
project-date: Since Summer 2016
client: Personal
service: Community Service Oriented with Web Development
description: Tech Tutoring is a not-for-profit organization I created in Summer 2016 that aims to bridge the gap between the older generation and millennials.
We accomplish our mission by teaching senior citizens ways to choose the device that best suits them and learn how to use it, set up and be confident with software like Skype, and gain a better knowledge of everything from Email to Social Media.
Check out the live website right here!
---


text:
<?php

namespace Ts\SearchBundle\Domain;

class IncomingLinkTextCollection extends AbstractCollection {

    /**
     * @param IncomingLinkText $linkText
     */
    public function set(IncomingLinkText $linkText) {
        $this->storage->offsetSet($linkText->getLinkText(),$linkText);
    }

    /**
     * @param string $linkText
     * @return IncomingLinkText
     */
    public function getByLinkText($linkText) {
        return $this->storage->offsetGet($linkText);
    }

    /**
     * @param $linkText
     * @return bool
     */
    public function hasLinkText($linkText) {
        return $this->storage->offsetExists($linkText);
    }

    /**
     * @return int
     */
    public function getCount() {
        return $this->storage->count();
    }

    /**
     * @return array
     */
    public function getAsArray() {
        return $this->storage->getArrayCopy();
    }
}


text:
define(['./toArray', '../array/find'], function (toArray, find) {

    /**
     * Return first non void argument
     */
    function defaults(var_args){
        return find(toArray(arguments), nonVoid);
    }

    function nonVoid(val){
        return val != null;
    }

    return defaults;

});


text:
'''
    The runner module is automatically generated by the RMAS Adapter framework.
    You can run this module directly::

         python runner.py

    which will call the run function for you or you can call the run function directly from elsewhere.
'''

import os
import logging

def run():
    '''
        This function starts the lifecycle consumer which will start
        listening for OpenEthics lifecycle events, and then it will start
        polling the RMAS ESB for RMAS events (polling is blocking so you must
        start the liefecycle consumer first).
    '''
    #this has to come first before you import any other modules otherwsise the settings won't be intitialized
    os.environ.setdefault("RMAS_ADAPTER_SETTINGS", "rmas_oe_adapter.settings")

    logging.basicConfig(level=logging.INFO)

    from rmas_adapter.core.poller import start_polling
    from rmas_oe_adapter import lifecycle_consumer

    lifecycle_consumer.connect()#start listening for oe lifecycle events
    start_polling()#start polling for rmas events

if __name__ == '__main__':
    run()


text:
package com.twister;

//configuration class used in Item to represent configurations
public class Configuration implements Cloneable{
	private boolean enabled = true;
	private boolean ieratorOD,iteratorSOF;//OD-onlyDefault,SOF-stoponfail
	private String file;
	private boolean isFromSuite = false;

	public Configuration(String file){
		this.file = file;
	}

	public boolean isEnabled() {
		return enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	public boolean isIeratorOD() {
		return ieratorOD;
	}

	public void setIeratorOD(boolean ieratorOD) {
		this.ieratorOD = ieratorOD;
	}

	public boolean isIteratorSOF() {
		return iteratorSOF;
	}

	public void setIteratorSOF(boolean iteratorSOF) {
		this.iteratorSOF = iteratorSOF;
	}

	public String getFile() {
		return file;
	}

	public void setFile(String file) {
		this.file = file;
	}

	public boolean isFromSuite() {
		return isFromSuite;
	}

	public void setFromSuite(boolean isFromSuite) {
		this.isFromSuite = isFromSuite;
	}

	public Configuration clone(){
		try{Configuration clone = (Configuration)super.clone();
        	return clone;}
    catch(CloneNotSupportedException e){
        e.printStackTrace();
        return null;}
	}
}


text:
/*

	Licensed under the Apache License, Version 2.0 (the "License");
	you may not use this file except in compliance with the License.
	You may obtain a copy of the License at

	    http://www.apache.org/licenses/LICENSE-2.0

	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
*/

insert ignore into role (name, description, priv_level) values ('migrations','Migrations User', 20);
insert ignore into tm_user (username,role,full_name) values ('migration',(select id from role where name='migrations'),'migrations user - DO NOT REMOVE');


text:
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined")

#elif defined(BOOST_ENDIAN_NO_INTRINSICS) && defined(BOOST_NO_CXX14_CONSTEXPR)

BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_ENDIAN_NO_INTRINSICS and BOOST_NO_CXX14_CONSTEXPR are defined")

#elif !defined(BOOST_ENDIAN_NO_INTRINSICS) && !defined(BOOST_ENDIAN_CONSTEXPR_INTRINSICS)

BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_ENDIAN_NO_INTRINSICS and BOOST_ENDIAN_CONSTEXPR_INTRINSICS are not defined")

#else

using namespace boost::endian;

#define STATIC_ASSERT(expr) static_assert(expr, #expr)

STATIC_ASSERT( endian_reverse( static_cast<boost::uint8_t>( 0x01 ) ) == 0x01 );
STATIC_ASSERT( endian_reverse( static_cast<boost::uint16_t>( 0x0102 ) ) == 0x0201 );
STATIC_ASSERT( endian_reverse( static_cast<boost::uint32_t>( 0x01020304 ) ) == 0x04030201 );
STATIC_ASSERT( endian_reverse( static_cast<boost::uint64_t>( 0x0102030405060708 ) ) == 0x0807060504030201 );

STATIC_ASSERT( big_to_native( native_to_big( 0x01020304 ) ) == 0x01020304 );
STATIC_ASSERT( little_to_native( native_to_little( 0x01020304 ) ) == 0x01020304 );

STATIC_ASSERT( native_to_big( 0x01020304 ) == (conditional_reverse<order::native, order::big>( 0x01020304 )) );
STATIC_ASSERT( native_to_big( 0x01020304 ) == conditional_reverse( 0x01020304, order::native, order::big ) );

#endif


text:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
	<title>The Statistics View</title>
	<link href="css/task_style.css" rel="stylesheet" media="all" />

		MiniBatteryLogger Help

The Statistics View

			The Statistics View contains a list of battery “snapshots”,
			that is, a list of records of the maximum capacity and cycle count ordered by date.

			Snapshots are plotted to the chart in the upper half of the window. The increasing blue graph
			plots the cycle count versus time, while the decreasing red graph plots the max capacity versus time.
			Additionally, a dotted orange line represents the regression line of the capacity. It is a linear
			approximation of the capacity graph.

			Snapshots are automatically saved when a property of your battery has changed,
			so you don’t have to bother saving them by hand. Snapshots can
			always be added and removed manually.

			You can add a custom note to a snapshot, e.g. “Initial value”
			or “Reached 100th cycle”.

			The chart can be copied to the pasteboard or dragged as an image.

				To add a comment to a snapshot, double click on the table cell.

				To add or remove a snapshot, use the paired buttons on the bottom
				of the window.

See also

		The Log View

		The Chart View

		The Comparison View

		User Preferences

		Keyboard Shortcuts


text:
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
    <id>com.criteriastudio.uxlibrary</id>
    <name>UXLibrary</name>
    <version>1.0</version>
    <publisher>criteriastudio</publisher>
    <url>http://</url>
    <description>not specified</description>
    <copyright>2014 by criteriastudio</copyright>
    <icon>appicon.png</icon>
    <persistent-wifi>false</persistent-wifi>
    <prerendered-icon>false</prerendered-icon>
    <statusbar-style>default</statusbar-style>
    <statusbar-hidden>false</statusbar-hidden>
    <fullscreen>false</fullscreen>
    <navbar-hidden>false</navbar-hidden>
    <analytics>true</analytics>
    <guid>6d0551da-489b-4079-9eee-158d356aa75e</guid>
    <property name="ti.ui.defaultunit" type="string">dip</property>
    <iphone>
        <min-ios-ver>6.0</min-ios-ver>
        <orientations device="iphone">
            <orientation>Ti.UI.PORTRAIT</orientation>
        </orientations>
        <orientations device="ipad">
            <orientation>Ti.UI.PORTRAIT</orientation>
            <orientation>Ti.UI.UPSIDE_PORTRAIT</orientation>
            <orientation>Ti.UI.LANDSCAPE_LEFT</orientation>
            <orientation>Ti.UI.LANDSCAPE_RIGHT</orientation>
        </orientations>
    </iphone>
    <android xmlns:android="http://schemas.android.com/apk/res/android"/>
    <mobileweb>
        <precache/>
        <splash>
            <enabled>true</enabled>
            <inline-css-images>true</inline-css-images>
        </splash>
        <theme>default</theme>
    </mobileweb>
    <modules>
        <module platform="iphone">ti.map</module>
        <module platform="android">ti.map</module>
    </modules>
    <deployment-targets>
        <target device="android">true</target>
        <target device="blackberry">false</target>
        <target device="ipad">false</target>
        <target device="iphone">true</target>
        <target device="mobileweb">false</target>
        <target device="tizen">false</target>
    </deployment-targets>
    <sdk-version>4.0.0.GA</sdk-version>
    <plugins>
        <plugin version="1.0">ti.alloy</plugin>
    </plugins>
    <property name="appc-app-id" type="string">55ae7fbcde87edb862d35f84</property>
</ti:app>


text:
from .token_resource import (
    TokenResource
)

__all__ = [
    "TokenResource"
]


text:
@interface ZKDescribeQuickActionListResult()
@property (strong,nonatomic) NSArray<ZKDescribeQuickActionListItemResult *>  *quickActionListItems__v;
@end

@implementation ZKDescribeQuickActionListResult

+(void)load {
    [self registerType:self xmlName:@"DescribeQuickActionListResult"];
}

+(ZKComplexTypeInfo *)wsdlSchema {
   static ZKComplexTypeInfo *wsdlSchema;
   static dispatch_once_t onceToken;
   dispatch_once(&onceToken, ^{
       wsdlSchema = [[ZKComplexTypeInfo alloc] initWithType:@"DescribeQuickActionListResult" parent:nil
                    fields:@[
                        [[ZKComplexTypeFieldInfo alloc] initWithElementName:@"quickActionListItems" propertyName:@"quickActionListItems" optional:YES nillable:NO],

                    ]];
   });
   return wsdlSchema;
}

-(NSArray<ZKDescribeQuickActionListItemResult *> *)quickActionListItems {
    if ((fields__set[0] & 0x1) == 0) {
        self.quickActionListItems__v = [self complexTypeArrayFromElements:@"quickActionListItems" cls:[ZKDescribeQuickActionListItemResult class]];
        fields__set[0] |= 0x1;
    }
    return self.quickActionListItems__v;
}

-(void)setQuickActionListItems:(NSArray<ZKDescribeQuickActionListItemResult *> *)v {
    self.quickActionListItems__v = v;
    fields__set[0] |= 0x1;
}

-(void)serializeTo:(ZKXmlWriter *)env elemName:(NSString *)elemName {
	[env startElement:elemName];
	[env addElementArray:@"quickActionListItems" elemValue:self.quickActionListItems];
	[env endElement:elemName];
}
@end


text:
namespace content {
class WebContents;
}

namespace resource_coordinator {
namespace {

class MockLoadingStateHelper : public TabLoadTracker::Observer {
 public:
  MockLoadingStateHelper() {
    resource_coordinator::TabLoadTracker::Get()->AddObserver(this);
  }
  ~MockLoadingStateHelper() override {
    resource_coordinator::TabLoadTracker::Get()->RemoveObserver(this);
  }

  MOCK_METHOD(void,
              OnLoadingStateChange,
              (content::WebContents * web_contents,
               LoadingState old_loading_state,
               LoadingState new_loading_state),
              (override));
};

}  // namespace

class TabHelperBrowserTest : public InProcessBrowserTest {
 public:
  TabHelperBrowserTest()
      : prerender_test_helper_(
            base::BindRepeating(&TabHelperBrowserTest::GetWebContents,
                                base::Unretained(this))) {}
  ~TabHelperBrowserTest() override = default;

  void SetUp() override {
    prerender_test_helper_.SetUp(embedded_test_server());
    InProcessBrowserTest::SetUp();
  }

  void SetUpOnMainThread() override {
    test_server_handle_ = embedded_test_server()->StartAndReturnHandle();
  }

  content::test::PrerenderTestHelper& prerender_helper() {
    return prerender_test_helper_;
  }

  content::WebContents* GetWebContents() {
    return browser()->tab_strip_model()->GetActiveWebContents();
  }

  void WaitForTabsToLoad() {
    resource_coordinator::WaitForTransitionToLoaded(GetWebContents());
  }

 private:
  content::test::PrerenderTestHelper prerender_test_helper_;
  net::test_server::EmbeddedTestServerHandle test_server_handle_;
};

// Tests that `ukm_source_id_` from ResourceCoordinatorTabHelper is updated and
// used only with the active page loading. Since `ukm_source_id_` is used in
// TabManagerStatsCollector::OnTabIsLoaded() triggered by
// OnLoadingStateChange(), this test checks that OnLoadingStateChange() is not
// called in prerendering.
IN_PROC_BROWSER_TEST_F(TabHelperBrowserTest,
                       TabHelperBrowserTestInPrerendering) {
  // Ensure that state change for the previous loading is completed.
  WaitForTabsToLoad();

  // Initial navigation.
  MockLoadingStateHelper mock_loading_state_helper;
  GURL initial_url = embedded_test_server()->GetURL("/empty.html");
  // The state is changed twice from LOADED to LOADING and from LOADING to
  // LOADED.
  EXPECT_CALL(mock_loading_state_helper, OnLoadingStateChange).Times(2);
  ASSERT_NE(ui_test_utils::NavigateToURL(browser(), initial_url), nullptr);
  resource_coordinator::ResourceCoordinatorTabHelper* observer =
      resource_coordinator::ResourceCoordinatorTabHelper::FromWebContents(
          GetWebContents());
  WaitForTabsToLoad();
  ukm::SourceId initial_source_id = observer->ukm_source_id();
  // UKM source id is updated by the initial loading.
  DCHECK_NE(initial_source_id, ukm::kInvalidSourceId);

  // Load a page in the prerender.
  GURL prerender_url = embedded_test_server()->GetURL("/title1.html");
  // The prerendering doesn't trigger any loading state change.
  EXPECT_CALL(mock_loading_state_helper, OnLoadingStateChange).Times(0);
  prerender_helper().AddPrerender(prerender_url);
  // The source id should not be updated in prerendering.
  DCHECK_EQ(initial_source_id, observer->ukm_source_id());

  // The state is changed twice from LOADED to LOADING and from LOADING to
  // LOADED.
  EXPECT_CALL(mock_loading_state_helper, OnLoadingStateChange).Times(2);
  // Activate the prerendered page.
  prerender_helper().NavigatePrimaryPage(prerender_url);
  WaitForTabsToLoad();
  // The source id should be updated by changing primary page.
  DCHECK_NE(initial_source_id, observer->ukm_source_id());
}

}  // namespace resource_coordinator


text:
from . import views

def register_in(router):
    router.register(
        r'digitalocean-images', views.ImageViewSet, basename='digitalocean-image'
    )
    router.register(
        r'digitalocean-regions', views.RegionViewSet, basename='digitalocean-region'
    )
    router.register(
        r'digitalocean-sizes', views.SizeViewSet, basename='digitalocean-size'
    )
    router.register(
        r'digitalocean-droplets', views.DropletViewSet, basename='digitalocean-droplet'
    )