text:
(function outer(modules, cache, entries){

  /**
   * Global
   */

  var global = (function(){ return this; })();

  /**
   * Require `name`.
   *
   * @param {String} name
   * @param {Boolean} jumped
   * @api public
   */

  function require(name, jumped){
    if (cache[name]) return cache[name].exports;
    if (modules[name]) return call(name, require);
    throw new Error('cannot find module "' + name + '"');
  }

  /**
   * Call module `id` and cache it.
   *
   * @param {Number} id
   * @param {Function} require
   * @return {Function}
   * @api private
   */

  function call(id, require){
    var m = cache[id] = { exports: {} };
    var mod = modules[id];
    var name = mod[2];
    var fn = mod[0];

    fn.call(m.exports, function(req){
      var dep = modules[id][1][req];
      return require(dep ? dep : req);
    }, m, m.exports, outer, modules, cache, entries);

    // expose as `name`.
    if (name) cache[name] = cache[id];

    return cache[id].exports;
  }

  /**
   * Require all entries exposing them on global if needed.
   */

  for (var id in entries) {
    if (entries[id]) {
      global[entries[id]] = require(id);
    } else {
      require(id);
    }
  }

  /**
   * Duo flag.
   */

  require.duo = true;

  /**
   * Expose cache.
   */

  require.cache = cache;

  /**
   * Expose modules
   */

  require.modules = modules;

  /**
   * Return newest require.
   */

   return require;
})({
1: [function(require, module, exports) {
(function () {

var gamepadController = require('kallaspriit/HTML5-JavaScript-Gamepad-Controller-Library@c38f53b:/gamepad.js');
var Promise = require('http://s3.amazonaws.com/es6-promises/promise-1.0.0.js');

/**
 * A simple drop-in JavaScript API to play multiplayer, web-based games
 * (with authentication, friends, leaderboards).
 *
 * @version 0.0.1
 * @exports galaxy
 * @namespace galaxy
 */
function galaxy() {
  this.paused = false;
  this.playing = false;
}

galaxy.version = '0.0.1';

/**
 * Authenticates a user.
 *
 * Opens a modal that overlays the game, prompting the user to sign in.
 * Returns a Promise that resolves with a `User` object for the user.
 *
 * @returns {Promise}
 * @memberOf galaxy
 */
galaxy.authenticate = function () {
  return new Promise(function (resolve, reject) {
    resolve({});
  });
};

/**
 * Begins the user's gameplay timer.
 *
 * Communicates with the Galaxy API that a user has begun playing the game.
 * If the user has not yet played the game before, the game is appended to the
 * list of games the user has played. If the user has played the game before,
 * the game is appended to the list of games the user is actively playing and
 * a counter is started which maintains the user's overall playtime for the
 * game.
 *
 * @returns {Promise}
 * @memberOf galaxy
 */
galaxy.beginPlaying = function () {
  return new Promise(function (resolve, reject) {
    resolve();
  });
};

/**
 * Connect to the Galaxy API and start a new game session.
 *
 * Establishes a WebSocket connection to the Galaxy API, indicating that the
 * user is ready to start playing the game.
 *
 * @returns {Promise}
 * @memberOf galaxy
 */
galaxy.connect = function () {
  return new Promise(function (resolve, reject) {
    resolve({});
  });
};

/**
 * Provides access to external gamepads connected via USB.
 *
 * This is a wrapper around the `navigator.getGamepads` API which provides
 * mappings to common controllers. You can either listen to events which
 * get fired when buttons/axes change or look at the `state` of a gamepad
 * in your game loop.
 *
 * @returns {Promise}
 * @memberOf galaxy
 */
galaxy.getGamepads = function () {
  return new Promise(function (resolve, reject) {
    return gamepadController;

    // TODO: Turn `WebKitPlatform` and `FirefoxPlatform` into promises.
  });
};

/**
 * Provides access to mobile-based gamepads using WebRTC.
 *
 * This controller uses a device's accelerometer (using `devicemotion` events
 * to determine controls to turn left/right/forward/backward and to accelerate
 * via `touchstart`/`touchmove`/touchend` events).
 *
 * @returns {Promise}
 * @memberOf galaxy
 */
galaxy.getWebRTCMobileGamepads = function () {
  return new Promise(function (resolve, reject) {
    resolve([]);
  });
};

/**
 * Provides access to mobile-based gamepads using WebSockets.
 *
 * This controller uses a device's accelerometer (using `devicemotion` events
 * to determine controls to turn left/right/forward/backward and to accelerate
 * via `touchstart`/`touchmove`/touchend` events).
 *
 * @returns {Promise}
 * @memberOf galaxy
 */
galaxy.getWebSocketMobileGamepads = function () {
  return new Promise(function (resolve, reject) {
    resolve([]);
  });
};

/**
 * Returns a list of the user's friends who have ever played the game.
 *
 * The Promise resolves with a list of `User` objects for each friend of the
 * user's who has ever played (or is actively playing) the game.
 *
 * @returns {Promise}
 * @memberOf galaxy
 */
galaxy.getFriends = function () {
  return new Promise(function (resolve, reject) {
    resolve([]);
  });
};

/**
 * Returns a list of the user's friends who are actively playing the game.
 *
 * The Promise resolves with a list of `User` objects for each friend of the
 * user's who is actively playing the game.
 *
 * @returns {Promise}
 * @memberOf galaxy
 */
galaxy.getFriendsPlaying = function () {
  return new Promise(function (resolve, reject) {
    resolve([]);
  });
};

/**
 * Ends the user's gameplay timer.
 *
 * Communicates with the Galaxy API that a user has stopped playing the game.
 * The game is removed from the list of games the user is actively playing and
 * the playtime counter is stopped, tallying the counter to the user's overall
 * playtime for the game.
 *
 * @returns {Promise}
 * @memberOf galaxy
 */
galaxy.endPlaying = function () {
  return new Promise(function (resolve, reject) {
    if (!this.playing) {
      return reject({reason: 'User must first be playing the game.'});
    }
    resolve();
  });
};

/**
 * Pauses the game and the user's gameplay timer.
 *
 * Communicates with the Galaxy API that a user has paused the game. The
 * user's playtime counter for the game is paused. It is the game's
 * responsibility to show a paused screen or overlay.
 *
 * @returns {Promise}
 * @memberOf galaxy
 */
galaxy.pause = function () {
  return new Promise(function (resolve, reject) {
    this.paused = true;
    resolve();
  });
};

/**
 * Posts a JSON blob to a friend of the user's who is also playing the game.
 *
 * Relays any arbitrary blob (serialised JSON, object or string) from one
 * friend to another using the Galaxy API. Using Redis PubSub, users are
 * automatically subscribed to their friend's data channels. It is the game's
 * responsibility to render the blobs as chat messages or virtual games in
 * the game.
 *
 * If the user is not online, the blob is stored on the server and relayed
 * to the friend when the friend plays the game next time.
 *
 * The ID of the friend appears as the `id` property in the user's `User`
 * object (returned from `galaxy.getFriends` or `galaxy.getFriendsPlaying`).
 *
 * This method is throttled by the Galaxy API.
 *
 * @param {String} friendID The ID of the friend.
 * @param {String} blob The type of data to store (i.e., a key name).
 * @returns {Promise}
 * @memberOf galaxy
 */
galaxy.postFriend = function (friendID, blob) {
  return new Promise(function (resolve, reject) {
    resolve();
  });
};

/**
 * Retrieves a JSON blob on the Galaxy API server.
 *
 * Returns a stringified JSON blob. It is the game's responsibility to
 * reconstitute the game from saved game state or user data.
 *
 * This method is throttled by the Galaxy API.
 *
 * @param {String} type The type of data to store (i.e., a key name).
 * @param {String} value The value of data to store (i.e., any arbitrary blob).
 * @returns {Promise}
 * @memberOf galaxy
 */
galaxy.retrieve = function (type) {
  return new Promise(function (resolve, reject) {
    resolve();
  });
};

/**
 * Stores a JSON blob on the Galaxy API server.
 *
 * Stores any arbitrary blob (JSON, object or string) in the Galaxy database.
 * This can be anything pertaining to the game state or any user data.
 *
 * This method is throttled by the Galaxy API.
 *
 * @param {String} type The type of data to store (i.e., a key name).
 * @param {String} blob The value of data to store (i.e., any arbitrary blob).
 * @returns {Promise}
 * @memberOf galaxy
 */
galaxy.store = function (type, blob) {
  return new Promise(function (resolve, reject) {
    resolve();
  });
};

/**
 * Unpauses the game and the user's gameplay timer.
 *
 * Communicates with the Galaxy API that a user has resumed the game. The user's
 * playtime counter for the game is resumed. It is the game's responsibility
 * to show a paused screen or overlay.
 *
 * @returns {Promise}
 * @memberOf galaxy
 */
galaxy.unpause = function () {
  return new Promise(function (resolve, reject) {
    if (!this.paused) {
      return reject({reason: 'User must first have paused the game.'});
    }
    resolve();
  });
};

/**
 * Updates the user's score for a particular game leaderboard.
 *
 * The leaderboard must be already be created (via the REST API). The number
 * of points are incremented to the user's leaderboard score.
 *
 * This method is throttled by the Galaxy API.
 *
 * @param {String} board The slug of the game leaderboard.
 * @param {String} increment The number of points to increment by.
 * @returns {Promise}
 * @memberOf galaxy
 */
galaxy.updateScore = function (board, increment) {
  return new Promise(function (resolve, reject) {
    resolve();
  });
};

// Export the module via AMD, CommonJS or as a browser global.
// Export code from https://github.com/umdjs/umd/blob/master/returnExports.js
;(function (root, factory) {
  if (typeof define === 'function' && define.amd) {
    // AMD. Register as an anonymous module.
    define(factory);
  } else if (typeof exports === 'object') {
    // NodeJS. Does not work with strict CommonJS, but only CommonJS-like
    // environments that support module.exports, like NodeJS.
    module.exports = factory();
  } else {
    // Browser globals (root is window).
    root.galaxy = factory();
  }
}(this, function () {
  // Just return a value to define the module export. This example returns an
  // object, but the module can return a function as the exported value.
  return galaxy;
}));

})();

}, {"kallaspriit/HTML5-JavaScript-Gamepad-Controller-Library@c38f53b:/gamepad.js":2}],
2: [function(require, module, exports) {
/*
 * Copyright 2012 Priit Kallas <kallaspriit@gmail.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

(function(exports) {
	'use strict';

	/**
	 * A null function - does nothing, returns nothing
	 */
	var nullFunction = function() {};

	/**
	 * The null platform, which doesn't support anything
	 */
	var nullPlatform = {
		getType: function() {
			return 'null';
		},
		isSupported: function() {
			return false;
		},
		update: nullFunction
	};

	/**
	 * This strategy uses a timer function to call an update function.
	 * The timer (re)start function can be provided or the strategy reverts to
	 * one of the window.*requestAnimationFrame variants.
	 *
	 * @class AnimFrameUpdateStrategy
	 * @constructor
	 * @param {Function} [requestAnimationFrame] function to use for timer creation
	 * @module Gamepad
	 */
	var AnimFrameUpdateStrategy = function(requestAnimationFrame) {
		var that = this;
		var win = window;

		this.update = nullFunction;

		this.requestAnimationFrame = requestAnimationFrame || win.requestAnimationFrame ||
			win.webkitRequestAnimationFrame || win.mozRequestAnimationFrame;

		/**
		 * This method calls the (user) update and restarts itself
		 * @method tickFunction
		 */
		this.tickFunction = function() {
			that.update();
			that.startTicker();
		};

		/**
		 * (Re)Starts the ticker
		 * @method startTicker
		 */
		this.startTicker = function() {
			that.requestAnimationFrame.apply(win, [that.tickFunction]);
		};
	};

	/**
	 * Starts the update strategy using the given function
	 *
	 * @method start
	 * @param {Function} updateFunction the function to call at each update
	 */
	AnimFrameUpdateStrategy.prototype.start = function(updateFunction) {
		this.update = updateFunction || nullFunction;
		this.startTicker();
	};

	/**
	 * This strategy gives the user the ability to call the library internal
	 * update function on request. Use this strategy if you already have a
	 * timer function running by requestAnimationFrame and you need fine control
	 * over when the gamepads are updated.
	 *
	 * @class ManualUpdateStrategy
	 * @constructor
	 * @module Gamepad
	 */
	var ManualUpdateStrategy = function() {

	};

	/**
	 * Calls the update function in the started state. Does nothing otherwise.
	 * @method update
	 */
	ManualUpdateStrategy.prototype.update = nullFunction;

	/**
	 * Starts the update strategy using the given function
	 *
	 * @method start
	 * @param {Function} updateFunction the function to call at each update
	 */
	ManualUpdateStrategy.prototype.start = function(updateFunction) {
		this.update = updateFunction || nullFunction;
	};

	/**
	 * This platform is for webkit based environments that need to be polled
	 * for updates.
	 *
	 * @class WebKitPlatform
	 * @constructor
	 * @param {Object} listener the listener to provide _connect and _disconnect callbacks
	 * @param {Function} gamepadGetter the poll function to return an array of connected gamepads
	 * @module Gamepad
	 */
	var WebKitPlatform = function(listener, gamepadGetter) {
		this.listener = listener;
		this.gamepadGetter = gamepadGetter;
		this.knownGamepads = [];
	};

	/**
	 * Provides a platform object that returns true for isSupported() if valid.
	 * @method factory
	 * @static
	 * @param {Object} listener the listener to use
	 * @return {Object} a platform object
	 */
	WebKitPlatform.factory = function(listener) {
		var platform = nullPlatform;
		var navigator = window && window.navigator;

		if (navigator) {
			if (typeof(navigator.getGamepads) !== 'undefined') {
				platform = new WebKitPlatform(listener, function() {
					return navigator.getGamepads();
				});
			} else if (typeof(navigator.webkitGamepads) !== 'undefined') {
				platform = new WebKitPlatform(listener, function() {
					return navigator.webkitGamepads();
				});
			} else if (typeof(navigator.webkitGetGamepads) !== 'undefined') {
				platform = new WebKitPlatform(listener, function() {
					return navigator.webkitGetGamepads();
				});
			}
		}

		return platform;
	};

	/**
	 * @method getType()
	 * @static
	 * @return {String} 'WebKit'
	 */
	WebKitPlatform.getType = function() {
		return 'WebKit';
	},

	/**
	 * @method getType()
	 * @return {String} 'WebKit'
	 */
	WebKitPlatform.prototype.getType = function() {
		return WebKitPlatform.getType();
	},

	/**
	 * @method isSupported
	 * @return {Boolean} true
	 */
	WebKitPlatform.prototype.isSupported = function() {
		return true;
	};

	/**
	 * Queries the currently connected gamepads and reports any changes.
	 * @method update
	 */
	WebKitPlatform.prototype.update = function() {
		var that = this;
		var gamepads = Array.prototype.slice.call(this.gamepadGetter(), 0);
		var gamepad;
		var i;

		for (i = this.knownGamepads.length - 1; i >= 0; i--) {
			gamepad = this.knownGamepads[i];
			if (gamepads.indexOf(gamepad) < 0) {
				this.knownGamepads.splice(i, 1);
				this.listener._disconnect(gamepad);
			}
		}

		for (i = 0; i < gamepads.length; i++) {
			gamepad = gamepads[i];
			if (gamepad && (that.knownGamepads.indexOf(gamepad) < 0)) {
				that.knownGamepads.push(gamepad);
				that.listener._connect(gamepad);
			}
		}
	};

	/**
	 * This platform is for mozilla based environments that provide gamepad
	 * updates via events.
	 *
	 * @class FirefoxPlatform
	 * @constructor
	 * @module Gamepad
	 */
	var FirefoxPlatform = function(listener) {
		this.listener = listener;

		window.addEventListener('gamepadconnected', function(e) {
			listener._connect(e.gamepad);
		});
		window.addEventListener('gamepaddisconnected', function(e) {
			listener._disconnect(e.gamepad);
		});
	};

	/**
	 * Provides a platform object that returns true for isSupported() if valid.
	 * @method factory
	 * @static
	 * @param {Object} listener the listener to use
	 * @return {Object} a platform object
	 */
	FirefoxPlatform.factory = function(listener) {
		var platform = nullPlatform;

		if (window && (typeof(window.addEventListener) !== 'undefined')) {
			platform = new FirefoxPlatform(listener);
		}

		return platform;
	};

	/**
	 * @method getType()
	 * @static
	 * @return {String} 'Firefox'
	 */
	FirefoxPlatform.getType = function() {
		return 'Firefox';
	},

	/**
	 * @method getType()
	 * @return {String} 'Firefox'
	 */
	FirefoxPlatform.prototype.getType = function() {
		return FirefoxPlatform.getType();
	},

	/**
	 * @method isSupported
	 * @return {Boolean} true
	 */
	FirefoxPlatform.prototype.isSupported = function() {
		var navigator = window && window.navigator;
		return navigator.userAgent.indexOf('Firefox') !== -1;
	};

	/**
	 * Does nothing on the Firefox platform
	 * @method update
	 */
	FirefoxPlatform.prototype.update = nullFunction;

	/**
	 * Provides simple interface and multi-platform support for the gamepad API.
	 *
	 * You can change the deadzone and maximizeThreshold parameters to suit your
	 * taste but the defaults should generally work fine.
	 *
	 * @class Gamepad
	 * @constructor
	 * @param {Object} [updateStrategy] an update strategy, defaulting to
	 *		{{#crossLink "AnimFrameUpdateStrategy"}}{{/crossLink}}
	 * @module Gamepad
	 * @author Priit Kallas <kallaspriit@gmail.com>
	 */
	var Gamepad = function(updateStrategy) {
		this.updateStrategy = updateStrategy || new AnimFrameUpdateStrategy();
		this.gamepads = [];
		this.listeners = {};
		this.platform = nullPlatform;
		this.deadzone = 0.03;
		this.maximizeThreshold = 0.97;
	};

	/**
	 * The available update strategies
	 * @property UpdateStrategies
	 * @param {AnimFrameUpdateStrategy} AnimFrameUpdateStrategy
	 * @param {ManualUpdateStrategy} ManualUpdateStrategy
	 */
	Gamepad.UpdateStrategies = {
		AnimFrameUpdateStrategy: AnimFrameUpdateStrategy,
		ManualUpdateStrategy: ManualUpdateStrategy
	};

	/**
	 * List of factories of supported platforms. Currently available platforms:
	 * {{#crossLink "WebKitPlatform"}}{{/crossLink}},
	 * {{#crossLink "FirefoxPlatform"}}{{/crossLink}},
	 * @property PlatformFactories
	 * @type {Array}
	 */
	Gamepad.PlatformFactories = [FirefoxPlatform.factory, WebKitPlatform.factory];

	/**
	 * List of supported controller types.
	 *
	 * @property Type
	 * @param {String} Type.N64 Retrolink N64 controller
	 * @param {String} Type.PLAYSTATION Playstation controller
	 * @param {String} Type.LOGITECH Logitech controller
	 * @param {String} Type.XBOX XBOX controller
	 * @param {String} Type.UNKNOWN Unknown controller
	 */
	Gamepad.Type = {
		N64: 'n64',
		PLAYSTATION: 'playstation',
		LOGITECH: 'logitech',
		XBOX: 'xbox',
		UNKNOWN: 'unknown'
	};

	/*
	 * List of events you can expect from the library.
	 *
	 * CONNECTED, DISCONNECTED and UNSUPPORTED events include the gamepad in
	 * question and tick provides the list of all connected gamepads.
	 *
	 * BUTTON_DOWN and BUTTON_UP events provide an alternative to polling button states at each tick.
	 *
	 * AXIS_CHANGED is called if a value of some specific axis changes.
	 */
	Gamepad.Event = {
		/**
		 * Triggered when a new controller connects.
		 *
		 * @event connected
		 * @param {Object} device
		 */
		CONNECTED: 'connected',

		/**
		 * Called when an unsupported controller connects.
		 *
		 * @event unsupported
		 * @param {Object} device
		 * @deprecated not used anymore. Any controller is supported.
		 */
		UNSUPPORTED: 'unsupported',

		/**
		 * Triggered when a controller disconnects.
		 *
		 * @event disconnected
		 * @param {Object} device
		 */
		DISCONNECTED: 'disconnected',

		/**
		 * Called regularly with the latest controllers info.
		 *
		 * @event tick
		 * @param {Array} gamepads
		 */
		TICK: 'tick',

		/**
		 * Called when a gamepad button is pressed down.
		 *
		 * @event button-down
		 * @param {Object} event
		 * @param {Object} event.gamepad The gamepad object
		 * @param {String} event.control Control name
		 */
		BUTTON_DOWN: 'button-down',

		/**
		 * Called when a gamepad button is released.
		 *
		 * @event button-up
		 * @param {Object} event
		 * @param {Object} event.gamepad The gamepad object
		 * @param {String} event.control Control name
		 */
		BUTTON_UP: 'button-up',

		/**
		 * Called when gamepad axis value changed.
		 *
		 * @event axis-changed
		 * @param {Object} event
		 * @param {Object} event.gamepad The gamepad object
		 * @param {String} event.axis Axis name
		 * @param {Number} event.value New axis value
		 */
		AXIS_CHANGED: 'axis-changed'
	};

	/**
	 * List of standard button names. The index is the according standard button
	 * index as per standard.
	 *
	 * @property StandardButtons
	 */
	Gamepad.StandardButtons = [
		'FACE_1', 'FACE_2', 'FACE_3', 'FACE_4',
		'LEFT_TOP_SHOULDER', 'RIGHT_TOP_SHOULDER', 'LEFT_BOTTOM_SHOULDER', 'RIGHT_BOTTOM_SHOULDER',
		'SELECT_BACK', 'START_FORWARD', 'LEFT_STICK', 'RIGHT_STICK',
		'DPAD_UP', 'DPAD_DOWN', 'DPAD_LEFT', 'DPAD_RIGHT',
		'HOME'
	];

	/**
	 * List of standard axis names. The index is the according standard axis
	 * index as per standard.
	 *
	 * @property StandardAxes
	 */
	Gamepad.StandardAxes = ['LEFT_STICK_X', 'LEFT_STICK_Y', 'RIGHT_STICK_X', 'RIGHT_STICK_Y'];

	var getControlName = function(names, index, extraPrefix) {
		return (index < names.length) ? names[index] : extraPrefix + (index - names.length + 1);
	};

	/**
	 * The standard mapping that represents the mapping as per definition.
	 * Each button and axis map to the same index.
	 *
	 * @property StandardMapping
	 */
	Gamepad.StandardMapping = {
		env: {},
		buttons: {
			byButton: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
		},
		axes: {
			byAxis: [0, 1, 2, 3]
		}
	};

	/**
	 * Mapping of various gamepads that differ from the standard mapping on
	 * different platforms too unify their buttons and axes.
	 *
	 * Each mapping should have an 'env' object, which describes the environment
	 * in which the mapping is active. The more entries such an environment has,
	 * the more specific it is.
	 *
	 * Mappings are expressed for both buttons and axes. Buttons might refer to
	 * axes if they are notified as such.
	 *
	 * @property Mappings
	 */
	Gamepad.Mappings = [
		// Retrolink N64 controller on Firefox
		{
			env: {
				platform: FirefoxPlatform.getType(),
				type: Gamepad.Type.N64
			},
			buttons: {
				byButton: [
					// TODO: Figure out which buttons to map A and Z buttons to.
					2, // FACE_1 -- C-down button
					1, // FACE_2 -- C-right button
					3, // FACE_3 -- C-left button
					0, // FACE_4 -- C-down button
					4, // LEFT_TOP_SHOULDER -- L button
					5, // RIGHT_TOP_SHOULDER -- R button
					-1, // LEFT_BOTTOM_SHOULDER -- missing on controller
					-1, // RIGHT_BOTTOM_SHOULDER -- missing on controller
					8, // SELECT_BACK -- B button (is this right?)
					9, // START_FORWARD -- START button
					-1, // LEFT_STICK -- missing on controller
					-1, // RIGHT_STICK -- missing on controller
					12, // DPAD_UP -- not supported by API (but may eventually)
					13, // DPAD_DOWN -- not supported by API (but may eventually)
					14, // DPAD_LEFT -- not supported by API (but may eventually)
					15, // DPAD_RIGHT -- not supported by API (but may eventually)
					-1 // HOME -- missing on controller (could be START/B?)
				]
			},
			axes: {
				byAxis: [
					1, // LEFT_STICK_X
					2, // LEFT_STICK_Y
					-1, // RIGHT_STICK_X
					-1 // RIGHT_STICK_Y
				]
			}
		},
		// Retrolink N64 controller on WebKit
		{
			env: {
				platform: WebKitPlatform.getType(),
				type: Gamepad.Type.N64
			},
			buttons: {
				byButton: [
					// TODO: Figure out which buttons to map A and Z buttons to.
					2, // FACE_1 -- C-down button
					1, // FACE_2 -- C-right button
					3, // FACE_3 -- C-left button
					0, // FACE_4 -- C-down button
					4, // LEFT_TOP_SHOULDER -- L button
					5, // RIGHT_TOP_SHOULDER -- R button
					-1, // LEFT_BOTTOM_SHOULDER -- missing on controller
					-1, // RIGHT_BOTTOM_SHOULDER -- missing on controller
					8, // SELECT_BACK -- B button (is this right?)
					9, // START_FORWARD -- START button
					-1, // LEFT_STICK -- missing on controller
					-1, // RIGHT_STICK -- missing on controller
					12, // DPAD_UP -- D-Pad-up button
					13, // DPAD_DOWN -- D-Pad-down button
					14, // DPAD_LEFT -- D-Pad-left button
					15, // DPAD_RIGHT -- D-Pad-right button
					-1 // HOME -- missing on controller (could be START/B?)
				]
			},
			axes: {
				byAxis: [
					0, // LEFT_STICK_X
					1, // LEFT_STICK_Y
					-1, // RIGHT_STICK_X
					-1 // RIGHT_STICK_Y
				]
			}
		},
		// XBOX360 controller on Firefox
		{
			env: {
				platform: FirefoxPlatform.getType(),
				type: Gamepad.Type.XBOX
			},
			buttons: {
				byButton: [0, 1, 2, 3, 4, 5, 15, 16, 9, 8, 6, 7, 11, 12, 13, 14, 10]
			},
			axes: {
				byAxis: [0, 1, 2, 3]
			}
		},
		// PS3 controller on Firefox
		{
			env: {
				platform: FirefoxPlatform.getType(),
				type: Gamepad.Type.PLAYSTATION
			},
			buttons: {
				byButton: [14, 13, 15, 12, 10, 11, 8, 9, 0, 3, 1, 2, 4, 6, 7, 5, 16]
			},
			axes: {
				byAxis: [0, 1, 2, 3]
			}
		},
		// Logitech gamepad on WebKit
		{
			env: {
				platform: WebKitPlatform.getType(),
				type: Gamepad.Type.LOGITECH
			},
			buttons: { // TODO: This can't be right - LEFT/RIGHT_STICK have same mappings as HOME/DPAD_UP
				byButton: [1, 2, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 10]
			},
			axes: {
				byAxis: [0, 1, 2, 3]
			}
		},
		// Logitech gamepad on Firefox
		{
			env: {
				platform: FirefoxPlatform.getType(),
				type: Gamepad.Type.LOGITECH
			},
			buttons: {
				byButton: [0, 1, 2, 3, 4, 5, -1, -1, 6, 7, 8, 9, 11, 12, 13, 14, 10],
				byAxis: [-1, -1, -1, -1, -1, -1, [2, 0, 1],
					[2, 0, -1]
				]
			},
			axes: {
				byAxis: [0, 1, 3, 4]
			}
		}
	];

	/**
	 * Initializes the gamepad.
	 *
	 * You usually want to bind to the events first and then initialize it.
	 *
	 * @method init
	 * @return {Boolean} true if a supporting platform was detected, false otherwise.
	 */
	Gamepad.prototype.init = function() {
		var platform = Gamepad.resolvePlatform(this);
		var that = this;

		this.platform = platform;
		this.updateStrategy.start(function() {
			that._update();
		});

		return platform.isSupported();
	};

	/**
	 * Binds a listener to a gamepad event.
	 *
	 * @method bind
	 * @param {String} event Event to bind to, one of Gamepad.Event..
	 * @param {Function} listener Listener to call when given event occurs
	 * @return {Gamepad} Self
	 */
	Gamepad.prototype.bind = function(event, listener) {
		if (typeof(this.listeners[event]) === 'undefined') {
			this.listeners[event] = [];
		}

		this.listeners[event].push(listener);

		return this;
	};

	/**
	 * Removes listener of given type.
	 *
	 * If no type is given, all listeners are removed. If no listener is given, all
	 * listeners of given type are removed.
	 *
	 * @method unbind
	 * @param {String} [type] Type of listener to remove
	 * @param {Function} [listener] The listener function to remove
	 * @return {Boolean} Was unbinding the listener successful
	 */
	Gamepad.prototype.unbind = function(type, listener) {
		if (typeof(type) === 'undefined') {
			this.listeners = {};

			return;
		}

		if (typeof(listener) === 'undefined') {
			this.listeners[type] = [];

			return;
		}

		if (typeof(this.listeners[type]) === 'undefined') {
			return false;
		}

		for (var i = 0; i < this.listeners[type].length; i++) {
			if (this.listeners[type][i] === listener) {
				this.listeners[type].splice(i, 1);

				return true;
			}
		}

		return false;
	};

	/**
	 * Returns the number of connected gamepads.
	 *
	 * @method count
	 * @return {Number}
	 */
	Gamepad.prototype.count = function() {
		return this.gamepads.length;
	};

	/**
	 * Fires an internal event with given data.
	 *
	 * @method _fire
	 * @param {String} event Event to fire, one of Gamepad.Event..
	 * @param {*} data Data to pass to the listener
	 * @private
	 */
	Gamepad.prototype._fire = function(event, data) {
		if (typeof(this.listeners[event]) === 'undefined') {
			return;
		}

		for (var i = 0; i < this.listeners[event].length; i++) {
			this.listeners[event][i].apply(this.listeners[event][i], [data]);
		}
	};

	/**
	 * @method getNullPlatform
	 * @static
	 * @return {Object} a platform that does not support anything
	 */
	Gamepad.getNullPlatform = function() {
		return Object.create(nullPlatform);
	};

	/**
	 * Resolves platform.
	 *
	 * @method resolvePlatform
	 * @static
	 * @param listener {Object} the listener to handle _connect() or _disconnect() calls
	 * @return {Object} A platform instance
	 */
	Gamepad.resolvePlatform = function(listener) {
		var platform = nullPlatform;
		var i;

		for (i = 0; !platform.isSupported() && (i < Gamepad.PlatformFactories.length); i++) {
			platform = Gamepad.PlatformFactories[i](listener);
		}

		return platform;
	};

	/**
	 * Registers given gamepad.
	 *
	 * @method _connect
	 * @param {Object} gamepad Gamepad to connect to
	 * @private
	 */
	Gamepad.prototype._connect = function(gamepad) {
		var mapping = this._resolveMapping(gamepad);
		var count;
		var i;

		//gamepad.mapping = this._resolveMapping(gamepad);
		gamepad.state = {};
		gamepad.lastState = {};
		gamepad.updater = [];

		count = mapping.buttons.byButton.length;
		for (i = 0; i < count; i++) {
			this._addButtonUpdater(gamepad, mapping, i);
		}

		count = mapping.axes.byAxis.length;
		for (i = 0; i < count; i++) {
			this._addAxisUpdater(gamepad, mapping, i);
		}

		this.gamepads[gamepad.index] = gamepad;

		this._fire(Gamepad.Event.CONNECTED, gamepad);
	};

	/**
	 * Adds an updater for a button control
	 *
	 * @method _addButtonUpdater
	 * @private
	 * @param {Object} gamepad the gamepad for which to create the updater
	 * @param {Object} mapping the mapping on which to work on
	 * @param {Number} index button index
	 */
	Gamepad.prototype._addButtonUpdater = function(gamepad, mapping, index) {
		var updater = nullFunction;
		var controlName = getControlName(Gamepad.StandardButtons, index, 'EXTRA_BUTTON_');
		var getter = this._createButtonGetter(gamepad, mapping.buttons, index);
		var that = this;
		var buttonEventData = {
			gamepad: gamepad,
			control: controlName
		};

		gamepad.state[controlName] = 0;
		gamepad.lastState[controlName] = 0;

		updater = function() {
			var value = getter();
			var lastValue = gamepad.lastState[controlName];
			var isDown = value > 0.5;
			var wasDown = lastValue > 0.5;

			gamepad.state[controlName] = value;

			if (isDown && !wasDown) {
				that._fire(Gamepad.Event.BUTTON_DOWN, Object.create(buttonEventData));
			} else if (!isDown && wasDown) {
				that._fire(Gamepad.Event.BUTTON_UP, Object.create(buttonEventData));
			}

			if ((value !== 0) && (value !== 1) && (value !== lastValue)) {
				that._fireAxisChangedEvent(gamepad, controlName, value);
			}

			gamepad.lastState[controlName] = value;
		};

		gamepad.updater.push(updater);
	};

	/**
	 * Adds an updater for an axis control
	 *
	 * @method _addAxisUpdater
	 * @private
	 * @param {Object} gamepad the gamepad for which to create the updater
	 * @param {Object} mapping the mapping on which to work on
	 * @param {Number} index axis index
	 */
	Gamepad.prototype._addAxisUpdater = function(gamepad, mapping, index) {
		var updater = nullFunction;
		var controlName = getControlName(Gamepad.StandardAxes, index, 'EXTRA_AXIS_');
		var getter = this._createAxisGetter(gamepad, mapping.axes, index);
		var that = this;

		gamepad.state[controlName] = 0;
		gamepad.lastState[controlName] = 0;

		updater = function() {
			var value = getter();
			var lastValue = gamepad.lastState[controlName];

			gamepad.state[controlName] = value;

			if ((value !== lastValue)) {
				that._fireAxisChangedEvent(gamepad, controlName, value);
			}

			gamepad.lastState[controlName] = value;
		};

		gamepad.updater.push(updater);
	};

	/**
	 * Fires an AXIS_CHANGED event
	 * @method _fireAxisChangedEvent
	 * @private
	 * @param {Object} gamepad the gamepad to notify for
	 * @param {String} controlName name of the control that changes its value
	 * @param {Number} value the new value
	 */
	Gamepad.prototype._fireAxisChangedEvent = function(gamepad, controlName, value) {
		var eventData = {
			gamepad: gamepad,
			axis: controlName,
			value: value
		};

		this._fire(Gamepad.Event.AXIS_CHANGED, eventData);
	};

	/**
	 * Creates a getter according to the mapping entry for the specific index.
	 * Currently supported entries:
	 *
	 * buttons.byButton[index]: Number := Index into gamepad.buttons; -1 tests byAxis
	 * buttons.byAxis[index]: Array := [Index into gamepad.axes; Zero Value, One Value]
	 *
	 * @method _createButtonGetter
	 * @private
	 * @param {Object} gamepad the gamepad for which to create a getter
	 * @param {Object} buttons the mappings entry for the buttons
	 * @param {Number} index the specific button entry
	 * @return {Function} a getter returning the value for the requested button
	 */
	Gamepad.prototype._createButtonGetter = (function() {
		var nullGetter = function() {
			return 0;
		};

		var createRangeGetter = function(valueGetter, from, to) {
			var getter = nullGetter;

			if (from < to) {
				getter = function() {
					var range = to - from;
					var value = valueGetter();

					value = (value - from) / range;

					return (value < 0) ? 0 : value;
				};
			} else if (to < from) {
				getter = function() {
					var range = from - to;
					var value = valueGetter();

					value = (value - to) / range;

					return (value > 1) ? 0 : (1 - value);
				};
			}

			return getter;
		};

		var isArray = function(thing) {
			return Object.prototype.toString.call(thing) === '[object Array]';
		};

		return function(gamepad, buttons, index) {
			var getter = nullGetter;
			var entry;
			var that = this;

			entry = buttons.byButton[index];
			if (entry !== -1) {
				if ((typeof(entry) === 'number') && (entry < gamepad.buttons.length)) {
					getter = function() {
						var value = gamepad.buttons[entry];

						if (typeof value === 'number') {
							return value;
						}

						if (typeof value.value === 'number') {
							return value.value;
						}

						return 0;
					};
				}
			} else if (buttons.byAxis && (index < buttons.byAxis.length)) {
				entry = buttons.byAxis[index];
				if (isArray(entry) && (entry.length == 3) && (entry[0] < gamepad.axes.length)) {
					getter = function() {
						var value = gamepad.axes[entry[0]];

						return that._applyDeadzoneMaximize(value);
					};

					getter = createRangeGetter(getter, entry[1], entry[2]);
				}
			}

			return getter;
		};
	})();

	/**
	 * Creates a getter according to the mapping entry for the specific index.
	 * Currently supported entries:
	 *
	 * axes.byAxis[index]: Number := Index into gamepad.axes; -1 ignored
	 *
	 * @method _createAxisGetter
	 * @private
	 * @param {Object} gamepad the gamepad for which to create a getter
	 * @param {Object} axes the mappings entry for the axes
	 * @param {Number} index the specific axis entry
	 * @return {Function} a getter returning the value for the requested axis
	 */
	Gamepad.prototype._createAxisGetter = (function() {
		var nullGetter = function() {
			return 0;
		};

		return function(gamepad, axes, index) {
			var getter = nullGetter;
			var entry;
			var that = this;

			entry = axes.byAxis[index];
			if (entry !== -1) {
				if ((typeof(entry) === 'number') && (entry < gamepad.axes.length)) {
					getter = function() {
						var value = gamepad.axes[entry];

						return that._applyDeadzoneMaximize(value);
					};
				}
			}

			return getter;
		};
	})();

	/**
	 * Disconnects from given gamepad.
	 *
	 * @method _disconnect
	 * @param {Object} gamepad Gamepad to disconnect
	 * @private
	 */
	Gamepad.prototype._disconnect = function(gamepad) {
		var newGamepads = [],
			i;

		if (typeof(this.gamepads[gamepad.index]) !== 'undefined') {
			delete this.gamepads[gamepad.index];
		}

		for (i = 0; i < this.gamepads.length; i++) {
			if (typeof(this.gamepads[i]) !== 'undefined') {
				newGamepads[i] = this.gamepads[i];
			}
		}

		this.gamepads = newGamepads;

		this._fire(Gamepad.Event.DISCONNECTED, gamepad);
	};

	/**
	 * Resolves controller type from its id.
	 *
	 * @method _resolveControllerType
	 * @param {String} id Controller id
	 * @return {String} Controller type, one of Gamepad.Type
	 * @private
	 */
	Gamepad.prototype._resolveControllerType = function(id) {
		// Lowercase and strip all extra whitespace.
		id = id.toLowerCase().replace(/\s+/g, ' ').replace(/^\s+|\s+$/g, '');

		if (id.indexOf('playstation') !== -1) {
			return Gamepad.Type.PLAYSTATION;
		} else if (
			id.indexOf('logitech') !== -1 || id.indexOf('wireless gamepad') !== -1) {
			return Gamepad.Type.LOGITECH;
		} else if (id.indexOf('xbox') !== -1 || id.indexOf('360') !== -1) {
			return Gamepad.Type.XBOX;
		} else if ((id.indexOf('79-6-generic') !== -1 && id.indexOf('joystick') !== -1) ||
			(id.indexOf('vendor: 0079 product: 0006') !== -1 &&
				id.indexOf('generic usb joystick') !== -1)) {
			return Gamepad.Type.N64;
		} else {
			return Gamepad.Type.UNKNOWN;
		}
	};

	/**
	 * @method _resolveMapping
	 * @private
	 * @param {Object} gamepad the gamepad for which to resolve the mapping
	 * @return {Object} a mapping object for the given gamepad
	 */
	Gamepad.prototype._resolveMapping = function(gamepad) {
		var mappings = Gamepad.Mappings;
		var mapping = null;
		var env = {
			platform: this.platform.getType(),
			type: this._resolveControllerType(gamepad.id)
		};
		var i;
		var test;

		for (i = 0; !mapping && (i < mappings.length); i++) {
			test = mappings[i];
			if (Gamepad.envMatchesFilter(test.env, env)) {
				mapping = test;
			}
		}

		return mapping || Gamepad.StandardMapping;
	};

	/**
	 * @method envMatchesFilter
	 * @static
	 * @param {Object} filter the filter object describing properties to match
	 * @param {Object} env the environment object that is matched against filter
	 * @return {Boolean} true if env is covered by filter
	 */
	Gamepad.envMatchesFilter = function(filter, env) {
		var result = true;
		var field;

		for (field in filter) {
			if (filter[field] !== env[field]) {
				result = false;
			}
		}

		return result;
	};

	/**
	 * Updates the controllers, triggering TICK events.
	 *
	 * @method _update
	 * @private
	 */
	Gamepad.prototype._update = function() {
		this.platform.update();

		this.gamepads.forEach(function(gamepad) {
			if (gamepad) {
				gamepad.updater.forEach(function(updater) {
					updater();
				});
			}
		});

		if (this.gamepads.length > 0) {
			this._fire(Gamepad.Event.TICK, this.gamepads);
		}
	},

	/**
	 * Applies deadzone and maximization.
	 *
	 * You can change the thresholds via deadzone and maximizeThreshold members.
	 *
	 * @method _applyDeadzoneMaximize
	 * @param {Number} value Value to modify
	 * @param {Number} [deadzone] Deadzone to apply
	 * @param {Number} [maximizeThreshold] From which value to maximize value
	 * @private
	 */
	Gamepad.prototype._applyDeadzoneMaximize = function(
		value,
		deadzone,
		maximizeThreshold) {
		deadzone = typeof(deadzone) !== 'undefined' ? deadzone : this.deadzone;
		maximizeThreshold = typeof(maximizeThreshold) !== 'undefined' ? maximizeThreshold : this.maximizeThreshold;

		if (value >= 0) {
			if (value < deadzone) {
				value = 0;
			} else if (value > maximizeThreshold) {
				value = 1;
			}
		} else {
			if (value > -deadzone) {
				value = 0;
			} else if (value < -maximizeThreshold) {
				value = -1;
			}
		}

		return value;
	};

	exports.Gamepad = Gamepad;

})(((typeof(module) !== 'undefined') && module.exports) || window);

}, {}]}, {}, {"1":""})


