text:
package ca.ualberta.papaya;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;

import com.google.android.gms.maps.model.LatLng;

import ca.ualberta.papaya.controllers.AddThingController;
import ca.ualberta.papaya.controllers.EditThingController;
import ca.ualberta.papaya.controllers.ThingListController;
import ca.ualberta.papaya.models.Photo;

/**
 * Activity for adding Thing objects.
 *
 * Calls AddThingController for all of the button implementations.
 * @see AddThingController
 *
 */
public class AddThingActivity extends AbstractPapayaActivity {

    private Bitmap picture = null;
    public static final int PHOTO_RESULT = 10;
    ImageView imageView;
    private LatLng location = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_item);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setDisplayShowTitleEnabled(false);

        }

        toolbar.setNavigationIcon(R.drawable.ic_action_home);

        imageView = (ImageButton) findViewById(R.id.viewPicture);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(AddThingActivity.this, AddPictureActivity.class);
                intent.putExtra(AddPictureActivity.PICTURE_EXTRA, picture);

                startActivityForResult(intent, PHOTO_RESULT);

            }
        });
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_add_item, menu);
        return true;
    }

    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        super.onPrepareOptionsMenu(menu);

        EditText itemNameEditText = (EditText) findViewById(R.id.itemName),
                descriptionEditText = (EditText) findViewById(R.id.description);

        menu.findItem(R.id.addItem).setOnMenuItemClickListener(AddThingController.getInstance()
                .getSaveOnClickListener(this, itemNameEditText, descriptionEditText, imageView, location));
        menu.findItem(R.id.location).setOnMenuItemClickListener(AddThingController.getInstance()
                .getSetLocationOnClickListener(this, location));

        return true;
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // Check which request we're responding to
        if (requestCode == AddThingController.PHOTO_RESULT) {
            // Make sure the request was successful
            if (resultCode == RESULT_OK) {
                picture = data.getParcelableExtra(AddPictureActivity.PICTURE_EXTRA);
                ImageButton imageButton =(ImageButton) findViewById(R.id.viewPicture);
                imageButton.setImageBitmap(picture);
            }
        } else if( requestCode == SetLocationActivity.LOCATION_RESULT){
            if (resultCode == RESULT_OK) {
                location = data.getParcelableExtra(SetLocationActivity.LATLNG_EXTRA);

            }
        }
    }
}


text:
<?php
namespace Druto\Filesystem;
class Filesystem
{
	public function copy($src,$dest)
	{

	}
	public function mkdir($dirs,$mode=0777)
	{

	}
}

redpajama_set_name: RedPajamaGithub


text:
import * as _ from 'lodash';
import * as AWS from 'aws-sdk';
import Decimal from 'decimal.js';

import { Announcement } from './steam_announcements';
import RawClient from './clients/raw';

const STEAM_ANNOUNCEMENTS_TABLE = 'GRB.PostedSteamAnnouncements';

export default class PostActions {
  reddit: RawClient;

  constructor(
    private readonly dynamodb: AWS.DynamoDB,
    redditUsername: string,
    redditPassword: string,
    redditClientId: string,
    redditClientToken: string,
  ) {
    this.reddit = new RawClient(
      redditUsername,
      redditPassword,
      redditClientId,
      redditClientToken,
    );
  }

  /**
   * This function uses DynamoDB to ensure posts are only posted once.
   */
  public async postAnnouncement(announcement: Announcement): Promise<void> {
    // TODO: Use an ORM or something for this low level stuff.
    const existingPost = await this.dynamodb.getItem({
      TableName: STEAM_ANNOUNCEMENTS_TABLE,
      Key: { PostId: { S: announcement.link } }, // wtf is this shit.
    }).promise();

    if (existingPost.Item) {
      console.info(`Skipping ${announcement.link} because it has already been posted.`);
      return;
    }

    // TODO: Transaction.
    const post = this.makePost(announcement);
    console.info(`Posting to reddit for ${announcement.link}: ${post.title}`);
    await this.reddit.post(post.title, post.content);
    await this.dynamodb.putItem({
      TableName: STEAM_ANNOUNCEMENTS_TABLE,
      Item: {
        PostId: { S: announcement.link },
        // TODO: Expand the table to support these extra params.
        // post: _.mapValues(post, v => ({ S: v })) as any,
        // announcement: _.mapValues(announcement, v => ({ S: v })) as any,
      },
    }, undefined).promise();
    console.info(`Finished saving record for ${announcement.link}`);
  }

  private makePost(a: Announcement): { title: string, content: string } {
    let title;
    const content = `
  Current Active Players: ${a.app.activePlayers}

  ${a.appLink || ''}

  Genres: ${_.join(a.app.genres, ', ')}

  Categories: ${_.join(a.app.categories, ', ')}

  ${this.getFooter()}
  `;

    switch (a.type) {
      case 'Free Weekend':
        title = `${a.app.name} Free Weekend!`;
        break;
      default:
        const priceStr = new Decimal(a.app.priceCents).dividedBy(100).toFixed(2);
        title = `${a.app.name} on Sale for $${priceStr}!`;
        break;
    }

    return { title, content };
  }

  private getFooter(): string {
    return `
  *****
  Beep, Boop, I'm a bot.

  [Github](https://github.com/jmoseley/new-game-recommender)
  `;
  }
}


text:
package org.ehcache.clustered.client.internal.store.operations;

public interface KeyValueOperation<K, V> extends Operation <K> {

  V getValue();
}


text:
package zdcf

import (
	"encoding/json"
	"errors"
	"fmt"

	"github.com/jtacoma/go-zpl"
)

type zdcf1 struct {
	Version float32          `version`
	Apps    map[string]*app1 `apps`
}

type app1 struct {
	Context *context1           `context`
	Devices map[string]*device1 `devices`
}

type context1 struct {
	IoThreads int  `iothreads`
	Verbose   bool `verbose`
}

type device1 struct {
	Type    string              `type`
	Sockets map[string]*socket1 `sockets`
}

type socket1 struct {
	Type    string    `type`
	Options *options1 `option`
	Bind    []string  `bind`
	Connect []string  `connect`
}

type options1 struct {
	Hwm         int      `hwm`
	Swap        int      `swap`
	Affinity    int      `affinity`
	Identity    string   `identity`
	Subscribe   []string `subscribe`
	Rate        int      `rate`
	RecoveryIvl int      `recovery_ivl`
	McastLoop   bool     `mcast_loop`
	SndBuf      int      `sndbuf`
	RcvBuf      int      `rcvbuf`
}

func unmarshalZdcf1(bytes []byte) (*zdcf1, error) {
	var conf zdcf1
	err_json := json.Unmarshal(bytes, &conf)
	if err_json != nil {
		err_zpl := zpl.Unmarshal(bytes, &conf)
		if err_zpl != nil {
			return nil, fmt.Errorf("failed to parse as JSON (%s) or as ZPL (%s).", err_json, err_zpl)
		}
	}
	if conf.Version < 1 || 2 <= conf.Version {
		return nil, errors.New(fmt.Sprintf(
			"unsupported ZDCF version: %f",
			conf.Version))
	}
	return &conf, nil
}

func (conf *zdcf1) update(other *zdcf1) error {
	if other.Version < 1 || 2 <= other.Version {
		return errors.New(fmt.Sprintf(
			"unsupported ZDCF version: %f",
			other.Version))
	}
	for appName, appConf := range other.Apps {
		if appConf0, already := conf.Apps[appName]; !already {
			conf.Apps[appName] = appConf
		} else {
			// TODO: context? gozmq provides no API for this.
			for devName, devConf := range appConf.Devices {
				if devConf0, already := appConf0.Devices[devName]; !already {
					appConf0.Devices[devName] = devConf
				} else {
					for sockName, sockConf := range devConf.Sockets {
						if sockConf0, already := devConf0.Sockets[sockName]; !already {
							devConf0.Sockets[sockName] = sockConf
						} else {
							if len(sockConf.Type) > 0 {
								sockConf0.Type = sockConf.Type
							}
							if sockConf.Options != nil {
								// TODO: do a proper update here!
								sockConf0.Options = sockConf.Options
							}
							if len(sockConf.Bind) > 0 {
								sockConf0.Bind = sockConf.Bind
							}
							if len(sockConf.Connect) > 0 {
								sockConf0.Connect = sockConf.Connect
							}
						}
					}
				}
			}
		}
	}
	return nil
}


text:
package de.nixis.web.disco.dto;

import org.bson.types.ObjectId;

/**
 *
 * @author nico.rehwaldt
 */
public class Participant implements Comparable<Participant> {

  private ObjectId id;

  private String name;

  public Participant(String name) {
    this.name = name;

    this.id = new ObjectId();
  }

  public Participant() {
  }

