text:
<?php

class CacheXCache extends CacheCore implements ICacheCore
{

	/*%******************************************************************************************%*/
	// CONSTRUCTOR

	/**
	 * Constructs a new instance of this class.
	 *
	 * @param string $name (Required) A name to uniquely identify the cache object.
	 * @param string $location (Required) The location to store the cache object in. This may vary by cache method.
	 * @param integer $expires (Required) The number of seconds until a cache object is considered stale.
	 * @param boolean $gzip (Optional) Whether data should be gzipped before being stored. Defaults to true.
	 * @return object Reference to the cache object.
	 */
	public function __construct($name, $location, $expires, $gzip = true)
	{
		parent::__construct($name, null, $expires, $gzip);
		$this->id = $this->name;
	}

	/**
	 * Creates a new cache.
	 *
	 * @param mixed $data (Required) The data to cache.
	 * @return boolean Whether the operation was successful.
	 */
	public function create($data)
	{
		$data = serialize($data);
		$data = $this->gzip ? gzcompress($data) : $data;

		return xcache_set($this->id, $data, $this->expires);
	}

	/**
	 * Reads a cache.
	 *
	 * @return mixed Either the content of the cache object, or boolean `false`.
	 */
	public function read()
	{
		if ($data = xcache_get($this->id))
		{
			$data = $this->gzip ? gzuncompress($data) : $data;
			return unserialize($data);
		}

		return false;
	}

	/**
	 * Updates an existing cache.
	 *
	 * @param mixed $data (Required) The data to cache.
	 * @return boolean Whether the operation was successful.
	 */
	public function update($data)
	{
		$data = serialize($data);
		$data = $this->gzip ? gzcompress($data) : $data;

		return xcache_set($this->id, $data, $this->expires);
	}

	/**
	 * Deletes a cache.
	 *
	 * @return boolean Whether the operation was successful.
	 */
	public function delete()
	{
		return xcache_unset($this->id);
	}

	/**
	 * Defined here, but always returns false. XCache manages it's own expirations. It's worth
	 * mentioning that if the server is configured for a long xcache.var_gc_interval then it IS
	 * possible for expired data to remain in the var cache, though it is not possible to access
	 * it.
	 *
	 * @return boolean Whether the cache is expired or not.
	 */
	public function is_expired()
	{
		return false;
	}

	/**
	 * Implemented here, but always returns `false`. XCache manages its own expirations.
	 *
	 * @return mixed Either the Unix time stamp of the cache creation, or boolean `false`.
	 */
	public function timestamp()
	{
		return false;
	}

	/**
	 * Implemented here, but always returns `false`. XCache manages its own expirations.
	 *
	 * @return boolean Whether the operation was successful.
	 */
	public function reset()
	{
		return false;
	}
}

redpajama_set_name: RedPajamaGithub


text:
package tipster.build

import sbt._
import sbt.Keys._
import sbt.complete.DefaultParsers._

object DockerComposePlugin extends AutoPlugin {
  override def trigger = allRequirements

  object autoImport {
    val dockerCompose = inputKey[String]("Run a raw docker-compose command and return its output")
    val dockerComposeCommand = settingKey[String]("The path to the docker-compose command")
    val dockerComposeEnvVars = settingKey[Seq[(String, String)]]("Environment variables to set when running docker-compose")
  }

  import autoImport._

  override def projectSettings = Seq(
    dockerCompose := {
      val args = spaceDelimited("<command> <options>").parsed
      execDockerCompose(
        dockerComposeCommand.value,
        args,
        dockerComposeEnvVars.value,
        streams.value.log)
    },
    dockerComposeCommand := "docker-compose",
    dockerComposeEnvVars := Seq()
  )

  def execDockerCompose(command: String,
                        args: Seq[String],
                        environment: Seq[(String, String)],
                        log: Logger
  ): String = {
    val envString = environment map { e =>
      val (envvar, value) = e
      s"$envvar=$value"
    } mkString " "
    val cmdline = s"env ${envString} $command ${args mkString " "}"
    log.info(s"Executing command: $cmdline")
    cmdline !!
  }
}


text:
package com.callfire.api11.client.api.labels;

import com.callfire.api11.client.AccessForbiddenException;
import com.callfire.api11.client.BadRequestException;
import com.callfire.api11.client.CfApi11ApiException;
import com.callfire.api11.client.CfApi11ClientException;
import com.callfire.api11.client.InternalServerErrorException;
import com.callfire.api11.client.ResourceNotFoundException;
import com.callfire.api11.client.RestApi11Client;
import com.callfire.api11.client.UnauthorizedException;
import com.callfire.api11.client.api.common.model.Label;
import com.callfire.api11.client.api.common.model.request.QueryRequest;
import org.apache.commons.lang3.Validate;

import java.util.List;

import static com.callfire.api11.client.ClientConstants.PLACEHOLDER;
import static com.callfire.api11.client.ClientUtils.asParams;
import static com.callfire.api11.client.ModelType.listOf;
import static com.callfire.api11.client.ModelType.of;

/**
 * Using labels API you can assign or remove label to/from broadcast or number
 */
public class LabelsApi {
    private static final String LABELS_PATH = "/label.json";
    private static final String LABELS_BROADCAST_PATH = "/label/broadcast/{}.json";
    private static final String LABELS_NUMBER_PATH = "/label/number/{}.json";

    private RestApi11Client client;

    public LabelsApi(RestApi11Client client) {
        this.client = client;
    }

    /**
     * Return list of all defined label names. The labels may be associated with broadcasts or numbers.
     *
     * @param request request object with filtering options
     * @return {@link List} of {@link Label} objects
     * @throws BadRequestException          in case HTTP response code is 400 - Bad request, the request was formatted improperly.
     * @throws UnauthorizedException        in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.
     * @throws AccessForbiddenException     in case HTTP response code is 403 - Forbidden, insufficient permissions.
     * @throws ResourceNotFoundException    in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.
     * @throws InternalServerErrorException in case HTTP response code is 500 - Internal Server Error.
     * @throws CfApi11ApiException          in case HTTP response code is something different from codes listed above.
     * @throws CfApi11ClientException       in case error has occurred in client.
     */
    public List<Label> query(QueryRequest request) {
        return client.query(LABELS_PATH, listOf(Label.class), request).get();
    }