text:
$(function () {
    $(".search-xiami-btn").click(function () {
        var $searchItem = $(this).parent(".search-item");
        var name = $searchItem.find('.search-field').val();
        if (name) {
            window.location.href = host + '/index.php/sites/xiami/search/' + name;
        }
    });

    $(document).on('click', '.add-to-play-list-btn', function () {
        var $tr = $(this).parents('tr');
        var name = $tr.find('td[data-name]').attr('data-name').trim();
        var artist = $tr.find('td[data-artist]').attr('data-artist').trim();
        var album = $tr.find('td[data-album]').attr('data-album').trim();
        var source = $tr.find('td[data-source]').attr('data-source').trim();
        var url = $tr.find('td[data-url]').attr('data-url').trim();
        var lyricUrl = $tr.find('td[data-lyric-url]').attr('data-lyric-url').trim();
        music_common.addToPlayList({
            name: name,
            artist: artist,
            album: album,
            source: source,
            url: url,
            lyricUrl: lyricUrl
        });
    });
    $(".download-all-btn").click(function () {
        var $storeBtns = $(".store-btn");
        _.each($storeBtns, function (storeBtn) {
            var url = $(storeBtn).attr('href');
            $.get(url, {}, function () {
            });
        });
        alert('已经添加到存储队列');
    });
});