  public String getId() {
    return id.toString();
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int compareTo(Participant o) {
    return o.id.compareTo(id);
  }
}


text:
license: >
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you 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.

title: MediaFile.getFormatData
---

# MediaFile.getFormatData

> Récupère le format d'informations sur le fichier de capture de médias.

    mediaFile.getFormatData (MediaFileDataSuccessCB successCallback, [MediaFileDataErrorCB errorCallback]) ;

## Description

Cette fonction de façon asynchrone tente de récupérer les informations de format pour le fichier multimédia. Si réussie, elle appelle le `MediaFileDataSuccessCB` rappel avec un `[MediaFileData](MediaFileData.html)` objet. Si la tentative échoue, cette fonction appelle la `MediaFileDataErrorCB` rappel.

## Plates-formes prises en charge

*   Android
*   BlackBerry WebWorks (OS 5.0 et plus)
*   iOS
*   Windows Phone 7 et 8
*   Windows 8

## BlackBerry WebWorks Quirks

Ne fournit pas une API pour plus d'informations sur les fichiers de médias, alors tous les `[MediaFileData](MediaFileData.html)` objets reviennent avec les valeurs par défaut.

## Quirks Android

L'API pour accéder aux médias file format informations est limité, donc pas tous les `[MediaFileData](MediaFileData.html)` propriétés sont prises en charge.

## iOS Quirks

L'API pour accéder aux médias file format informations est limité, donc pas tous les `[MediaFileData](MediaFileData.html)` propriétés sont prises en charge.


text:
package mil.nga.giat.asam.test;

import junit.framework.Assert;
import mil.nga.giat.asam.test.util.Screenshot;
import mil.nga.giat.asam.test.util.TestConstants;

import com.android.uiautomator.core.UiCollection;
import com.android.uiautomator.core.UiDevice;
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiScrollable;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;

public class PhoneTest implements DeviceTest {

    private static final String DISCLAIMER_SCREENSHOT_FORMAT = "Disclaimer_%d";
    private static final String MAP_VIEW_SCREENSHOT_FORMAT = "Map_View_%d";
    private static final String SUBREGION_SCREENSHOT_FORMAT = "Subregion_%d";
    private static final String ASAM_QUERY_SCREENSHOT_FORMAT = "ASAM_Query_%d";
    private static final String SETTINGS_SCREENSHOT_FORMAT = "ASAM_Query_%d";
    private static final String ABOUT_SCREENSHOT_FORMAT = "About_%d";
    private UiAutomatorTestCase mUiAutomatorTestCase;
    private int mScreenshotCounter;

    public PhoneTest(UiAutomatorTestCase uiAutomatorTestCase) {
        mUiAutomatorTestCase = uiAutomatorTestCase;
        mScreenshotCounter = 1;
    }

    @Override
    public void runTest() {
        closeDisclaimer();
        runMapViewTest();
        runSubregionTest();
        runTextQueryTest();
        runSettingsTest();
        runAboutTest();
    }

    private void closeDisclaimer() {
        UiObject closeButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("I Agree"));
        try {
            System.out.println("Closing disclaimer.");
            Screenshot.takeScreenshot(String.format(DISCLAIMER_SCREENSHOT_FORMAT, mScreenshotCounter++));
            closeButton.click();
            if (!closeButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT)) {
                Assert.fail("Failed to close disclaimer prompt!");
            }
        }
        catch (UiObjectNotFoundException caught) {
            Assert.fail("Failed to close disclaimer prompt! " + caught.getMessage());
        }
    }

    private void runMapViewTest() {
        try {

            // Should be on main launch screen.
            System.out.println("Clicking map view.");
            UiObject mapViewIcon = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.ImageView").description("Map View"));
            mapViewIcon.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(MAP_VIEW_SCREENSHOT_FORMAT, mScreenshotCounter++), 5 * TestConstants.PAUSE_BEFORE_MAP_SCREENSHOT); // Give some time to draw map before taking screenshot.
            // NOTE: 5 * PAUSE is to give a little extra time for the initial web service call.

            exerciseMapTypes(MAP_VIEW_SCREENSHOT_FORMAT);

            // View the results in a list.
            System.out.println("Clicking list view.");
            UiObject listButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("List View"));
            listButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(MAP_VIEW_SCREENSHOT_FORMAT, mScreenshotCounter++));

            exerciseList(MAP_VIEW_SCREENSHOT_FORMAT);

            // Go back to map view.
            System.out.println("Going back to map view.");
            UiDevice.getInstance().pressBack();

            // Run a time query from map view.
            System.out.println("Running a time query.");
            UiObject queryButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("Query"));
            queryButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            UiObject queryTextPopup = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").text("180 days"));
            queryTextPopup.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(MAP_VIEW_SCREENSHOT_FORMAT, mScreenshotCounter++), TestConstants.PAUSE_BEFORE_MAP_SCREENSHOT); // Give some time to draw map before taking screenshot.

            // Reset the map view.
            System.out.println("Resetting the map view.");
            UiDevice device = UiDevice.getInstance();
            device.pressMenu();
            UiObject centerButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").text("Center Map"));
            centerButton.click();
            mUiAutomatorTestCase.sleep(TestConstants.UI_ACTION_TIMEOUT); // Give some time for the map to reset.
            Screenshot.takeScreenshot(String.format(MAP_VIEW_SCREENSHOT_FORMAT, mScreenshotCounter++), TestConstants.PAUSE_BEFORE_MAP_SCREENSHOT); // Give some time to draw map before taking screenshot.

            // Go back to main launch screen.
            System.out.println("Go back to launch screen.");
            UiDevice.getInstance().pressBack();

        }
        catch (UiObjectNotFoundException caught) {
            Assert.fail("Failed exercising Map View! " + caught.getMessage());
        }
    }

    private void runSubregionTest() {
        try {

            // Should be on main launch screen.
            System.out.println("Clicking subregion.");
            UiObject subregionIcon = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.ImageView").description("Subregions"));
            subregionIcon.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(SUBREGION_SCREENSHOT_FORMAT, mScreenshotCounter++), TestConstants.PAUSE_BEFORE_MAP_SCREENSHOT); // Give some time to draw map before taking screenshot.

            exerciseMapTypes(SUBREGION_SCREENSHOT_FORMAT);

            // Click 3/4 in x direction and 1/3 down y direction.
            System.out.println("Click a subregion.");
            UiDevice device = UiDevice.getInstance();
            int x = device.getDisplayWidth() * 1 / 2; // Backwards.
            int y = device.getDisplayHeight() / 3;
            System.out.println(String.format("Clicking on coordinate x: %d, y: %d", x, y));
            device.click(x, y);
            Screenshot.takeScreenshot(String.format(SUBREGION_SCREENSHOT_FORMAT, mScreenshotCounter++));

            // Reset the screen.
            System.out.println("Resetting screen.");
            device.pressMenu();
            UiObject resetButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").text("Reset"));
            resetButton.click();
            Screenshot.takeScreenshot(String.format(SUBREGION_SCREENSHOT_FORMAT, mScreenshotCounter++));
            mUiAutomatorTestCase.sleep(TestConstants.UI_ACTION_TIMEOUT); // Give some time for the map to reset.

            // Selected subregions popup.
            System.out.println("Finding selected subregions.");
            device = UiDevice.getInstance();
            System.out.println(String.format("Clicking on coordinate x: %d, y: %d", x, y));
            device.click(x, y);
            Screenshot.takeScreenshot(String.format(SUBREGION_SCREENSHOT_FORMAT, mScreenshotCounter++));
            UiObject selectedSubregionsButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("Selected Subregions"));
            if (!selectedSubregionsButton.exists()) {
                device.pressMenu();
                selectedSubregionsButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").text("Selected Subregions"));
            }
            selectedSubregionsButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(SUBREGION_SCREENSHOT_FORMAT, mScreenshotCounter++));
            UiObject closeButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Close"));
            closeButton.click();
            closeButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);

            // Now run a query. NOTE: Should still be clicked.
            System.out.println("Run a subregions query.");
            Screenshot.takeScreenshot(String.format(SUBREGION_SCREENSHOT_FORMAT, mScreenshotCounter++));
            UiObject queryButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("Query"));
            queryButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(SUBREGION_SCREENSHOT_FORMAT, mScreenshotCounter++));
            UiObject timePeriodButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").text("5 years"));
            timePeriodButton.clickAndWaitForNewWindow(3 * TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(SUBREGION_SCREENSHOT_FORMAT, mScreenshotCounter++), TestConstants.PAUSE_BEFORE_MAP_SCREENSHOT); // Give some time to draw map before taking screenshot.

            // Click on the list button.
            System.out.println("Clicking on list view.");
            UiObject listButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("List View"));
            listButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(SUBREGION_SCREENSHOT_FORMAT, mScreenshotCounter++));

            exerciseList(SUBREGION_SCREENSHOT_FORMAT);

            // Go back to query results.
            System.out.println("Going back to query results.");
            UiDevice.getInstance().pressBack();

            // Go back to query subregions.
            System.out.println("Going back to subregions.");
            UiDevice.getInstance().pressBack();

            // Go back to main launch screen.
            System.out.println("Going back to launch screen.");
            UiDevice.getInstance().pressBack();

        }
        catch (UiObjectNotFoundException caught) {
            Assert.fail("Failed exercising Subregions! " + caught.getMessage());
        }
    }

    private void runTextQueryTest() {
        try {

            // Should be on main launch screen.
            System.out.println("Clicking ASAM Query.");
            UiObject subregionIcon = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.ImageView").description("ASAM Query"));
            subregionIcon.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(ASAM_QUERY_SCREENSHOT_FORMAT, mScreenshotCounter++));

            // Do a subregion query.
            System.out.println("Running a subregion query.");
            UiObject subregionSpinner = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Spinner"));
            subregionSpinner.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(ASAM_QUERY_SCREENSHOT_FORMAT, mScreenshotCounter++));
            UiScrollable subregionList = new UiScrollable(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.ListView"));
            subregionList.scrollIntoView(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.CheckedTextView").text("Subregion 62"));
            Screenshot.takeScreenshot(String.format(ASAM_QUERY_SCREENSHOT_FORMAT, mScreenshotCounter++));
            UiObject subregionButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.CheckedTextView").text("Subregion 62"));
            subregionButton.click();
            subregionButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(ASAM_QUERY_SCREENSHOT_FORMAT, mScreenshotCounter++));
            System.out.println("Clicking search button.");
            UiObject searchButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Search"));
            searchButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(ASAM_QUERY_SCREENSHOT_FORMAT, mScreenshotCounter++), TestConstants.PAUSE_BEFORE_MAP_SCREENSHOT); // Give some time to draw map before taking screenshot.

            // Click on the list button.
            System.out.println("Clicking on list view.");
            UiObject listButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("List View"));
            listButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(SUBREGION_SCREENSHOT_FORMAT, mScreenshotCounter++));

            exerciseList(ASAM_QUERY_SCREENSHOT_FORMAT);

            // Go back to query results.
            System.out.println("Going back to query results.");
            UiDevice.getInstance().pressBack();

            // Reset the map view.
            System.out.println("Resetting the map view.");
            UiDevice device = UiDevice.getInstance();
            device.pressMenu();
            UiObject resetButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").text("Center Map"));
            resetButton.click();
            mUiAutomatorTestCase.sleep(TestConstants.UI_ACTION_TIMEOUT); // Give some time for the map to reset.
            Screenshot.takeScreenshot(String.format(ASAM_QUERY_SCREENSHOT_FORMAT, mScreenshotCounter++), TestConstants.PAUSE_BEFORE_MAP_SCREENSHOT); // Give some time to draw map before taking screenshot.

            // Go back to query screen.
            System.out.println("Going back to query screen.");
            UiDevice.getInstance().pressBack();

            System.out.println("Resetting query screen.");
            resetButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Reset"));
            resetButton.click();

            // Do a reference number query.
            System.out.println("Running a reference number query.");
            UiObject referenceYearEditText = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.EditText").text("YYYY"));
            referenceYearEditText.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            referenceYearEditText.setText("2013");
            device.pressBack();
            UiObject referenceNumberEditText = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.EditText").text("###"));
            referenceNumberEditText.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            referenceNumberEditText.setText("100");
            device.pressBack();
            Screenshot.takeScreenshot(String.format(ASAM_QUERY_SCREENSHOT_FORMAT, mScreenshotCounter++));
            System.out.println("Clicking search button.");
            searchButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Search"));
            searchButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(ASAM_QUERY_SCREENSHOT_FORMAT, mScreenshotCounter++), TestConstants.PAUSE_BEFORE_MAP_SCREENSHOT); // Give some time to draw map before taking screenshot.

            // Go back to query screen.
            System.out.println("Going back to query screen.");
            UiDevice.getInstance().pressBack();

            System.out.println("Resetting query screen.");
            resetButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Reset"));
            resetButton.click();

