text:
using System;
using OpenTracing.Contrib.Core;
using OpenTracing.Contrib.Core.Configuration;
using OpenTracing.Contrib.Core.Interceptors.EntityFrameworkCore;
using OpenTracing.Contrib.Core.Interceptors.HttpOut;

namespace Microsoft.Extensions.DependencyInjection
{
    public static class OpenTracingBuilderExtensions
    {
        /// <summary>
        /// Traces Entity Framework Core commands.
        /// </summary>
        public static IOpenTracingBuilder AddEntityFrameworkCore(this IOpenTracingBuilder builder)
        {
            if (builder == null)
                throw new ArgumentNullException(nameof(builder));

            builder.Services.AddSingleton<IDiagnosticInterceptor, EntityFrameworkCoreInterceptor>();

            return builder;
        }

        /// <summary>
        /// Traces <see cref="System.Net.Http.HttpClient"/> calls.
        /// </summary>
        public static IOpenTracingBuilder AddHttpClient(this IOpenTracingBuilder builder, Action<HttpOutOptions> options = null)
        {
            if (builder == null)
                throw new ArgumentNullException(nameof(builder));

            builder.Services.AddSingleton<IDiagnosticInterceptor, HttpOutInterceptor>();

            return ConfigureHttpClient(builder, options);
        }

        /// <summary>
        /// Configuration for the instrumentation of <see cref="System.Net.Http.HttpClient"/> calls.
        /// </summary>
        /// <seealso cref="AddHttpClient(IOpenTracingBuilder, Action{HttpOutOptions})"/>
        public static IOpenTracingBuilder ConfigureHttpClient(this IOpenTracingBuilder builder, Action<HttpOutOptions> options)
        {
            if (builder == null)
                throw new ArgumentNullException(nameof(builder));

            if (options != null)
            {
                builder.Services.Configure(options);
            }

            return builder;
        }
    }
}


text:
package com.ocdsoft.bacta.swg.precu.message.game.messagequeue;

import com.ocdsoft.bacta.swg.network.soe.lang.UnicodeString;

/**
 * Created by crush on 8/13/2014.
 */
public class MessageQueueGenericString {
    UnicodeString string;
    byte sequenceId;
}

redpajama_set_name: RedPajamaGithub


text:
body, td.contentsarea  {
	background-color:#ffffff;
	color: #000000;
	width:100%;
	padding:0;
	margin:0;
	font-size: 9pt;
	font-family: helvetica, "trebuchet MS", arial, sans-serif;
}

div.contents  td.contentsarea {
	font-size: 9pt;
	font-family: helvetica, "trebuchet MS", arial, sans-serif;
}

.contents{
	position: absolute;
	/*width: 100%;*/
	top: 55px;
	margin: 0;
	padding: 0;
	clear: both; /* test */
}

.innercontents div, .innercontents div div, .innercontents div div div, .innercontents div div div div, .innercontents div div div div div{
	z-index: inherit;
}

.headerdiv{
	position:absolute;
	left:0px;
	top:0px;
	padding:0px;
	margin:0px;
	width:100%;
	height:57px;
	border: 0;
	background-color: #207a7a;
}

div.footerdiv{
	width:100%;
	height: 22px;
	z-index: 2;
	float: left;
	vertical-align: top;
	border: 0;
	margin: 0;
	padding: 0;
}

.contents{
	position: absolute;
	width: 100%;
	top: 57px;
	z-index: 2;
}

table.contentspane{
	padding:0;
	width: 762px;
	vertical-align: top;
	margin-top: 6px;
	margin-bottom: 6px;
}

.contentspane{
	width: 762px;
	border-collapse: collapse;
}

table td.leftmargin{
	margin:0;
	height:540px;    /*sets min height */
	font-size: 1px;
	width: 1px;
	padding: 0;
	font-size: 1px;
}

table td.leftmenucell{
	padding-left:0;
	padding-right:0;
	padding-top:0;
	margin:0;
	width: 1px;
	vertical-align: top;
	padding-bottom: 0;
}

table td.contentsarea{
	margin:0;
	/*border-left: 1px solid #dedede;*/
	border-left: 1px solid #ffffff;
	border-right: 1px solid #dedede;
	border-top: 1px solid #ffffff;
	border-bottom: 1px solid #ffffff;
	vertical-align: top;
	text-align: left;
	padding-bottom: 0;
	padding-top: 5px;
	padding-left: 10px;
	padding-right: 10px;
}

table td.rightmenucell{
	margin:0px;
	width: 1px;
	vertical-align: top;
	padding-bottom: 0;
	padding-top: 0;
	padding-left: 0;
	padding-right: 0;
}

table td.footerrow{
	margin:0;
	border: 0;
	height: 22px;
	vertical-align: top;
	padding-top: 3px;
	padding-left: 2px;
	padding-right: 0;
	padding-bottom: 0;
	text-align: left;
}

div.leftmenu{
	 margin-right: 5px;
	 margin-top: 0;
	 border: 1px solid #ffffff;
	 visibility: hidden;
	 display: none;
	 vertical-align: top;
	 text-align: left;
	 width: 1px; /* for print */
	 display: none;
}

div.rightmenu{
	margin-left: 5px;
	margin-top: 5px;
	border: 1px solid #ffffff;
	visibility: hidden;
	display: none;
	vertical-align: top;
	width: 1px; /* for print */
}

div.contentsareadiv{
	margin:0px 5px 0px 5px;
}

.contents{
	position:absolute;
	z-index:2;
	/*left: -4px;*/
}

.leftmenu, .rightmenu{
	vertical-align: top;
	width: 1px;
}

.footerpane{
	width: 100%;
}

.spacer{
	border: 0;
	padding: 0;
	width: 1px;
	height: 1px;
}

table.footerpane{
	border-top: 1px solid #bfbfbf;
	border-bottom: 1px solid #bfbfbf;
	border-left: 0;
	border-right: 0;
	background-color: #dedede;
	border-collapse: collapse;
	height: 22px;
	text-align: left;
}

table.footerpane td{
	border: 0;
	margin: 0;
	padding: 0;
	text-align: left;
	padding-left: 15px;
}


text:
/**
 * @fileoverview manages the plugins for Arte
 */
(function($) {
    $.Arte = $.Arte || {};
    $.Arte.pluginManager = {
        plugins: {},
        /**
         * Register a plugin
         * @param {string} name of the plugin
         * @param {function} constructor function of the plugin
         */
        register: function(name, plugin) {
            this.plugins[name] = plugin;
        },
        /*
         * Initializes the plugin
         * @param {Arte} an instance of Arte
         */
        init: function(richTextEditor) {
            richTextEditor.pluginInstances = richTextEditor.pluginInstances || [];
            for (var pluginName in this.plugins) {
                var pluginInstanse = new this.plugins[pluginName]();
                pluginInstanse.init(richTextEditor);
                richTextEditor.pluginInstances.push(pluginInstanse);
            }
        }
    };
})(jQuery);


text:
<Alloy>
	<Window>

		<View id="app">
			<View id="topBar">
				<ImageView height="30dp" onClick="back" width="12dp"  image="/icon/Previous@2x.png" left="10dp"/>

				<ImageView height="30dp" zIndex="2" width="30dp" onClick="search" image="/icon/search-icon-white.png" right="10dp"/>
			</View>
			<View layout="vertical">

				<View class="headerTitle">

				</View>

				<View class="blockSearch">
					<View class="item">
						<ImageView image="/icon/near_me.png" width="20dp" height="20dp" left="25dp" />

						<ImageView zIndex="2" image="/icon/location.png" onClick="changeLocation" width="20dp" height="20dp" right="25dp" />
					</View>

					<View class="item">
						<ImageView image="/icon/marker.png" width="20dp" height="20dp" left="25dp" />
						<TextField hintText="Địa điểm đến ?" class="input"/>
					</View>

					<View class="item">
						<ImageView image="/icon/person.png" width="20dp" height="20dp" left="25dp" />
						<TextField hintText="Số người ?" text="6" class="input"/>
					</View>
				</View>

				<View class="headerTitle">

				</View>

				<View class="item">
					<ImageView image="/icon/time.png" width="20dp" height="20dp" left="25dp" />

				</View>
				<View class="item" top="0">
					<View class="date" left="60dp">

					</View>
					<View class="date" left="150dp" width="40dp">

					</View>
					<View class="date" left="200dp">

					</View>
				</View>

				<View class="item">
					<ImageView image="/icon/payment.png" width="20dp" height="20dp" left="25dp" />

				</View>
				<View class="item" top="0">
					<View class="priceActive" left="60dp">

					</View>
					<View class="price" left="150dp">

					</View>
					<View class="price" left="240dp">

					</View>
					<View class="price" left="60dp" top="40dp">

					</View>
					<View class="price" left="150dp" top="40dp">

					</View>
				</View>

			</View>

		</View>
		<Require type="view" src="bar_menu"/>
	</Window>
</Alloy>


text:
<?php
namespace FwsLogger\Exception;

/**
 * Exception Interface
 *
 * @author Garry Childs (Freedom Web Services)
 */
interface ExceptionInterface
{}


text:
<?php

namespace Pronit\CoreBundle\Entity\Automatizacion\EsquemasCalculo;

use Doctrine\ORM\Mapping as ORM;
use Pronit\CoreBundle\Entity\Automatizacion\EsquemasCalculo\Estrategias\EstrategiaCalculo;
use Pronit\CoreBundle\Model\Automatizacion\EsquemasCalculo\Contextos\ContextoItemEsquemaCalculo;

/**
 * Description of ClaseCondicion
 *
 * @author gcaseres
 * @ORM\Entity
 * @ORM\Table(name="core_clasescondicion")
 */
class ClaseCondicion
{

    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="string", length=8)
     */
    protected $codigo;

    /**
     * @ORM\Column(type="string", length=60)
     */
    protected $nombre;

    /** @var EstrategiaCalculo */
    protected $estrategiaCalculo;

    public function getId()
    {
        return $this->id;
    }

    public function setCodigo($value)
    {
        $this->codigo = $value;
    }

    public function getCodigo()
    {
        return $this->codigo;
    }

    public function setNombre($value)
    {
        $this->nombre = $value;
    }

    public function getNombre()
    {
        return $this->nombre;
    }

    /**
     *
     * @param EstrategiaCalculo $value
     */
    public function setEstrategiaCalculo(EstrategiaCalculo $value)
    {
        $this->estrategiaCalculo = $value;
    }

    /**
     *
     * @return EstrategiaCalculo
     */
    public function getEstrategiaCalculo()
    {
        return $this->estrategiaCalculo;
    }

    /**
     *
     * @param ContextoItemEsquemaCalculo $contexto
     */
    public function calcular(ContextoItemEsquemaCalculo $contexto, ResultadoCalculo $parcial)
    {
        $descripcion = $contexto->getItemEsquemaCalculo()->getDescripcion();

        $valor = $this->estrategiaCalculo->calcular($contexto);

        $parcial->addCondicion($descripcion, $valor);
    }

}


text:
/*
PNotify 2.0.1 sciactive.com/pnotify/
(C) 2014 Hunter Perrin
license GPL/LGPL/MPL
*/
/*
 * ====== PNotify ======
 *
 * http://sciactive.com/pnotify/
 *
 * Copyright 2009-2014 Hunter Perrin
 *
 * Triple licensed under the GPL, LGPL, and MPL.
 * 	http://gnu.org/licenses/gpl.html
 * 	http://gnu.org/licenses/lgpl.html
 * 	http://mozilla.org/MPL/MPL-1.1.html
 */