redpajama_set_name: RedPajamaGithub


text:
#region license
// Copyright (c) 2005 - 2007 Ayende Rahien (ayende@ayende.com)
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//     * Neither the name of Ayende Rahien nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using Castle.ActiveRecord;

namespace Rhino.Commons
{
	[DebuggerDisplay("{Start}:{End}")]
	public struct DateRange
	{
		private DateTime start;
		private DateTime end;

		[Property(Column = "StartDate", NotNull = true, Access = PropertyAccess.FieldCamelcase)]
		public DateTime Start
		{
			get { return start; }
		}

		[Property(Column = "EndDate", NotNull = true, Access = PropertyAccess.FieldCamelcase)]
		public DateTime End
		{
			get { return end; }
		}

		public DateRange(DateTime start, DateTime end)
		{
			Guard.Against<ArgumentException>(start > end, "The start date cannot come after the end date");
			this.start = start;
			this.end = end;
		}

		public bool IsEmpty
		{
			get { return (Span.Ticks == 0); }
		}

		public TimeSpan Span
		{
			get { return end.Subtract(start); }
		}

		public bool Overlap(DateTime date)
		{
			return start <= date && date <= end;
		}

		public bool Overlap(TimeSpan time)
		{
			TimeSpan start_TimeOfDay = start.TimeOfDay;
			TimeSpan end_TimeOfDay = end.TimeOfDay;
			if (start_TimeOfDay > end_TimeOfDay)
			{
				end_TimeOfDay = end_TimeOfDay.Add(TimeSpan.FromDays(1));
			}
			return start_TimeOfDay <= time && time <= end_TimeOfDay;
		}