//            // Do a date query.
//            System.out.println("Running a date query.");
//            UiObject dateFromEditText = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.EditText").resourceId(TestConstants.PACKAGE_NAME + ":id/text_query_date_from_edit_text_ui"));
//            dateFromEditText.setText("01/01/2013");
//            UiObject closeDateDialogButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Done"));
//            if (closeDateDialogButton.exists()) {
//                closeDateDialogButton.click();
//                closeDateDialogButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
//            }
//            UiObject dateToEditText = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.EditText").resourceId(TestConstants.PACKAGE_NAME + ":id/text_query_date_to_edit_text_ui"));
//            dateToEditText.setText("06/01/2013");
//            closeDateDialogButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Done"));
//            if (closeDateDialogButton.exists()) {
//                closeDateDialogButton.click();
//                closeDateDialogButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
//            }
//            UiDevice.getInstance().pressBack(); // Dismiss date picker.
//            Screenshot.takeScreenshot(String.format(ASAM_QUERY_SCREENSHOT_FORMAT, mScreenshotCounter++));
//            System.out.println("Clicking search button.");
//            searchButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Search"));
//            searchButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
//            Screenshot.takeScreenshot(String.format(ASAM_QUERY_SCREENSHOT_FORMAT, mScreenshotCounter++), TestConstants.PAUSE_BEFORE_MAP_SCREENSHOT); // Give some time to draw map before taking screenshot.
//
//            // Go back to query screen.
//            System.out.println("Going back to query screen.");
//            backButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").text("ASAM"));
//            backButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
//            System.out.println("Resetting query screen.");
//            resetButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("Reset"));
//            resetButton.click();

            // Do a victim query.
            System.out.println("Running a victim query.");
            UiObject victimEditText = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.EditText").description("Victim"));
            victimEditText.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            victimEditText.setText("tug");
            Screenshot.takeScreenshot(String.format(ASAM_QUERY_SCREENSHOT_FORMAT, mScreenshotCounter++));
            device.pressBack();
            System.out.println("Clicking search button.");
            searchButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Search"));
            searchButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(ASAM_QUERY_SCREENSHOT_FORMAT, mScreenshotCounter++), TestConstants.PAUSE_BEFORE_MAP_SCREENSHOT); // Give some time to draw map before taking screenshot.

            // Go back to query screen.
            System.out.println("Going back to query screen.");
            UiDevice.getInstance().pressBack();

            System.out.println("Resetting query screen.");
            resetButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Reset"));
            resetButton.click();

            // Do an aggressor query.
            System.out.println("Running an aggressor query.");
            UiObject aggressorEditText = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.EditText").description("Aggressor"));
            aggressorEditText.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            aggressorEditText.setText("greenpeace");
            Screenshot.takeScreenshot(String.format(ASAM_QUERY_SCREENSHOT_FORMAT, mScreenshotCounter++));
            device.pressBack();
            System.out.println("Clicking search button.");
            searchButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Search"));
            searchButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(ASAM_QUERY_SCREENSHOT_FORMAT, mScreenshotCounter++), TestConstants.PAUSE_BEFORE_MAP_SCREENSHOT); // Give some time to draw map before taking screenshot.

            // Go back to query screen.
            System.out.println("Going back to query screen.");
            UiDevice.getInstance().pressBack();

            System.out.println("Resetting query screen.");
            resetButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Reset"));
            resetButton.click();

            // Go back to main launch screen.
            System.out.println("Go back to launch screen.");
            UiDevice.getInstance().pressBack();

        }
        catch (UiObjectNotFoundException caught) {
            Assert.fail("Failed exercising ASAM Query! " + caught.getMessage());
        }
    }

    private void runSettingsTest() {
        try {

            // Should be on main launch screen.
            System.out.println("Clicking Settings.");
            UiObject settingsIcon = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.ImageView").description("Settings"));
            settingsIcon.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(SETTINGS_SCREENSHOT_FORMAT, mScreenshotCounter++));

            // Hide disclaimer.
            System.out.println("Hiding discalimer.");
            UiObject hideDisclaimerCheckbox = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.CheckBox").text("Hide Disclaimer"));
            hideDisclaimerCheckbox.click();
            Screenshot.takeScreenshot(String.format(SETTINGS_SCREENSHOT_FORMAT, mScreenshotCounter++));

            // Unhide disclaimer.
            System.out.println("Unhiding discalimer.");
            hideDisclaimerCheckbox = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.CheckBox").text("Hide Disclaimer"));
            hideDisclaimerCheckbox.click();
            Screenshot.takeScreenshot(String.format(SETTINGS_SCREENSHOT_FORMAT, mScreenshotCounter++));

            // Synchronize.
            System.out.println("Synchronizing.");
            UiObject synchronizeButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Sync Now"));
            synchronizeButton.click();
            UiObject okButton = null;
            do {
                okButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("OK"));
                mUiAutomatorTestCase.sleep(TestConstants.UI_ACTION_TIMEOUT); // Give some time to sync.
            } while (!okButton.exists());
            Screenshot.takeScreenshot(String.format(SETTINGS_SCREENSHOT_FORMAT, mScreenshotCounter++));
            okButton.click();
            okButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);

            // Go back to main launch screen.
            System.out.println("Go back to launch screen.");
            UiDevice.getInstance().pressBack();

        }
        catch (UiObjectNotFoundException caught) {
            Assert.fail("Failed exercising Settings! " + caught.getMessage());
        }
    }

    private void runAboutTest() {
        try {

            // Should be on main launch screen.
            System.out.println("Clicking About.");
            UiObject aboutButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("About"));
            aboutButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(ABOUT_SCREENSHOT_FORMAT, mScreenshotCounter++));

            // Go to legal screen.
            System.out.println("Clicking legal row.");
            UiObject legalRow = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").text("Legal Information"));
            legalRow.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(ABOUT_SCREENSHOT_FORMAT, mScreenshotCounter++));

            // Click on NGA Disclaimer.
            System.out.println("Clicking NGA disclaimer.");
            UiObject disclaimerRow = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").text("Disclaimer"));
            disclaimerRow.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(ABOUT_SCREENSHOT_FORMAT, mScreenshotCounter++));

            // Go back to legal screen.
            System.out.println("Going back to legal screen.");
            UiDevice.getInstance().pressBack();
            Screenshot.takeScreenshot(String.format(ABOUT_SCREENSHOT_FORMAT, mScreenshotCounter++));

            // Click on NGA Privacy Policy.
            System.out.println("Clicking NGA privacy policy.");
            UiObject privacyRow = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").text("ASAM app"));
            privacyRow.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(ABOUT_SCREENSHOT_FORMAT, mScreenshotCounter++));

            // Go back to legal screen.
            System.out.println("Going back to legal screen.");
            UiDevice.getInstance().pressBack();
            Screenshot.takeScreenshot(String.format(ABOUT_SCREENSHOT_FORMAT, mScreenshotCounter++));

            // Go back to about screen.
            System.out.println("Going back to about screen.");
            UiDevice.getInstance().pressBack();
            Screenshot.takeScreenshot(String.format(ABOUT_SCREENSHOT_FORMAT, mScreenshotCounter++));

            // Go back to main launch screen.
            System.out.println("Go back to launch screen.");
            UiDevice.getInstance().pressBack();
        }
        catch (UiObjectNotFoundException caught) {
            Assert.fail("Failed exercising About! " + caught.getMessage());
        }
    }

    private void exerciseMapTypes(String screenshotFormat) throws UiObjectNotFoundException {
        System.out.println("Selecting Satellite Map Type");
        UiObject mapTypeButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("Map Type"));
        mapTypeButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
        UiObject satelliteButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").text("Satellite"));
        satelliteButton.click();
        Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));
        satelliteButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);

        System.out.println("Selecting Hybrid Map Type");
        mapTypeButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
        UiObject hybridButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").text("Hybrid"));
        hybridButton.click();
        Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));
        hybridButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);

        System.out.println("Selecting Offline Map Type");
        mapTypeButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
        UiObject offlineButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").text("Offline 1:110m"));
        offlineButton.click();
        Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));
        offlineButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);

        System.out.println("Selecting Normal Map Type");
        mapTypeButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
        UiObject normalButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").text("Normal"));
        normalButton.click();
        Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));
        normalButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
    }

    private void exerciseList(String screenshotFormat) throws UiObjectNotFoundException {

        // Click the first item in the list.
        UiCollection list = new UiCollection(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.ListView"));
        if (list != null && list.getChildCount(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.LinearLayout")) > 0) {
            System.out.println("Clicking a row in the list.");
            UiObject firstRow = list.getChildByInstance(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.LinearLayout"), 0);
            firstRow.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));

            // Go back to list view.
            System.out.println("Going back to list view.");
            UiDevice.getInstance().pressBack();

            // Sort the list by occurrence date ascending.
            System.out.println("Sorting by occurrence date ascending.");
            UiObject sortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("Sort"));
            sortButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            UiObject sortBySpinner = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Spinner"));
            sortBySpinner.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            UiObject occurrenceDateButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.CheckedTextView").text("Occurrence Date"));
            occurrenceDateButton.click();
            occurrenceDateButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            UiObject ascendingButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.RadioButton").text("Ascending"));
            ascendingButton.click();
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));
            UiObject listSortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Sort"));
            listSortButton.click();
            listSortButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));

            // Sort the list by occurrence date descending.
            System.out.println("Sorting by occurrence date descending.");
            sortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("Sort"));
            sortButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            sortBySpinner = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Spinner"));
            sortBySpinner.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            occurrenceDateButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.CheckedTextView").text("Occurrence Date"));
            occurrenceDateButton.click();
            occurrenceDateButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            UiObject descendingButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.RadioButton").text("Descending"));
            descendingButton.click();
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));
            listSortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Sort"));
            listSortButton.click();
            listSortButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));

            // Sort the list by subregions ascending.
            System.out.println("Sorting by subregions ascending.");
            sortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("Sort"));
            sortButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            sortBySpinner = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Spinner"));
            sortBySpinner.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            UiObject subregionsButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.CheckedTextView").text("Subregions"));
            subregionsButton.click();
            subregionsButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            ascendingButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.RadioButton").text("Ascending"));
            ascendingButton.click();
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));
            listSortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Sort"));
            listSortButton.click();
            listSortButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));

            // Sort the list by subregions descending.
            System.out.println("Sorting by subregions descending.");
            sortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("Sort"));
            sortButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            sortBySpinner = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Spinner"));
            sortBySpinner.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            subregionsButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.CheckedTextView").text("Subregions"));
            subregionsButton.click();
            subregionsButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            ascendingButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.RadioButton").text("Descending"));
            ascendingButton.click();
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));
            listSortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Sort"));
            listSortButton.click();
            listSortButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));

            // Sort the list by reference number ascending.
            System.out.println("Sorting by reference number ascending.");
            sortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("Sort"));
            sortButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            sortBySpinner = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Spinner"));
            sortBySpinner.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            UiObject referenceNumberButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.CheckedTextView").text("Reference Number"));
            referenceNumberButton.click();
            referenceNumberButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            ascendingButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.RadioButton").text("Ascending"));
            ascendingButton.click();
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));
            listSortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Sort"));
            listSortButton.click();
            listSortButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));

            // Sort the list by reference number descending.
            System.out.println("Sorting by reference number descending.");
            sortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("Sort"));
            sortButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            sortBySpinner = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Spinner"));
            sortBySpinner.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            referenceNumberButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.CheckedTextView").text("Reference Number"));
            referenceNumberButton.click();
            referenceNumberButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            ascendingButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.RadioButton").text("Descending"));
            ascendingButton.click();
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));
            listSortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Sort"));
            listSortButton.click();
            listSortButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));

            // Sort the list by victim ascending.
            System.out.println("Sorting by victim ascending.");
            sortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("Sort"));
            sortButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            sortBySpinner = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Spinner"));
            sortBySpinner.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            UiObject victimButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.CheckedTextView").text("Victim"));
            victimButton.click();
            victimButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            ascendingButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.RadioButton").text("Ascending"));
            ascendingButton.click();
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));
            listSortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Sort"));
            listSortButton.click();
            listSortButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));

            // Sort the list by victim descending.
            System.out.println("Sorting by victim descending.");
            sortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("Sort"));
            sortButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            sortBySpinner = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Spinner"));
            sortBySpinner.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            victimButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.CheckedTextView").text("Victim"));
            victimButton.click();
            victimButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            ascendingButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.RadioButton").text("Descending"));
            ascendingButton.click();
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));
            listSortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Sort"));
            listSortButton.click();
            listSortButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));

            // Sort the list by aggressor ascending.
            System.out.println("Sorting by aggressor ascending.");
            sortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("Sort"));
            sortButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            sortBySpinner = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Spinner"));
            sortBySpinner.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            UiObject aggressorButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.CheckedTextView").text("Aggressor"));
            aggressorButton.click();
            aggressorButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            ascendingButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.RadioButton").text("Ascending"));
            ascendingButton.click();
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));
            listSortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Sort"));
            listSortButton.click();
            listSortButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));

            // Sort the list by aggressor descending.
            System.out.println("Sorting by aggressor descending.");
            sortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.TextView").description("Sort"));
            sortButton.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            sortBySpinner = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Spinner"));
            sortBySpinner.clickAndWaitForNewWindow(TestConstants.UI_ACTION_TIMEOUT);
            aggressorButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.CheckedTextView").text("Aggressor"));
            aggressorButton.click();
            aggressorButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            ascendingButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.RadioButton").text("Descending"));
            ascendingButton.click();
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));
            listSortButton = new UiObject(new UiSelector().packageName(TestConstants.PACKAGE_NAME).className("android.widget.Button").text("Sort"));
            listSortButton.click();
            listSortButton.waitUntilGone(TestConstants.UI_ACTION_TIMEOUT);
            Screenshot.takeScreenshot(String.format(screenshotFormat, mScreenshotCounter++));
        }
        else {
            System.out.println("No row to click.");
        }
    }
}