// Uses AMD or browser globals for jQuery.
(function (factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as a module.
        define('pnotify', ['jquery'], factory);
    } else {
        // Browser globals
        factory(jQuery);
    }
}(function($){
	var default_stack = {
		dir1: "down",
		dir2: "left",
		push: "bottom",
		spacing1: 25,
		spacing2: 25,
		context: $("body")
	};
	var timer, // Position all timer.
		body,
		jwindow = $(window);
	// Set global variables.
	var do_when_ready = function(){
		body = $("body");
		PNotify.prototype.options.stack.context = body;
		jwindow = $(window);
		// Reposition the notices when the window resizes.
		jwindow.bind('resize', function(){
			if (timer)
				clearTimeout(timer);
			timer = setTimeout(function(){ PNotify.positionAll(true) }, 10);
		});
	};
	PNotify = function(options){
		this.parseOptions(options);
		this.init();
	};
	$.extend(PNotify.prototype, {
		// The current version of PNotify.
		version: "2.0.1",

		// === Options ===

		// Options defaults.
		options: {
			// The notice's title.
			title: false,
			// Whether to escape the content of the title. (Not allow HTML.)
			title_escape: false,
			// The notice's text.
			text: false,
			// Whether to escape the content of the text. (Not allow HTML.)
			text_escape: false,
			// What styling classes to use. (Can be either jqueryui or bootstrap.)
			styling: "bootstrap3",
			// Additional classes to be added to the notice. (For custom styling.)
			addclass: "",
			// Class to be added to the notice for corner styling.
			cornerclass: "",
			// Display the notice when it is created.
			auto_display: true,
			// Width of the notice.
			width: "300px",
			// Minimum height of the notice. It will expand to fit content.
			min_height: "16px",
			// Type of the notice. "notice", "info", "success", or "error".
			type: "notice",
			// Set icon to true to use the default icon for the selected
			// style/type, false for no icon, or a string for your own icon class.
			icon: true,
			// Opacity of the notice.
			opacity: 1,
			// The animation to use when displaying and hiding the notice. "none",
			// "show", "fade", and "slide" are built in to jQuery. Others require jQuery
			// UI. Use an object with effect_in and effect_out to use different effects.
			animation: "fade",
			// Speed at which the notice animates in and out. "slow", "def" or "normal",
			// "fast" or number of milliseconds.
			animate_speed: "slow",
			// Specify a specific duration of position animation
			position_animate_speed: 500,
			// Display a drop shadow.
			shadow: true,
			// After a delay, remove the notice.
			hide: true,
			// Delay in milliseconds before the notice is removed.
			delay: 8000,
			// Reset the hide timer if the mouse moves over the notice.
			mouse_reset: true,
			// Remove the notice's elements from the DOM after it is removed.
			remove: true,
			// Change new lines to br tags.
			insert_brs: true,
			// Whether to remove notices from the global array.
			destroy: true,
			// The stack on which the notices will be placed. Also controls the
			// direction the notices stack.
			stack: default_stack
		},

		// === Modules ===

		// This object holds all the PNotify modules. They are used to provide
		// additional functionality.
		modules: {},
		// This runs an event on all the modules.
		runModules: function(event, arg){
			var curArg;
			for (var module in this.modules) {
				curArg = ((typeof arg === "object" && module in arg) ? arg[module] : arg);
				if (typeof this.modules[module][event] === 'function')
					this.modules[module][event](this, typeof this.options[module] === 'object' ? this.options[module] : {}, curArg);
			}
		},

		// === Class Variables ===

		state: "initializing", // The state can be "initializing", "opening", "open", "closing", and "closed".
		timer: null, // Auto close timer.
		styles: null,
		elem: null,
		container: null,
		title_container: null,
		text_container: null,
		animating: false, // Stores what is currently being animated (in or out).
		timerHide: false, // Stores whether the notice was hidden by a timer.

		// === Events ===

		init: function(){
			var that = this;

			// First and foremost, we don't want our module objects all referencing the prototype.
			this.modules = {};
			$.extend(true, this.modules, PNotify.prototype.modules);

			// Get our styling object.
			if (typeof this.options.styling === "object") {
				this.styles = this.options.styling;
			} else {
				this.styles = PNotify.styling[this.options.styling];
			}

			// Create our widget.
			// Stop animation, reset the removal timer when the user mouses over.
			this.elem = $("
", {
				"class": "ui-pnotify "+this.options.addclass,
				"css": {"display": "none"},
				"mouseenter": function(e){
					if (that.options.mouse_reset && that.animating === "out") {
						if (!that.timerHide)
							return;
						that.cancelRemove();
					}
					// Stop the close timer.
					if (that.options.hide && that.options.mouse_reset) that.cancelRemove();
				},
				"mouseleave": function(e){
					// Start the close timer.
					if (that.options.hide && that.options.mouse_reset) that.queueRemove();
					PNotify.positionAll();
				}
			});
			// Create a container for the notice contents.
			this.container = $("
", {"class": this.styles.container+" ui-pnotify-container "+(this.options.type === "error" ? this.styles.error : (this.options.type === "info" ? this.styles.info : (this.options.type === "success" ? this.styles.success : this.styles.notice)))})
			.appendTo(this.elem);
			if (this.options.cornerclass !== "")
				this.container.removeClass("ui-corner-all").addClass(this.options.cornerclass);
			// Create a drop shadow.
			if (this.options.shadow)
				this.container.addClass("ui-pnotify-shadow");

			// Add the appropriate icon.
			if (this.options.icon !== false) {
				$("
", {"class": "ui-pnotify-icon"})
				.append($("", {"class": this.options.icon === true ? (this.options.type === "error" ? this.styles.error_icon : (this.options.type === "info" ? this.styles.info_icon : (this.options.type === "success" ? this.styles.success_icon : this.styles.notice_icon))) : this.options.icon}))
				.prependTo(this.container);
			}

			// Add a title.
			this.title_container = $("
", {
				"class": "ui-pnotify-title"
			})
			.appendTo(this.container);
			if (this.options.title === false)
				this.title_container.hide();
			else if (this.options.title_escape)
				this.title_container.text(this.options.title);
			else
				this.title_container.html(this.options.title);

			// Add text.
			this.text_container = $("
", {
				"class": "ui-pnotify-text"
			})
			.appendTo(this.container);
			if (this.options.text === false)
				this.text_container.hide();
			else if (this.options.text_escape)
				this.text_container.text(this.options.text);
			else
				this.text_container.html(this.options.insert_brs ? String(this.options.text).replace(/\n/g, "
") : this.options.text);

			// Set width and min height.
			if (typeof this.options.width === "string")
				this.elem.css("width", this.options.width);
			if (typeof this.options.min_height === "string")
				this.container.css("min-height", this.options.min_height);

			// Add the notice to the notice array.
			if (this.options.stack.push === "top")
				PNotify.notices = $.merge([this], PNotify.notices);
			else
				PNotify.notices = $.merge(PNotify.notices, [this]);
			// Now position all the notices if they are to push to the top.
			if (this.options.stack.push === "top")
				this.queuePosition(false, 1);

			// Mark the stack so it won't animate the new notice.
			this.options.stack.animation = false;

			// Run the modules.
			this.runModules('init');

			// Display the notice.
			if (this.options.auto_display)
				this.open();
			return this;
		},

		// This function is for updating the notice.
		update: function(options){
			// Save old options.
			var oldOpts = this.options;
			// Then update to the new options.
			this.parseOptions(oldOpts, options);
			// Update the corner class.
			if (this.options.cornerclass !== oldOpts.cornerclass)
				this.container.removeClass("ui-corner-all "+oldOpts.cornerclass).addClass(this.options.cornerclass);
			// Update the shadow.
			if (this.options.shadow !== oldOpts.shadow) {
				if (this.options.shadow)
					this.container.addClass("ui-pnotify-shadow");
				else
					this.container.removeClass("ui-pnotify-shadow");
			}
			// Update the additional classes.
			if (this.options.addclass === false)
				this.elem.removeClass(oldOpts.addclass);
			else if (this.options.addclass !== oldOpts.addclass)
				this.elem.removeClass(oldOpts.addclass).addClass(this.options.addclass);
			// Update the title.
			if (this.options.title === false)
				this.title_container.slideUp("fast");
			else if (this.options.title !== oldOpts.title) {
				if (this.options.title_escape)
					this.title_container.text(this.options.title);
				else
					this.title_container.html(this.options.title);
				if (oldOpts.title === false)
					this.title_container.slideDown(200)
			}
			// Update the text.
			if (this.options.text === false) {
				this.text_container.slideUp("fast");
			} else if (this.options.text !== oldOpts.text) {
				if (this.options.text_escape)
					this.text_container.text(this.options.text);
				else
					this.text_container.html(this.options.insert_brs ? String(this.options.text).replace(/\n/g, "
") : this.options.text);
				if (oldOpts.text === false)
					this.text_container.slideDown(200)
			}
			// Change the notice type.
			if (this.options.type !== oldOpts.type)
				this.container.removeClass(
					this.styles.error+" "+this.styles.notice+" "+this.styles.success+" "+this.styles.info
				).addClass(this.options.type === "error" ?
					this.styles.error :
					(this.options.type === "info" ?
						this.styles.info :
						(this.options.type === "success" ?
							this.styles.success :
							this.styles.notice
						)
					)
				);
			if (this.options.icon !== oldOpts.icon || (this.options.icon === true && this.options.type !== oldOpts.type)) {
				// Remove any old icon.
				this.container.find("div.ui-pnotify-icon").remove();
				if (this.options.icon !== false) {
					// Build the new icon.
					$("
", {"class": "ui-pnotify-icon"})
					.append($("", {"class": this.options.icon === true ? (this.options.type === "error" ? this.styles.error_icon : (this.options.type === "info" ? this.styles.info_icon : (this.options.type === "success" ? this.styles.success_icon : this.styles.notice_icon))) : this.options.icon}))
					.prependTo(this.container);
				}
			}
			// Update the width.
			if (this.options.width !== oldOpts.width)
				this.elem.animate({width: this.options.width});
			// Update the minimum height.
			if (this.options.min_height !== oldOpts.min_height)
				this.container.animate({minHeight: this.options.min_height});
			// Update the opacity.
			if (this.options.opacity !== oldOpts.opacity)
				this.elem.fadeTo(this.options.animate_speed, this.options.opacity);
			// Update the timed hiding.
			if (!this.options.hide)
				this.cancelRemove();
			else if (!oldOpts.hide)
				this.queueRemove();
			this.queuePosition(true);

			// Run the modules.
			this.runModules('update', oldOpts);
			return this;
		},

		// Display the notice.
		open: function(){
			this.state = "opening";
			// Run the modules.
			this.runModules('beforeOpen');

			var that = this;
			// If the notice is not in the DOM, append it.
			if (!this.elem.parent().length)
				this.elem.appendTo(this.options.stack.context ? this.options.stack.context : body);
			// Try to put it in the right position.
			if (this.options.stack.push !== "top")
				this.position(true);
			// First show it, then set its opacity, then hide it.
			if (this.options.animation === "fade" || this.options.animation.effect_in === "fade") {
				// If it's fading in, it should start at 0.
				this.elem.show().fadeTo(0, 0).hide();
			} else {
				// Or else it should be set to the opacity.
				if (this.options.opacity !== 1)
					this.elem.show().fadeTo(0, this.options.opacity).hide();
			}
			this.animateIn(function(){
				that.queuePosition(true);

				// Now set it to hide.
				if (that.options.hide)
					that.queueRemove();

				that.state = "open";

				// Run the modules.
				that.runModules('afterOpen');
			});

			return this;
		},

		// Remove the notice.
		remove: function(timer_hide) {
			this.state = "closing";
			this.timerHide = !!timer_hide; // Make sure it's a boolean.
			// Run the modules.
			this.runModules('beforeClose');

			var that = this;
			if (this.timer) {
				window.clearTimeout(this.timer);
				this.timer = null;
			}
			this.animateOut(function(){
				that.state = "closed";
				// Run the modules.
				that.runModules('afterClose');
				that.queuePosition(true);
				// If we're supposed to remove the notice from the DOM, do it.
				if (that.options.remove)
					that.elem.detach();
				// Run the modules.
				that.runModules('beforeDestroy');
				// Remove object from PNotify.notices to prevent memory leak (issue #49)
				// unless destroy is off
				if (that.options.destroy) {
					if (PNotify.notices !== null) {
						var idx = $.inArray(that,PNotify.notices);
						if (idx !== -1) {
							PNotify.notices.splice(idx,1);
						}
					}
				}
				// Run the modules.
				that.runModules('afterDestroy');
			});

			return this;
		},

		// === Class Methods ===

		// Get the DOM element.
		get: function(){ return this.elem; },

		// Put all the options in the right places.
		parseOptions: function(options, moreOptions){
			this.options = $.extend(true, {}, PNotify.prototype.options);
			// This is the only thing that *should* be copied by reference.
			this.options.stack = PNotify.prototype.options.stack;
			var optArray = [options, moreOptions], curOpts;
			for (var curIndex in optArray) {
				curOpts = optArray[curIndex];
				if (typeof curOpts == "undefined")
					break;
				if (typeof curOpts !== 'object') {
					this.options.text = curOpts;
				} else {
					for (var option in curOpts) {
						if (this.modules[option]) {
							// Avoid overwriting module defaults.
							$.extend(true, this.options[option], curOpts[option]);
						} else {
							this.options[option] = curOpts[option];
						}
					}
				}
			}
		},

		// Animate the notice in.
		animateIn: function(callback){
			// Declare that the notice is animating in. (Or has completed animating in.)
			this.animating = "in";
			var animation;
			if (typeof this.options.animation.effect_in !== "undefined")
				animation = this.options.animation.effect_in;
			else
				animation = this.options.animation;
			if (animation === "none") {
				this.elem.show();
				callback();
			} else if (animation === "show")
				this.elem.show(this.options.animate_speed, callback);
			else if (animation === "fade")
				this.elem.show().fadeTo(this.options.animate_speed, this.options.opacity, callback);
			else if (animation === "slide")
				this.elem.slideDown(this.options.animate_speed, callback);
			else if (typeof animation === "function")
				animation("in", callback, this.elem);
			else
				this.elem.show(animation, (typeof this.options.animation.options_in === "object" ? this.options.animation.options_in : {}), this.options.animate_speed, callback);
			if (this.elem.parent().hasClass('ui-effects-wrapper'))
				this.elem.parent().css({"position": "fixed", "overflow": "visible"});
			if (animation !== "slide")
				this.elem.css("overflow", "visible");
			this.container.css("overflow", "hidden");
		},

		// Animate the notice out.
		animateOut: function(callback){
			// Declare that the notice is animating out. (Or has completed animating out.)
			this.animating = "out";
			var animation;
			if (typeof this.options.animation.effect_out !== "undefined")
				animation = this.options.animation.effect_out;
			else
				animation = this.options.animation;
			if (animation === "none") {
				this.elem.hide();
				callback();
			} else if (animation === "show")
				this.elem.hide(this.options.animate_speed, callback);
			else if (animation === "fade")
				this.elem.fadeOut(this.options.animate_speed, callback);
			else if (animation === "slide")
				this.elem.slideUp(this.options.animate_speed, callback);
			else if (typeof animation === "function")
				animation("out", callback, this.elem);
			else
				this.elem.hide(animation, (typeof this.options.animation.options_out === "object" ? this.options.animation.options_out : {}), this.options.animate_speed, callback);
			if (this.elem.parent().hasClass('ui-effects-wrapper'))
				this.elem.parent().css({"position": "fixed", "overflow": "visible"});
			if (animation !== "slide")
				this.elem.css("overflow", "visible");
			this.container.css("overflow", "hidden");
		},

		// Position the notice. dont_skip_hidden causes the notice to
		// position even if it's not visible.
		position: function(dontSkipHidden){
			// Get the notice's stack.
			var s = this.options.stack,
				e = this.elem;
			if (e.parent().hasClass('ui-effects-wrapper'))
				e = this.elem.css({"left": "0", "top": "0", "right": "0", "bottom": "0"}).parent();
			if (typeof s.context === "undefined")
				s.context = body;
			if (!s) return;
			if (typeof s.nextpos1 !== "number")
				s.nextpos1 = s.firstpos1;
			if (typeof s.nextpos2 !== "number")
				s.nextpos2 = s.firstpos2;
			if (typeof s.addpos2 !== "number")
				s.addpos2 = 0;
			var hidden = e.css("display") === "none";
			// Skip this notice if it's not shown.
			if (!hidden || dontSkipHidden) {
				var curpos1, curpos2;
				// Store what will need to be animated.
				var animate = {};
				// Calculate the current pos1 value.
				var csspos1;
				switch (s.dir1) {
					case "down":
						csspos1 = "top";
						break;
					case "up":
						csspos1 = "bottom";
						break;
					case "left":
						csspos1 = "right";
						break;
					case "right":
						csspos1 = "left";
						break;
				}
				curpos1 = parseInt(e.css(csspos1).replace(/(?:\..*|[^0-9.])/g, ''));
				if (isNaN(curpos1))
					curpos1 = 0;
				// Remember the first pos1, so the first visible notice goes there.
				if (typeof s.firstpos1 === "undefined" && !hidden) {
					s.firstpos1 = curpos1;
					s.nextpos1 = s.firstpos1;
				}
				// Calculate the current pos2 value.
				var csspos2;
				switch (s.dir2) {
					case "down":
						csspos2 = "top";
						break;
					case "up":
						csspos2 = "bottom";
						break;
					case "left":
						csspos2 = "right";
						break;
					case "right":
						csspos2 = "left";
						break;
				}
				curpos2 = parseInt(e.css(csspos2).replace(/(?:\..*|[^0-9.])/g, ''));
				if (isNaN(curpos2))
					curpos2 = 0;
				// Remember the first pos2, so the first visible notice goes there.
				if (typeof s.firstpos2 === "undefined" && !hidden) {
					s.firstpos2 = curpos2;
					s.nextpos2 = s.firstpos2;
				}
				// Check that it's not beyond the viewport edge.
				if ((s.dir1 === "down" && s.nextpos1 + e.height() > (s.context.is(body) ? jwindow.height() : s.context.prop('scrollHeight')) ) ||
					(s.dir1 === "up" && s.nextpos1 + e.height() > (s.context.is(body) ? jwindow.height() : s.context.prop('scrollHeight')) ) ||
					(s.dir1 === "left" && s.nextpos1 + e.width() > (s.context.is(body) ? jwindow.width() : s.context.prop('scrollWidth')) ) ||
					(s.dir1 === "right" && s.nextpos1 + e.width() > (s.context.is(body) ? jwindow.width() : s.context.prop('scrollWidth')) ) ) {
					// If it is, it needs to go back to the first pos1, and over on pos2.
					s.nextpos1 = s.firstpos1;
					s.nextpos2 += s.addpos2 + (typeof s.spacing2 === "undefined" ? 25 : s.spacing2);
					s.addpos2 = 0;
				}
				// Animate if we're moving on dir2.
				if (s.animation && s.nextpos2 < curpos2) {
					switch (s.dir2) {
						case "down":
							animate.top = s.nextpos2+"px";
							break;
						case "up":
							animate.bottom = s.nextpos2+"px";
							break;
						case "left":
							animate.right = s.nextpos2+"px";
							break;
						case "right":
							animate.left = s.nextpos2+"px";
							break;
					}
				} else {
					if(typeof s.nextpos2 === "number")
						e.css(csspos2, s.nextpos2+"px");
				}
				// Keep track of the widest/tallest notice in the column/row, so we can push the next column/row.
				switch (s.dir2) {
					case "down":
					case "up":
						if (e.outerHeight(true) > s.addpos2)
							s.addpos2 = e.height();
						break;
					case "left":
					case "right":
						if (e.outerWidth(true) > s.addpos2)
							s.addpos2 = e.width();
						break;
				}
				// Move the notice on dir1.
				if (typeof s.nextpos1 === "number") {
					// Animate if we're moving toward the first pos.
					if (s.animation && (curpos1 > s.nextpos1 || animate.top || animate.bottom || animate.right || animate.left)) {
						switch (s.dir1) {
							case "down":
								animate.top = s.nextpos1+"px";
								break;
							case "up":
								animate.bottom = s.nextpos1+"px";
								break;
							case "left":
								animate.right = s.nextpos1+"px";
								break;
							case "right":
								animate.left = s.nextpos1+"px";
								break;
						}
					} else
						e.css(csspos1, s.nextpos1+"px");
				}
				// Run the animation.
				if (animate.top || animate.bottom || animate.right || animate.left)
					e.animate(animate, {duration: this.options.position_animate_speed, queue: false});
				// Calculate the next dir1 position.
				switch (s.dir1) {
					case "down":
					case "up":
						s.nextpos1 += e.height() + (typeof s.spacing1 === "undefined" ? 25 : s.spacing1);
						break;
					case "left":
					case "right":
						s.nextpos1 += e.width() + (typeof s.spacing1 === "undefined" ? 25 : s.spacing1);
						break;
				}
			}
			return this;
		},
		// Queue the position all function so it doesn't run repeatedly and
		// use up resources.
		queuePosition: function(animate, milliseconds){
			if (timer)
				clearTimeout(timer);
			if (!milliseconds)
				milliseconds = 10;
			timer = setTimeout(function(){ PNotify.positionAll(animate) }, milliseconds);
			return this;
		},

		// Cancel any pending removal timer.
		cancelRemove: function(){
			if (this.timer)
				window.clearTimeout(this.timer);
			if (this.state === "closing") {
				// If it's animating out, animate back in really quickly.
				this.elem.stop(true);
				this.state = "open";
				this.animating = "in";
				this.elem.css("height", "auto").animate({"width": this.options.width, "opacity": this.options.opacity}, "fast");
			}
			return this;
		},
		// Queue a removal timer.
		queueRemove: function(){
			var that = this;
			// Cancel any current removal timer.
			this.cancelRemove();
			this.timer = window.setTimeout(function(){
				that.remove(true);
			}, (isNaN(this.options.delay) ? 0 : this.options.delay));
			return this;
		}
	});
	// These functions affect all notices.
	$.extend(PNotify, {
		// This holds all the notices.
		notices: [],
		removeAll: function () {
			$.each(PNotify.notices, function(){
				if (this.remove)
					this.remove();
			});
		},
		positionAll: function (animate) {
			// This timer is used for queueing this function so it doesn't run
			// repeatedly.
			if (timer)
				clearTimeout(timer);
			timer = null;
			// Reset the next position data.
			$.each(PNotify.notices, function(){
				var s = this.options.stack;
				if (!s) return;
				s.nextpos1 = s.firstpos1;
				s.nextpos2 = s.firstpos2;
				s.addpos2 = 0;
				s.animation = animate;
			});
			$.each(PNotify.notices, function(){
				this.position();
			});
		},
		styling: {
			jqueryui: {
				container: "ui-widget ui-widget-content ui-corner-all",
				notice: "ui-state-highlight",
				// (The actual jQUI notice icon looks terrible.)
				notice_icon: "ui-icon ui-icon-info",
				info: "",
				info_icon: "ui-icon ui-icon-info",
				success: "ui-state-default",
				success_icon: "ui-icon ui-icon-circle-check",
				error: "ui-state-error",
				error_icon: "ui-icon ui-icon-alert"
			},
			bootstrap2: {
				container: "alert",
				notice: "",
				notice_icon: "icon-exclamation-sign",
				info: "alert-info",
				info_icon: "icon-info-sign",
				success: "alert-success",
				success_icon: "icon-ok-sign",
				error: "alert-error",
				error_icon: "icon-warning-sign"
			},
			bootstrap3: {
				container: "alert",
				notice: "alert-warning",
				notice_icon: "glyphicon glyphicon-exclamation-sign",
				info: "alert-info",
				info_icon: "glyphicon glyphicon-info-sign",
				success: "alert-success",
				success_icon: "glyphicon glyphicon-ok-sign",
				error: "alert-danger",
				error_icon: "glyphicon glyphicon-warning-sign"
			}
		}
	});
	/*
	 * uses icons from http://fontawesome.io/
	 * version 4.0.3
	 */
	PNotify.styling.fontawesome = $.extend({}, PNotify.styling.bootstrap3);
	$.extend(PNotify.styling.fontawesome, {
		notice_icon: "fa fa-exclamation-circle",
		info_icon: "fa fa-info",
		success_icon: "fa fa-check",
		error_icon: "fa fa-warning"
	});

	if (document.body)
		do_when_ready();
	else
		$(do_when_ready);
	return PNotify;
}));

// Buttons
// Uses AMD or browser globals for jQuery.
(function (factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as a module.
        define('pnotify.buttons', ['jquery', 'pnotify'], factory);
    } else {
        // Browser globals
        factory(jQuery, PNotify);
    }
}(function($, PNotify){
	PNotify.prototype.options.buttons = {
		// Provide a button for the user to manually close the notice.
		closer: true,
		// Only show the closer button on hover.
		closer_hover: true,
		// Provide a button for the user to manually stick the notice.
		sticker: true,
		// Only show the sticker button on hover.
		sticker_hover: true,
		// The various displayed text, helps facilitating internationalization.
		labels: {
			close: "Close",
			stick: "Stick"
		}
	};
	PNotify.prototype.modules.buttons = {
		// This lets us update the options available in the closures.
		myOptions: null,

		closer: null,
		sticker: null,

		init: function(notice, options){
			var that = this;
			this.myOptions = options;
			notice.elem.on({
				"mouseenter": function(e){
					// Show the buttons.
					if (that.myOptions.sticker && !(notice.options.nonblock && notice.options.nonblock.nonblock)) that.sticker.trigger("pnotify_icon").css("visibility", "visible");
					if (that.myOptions.closer && !(notice.options.nonblock && notice.options.nonblock.nonblock)) that.closer.css("visibility", "visible");
				},
				"mouseleave": function(e){
					// Hide the buttons.
					if (that.myOptions.sticker_hover)
						that.sticker.css("visibility", "hidden");
					if (that.myOptions.closer_hover)
						that.closer.css("visibility", "hidden");
				}
			});

			// Provide a button to stick the notice.
			this.sticker = $("
", {
				"class": "ui-pnotify-sticker",
				"css": {"cursor": "pointer", "visibility": options.sticker_hover ? "hidden" : "visible"},
				"click": function(){
					notice.options.hide = !notice.options.hide;
					if (notice.options.hide)
						notice.queueRemove();
					else
						notice.cancelRemove();
					$(this).trigger("pnotify_icon");
				}
			})
			.bind("pnotify_icon", function(){
				$(this).children().removeClass(notice.styles.pin_up+" "+notice.styles.pin_down).addClass(notice.options.hide ? notice.styles.pin_up : notice.styles.pin_down);
			})
			.append($("", {"class": notice.styles.pin_up, "title": options.labels.stick}))
			.prependTo(notice.container);
			if (!options.sticker || (notice.options.nonblock && notice.options.nonblock.nonblock))
				this.sticker.css("display", "none");

			// Provide a button to close the notice.
			this.closer = $("
", {
				"class": "ui-pnotify-closer",
				"css": {"cursor": "pointer", "visibility": options.closer_hover ? "hidden" : "visible"},
				"click": function(){
					notice.remove(false);
					that.sticker.css("visibility", "hidden");
					that.closer.css("visibility", "hidden");
				}
			})
			.append($("", {"class": notice.styles.closer, "title": options.labels.close}))
			.prependTo(notice.container);
			if (!options.closer || (notice.options.nonblock && notice.options.nonblock.nonblock))
				this.closer.css("display", "none");
		},
		update: function(notice, options){
			this.myOptions = options;
			// Update the sticker and closer buttons.
			if (!options.closer || (notice.options.nonblock && notice.options.nonblock.nonblock))
				this.closer.css("display", "none");
			else if (options.closer)
				this.closer.css("display", "block");
			if (!options.sticker || (notice.options.nonblock && notice.options.nonblock.nonblock))
				this.sticker.css("display", "none");
			else if (options.sticker)
				this.sticker.css("display", "block");
			// Update the sticker icon.
			this.sticker.trigger("pnotify_icon");
			// Update the hover status of the buttons.
			if (options.sticker_hover)
				this.sticker.css("visibility", "hidden");
			else if (!(notice.options.nonblock && notice.options.nonblock.nonblock))
				this.sticker.css("visibility", "visible");
			if (options.closer_hover)
				this.closer.css("visibility", "hidden");
			else if (!(notice.options.nonblock && notice.options.nonblock.nonblock))
				this.closer.css("visibility", "visible");
		}
	};
	$.extend(PNotify.styling.jqueryui, {
		closer: "ui-icon ui-icon-close",
		pin_up: "ui-icon ui-icon-pin-w",
		pin_down: "ui-icon ui-icon-pin-s"
	});
	$.extend(PNotify.styling.bootstrap2, {
		closer: "icon-remove",
		pin_up: "icon-pause",
		pin_down: "icon-play"
	});
	$.extend(PNotify.styling.bootstrap3, {
		closer: "glyphicon glyphicon-remove",
		pin_up: "glyphicon glyphicon-pause",
		pin_down: "glyphicon glyphicon-play"
	});
	$.extend(PNotify.styling.fontawesome, {
		closer: "fa fa-times",
		pin_up: "fa fa-pause",
		pin_down: "fa fa-play"
	});
}));