		public bool Overlap(DateRange range)
		{
		    return !(range.start >= this.end | range.end <= this.start);
		}

		public void ForEachDay(Proc<DateTime> action)
		{
			foreach (DateTime day in Days)
			{
				action(day);
			}
		}

		public IEnumerable<DateTime> Days
		{
			get
			{
				DateTime current = start.Date;
				DateTime endDate = end.Date;
				//Changed by bernie
				//while (current != endDate)
				while (current <= endDate)
				{
					yield return current;
					current = current.AddDays(1);
				}
			}
		}

		public void ForEachWeek(Proc<DateRange> action)
		{
			foreach (DateRange week in Weeks)
			{
				action(week);
			}
		}

		private IEnumerable<DateRange> Weeks
		{
			get
			{
				DateTime current = start;
				DateTime weekStart;
				while (current.AddDays(1).DayOfWeek != DayOfWeek.Sunday
					   && current < end)
				{
					current = current.AddDays(1);
				}
				yield return new DateRange(start, current);
				weekStart = current.AddDays(1);//current is the last day of the week
				while (weekStart < end && weekStart.AddDays(7) < end)
				{
					yield return new DateRange(weekStart, weekStart.AddDays(6));
					weekStart = weekStart.AddDays(7);
				}
				if (weekStart <= end)
					yield return new DateRange(weekStart, end);
			}
		}