    /**
     * Delete label identified by name. All broadcasts and numbers currently containing the label will have the label
     * association removed.
     *
     * @param labelName label to remove
     * @throws BadRequestException          in case HTTP response code is 400 - Bad request, the request was formatted improperly.
     * @throws UnauthorizedException        in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.
     * @throws AccessForbiddenException     in case HTTP response code is 403 - Forbidden, insufficient permissions.
     * @throws ResourceNotFoundException    in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.
     * @throws InternalServerErrorException in case HTTP response code is 500 - Internal Server Error.
     * @throws CfApi11ApiException          in case HTTP response code is something different from codes listed above.
     * @throws CfApi11ClientException       in case error has occurred in client.
     */
    public void delete(String labelName) {
        Validate.notBlank(labelName, "labelName cannot be blank");
        client.delete(LABELS_PATH, asParams("LabelName", labelName));
    }

    /**
     * Label broadcast (Voice, Text, or IVR) by specifying broadcastId and label name. If label name doesn't currently
     * exist on system it will be created and saved.
     *
     * @param id        broadcast id
     * @param labelName label to add
     * @throws BadRequestException          in case HTTP response code is 400 - Bad request, the request was formatted improperly.
     * @throws UnauthorizedException        in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.
     * @throws AccessForbiddenException     in case HTTP response code is 403 - Forbidden, insufficient permissions.
     * @throws ResourceNotFoundException    in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.
     * @throws InternalServerErrorException in case HTTP response code is 500 - Internal Server Error.
     * @throws CfApi11ApiException          in case HTTP response code is something different from codes listed above.
     * @throws CfApi11ClientException       in case error has occurred in client.
     */
    public void labelBroadcast(long id, String labelName) {
        Validate.notBlank(labelName, "labelName cannot be blank");
        String path = LABELS_BROADCAST_PATH.replaceFirst(PLACEHOLDER, String.valueOf(id));
        client.post(path, of(Object.class), null, asParams("LabelName", labelName, "Id", id));
    }

    /**
     * Remove label from broadcast. This doesn't remove label from system, it just removes association between broadcast and label.
     *
     * @param id        broadcast id
     * @param labelName label to remove
     * @throws BadRequestException          in case HTTP response code is 400 - Bad request, the request was formatted improperly.
     * @throws UnauthorizedException        in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.
     * @throws AccessForbiddenException     in case HTTP response code is 403 - Forbidden, insufficient permissions.
     * @throws ResourceNotFoundException    in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.
     * @throws InternalServerErrorException in case HTTP response code is 500 - Internal Server Error.
     * @throws CfApi11ApiException          in case HTTP response code is something different from codes listed above.
     * @throws CfApi11ClientException       in case error has occurred in client.
     */
    public void unlabelBroadcast(long id, String labelName) {
        Validate.notBlank(labelName, "labelName cannot be blank");
        String path = LABELS_BROADCAST_PATH.replaceFirst(PLACEHOLDER, String.valueOf(id));
        client.delete(path, asParams("LabelName", labelName, "Id", id));
    }

    /**
     * Label number by specifying E.164 11 digit number identifier and label name. If label name doesn't currently
     * exist on system it will be created and saved.
     *
     * @param number    number to add label
     * @param labelName label to add
     * @throws BadRequestException          in case HTTP response code is 400 - Bad request, the request was formatted improperly.
     * @throws UnauthorizedException        in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.
     * @throws AccessForbiddenException     in case HTTP response code is 403 - Forbidden, insufficient permissions.
     * @throws ResourceNotFoundException    in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.
     * @throws InternalServerErrorException in case HTTP response code is 500 - Internal Server Error.
     * @throws CfApi11ApiException          in case HTTP response code is something different from codes listed above.
     * @throws CfApi11ClientException       in case error has occurred in client.
     */
    public void labelNumber(String number, String labelName) {
        Validate.notBlank(number, "number cannot be blank");
        Validate.notBlank(labelName, "labelName cannot be blank");
        String path = LABELS_NUMBER_PATH.replaceFirst(PLACEHOLDER, number);
        client.post(path, of(Object.class), null, asParams("LabelName", labelName, "Number", number));
    }

    /**
     * Remove label from number. This doesn't remove label from system, it just removes association between number and label.
     *
     * @param number    label to remove
     * @param labelName label to remove
     * @throws BadRequestException          in case HTTP response code is 400 - Bad request, the request was formatted improperly.
     * @throws UnauthorizedException        in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.
     * @throws AccessForbiddenException     in case HTTP response code is 403 - Forbidden, insufficient permissions.
     * @throws ResourceNotFoundException    in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.
     * @throws InternalServerErrorException in case HTTP response code is 500 - Internal Server Error.
     * @throws CfApi11ApiException          in case HTTP response code is something different from codes listed above.
     * @throws CfApi11ClientException       in case error has occurred in client.
     */
    public void unlabelNumber(String number, String labelName) {
        Validate.notBlank(number, "number cannot be blank");
        Validate.notBlank(labelName, "labelName cannot be blank");
        String path = LABELS_NUMBER_PATH.replaceFirst(PLACEHOLDER, number);
        client.delete(path, asParams("LabelName", labelName, "Number", number));
    }
}


text:
<!DOCTYPE html>

    <link rel="stylesheet" href="reset.css" />
    <link rel="stylesheet" href="style.css" />

About

Location

Sales

Shop

Pat's Salmon Cookies

Tuesday – Sunday | 6am – 8pm

Bakeshop and Cafe

--------

Order Merchandise

At Pat's Salmon Cookies, we can't wait to serve you!

We're currently selling our world-famous Salmon Cookies in baker's dozen batches, as well as gift baskets and salmon t-shirts. Please call us to place an order, or place your order online below:

--------

        <form id="shop">

Name: <input name="name" type="text" placeholder="Name">
           City: <input name="address" type="text" placeholder="City">

 Email: <input name="email" type="text" placeholder="Email">

Select Item: <select name="item" placeholder="Select Item">
                <option name="Salmon Cookies">Salmon Cookies (one dozen)</option>
                <option name="Salmon Shirt">Salmon Shirt</option>
                <option name="Gift Basket">Gift Basket</option>
            </select>

Quantity: <input name="quantity" type="number" placeholder="Quantity">

Credit Card #: <input name="payment" type="password">

Note: This is just a demo page, and has no security; please do not actually put in your real credit card number.

I agree to receive more information about Pat's Salmon Cookies.<input name"offers" type="checkbox" checked="checked">

            <button type="submit">Submit</button>

        </form>

Pat's Salmon Cookies

© 2016 Keeley Hammond.


text:
<?xml version="1.0" ?>
<tei xml:space="preserve">
	<teiHeader>
		<fileDesc xml:id="0809_0048"/>
	</teiHeader>
	<text xml:lang="en">
		<front>
<lb/>
	<idno>arXiv:0809.0048v1 [hep-ex]</idno>

	<date>30 Aug 2008<lb/></date>

	<docTitle>
	<titlePart>Global Search for New Physics at CDF<lb/> Si Xie on behalf of the CDF collaboration<lb/></titlePart>
	</docTitle>

	<byline>
	<affiliation>Massachusetts Institute of Technology,</affiliation>
	</byline>

	<address>Cambridge, MA 02139, USA.<lb/></address>

	Abstract.

A model-independent global search for new physics has been performed at the CDF experiment. This search<lb/> examines 399 final states, looking for discrepancies between observation and the standard model expectation in populations,<lb/> kinematic shapes, bumps in mass distributions suggestive of new resonances and the tails of the summed transverse momentum<lb/> distribution. This global search reveals no evidence of physics beyond the Standard Model in 2.0 fb −1 of p p collisions at<lb/> √<lb/> s = 1.96 TeV.<lb/>

	Keywords:
	<keyword>exotics, beyond Standard Model, model-independent, global search<lb/></keyword>

	<keyword>PACS: 13.90.+i</keyword>

		</front>
	</text>
</tei>


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Coq bench</title>
    <link rel="shortcut icon" type="image/png" href="../../../../../favicon.png" />
    <link href="../../../../../bootstrap.min.css" rel="stylesheet">
    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">

            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
              Toggle navigation

            </button>
             Coq bench

Unstable

dev / concurrency:proxy dev

2015-01-07 17:10:42

About

            « Up

              concurrency:proxy

                dev
                Error

 (2015-01-07 17:10:42 UTC)

Lint

Command

ruby lint.rb unstable ../unstable/packages/coq:concurrency:proxy/coq:concurrency:proxy.dev

Return code

0

Duration

0 s

Output

The package is valid.

Dry install

Dry install with the current Coq version:

Command

opam install -y --dry-run coq:concurrency:proxy.dev coq.dev

Return code

0

Duration

2 s

Output

[NOTE] Package coq is already installed (current version is dev).
The following actions will be performed:
 - install   ocamlfind.1.5.5                       [required by lwt, base64]
 - install   ppx_tools.0.99.2                      [required by lwt]
 - install   base-bytes.base                       [required by base64]
 - install   lwt.2.4.7                             [required by coq:concurrency:proxy]
 - install   base64.2.0.0                          [required by coq:concurrency:proxy]
 - install   coq:concurrency:proxy.dev
=== 6 to install ===
=-=- Synchronizing package archives -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=-=- Installing packages =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Building ocamlfind.1.5.5:
  ./configure -bindir /home/bench/.opam/system/bin -sitelib /home/bench/.opam/system/lib -mandir /home/bench/.opam/system/man -config /home/bench/.opam/system/lib/findlib.conf -no-topfind
  make all
  make opt
  make install
Installing ocamlfind.1.5.5.
Installing base-bytes.base.
Building ppx_tools.0.99.2:
  make all
  make install
Installing ppx_tools.0.99.2.
Building base64.2.0.0:
  ocaml setup.ml -configure --prefix /home/bench/.opam/system
  ocaml setup.ml -build
  ocaml setup.ml -install
Installing base64.2.0.0.
Building lwt.2.4.7:
  ./configure --prefix /home/bench/.opam/system --disable-libev --disable-camlp4 --disable-react --disable-ssl --enable-unix --enable-preemptive --disable-glib --enable-ppx
  make build
  make install
Installing lwt.2.4.7.
Building coq:concurrency:proxy.dev:
  make -j4
Installing coq:concurrency:proxy.dev.

Dry install without Coq, to test if the problem was incompatibility with the current Coq version:

Command

true

Return code

0

Duration

0 s

Install dependencies

Command

ulimit -Sv 2000000; opam install -y --deps-only coq:concurrency:proxy.dev

Return code

0

Duration

27 s

Output

The following actions will be performed:
 - install   ocamlfind.1.5.5                       [required by lwt, base64]
 - install   ppx_tools.0.99.2                      [required by lwt]
 - install   base-bytes.base                       [required by base64]
 - install   lwt.2.4.7                             [required by coq:concurrency:proxy]
 - install   base64.2.0.0                          [required by coq:concurrency:proxy]
=== 5 to install ===
=-=- Synchronizing package archives -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[default] Downloading https://opam.ocaml.org/archives/base64.2.0.0+opam.tar.gz
[default] Downloading https://opam.ocaml.org/archives/lwt.2.4.7+opam.tar.gz
[default] Downloading https://opam.ocaml.org/archives/ocamlfind.1.5.5+opam.tar.gz
[default] Downloading https://opam.ocaml.org/archives/ppx_tools.0.99.2+opam.tar.gz
=-=- Installing packages =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Building ocamlfind.1.5.5:
  ./configure -bindir /home/bench/.opam/system/bin -sitelib /home/bench/.opam/system/lib -mandir /home/bench/.opam/system/man -config /home/bench/.opam/system/lib/findlib.conf -no-topfind
  make all
  make opt
  make install