// Callbacks
// Uses AMD or browser globals for jQuery.
(function (factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as a module.
        define('pnotify.callbacks', ['jquery', 'pnotify'], factory);
    } else {
        // Browser globals
        factory(jQuery, PNotify);
    }
}(function($, PNotify){
	var _init   = PNotify.prototype.init,
		_open   = PNotify.prototype.open,
		_remove = PNotify.prototype.remove;
	PNotify.prototype.init = function(){
		if (this.options.before_init) {
			this.options.before_init(this.options);
		}
		_init.apply(this, arguments);
		if (this.options.after_init) {
			this.options.after_init(this);
		}
	};
	PNotify.prototype.open = function(){
		var ret;
		if (this.options.before_open) {
			ret = this.options.before_open(this);
		}
		if (ret !== false) {
			_open.apply(this, arguments);
			if (this.options.after_open) {
				this.options.after_open(this);
			}
		}
	};
	PNotify.prototype.remove = function(timer_hide){
		var ret;
		if (this.options.before_close) {
			ret = this.options.before_close(this, timer_hide);
		}
		if (ret !== false) {
			_remove.apply(this, arguments);
			if (this.options.after_close) {
				this.options.after_close(this, timer_hide);
			}
		}
	};
}));
// Confirm
// Uses AMD or browser globals for jQuery.
(function (factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as a module.
        define('pnotify.confirm', ['jquery', 'pnotify'], factory);
    } else {
        // Browser globals
        factory(jQuery, PNotify);
    }
}(function($, PNotify){
	PNotify.prototype.options.confirm = {
		// Make a confirmation box.
		confirm: false,
		// Make a prompt.
		prompt: false,
		// Classes to add to the input element of the prompt.
		prompt_class: "",
		// The default value of the prompt.
		prompt_default: "",
		// Whether the prompt should accept multiple lines of text.
		prompt_multi_line: false,
		// Where to align the buttons. (right, center, left, justify)
		align: "right",
		// The buttons to display, and their callbacks.
		buttons: [
			{
				text: "Ok",
				addClass: "",
				// Whether to trigger this button when the user hits enter in a single line prompt.
				promptTrigger: true,
				click: function(notice, value){
					notice.remove();
					notice.get().trigger("pnotify.confirm", [notice, value]);
				}
			},
			{
				text: "Cancel",
				addClass: "",
				click: function(notice){
					notice.remove();
					notice.get().trigger("pnotify.cancel", notice);
				}
			}
		]
	};
	PNotify.prototype.modules.confirm = {
		// The div that contains the buttons.
		container: null,
		// The input element of a prompt.
		prompt: null,

		init: function(notice, options){
			this.container = $('
').css('text-align', options.align).appendTo(notice.container);

			if (options.confirm || options.prompt)
				this.makeDialog(notice, options);
			else
				this.container.hide();
		},

		update: function(notice, options){
			if (options.confirm) {
				this.makeDialog(notice, options);
				this.container.show();
			} else {
				this.container.hide().empty();
			}
		},

		afterOpen: function(notice, options){
			if (options.prompt)
				this.prompt.focus();
		},

		makeDialog: function(notice, options) {
			var already = false, that = this, btn, elem;
			this.container.empty();
			if (options.prompt) {
				this.prompt = $('<'+(options.prompt_multi_line ? 'textarea rows="5"' : 'input type="text"')+' style="margin-bottom:5px;clear:both;" />')
				.addClass(notice.styles.input+' '+options.prompt_class)
				.val(options.prompt_default)
				.appendTo(this.container);
			}
			for (var i in options.buttons) {
				btn = options.buttons[i];
				if (already)
					this.container.append(' ');
				else
					already = true;
				elem = $('<button type="button" />')
				.addClass(notice.styles.btn+' '+btn.addClass)
				.text(btn.text)
				.appendTo(this.container)
				.on("click", (function(btn){ return function(){
					if (typeof btn.click == "function") {
						btn.click(notice, options.prompt ? that.prompt.val() : null);
					}
				}})(btn));
				if (options.prompt && !options.prompt_multi_line && btn.promptTrigger)
					this.prompt.keypress((function(elem){ return function(e){
						if (e.keyCode == 13)
							elem.click();
					}})(elem));
				if (notice.styles.text) {
					elem.wrapInner('');
				}
				if (notice.styles.btnhover) {
					elem.hover((function(elem){ return function(){
						elem.addClass(notice.styles.btnhover);
					}})(elem), (function(elem){ return function(){
						elem.removeClass(notice.styles.btnhover);
					}})(elem));
				}
				if (notice.styles.btnactive) {
					elem.on("mousedown", (function(elem){ return function(){
						elem.addClass(notice.styles.btnactive);
					}})(elem)).on("mouseup", (function(elem){ return function(){
						elem.removeClass(notice.styles.btnactive);
					}})(elem));
				}
				if (notice.styles.btnfocus) {
					elem.on("focus", (function(elem){ return function(){
						elem.addClass(notice.styles.btnfocus);
					}})(elem)).on("blur", (function(elem){ return function(){
						elem.removeClass(notice.styles.btnfocus);
					}})(elem));
				}
			}
		}
	};
	$.extend(PNotify.styling.jqueryui, {
		btn: "ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only",
		btnhover: "ui-state-hover",
		btnactive: "ui-state-active",
		btnfocus: "ui-state-focus",
		input: "",
		text: "ui-button-text"
	});
	$.extend(PNotify.styling.bootstrap2, {
		btn: "btn",
		input: ""
	});
	$.extend(PNotify.styling.bootstrap3, {
		btn: "btn btn-default",
		input: "form-control"
	});
	$.extend(PNotify.styling.fontawesome, {
		btn: "btn btn-default",
		input: "form-control"
	});
}));
// Desktop
// Uses AMD or browser globals for jQuery.
(function (factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as a module.
        define('pnotify.desktop', ['jquery', 'pnotify'], factory);
    } else {
        // Browser globals
        factory(jQuery, PNotify);
    }
}(function($, PNotify){
	var permission;
	var notify = function(title, options){
		// Memoize based on feature detection.
		if ("Notification" in window) {
			notify = function (title, options) {
				return new Notification(title, options);
			};
		} else if ("mozNotification" in navigator) {
			notify = function (title, options) {
				// Gecko < 22
				return navigator.mozNotification
					.createNotification(title, options.body, options.icon)
					.show();
			};
		} else if ("webkitNotifications" in window) {
			notify = function (title, options) {
				return window.webkitNotifications.createNotification(
					options.icon,
					title,
					options.body
				);
			};
		} else {
			notify = function (title, options) {
				return null;
			};
		}
		return notify(title, options);
	};

	PNotify.prototype.options.desktop = {
		// Display the notification as a desktop notification.
		desktop: false,
		// The URL of the icon to display. If false, no icon will show. If null, a default icon will show.
		icon: null,
		// Using a tag lets you update an existing notice, or keep from duplicating notices between tabs.
		// If you leave tag null, one will be generated, facilitating the "update" function.
		// see: http://www.w3.org/TR/notifications/#tags-example
		tag: null
	};
	PNotify.prototype.modules.desktop = {
		tag: null,
		icon: null,
		genNotice: function(notice, options){
			if (options.icon === null) {
				this.icon = "http://sciactive.com/pnotify/includes/desktop/"+notice.options.type+".png";
			} else if (options.icon === false) {
				this.icon = null;
			} else {
				this.icon = options.icon;
			}
			if (this.tag === null || options.tag !== null) {
				this.tag = options.tag === null ? "PNotify-"+Math.round(Math.random() * 1000000) : options.tag;
			}
			notice.desktop = notify(notice.options.title, {
				icon: this.icon,
				body: notice.options.text,
				tag: this.tag
			});
			if (!("close" in notice.desktop)) {
				notice.desktop.close = function(){
					notice.desktop.cancel();
				};
			}
			notice.desktop.onclick = function(){
				notice.elem.trigger("click");
			};
			notice.desktop.onclose = function(){
				if (notice.state !== "closing" && notice.state !== "closed") {
					notice.remove();
				}
			};
		},
		init: function(notice, options){
			if (!options.desktop)
				return;
			permission = PNotify.desktop.checkPermission();
			if (permission != 0)
				return;
			this.genNotice(notice, options);
		},
		update: function(notice, options, oldOpts){
			if (permission != 0 || !options.desktop)
				return;
			this.genNotice(notice, options);
		},
		beforeOpen: function(notice, options){
			if (permission != 0 || !options.desktop)
				return;
			notice.elem.css({'left': '-10000px', 'display': 'none'});
		},
		afterOpen: function(notice, options){
			if (permission != 0 || !options.desktop)
				return;
			notice.elem.css({'left': '-10000px', 'display': 'none'});
			if ("show" in notice.desktop) {
				notice.desktop.show();
			}
		},
		beforeClose: function(notice, options){
			if (permission != 0 || !options.desktop)
				return;
			notice.elem.css({'left': '-10000px', 'display': 'none'});
		},
		afterClose: function(notice, options){
			if (permission != 0 || !options.desktop)
				return;
			notice.elem.css({'left': '-10000px', 'display': 'none'});
			notice.desktop.close();
		}
	};
	PNotify.desktop = {
		permission: function(){
			if (typeof Notification !== "undefined" && "requestPermission" in Notification) {
				Notification.requestPermission();
			} else if ("webkitNotifications" in window) {
				window.webkitNotifications.requestPermission();
			}
		},
		checkPermission: function(){
			if (typeof Notification !== "undefined" && "permission" in Notification) {
				return (Notification.permission == "granted" ? 0 : 1);
			} else if ("webkitNotifications" in window) {
				return window.webkitNotifications.checkPermission();
			} else {
				return 1;
			}
		}
	};
	permission = PNotify.desktop.checkPermission();
}));
// History
// Uses AMD or browser globals for jQuery.
(function (factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as a module.
        define('pnotify.history', ['jquery', 'pnotify'], factory);
    } else {
        // Browser globals
        factory(jQuery, PNotify);
    }
}(function($, PNotify){
	var history_menu,
		history_handle_top;
	$(function(){
		$("body").on("pnotify.history-all", function(){
			// Display all notices. (Disregarding non-history notices.)
			$.each(PNotify.notices, function(){
				if (this.modules.history.inHistory) {
					if (this.elem.is(":visible")) {
						// The hide variable controls whether the history pull down should
						// queue a removal timer.
						if (this.options.hide)
							this.queueRemove();
					} else if (this.open)
						this.open();
				}
			});
		}).on("pnotify.history-last", function(){
			var pushTop = (PNotify.prototype.options.stack.push === "top");

			// Look up the last history notice, and display it.
			var i = (pushTop ? 0 : -1);

			var notice;
			do {
				if (i === -1)
					notice = PNotify.notices.slice(i);
				else
					notice = PNotify.notices.slice(i, i+1);
				if (!notice[0])
					return false;

				i = (pushTop ? i + 1 : i - 1);
			} while (!notice[0].modules.history.inHistory || notice[0].elem.is(":visible"));
			if (notice[0].open)
				notice[0].open();
		});
	});
	PNotify.prototype.options.history = {
		// Place the notice in the history.
		history: true,
		// Display a pull down menu to redisplay previous notices.
		menu: false,
		// Make the pull down menu fixed to the top of the viewport.
		fixed: true,
		// Maximum number of notifications to have onscreen.
		maxonscreen: Infinity,
		// The various displayed text, helps facilitating internationalization.
		labels: {
			redisplay: "Redisplay",
			all: "All",
			last: "Last"
		}
	};
	PNotify.prototype.modules.history = {
		// The history variable controls whether the notice gets redisplayed
		// by the history pull down.
		inHistory: false,

		init: function(notice, options){
			// Make sure that no notices get destroyed.
			notice.options.destroy = false;

			this.inHistory = options.history;

			if (options.menu) {
				// If there isn't a history pull down, create one.
				if (typeof history_menu === "undefined") {
					history_menu = $("
", {
						"class": "ui-pnotify-history-container "+notice.styles.hi_menu,
						"mouseleave": function(){
							history_menu.animate({top: "-"+history_handle_top+"px"}, {duration: 100, queue: false});
						}
					})
					.append($("
", {"class": "ui-pnotify-history-header", "text": options.labels.redisplay}))
					.append($("<button />", {
							"class": "ui-pnotify-history-all "+notice.styles.hi_btn,
							"text": options.labels.all,
							"mouseenter": function(){
								$(this).addClass(notice.styles.hi_btnhov);
							},
							"mouseleave": function(){
								$(this).removeClass(notice.styles.hi_btnhov);
							},
							"click": function(){
								$(this).trigger("pnotify.history-all");
								return false;
							}
					}))
					.append($("<button />", {
							"class": "ui-pnotify-history-last "+notice.styles.hi_btn,
							"text": options.labels.last,
							"mouseenter": function(){
								$(this).addClass(notice.styles.hi_btnhov);
							},
							"mouseleave": function(){
								$(this).removeClass(notice.styles.hi_btnhov);
							},
							"click": function(){
								$(this).trigger("pnotify.history-last");
								return false;
							}
					}))
					.appendTo("body");

					// Make a handle so the user can pull down the history tab.
					var handle = $("", {
						"class": "ui-pnotify-history-pulldown "+notice.styles.hi_hnd,
						"mouseenter": function(){
							history_menu.animate({top: "0"}, {duration: 100, queue: false});
						}
					})
					.appendTo(history_menu);

					// Get the top of the handle.
					console.log(handle.offset());
					history_handle_top = handle.offset().top + 2;
					// Hide the history pull down up to the top of the handle.
					history_menu.css({top: "-"+history_handle_top+"px"});

					// Apply the fixed styling.
					if (options.fixed) {
						history_menu.addClass('ui-pnotify-history-fixed');
					}
				}
			}
		},
		update: function(notice, options){
			// Update values for history menu access.
			this.inHistory = options.history;
			if (options.fixed && history_menu) {
				history_menu.addClass('ui-pnotify-history-fixed');
			} else if (history_menu) {
				history_menu.removeClass('ui-pnotify-history-fixed');
			}
		},
		beforeOpen: function(notice, options){
			// Remove oldest notifications leaving only options.maxonscreen on screen
			if (PNotify.notices && (PNotify.notices.length > options.maxonscreen)) {
				// Oldest are normally in front of array, or if stack.push=="top" then
				// they are at the end of the array! (issue #98)
				var el;
				if (notice.options.stack.push !== "top")
					el = PNotify.notices.slice(0, PNotify.notices.length - options.maxonscreen);
				else
					el = PNotify.notices.slice(options.maxonscreen, PNotify.notices.length);

				$.each(el, function(){
					if (this.remove)
						this.remove();
				});
			}
		}
	};
	$.extend(PNotify.styling.jqueryui, {
		hi_menu: "ui-state-default ui-corner-bottom",
		hi_btn: "ui-state-default ui-corner-all",
		hi_btnhov: "ui-state-hover",
		hi_hnd: "ui-icon ui-icon-grip-dotted-horizontal"
	});
	$.extend(PNotify.styling.bootstrap2, {
		hi_menu: "well",
		hi_btn: "btn",
		hi_btnhov: "",
		hi_hnd: "icon-chevron-down"
	});
	$.extend(PNotify.styling.bootstrap3, {
		hi_menu: "well",
		hi_btn: "btn btn-default",
		hi_btnhov: "",
		hi_hnd: "glyphicon glyphicon-chevron-down"
	});
	$.extend(PNotify.styling.fontawesome, {
		hi_menu: "well",
		hi_btn: "btn btn-default",
		hi_btnhov: "",
		hi_hnd: "fa fa-chevron-down"
	});
}));
// Nonblock
// Uses AMD or browser globals for jQuery.
(function (factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as a module.
        define('pnotify.nonblock', ['jquery', 'pnotify'], factory);
    } else {
        // Browser globals
        factory(jQuery, PNotify);
    }
}(function($, PNotify){
	// Some useful regexes.
	var re_on = /^on/,
		re_mouse_events = /^(dbl)?click$|^mouse(move|down|up|over|out|enter|leave)$|^contextmenu$/,
		re_ui_events = /^(focus|blur|select|change|reset)$|^key(press|down|up)$/,
		re_html_events = /^(scroll|resize|(un)?load|abort|error)$/;
	// Fire a DOM event.
	var dom_event = function(e, orig_e){
		var event_object;
		e = e.toLowerCase();
		if (document.createEvent && this.dispatchEvent) {
			// FireFox, Opera, Safari, Chrome
			e = e.replace(re_on, '');
			if (e.match(re_mouse_events)) {
				// This allows the click event to fire on the notice. There is
				// probably a much better way to do it.
				$(this).offset();
				event_object = document.createEvent("MouseEvents");
				event_object.initMouseEvent(
					e, orig_e.bubbles, orig_e.cancelable, orig_e.view, orig_e.detail,
					orig_e.screenX, orig_e.screenY, orig_e.clientX, orig_e.clientY,
					orig_e.ctrlKey, orig_e.altKey, orig_e.shiftKey, orig_e.metaKey, orig_e.button, orig_e.relatedTarget
				);
			} else if (e.match(re_ui_events)) {
				event_object = document.createEvent("UIEvents");
				event_object.initUIEvent(e, orig_e.bubbles, orig_e.cancelable, orig_e.view, orig_e.detail);
			} else if (e.match(re_html_events)) {
				event_object = document.createEvent("HTMLEvents");
				event_object.initEvent(e, orig_e.bubbles, orig_e.cancelable);
			}
			if (!event_object) return;
			this.dispatchEvent(event_object);
		} else {
			// Internet Explorer
			if (!e.match(re_on)) e = "on"+e;
			event_object = document.createEventObject(orig_e);
			this.fireEvent(e, event_object);
		}
	};

	// This keeps track of the last element the mouse was over, so
	// mouseleave, mouseenter, etc can be called.
	var nonblock_last_elem;
	// This is used to pass events through the notice if it is non-blocking.
	var nonblock_pass = function(notice, e, e_name){
		notice.elem.css("display", "none");
		var element_below = document.elementFromPoint(e.clientX, e.clientY);
		notice.elem.css("display", "block");
		var jelement_below = $(element_below);
		var cursor_style = jelement_below.css("cursor");
		notice.elem.css("cursor", cursor_style !== "auto" ? cursor_style : "default");
		// If the element changed, call mouseenter, mouseleave, etc.
		if (!nonblock_last_elem || nonblock_last_elem.get(0) != element_below) {
			if (nonblock_last_elem) {
				dom_event.call(nonblock_last_elem.get(0), "mouseleave", e.originalEvent);
				dom_event.call(nonblock_last_elem.get(0), "mouseout", e.originalEvent);
			}
			dom_event.call(element_below, "mouseenter", e.originalEvent);
			dom_event.call(element_below, "mouseover", e.originalEvent);
		}
		dom_event.call(element_below, e_name, e.originalEvent);
		// Remember the latest element the mouse was over.
		nonblock_last_elem = jelement_below;
	};

	PNotify.prototype.options.nonblock = {
		// Create a non-blocking notice. It lets the user click elements underneath it.
		nonblock: false,
		// The opacity of the notice (if it's non-blocking) when the mouse is over it.
		nonblock_opacity: .2
	};
	PNotify.prototype.modules.nonblock = {
		// This lets us update the options available in the closures.
		myOptions: null,

		init: function(notice, options){
			var that = this;
			this.myOptions = options;
			notice.elem.on({
				"mouseenter": function(e){
					if (that.myOptions.nonblock) e.stopPropagation();
					if (that.myOptions.nonblock) {
						// If it's non-blocking, animate to the other opacity.
						notice.elem.stop().animate({"opacity": that.myOptions.nonblock_opacity}, "fast");
					}
				},
				"mouseleave": function(e){
					if (that.myOptions.nonblock) e.stopPropagation();
					nonblock_last_elem = null;
					notice.elem.css("cursor", "auto");
					// Animate back to the normal opacity.
					if (that.myOptions.nonblock && notice.animating !== "out")
						notice.elem.stop().animate({"opacity": notice.options.opacity}, "fast");
				},
				"mouseover": function(e){
					if (that.myOptions.nonblock) e.stopPropagation();
				},
				"mouseout": function(e){
					if (that.myOptions.nonblock) e.stopPropagation();
				},
				"mousemove": function(e){
					if (that.myOptions.nonblock) {
						e.stopPropagation();
						nonblock_pass(notice, e, "onmousemove");
					}
				},
				"mousedown": function(e){
					if (that.myOptions.nonblock) {
						e.stopPropagation();
						e.preventDefault();
						nonblock_pass(notice, e, "onmousedown");
					}
				},
				"mouseup": function(e){
					if (that.myOptions.nonblock) {
						e.stopPropagation();
						e.preventDefault();
						nonblock_pass(notice, e, "onmouseup");
					}
				},
				"click": function(e){
					if (that.myOptions.nonblock) {
						e.stopPropagation();
						nonblock_pass(notice, e, "onclick");
					}
				},
				"dblclick": function(e){
					if (that.myOptions.nonblock) {
						e.stopPropagation();
						nonblock_pass(notice, e, "ondblclick");
					}
				}
			});
		},
		update: function(notice, options){
			this.myOptions = options;
		}
	};
}));
// Reference
// This file is for referencing while you are making a notify module.
// Uses AMD or browser globals for jQuery.
(function (factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as a module.
        define('pnotify.reference', ['jquery', 'pnotify'], factory);
    } else {
        // Browser globals
        factory(jQuery, PNotify);
    }
}(function($, PNotify){
	// This if the default values of your options.
	PNotify.prototype.options.reference = {
		// Provide a thing for stuff. Turned off by default.
		putThing: false,
		// If you are displaying any text, you should use a labels options to
		// support internationalization.
		labels: {
			text: "Spin Around"
		}
	};
	PNotify.prototype.modules.reference = {
		// You can put variables here that are specific to a notice instance.
		thingElem: null,

		// This function is called when the notice is being created, after the
		// core has done all of its work.
		init: function(notice /* the notice object */, options /* this module's options */){
			var that = this; // This line will allow you to access instance variables
							 // like "this.thingElem" from within closures.

			// Note that options only contains the options specific to our modules.
			// To access global options, we would use notice.options.

			// We want to check to make sure the notice should include our thing.
			if (!options.putThing)
				return;

			// We're going to create a button that will be appended to the notice.
			// It will be disabled by default, so we can enable it on mouseover.
			// You should try to keep elements inside the notice container.
			this.thingElem = $('<button style="float:right;" class="btn btn-default" type="button" disabled> '+options.labels.text+'</button>').appendTo(notice.container);
			// Since our button is floated, we have to add a clearing div.
			notice.container.append('
')

			// Now we're going to enable the button on mouseenter.
			notice.elem.on({
				"mouseenter": function(e){
					// Enable the button.
					// Notice that we have to use "that" to access thingElem, because
					// we are in a different scope inside this function.
					that.thingElem.prop("disabled", false);
				},
				"mouseleave": function(e){
					// Disable the button.
					that.thingElem.prop("disabled", true);
				}
			});

			// Now we're going to make our button do something.
			this.thingElem.on("click", function(){
				// Spin the notice around.
				var cur_angle = 0;
				var timer = setInterval(function(){
					cur_angle += 10;
					if (cur_angle == 360) {
						cur_angle = 0;
						clearInterval(timer);
					}
					notice.elem.css({
						'-moz-transform': ('rotate('+cur_angle+'deg)'),
						'-webkit-transform': ('rotate('+cur_angle+'deg)'),
						'-o-transform': ('rotate('+cur_angle+'deg)'),
						'-ms-transform': ('rotate('+cur_angle+'deg)'),
						'filter': ('progid:DXImageTransform.Microsoft.BasicImage(rotation='+(cur_angle / 360 * 4)+')')
					});
				}, 20);
			});
		},

		// This is called when the notice is updating its options.
		update: function(notice, options /* the new options for our module */, oldOpts /* the old options for our module */){
			// We need to remove the button if it's now disabled, and show it again if it's enabled.
			if (options.putThing && this.thingElem)
				this.thingElem.show();
			else if (!options.putThing && this.thingElem)
				this.thingElem.hide();
			// You may notice that if the user creates a notice without our button,
			// then updates it to enable our button, they will be out of luck.
			// Whatever, I don't want to write that much code.

			// Now we update the icon, which may have changed.
			// Note that as of right now, PNotify doesn't support updating styling.
			if (this.thingElem)
				this.thingElem.find('i').attr("class", notice.styles.athing);
		},
		// I have nothing to put in these, just showing you that they exist. You
		// won't need to include them if you aren't using them.
		beforeOpen: function(notice, options){
			// Called before the notice is opened.
		},
		afterOpen: function(notice, options){
			// Called after the notice is opened.
		},
		beforeClose: function(notice, options){
			// Called before the notice is closed.
		},
		afterClose: function(notice, options){
			// Called after the notice is closed.
		},
		beforeDestroy: function(notice, options){
			// Called before the notice is destroyed.
		},
		afterDestroy: function(notice, options){
			// Called after the notice is destroyed.
		}
	};
	// This is where you would add any styling options you are using in your code.
	$.extend(PNotify.styling.jqueryui, {
		athing: "ui-icon ui-icon-refresh"
	});
	$.extend(PNotify.styling.bootstrap2, {
		athing: "icon-refresh"
	});
	$.extend(PNotify.styling.bootstrap3, {
		athing: "glyphicon glyphicon-refresh"
	});
	$.extend(PNotify.styling.fontawesome, {
		athing: "fa fa-refresh"
	});
}));