		public void ForEachMonth(Proc<DateRange> action)
		{
			foreach (DateRange month in Months)
			{
				action(month);
			}
		}

		private IEnumerable<DateRange> Months
		{
			get
			{
				DateTime current = start;
				DateTime monthStart;
				while (current.AddDays(1).Day != 1 && current < end)
				{
					current = current.AddDays(1);
				}
				yield return new DateRange(start, current);
				monthStart = current.AddDays(1);//current is the last day of the month
				while (monthStart < end && monthStart.AddMonths(1) < end)
				{
					yield return new DateRange(monthStart, monthStart.AddMonths(1).AddDays(-1));
					monthStart = monthStart.AddMonths(1);
				}
				if (monthStart <= end)
					yield return new DateRange(monthStart, end);
			}
		}

		public override bool Equals(object obj)
		{
			//Equals method is provides by ValueType, which does bitwise check, which
			//is what we need.
			return base.Equals(obj);
		}

		public override int GetHashCode()
		{
			return start.GetHashCode() + end.GetHashCode();
		}

		public override string ToString()
		{
			return start.ToString() + " - " + end.ToString();
		}

		public string ToString(string format)
		{
			return start.ToString(format) + " - " + end.ToString(format);
		}

		public static DateRange Intersection(DateRange x, DateRange y)
		{
			return new DateRange(
			x.Start > y.Start ? x.Start : y.Start,
			x.End < y.End ? x.End : y.End
			);
		}
	}
}


text:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- From: file:/G:/Users/Deon_ROG/AndroidStudioProjects/MathGame1/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.0.0/res/values-w600dp-v13/values.xml -->
    <eat-comment/>
    <dimen name="abc_search_view_text_min_width">192dip</dimen>
    <integer name="abc_max_action_buttons">5</integer>
</resources>


text:
fn bad_bang(i: usize) -> ! { //~ ERROR computation may converge in a function marked as diverging
    if i < 0us { } else { panic!(); }
}

fn main() { bad_bang(5us); }


text:
package cluster_test

import (
	"database/sql"
	"fmt"
	"testing"
	"time"

	"github.com/lxc/lxd/lxd/db/cluster"
	"github.com/lxc/lxd/lxd/db/query"
	"github.com/lxc/lxd/shared/osarch"
	"github.com/mattn/go-sqlite3"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)