Installing ocamlfind.1.5.5.
Installing base-bytes.base.
Building ppx_tools.0.99.2:
  make all
  make install
Building base64.2.0.0:
  ocaml setup.ml -configure --prefix /home/bench/.opam/system
  ocaml setup.ml -build
  ocaml setup.ml -install
Installing ppx_tools.0.99.2.
Building lwt.2.4.7:
  ./configure --prefix /home/bench/.opam/system --disable-libev --disable-camlp4 --disable-react --disable-ssl --enable-unix --enable-preemptive --disable-glib --enable-ppx
  make build
  make install
Installing base64.2.0.0.
Installing lwt.2.4.7.

Install

Command

ulimit -Sv 2000000; opam install -y --verbose coq:concurrency:proxy.dev

Return code

1024

Duration

3 s

Output

The following actions will be performed:
 - install   coq:concurrency:proxy.dev
=== 1 to install ===
=-=- Synchronizing package archives -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[coq:concurrency:proxy.dev] Downloading https://github.com/coq-concurrency/proxy/archive/master.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   129    0   129    0     0    277      0 --:--:-- --:--:-- --:--:--   277

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  5898  100  5898    0     0   6265      0 --:--:-- --:--:-- --:--:-- 26213
200
=-=- Installing packages =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Building coq:concurrency:proxy.dev:
  make -j4
ocamlbuild coqConcurrencyProxy.native coqConcurrencyProxy.byte -use-ocamlfind -package base64,lwt,lwt.unix,num,str
ocamlfind ocamldep -package base64,lwt,lwt.unix,num,str -modules coqConcurrencyProxy.ml > coqConcurrencyProxy.ml.depends
ocamlfind ocamldep -package base64,lwt,lwt.unix,num,str -modules heap.ml > heap.ml.depends
ocamlfind ocamlc -c -package base64,lwt,lwt.unix,num,str -o heap.cmo heap.ml
ocamlfind ocamlc -c -package base64,lwt,lwt.unix,num,str -o coqConcurrencyProxy.cmo coqConcurrencyProxy.ml
+ ocamlfind ocamlc -c -package base64,lwt,lwt.unix,num,str -o coqConcurrencyProxy.cmo coqConcurrencyProxy.ml
File "coqConcurrencyProxy.ml", line 14, characters 20-33:
Error: Unbound module Base64
Command exited with code 2.
Hint: Recursive traversal of subdirectories was not enabled for this build,
  as the working directory does not look like an ocamlbuild project (no
  '_tags' or 'myocamlbuild.ml' file). If you have modules in subdirectories,
  you should add the option "-r" or create an empty '_tags' file.
  To enable recursive traversal for some subdirectories only, you can use the
  following '_tags' file:
      true: -traverse
      <dir1> or <dir2>: traverse
Makefile:2: recipe for target 'default' failed
make: *** [default] Error 10
[ERROR] The compilation of coq:concurrency:proxy.dev failed.
Removing coq:concurrency:proxy.dev.
  Nothing to do.
#=== ERROR while installing coq:concurrency:proxy.dev =========================#
# opam-version         1.2.0
# os                   linux
# command              make -j4
# path                 /home/bench/.opam/system/build/coq:concurrency:proxy.dev
# compiler             system (4.02.1)
# exit-code            2
# env-file             /home/bench/.opam/system/build/coq:concurrency:proxy.dev/coq:concurrency:proxy-9646-c61e7b.env
# stdout-file          /home/bench/.opam/system/build/coq:concurrency:proxy.dev/coq:concurrency:proxy-9646-c61e7b.out
# stderr-file          /home/bench/.opam/system/build/coq:concurrency:proxy.dev/coq:concurrency:proxy-9646-c61e7b.err
### stdout ###
# ...[truncated]
#   '_tags' or 'myocamlbuild.ml' file). If you have modules in subdirectories,
#   you should add the option "-r" or create an empty '_tags' file.
#
#   To enable recursive traversal for some subdirectories only, you can use the
#   following '_tags' file:
#
#       true: -traverse
#       <dir1> or <dir2>: traverse
#
# Makefile:2: recipe for target 'default' failed
### stderr ###
# make: *** [default] Error 10
'opam install -y --verbose coq:concurrency:proxy.dev' failed.

Installation size

No files were installed.

Uninstall

Command

true

Return code

0

Duration

0 s

Missing removes

                none

Wrong removes

                none

          Sources are on GitHub. © Guillaume Claret.


text:
module SpecHelpers
  module Helper
    module Base
      def controller
        @controller ||= Superhosting::Base.new
      end

      def mysql_controller
        controller.controller(Superhosting::Controller::Mysql)
      end

      def mysql_container_users_index(container_name)
        controller.controller(Superhosting::Controller::Mysql::User).container_users(container_name: container_name)
      end

      def mysql_container_dbs_index(container_name)
        controller.controller(Superhosting::Controller::Mysql::Db).container_dbs(container_name: container_name)
      end

      def mysql_query(sql)
        mysql_controller.query(sql)
      end

      def config
        controller.config
      end

      def lib
        controller.lib
      end

      def etc
        PathMapper.new('/etc')
      end

      def web
        PathMapper.new('/web')
      end

      def site_web(container_name, site_name)
        container_web(container_name).f(site_name)
      end

      def container_web(container_name)
        web.f(container_name)
      end

      def site_etc(container_name, site_name)
        container_etc(container_name).sites.f(site_name)
      end

      def container_etc(container_name)
        config.containers.f(container_name)
      end

      def site_lib(container_name, site_name)
        container_lib(container_name).web.f(site_name)
      end

      def container_lib(container_name)
        lib.containers.f(container_name)
      end

      def mux_lib(mux_name)
        lib.muxs.f(mux_name)
      end

      def site_aliases(container_name, site_name)
        container_lib(container_name).sites.f(site_name).aliases
      end

      def site_state(container_name, site_name)
        container_lib(container_name).sites.f(site_name).state
      end

      def container_state(container_name)
        container_lib(container_name).state
      end

      def cli(*args)
        with_thread_options = lambda do |&b|
          begin
            old_logger = Thread.current[:logger]
            old_dry_run = Thread.current[:debug]
            old_verbose = Thread.current[:verbose]
            b.call
          ensure
            Thread.current[:logger] = old_logger
            Thread.current[:debug] = old_dry_run
            Thread.current[:verbose] = old_verbose
          end
        end

        begin
          with_thread_options.call do
            Superhosting::Cli::Base.start(args)
          end
        rescue SystemExit => e
          raise unless e.status == 1
        rescue StandardError => e
          net_status = e.net_status.net_status_normalize
          $stderr.puts(net_status[:message] || [net_status[:error], net_status[:code]].compact.join(': '))
          raise
        end
      end

      def docker_api
        @docker_api ||= if @with_docker
                          Superhosting::DockerApi.new
                        else
                          docker_instance = instance_double('Superhosting::DockerApi')
                          allow(docker_instance).to receive(:method_missing) { |_method, *_args| true }
                          [:container_list, :grab_container_options].each { |m| allow(docker_instance).to receive(m) { |_options| [] } }
                          docker_instance
                        end
      end
    end
  end