text:
package com.github.bguild.spag.parse;

/** @author Brendan Guild */
public class ExpItem extends Item {
	public static ExpItem insertion(Exp content) {
		return new ExpItem(ItemType.INSERTION, content, null, null);
	}

	public static ExpItem insertion(Exp content, Block block) {
		return new ExpItem(ItemType.INSERTION, content, block, null);
	}

	public static ExpItem command(Exp content) {
		return new ExpItem(ItemType.COMMAND, content, null, null);
	}

	public static ExpItem command(Exp content, Block block) {
		return new ExpItem(ItemType.COMMAND, content, block, null);
	}

	public static ExpItem command(Exp content, Exp value) {
		return new ExpItem(ItemType.COMMAND, content, null, value);
	}

	public static ExpItem selector(Exp content, Block block) {
		return new ExpItem(ItemType.SELECTOR, content, block, null);
	}

	public final Exp content;
	public final Block block;
	public final Exp value;

	private ExpItem(ItemType type, Exp content, Block block, Exp value) {
		super(type);
		this.content = content;
		this.block = block;
		this.value = value;
	}

	@Override
	public boolean containsError() {
		return content.containsError() || (block != null && block.containsError());
	}

	@Override
	public Exp getExp() {
		return content;
	}

	@Override
	public Block getBlock() {
		return block;
	}