func TestUpdateFromV0(t *testing.T) {
	schema := cluster.Schema()
	db, err := schema.ExerciseUpdate(1, nil)
	require.NoError(t, err)

	stmt := "INSERT INTO nodes VALUES (1, 'foo', 'blah', '1.2.3.4:666', 1, 32, ?, 0)"
	_, err = db.Exec(stmt, time.Now())
	require.NoError(t, err)

	// Unique constraint on name
	stmt = "INSERT INTO nodes VALUES (2, 'foo', 'gosh', '5.6.7.8:666', 5, 20, ?, 0)"
	_, err = db.Exec(stmt, time.Now())
	require.Error(t, err)

	// Unique constraint on address
	stmt = "INSERT INTO nodes VALUES (3, 'bar', 'gasp', '1.2.3.4:666', 9, 11), ?, 0)"
	_, err = db.Exec(stmt, time.Now())
	require.Error(t, err)
}

func TestUpdateFromV1_Certificates(t *testing.T) {
	schema := cluster.Schema()
	db, err := schema.ExerciseUpdate(2, nil)
	require.NoError(t, err)

	_, err = db.Exec("INSERT INTO certificates VALUES (1, 'abcd:efgh', 1, 'foo', 'FOO')")
	require.NoError(t, err)

	// Unique constraint on fingerprint.
	_, err = db.Exec("INSERT INTO certificates VALUES (2, 'abcd:efgh', 2, 'bar', 'BAR')")
	require.Error(t, err)
}

func TestUpdateFromV1_Config(t *testing.T) {
	schema := cluster.Schema()
	db, err := schema.ExerciseUpdate(2, nil)
	require.NoError(t, err)

	_, err = db.Exec("INSERT INTO config VALUES (1, 'foo', 'blah')")
	require.NoError(t, err)

	// Unique constraint on key.
	_, err = db.Exec("INSERT INTO config VALUES (2, 'foo', 'gosh')")
	require.Error(t, err)
}

func TestUpdateFromV1_Containers(t *testing.T) {
	schema := cluster.Schema()
	db, err := schema.ExerciseUpdate(2, nil)
	require.NoError(t, err)

	_, err = db.Exec("INSERT INTO nodes VALUES (1, 'one', '', '1.1.1.1', 666, 999, ?, 0)", time.Now())
	require.NoError(t, err)

	_, err = db.Exec("INSERT INTO nodes VALUES (2, 'two', '', '2.2.2.2', 666, 999, ?, 0)", time.Now())
	require.NoError(t, err)

	_, err = db.Exec(`
INSERT INTO containers VALUES (1, 1, 'bionic', 1, 1, 0, ?, 0, ?, 'Bionic Beaver')
`, time.Now(), time.Now())
	require.NoError(t, err)

	// Unique constraint on name
	_, err = db.Exec(`
INSERT INTO containers VALUES (2, 2, 'bionic', 2, 2, 1, ?, 1, ?, 'Ubuntu LTS')
`, time.Now(), time.Now())
	require.Error(t, err)

	// Cascading delete
	_, err = db.Exec("INSERT INTO containers_config VALUES (1, 1, 'thekey', 'thevalue')")
	require.NoError(t, err)
	_, err = db.Exec("DELETE FROM containers")
	require.NoError(t, err)
	result, err := db.Exec("DELETE FROM containers_config")
	require.NoError(t, err)
	n, err := result.RowsAffected()
	require.NoError(t, err)
	assert.Equal(t, int64(0), n) // The row was already deleted by the previous query

}

func TestUpdateFromV1_Network(t *testing.T) {
	schema := cluster.Schema()
	db, err := schema.ExerciseUpdate(2, nil)
	require.NoError(t, err)

	_, err = db.Exec("INSERT INTO networks VALUES (1, 'foo', 'blah', 1)")
	require.NoError(t, err)

	// Unique constraint on name.
	_, err = db.Exec("INSERT INTO networks VALUES (2, 'foo', 'gosh', 1)")
	require.Error(t, err)
}

func TestUpdateFromV1_ConfigTables(t *testing.T) {
	testConfigTable(t, "networks", func(db *sql.DB) {
		_, err := db.Exec("INSERT INTO networks VALUES (1, 'foo', 'blah', 1)")
		require.NoError(t, err)
	})
	testConfigTable(t, "storage_pools", func(db *sql.DB) {
		_, err := db.Exec("INSERT INTO storage_pools VALUES (1, 'default', 'dir', '')")
		require.NoError(t, err)
	})
}

func testConfigTable(t *testing.T, table string, setup func(db *sql.DB)) {
	schema := cluster.Schema()
	db, err := schema.ExerciseUpdate(2, nil)
	require.NoError(t, err)

	_, err = db.Exec("INSERT INTO nodes VALUES (1, 'one', '', '1.1.1.1', 666, 999, ?, 0)", time.Now())
	require.NoError(t, err)

	_, err = db.Exec("INSERT INTO nodes VALUES (2, 'two', '', '2.2.2.2', 666, 999, ?, 0)", time.Now())
	require.NoError(t, err)

	stmt := func(format string) string {
		return fmt.Sprintf(format, table)
	}

	setup(db)

	_, err = db.Exec(stmt("INSERT INTO %s_config VALUES (1, 1, 1, 'bar', 'baz')"))
	require.NoError(t, err)

	// Unique constraint on <entity>_id/node_id/key.
	_, err = db.Exec(stmt("INSERT INTO %s_config VALUES (2, 1, 1, 'bar', 'egg')"))
	require.Error(t, err)
	_, err = db.Exec(stmt("INSERT INTO %s_config VALUES (3, 1, 2, 'bar', 'egg')"))
	require.NoError(t, err)

	// Reference constraint on <entity>_id.
	_, err = db.Exec(stmt("INSERT INTO %s_config VALUES (4, 2, 1, 'fuz', 'buz')"))
	require.Error(t, err)

	// Reference constraint on node_id.
	_, err = db.Exec(stmt("INSERT INTO %s_config VALUES (5, 1, 3, 'fuz', 'buz')"))
	require.Error(t, err)

	// Cascade deletes on node_id
	result, err := db.Exec("DELETE FROM nodes WHERE id=2")
	require.NoError(t, err)
	n, err := result.RowsAffected()
	require.NoError(t, err)
	assert.Equal(t, int64(1), n)
	result, err = db.Exec(stmt("UPDATE %s_config SET value='yuk'"))
	require.NoError(t, err)
	n, err = result.RowsAffected()
	require.NoError(t, err)
	assert.Equal(t, int64(1), n) // Only one row was affected, since the other got deleted

	// Cascade deletes on <entity>_id
	result, err = db.Exec(stmt("DELETE FROM %s"))
	require.NoError(t, err)
	n, err = result.RowsAffected()
	require.NoError(t, err)
	assert.Equal(t, int64(1), n)
	result, err = db.Exec(stmt("DELETE FROM %s_config"))
	require.NoError(t, err)
	n, err = result.RowsAffected()
	require.NoError(t, err)
	assert.Equal(t, int64(0), n) // The row was already deleted by the previous query
}

func TestUpdateFromV2(t *testing.T) {
	schema := cluster.Schema()
	db, err := schema.ExerciseUpdate(3, nil)
	require.NoError(t, err)

	_, err = db.Exec("INSERT INTO nodes VALUES (1, 'one', '', '1.1.1.1', 666, 999, ?, 0)", time.Now())
	require.NoError(t, err)

	_, err = db.Exec("INSERT INTO operations VALUES (1, 'abcd', 1)")
	require.NoError(t, err)

	// Unique constraint on uuid
	_, err = db.Exec("INSERT INTO operations VALUES (2, 'abcd', 1)")
	require.Error(t, err)

	// Cascade delete on node_id
	_, err = db.Exec("DELETE FROM nodes")
	require.NoError(t, err)
	result, err := db.Exec("DELETE FROM operations")
	require.NoError(t, err)
	n, err := result.RowsAffected()
	require.NoError(t, err)
	assert.Equal(t, int64(0), n)
}

func TestUpdateFromV3(t *testing.T) {
	schema := cluster.Schema()
	db, err := schema.ExerciseUpdate(4, nil)
	require.NoError(t, err)

	_, err = db.Exec("INSERT INTO nodes VALUES (1, 'c1', '', '1.1.1.1', 666, 999, ?, 0)", time.Now())
	require.NoError(t, err)

	_, err = db.Exec("INSERT INTO storage_pools VALUES (1, 'p1', 'zfs', '', 0)")
	require.NoError(t, err)

	_, err = db.Exec("INSERT INTO storage_pools_nodes VALUES (1, 1, 1)")
	require.NoError(t, err)

	// Unique constraint on storage_pool_id/node_id
	_, err = db.Exec("INSERT INTO storage_pools_nodes VALUES (1, 1, 1)")
	require.Error(t, err)
}