end


text:
package frogcraftrebirth.common.tile;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Set;

import frogcraftrebirth.api.FrogAPI;
import frogcraftrebirth.api.recipes.ICondenseTowerRecipe;
import frogcraftrebirth.api.tile.ICondenseTowerCore;
import frogcraftrebirth.api.tile.ICondenseTowerOutputHatch;
import frogcraftrebirth.api.tile.ICondenseTowerPart;
import frogcraftrebirth.client.gui.GuiCondenseTower;
import frogcraftrebirth.client.gui.GuiTileFrog;
import frogcraftrebirth.common.gui.ContainerCondenseTower;
import frogcraftrebirth.common.gui.ContainerTileFrog;
import frogcraftrebirth.common.lib.FrogFluidTank;
import frogcraftrebirth.common.lib.recipes.FrogRecipeInputFluidStack;
import frogcraftrebirth.common.lib.tile.TileEnergySink;
import frogcraftrebirth.common.lib.tile.TileFrog;
import frogcraftrebirth.common.lib.util.ItemUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.ItemStackHandler;

import javax.annotation.Nullable;

public class TileCondenseTower extends TileEnergySink implements ICondenseTowerCore, IHasGui, IHasWork, ITickable {

	private static final int INPUT_F = 0, OUTPUT_F = 1;

	public final ItemStackHandler inv = new ItemStackHandler(2);
	public final FrogFluidTank tank = new FrogFluidTank(8000);
	private boolean previousStructureCompleteness = false;
	private final Set<ICondenseTowerOutputHatch> outputs = Collections.newSetFromMap(new IdentityHashMap<>());
	private ICondenseTowerRecipe recipe;
	public int process;
	private int processMax;
	private boolean working;
	private boolean requireRefresh;

	public TileCondenseTower() {
		super(3, 10000);
	}

	public boolean isWorking() {
		return working;
	}

	@Override
	public boolean isCompleted() {
		return previousStructureCompleteness ? outputs.size() > 0 : checkStructure();
	}

	@Override
	public void update() {
		if (getWorld().isRemote) {
			if (requireRefresh) {
				getWorld().markBlockRangeForRenderUpdate(getPos(), getPos());
				requireRefresh = false;
			}
			return;
		}

		if (!inv.getStackInSlot(INPUT_F).isEmpty()) {
			IFluidHandlerItem fluidIn = FluidUtil.getFluidHandler(inv.extractItem(INPUT_F, 1, true));
			if (fluidIn != null) {
				FluidStack transferResult = FluidUtil.tryFluidTransfer(this.tank, fluidIn, Integer.MAX_VALUE, true);
				if (transferResult != null) {
					inv.extractItem(INPUT_F, 1, false);
					ItemStack remainder = inv.insertItem(OUTPUT_F, fluidIn.getContainer(), false);
					if (!remainder.isEmpty() && remainder.getCount()> 0) {
						ItemUtil.dropItemStackAsEntityInsanely(getWorld(), getPos(), remainder);
					}
				}
			}
		}

		if (!this.isCompleted()) {
			return;
		}

		if (recipe == null) {
			recipe = FrogAPI.managerCT.getRecipe(new FrogRecipeInputFluidStack(tank.getFluid()));
			if (checkRecipe(recipe)) {
				processMax = recipe.getTime();
				process = 0;
				working = true;
				this.requireRefresh = true;
			} else {
				working = false; // Put working = false here, so that debug screen won't blink (hopefully)
				this.markDirty();
				this.sendTileUpdatePacket(this);
				this.requireRefresh = true;
				return;
			}
		}

		if (charge >= recipe.getEnergyPerTick()) {
			charge -= recipe.getEnergyPerTick();
			process++;
		}

		if (charge < 0)
			charge = 0;

		if (process == processMax) {
			this.tank.drain(recipe.getInput().amount, true);
			recipe.getOutput().forEach(fluid -> {
				for (ICondenseTowerOutputHatch output : this.outputs) {
					if (output.canInject(fluid)) {
						output.inject(fluid.copy(), true);
						return;
					}
				}
			});
			process = 0;
			processMax = 0;
			recipe = null;
		}
		this.markDirty();
		this.sendTileUpdatePacket(this);
		this.requireRefresh = true;
	}

	@Override
	public void behave() {

	}

	@Override
	public void onPartAttached(ICondenseTowerPart part) {
		if (part instanceof ICondenseTowerOutputHatch) {
			this.registerOutputHatch((ICondenseTowerOutputHatch)part);
		}
		part.setMainBlock(this);
	}

	@Override
	public void onPartRemoved(ICondenseTowerPart part) {
		this.previousStructureCompleteness = checkStructure();
	}