	@Override
	public boolean isEquivalent(Item item) {
		if (!(item instanceof ExpItem)) return false;
		final ExpItem other = (ExpItem) item;
		if (!content.isEquivalent(other.content)) return false;
		if (value != null) {
			if (other.value == null) return false;
			if (!value.isEquivalent(other.value)) return false;
		} else if (other.value != null) return false;
		if (block != null) {
			if (other.block == null) return false;
			if (!block.isEquivalent(other.block)) return false;
		} else if (other.block != null) return false;
		return true;
	}

	@Override
	public String toString() {
		final StringBuilder sb = new StringBuilder();
		sb.append(type);
		sb.append(':');
		sb.append(content);
		if (value != null) sb.append('=').append(value);
		if (block != null)
			sb.append(block);
		else
			sb.append(';');
		return sb.toString();
	}
}


text:
package com.emerchantpay.gateway.apm;

import com.emerchantpay.gateway.GenesisClient;
import com.emerchantpay.gateway.api.constants.ErrorCodes;
import com.emerchantpay.gateway.api.constants.P24BankCodes;
import com.emerchantpay.gateway.api.exceptions.ApiException;
import com.emerchantpay.gateway.api.exceptions.InvalidParamException;
import com.emerchantpay.gateway.api.requests.financial.apm.P24Request;
import com.emerchantpay.gateway.util.Currency;
import com.emerchantpay.gateway.util.StringUtils;
import org.junit.Before;
import org.junit.Test;