func TestUpdateFromV5(t *testing.T) {
	schema := cluster.Schema()
	db, err := schema.ExerciseUpdate(6, func(db *sql.DB) {
		// Create two nodes.
		_, err := db.Exec(
			"INSERT INTO nodes VALUES (1, 'n1', '', '1.2.3.4:666', 1, 32, ?, 0)",
			time.Now())
		require.NoError(t, err)
		_, err = db.Exec(
			"INSERT INTO nodes VALUES (2, 'n2', '', '5.6.7.8:666', 1, 32, ?, 0)",
			time.Now())
		require.NoError(t, err)

		// Create a pool p1 of type zfs.
		_, err = db.Exec("INSERT INTO storage_pools VALUES (1, 'p1', 'zfs', '', 0)")
		require.NoError(t, err)

		// Create a pool p2 of type ceph.
		_, err = db.Exec("INSERT INTO storage_pools VALUES (2, 'p2', 'ceph', '', 0)")

		// Create a volume v1 on pool p1, associated with n1 and a config.
		require.NoError(t, err)
		_, err = db.Exec("INSERT INTO storage_volumes VALUES (1, 'v1', 1, 1, 1, '')")
		require.NoError(t, err)
		_, err = db.Exec("INSERT INTO storage_volumes_config VALUES (1, 1, 'k', 'v')")
		require.NoError(t, err)

		// Create a volume v1 on pool p2, associated with n1 and a config.
		require.NoError(t, err)
		_, err = db.Exec("INSERT INTO storage_volumes VALUES (2, 'v1', 2, 1, 1, '')")
		require.NoError(t, err)
		_, err = db.Exec("INSERT INTO storage_volumes_config VALUES (2, 2, 'k', 'v')")
		require.NoError(t, err)

		// Create a volume v2 on pool p2, associated with n2 and no config.
		require.NoError(t, err)
		_, err = db.Exec("INSERT INTO storage_volumes VALUES (3, 'v2', 2, 2, 1, '')")
		require.NoError(t, err)
	})
	require.NoError(t, err)

	// Check that a volume row for n2 was added for v1 on p2.
	tx, err := db.Begin()
	require.NoError(t, err)
	defer tx.Rollback()
	nodeIDs, err := query.SelectIntegers(tx, `
SELECT node_id FROM storage_volumes WHERE storage_pool_id=2 AND name='v1' ORDER BY node_id
`)
	require.NoError(t, err)
	require.Equal(t, []int{1, 2}, nodeIDs)

	// Check that a volume row for n1 was added for v2 on p2.
	nodeIDs, err = query.SelectIntegers(tx, `
SELECT node_id FROM storage_volumes WHERE storage_pool_id=2 AND name='v2' ORDER BY node_id
`)
	require.NoError(t, err)
	require.Equal(t, []int{1, 2}, nodeIDs)

	// Check that the config for volume v1 on p2 was duplicated.
	volumeIDs, err := query.SelectIntegers(tx, `
SELECT id FROM storage_volumes WHERE storage_pool_id=2 AND name='v1' ORDER BY id
`)
	require.NoError(t, err)
	require.Equal(t, []int{2, 4}, volumeIDs)
	config1, err := query.SelectConfig(tx, "storage_volumes_config", "storage_volume_id=?", volumeIDs[0])
	require.NoError(t, err)
	config2, err := query.SelectConfig(tx, "storage_volumes_config", "storage_volume_id=?", volumeIDs[1])
	require.NoError(t, err)
	require.Equal(t, config1, config2)
}

func TestUpdateFromV6(t *testing.T) {
	schema := cluster.Schema()
	db, err := schema.ExerciseUpdate(7, func(db *sql.DB) {
		// Create two nodes.
		_, err := db.Exec(
			"INSERT INTO nodes VALUES (1, 'n1', '', '1.2.3.4:666', 1, 32, ?, 0)",
			time.Now())
		require.NoError(t, err)
		_, err = db.Exec(
			"INSERT INTO nodes VALUES (2, 'n2', '', '5.6.7.8:666', 1, 32, ?, 0)",
			time.Now())
		require.NoError(t, err)

		// Create a pool p1 of type zfs.
		_, err = db.Exec("INSERT INTO storage_pools VALUES (1, 'p1', 'zfs', '', 0)")
		require.NoError(t, err)

		// Create a pool p2 of type zfs.
		_, err = db.Exec("INSERT INTO storage_pools VALUES (2, 'p2', 'zfs', '', 0)")
		require.NoError(t, err)

		// Create a zfs.pool_name config for p1.
		_, err = db.Exec(`
INSERT INTO storage_pools_config(storage_pool_id, node_id, key, value)
  VALUES(1, NULL, 'zfs.pool_name', 'my-pool')
`)
		require.NoError(t, err)

		// Create a zfs.clone_copy config for p2.
		_, err = db.Exec(`
INSERT INTO storage_pools_config(storage_pool_id, node_id, key, value)
  VALUES(2, NULL, 'zfs.clone_copy', 'true')
`)
		require.NoError(t, err)
	})
	require.NoError(t, err)

	tx, err := db.Begin()
	require.NoError(t, err)
	defer tx.Rollback()

	// Check the zfs.pool_name config is now node-specific.
	for _, nodeID := range []int{1, 2} {
		config, err := query.SelectConfig(
			tx, "storage_pools_config", "storage_pool_id=1 AND node_id=?", nodeID)
		require.NoError(t, err)
		assert.Equal(t, map[string]string{"zfs.pool_name": "my-pool"}, config)
	}

	// Check the zfs.clone_copy is still global
	config, err := query.SelectConfig(
		tx, "storage_pools_config", "storage_pool_id=2 AND node_id IS NULL")
	require.NoError(t, err)
	assert.Equal(t, map[string]string{"zfs.clone_copy": "true"}, config)
}

func TestUpdateFromV9(t *testing.T) {
	schema := cluster.Schema()
	db, err := schema.ExerciseUpdate(10, func(db *sql.DB) {
		// Create a node.
		_, err := db.Exec(
			"INSERT INTO nodes VALUES (1, 'n1', '', '1.2.3.4:666', 1, 32, ?, 0)",
			time.Now())
		require.NoError(t, err)

		// Create an operation.
		_, err = db.Exec("INSERT INTO operations VALUES (1, 'op1', 1)")
		require.NoError(t, err)
	})
	require.NoError(t, err)

	// Check that a type column has been added and that existing rows get type 0.
	tx, err := db.Begin()
	require.NoError(t, err)

	defer tx.Rollback()

	types, err := query.SelectIntegers(tx, `SELECT type FROM operations`)
	require.NoError(t, err)
	require.Equal(t, []int{0}, types)
}

func TestUpdateFromV11(t *testing.T) {
	schema := cluster.Schema()
	db, err := schema.ExerciseUpdate(12, func(db *sql.DB) {
		// Insert a node.
		_, err := db.Exec(
			"INSERT INTO nodes VALUES (1, 'n1', '', '1.2.3.4:666', 1, 32, ?, 0)",
			time.Now())
		require.NoError(t, err)

		// Insert a container.
		_, err = db.Exec(`
INSERT INTO containers VALUES (1, 1, 'bionic', 1, 1, 0, ?, 0, ?, 'Bionic Beaver')
`, time.Now(), time.Now())
		require.NoError(t, err)

		// Insert an image.
		_, err = db.Exec(`
INSERT INTO images VALUES (1, 'abcd', 'img.tgz', 123, 0, 0, NULL, NULL, ?, 0, NULL, 0)
`, time.Now())
		require.NoError(t, err)

		// Insert an image alias.
		_, err = db.Exec(`
INSERT INTO images_aliases VALUES (1, 'my-img', 1, NULL)
`, time.Now())
		require.NoError(t, err)

		// Insert some profiles.
		_, err = db.Exec(`
INSERT INTO profiles VALUES (1, 'default', NULL);
INSERT INTO profiles VALUES(2, 'users', '');
INSERT INTO profiles_config VALUES(2, 2, 'boot.autostart', 'false');
INSERT INTO profiles_config VALUES(3, 2, 'limits.cpu.allowance', '50%');
INSERT INTO profiles_devices VALUES(1, 1, 'eth0', 1);
INSERT INTO profiles_devices VALUES(2, 1, 'root', 1);
INSERT INTO profiles_devices_config VALUES(1, 1, 'nictype', 'bridged');
INSERT INTO profiles_devices_config VALUES(2, 1, 'parent', 'lxdbr0');
INSERT INTO profiles_devices_config VALUES(3, 2, 'path', '/');
INSERT INTO profiles_devices_config VALUES(4, 2, 'pool', 'default');
`, time.Now())
		require.NoError(t, err)

	})
	require.NoError(t, err)

	tx, err := db.Begin()
	require.NoError(t, err)

	defer tx.Rollback()

	// Check that a project_id column has been added to the various talbles
	// and that existing rows default to 1 (the ID of the default project).
	for _, table := range []string{"containers", "images", "images_aliases"} {
		count, err := query.Count(tx, table, "")
		require.NoError(t, err)
		assert.Equal(t, 1, count)

		stmt := fmt.Sprintf("SELECT project_id FROM %s", table)
		ids, err := query.SelectIntegers(tx, stmt)
		require.NoError(t, err)
		assert.Equal(t, []int{1}, ids)
	}

	// Create a new project.
	_, err = tx.Exec(`
INSERT INTO projects VALUES (2, 'staging', 'Staging environment')`)
	require.NoError(t, err)

	// Check that it's possible to have two containers with the same name
	// as long as they are in different projects.
	_, err = tx.Exec(`
INSERT INTO containers VALUES (2, 1, 'xenial', 1, 1, 0, ?, 0, ?, 'Xenial Xerus', 1)
`, time.Now(), time.Now())
	require.NoError(t, err)

	_, err = tx.Exec(`
INSERT INTO containers VALUES (3, 1, 'xenial', 1, 1, 0, ?, 0, ?, 'Xenial Xerus', 2)
`, time.Now(), time.Now())
	require.NoError(t, err)

	// Check that it's not possible to have two containers with the same name
	// in the same project.

	_, err = tx.Exec(`
INSERT INTO containers VALUES (4, 1, 'xenial', 1, 1, 0, ?, 0, ?, 'Xenial Xerus', 1)
`, time.Now(), time.Now())
	assert.EqualError(t, err, "UNIQUE constraint failed: containers.project_id, containers.name")
}

func TestUpdateFromV14(t *testing.T) {
	schema := cluster.Schema()
	db, err := schema.ExerciseUpdate(15, func(db *sql.DB) {
		// Insert a node.
		_, err := db.Exec(
			"INSERT INTO nodes VALUES (1, 'n1', '', '1.2.3.4:666', 1, 32, ?, 0)",
			time.Now())
		require.NoError(t, err)

		// Insert a container.
		_, err = db.Exec(`
INSERT INTO containers VALUES (1, 1, 'eoan', 1, 1, 0, ?, 0, ?, 'Eoan Ermine', 1, NULL)
`, time.Now(), time.Now())
		require.NoError(t, err)
	})

	require.NoError(t, err)

	tx, err := db.Begin()
	require.NoError(t, err)

	defer tx.Rollback()

	// Check that the new instances table can be queried.
	count, err := query.Count(tx, "instances", "")
	require.NoError(t, err)
	assert.Equal(t, 1, count)
}