text:
const Constants = require('../util/Constants');
const Util = require('../util/Util');
const { Error } = require('../errors');

/**
 * A wrapper around the ClientUser's settings.
 */
class ClientUserSettings {
  constructor(user, data) {
    this.user = user;
    this.patch(data);
  }

  /**
   * Patch the data contained in this class with new partial data.
   * @param {Object} data Data to patch this with
   */
  patch(data) {
    for (const [key, value] of Object.entries(Constants.UserSettingsMap)) {
      if (!data.hasOwnProperty(key)) continue;
      if (typeof value === 'function') {
        this[value.name] = value(data[key]);
      } else {
        this[value] = data[key];
      }
    }
  }

  /**
   * Update a specific property of of user settings.
   * @param {string} name Name of property
   * @param {value} value Value to patch
   * @returns {Promise<Object>}
   */
  update(name, value) {
    return this.user.client.api.users['@me'].settings.patch({ data: { [name]: value } });
  }

  /**
   * @param {Guild} guild The guild to move
   * @param {number} position Absolute or relative position
   * @param {boolean} [relative=false] Whether to position relatively or absolutely
   * @returns {Promise<Guild>}
   */
  setGuildPosition(guild, position, relative) {
    const temp = Object.assign([], this.guildPositions);
    Util.moveElementInArray(temp, guild.id, position, relative);
    return this.update('guild_positions', temp).then(() => guild);
  }