import java.math.BigDecimal;
import java.net.MalformedURLException;
import java.net.URL;

import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;

public class P24Test {

	private String uniqueId;

	private GenesisClient client;
	private P24Request p24Request;

	@Before
	public void createP24() throws MalformedURLException {
		uniqueId = new StringUtils().generateUID();

		client = mock(GenesisClient.class);
		p24Request = mock(P24Request.class);
	}

	public void clearRequiredParams() {
		Integer errorCode = ErrorCodes.INPUT_DATA_ERROR.getCode();
		ApiException exception = new ApiException(errorCode, ErrorCodes.getErrorDescription(errorCode),
				new Throwable());

		when(p24Request.setBillingCountry(null)).thenThrow(exception);
	}

	public void verifyExecute() {
		when(client.execute()).thenReturn(p24Request);
		assertEquals(client.execute(), p24Request);
		verify(client).execute();
		verifyNoMoreInteractions(client);
	}

	@Test
	public void testP24() throws MalformedURLException {
		// P24
		when(p24Request.setTransactionId(isA(String.class))).thenReturn(p24Request);
		when(p24Request.setRemoteIp((isA(String.class)))).thenReturn(p24Request);
		when(p24Request.setUsage(isA(String.class))).thenReturn(p24Request);
		when(p24Request.setCurrency(isA(String.class))).thenReturn(p24Request);
		when(p24Request.setAmount(isA(BigDecimal.class))).thenReturn(p24Request);
		when(p24Request.setCustomerEmail(isA(String.class))).thenReturn(p24Request);
		when(p24Request.setCustomerPhone(isA(String.class))).thenReturn(p24Request);
		when(p24Request.setReturnSuccessUrl(isA(URL.class))).thenReturn(p24Request);
		when(p24Request.setReturnFailureUrl(isA(URL.class))).thenReturn(p24Request);
		when(p24Request.setBillingPrimaryAddress(isA(String.class))).thenReturn(p24Request);
		when(p24Request.setBillingSecondaryAddress(isA(String.class))).thenReturn(p24Request);
		when(p24Request.setBillingFirstname(isA(String.class))).thenReturn(p24Request);
		when(p24Request.setBillingLastname(isA(String.class))).thenReturn(p24Request);
		when(p24Request.setBillingCity(isA(String.class))).thenReturn(p24Request);
		when(p24Request.setBillingCountry(isA(String.class))).thenReturn(p24Request);
		when(p24Request.setBillingZipCode(isA(String.class))).thenReturn(p24Request);
		when(p24Request.setBillingState(isA(String.class))).thenReturn(p24Request);

		assertEquals(p24Request.setTransactionId(uniqueId).setRemoteIp("82.137.112.202").setUsage("TICKETS"),
				p24Request);
		assertEquals(p24Request.setCurrency(Currency.EUR.getCurrency()).setAmount(new BigDecimal("2.00")),
				p24Request);
		assertEquals(p24Request.setCustomerEmail("john@example.com").setCustomerPhone("+55555555"), p24Request);
		assertEquals(p24Request.setReturnSuccessUrl(new URL("https://example.com/return_success_url"))
				.setReturnFailureUrl(new URL("https://example.com/return_failure_url")), p24Request);
		assertEquals(p24Request.setBillingPrimaryAddress("Berlin").setBillingSecondaryAddress("Berlin")
				.setBillingFirstname("Plamen").setBillingLastname("Petrov")
				.setBillingCity("Berlin").setBillingCountry("DE")
				.setBillingZipCode("M4B1B3").setBillingState("BE"), p24Request);

		verify(p24Request).setTransactionId(uniqueId);
		verify(p24Request).setRemoteIp("82.137.112.202");
		verify(p24Request).setUsage("TICKETS");
		verify(p24Request).setCurrency(Currency.EUR.getCurrency());
		verify(p24Request).setAmount(new BigDecimal("2.00"));
		verify(p24Request).setCustomerEmail("john@example.com");
		verify(p24Request).setCustomerPhone("+55555555");
		verify(p24Request).setReturnSuccessUrl(new URL("https://example.com/return_success_url"));
		verify(p24Request).setReturnFailureUrl(new URL("https://example.com/return_failure_url"));
		verify(p24Request).setBillingPrimaryAddress("Berlin");
		verify(p24Request).setBillingSecondaryAddress("Berlin");
		verify(p24Request).setBillingFirstname("Plamen");
		verify(p24Request).setBillingLastname("Petrov");
		verify(p24Request).setBillingCity("Berlin");
		verify(p24Request).setBillingCountry("DE");
		verify(p24Request).setBillingZipCode("M4B1B3");
		verify(p24Request).setBillingState("BE");
		verifyNoMoreInteractions(p24Request);

		verifyExecute();
	}

	@Test(expected = ApiException.class)
	public void testP24WithMissingParams() {

		clearRequiredParams();

		assertNull(p24Request.setBillingCountry(null));
		verify(p24Request).setBillingCountry(null);
		verifyNoMoreInteractions(p24Request);

		verifyExecute();
	}

    @Test(expected = InvalidParamException.class)
    public void testP24BankCodeError() {
        P24Request p24Request = new P24Request();
        p24Request.setBankCode(1);
        p24Request.setCurrency(Currency.EUR.getCurrency());
        p24Request.setAmount(new BigDecimal("2.00"));
        p24Request.toXML();
    }

    @Test
    public void testP24WithBankCode() {
        P24Request p24Request = new P24Request();
        p24Request.setBankCode(P24BankCodes.BLIK_PSP);
        p24Request.setCurrency(Currency.EUR.getCurrency());
        p24Request.setAmount(new BigDecimal("2.00"));
        assertEquals(P24BankCodes.BLIK_PSP, p24Request.getBankCode());
        assertTrue(p24Request.toXML() instanceof String);
    }
}


text:
Network Statistics Extension Module
===================================

**NetStatsModule** is an extension module which shows the total network usage of the application.
The stats include all network interfaces, and both TCP and UDP usage.

<img src="../art/overlay_with_netstats_module_small.png" width="50%" alt="DebugOverlay Screen Capture">

Setup
-----

Gradle:

```groovy
dependencies {
  debugCompile 'com.ms-square:debugoverlay:1.1.3'
  releaseCompile 'com.ms-square:debugoverlay-no-op:1.1.3'
  testCompile 'com.ms-square:debugoverlay-no-op:1.1.3'

  compile ('com.ms-square:debugoverlay-ext-netstats:1.1.3') {
    exclude module: 'debugoverlay'
  }
}
```

or

```groovy
dependencies {
  // this will use a full debugoverlay lib even in the test/release build
  compile 'com.ms-square:debugoverlay-ext-netstats:1.1.3'
}
```

Usage
-----

### Simple Example

In your `Application` class:

```java
public class ExampleApplication extends Application {

  @Override public void onCreate() {
    super.onCreate();
    new DebugOverlay.Builder(this)
            .modules(new CpuUsageModule(),
                     new MemInfoModule(this),
                     new FpsModule(),
                     new NetStatsModule())
            .build()
            .install();
    // Normal app init code...
  }
}
```


text:
from flask import Flask, jsonify, Response, request  # type: ignore
import json, datetime

app = Flask(__name__)