	@Override
	public void onDestruction() {
		outputs.stream().filter(ICondenseTowerPart::isFunctional).forEach(ICondenseTowerPart::behave);
		outputs.forEach(output -> output.setMainBlock(null));
		this.outputs.clear();
		TileEntity
				struct1 = getWorld().getTileEntity(getPos().up(1)),
				struct2 = getWorld().getTileEntity(getPos().up(2));
		if (struct1 instanceof ICondenseTowerPart) {
			((ICondenseTowerPart)struct1).setMainBlock(null);
		}
		if (struct2 instanceof ICondenseTowerPart) {
			((ICondenseTowerPart)struct2).setMainBlock(null);
		}
	}

	private boolean checkStructure() {
		this.outputs.clear();
		TileEntity
				struct1 = getWorld().getTileEntity(getPos().up(1)),
				struct2 = getWorld().getTileEntity(getPos().up(2));
		if (struct1 instanceof ICondenseTowerPart && !((ICondenseTowerPart)struct1).isFunctional() && struct2 instanceof ICondenseTowerPart && !((ICondenseTowerPart)struct2).isFunctional()) {
			for (int i = 3;;i++) {
				TileEntity tile = getWorld().getTileEntity(getPos().up(i));
				if (tile instanceof ICondenseTowerOutputHatch) {
					this.registerOutputHatch((ICondenseTowerOutputHatch)tile);
				} else {
					break;
				}
			}
			((ICondenseTowerPart)struct1).setMainBlock(this);
			((ICondenseTowerPart)struct2).setMainBlock(this);
			return true;
		} else {
			if (struct1 instanceof ICondenseTowerPart) {
				((ICondenseTowerPart)struct1).setMainBlock(null);
			}
			if (struct2 instanceof ICondenseTowerPart) {
				((ICondenseTowerPart)struct2).setMainBlock(null);
			}
			return false;
		}
	}

	private boolean checkRecipe(@Nullable ICondenseTowerRecipe aRecipe) {
		if (aRecipe == null)
			return false;
		for (FluidStack fluid : aRecipe.getOutput()) {
			boolean checkPass = false;
			for (ICondenseTowerOutputHatch output : outputs) {
				if (output.canInject(fluid.copy())) {
					checkPass = true;
					break;
				}
			}
			if (!checkPass) {
				return false;
			}
		}
		return true;
	}

	@Override
	public void onLoad() {
		super.onLoad();
		this.previousStructureCompleteness = checkStructure();
	}

	@SideOnly(Side.CLIENT)
	@Override
	public void readPacketData(DataInputStream input) throws IOException {
		super.readPacketData(input);
		tank.readPacketData(input);
		this.process = input.readInt();
		this.processMax = input.readInt();
		this.working = input.readBoolean();
	}

	@Override
	public void writePacketData(DataOutputStream output) throws IOException {
		super.writePacketData(output);
		tank.writePacketData(output);
		output.writeInt(process);
		output.writeInt(processMax);
		output.writeBoolean(working);
	}

	@Override
	public void readFromNBT(NBTTagCompound tag) {
		super.readFromNBT(tag);
		this.tank.readFromNBT(tag);
		this.inv.deserializeNBT(tag.getCompoundTag("inv"));
		this.recipe = FrogAPI.managerCT.getRecipe(new FrogRecipeInputFluidStack(FluidStack.loadFluidStackFromNBT(tag.getCompoundTag("recipe"))));
		this.working = tag.getBoolean("working");
		this.process = tag.getInteger("process");
		this.processMax = tag.getInteger("processMax");
	}

	@Override
	public NBTTagCompound writeToNBT(NBTTagCompound tag) {
		this.tank.writeToNBT(tag);
		tag.setTag("inv", inv.serializeNBT());
		tag.setTag("recipe", recipe != null ? recipe.getInput().copy().writeToNBT(new NBTTagCompound()) : new NBTTagCompound());
		tag.setBoolean("working", working);
		tag.setInteger("process", process);
		tag.setInteger("processMax", processMax);
		return super.writeToNBT(tag);
	}

	@Override
	public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
		return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
	}

	@SuppressWarnings("unchecked")
	@Override
	public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
		return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY ?
				CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tank) : super.getCapability(capability, facing);
	}

	private void registerOutputHatch(@Nullable ICondenseTowerOutputHatch output) {
		if (output != null) {
			outputs.add(output);
		}
	}

	@Override
	public ContainerTileFrog<? extends TileFrog> getGuiContainer(World world, EntityPlayer player) {
		return new ContainerCondenseTower(player.inventory, this);
	}

	@SideOnly(Side.CLIENT)
	@Override
	public GuiTileFrog<? extends TileFrog, ? extends ContainerTileFrog<? extends TileFrog>> getGui(World world, EntityPlayer player) {
		return new GuiCondenseTower(player.inventory, this);
	}
}


text:
// <copyright file="Specification.cs" company="Automate The Planet Ltd.">
// Copyright 2021 Automate The Planet Ltd.
// Licensed under the Apache License, Version 2.0 (the "License");
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
// <author>Anton Angelov</author>
// <site>http://automatetheplanet.com/</site>

namespace AdvancedSpecificationDesignPattern.Specifications.Core
{
    public abstract class Specification<TEntity> : ISpecification<TEntity>
    {
        public abstract bool IsSatisfiedBy(TEntity entity);

        public ISpecification<TEntity> And(ISpecification<TEntity> other)
        {
            return new AndSpecification<TEntity>(this, other);
        }

        public ISpecification<TEntity> Or(ISpecification<TEntity> other)
        {
            return new OrSpecification<TEntity>(this, other);
        }

        public ISpecification<TEntity> Not()
        {
            return new NotSpecification<TEntity>(this);
        }
    }
}


text:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="none">

        <LinearLayout
            android:id="@+id/mTagLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" />
    </HorizontalScrollView>

    <com.whitelaning.whitefragment.thirdparty.xrecyclerview.XRecyclerView
        android:id="@+id/mRecyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>


text:
Program to write, read and respond to a device connected to a COM-Port. (Windows-only)</br>
__Written in C# (Visual Studio)__