  /**
   * Add a guild to the list of restricted guilds.
   * @param {Guild} guild The guild to add
   * @returns {Promise<Guild>}
   */
  addRestrictedGuild(guild) {
    const temp = Object.assign([], this.restrictedGuilds);
    if (temp.includes(guild.id)) return Promise.reject(new Error('GUILD_RESTRICTED', true));
    temp.push(guild.id);
    return this.update('restricted_guilds', temp).then(() => guild);
  }

  /**
   * Remove a guild from the list of restricted guilds.
   * @param {Guild} guild The guild to remove
   * @returns {Promise<Guild>}
   */
  removeRestrictedGuild(guild) {
    const temp = Object.assign([], this.restrictedGuilds);
    const index = temp.indexOf(guild.id);
    if (index < 0) return Promise.reject(new Error('GUILD_RESTRICTED'));
    temp.splice(index, 1);
    return this.update('restricted_guilds', temp).then(() => guild);
  }
}

module.exports = ClientUserSettings;


text:
<list>
  <contact>
    <firstName>NameDef</firstName>
    <lastName>SurnameDef</lastName>
    <address>Contry City Address</address>
    <home>123 </home>
    <mobile>8 123 456 78</mobile>
    <work>23465766</work>
    <email1>default1@ya.ru</email1>
    <email2>default12@ya.ru</email2>
    <birthDay>2</birthDay>
    <birthMonth>October</birthMonth>
    <birthYear>1998</birthYear>
    <address2>Contry2 City2 Address2</address2>
    <phone2>Def123</phone2>
  </contact>
</list>