func TestUpdateFromV15(t *testing.T) {
	schema := cluster.Schema()
	db, err := schema.ExerciseUpdate(16, func(db *sql.DB) {
		// Insert a node.
		_, err := db.Exec(
			"INSERT INTO nodes VALUES (1, 'n1', '', '1.2.3.4:666', 1, 32, ?, 0)",
			time.Now())
		require.NoError(t, err)

		// Insert an instance.
		_, err = db.Exec(`
INSERT INTO instances VALUES (1, 1, 'eoan', 2, 0, 0, ?, 0, ?, NULL, 1, ?)
`, time.Now(), time.Now(), time.Now())
		require.NoError(t, err)
		_, err = db.Exec("INSERT INTO instances_config VALUES (1, 1, 'key', 'value2')")
		require.NoError(t, err)
		_, err = db.Exec("INSERT INTO instances_devices VALUES (1, 1, 'dev', 0)")
		require.NoError(t, err)
		_, err = db.Exec("INSERT INTO instances_devices_config VALUES (1, 1, 'k', 'v')")
		require.NoError(t, err)

		// Insert an instance snapshot.
		expiry_date := time.Date(2019, 8, 14, 11, 9, 0, 0, time.UTC)
		_, err = db.Exec(`
INSERT INTO instances VALUES (2, 1, 'eoan/snap', 2, 1, 0, ?, 0, ?, 'Eoan Ermine Snapshot', 1, ?)
`, time.Now(), time.Now(), expiry_date)
		require.NoError(t, err)
		_, err = db.Exec("INSERT INTO instances_config VALUES (2, 2, 'key', 'value1')")
		require.NoError(t, err)
		_, err = db.Exec("INSERT INTO instances_devices VALUES (2, 2, 'dev', 0)")
		require.NoError(t, err)
		_, err = db.Exec("INSERT INTO instances_devices_config VALUES (2, 2, 'k', 'v')")
		require.NoError(t, err)

	})

	require.NoError(t, err)

	tx, err := db.Begin()
	require.NoError(t, err)

	defer tx.Rollback()

	// Check that snapshots were migrated to the new tables.
	count, err := query.Count(tx, "instances", "")
	require.NoError(t, err)
	assert.Equal(t, 1, count)

	count, err = query.Count(tx, "instances_config", "")
	require.NoError(t, err)
	assert.Equal(t, 1, count)

	count, err = query.Count(tx, "instances_devices", "")
	require.NoError(t, err)
	assert.Equal(t, 1, count)

	count, err = query.Count(tx, "instances_devices_config", "")
	require.NoError(t, err)
	assert.Equal(t, 1, count)

	count, err = query.Count(tx, "instances_snapshots", "")
	require.NoError(t, err)
	assert.Equal(t, 1, count)

	count, err = query.Count(tx, "instances_snapshots_config", "")
	require.NoError(t, err)
	assert.Equal(t, 1, count)

	count, err = query.Count(tx, "instances_snapshots_devices", "")
	require.NoError(t, err)
	assert.Equal(t, 1, count)

	count, err = query.Count(tx, "instances_snapshots_devices_config", "")
	require.NoError(t, err)
	assert.Equal(t, 1, count)

	config, err := query.SelectConfig(tx, "instances_config", "id = 1")
	require.NoError(t, err)
	assert.Equal(t, config, map[string]string{"key": "value2"})

	config, err = query.SelectConfig(tx, "instances_snapshots_config", "id = 1")
	require.NoError(t, err)
	assert.Equal(t, config, map[string]string{"key": "value1"})

	config, err = query.SelectConfig(tx, "instances_devices_config", "id = 1")
	require.NoError(t, err)
	assert.Equal(t, config, map[string]string{"k": "v"})

	config, err = query.SelectConfig(tx, "instances_snapshots_devices_config", "id = 1")
	require.NoError(t, err)
	assert.Equal(t, config, map[string]string{"k": "v"})
}

func TestUpdateFromV19(t *testing.T) {
	schema := cluster.Schema()
	db, err := schema.ExerciseUpdate(20, func(db *sql.DB) {
		// Insert a node.
		_, err := db.Exec(
			"INSERT INTO nodes VALUES (1, 'n1', '', '1.2.3.4:666', 1, 32, ?, 0)",
			time.Now())
		require.NoError(t, err)
	})
	require.NoError(t, err)
	defer db.Close()

	expectedArch, err := osarch.ArchitectureGetLocalID()
	require.NoError(t, err)

	row := db.QueryRow("SELECT arch FROM nodes")
	arch := 0
	err = row.Scan(&arch)
	require.NoError(t, err)

	assert.Equal(t, expectedArch, arch)

	// Trying to create a row without specififying the architecture results
	// in an error.
	_, err = db.Exec(`
INSERT INTO nodes(id, name, description, address, schema, api_extensions, heartbeat, pending)
VALUES (2, 'n2', '', '2.2.3.4:666', 1, 32, ?, 0)`, time.Now())
	if err == nil {
		t.Fatal("expected insertion to fail")
	}
	sqliteErr, ok := err.(sqlite3.Error)
	require.True(t, ok)
	assert.Equal(t, sqliteErr.Code, sqlite3.ErrConstraint)
}

func TestUpdateFromV25(t *testing.T) {
	schema := cluster.Schema()
	db, err := schema.ExerciseUpdate(26, func(db *sql.DB) {
		// Insert a node.
		_, err := db.Exec(
			"INSERT INTO nodes VALUES (1, 'n1', '', '1.2.3.4:666', 1, 32, ?, 0, 1)",
			time.Now())
		require.NoError(t, err)

		// Insert a pool
		_, err = db.Exec("INSERT INTO storage_pools VALUES (1, 'p1', 'zfs', '', 0)")
		require.NoError(t, err)

		// Create a volume v1 on pool p1, associated with n1 and a config.
		_, err = db.Exec("INSERT INTO storage_volumes VALUES (1, 'v1', 1, 1, 1, '', 0, 1)")
		require.NoError(t, err)
		_, err = db.Exec("INSERT INTO storage_volumes_config VALUES (1, 1, 'k', 'v')")
		require.NoError(t, err)

		// Create a snapshot v1/snap0 with a config.
		_, err = db.Exec("INSERT INTO storage_volumes VALUES (2, 'v1/snap0', 1, 1, 1, '', 1, 1)")
		require.NoError(t, err)
		_, err = db.Exec("INSERT INTO storage_volumes_config VALUES (2, 2, 'k', 'v-old')")
		require.NoError(t, err)
	})
	require.NoError(t, err)
	defer db.Close()

	tx, err := db.Begin()
	require.NoError(t, err)

	defer tx.Rollback()

	// Check that regular volumes were kept.
	count, err := query.Count(tx, "storage_volumes", "")
	require.NoError(t, err)
	assert.Equal(t, 1, count)
	count, err = query.Count(tx, "storage_volumes_config", "")
	require.NoError(t, err)
	assert.Equal(t, 1, count)

	// Check that volume snapshots were migrated.
	count, err = query.Count(tx, "storage_volumes_snapshots", "")
	require.NoError(t, err)
	assert.Equal(t, 1, count)

	config, err := query.SelectConfig(tx, "storage_volumes_snapshots_config", "")
	require.NoError(t, err)
	assert.Len(t, config, 1)
	assert.Equal(t, config["k"], "v-old")
}

func TestUpdateFromV26_WithoutVolumes(t *testing.T) {
	schema := cluster.Schema()
	db, err := schema.ExerciseUpdate(27, func(db *sql.DB) {})
	require.NoError(t, err)
	defer db.Close()
}

func TestUpdateFromV26_WithVolumes(t *testing.T) {
	schema := cluster.Schema()
	db, err := schema.ExerciseUpdate(27, func(db *sql.DB) {
		// Insert a node.
		_, err := db.Exec(
			"INSERT INTO nodes VALUES (1, 'n1', '', '1.2.3.4:666', 1, 32, ?, 0, 1)",
			time.Now())
		require.NoError(t, err)

		// Insert a pool
		_, err = db.Exec("INSERT INTO storage_pools VALUES (1, 'p1', 'zfs', '', 0)")
		require.NoError(t, err)

		// Create a volume v1 on pool p1
		_, err = db.Exec("INSERT INTO storage_volumes VALUES (1, 'v1', 1, 1, 1, '', 1)")
		require.NoError(t, err)

		// Create a snapshot snap0.
		_, err = db.Exec("INSERT INTO storage_volumes_snapshots VALUES (2, 1, 'snap0', '')")
		require.NoError(t, err)

		// Mess up the sqlite_sequence value.
		_, err = db.Exec("UPDATE sqlite_sequence SET seq = 1 WHERE name = 'storage_volumes'")
		require.NoError(t, err)
	})
	require.NoError(t, err)
	defer db.Close()

	tx, err := db.Begin()
	require.NoError(t, err)

	defer tx.Rollback()
	ids, err := query.SelectIntegers(tx, "SELECT seq FROM sqlite_sequence WHERE name = 'storage_volumes'")
	require.NoError(t, err)

	assert.Equal(t, ids[0], 2)
}


text:
import {Component, Input, OnChanges} from 'angular2/core';
import {UserService} from './services/user.service';

@Component({
    selector: 'lead-details',
    templateUrl: './templates/lead-details.modal.tpl.html',
    styleUrls: []
})
export class LeadDetailsComponent implements OnChanges {
    @Input() client: Object;
    clientid: string;
    tab: string = '1';
    statusNotes: Object;

    constructor(private _userService: UserService) {}

    ngOnChanges(changes) {
        this.clientid = this.client['id'];

        // this._userService.getLeadNotes(this.clientid)
        // .subscribe(
        //     data => this.statusNotes = data
        // )
    }
}


text:
package de.uniulm.omi.cloudiator.visor.exceptions;

/**
 * This exception is thrown if a probe could not execute its measurement, and the metric is
 * therefore not available.
 */
public class MeasurementNotAvailableException extends Exception {

  /**
   * @see java.lang.Exception
   */
  public MeasurementNotAvailableException(Throwable cause) {
    super(cause);
  }

  /**
   * @see java.lang.Exception
   */
  public MeasurementNotAvailableException(String message) {
    super(message);
  }

  /**
   * @see java.lang.Exception
   */
  public MeasurementNotAvailableException(String message, Throwable cause) {
    super(message, cause);
  }
}