##Description / Ideas

* __Read__ on COM-Port, __respond__ to it and __write__
* Write scripts in C
* Use Variables
* Use Break Points
* Save and load "C-Scripts"

##GUI

![GUI](ScreenShots/ScreenShot_14-08-2015.PNG )


text:
var test = require('ava');
var Applause = require('.');

test('should replace simple key with value', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key',
        replacement: 'value'
      }
    ]
  });
  var result = applause.replace('@@key');
  t.is(result.content, 'value');
});

test('should replace simple key with empty value', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key',
        replacement: ''
      }
    ]
  });
  var result = applause.replace('@@key');
  t.is(result.content, '');
});

test('should replace simple key with value and return the detail', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key',
        replacement: 'value'
      }
    ],
    detail: true
  });
  var result = applause.replace('@@key');
  t.is(result.content, 'value');
  t.is(result.detail.length, 1);
});

test('should replace simple key with value (replacement alternative)', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key',
        replace: 'value'
      }
    ]
  });
  var result = applause.replace('@@key');
  t.is(result.content, 'value');
});

test('should replace simple key with value using custom prefix', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key',
        replacement: 'value'
      }
    ],
    prefix: '@replace:'
  });
  var result = applause.replace('@replace:key');
  t.is(result.content, 'value');
});

test('should replace simple key with value without prefix', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key',
        replacement: 'value'
      }
    ],
    usePrefix: false
  });
  var result = applause.replace('key');
  t.is(result.content, 'value');
});

test('should replace multiple key-value pairs', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key-1',
        replacement: 'value-1'
      },
      {
        match: 'key-2',
        replacement: 'value-2'
      }
    ]
  });
  var result = applause.replace('@@key-1,@@key-2');
  t.is(result.content, 'value-1,value-2');
});

test('should replace multiple key-value pairs and return the detail', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key-1',
        replacement: 'value-1'
      },
      {
        match: 'key-2',
        replacement: 'value-2'
      }
    ],
    detail: true
  });
  var result = applause.replace('@@key-1,@@key-2');
  t.is(result.content, 'value-1,value-2');
  t.is(result.detail.length, 2);
});

test('should not escape dollar sequence when use simple key', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key',
        replacement: '$'
      }
    ]
  });
  var result = applause.replace('@@key');
  t.is(result.content, '$');
});

test('should escape dollar sequence when use regexp for matching', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: /key/g,
        replacement: '$$'
      }
    ]
  });
  var result = applause.replace('key');
  t.is(result.content, '$');
});

test('should use special characters in replacement', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key',
        replacement: 'detta är en sträng'
      }
    ]
  });
  var result = applause.replace('@@key');
  t.is(result.content, 'detta är en sträng');
});

test('should use regexp for matching', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: /key/g,
        replacement: 'value'
      }
    ]
  });
  var result = applause.replace('key');
  t.is(result.content, 'value');
});

test('should use function for replacements', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key',
        replacement: function () {
          return 'value';
        }
      }
    ]
  });
  var result = applause.replace('@@key');
  t.is(result.content, 'value');
});

test('should replace "John Smith" for "Smith, John"', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: /(\w+)\s(\w+)/,
        replacement: '$2, $1'
      }
    ]
  });
  var result = applause.replace('John Smith');
  t.is(result.content, 'Smith, John');
});

test('should throw error when invalid match type found', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 1,
        replacement: 'value'
      }
    ]
  });
  t.throws(function () {
    applause.replace('@@1');
  });
});

test('should throw error when match attribute is undefined', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        replacement: 'value'
      }
    ]
  });
  t.throws(function () {
    applause.replace('@@key');
  });
});

test('should throw error when match attribute is null', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: null,
        replacement: 'value'
      }
    ]
  });
  t.throws(function () {
    applause.replace('@@key');
  });
});

test('should throw error when replacement attribute is undefined', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key'
      }
    ]
  });
  t.throws(function () {
    applause.replace('@@key');
  });
});

test('should throw error when replacement attribute is null', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key',
        replacement: null
      }
    ]
  });
  t.throws(function () {
    applause.replace('@@key');
  });
});

test('should ignore empty patterns definitions', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        // Pass
      }
    ]
  });
  var result = applause.replace('@@key');
  t.is(result.content, false);
});

test('should not match any pattern definition', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key',
        replacement: 'value'
      }
    ]
  });
  var result = applause.replace();
  t.is(result.content, false);
});

test('should ignore non-string data types', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key',
        replacement: 'value'
      }
    ]
  });
  var booleanResult = applause.replace(true);
  t.is(booleanResult.content, false);
  var numberResult = applause.replace(404);
  t.is(numberResult.content, false);
});

test('should replace patterns using plain objects', function (t) {
  var applause = Applause.create({
    variables: {
      key: 'value'
    }
  });
  var result = applause.replace('@@key');
  t.is(result.content, 'value');
});

test('should replace simple key with array object representation', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key',
        replacement: [1, 2, 3, 4]
      }
    ]
  });
  var result = applause.replace('@@key');
  t.is(result.content, '[1,2,3,4]');
});

test('should replace simple key with plain object representation', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key',
        replacement: {
          foo: 'bar'
        }
      }
    ]
  });
  var result = applause.replace('@@key');
  t.is(result.content, '{"foo":"bar"}');
});

test('should sort patterns to prevent bad replaces', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'smaller',
        replacement: '2'
      },
      {
        match: 'small',
        replacement: '1'
      },
      {
        match: 'smallest',
        replacement: '3'
      }
    ]
  });
  var result = applause.replace('@@small-@@smaller-@@smallest');
  t.is(result.content, '1-2-3');
});

test('should replace simple key with value and preserve prefix', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key',
        replacement: 'value'
      }
    ],
    preservePrefix: true
  });
  var result = applause.replace('@@key');
  t.is(result.content, '@@value');
});

test('should replace simple key with array object representation and preserve prefix', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key',
        replacement: [1, 2, 3, 4]
      }
    ],
    preservePrefix: true
  });
  var result = applause.replace('@@key');
  t.is(result.content, '@@[1,2,3,4]');
});