if __name__ == '__main__':
	app.run(debug=True)


text:
package main

import (
	"fmt"
	"github.com/spf13/cobra"
	"k8s.io/kops/channels/pkg/channels"
	"k8s.io/kops/util/pkg/tables"
	"k8s.io/kubernetes/pkg/api/v1"
	"os"
)

type GetAddonsCmd struct {
}

var getAddonsCmd GetAddonsCmd

func init() {
	cmd := &cobra.Command{
		Use:     "addons",
		Aliases: []string{"addon"},
		Short:   "get addons",
		Long:    `List or get addons.`,
		Run: func(cmd *cobra.Command, args []string) {
			err := getAddonsCmd.Run(args)
			if err != nil {
				exitWithError(err)
			}
		},
	}

	getCmd.cobraCommand.AddCommand(cmd)
}

type addonInfo struct {
	Name      string
	Version   *channels.ChannelVersion
	Namespace *v1.Namespace
}

func (c *GetAddonsCmd) Run(args []string) error {
	k8sClient, err := rootCommand.KubernetesClient()
	if err != nil {
		return err
	}

	namespaces, err := k8sClient.Namespaces().List(v1.ListOptions{})
	if err != nil {
		return fmt.Errorf("error listing namespaces: %v", err)
	}

	var info []*addonInfo

	for i := range namespaces.Items {
		ns := &namespaces.Items[i]
		addons := channels.FindAddons(ns)
		for name, version := range addons {
			i := &addonInfo{
				Name:      name,
				Version:   version,
				Namespace: ns,
			}
			info = append(info, i)
		}
	}

	if len(info) == 0 {
		fmt.Printf("\nNo managed addons found\n")
		return nil
	}

	{
		t := &tables.Table{}
		t.AddColumn("NAME", func(r *addonInfo) string {
			return r.Name
		})
		t.AddColumn("NAMESPACE", func(r *addonInfo) string {
			return r.Namespace.Name
		})
		t.AddColumn("VERSION", func(r *addonInfo) string {
			if r.Version == nil {
				return "-"
			}
			if r.Version.Version != nil {
				return *r.Version.Version
			}
			return "?"
		})
		t.AddColumn("CHANNEL", func(r *addonInfo) string {
			if r.Version == nil {
				return "-"
			}
			if r.Version.Channel != nil {
				return *r.Version.Channel
			}
			return "?"
		})

		columns := []string{"NAMESPACE", "NAME", "VERSION", "CHANNEL"}
		err := t.Render(info, os.Stdout, columns...)
		if err != nil {
			return err
		}
	}

	fmt.Printf("\n")

	return nil
}


text:
package com.example.dao.memory;

import java.util.List;
import java.util.NoSuchElementException;
import java.util.Vector;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger;

import com.example.dao.ClienteDAO;
import com.example.model.Cliente;

/**
 * Cliente DAO Memory Implementation.
 *
 * @author Gustavo Bazan
 *
 */
public class ClienteDAOMemoryImpl implements ClienteDAO {
    /** Singleton instance */
	private static final ClienteDAOMemoryImpl INSTANCE = new ClienteDAOMemoryImpl();
    /** Logger */
    private static final Logger logger = Logger.getLogger(ClienteDAOMemoryImpl.class.getCanonicalName());
    /** Data */
    private static Vector<Cliente> clientes;
    /** Threadsafe ID control */
    private static AtomicInteger LAST_ID;

    private ClienteDAOMemoryImpl(){
        clientes = new Vector<>();
        LAST_ID = new AtomicInteger(0);
    }

    public static ClienteDAOMemoryImpl getInstance() {
        return INSTANCE;
    }

    private Integer incrementCount() {
        return LAST_ID.incrementAndGet();
    }

    @Override
    public Cliente create(Cliente cliente) {
        cliente.setId(incrementCount());
        clientes.add(cliente);
        logger.info(cliente.toString());
        return cliente;
    }

    @Override
    public boolean update(Cliente cliente) {
        int index = clientes.indexOf(cliente);
        if(index < 0)
            return false;
        clientes.remove(index);
        if(index < clientes.size())
            clientes.add(index, cliente);
        else
            clientes.add(cliente);
        return true;
    }

    @Override
    public boolean remove(Cliente cliente) {
        return clientes.remove(cliente);
    }

    @Override
    public Cliente find(Integer id) {
        Cliente cliente = null;
        //Optional<Cliente>  c = clientes.stream().parallel().filter(c->c.getId().equals(id)).findFirst();
        for(Cliente o : clientes){
            if(o.getId().equals(id)){
                cliente = o;
                break;
            }
        }
        return cliente;
    }

    @Override
    public Cliente first() {
        try {
            return clientes.firstElement();
        } catch (NoSuchElementException ex){
            logger.warning(ex.getMessage());
            return null;
        }
    }

    @Override
    public Cliente last() {
        try {
            return clientes.lastElement();
        } catch (NoSuchElementException ex){
            logger.warning(ex.getMessage());
            return null;
        }
    }

    @Override
    public List<Cliente> findAll() {
        return clientes;
    }

    @Override
    public Integer count(){
        return clientes.size();
    }

    public void empty(){
        clientes.clear();
        LAST_ID = new AtomicInteger(0);
    }

}


text:
class JKHtmlData;
class JKTagTextContext;

class JKParserHtmlData
{
public:
	JKParserHtmlData();
	virtual ~JKParserHtmlData();

	JK_DISABLE_COPY(JKParserHtmlData);

	static bool parserTagTextAttribute(JKHtmlData* htmlData, JKTagTextContext* tagContext);

};


text:
#ifndef __OBJC2__
#define __OBJC2__
#endif
struct objc_selector; struct objc_class;
struct __rw_objc_super {
	struct objc_object *object;
	struct objc_object *superClass;
	__rw_objc_super(struct objc_object *o, struct objc_object *s) : object(o), superClass(s) {}
};
#ifndef _REWRITER_typedef_Protocol
typedef struct objc_object Protocol;
#define _REWRITER_typedef_Protocol
#endif
#define __OBJC_RW_DLLIMPORT extern
__OBJC_RW_DLLIMPORT void objc_msgSend(void);
__OBJC_RW_DLLIMPORT void objc_msgSendSuper(void);
__OBJC_RW_DLLIMPORT void objc_msgSend_stret(void);
__OBJC_RW_DLLIMPORT void objc_msgSendSuper_stret(void);
__OBJC_RW_DLLIMPORT void objc_msgSend_fpret(void);
__OBJC_RW_DLLIMPORT struct objc_class *objc_getClass(const char *);
__OBJC_RW_DLLIMPORT struct objc_class *class_getSuperclass(struct objc_class *);
__OBJC_RW_DLLIMPORT struct objc_class *objc_getMetaClass(const char *);
__OBJC_RW_DLLIMPORT void objc_exception_throw( struct objc_object *);
__OBJC_RW_DLLIMPORT int objc_sync_enter( struct objc_object *);
__OBJC_RW_DLLIMPORT int objc_sync_exit( struct objc_object *);
__OBJC_RW_DLLIMPORT Protocol *objc_getProtocol(const char *);
#ifdef _WIN64
typedef unsigned long long  _WIN_NSUInteger;
#else
typedef unsigned int _WIN_NSUInteger;
#endif
#ifndef __FASTENUMERATIONSTATE
struct __objcFastEnumerationState {
	unsigned long state;
	void **itemsPtr;
	unsigned long *mutationsPtr;
	unsigned long extra[5];
};
__OBJC_RW_DLLIMPORT void objc_enumerationMutation(struct objc_object *);
#define __FASTENUMERATIONSTATE
#endif
#ifndef __NSCONSTANTSTRINGIMPL
struct __NSConstantStringImpl {
  int *isa;
  int flags;
  char *str;
#if _WIN64
  long long length;
#else
  long length;
#endif
};
#ifdef CF_EXPORT_CONSTANT_STRING
extern "C" __declspec(dllexport) int __CFConstantStringClassReference[];
#else
__OBJC_RW_DLLIMPORT int __CFConstantStringClassReference[];
#endif
#define __NSCONSTANTSTRINGIMPL
#endif
#ifndef BLOCK_IMPL
#define BLOCK_IMPL
struct __block_impl {
  void *isa;
  int Flags;
  int Reserved;
  void *FuncPtr;
};
// Runtime copy/destroy helper functions (from Block_private.h)
#ifdef __OBJC_EXPORT_BLOCKS
extern "C" __declspec(dllexport) void _Block_object_assign(void *, const void *, const int);
extern "C" __declspec(dllexport) void _Block_object_dispose(const void *, const int);
extern "C" __declspec(dllexport) void *_NSConcreteGlobalBlock[32];
extern "C" __declspec(dllexport) void *_NSConcreteStackBlock[32];
#else
__OBJC_RW_DLLIMPORT void _Block_object_assign(void *, const void *, const int);
__OBJC_RW_DLLIMPORT void _Block_object_dispose(const void *, const int);
__OBJC_RW_DLLIMPORT void *_NSConcreteGlobalBlock[32];
__OBJC_RW_DLLIMPORT void *_NSConcreteStackBlock[32];
#endif
#endif
#define __block
#define __weak

#include <stdarg.h>
struct __NSContainer_literal {
  void * *arr;
  __NSContainer_literal (unsigned int count, ...) {
	va_list marker;
	va_start(marker, count);
	arr = new void *[count];
	for (unsigned i = 0; i < count; i++)
	  arr[i] = va_arg(marker, void *);
	va_end( marker );
  };
  ~__NSContainer_literal() {
	delete[] arr;
  }
};
extern "C" __declspec(dllimport) void * objc_autoreleasePoolPush(void);
extern "C" __declspec(dllimport) void objc_autoreleasePoolPop(void *);

struct __AtAutoreleasePool {
  __AtAutoreleasePool() {atautoreleasepoolobj = objc_autoreleasePoolPush();}
  ~__AtAutoreleasePool() {objc_autoreleasePoolPop(atautoreleasepoolobj);}
  void * atautoreleasepoolobj;
};

#define __OFFSETOFIVAR__(TYPE, MEMBER) ((long long) &((TYPE *)0)->MEMBER)
struct __Block_byref_a_0 {
  void *__isa;
__Block_byref_a_0 *__forwarding;
 int __flags;
 int __size;
 int a;
};

struct __main_block_impl_0 {
  struct __block_impl impl;
  struct __main_block_desc_0* Desc;
  __Block_byref_a_0 *a; // by ref
  __main_block_impl_0(void *fp, struct __main_block_desc_0 *desc, __Block_byref_a_0 *_a, int flags=0) : a(_a->__forwarding) {
    impl.isa = &_NSConcreteStackBlock;
    impl.Flags = flags;
    impl.FuncPtr = fp;
    Desc = desc;
  }
};
static void __main_block_func_0(struct __main_block_impl_0 *__cself) {
  __Block_byref_a_0 *a = __cself->a; // bound by ref

 (a->__forwarding->a) = (a->__forwarding->a) + 1;
    }
static void __main_block_copy_0(struct __main_block_impl_0*dst, struct __main_block_impl_0*src) {_Block_object_assign((void*)&dst->a, (void*)src->a, 8/*BLOCK_FIELD_IS_BYREF*/);}

static void __main_block_dispose_0(struct __main_block_impl_0*src) {_Block_object_dispose((void*)src->a, 8/*BLOCK_FIELD_IS_BYREF*/);}

static struct __main_block_desc_0 {
  size_t reserved;
  size_t Block_size;
  void (*copy)(struct __main_block_impl_0*, struct __main_block_impl_0*);
  void (*dispose)(struct __main_block_impl_0*);
} __main_block_desc_0_DATA = { 0, sizeof(struct __main_block_impl_0), __main_block_copy_0, __main_block_dispose_0};
int main(int argc, const char * argv[]) {
    __attribute__((__blocks__(byref))) __Block_byref_a_0 a = {(void*)0,(__Block_byref_a_0 *)&a, 0, sizeof(__Block_byref_a_0), 6};
    void (*blk)(void) = ((void (*)())&__main_block_impl_0((void *)__main_block_func_0, &__main_block_desc_0_DATA, (__Block_byref_a_0 *)&a, 570425344));
    ((void (*)(__block_impl *))((__block_impl *)blk)->FuncPtr)((__block_impl *)blk);
    return 0;
}
static struct IMAGE_INFO { unsigned version; unsigned flag; } _OBJC_IMAGE_INFO = { 0, 2 };


text:
using System;
using System.Linq;