text:
What is it?
===========
This is a super simple Bundle that facilitate the usage of [Google Chart Tool](http://code.google.com/apis/chart/interactive/docs/index.html), [Google Chart Image API](http://code.google.com/apis/chart/image/) and [Google Infographics](http://code.google.com/apis/chart/infographics/).

It allows to render:

  * QRCode
  * Pie Chart (3 ways: canvas or svg, simple image from url, simple 3d image from url)
  * Column Chart
  * Bar Chart
  * Area Chart
  * scatter Chart
  * Combo Chart
  * Table
  * Gauge
  * Candlestick Chart
  * Map tree
  * Dynamic Icons

Added (special recommendations are bellow):

  * Calendar
  * Bubble Chart
  * Donut Chart (you don't really need it as you can do it with Pie Chart and configuration but it is a shortcut)
  * Gantt (beware gantt are betas)
  * Geo Chart
  * Histogram
  * Interval
  * Map
  * Org Chart
  * Sankey
  * Stepped Area Chart
  * Timeline
  * Trendline
  * Waterfall
  * Word Tree

Make sure you read the [Chart Image terms](http://code.google.com/apis/chart/image/terms.html) and [Chart tool terms](http://code.google.com/apis/chart/interactive/terms.html) before using that bundle.

It also contains some Twig extension that facilitates the integration.

Demo
----

http://blog.fruitsoftware.com/a-propos/demo-gchartbundle/

How to install it?
------------------

Thanks to [AaronDDM](http://example.com/ "AaronDDM"), you can use
[composer](http://packagist.org/packages/saad-tazi/g-chart-bundle "composer") to instlall the bundle.
```
composer require saad-tazi/g-chart-bundle
```

Or you can use the following method:

  1. Add this bundle to your ``vendor/`` dir:
      * Using the vendors script.

        Add the following lines in your ``deps`` file:

            [SaadTaziGChartBundle]
                git=git://github.com/saadtazi/SaadTaziGChartBundle.git
                target=/bundles/SaadTazi/GChartBundle

        Run the vendors script:

            ./bin/vendors install

      * Using git submodules.

            $ git submodule add git://github.com/saadtazi/SaadTaziGChartBundle.git vendor/bundles/SaadTazi/GChartBundle

  2. Add the SaadTazi namespace to your autoloader:

``` php

          // app/autoload.php
          $loader->registerNamespaces(array(
                'SaadTazi' => __DIR__.'/../vendor/bundles',
                // your other namespaces
          ));
```

  3. Add this bundle to your application's kernel:

``` php

          // app/ApplicationKernel.php
          public function registerBundles()
          {
              return array(
                  // ...
                  new SaadTazi\GChartBundle\SaadTaziGChartBundle(),
                  // ...
              );
          }
```

Optional: If you want to see the demo page, add the following to your routing.yml (requires Twig):

``` yaml
    _demo:
        resource: "@SaadTaziGChartBundle/Resources/config/routing.yml"
        type:     yaml
        prefix:   /gchart
```

Then you should be able to go to http://your.site.com/gchart/demo

Don't forget to include the required javascript in your layout, for example:

```
        <script type="text/javascript">
            // adds the package you need
            google.load("visualization", "1", {packages:["corechart", 'table', 'gauge']});
        </script>
```

How to use it?
--------------

Mmm, please check the Controller\DemoController to see how to build DataTable,
and Resources\views\Demo\demo.html.twig

Notes
-----
I implemented almost all the corechart chart types from the Google Chart Tool.
But I only implemented 3 Google Chart Image types, because
(<strike>they are ugly and</strike>) almost all of them can be built using
the Google Chart Tool.
From the Visualization, I only implemented the marker.

Ohh, please feel free to fork, add to it and send me pull requests!

Note: You don't have to use the Twig functions: you can use the php classes (in DataTable and or in Chart).
But you will probably find it a little bit "painful".

Using the added charts
----------------------

Calendar, Interval and gantt (charts needing dates as datas) :

These are special charts see https://developers.google.com/chart/interactive/docs/gallery/calendar#a-simple-example

These charts needs javascript Date Objects in first column.

As the Js Date Object need to be written (in json) like :

```

    [ new Date(2012, 3, 13), 37032 ],
    [ new Date(2012, 3, 14), 38024 ],
    [ new Date(2012, 3, 15), 38024 ],
    [ new Date(2012, 3, 16), 38108 ],
    [ new Date(2012, 3, 17), 38229 ],

```

I encountered issues with PHP and Json_encode. To avoid this you had to make your datas like this :

```php

    $datas = array(
        array('date' => DateTime::createFromFormat ( 'Y-m-d' , "2016-03-01"), 'md' => 3),
        array('date' => DateTime::createFromFormat ( 'Y-m-d' , "2016-03-02"), 'md' => 5),
        array('date' => DateTime::createFromFormat ( 'Y-m-d' , "2016-03-03"), 'md' => 1),
        array('date' => DateTime::createFromFormat ( 'Y-m-d' , "2016-03-04"), 'md' => 9),
        array('date' => DateTime::createFromFormat ( 'Y-m-d' , "2016-03-10"), 'md' => 24),
    );
    $res = new DataTable();
    $res->addColumn('date', 'Date', 'date');
    $res->addColumn('my_datas', 'My Datas', 'number');
    foreach($datas as $data) {
        // js month starts at 0 for Jan !
        $date => $data['date']->format("Y, ").(intval($data['date']->format("m"))-1).$data['date']->format(", d");
        $res->addRow([['v' => "new Date[[[{$date}]]]"], ['v' => $data['md']]);
    }

```

It gives the following json (don't get scared by the '"new Date[[[' and ']]]"', they are substituded when needed in the twig) :

```

    [ "new Date[[[2016, 2, 1]]]", 3 ],....

```

You can had a Tooltip to your datas by using this code :

```php

    // 'role_tooltip' must be written as i showed because it makes all the magic.
    $res->addColumn('role_tooltip', 'Tooltip', 'string');

    // ....

    foreach($datas as $data) {
        // js month starts at 0 for Jan !
        $date => $data['date']->format("Y, ").(intval($data['date']->format("m"))-1).$data['date']->format(", d");
        $res->addRow([['v' => "new Date[[[{$date}]]]"], ['v' => $data['md'], ['v' => "My wonderfull Tooltip for this row"]]);
    }

```

Support for events
------------------

You can define your own callback functions and associate it to the corresponding chart event like this:

```
    <div id="calChart"> </div>
    <script>
        $(function() {
            var myMo = function (ee) {
                console.log('Mouse over');
            }
            var myMou = function (ee) {
                console.log('Mouse out');
            }
            var myR = function () {
                console.log('Ready');
            }

            {{ gchart_calendar(calDatas, 'calChart', 950, 180, 'My cal datas', {tooltip:{isHtml: true,trigger: 'selection'}},
                [{'eventName': 'ready', 'callbackFunc': 'myR'},
                 {'eventName': 'onmouseover', 'callbackFunc': 'myMo'},
                 {'eventName': 'onmouseout', 'callbackFunc': 'myMou'},
          ]) }}
        });
    </script>

```

Have fun with those mods ;-)

Mods
----

2012-03-20

* added composer support (thanks to AaronDDM)

2011-10-23

* removed jQuery dependency (and div output - needs to be done "manually" now... Provides more control)

2011-09-22

* zero value bug fix

2011-09-06

* Added DataTable::toStrictArray() that checks array keys (ticket #1)

2011-06-23

* Initial commit


text:
package ca.corefacility.bioinformatics.irida.security.annotations;

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

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.test.context.support.WithSecurityContext;

/**
 * Annotation for use with {@link WithMockOAuth2SecurityContextFactory} to add a {@link OAuth2Authentication} object
 * into the security context for junit tests.
 */
@Target({ ElementType.METHOD, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@WithSecurityContext(factory = WithMockOAuth2SecurityContextFactory.class)
public @interface WithMockOAuth2Client {
	/**
	 * The username to be used. Note that {@link #value()} is a synonym for {@link #username()}, but if
	 * {@link #username()} is specified it will take precedence.
	 *
	 * @return
	 */
	String username() default "";

	/**
	 * The roles to use. The default is "USER". A {@link GrantedAuthority} will be created for each value within roles.
	 * Each value in roles will automatically be prefixed with "ROLE_". For example, the default will result in
	 * "ROLE_USER" being used.
	 *
	 * @return
	 */
	String[] roles() default { "USER" };

	/**
	 * The password to be used. The default is "password".
	 *
	 * @return
	 */
	String password() default "password";

	/**
	 * The clientId of the client being mocked. Default is "client"
	 *
	 * @return
	 */
	String clientId() default "client";

	/**
	 * Scope of OAuth2 client. Default is none
	 *
	 * @return
	 */
	String[] scope() default "";
}


text:
/*! \file disjoint_pool.h
 *  \brief A caching and pooling memory resource adaptor which uses separate upstream resources for memory allocation
 *      and bookkeeping.
 */

#pragma once

#include <algorithm>

#include <thrust/host_vector.h>
#include <thrust/binary_search.h>
#include <thrust/detail/seq.h>

#include <thrust/mr/memory_resource.h>
#include <thrust/mr/allocator.h>
#include <thrust/mr/pool_options.h>

#include <cassert>

namespace thrust
{
namespace mr
{

/** \addtogroup memory_resources Memory Resources
 *  \ingroup memory_management_classes
 *  \{
 */

/*! A memory resource adaptor allowing for pooling and caching allocations from \p Upstream, using \p Bookkeeper for
 *      management of that cached and pooled memory, allowing to cache portions of memory inaccessible from the host.
 *
 *  On a typical memory resource, calls to \p allocate and \p deallocate actually allocate and deallocate memory. Pooling
 *      memory resources only allocate and deallocate memory from an external resource (the upstream memory resource) when
 *      there's no suitable memory currently cached; otherwise, they use memory they have acquired beforehand, to make
 *      memory allocation faster and more efficient.
 *
 *  The disjoint version of the pool resources uses a separate upstream memory resource, \p Bookkeeper, to allocate memory
 *      necessary to manage the cached memory. There may be many reasons to do that; the canonical one is that \p Upstream
 *      allocates memory that is inaccessible to the code of the pool resource, which means that it cannot embed the necessary
 *      information in memory obtained from \p Upstream; for instance, \p Upstream can be a CUDA non-managed memory
 *      resource, or a CUDA managed memory resource whose memory we would prefer to not migrate back and forth between
 *      host and device when executing bookkeeping code.
 *
 *  This is not the only case where it makes sense to use a disjoint pool resource, though. In a multi-core environment
 *      it may be beneficial to avoid stealing cache lines from other cores by writing over bookkeeping information
 *      embedded in an allocated block of memory. In such a case, one can imagine wanting to use a disjoint pool where
 *      both the upstream and the bookkeeper are of the same type, to allocate memory consistently, but separately for
 *      those two purposes.
 *
 *  \tparam Upstream the type of memory resources that will be used for allocating memory blocks to be handed off to the user
 *  \tparam Bookkeeper the type of memory resources that will be used for allocating bookkeeping memory
 */
template<typename Upstream, typename Bookkeeper>
class disjoint_unsynchronized_pool_resource THRUST_FINAL
    : public memory_resource<typename Upstream::pointer>,
        private validator2<Upstream, Bookkeeper>
{
public:
    /*! Get the default options for a disjoint pool. These are meant to be a sensible set of values for many use cases,
     *      and as such, may be tuned in the future. This function is exposed so that creating a set of options that are
     *      just a slight departure from the defaults is easy.
     */
    static pool_options get_default_options()
    {
        pool_options ret;

        ret.min_blocks_per_chunk = 16;
        ret.min_bytes_per_chunk = 1024;
        ret.max_blocks_per_chunk = static_cast<std::size_t>(1) << 20;
        ret.max_bytes_per_chunk = static_cast<std::size_t>(1) << 30;

        ret.smallest_block_size = THRUST_MR_DEFAULT_ALIGNMENT;
        ret.largest_block_size = static_cast<std::size_t>(1) << 20;

        ret.alignment = THRUST_MR_DEFAULT_ALIGNMENT;

        ret.cache_oversized = true;

        ret.cached_size_cutoff_factor = 16;
        ret.cached_alignment_cutoff_factor = 16;

        return ret;
    }

    /*! Constructor.
     *
     *  \param upstream the upstream memory resource for allocations
     *  \param bookkeeper the upstream memory resource for bookkeeping
     *  \param options pool options to use
     */
    disjoint_unsynchronized_pool_resource(Upstream * upstream, Bookkeeper * bookkeeper,
        pool_options options = get_default_options())
        : m_upstream(upstream),
        m_bookkeeper(bookkeeper),
        m_options(options),
        m_smallest_block_log2(detail::log2_ri(m_options.smallest_block_size)),
        m_pools(m_bookkeeper),
        m_allocated(m_bookkeeper),
        m_cached_oversized(m_bookkeeper),
        m_oversized(m_bookkeeper)
    {
        assert(m_options.validate());

        pointer_vector free(m_bookkeeper);
        pool p(free);
        m_pools.resize(detail::log2_ri(m_options.largest_block_size) - m_smallest_block_log2 + 1, p);
    }

    // TODO: C++11: use delegating constructors

    /*! Constructor. Upstream and bookkeeping resources are obtained by calling \p get_global_resource for their types.
     *
     *  \param options pool options to use
     */
    disjoint_unsynchronized_pool_resource(pool_options options = get_default_options())
        : m_upstream(get_global_resource<Upstream>()),
        m_bookkeeper(get_global_resource<Bookkeeper>()),
        m_options(options),
        m_smallest_block_log2(detail::log2_ri(m_options.smallest_block_size)),
        m_pools(m_bookkeeper),
        m_allocated(m_bookkeeper),
        m_cached_oversized(m_bookkeeper),
        m_oversized(m_bookkeeper)
    {
        assert(m_options.validate());

        pointer_vector free(m_bookkeeper);
        pool p(free);
        m_pools.resize(detail::log2_ri(m_options.largest_block_size) - m_smallest_block_log2 + 1, p);
    }

    /*! Destructor. Releases all held memory to upstream.
     */
    ~disjoint_unsynchronized_pool_resource()
    {
        release();
    }

private:
    typedef typename Upstream::pointer void_ptr;
    typedef typename thrust::detail::pointer_traits<void_ptr>::template rebind<char>::other char_ptr;

    struct chunk_descriptor
    {
        std::size_t size;
        void_ptr pointer;
    };

    typedef thrust::host_vector<
        chunk_descriptor,
        allocator<chunk_descriptor, Bookkeeper>
    > chunk_vector;

    struct oversized_block_descriptor
    {
        std::size_t size;
        std::size_t alignment;
        void_ptr pointer;

        __host__ __device__
        bool operator==(const oversized_block_descriptor & other) const
        {
            return size == other.size && alignment == other.alignment && pointer == other.pointer;
        }

        __host__ __device__
        bool operator<(const oversized_block_descriptor & other) const
        {
            return size < other.size || (size == other.size && alignment < other.alignment);
        }
    };

    struct equal_pointers
    {
    public:
        __host__ __device__
        equal_pointers(void_ptr p) : p(p)
        {
        }

        __host__ __device__
        bool operator()(const oversized_block_descriptor & desc) const
        {
            return desc.pointer == p;
        }

    private:
        void_ptr p;
    };

    struct matching_alignment
    {
    public:
        __host__ __device__
        matching_alignment(std::size_t requested) : requested(requested)
        {
        }

        __host__ __device__
        bool operator()(const oversized_block_descriptor & desc) const
        {
            return desc.alignment >= requested;
        }

    private:
        std::size_t requested;
    };

    typedef thrust::host_vector<
        oversized_block_descriptor,
        allocator<oversized_block_descriptor, Bookkeeper>
    > oversized_block_vector;

    typedef thrust::host_vector<
        void_ptr,
        allocator<void_ptr, Bookkeeper>
    > pointer_vector;

    struct pool
    {
        __host__
        pool(const pointer_vector & free)
            : free_blocks(free),
            previous_allocated_count(0)
        {
        }

        __host__
        pool(const pool & other)
            : free_blocks(other.free_blocks),
            previous_allocated_count(other.previous_allocated_count)
        {
        }

#if THRUST_CPP_DIALECT >= 2011
        pool & operator=(const pool &) = default;
#endif

        __host__
        ~pool() {}

        pointer_vector free_blocks;
        std::size_t previous_allocated_count;
    };

    typedef thrust::host_vector<
        pool,
        allocator<pool, Bookkeeper>
    > pool_vector;

    Upstream * m_upstream;
    Bookkeeper * m_bookkeeper;

    pool_options m_options;
    std::size_t m_smallest_block_log2;

    // buckets containing free lists for each pooled size
    pool_vector m_pools;
    // list of all allocations from upstream for the above
    chunk_vector m_allocated;
    // list of all cached oversized/overaligned blocks that have been returned to the pool to cache
    oversized_block_vector m_cached_oversized;
    // list of all oversized/overaligned allocations from upstream
    oversized_block_vector m_oversized;

public:
    /*! Releases all held memory to upstream.
     */
    void release()
    {
        // reset the buckets
        for (std::size_t i = 0; i < m_pools.size(); ++i)
        {
            m_pools[i].free_blocks.clear();
            m_pools[i].previous_allocated_count = 0;
        }

        // deallocate memory allocated for the buckets
        for (std::size_t i = 0; i < m_allocated.size(); ++i)
        {
            m_upstream->do_deallocate(
                m_allocated[i].pointer,
                m_allocated[i].size,
                m_options.alignment);
        }

        // deallocate cached oversized/overaligned memory
        for (std::size_t i = 0; i < m_oversized.size(); ++i)
        {
            m_upstream->do_deallocate(
                m_oversized[i].pointer,
                m_oversized[i].size,
                m_oversized[i].alignment);
        }

        m_allocated.clear();
        m_oversized.clear();
        m_cached_oversized.clear();
    }

    THRUST_NODISCARD virtual void_ptr do_allocate(std::size_t bytes, std::size_t alignment = THRUST_MR_DEFAULT_ALIGNMENT) THRUST_OVERRIDE
    {
        bytes = (std::max)(bytes, m_options.smallest_block_size);
        assert(detail::is_power_of_2(alignment));

        // an oversized and/or overaligned allocation requested; needs to be allocated separately
        if (bytes > m_options.largest_block_size || alignment > m_options.alignment)
        {
            oversized_block_descriptor oversized;
            oversized.size = bytes;
            oversized.alignment = alignment;

            if (m_options.cache_oversized && !m_cached_oversized.empty())
            {
                typename oversized_block_vector::iterator it = thrust::lower_bound(
                    thrust::seq,
                    m_cached_oversized.begin(),
                    m_cached_oversized.end(),
                    oversized);

                // if the size is bigger than the requested size by a factor
                // bigger than or equal to the specified cutoff for size,
                // allocate a new block
                if (it != m_cached_oversized.end())
                {
                    std::size_t size_factor = (*it).size / bytes;
                    if (size_factor >= m_options.cached_size_cutoff_factor)
                    {
                        it = m_cached_oversized.end();
                    }
                }

                if (it != m_cached_oversized.end() && (*it).alignment < alignment)
                {
                    it = find_if(it + 1, m_cached_oversized.end(), matching_alignment(alignment));
                }

                // if the alignment is bigger than the requested one by a factor
                // bigger than or equal to the specified cutoff for alignment,
                // allocate a new block
                if (it != m_cached_oversized.end())
                {
                    std::size_t alignment_factor = (*it).alignment / alignment;
                    if (alignment_factor >= m_options.cached_alignment_cutoff_factor)
                    {
                        it = m_cached_oversized.end();
                    }
                }

                if (it != m_cached_oversized.end())
                {
                    oversized.pointer = (*it).pointer;
                    m_cached_oversized.erase(it);
                    return oversized.pointer;
                }
            }

            // no fitting cached block found; allocate a new one that's just up to the specs
            oversized.pointer = m_upstream->do_allocate(bytes, alignment);
            m_oversized.push_back(oversized);

            return oversized.pointer;
        }

        // the request is NOT for oversized and/or overaligned memory
        // allocate a block from an appropriate bucket
        std::size_t bytes_log2 = thrust::detail::log2_ri(bytes);
        std::size_t bucket_idx = bytes_log2 - m_smallest_block_log2;
        pool & bucket = m_pools[bucket_idx];

        // if the free list of the bucket has no elements, allocate a new chunk
        // and split it into blocks pushed to the free list
        if (bucket.free_blocks.empty())
        {
            std::size_t bucket_size = static_cast<std::size_t>(1) << bytes_log2;

            std::size_t n = bucket.previous_allocated_count;
            if (n == 0)
            {
                n = m_options.min_blocks_per_chunk;
                if (n < (m_options.min_bytes_per_chunk >> bytes_log2))
                {
                    n = m_options.min_bytes_per_chunk >> bytes_log2;
                }
            }
            else
            {
                n = n * 3 / 2;
                if (n > (m_options.max_bytes_per_chunk >> bytes_log2))
                {
                    n = m_options.max_bytes_per_chunk >> bytes_log2;
                }
                if (n > m_options.max_blocks_per_chunk)
                {
                    n = m_options.max_blocks_per_chunk;
                }
            }

            bytes = n << bytes_log2;

            assert(n >= m_options.min_blocks_per_chunk);
            assert(n <= m_options.max_blocks_per_chunk);
            assert(bytes >= m_options.min_bytes_per_chunk);
            assert(bytes <= m_options.max_bytes_per_chunk);

            chunk_descriptor allocated;
            allocated.size = bytes;
            allocated.pointer = m_upstream->do_allocate(bytes, m_options.alignment);
            m_allocated.push_back(allocated);
            bucket.previous_allocated_count = n;

            for (std::size_t i = 0; i < n; ++i)
            {
                bucket.free_blocks.push_back(
                    static_cast<void_ptr>(
                        static_cast<char_ptr>(allocated.pointer) + i * bucket_size
                    )
                );
            }
        }

        // allocate a block from the front of the bucket's free list
        void_ptr ret = bucket.free_blocks.back();
        bucket.free_blocks.pop_back();
        return ret;
    }

    virtual void do_deallocate(void_ptr p, std::size_t n, std::size_t alignment = THRUST_MR_DEFAULT_ALIGNMENT) THRUST_OVERRIDE
    {
        n = (std::max)(n, m_options.smallest_block_size);
        assert(detail::is_power_of_2(alignment));

        // verify that the pointer is at least as aligned as claimed
        assert(reinterpret_cast<detail::intmax_t>(detail::pointer_traits<void_ptr>::get(p)) % alignment == 0);

        // the deallocated block is oversized and/or overaligned
        if (n > m_options.largest_block_size || alignment > m_options.alignment)
        {
            typename oversized_block_vector::iterator it = find_if(m_oversized.begin(), m_oversized.end(), equal_pointers(p));
            assert(it != m_oversized.end());

            oversized_block_descriptor oversized = *it;

            if (m_options.cache_oversized)
            {
                typename oversized_block_vector::iterator position = lower_bound(m_cached_oversized.begin(), m_cached_oversized.end(), oversized);
                m_cached_oversized.insert(position, oversized);
                return;
            }

            m_oversized.erase(it);

            m_upstream->do_deallocate(p, oversized.size, oversized.alignment);

            return;
        }

        // push the block to the front of the appropriate bucket's free list
        std::size_t n_log2 = thrust::detail::log2_ri(n);
        std::size_t bucket_idx = n_log2 - m_smallest_block_log2;
        pool & bucket = m_pools[bucket_idx];

        bucket.free_blocks.push_back(p);
    }
};

/*! \}
 */

} // end mr
} // end thrust


text:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="Encoding">
    <file url="file://$PROJECT_DIR$/README.md" charset="ISO-8859-1" />
  </component>
</project>


text:
from swgpy.object import *

def create(kernel):
	result = Tangible()

	result.template = "object/tangible/food/crafted/shared_dish_scrimpi.iff"
	result.attribute_template_id = 5
	result.stfName("food_name","scrimpi")

	#### BEGIN MODIFICATIONS ####
	####  END MODIFICATIONS  ####

	return result


text:
package org.stem.coordination;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.ObjectCodec;
import com.fasterxml.jackson.core.TreeNode;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.node.TextNode;
import com.google.common.util.concurrent.Uninterruptibles;
import org.apache.commons.lang3.StringUtils;
import org.stem.api.response.ErrorResponse;
import org.stem.api.response.StemResponse;
import org.stem.exceptions.EventException;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

// TODO:  In case of JSON serialization investigate and start using Mix-in feature (http://wiki.fasterxml.com/JacksonMixInAnnotations)

@JsonDeserialize(using = Event.CustomDeserializer.class)
public class Event extends ZNodeAbstract {

    @JsonCreator
    public static Object test(String name) {
        return null;
    }

    public static enum Type {
        JOIN("join", Join.listener, Join.class);

        private static Map<String, Type> values = new HashMap<>();

        static {
            for (Type val : Type.values()) {
                values.put(val.name, val);
            }
        }

        @JsonCreator
        public static Type byName(String name) {
            if (null == name)
                throw new IllegalStateException("Request type is empty");

            Type type = values.get(name);
            if (null == type)
                throw new IllegalStateException(String.format("Invalid request: %s. Available types: %s",
                        name, StringUtils.join(values.keySet(), ", ")));

            return type;
        }

        @JsonValue
        public String getName() {
            return name;
        }

        final String name;
        public final Listener listener;
        private Class<? extends StemResponse> clazz;

        Type(String name, Listener listener, Class<? extends StemResponse> clazz) {
            this.name = name;
            this.listener = listener;
            this.clazz = clazz;
        }
    }

    public static Event create(Type type) {
        return new Event(UUID.randomUUID(), type);
    }

    public static Event create(Type type, UUID id) {
        return new Event(id, type);
    }

    UUID id;
    Type type;

    private StemResponse response;
    private long started;
    // long completed;
    // boolean disposable // Should this event be discarded once it fired

    public UUID getId() {
        return id;
    }

    public void setId(UUID id) {
        this.id = id;
    }

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    public void setResponse(StemResponse response) {
        this.response = response;
    }

    public StemResponse getResponse() {
        return response;
    }

    protected Event() {
    }

    protected Event(UUID id, Type type) {
        this.id = id;
        this.type = type;
        this.started = System.nanoTime();
    }

    @Override
    public String name() {
        return id.toString();
    }

    /**
     *
     */
    public static abstract class Factory {

        public static Handler newHandler(UUID requestId, Type type, EventResultFuture future, ZookeeperClient client) {
            return new Handler(requestId, future, type.listener, client);
        }
    }

    /**
     *
     */
    public static class Handler {

        private final UUID requestId;
        private final EventResultFuture future;
        private Listener listener;
        private final ZookeeperClient client;

        public Handler(UUID requestId, EventResultFuture future, Listener listener, ZookeeperClient client) {

            this.requestId = requestId;
            this.future = future;
            this.listener = listener;
            this.client = client;
        }

        public void start() throws Exception {
            // TODO: check already started ?
            listener.register(future);
            client.listenForZNode(ZookeeperPaths.ASYNC_REQUESTS + '/' + requestId.toString(), listener);
        }

        public interface Callback {

            public void onSet(StemResponse response, long latency);
            //public void register(RequestHandler handler);
        }
    }

    /**
     *
     */
    public static class Listener extends ZookeeperEventListener<Event> {

        public static StemResponse waitFor(UUID requestId, Type type, ZookeeperClient client) throws Exception {
            EventResultFuture future = new EventResultFuture();
            Event.Factory
                    .newHandler(requestId, type, future, client)
                    .start();

            StemResponse result = Uninterruptibles.getUninterruptibly(future);
            if (result instanceof ErrorResponse) {
                ErrorResponse response = (ErrorResponse) result;
                throw new EventException(response.toString());
            }

            return result;
        }

        protected EventResultFuture future;

        public void register(EventResultFuture future) {
            this.future = future;
        }

        @Override
        public Class<Event> getBaseClass() {
            return Event.class;
        }

        @Override
        protected void onNodeUpdated(Event request) {
            StemResponse response = request.response;
            if (null == response)
                return;

            process(response);

            future.onSet(response, System.nanoTime() - request.started);
        }

        protected void process(StemResponse response) {
        }
    }

    static abstract class AsyncResponseAbstract<T extends StemResponse> extends StemResponse {

    }

    // Events

    public static class Join extends StemResponse {

        public static Listener listener = new Listener() {

        };

        Result result;

        public Result getResult() {
            return result;
        }

        public String getMessage() {
            return message;
        }

        @JsonIgnore
        public boolean isSuccess() {
            return Result.SUCCESS == result;
        }

        public Join() {
        }

        public Join(Result result, String message) {
            this.result = result;
            this.message = message;
        }

        public Join(Exception e) {
            this.result = Result.ERROR;
            this.message = e.getMessage();
        }

        public static enum Result {
            SUCCESS("success"),
            ERROR("error");

            private static Map<String, Result> values = new HashMap<>();

            static {
                for (Result val : Result.values()) {
                    values.put(val.name, val);
                }
            }

            @JsonCreator
            public static Result byName(String name) {
                if (null == name)
                    throw new IllegalStateException("value is empty");

                Result result = values.get(name);
                if (null == result)
                    throw new IllegalStateException(String.format("Invalid value: %s. Available types: %s",
                            name, StringUtils.join(values.keySet(), ", ")));

                return result;
            }

            @JsonValue
            public String getName() {
                return name;
            }

            final String name;

            Result(String name) {
                this.name = name;
            }
        }
    }

    static class CustomDeserializer extends JsonDeserializer<Event> {

        private static ObjectMapper mapper = new ObjectMapper();

        @Override
        public Event deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
            ObjectCodec codec = jp.getCodec();
            TreeNode treeNode = codec.readTree(jp);

            UUID id = UUID.fromString(((TextNode) treeNode.get("id")).asText());
            String typeStr = ((TextNode) treeNode.get("type")).asText();
            Type type = Type.byName(typeStr);

            TreeNode responseNode = treeNode.get("response");
            StemResponse result = mapper.treeToValue(responseNode, type.clazz);

            Event event = Event.create(type, id);
            event.setResponse(result);
            return event;
        }
    }
}


text:
import { StoreModel } from '../src';

export class Tenant implements StoreModel {
  id: string;
  name: string;
  isEqual(otherStore: Tenant): boolean {
    return otherStore.id === this.id;
  }
}

export class User implements StoreModel {
  id: string;
  first: string;
  isEqual(user: User) {
    return user.id === this.id;
  }
}


text:
<!DOCTYPE html>
<html>
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>HTML5 MediaElement</title>

        <script src="mediaelement/build/jquery.js"></script>
        <script src="mediaelement/build/mediaelement-and-player.min.js"></script>
        <link rel="stylesheet" href="mediaelement/build/mediaelementplayer.min.css" />
</head>
<body>

<video style="width: 1080px;" src="mp4-streamer.php?file=<?=$_GET['file']?>" type="video/mp4" id="player1"  controls="controls" preload="none">
<!-- Flash fallback for non-HTML5 browsers without JavaScript -->
    <object width="320" height="240" type="application/x-shockwave-flash" data="mediaelement/build/flashmediaelement.swf">
        <param name="movie" value="flashmediaelement.swf" />
        <param name="flashvars" value="mp4-streamer.php?file=<?=$_GET['file']?>" />
    </object>
</video>
</body>
</html>