test('should replace simple key with value and not preserve prefix (function as replacement)', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: 'key',
        replacement: function () {
          return 'value';
        }
      }
    ],
    preservePrefix: true
  });
  var result = applause.replace('@@key');
  t.is(result.content, 'value');
});

test('should replace simple key with value and not preserve prefix (regexp as match)', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: /@@key/g,
        replacement: 'value'
      }
    ],
    preservePrefix: true
  });
  var result = applause.replace('@@key');
  t.is(result.content, 'value');
});

test('should escape string to create an regexp', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: '(../fonts/',
        replacement: '../font/'
      }
    ],
    usePrefix: false
  });
  var result = applause.replace('(../fonts/');
  t.is(result.content, '../font/');
});

test('should escape special characters in replacement', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: '$var',
        replacement: '$var-value'
      },
      {
        match: '@var',
        replacement: '@var-value'
      }
    ],
    usePrefix: false
  });
  var result = applause.replace([
    '$var',
    '@var'
  ].join());
  t.is(result.content, [
    '$var-value',
    '@var-value'
  ].join());
});

test('should escape special characters in replacement (function as replacement)', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        match: '$var-fn',
        replacement: function () {
          return '$var-fn-value';
        }
      },
      {
        match: '@var-fn',
        replacement: function () {
          return '@var-fn-value';
        }
      }
    ],
    usePrefix: false
  });
  var result = applause.replace([
    '$var-fn',
    '@var-fn'
  ].join());
  t.is(result.content, [
    '$var-fn-value',
    '@var-fn-value'
  ].join());
});

test('should check version number', function (t) {
  t.truthy(Applause.version);
});

// Plugins

// JSON

test('should read from json and replace simple key with value', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        json: {
          key: 'value'
        }
      }
    ]
  });
  var result = applause.replace('@@key');
  t.is(result.content, 'value');
});

test('should read from json and replace simple key with value (escape dollar sequence)', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        json: {
          API_KEY: '12213lkhgjhvj$$bvhmvff@sdfertvc'
        }
      }
    ]
  });
  var result = applause.replace('@@API_KEY');
  t.is(result.content, '12213lkhgjhvj$$bvhmvff@sdfertvc');
});

test('should read from deferrer json and replace simple key with value', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        json: function (done) {
          done({
            key: 'value'
          });
        }
      }
    ]
  });
  var result = applause.replace('@@key');
  t.is(result.content, 'value');
});

test('should sort the json patterns to prevent bad replaces', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        json: {
          small: '1',
          smaller: '2',
          smallest: '3'
        }
      }
    ]
  });
  var result = applause.replace('@@small-@@smaller-@@smallest');
  t.is(result.content, '1-2-3');
});

// Flatten

var jsonFixture = {
  key1: 'value1',
  key2: 'value2',
  group1: {
    group2: {
      key3: 'value3'
    },
    group3: {
      key4: 'value4'
    },
    array: [1, 2, 3]
  }
};

test('should flatten json object', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        json: jsonFixture
      }
    ]
  });
  var result = applause.replace('@@group1.group2.key3');
  t.is(result.content, 'value3');
});

test('should flatten json object with custom delimiter', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        json: jsonFixture
      }
    ],
    delimiter: '-'
  });
  var result = applause.replace('@@group1-group2-key3');
  t.is(result.content, 'value3');
});

test('should replace simple key from json with plain object representation', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        json: jsonFixture
      }
    ]
  });
  var result = applause.replace('@@group1.group2');
  t.is(result.content, '{"key3":"value3"}');
});

test('should replace simple key from json with plain object representation and preserve prefix', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        json: jsonFixture
      }
    ],
    preservePrefix: true
  });
  var result = applause.replace('@@group1.group2');
  t.is(result.content, '@@{"key3":"value3"}');
});

// YAML

test('should read from yaml and replace simple key with value', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        yaml: 'key: "value"'
      }
    ]
  });
  var result = applause.replace('@@key');
  t.is(result.content, 'value');
});

test('should read from yaml and replace simple key with value (escape dollar sequence)', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        yaml: 'API_KEY: "12213lkhgjhvj$$bvhmvff@sdfertvc"'
      }
    ]
  });
  var result = applause.replace('@@API_KEY');
  t.is(result.content, '12213lkhgjhvj$$bvhmvff@sdfertvc');
});

test('should read from deferrer yaml and replace simple key with value', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        yaml: function (done) {
          done('key: "value"');
        }
      }
    ]
  });
  var result = applause.replace('@@key');
  t.is(result.content, 'value');
});

test('should sort the yaml patterns to prevent bad replaces', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        yaml: 'small: "1"\nsmaller: "2"\nsmallest: "3"'
      }
    ]
  });
  var result = applause.replace('@@small-@@smaller-@@smallest');
  t.is(result.content, '1-2-3');
});

// CSON

test('should read from cson and replace simple key with value', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        cson: 'key: "value"'
      }
    ]
  });
  var result = applause.replace('@@key');
  t.is(result.content, 'value');
});

test('should read from cson and replace simple key with value (escape dollar sequence)', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        cson: 'API_KEY: "12213lkhgjhvj$$bvhmvff@sdfertvc"'
      }
    ]
  });
  var result = applause.replace('@@API_KEY');
  t.is(result.content, '12213lkhgjhvj$$bvhmvff@sdfertvc');
});

test('should read from deferrer cson and replace simple key with value', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        cson: function (done) {
          done('key: "value"');
        }
      }
    ]
  });
  var result = applause.replace('@@key');
  t.is(result.content, 'value');
});

test('should sort the cson patterns to prevent bad replaces', function (t) {
  var applause = Applause.create({
    patterns: [
      {
        cson: 'small: "1"\nsmaller: "2"\nsmallest: "3"'
      }
    ]
  });
  var result = applause.replace('@@small-@@smaller-@@smallest');
  t.is(result.content, '1-2-3');
});