namespace CTC.CvsntGitImporter
{
	/// <summary>
	/// Extension methods on TimeSpan.
	/// </summary>
	public static class TimeSpanExtensions
	{
		/// <summary>
		/// Display a TimeSpan in friendly manner. Adapted from http://stackoverflow.com/a/7204071/214776.
		/// </summary>
		public static string ToFriendlyDisplay(this TimeSpan timeSpan, int maxNrOfElements = 2)
		{
			maxNrOfElements = Math.Max(Math.Min(maxNrOfElements, 5), 1);

			var parts = new[]
						{
							Tuple.Create("day", timeSpan.Days),
							Tuple.Create("hour", timeSpan.Hours),
							Tuple.Create("min", timeSpan.Minutes),
							Tuple.Create("s", timeSpan.Seconds),
							Tuple.Create("ms", timeSpan.Milliseconds)
						}
						.SkipWhile(i => i.Item2 <= 0)
						.Take(maxNrOfElements);

			return String.Join(", ", parts.Select(p => String.Format("{0} {1}", p.Item2, Pluralise(p.Item1, p.Item2))));
		}

		private static string Pluralise(string unit, int value)
		{
			if (value != 1 && !unit.EndsWith("s"))
				return unit + "s";
			else
				return unit;
		}
	}
}


text:
package kafka

import (
	"bufio"
	"bytes"
	"context"
	"log"
	"os"
	"reflect"
	"strconv"
	"testing"
	"time"
)

func TestOffsetCommitResponseV2(t *testing.T) {
	item := offsetCommitResponseV2{
		Responses: []offsetCommitResponseV2Response{
			{
				Topic: "a",
				PartitionResponses: []offsetCommitResponseV2PartitionResponse{
					{
						Partition: 1,
						ErrorCode: 2,
					},
				},
			},
		},
	}

	b := bytes.NewBuffer(nil)
	w := &writeBuffer{w: b}
	item.writeTo(w)

	var found offsetCommitResponseV2
	remain, err := (&found).readFrom(bufio.NewReader(b), b.Len())
	if err != nil {
		t.Error(err)
		t.FailNow()
	}
	if remain != 0 {
		t.Errorf("expected 0 remain, got %v", remain)
		t.FailNow()
	}
	if !reflect.DeepEqual(item, found) {
		t.Error("expected item and found to be the same")
		t.FailNow()
	}
}

func TestClientOffsetCommit(t *testing.T) {
	topic := makeTopic()
	client, shutdown := newLocalClientWithTopic(topic, 3)
	defer shutdown()
	now := time.Now()

	const N = 10 * 3
	records := make([]Record, 0, N)
	for i := 0; i < N; i++ {
		records = append(records, Record{
			Time:  now,
			Value: NewBytes([]byte("test-message-" + strconv.Itoa(i))),
		})
	}
	ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
	defer cancel()
	res, err := client.Produce(ctx, &ProduceRequest{
		Topic:        topic,
		RequiredAcks: RequireAll,
		Records:      NewRecordReader(records...),
	})
	if err != nil {
		t.Fatal(err)
	}

	if res.Error != nil {
		t.Error(res.Error)
	}

	for index, err := range res.RecordErrors {
		t.Fatalf("record at index %d produced an error: %v", index, err)
	}
	ctx, cancel = context.WithTimeout(context.Background(), time.Second*30)
	defer cancel()
	groupID := makeGroupID()

	group, err := NewConsumerGroup(ConsumerGroupConfig{
		ID:                groupID,
		Topics:            []string{topic},
		Brokers:           []string{"localhost:9092"},
		HeartbeatInterval: 2 * time.Second,
		RebalanceTimeout:  2 * time.Second,
		RetentionTime:     time.Hour,
		Logger:            log.New(os.Stdout, "cg-test: ", 0),
	})
	if err != nil {
		t.Fatal(err)
	}
	defer group.Close()

	gen, err := group.Next(ctx)
	if err != nil {
		t.Fatal(err)
	}

	ocr, err := client.OffsetCommit(ctx, &OffsetCommitRequest{
		Addr:         nil,
		GroupID:      groupID,
		GenerationID: int(gen.ID),
		MemberID:     gen.MemberID,
		Topics: map[string][]OffsetCommit{
			topic: {
				{Partition: 0, Offset: 10},
				{Partition: 1, Offset: 10},
				{Partition: 2, Offset: 10},
			},
		},
	})
	if err != nil {
		t.Fatal(err)
	}

	resps := ocr.Topics[topic]
	if len(resps) != 3 {
		t.Fatalf("expected 3 offsetcommitpartition responses; got %d", len(resps))
	}

	for _, resp := range resps {
		if resp.Error != nil {
			t.Fatal(resp.Error)
		}
	}

	ofr, err := client.OffsetFetch(ctx, &OffsetFetchRequest{
		GroupID: groupID,
		Topics:  map[string][]int{topic: {0, 1, 2}},
	})
	if err != nil {
		t.Fatal(err)
	}

	if ofr.Error != nil {
		t.Error(res.Error)
	}

	fetresps := ofr.Topics[topic]
	if len(fetresps) != 3 {
		t.Fatalf("expected 3 offsetfetchpartition responses; got %d", len(resps))
	}

	for _, r := range fetresps {
		if r.Error != nil {
			t.Fatal(r.Error)
		}

		if r.CommittedOffset != 10 {
			t.Fatalf("expected committed offset to be 10; got: %v for partition: %v", r.CommittedOffset, r.Partition)
		}
	}
}


text:
package org.apache.isis.core.metamodel.progmodel;

import java.util.List;

public interface PostProcessorSet {

    List<ObjectSpecificationPostProcessor> getPostProcessors();

}


text:
require 'mechanize'
require 'nokogiri'
require 'rails'
class AngularInitializer

  def initialize
    config = OaAngularSetup.configuration
    @app_name = config.app_name
    @factory_name = "#{@app_name}Services"
    @create_factories = config.create_factories
    @create_app_js = config.create_app_js
    @create_controllers = config.create_controllers
    @url = config.swagger_doc_url
    @destination = "#{Rails.root}#{config.destination}"
  end

  def test
    puts "in app"
    puts @app_name
  end

  def run
    Dir.mkdir("#{@destination}") unless File.exists?("#{@destination}")
    mechanize = Mechanize.new
    page = mechanize.get(@url)
    body = JSON.parse(page.body)

    if @create_app_js
      app_js_file = File.open("#{@destination}#{@app_name}.js", 'w')
      if @create_factories
        app_js_file.write("var #{@app_name} = angular.module('#{@app_name}', ['ngRoute', '#{@factory_name}']); \n")
      else
        app_js_file.write("var #{@app_name} = angular.module('#{@app_name}', ['ngRoute']); \n")
      end
      app_js_file.write("\n ");
      app_js_file.write("#{@app_name}.config(['$routeProvider', function($routeProvider) { \n");
      app_js_file.write("  $routeProvider.\n")
    end

    body["apis"].each do |api|
      model = api["path"].split('.')[0]
      api_page = mechanize.get(@url + model)
      api_body = JSON.parse(api_page.body)

      write_factories(api_body["apis"], model, @factory_name) if @create_factories
      write_app_js(api_body["apis"], model, app_js_file) if @create_app_js
      write_controllers(api_body["apis"], model, @app_name) if @create_controllers

    end

    if @create_app_js
      app_js_file.write("    otherwise({ \n")
      app_js_file.write("      redirectTo: '/' \n")
      app_js_file.write("    }); \n")
      app_js_file.write("}]); \n")
      if @create_factories
        app_js_file.write("\n")
        app_js_file.write("var #{@factory_name} = angular.module('#{@factory_name}', ['ngResource']); \n")
      end
      app_js_file.close
    end
  end

  def output_to_angular(outfile, method, path)
    # assuming only called for PUT and GET methods
    if method == 'GET'
      command = 'show'
    elsif method == 'PUT'
      command = 'update'
    else
      puts "problem. method not GET or PUT"
      return
    end
    if path.include?("id")
      ep_path = path.split('/')
      if ep_path[4].nil?
        outfile.write("    #{command}: {method:'#{method}'}")
      else
        action = ep_path[4].split(".")[0]
        if method == 'GET'
          outfile.write("    #{action}: {method:'#{method}', isArray:true, params:{action:'#{action}'}}")
        else
          outfile.write("    #{action}: {method:'#{method}', params:{action:'#{action}'}}")
        end
      end
    else
      outfile.write("    query: {method:'#{method}', isArray:true}")
    end
  end

  def write_factories(apis, model, name)
    Dir.mkdir("#{@destination}factories") unless File.exists?("#{@destination}factories")

    fh1 = name + ".factory('"
    fh2 = "', ['$resource', function($resource){\n"

    fname = "#{@destination}factories/" + model.gsub("/","") + "_factory.js"
    outfile = File.open(fname, 'w')
    outfile.write(fh1 + model.gsub("/","").chomp('s').capitalize + fh2)
    outfile.write("  return $resource('api/v1" + model + "/:id/:action', {}, { \n")

    apis.each do |endpoint|
      endpoint["operations"].each do |op|
        outfile.write("    // #{op['summary']} \n")
        ep_path = endpoint["path"].split('/')
        case op["method"]
        when /GET/
          output_to_angular(outfile, op["method"], endpoint["path"])
        when /PUT/
          output_to_angular(outfile, op["method"], endpoint["path"])
        when /POST/
          outfile.write("    create: {method:'POST'}")
        when /DELETE/
          outfile.write("    destroy: {method:'DELETE'}")
        end
        if op == endpoint["operations"].last && endpoint == apis.last
          outfile.write("\n")
        else
          outfile.write(",\n")
        end
      end
    end
    outfile.write("  });\n")
    outfile.write("}]);\n")
    outfile.close
  end

  def write_app_js(apis, model_name, outfile)
    model = model_name.delete('/')
    apis.each do |endpoint|
      endpoint["operations"].each do |op|
        case op["method"]
          when /GET/
            ep_path = endpoint["path"].split('/')
            if ep_path[4].nil?
              if endpoint["path"].include?("id")
                outfile.write("    when('/#{model}/:id', { \n")
                outfile.write("      template@url: '/angular/templates/#{model}/show.html', \n")
                outfile.write("      controller:  '#{model.capitalize}ShowCtrl' \n")
              else
                ctrl = 'index'
                outfile.write("    when('/#{model}', { \n")
                outfile.write("      template@url: '/angular/templates/#{model}/index.html',\n")
                outfile.write("      controller:  '#{model.capitalize}IndexCtrl' \n")
              end
              outfile.write("    }). \n")
            end
          when /PUT/
            ep_path = endpoint["path"].split('/')
            if ep_path[4].nil?
              outfile.write("    when('/#{model}/:id/edit', { \n")
              outfile.write("      template@url: '/angular/templates/#{model}/edit.html', \n")
              outfile.write("      controller:  '#{model.capitalize}EditCtrl' \n")
              outfile.write("    }). \n")
            end
          when /POST/
            outfile.write("    when('/#{model}/new', { \n")
            outfile.write("      template@url: '/angular/templates/#{model}/new.html', \n")
            outfile.write("      controller: '#{model.capitalize}NewCtrl' \n")
            outfile.write("    }). \n")
        end
      end
    end
  end

  def write_controllers(apis, model_name, app_name)
    Dir.mkdir("#{@destination}controllers") unless File.exists?("#{@destination}controllers")
    model = model_name.delete('/')
    service = model.chomp('s').capitalize
    outfile = File.open("#{@destination}controllers/#{model}_controllers.js", 'w')
    apis.each do |endpoint|
      endpoint["operations"].each do |op|
        case op["method"]
        when /GET/
          ep_path = endpoint["path"].split('/')
          if ep_path[4].nil?
            if endpoint["path"].include?("id")
              outfile.write("angular.module('#{@app_name}').controller('#{model.capitalize}IndexCtrl', ['$scope', '#{service}', function ($scope, #{service}) { \n")
              outfile.write("  $scope.#{model} = #{service}.query(); \n")
              outfile.write("}]); \n")
              outfile.write(" \n")
            else
              outfile.write("angular.module('#{@app_name}').controller('#{model.capitalize}ShowCtrl', ['$scope', '$routeParams', '#{service}', function ($scope, $routeParams, #{service}) { \n")
              outfile.write("  $scope.id = $routeParams.id; \n");
              outfile.write("}]); \n")
              outfile.write(" \n")
            end
          end
        when /PUT/
          ep_path = endpoint["path"].split('/')
          if ep_path[4].nil?
            outfile.write("angular.module('#{@app_name}').controller('#{model.capitalize}EditCtrl', ['$scope', '$routeParams', '#{service}', function ($scope, $routeParams, #{service}) { \n")
            outfile.write("  $scope.id = $routeParams.id; \n");
            outfile.write("}]); \n")
            outfile.write(" \n")
          end
        when /POST/
          outfile.write("angular.module('#{@app_name}').controller('#{model.capitalize}NewCtrl', ['$scope', '#{service}', function ($scope, #{service}) { \n")
          outfile.write("}]); \n")
          outfile.write(" \n")
        end
      end
    end
    outfile.close
  end
end