text:
namespace CompositeC1Contrib.FormBuilder.Validation
{
    public class ValidationOptions
    {
        public bool ValidateFiles { get; set; }
        public bool ValidateCaptcha { get; set; }
        public ValidationOptions()
        {
            ValidateFiles = true;
            ValidateCaptcha = true;
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
package com.artbeatte.exercises.arrays;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
 * @author art.beatte
 * @version 1/22/16
 */
public class GivenNumbersSumThreeTest {

    private ArrayFindable mGNS3;

    @Before
    public void setUp() {
        mGNS3 = new GivenNumbersSumThree();
    }

    @Test
    public void testGivenSumNumbers() {
        int[] testArray = {1, 2, 4, 7, 11, 15};
        int[] solution = mGNS3.find(testArray, 30);

        assertEquals(solution.length, 3);
        assertTrue(solution[0] != solution[1] && solution[1] != solution[2] && solution[2] != solution[0]);
        assertTrue(solution[0] == 4 || solution[0] == 11 || solution[0] == 15);
        assertTrue(solution[1] == 4 || solution[1] == 11 || solution[1] == 15);
    }
}


text:
ACCEPTED

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Mycotaxon 30: 419 (1987)

#### Original name
Pseudaleuria quinaultiana Lusk, 1987

### Remarks
null


text:
;function GpuWorker() {

  var me = this;
  var resultOffset = 0;

  //var pow2 = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096];
  var pow2 = [1, 4, 16, 64, 256, 1024];

  me.prepare = function(id) {
    return me.prepareString(document.getElementById(id).innerHTML);
  };

  me.setResultRange = function(min, max) {
    resultOffset = Math.max(Math.abs(min), Math.abs(max));
  };

  me.prepareString  = function(glsl_str) {
    var length = -1;
    var pad = 0;
    var webCLGL = new WebCLGL();

    return function() {
      var args = Array.prototype.slice.call(arguments);
      var buffers = [];

      for (var i=0; i < args.length; i++) {
        var arg = args[i];

        if (Object.prototype.toString.call(arg) !== '[object Array]') {
          if (typeof arg === 'Number') {
            // Special case.  It's a constant
            buffers[i] = arg;
            continue;
          } else {
            console.error('Arguments must be numbers or array types');
            return false;
          }
        }

        if (length < 0) {
          // Length requirement not set yet
          length = arg.length;
          //if (!isPow2(length) || length < 4) {
            // Calculate amount of padding
            // need to pad if it's not a power of 2!  Or less than 4
            var nextPow2 = -1;
            for (var j=0; j < pow2.length; j++) {
              var pp = pow2[j];
              if (pp >= length) {
                pad = pp - length;
                break;
              }
            }
            pad = 0;
            if (pad < 0) {
              // Failed, maybe because this is a really long list
              // User is responsible for enforcing power of 2 now
              console.error('Array arguments must be a power of 2 in length');
              return false;
            }
          //}
        } else if (arg.length !== length) {
          console.error('Required length', length, 'but got', arg.length + pad);
          console.log('For arg:', arg);
          return false;
        }

        if (pad > 0) {
          // Pad to power of 2 length
          for (var j=0; j < pad; j++) {
            arg.push(0);
          }
        }

        var offset = 0;
        // offset is set dynamically based on range
        var min = Number.MAX_VALUE;
        var max = Number.MIN_VALUE;

        if (typeof arg[0] === 'number') {
          // It's an array of floats
          for (var j=0; j < arg.length; j++) {
            var tmpj = arg[j];
            min = Math.min(tmpj, min);
            max = Math.max(tmpj, max);
          }
          offset = Math.max(Math.abs(min)-1, Math.abs(max)+1);
          buffers[i] = webCLGL.createBuffer(length, 'FLOAT', offset);
          webCLGL.enqueueWriteBuffer(buffers[i], arg);
          console.log('queueing', arg);
        } else if (Object.prototype.toString.call(arg) === '[object Array]') {
          // It's an array of float4s, so flatten it and create a buffer
          var flat = [];
          for (var j=0; j < arg.length; j++) {
            var subarr = arg[j];
            if (subarr.length != 4) {
              console.error('Only float4s are supported.  Make sure each subarray has exactly 4 values.');
              return false;
            }
            min = Math.min(subarr, min);
            max = Math.max(subarr, max);
            flat.concat(subarr);
          }
          offset = Math.max(Math.abs(min)-1, Math.abs(max)+1);
          buffers[i] = webCLGL.createBuffer(length, 'FLOAT4', offset);
          webCLGL.enqueueWriteBuffer(buffers[i], flat);
        }
      }  // end for

      console.log(glsl_str);
      var kernel = webCLGL.createKernel(glsl_str);
      for (var i=0; i < args.length; i++) {
        console.log('Setting', i, 'to', buffers[i].inData);
        kernel.setKernelArg(i, buffers[i]);
      }
      console.log('resultOffset', resultOffset);
      /*
      kernel.setKernelArg(0, [1.0, 1.0, 1.0]);
      kernel.setKernelArg(1, [1.0, 1.0, 1.0]);
      */
      kernel.compile();

      // TODO get result, either an array of floats or an array of float4s
      var buffer_ret = webCLGL.createBuffer(length+pad, 'FLOAT', resultOffset);
      webCLGL.enqueueNDRangeKernel(kernel, buffer_ret);

      var result = webCLGL.enqueueReadBuffer_Float(buffer_ret);
      return result;
    };
  };

  function isPow2(n) {
    return n != 0 && (n & (n - 1) == 0)
  }

};


text:
var elixir = require('laravel-elixir');
var gulp = require('gulp');
var gulpCopy = require('gulp-copy');

elixir.extend('copyHidden', function() {

  return new elixir.Task('copyHidden', function() {
    return gulp.src('app/includes/.*')
       // prefix prevents creation of app/ and app/includes in public/
      .pipe(gulpCopy('public/', {prefix: 2}));
  });

});


text:
<?php
namespace Wandu\DI\Providers\Pecl;

use Memcached;
use Wandu\Config\Contracts\Config;
use Wandu\DI\ContainerInterface;
use Wandu\DI\ServiceProviderInterface;

class MemcachedServiceProvider implements ServiceProviderInterface
{
    /**
     * {@inheritdoc}
     */
    public function register(ContainerInterface $app)
    {
        $app->bind(Memcached::class)->after(function(Memcached $memcached) use ($app) {
            $config = $app->get(Config::class);
            foreach ($config->get('pecl.memcached.servers', []) as $server) {
                $this->addServer($memcached, $server);
            }
            if ($server = $config->get('pecl.memcached.server')) {
                $this->addServer($memcached, $server);
            }
        });
    }

    /**
     * {@inheritdoc}
     */
    public function boot(ContainerInterface $app)
    {
    }

    private function addServer(Memcached $memcached, array $server)
    {
        $memcached->addServer(
            $server['host'] ?? '127.0.0.1',
            $server['port'] ?? 11211,
            $server['weight'] ?? 0
        );
    }
}


text:
using UnityEngine;
using System.Collections.Generic;

[System.Serializable]
public class MegaRopeMesher
{
	public Vector3[]		verts;
	public Vector2[]		uvs;
	public int[]			tris;
	public bool				show = false;

	public virtual void BuildMesh(MegaRope rope) { }
}

[System.Serializable]
public class MegaRopeHoseMesher : MegaRopeMesher
{
	// Hose, should have feature so we can fill hose
}
#endif

// TODO: region where masses get disabled (put to sleep) so if cable winds onto a drum for example

[System.Serializable]
public class MegaRopeNormMap
{
	public int[]	faces;
}

// Have a version that does the clone method with start, middle and end objects
// Deform a mesh along the spline mesher, use this in megashapes as a new layer type as well
[System.Serializable]
public class MegaRopeObjectMesher : MegaRopeMesher
{
	public GameObject	source;
	public MegaAxis		meshaxis;
	public Vector3		rot = Vector3.zero;
	public Vector3		offset = Vector3.zero;
	public Vector3		scale = Vector3.one;

	public bool			stretchtofit = true;
	public Vector3[]	sverts;
	public Vector3[]	overts;
	public Bounds bounds;

	// Twist options, curves for bulges etc
	public void SetSource()
	{

	}

	[ContextMenu("Rebuild")]
	public void Rebuild(MegaRope rope)
	{
		if ( source )
		{
			Mesh smesh = MegaUtils.GetSharedMesh(source);

			if ( smesh )
			{
				bounds = smesh.bounds;
				sverts = smesh.vertices;
				overts = new Vector3[smesh.vertexCount];

				rope.mesh.Clear();
				rope.mesh.vertices = smesh.vertices;
				rope.mesh.normals = smesh.normals;
				rope.mesh.uv = smesh.uv;
				//rope.mesh.uv1 = smesh.uv1;
				rope.mesh.subMeshCount = smesh.subMeshCount;

				for ( int i = 0; i < smesh.subMeshCount; i++ )
				{
					rope.mesh.SetTriangles(smesh.GetTriangles(i), i);
				}

				MeshRenderer mr = source.GetComponent<MeshRenderer>();

				MeshRenderer mr1 = rope.GetComponent<MeshRenderer>();
				if ( mr1 != null && mr != null )
					mr1.sharedMaterials = mr.sharedMaterials;
				// Calc the alphas

				BuildNormalMapping(smesh, true);

				BuildMesh(rope);
			}
		}
	}

	Vector3 Deform(Vector3 p, float off, MegaRope rope, float alpha)
	{
		Vector3 np = rope.Interp(alpha);	//tm.MultiplyPoint3x4(rope.Interp(alpha));
		T = rope.Velocity(alpha).normalized;
		wtm = rope.CalcFrame(T, ref N, ref B);
		//wtm.SetRow(3, np);
		MegaMatrix.SetTrans(ref wtm, np);

		return p;
	}

	Matrix4x4 wtm = Matrix4x4.identity;
	Matrix4x4 tm = Matrix4x4.identity;
	Vector3 T = Vector3.zero;
	Vector3 N = Vector3.zero;
	Vector3 B = Vector3.zero;

	// Going to have to run through the mesh and sort points based on alpha on bounds axis
	// split the spline into n frames

	Matrix4x4[]	frames;
	public int	numframes = 10;

	// This will take a selected object and deform that along the spline
	public override void BuildMesh(MegaRope rope)
	{
		// Option to stretch the mesh to fit, and end to start from
		if ( source )
		{
			if ( overts == null )
			{
				Rebuild(rope);
				//Mesh smesh = MegaUtils.GetMesh(source);
				//bounds = smesh.bounds;
				//sverts = smesh.vertices;
				//verts = new Vector3[smesh.vertexCount];
			}

			// Calc frames
			if ( frames == null || frames.Length != numframes + 1 )
			{
				frames = new Matrix4x4[numframes + 1];
			}

			wtm = rope.GetDeformMat(0.0f);
			T = wtm.MultiplyPoint3x4(rope.Velocity(0.0f).normalized);

			// Calc vector to use for cp based on velocity of first point
			Vector3 cp = wtm.MultiplyPoint3x4(tm.MultiplyPoint3x4(Vector3.right));
			N = (cp - wtm.MultiplyPoint3x4(rope.Interp(0.0f))).normalized;
			B = Vector3.Cross(T, N);

			frames[0] = wtm;

			for ( int i = 0; i <= numframes; i++ )
			{
				float alpha = (float)i / (float)numframes;
				if ( i == 0 )
				{
					alpha = 0.001f;
				}

				T = rope.Velocity(alpha).normalized;
				frames[i] = rope.CalcFrame(T, ref N, ref B);
			}

			int ax = (int)meshaxis;

			Vector3 sscl = scale;	//StartScale * GlobalScale;
			//Vector3 soff = Vector3.Scale(offset, sscl);

			tm = Matrix4x4.identity;
			//wtm = rope.GetDeformMat(0.0f);
			//T = wtm.MultiplyPoint3x4(rope.Velocity(0.0f).normalized);

			// Calc vector to use for cp based on velocity of first point
			//Vector3 cp = wtm.MultiplyPoint3x4(tm.MultiplyPoint3x4(Vector3.right));
			//N = (cp - wtm.MultiplyPoint3x4(rope.Interp(0.0f))).normalized;
			//B = Vector3.Cross(T, N);

			float off = 0.0f;
			float min = bounds.min[ax];
			float sz = bounds.size[ax];
			//float alpha = 0.0f;
			//Debug.Log("min " + min + "sz " + sz);

			off -= bounds.min[(int)meshaxis] * sscl[ax];

			if ( !stretchtofit )
			{
				sz = rope.RopeLength;
			}

			for ( int i = 0; i < sverts.Length; i++ )
			{
				Vector3 p = sverts[i];

				float alpha = Mathf.Clamp01((p[ax] - min) / sz);	// can pre calc

				//if ( alpha > 1.0f || alpha < 0.0f )
				//{
				//	Debug.Log("Alpha " + alpha + " val " + p[ax]);
				//}
				MegaMatrix.SetTrans(ref frames[(int)(alpha * numframes)], rope.Interp(alpha));

				p[ax] = 0.0f;
				p.x *= scale.x;
				p.y *= scale.y;
				p.z *= scale.z;
				//p = Deform(p, off, rope, alpha);
				overts[i] = frames[(int)(alpha * numframes)].MultiplyPoint3x4(p);
			}

			// Going to need Mega Normal calculator here potentially
			rope.mesh.vertices = overts;
			rope.mesh.RecalculateBounds();
			//rope.mesh.RecalculateNormals();
			RecalcNormals(rope.mesh, overts);
		}
	}

	public MegaRopeNormMap[]	mapping;
	public int[]		otris;
	public Vector3[]	facenorms;
	public Vector3[]	norms;

	int[] FindFacesUsing(Vector3 p, Vector3 n)
	{
		List<int> faces = new List<int>();
		Vector3 v = Vector3.zero;

		for ( int i = 0; i < otris.Length; i += 3 )
		{
			v = overts[otris[i]];
			if ( v.x == p.x && v.y == p.y && v.z == p.z )
			{
				if ( n.Equals(norms[otris[i]]) )
					faces.Add(i / 3);
			}
			else
			{
				v = overts[otris[i + 1]];
				if ( v.x == p.x && v.y == p.y && v.z == p.z )
				{
					if ( n.Equals(norms[otris[i + 1]]) )
						faces.Add(i / 3);
				}
				else
				{
					v = overts[otris[i + 2]];
					if ( v.x == p.x && v.y == p.y && v.z == p.z )
					{
						if ( n.Equals(norms[otris[i + 2]]) )
							faces.Add(i / 3);
					}
				}
			}
		}

		return faces.ToArray();
		//return faces;
	}

	// Should call this from inspector when we change to mega
	public void BuildNormalMapping(Mesh mesh, bool force)
	{
		//float t = Time.realtimeSinceStartup;
		if ( mapping == null || mapping.Length == 0 || force )
		{
			Debug.Log("Build norm data");
			// so for each normal we have a vertex, so find all faces that share that vertex
			otris = mesh.triangles;
			norms = mesh.normals;
			facenorms = new Vector3[otris.Length / 3];
			mapping = new MegaRopeNormMap[overts.Length];

			for ( int i = 0; i < overts.Length; i++ )
			{
				mapping[i] = new MegaRopeNormMap();
				mapping[i].faces = FindFacesUsing(overts[i], norms[i]);
			}
		}
		//float len = Time.realtimeSinceStartup - t;
		//Debug.Log("Took " + (len * 1000.0f) + "ms");
	}

	// My version of recalc normals
	public void RecalcNormals(Mesh ms, Vector3[] _verts)
	{
		// so first need to recalc face normals
		// then we need a map of which faces each normal in the list uses to build its new normal value
		// to build new normal its a case of add up face normals used and average, so slow bit will be face norm calc, and preprocess of
		// building map of faces used by a normal
		//if ( mapping == null )	//tris == null || tris.Length == 0 )
		//{
		//	mesh.RecalculateNormals();
		//	return;
		//}

		if ( mapping == null )
		{
			return;
		}

		int index = 0;
		Vector3 v30 = Vector3.zero;
		Vector3 v31 = Vector3.zero;
		Vector3 v32 = Vector3.zero;
		Vector3 va = Vector3.zero;
		Vector3 vb = Vector3.zero;

		for ( int f = 0; f < otris.Length; f += 3 )
		{
			v30 = _verts[otris[f]];
			v31 = _verts[otris[f + 1]];
			v32 = _verts[otris[f + 2]];

			va.x = v31.x - v30.x;
			va.y = v31.y - v30.y;
			va.z = v31.z - v30.z;

			vb.x = v32.x - v31.x;
			vb.y = v32.y - v31.y;
			vb.z = v32.z - v31.z;

			v30.x = va.y * vb.z - va.z * vb.y;
			v30.y = va.z * vb.x - va.x * vb.z;
			v30.z = va.x * vb.y - va.y * vb.x;

			// Uncomment this if you dont want normals weighted by poly size
			//float l = v30.x * v30.x + v30.y * v30.y + v30.z * v30.z;
			//l = 1.0f / Mathf.Sqrt(l);
			//v30.x *= l;
			//v30.y *= l;
			//v30.z *= l;

			facenorms[index++] = v30;
		}

		for ( int n = 0; n < norms.Length; n++ )
		{
			if ( mapping[n].faces.Length > 0 )
			{
				Vector3 norm = facenorms[mapping[n].faces[0]];

				for ( int i = 1; i < mapping[n].faces.Length; i++ )
				{
					v30 = facenorms[mapping[n].faces[i]];
					norm.x += v30.x;
					norm.y += v30.y;
					norm.z += v30.z;
				}

				float l = norm.x * norm.x + norm.y * norm.y + norm.z * norm.z;
				l = 1.0f / Mathf.Sqrt(l);
				norm.x *= l;
				norm.y *= l;
				norm.z *= l;
				norms[n] = norm;
			}
			else
				norms[n] = Vector3.up;
		}

		ms.normals = norms;
	}
}


text: Guides, resources, notes, docs and knowledge for everything Oscar.


text:
---
uid: SolidEdgeFrameworkSupport.DisplayData.GetEllipseAtIndex(System.Int32,System.Double@,System.Double@,System.Double@,System.Double@,System.Double@,System.Double@,System.Double@,System.Double@,System.Double@)
summary:
remarks:
syntax:
    parameters:
    - id: CenterX
      description: Specifies the x coordinate of the center point of the ellipse.
    - id: CenterY
      description: Specifies the y coordinate of the center point of the ellipse.
    - id: CenterZ
      description: Specifies the z coordinate of the center point of the ellipse.
    - id: Index
      description: Specifies the index of the ellipse for which you want location information.  The index begins at zero.
    - id: MajorX
      description: Specifies the x coordinate of the point where the major axis crosses the ellipse.
    - id: MajorY
      description: Specifies the y coordinate of the point where the major axis crosses the ellipse.
    - id: MajorZ
      description: Specifies the z coordinate of the point where the major axis crosses the ellipse.
    - id: MinorX
      description: Specifies the x coordinate of the point where the minor axis crosses the ellipse.
    - id: MinorY
      description: Specifies the y coordinate of the point where the minor axis crosses the ellipse.
    - id: MinorZ
      description: Specifies the z coordinate of the point where the minor axis crosses the ellipse.
---


text:
module Azure::RecoveryServicesSiteRecovery::Mgmt::V2016_08_10
  module Models
    #
    # Provider specific input for unpairing operations.
    #
    class ReplicationProviderContainerUnmappingInput

      include MsRestAzure

      # @return [String] The class type.
      attr_accessor :instance_type

      #
      # Mapper for ReplicationProviderContainerUnmappingInput class as Ruby
      # Hash.
      # This will be used for serialization/deserialization.
      #
      def self.mapper()
        {
          client_side_validation: true,
          required: false,
          serialized_name: 'ReplicationProviderContainerUnmappingInput',
          type: {
            name: 'Composite',
            class_name: 'ReplicationProviderContainerUnmappingInput',
            model_properties: {
              instance_type: {
                client_side_validation: true,
                required: false,
                serialized_name: 'instanceType',
                type: {
                  name: 'String'
                }
              }
            }
          }
        }
      end
    end
  end
end


text:
namespace clang {
namespace tidy {
namespace bugprone {

/// This check finds string literals which are probably concatenated
/// accidentally.
///
/// For the user-facing documentation see:
/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-suspicious-missing-comma.html
class SuspiciousMissingCommaCheck : public ClangTidyCheck {
public:
  SuspiciousMissingCommaCheck(StringRef Name, ClangTidyContext *Context);
  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;

private:
  // Minimal size of a string literals array to be considered by the checker.
  const unsigned SizeThreshold;
  // Maximal threshold ratio of suspicious string literals to be considered.
  const double RatioThreshold;
  // Maximal number of concatenated tokens.
  const unsigned MaxConcatenatedTokens;
};

} // namespace bugprone
} // namespace tidy
} // namespace clang

#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSMISSINGCOMMACHECK_H


text:
import scala.reflect.runtime.universe._

object Test extends App {
  val tree1 = reify(new collection.immutable.ArraySeq.ofRef[String](Array()))
  val tree2 = reify(new collection.mutable.HashMap[String, String])
  def stabilize(s: String) = """#\d+""".r.replaceAllIn(s, "#<id>")
  println(stabilize(showRaw(tree1.tree, printIds = true)))
  println(stabilize(showRaw(tree2.tree, printIds = true)))
}


text:
export const FLUX_URL = 'https://flux.io/';

// TODO(daishi): Migrate to using joinUrl style without trailing /.
export const PROFILE_PATH = 'api/whoami/';
export const AUTHORIZE_PATH = 'authorize/';
export const ACCESS_TOKEN_PATH = 'api/token/';
export const COLLABORATORS_PATH = 'api/collaborators/';

export const PROJECTS_PATH = 'api/projects/';
export const projectPath = id => `p/${id}/`;
export const projectMetaPath = id => `${projectPath(id)}api/meta/`;
export const projectUsersPath = id => `api/v1/projects/${id}/users/`;
export const projectBlockExecPath = id => `p/${id}/api/blockexec`;
export const removeUserPath = (id, userId) => `${projectUsersPath(id)}${userId}`;
export const execFlowPath = id => `p/${id}/api/flowexec`;

const dataTablePath = id => `${projectPath(id)}api/datatable/v1/`;
export const dataTableCapabilityPath = id => `${dataTablePath(id)}capability/`;
export const dataTableWebSocketPath = id => `${projectPath(id)}wsurl`;
export const dataTableHistoryPath = id => `${dataTablePath(id)}history/`;

export const cellsPath = dataTableId => `${dataTablePath(dataTableId)}cells/`;
export const cellPath = (dataTableId, id) => (
  `${cellsPath(dataTableId)}${id ? `${id}/` : ''}`
);
export const publishCellPath = (projectId, cellId) =>
`api/v1/projects/${projectId}/sharedata/${cellId}/`;

export const BCF_PATH = 'api/bcf/2.1/';
export const bcfProjectsPath = `${BCF_PATH}projects/`;
export const bcfProjectPath = projectId => `${bcfProjectsPath}${projectId}/`;
export const bcfTopicsPath = projectId => `${bcfProjectPath(projectId)}topics/`;
export const bcfTopicPath = (projectId, topicId) => `${bcfTopicsPath(projectId)}${topicId}/`;
export const bcfViewpointsPath = (projectId, topicId) => `${bcfTopicPath(projectId, topicId)}viewpoints/`;
export const bcfViewpointPath = (projectId, topicId, viewpointId) => `${bcfViewpointsPath(projectId, topicId)}${viewpointId}/`;
export const bcfSnapshotPath = (projectId, topicId, viewpointId) => `${bcfViewpointPath(projectId, topicId, viewpointId)}snapshot`;
export const bcfCommentsPath = (projectId, topicId) => `${bcfTopicPath(projectId, topicId)}comments/`;
export const bcfCommentPath = (projectId, topicId, commentId) => `${bcfCommentsPath(projectId, topicId)}${commentId}/`;


text:
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v2.1.1...v2.1.2)

**Closed issues:**

- TypeError when used with node -r flag [\#226](https://github.com/testdouble/testdouble.js/issues/226)
- When replacing a node library calling it from other modules does not work as expected [\#225](https://github.com/testdouble/testdouble.js/issues/225)
- Consider using \_.isObjectLike rather than \_.isPlainObject within td.object [\#224](https://github.com/testdouble/testdouble.js/issues/224)

## [v2.1.1](https://github.com/testdouble/testdouble.js/tree/v2.1.1) (2017-03-28)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v2.1.0...v2.1.1)

**Closed issues:**

- Add td.config\(\) to index.d.ts [\#222](https://github.com/testdouble/testdouble.js/issues/222)
- Mocking external dependencies in Express app [\#221](https://github.com/testdouble/testdouble.js/issues/221)

**Merged pull requests:**

- Add typings for config function [\#223](https://github.com/testdouble/testdouble.js/pull/223) ([lumaxis](https://github.com/lumaxis))

## [v2.1.0](https://github.com/testdouble/testdouble.js/tree/v2.1.0) (2017-03-25)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v2.0.5...v2.1.0)

**Closed issues:**

- Using td.replace\(\) with external modules [\#51](https://github.com/testdouble/testdouble.js/issues/51)

**Merged pull requests:**

- Add support for third party modules [\#220](https://github.com/testdouble/testdouble.js/pull/220) ([searls](https://github.com/searls))

## [v2.0.5](https://github.com/testdouble/testdouble.js/tree/v2.0.5) (2017-03-25)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v2.0.4...v2.0.5)

## [v2.0.4](https://github.com/testdouble/testdouble.js/tree/v2.0.4) (2017-03-23)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v2.0.3...v2.0.4)

**Closed issues:**

- `constructor\(someConstructorFunction\)` not referenced in associated example [\#213](https://github.com/testdouble/testdouble.js/issues/213)

**Merged pull requests:**

- Improve main build [\#212](https://github.com/testdouble/testdouble.js/pull/212) ([searls](https://github.com/searls))

## [v2.0.3](https://github.com/testdouble/testdouble.js/tree/v2.0.3) (2017-03-18)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v2.0.2...v2.0.3)

**Merged pull requests:**

- Rework test build [\#211](https://github.com/testdouble/testdouble.js/pull/211) ([searls](https://github.com/searls))

## [v2.0.2](https://github.com/testdouble/testdouble.js/tree/v2.0.2) (2017-03-17)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v2.0.1...v2.0.2)

**Closed issues:**

- Mocking a constructor function with no prototypes does not correctly mock static methods [\#208](https://github.com/testdouble/testdouble.js/issues/208)
- Test td.function\(\) after other td fuction\(\) [\#202](https://github.com/testdouble/testdouble.js/issues/202)
- How do I stub a function that being promisify'd by bluebird? [\#200](https://github.com/testdouble/testdouble.js/issues/200)

**Merged pull requests:**

- Preserve function context when calling thenDo [\#209](https://github.com/testdouble/testdouble.js/pull/209) ([connor4312](https://github.com/connor4312))
- Decaffeinate [\#206](https://github.com/testdouble/testdouble.js/pull/206) ([searls](https://github.com/searls))

## [v2.0.1](https://github.com/testdouble/testdouble.js/tree/v2.0.1) (2017-03-13)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v2.0.0...v2.0.1)

## [v2.0.0](https://github.com/testdouble/testdouble.js/tree/v2.0.0) (2017-03-13)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.11.2...v2.0.0)

**Closed issues:**

- How can I write a test for such situation? [\#199](https://github.com/testdouble/testdouble.js/issues/199)
- contains not working against IIFE objects [\#192](https://github.com/testdouble/testdouble.js/issues/192)
- td.verify not returning true when true [\#191](https://github.com/testdouble/testdouble.js/issues/191)
- Typing definition for td.object doesn't support constructors with arguments [\#184](https://github.com/testdouble/testdouble.js/issues/184)
- Replacing methods on `window.location` [\#183](https://github.com/testdouble/testdouble.js/issues/183)
- stub also verified warning when using ignoreExtraArgs [\#181](https://github.com/testdouble/testdouble.js/issues/181)
- \[BREAKING\] Return constructor for `td.replace\(\)` [\#166](https://github.com/testdouble/testdouble.js/issues/166)
- Allow matchers inside objects [\#160](https://github.com/testdouble/testdouble.js/issues/160)
- Support invoking callbacks with arbitrary timing [\#106](https://github.com/testdouble/testdouble.js/issues/106)

**Merged pull requests:**

- Async callbacks [\#205](https://github.com/testdouble/testdouble.js/pull/205) ([searls](https://github.com/searls))
- Create test double functions and copy/fake their properties [\#204](https://github.com/testdouble/testdouble.js/pull/204) ([searls](https://github.com/searls))
- Support deep matchers [\#203](https://github.com/testdouble/testdouble.js/pull/203) ([searls](https://github.com/searls))
- introduce td.constructor\(\) as top-level API sibling to td.object\(\) & td.function\(\) [\#201](https://github.com/testdouble/testdouble.js/pull/201) ([searls](https://github.com/searls))
- Allow Babel compilation [\#197](https://github.com/testdouble/testdouble.js/pull/197) ([searls](https://github.com/searls))
- Improves warning when verifying a stub [\#196](https://github.com/testdouble/testdouble.js/pull/196) ([samjonester](https://github.com/samjonester))
- Yarn [\#195](https://github.com/testdouble/testdouble.js/pull/195) ([searls](https://github.com/searls))
- Creates Better Verification Message [\#194](https://github.com/testdouble/testdouble.js/pull/194) ([samjonester](https://github.com/samjonester))
- Replace constructors with constructors [\#193](https://github.com/testdouble/testdouble.js/pull/193) ([searls](https://github.com/searls))

## [v1.11.2](https://github.com/testdouble/testdouble.js/tree/v1.11.2) (2017-02-28)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.11.1...v1.11.2)

**Closed issues:**

- Stubbing promises with thenResolve does not actually provide for anything in the callback [\#189](https://github.com/testdouble/testdouble.js/issues/189)
- sinon.sandbox analog? [\#188](https://github.com/testdouble/testdouble.js/issues/188)
- Shortcut for new stub returning args [\#187](https://github.com/testdouble/testdouble.js/issues/187)
-  Can't find variable: Proxy [\#186](https://github.com/testdouble/testdouble.js/issues/186)

**Merged pull requests:**

- Improve the error message when using Proxy incorrectly. [\#190](https://github.com/testdouble/testdouble.js/pull/190) ([Schoonology](https://github.com/Schoonology))

## [v1.11.1](https://github.com/testdouble/testdouble.js/tree/v1.11.1) (2017-01-27)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.11.0...v1.11.1)

**Closed issues:**

- Is it possible to `thenReturn` the receiver? [\#182](https://github.com/testdouble/testdouble.js/issues/182)
- Multiple stubbings with argThat causes unexpected behavior [\#180](https://github.com/testdouble/testdouble.js/issues/180)

**Merged pull requests:**

- Update type definition [\#185](https://github.com/testdouble/testdouble.js/pull/185) ([caseyhoward](https://github.com/caseyhoward))

## [v1.11.0](https://github.com/testdouble/testdouble.js/tree/v1.11.0) (2017-01-17)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.10.2...v1.11.0)

**Closed issues:**

- Having something like "verifyNoFurtherInvocations\(mock\)" would be nice \(feature request\) [\#176](https://github.com/testdouble/testdouble.js/issues/176)

**Merged pull requests:**

- feat: contains allows for regexps against strings [\#178](https://github.com/testdouble/testdouble.js/pull/178) ([JaKXz](https://github.com/JaKXz))

## [v1.10.2](https://github.com/testdouble/testdouble.js/tree/v1.10.2) (2016-12-31)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.10.1...v1.10.2)

**Closed issues:**

- Possible pollution issue \(2 tests work individually, but fails when run together\) [\#171](https://github.com/testdouble/testdouble.js/issues/171)
- td.verify and td.when redundency warning [\#170](https://github.com/testdouble/testdouble.js/issues/170)
- Does not work with jest [\#128](https://github.com/testdouble/testdouble.js/issues/128)

**Merged pull requests:**

- Captor typings [\#174](https://github.com/testdouble/testdouble.js/pull/174) ([danielmoore](https://github.com/danielmoore))
- Align TS replace\(\) signuatrue return with implementaiton [\#173](https://github.com/testdouble/testdouble.js/pull/173) ([danielmoore](https://github.com/danielmoore))

## [v1.10.1](https://github.com/testdouble/testdouble.js/tree/v1.10.1) (2016-12-20)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.10.0...v1.10.1)

**Implemented enhancements:**

- Make the `constructor` property of td.replaced\(\) instantiable types useful [\#121](https://github.com/testdouble/testdouble.js/issues/121)
- Improve output for `times` verification failures [\#85](https://github.com/testdouble/testdouble.js/issues/85)
- Allow argument matchers to enhance failure messages [\#59](https://github.com/testdouble/testdouble.js/issues/59)
- td.constructor\(\) feature for creating fake constructors [\#54](https://github.com/testdouble/testdouble.js/issues/54)

**Closed issues:**

- typings for typescript [\#167](https://github.com/testdouble/testdouble.js/issues/167)
- A little typo in Getting Started documentation [\#165](https://github.com/testdouble/testdouble.js/issues/165)
- Unable to stub static method on ES6 classes [\#164](https://github.com/testdouble/testdouble.js/issues/164)
- transcribe unusual spending kata from ES5 to ES6/babel  [\#163](https://github.com/testdouble/testdouble.js/issues/163)
- Classes with overridden methods not doubling properly since 1.10.0 [\#159](https://github.com/testdouble/testdouble.js/issues/159)
- `td.replace\(\)` doesn't work with `import`? [\#147](https://github.com/testdouble/testdouble.js/issues/147)
- Support multiple capture invocations [\#139](https://github.com/testdouble/testdouble.js/issues/139)
- Constructor replacements will fail instanceof checks [\#107](https://github.com/testdouble/testdouble.js/issues/107)

**Merged pull requests:**

- Typings for typescript [\#169](https://github.com/testdouble/testdouble.js/pull/169) ([mkusher](https://github.com/mkusher))

## [v1.10.0](https://github.com/testdouble/testdouble.js/tree/v1.10.0) (2016-12-11)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.9.1...v1.10.0)

**Implemented enhancements:**

- td.replace doesn't properly detect ES6 classes [\#119](https://github.com/testdouble/testdouble.js/issues/119)

**Closed issues:**

- Mocking a Class [\#157](https://github.com/testdouble/testdouble.js/issues/157)
- Matcher for a specific position [\#156](https://github.com/testdouble/testdouble.js/issues/156)

**Merged pull requests:**

- Sort out replacement of especially 6+ Classes [\#158](https://github.com/testdouble/testdouble.js/pull/158) ([searls](https://github.com/searls))

## [v1.9.1](https://github.com/testdouble/testdouble.js/tree/v1.9.1) (2016-12-03)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.9.0...v1.9.1)

**Implemented enhancements:**

- td.replace for functions that have additional function properties [\#99](https://github.com/testdouble/testdouble.js/issues/99)

**Closed issues:**

- Is testdouble.js not compatible with PhantomJS? [\#154](https://github.com/testdouble/testdouble.js/issues/154)
- Model instance creation assistance [\#149](https://github.com/testdouble/testdouble.js/issues/149)
- Excessive warn "was both stubbed and verified" [\#148](https://github.com/testdouble/testdouble.js/issues/148)

**Merged pull requests:**

- Add failing test for resetting replaced modules. [\#215](https://github.com/testdouble/testdouble.js/pull/215) ([Schoonology](https://github.com/Schoonology))
- typo [\#152](https://github.com/testdouble/testdouble.js/pull/152) ([ghedamat](https://github.com/ghedamat))

## [v1.9.0](https://github.com/testdouble/testdouble.js/tree/v1.9.0) (2016-10-25)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.8.0...v1.9.0)

**Implemented enhancements:**

- Note when `ignoreExtraArgs` is used for a failed verification [\#60](https://github.com/testdouble/testdouble.js/issues/60)

**Closed issues:**

- td.replace multiple property names at once [\#146](https://github.com/testdouble/testdouble.js/issues/146)
- Consider ignoreExtraArgs method instead of parameter [\#143](https://github.com/testdouble/testdouble.js/issues/143)

**Merged pull requests:**

- Gives better hint when verification fails while ignoring extra args [\#150](https://github.com/testdouble/testdouble.js/pull/150) ([samjonester](https://github.com/samjonester))

## [v1.8.0](https://github.com/testdouble/testdouble.js/tree/v1.8.0) (2016-10-12)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.7.0...v1.8.0)

**Closed issues:**

- Feature request: Partial object matchers [\#141](https://github.com/testdouble/testdouble.js/issues/141)
- Drop CoffeeScript [\#140](https://github.com/testdouble/testdouble.js/issues/140)
- Question with verifications [\#138](https://github.com/testdouble/testdouble.js/issues/138)
- td.reset\(\) it´s working has expected? [\#133](https://github.com/testdouble/testdouble.js/issues/133)

**Merged pull requests:**

- Docs for multiple captor values.  [\#145](https://github.com/testdouble/testdouble.js/pull/145) ([marchaos](https://github.com/marchaos))
- Allow for multiple captor invocations [\#144](https://github.com/testdouble/testdouble.js/pull/144) ([marchaos](https://github.com/marchaos))
- Remove warning of implementations of ES2015 proxy [\#136](https://github.com/testdouble/testdouble.js/pull/136) ([mgryszko](https://github.com/mgryszko))
- Fix shorthand notation for stubbing [\#135](https://github.com/testdouble/testdouble.js/pull/135) ([mgryszko](https://github.com/mgryszko))

## [v1.7.0](https://github.com/testdouble/testdouble.js/tree/v1.7.0) (2016-09-18)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.6.2...v1.7.0)

**Merged pull requests:**

- Upgrade to lodash 4.15.0 [\#132](https://github.com/testdouble/testdouble.js/pull/132) ([searls](https://github.com/searls))

## [v1.6.2](https://github.com/testdouble/testdouble.js/tree/v1.6.2) (2016-09-18)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.6.1...v1.6.2)

**Closed issues:**

- Add support for concurrent test runners \(ava\)? [\#131](https://github.com/testdouble/testdouble.js/issues/131)
- Async use of verify results in timeout [\#129](https://github.com/testdouble/testdouble.js/issues/129)

**Merged pull requests:**

- Should methods on super types be stubbed in td.object? [\#130](https://github.com/testdouble/testdouble.js/pull/130) ([paultyng](https://github.com/paultyng))

## [v1.6.1](https://github.com/testdouble/testdouble.js/tree/v1.6.1) (2016-08-31)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.6.0...v1.6.1)

**Closed issues:**

- td.explain should indicate thenCallback / thenResolve / thenReject from thenReturn [\#126](https://github.com/testdouble/testdouble.js/issues/126)
- td.when and td.verify warning [\#125](https://github.com/testdouble/testdouble.js/issues/125)
- td.callback, when given a td.object, raises a TypeError [\#124](https://github.com/testdouble/testdouble.js/issues/124)
- not matcher and calling function multiple times [\#122](https://github.com/testdouble/testdouble.js/issues/122)
- Verify of a specific call when multiple calls happen [\#120](https://github.com/testdouble/testdouble.js/issues/120)

**Merged pull requests:**

- explain plan better in stubbing description [\#127](https://github.com/testdouble/testdouble.js/pull/127) ([Moeriki](https://github.com/Moeriki))
- Fix typo in plugin name [\#123](https://github.com/testdouble/testdouble.js/pull/123) ([hanneskaeufler](https://github.com/hanneskaeufler))

## [v1.6.0](https://github.com/testdouble/testdouble.js/tree/v1.6.0) (2016-07-14)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.5.0...v1.6.0)

**Closed issues:**

- Nested stubbing doesn't work [\#117](https://github.com/testdouble/testdouble.js/issues/117)

**Merged pull requests:**

- Allow nested stubbing configuration [\#118](https://github.com/testdouble/testdouble.js/pull/118) ([searls](https://github.com/searls))

## [v1.5.0](https://github.com/testdouble/testdouble.js/tree/v1.5.0) (2016-07-13)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.4.3...v1.5.0)

**Closed issues:**

- support promises resolve/reject [\#46](https://github.com/testdouble/testdouble.js/issues/46)

**Merged pull requests:**

- Use stringify-object now that my change is merged [\#116](https://github.com/testdouble/testdouble.js/pull/116) ([searls](https://github.com/searls))
- Promise stubbing sugar [\#115](https://github.com/testdouble/testdouble.js/pull/115) ([searls](https://github.com/searls))

## [v1.4.3](https://github.com/testdouble/testdouble.js/tree/v1.4.3) (2016-06-22)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.4.2...v1.4.3)

**Closed issues:**

- Build with Travis on Node 6.x [\#114](https://github.com/testdouble/testdouble.js/issues/114)
- Wrong test double name for proxies [\#112](https://github.com/testdouble/testdouble.js/issues/112)
- Improve error output message [\#111](https://github.com/testdouble/testdouble.js/issues/111)
- Flexible parameters [\#110](https://github.com/testdouble/testdouble.js/issues/110)
- How can I install and use this in an ember/ember-cli project? [\#105](https://github.com/testdouble/testdouble.js/issues/105)
- td.replace breaks subsequent require calls [\#103](https://github.com/testdouble/testdouble.js/issues/103)

**Merged pull requests:**

- Generate test double name for a Proxy test double [\#113](https://github.com/testdouble/testdouble.js/pull/113) ([mgryszko](https://github.com/mgryszko))

## [v1.4.2](https://github.com/testdouble/testdouble.js/tree/v1.4.2) (2016-04-29)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.4.1...v1.4.2)

**Closed issues:**

- matchers.contains\(number\) support [\#102](https://github.com/testdouble/testdouble.js/issues/102)

**Merged pull requests:**

- Fix contains\(\) behavior for arrays [\#104](https://github.com/testdouble/testdouble.js/pull/104) ([searls](https://github.com/searls))
- Add testdouble-timers as plugin to docs [\#101](https://github.com/testdouble/testdouble.js/pull/101) ([kuy](https://github.com/kuy))

## [v1.4.1](https://github.com/testdouble/testdouble.js/tree/v1.4.1) (2016-04-05)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.4.0...v1.4.1)

**Closed issues:**

- Changelog [\#97](https://github.com/testdouble/testdouble.js/issues/97)

**Merged pull requests:**

- Generate a changelog whenever we pubish [\#98](https://github.com/testdouble/testdouble.js/pull/98) ([searls](https://github.com/searls))

## [v1.4.0](https://github.com/testdouble/testdouble.js/tree/v1.4.0) (2016-04-03)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.3.1...v1.4.0)

**Closed issues:**

- Reserved word [\#82](https://github.com/testdouble/testdouble.js/issues/82)
- Warn when users verify an invocation they also stubbed [\#76](https://github.com/testdouble/testdouble.js/issues/76)
- Feature request: captors without verify [\#65](https://github.com/testdouble/testdouble.js/issues/65)

**Merged pull requests:**

- Warn verifications of exact stubbings [\#96](https://github.com/testdouble/testdouble.js/pull/96) ([searls](https://github.com/searls))
- Fixes \#82 [\#95](https://github.com/testdouble/testdouble.js/pull/95) ([searls](https://github.com/searls))

## [v1.3.1](https://github.com/testdouble/testdouble.js/tree/v1.3.1) (2016-04-03)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.3.0...v1.3.1)

**Closed issues:**

- Throws in node 0.10 [\#94](https://github.com/testdouble/testdouble.js/issues/94)
- td.replace\(\) property replacement warning & failure states [\#92](https://github.com/testdouble/testdouble.js/issues/92)
- give users a way to squelch individual warnings [\#90](https://github.com/testdouble/testdouble.js/issues/90)

## [v1.3.0](https://github.com/testdouble/testdouble.js/tree/v1.3.0) (2016-04-03)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.2.0...v1.3.0)

**Closed issues:**

- What's the best way to use testdouble.js with tape? [\#93](https://github.com/testdouble/testdouble.js/issues/93)
- help [\#91](https://github.com/testdouble/testdouble.js/issues/91)
- td.replace\(\) fails for method on prototype [\#86](https://github.com/testdouble/testdouble.js/issues/86)

**Merged pull requests:**

- README: Replace GIFs with code blocks [\#88](https://github.com/testdouble/testdouble.js/pull/88) ([Turbo87](https://github.com/Turbo87))
- replace: Use object\[property\] to check if property exists [\#87](https://github.com/testdouble/testdouble.js/pull/87) ([Turbo87](https://github.com/Turbo87))

## [v1.2.0](https://github.com/testdouble/testdouble.js/tree/v1.2.0) (2016-03-20)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.1.3...v1.2.0)

**Closed issues:**

- Print version in browserify build [\#23](https://github.com/testdouble/testdouble.js/issues/23)

**Merged pull requests:**

- Stringify objects better [\#84](https://github.com/testdouble/testdouble.js/pull/84) ([searls](https://github.com/searls))
- doc: thenDo and thenThrow are no longer unimplemented. [\#83](https://github.com/testdouble/testdouble.js/pull/83) ([verdammelt](https://github.com/verdammelt))
- Refactor time [\#81](https://github.com/testdouble/testdouble.js/pull/81) ([searls](https://github.com/searls))

## [v1.1.3](https://github.com/testdouble/testdouble.js/tree/v1.1.3) (2016-03-16)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.1.1...v1.1.3)

**Closed issues:**

- Quibble in the browser [\#77](https://github.com/testdouble/testdouble.js/issues/77)

**Merged pull requests:**

- Improve support for webpack users [\#80](https://github.com/testdouble/testdouble.js/pull/80) ([searls](https://github.com/searls))

## [v1.1.1](https://github.com/testdouble/testdouble.js/tree/v1.1.1) (2016-03-15)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.1.0...v1.1.1)

**Merged pull requests:**

- Add webpack specific metadata to package.json [\#79](https://github.com/testdouble/testdouble.js/pull/79) ([davemo](https://github.com/davemo))

## [v1.1.0](https://github.com/testdouble/testdouble.js/tree/v1.1.0) (2016-03-11)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v1.0.0...v1.1.0)

**Closed issues:**

- Add a property-namespacing-like replace strategy for browsers. [\#55](https://github.com/testdouble/testdouble.js/issues/55)

**Merged pull requests:**

- td.replace support for object properties \(incl. browsers\) [\#75](https://github.com/testdouble/testdouble.js/pull/75) ([searls](https://github.com/searls))
- td.explain tells you if you passed it a test double [\#74](https://github.com/testdouble/testdouble.js/pull/74) ([searls](https://github.com/searls))

## [v1.0.0](https://github.com/testdouble/testdouble.js/tree/v1.0.0) (2016-03-10)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v0.10.0...v1.0.0)

**Closed issues:**

- Document `thenDo` and `thenThrow` [\#64](https://github.com/testdouble/testdouble.js/issues/64)

**Merged pull requests:**

- Remove deprecated window.testdouble for 1.0.0 [\#73](https://github.com/testdouble/testdouble.js/pull/73) ([searls](https://github.com/searls))
- add some docs [\#72](https://github.com/testdouble/testdouble.js/pull/72) ([searls](https://github.com/searls))

## [v0.10.0](https://github.com/testdouble/testdouble.js/tree/v0.10.0) (2016-03-09)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v0.9.0...v0.10.0)

**Merged pull requests:**

- Change window.testdouble to window.td  [\#71](https://github.com/testdouble/testdouble.js/pull/71) ([searls](https://github.com/searls))

## [v0.9.0](https://github.com/testdouble/testdouble.js/tree/v0.9.0) (2016-03-09)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v0.8.0...v0.9.0)

**Implemented enhancements:**

- Stubbing callbacks [\#66](https://github.com/testdouble/testdouble.js/issues/66)

**Closed issues:**

- Getting testdouble.js to play nicely with Jasmine expectations? [\#41](https://github.com/testdouble/testdouble.js/issues/41)

**Merged pull requests:**

- Implement callback stubbing APIs [\#70](https://github.com/testdouble/testdouble.js/pull/70) ([searls](https://github.com/searls))
- fix typo [\#69](https://github.com/testdouble/testdouble.js/pull/69) ([jzinn](https://github.com/jzinn))
- Reference the completed testdouble-jasmine module [\#67](https://github.com/testdouble/testdouble.js/pull/67) ([BrianGenisio](https://github.com/BrianGenisio))

## [v0.8.0](https://github.com/testdouble/testdouble.js/tree/v0.8.0) (2016-02-06)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v0.7.3...v0.8.0)

**Closed issues:**

- Add `thenDo` [\#8](https://github.com/testdouble/testdouble.js/issues/8)
- Add `thenThrow` [\#7](https://github.com/testdouble/testdouble.js/issues/7)

## [v0.7.3](https://github.com/testdouble/testdouble.js/tree/v0.7.3) (2015-12-07)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v0.7.2...v0.7.3)

**Implemented enhancements:**

- td.matchers.contains does not work on sparse object trees [\#58](https://github.com/testdouble/testdouble.js/issues/58)

**Fixed bugs:**

- td.matchers.contains does not work on sparse object trees [\#58](https://github.com/testdouble/testdouble.js/issues/58)

**Merged pull requests:**

- Add headerify [\#62](https://github.com/testdouble/testdouble.js/pull/62) ([searls](https://github.com/searls))
- Rename src and scripts [\#61](https://github.com/testdouble/testdouble.js/pull/61) ([searls](https://github.com/searls))
- Better docs [\#49](https://github.com/testdouble/testdouble.js/pull/49) ([searls](https://github.com/searls))

## [v0.7.2](https://github.com/testdouble/testdouble.js/tree/v0.7.2) (2015-11-25)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v0.7.1...v0.7.2)

**Fixed bugs:**

- td.matchers.contains blows up on sparse matches [\#56](https://github.com/testdouble/testdouble.js/issues/56)

**Merged pull requests:**

- fixes \#56 [\#57](https://github.com/testdouble/testdouble.js/pull/57) ([searls](https://github.com/searls))
- Swap .replace with browser-specific function [\#52](https://github.com/testdouble/testdouble.js/pull/52) ([jasonkarns](https://github.com/jasonkarns))
- Use svg build badge [\#50](https://github.com/testdouble/testdouble.js/pull/50) ([hanneskaeufler](https://github.com/hanneskaeufler))

## [v0.7.1](https://github.com/testdouble/testdouble.js/tree/v0.7.1) (2015-11-12)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v0.7.0...v0.7.1)

## [v0.7.0](https://github.com/testdouble/testdouble.js/tree/v0.7.0) (2015-11-12)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v0.6.0...v0.7.0)

**Closed issues:**

- Is there a way to reset the state of a double? [\#43](https://github.com/testdouble/testdouble.js/issues/43)

**Merged pull requests:**

- Update README.md [\#45](https://github.com/testdouble/testdouble.js/pull/45) ([andrewvida](https://github.com/andrewvida))
- Adding reset\(\) to the Readme.md [\#44](https://github.com/testdouble/testdouble.js/pull/44) ([BrianGenisio](https://github.com/BrianGenisio))

## [v0.6.0](https://github.com/testdouble/testdouble.js/tree/v0.6.0) (2015-10-27)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v0.5.0...v0.6.0)

**Closed issues:**

- add ES2015 Proxy support  [\#39](https://github.com/testdouble/testdouble.js/issues/39)

**Merged pull requests:**

- Implement ES2015 proxy doubles [\#42](https://github.com/testdouble/testdouble.js/pull/42) ([searls](https://github.com/searls))

## [v0.5.0](https://github.com/testdouble/testdouble.js/tree/v0.5.0) (2015-10-25)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v0.4.0...v0.5.0)

**Closed issues:**

- Add verify times\(\) [\#5](https://github.com/testdouble/testdouble.js/issues/5)

**Merged pull requests:**

- Add a `times` option [\#40](https://github.com/testdouble/testdouble.js/pull/40) ([searls](https://github.com/searls))

## [v0.4.0](https://github.com/testdouble/testdouble.js/tree/v0.4.0) (2015-10-24)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v0.3.1...v0.4.0)

**Closed issues:**

- Allow when & verify to disregard arity [\#36](https://github.com/testdouble/testdouble.js/issues/36)
- implement argument captors [\#35](https://github.com/testdouble/testdouble.js/issues/35)

**Merged pull requests:**

- Add an option to ignore additional args [\#38](https://github.com/testdouble/testdouble.js/pull/38) ([searls](https://github.com/searls))
- Arg captors [\#37](https://github.com/testdouble/testdouble.js/pull/37) ([searls](https://github.com/searls))

## [v0.3.1](https://github.com/testdouble/testdouble.js/tree/v0.3.1) (2015-10-24)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v0.3.0...v0.3.1)

**Fixed bugs:**

- contains\(\) matcher doesn't seem to work on arrays [\#31](https://github.com/testdouble/testdouble.js/issues/31)

**Closed issues:**

- verify does not throw exception when too many arguments are passed [\#33](https://github.com/testdouble/testdouble.js/issues/33)
- Building CoffeeScript at runtime is slow. [\#29](https://github.com/testdouble/testdouble.js/issues/29)

**Merged pull requests:**

- Start checking arity on arg comparisons [\#34](https://github.com/testdouble/testdouble.js/pull/34) ([searls](https://github.com/searls))
- Compile coffeescript [\#30](https://github.com/testdouble/testdouble.js/pull/30) ([jasonkarns](https://github.com/jasonkarns))

## [v0.3.0](https://github.com/testdouble/testdouble.js/tree/v0.3.0) (2015-10-21)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v0.2.0...v0.3.0)

**Closed issues:**

- When stringifying args, use a testdouble's name if it has one [\#21](https://github.com/testdouble/testdouble.js/issues/21)

**Merged pull requests:**

- Clean up window/global management [\#28](https://github.com/testdouble/testdouble.js/pull/28) ([jasonkarns](https://github.com/jasonkarns))
- clean up package scripts \(primarily version\) [\#27](https://github.com/testdouble/testdouble.js/pull/27) ([jasonkarns](https://github.com/jasonkarns))
- don't watch generated files [\#26](https://github.com/testdouble/testdouble.js/pull/26) ([jasonkarns](https://github.com/jasonkarns))
- Export `version` property on base object [\#25](https://github.com/testdouble/testdouble.js/pull/25) ([jasonkarns](https://github.com/jasonkarns))
- Fixes \#21 [\#24](https://github.com/testdouble/testdouble.js/pull/24) ([searls](https://github.com/searls))

## [v0.2.0](https://github.com/testdouble/testdouble.js/tree/v0.2.0) (2015-09-13)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v0.1.0...v0.2.0)

**Closed issues:**

- Add a build task that distributes a web version / bower.json / etc [\#10](https://github.com/testdouble/testdouble.js/issues/10)

**Merged pull requests:**

- Browserify testing [\#22](https://github.com/testdouble/testdouble.js/pull/22) ([searls](https://github.com/searls))
- add some more syntax highlighting to README [\#20](https://github.com/testdouble/testdouble.js/pull/20) ([hanneskaeufler](https://github.com/hanneskaeufler))
- Configure Testem [\#19](https://github.com/testdouble/testdouble.js/pull/19) ([jasonkarns](https://github.com/jasonkarns))
- Browserify [\#13](https://github.com/testdouble/testdouble.js/pull/13) ([jasonkarns](https://github.com/jasonkarns))

## [v0.1.0](https://github.com/testdouble/testdouble.js/tree/v0.1.0) (2015-09-09)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/v0.0.5...v0.1.0)

**Closed issues:**

- name a test double with `create\("name"\)` [\#15](https://github.com/testdouble/testdouble.js/issues/15)
- Implement default matchers [\#9](https://github.com/testdouble/testdouble.js/issues/9)
- Add sequential stubbing [\#6](https://github.com/testdouble/testdouble.js/issues/6)
- Implement Prototype for create\(\) [\#2](https://github.com/testdouble/testdouble.js/issues/2)
- Implement argument matchers [\#1](https://github.com/testdouble/testdouble.js/issues/1)

**Merged pull requests:**

- Test prototype-based create\(\) [\#18](https://github.com/testdouble/testdouble.js/pull/18) ([searls](https://github.com/searls))
- Allow naming test doubles for better output [\#17](https://github.com/testdouble/testdouble.js/pull/17) ([searls](https://github.com/searls))
- sequential stubbing [\#16](https://github.com/testdouble/testdouble.js/pull/16) ([searls](https://github.com/searls))
- add more matchers [\#14](https://github.com/testdouble/testdouble.js/pull/14) ([searls](https://github.com/searls))

## [v0.0.5](https://github.com/testdouble/testdouble.js/tree/v0.0.5) (2015-09-08)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/0.0.4...v0.0.5)

**Closed issues:**

- Add `verify\(\)` [\#4](https://github.com/testdouble/testdouble.js/issues/4)

## [0.0.4](https://github.com/testdouble/testdouble.js/tree/0.0.4) (2015-09-08)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/0.0.3...0.0.4)

## [0.0.3](https://github.com/testdouble/testdouble.js/tree/0.0.3) (2015-09-08)
[Full Changelog](https://github.com/testdouble/testdouble.js/compare/0.0.2...0.0.3)

**Closed issues:**

- Add a `require\('testdouble'\).explain` function [\#12](https://github.com/testdouble/testdouble.js/issues/12)
- Ensure last stubbing wins [\#11](https://github.com/testdouble/testdouble.js/issues/11)

## [0.0.2](https://github.com/testdouble/testdouble.js/tree/0.0.2) (2015-09-07)

\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*


text:
#include <string.h>
#include "iotx_utils_internal.h"
#include "utils_md5.h"
#include "utils_sha1.h"
#include "utils_sha256.h"
#include "utils_hmac.h"
#include "utils_base64.h"

#ifdef UTILS_MD5
void utils_hmac_md5(const char *msg, int msg_len, char *digest, const char *key, int key_len)
{
    if ((NULL == msg) || (NULL == digest) || (NULL == key)) {
        utils_err("parameter is Null,failed!");
        return;
    }

    if (key_len > KEY_IOPAD_SIZE) {
        utils_err("key_len > size(%d) of array", KEY_IOPAD_SIZE);
        return;
    }

    iot_md5_context context;
    unsigned char k_ipad[KEY_IOPAD_SIZE];    /* inner padding - key XORd with ipad  */
    unsigned char k_opad[KEY_IOPAD_SIZE];    /* outer padding - key XORd with opad */
    unsigned char out[MD5_DIGEST_SIZE];
    int i;

    /* start out by storing key in pads */
    memset(k_ipad, 0, sizeof(k_ipad));
    memset(k_opad, 0, sizeof(k_opad));
    memcpy(k_ipad, key, key_len);
    memcpy(k_opad, key, key_len);

    /* XOR key with ipad and opad values */
    for (i = 0; i < KEY_IOPAD_SIZE; i++) {
        k_ipad[i] ^= 0x36;
        k_opad[i] ^= 0x5c;
    }

    /* perform inner MD5 */
    utils_md5_init(&context);                                      /* init context for 1st pass */
    utils_md5_starts(&context);                                    /* setup context for 1st pass */
    utils_md5_update(&context, k_ipad, KEY_IOPAD_SIZE);            /* start with inner pad */
    utils_md5_update(&context, (unsigned char *) msg, msg_len);    /* then text of datagram */
    utils_md5_finish(&context, out);                               /* finish up 1st pass */

    /* perform outer MD5 */
    utils_md5_init(&context);                              /* init context for 2nd pass */
    utils_md5_starts(&context);                            /* setup context for 2nd pass */
    utils_md5_update(&context, k_opad, KEY_IOPAD_SIZE);    /* start with outer pad */
    utils_md5_update(&context, out, MD5_DIGEST_SIZE);      /* then results of 1st hash */
    utils_md5_finish(&context, out);                       /* finish up 2nd pass */

    for (i = 0; i < MD5_DIGEST_SIZE; ++i) {
        digest[i * 2] = utils_hb2hex(out[i] >> 4);
        digest[i * 2 + 1] = utils_hb2hex(out[i]);
    }
}
#endif  /* #ifdef UTILS_MD5 */

#ifdef UTILS_SHA256
void utils_hmac_sha256(const char *msg, int msg_len, char *digest, const char *key, int key_len)
{
    if ((NULL == msg) || (NULL == digest) || (NULL == key)) {
        utils_err("parameter is Null,failed!");
        return;
    }

    if (key_len > KEY_IOPAD_SIZE) {
        utils_err("key_len > size(%d) of array", KEY_IOPAD_SIZE);
        return;
    }

    iot_sha256_context context;
    unsigned char k_ipad[KEY_IOPAD_SIZE];    /* inner padding - key XORd with ipad  */
    unsigned char k_opad[KEY_IOPAD_SIZE];    /* outer padding - key XORd with opad */
    unsigned char out[SHA256_DIGEST_SIZE];
    int i;

    /* start out by storing key in pads */
    memset(k_ipad, 0, sizeof(k_ipad));
    memset(k_opad, 0, sizeof(k_opad));
    memcpy(k_ipad, key, key_len);
    memcpy(k_opad, key, key_len);

    /* XOR key with ipad and opad values */
    for (i = 0; i < KEY_IOPAD_SIZE; i++) {
        k_ipad[i] ^= 0x36;
        k_opad[i] ^= 0x5c;
    }

    /* perform inner SHA */
    utils_sha256_init(&context);                                      /* init context for 1st pass */
    utils_sha256_starts(&context);                                    /* setup context for 1st pass */
    utils_sha256_update(&context, k_ipad, KEY_IOPAD_SIZE);            /* start with inner pad */
    utils_sha256_update(&context, (unsigned char *) msg, msg_len);    /* then text of datagram */
    utils_sha256_finish(&context, out);                               /* finish up 1st pass */

    /* perform outer SHA */
    utils_sha256_init(&context);                              /* init context for 2nd pass */
    utils_sha256_starts(&context);                            /* setup context for 2nd pass */
    utils_sha256_update(&context, k_opad, KEY_IOPAD_SIZE);    /* start with outer pad */
    utils_sha256_update(&context, out, SHA256_DIGEST_SIZE);     /* then results of 1st hash */
    utils_sha256_finish(&context, out);                       /* finish up 2nd pass */

    for (i = 0; i < SHA256_DIGEST_SIZE; ++i) {
        digest[i * 2] = utils_hb2hex(out[i] >> 4);
        digest[i * 2 + 1] = utils_hb2hex(out[i]);
    }
}
#endif /* #ifdef UTILS_SHA256 */

#ifdef UTILS_SHA1
void utils_hmac_sha1(const char *msg, int msg_len, char *digest, const char *key, int key_len)
{
    if ((NULL == msg) || (NULL == digest) || (NULL == key)) {
        utils_err("parameter is Null,failed!");
        return;
    }

    if (key_len > KEY_IOPAD_SIZE) {
        utils_err("key_len > size(%d) of array", KEY_IOPAD_SIZE);
        return;
    }

    iot_sha1_context context;
    unsigned char k_ipad[KEY_IOPAD_SIZE];    /* inner padding - key XORd with ipad  */
    unsigned char k_opad[KEY_IOPAD_SIZE];    /* outer padding - key XORd with opad */
    unsigned char out[SHA1_DIGEST_SIZE];
    int i;

    /* start out by storing key in pads */
    memset(k_ipad, 0, sizeof(k_ipad));
    memset(k_opad, 0, sizeof(k_opad));
    memcpy(k_ipad, key, key_len);
    memcpy(k_opad, key, key_len);

    /* XOR key with ipad and opad values */
    for (i = 0; i < KEY_IOPAD_SIZE; i++) {
        k_ipad[i] ^= 0x36;
        k_opad[i] ^= 0x5c;
    }

    /* perform inner SHA */
    utils_sha1_init(&context);                                      /* init context for 1st pass */
    utils_sha1_starts(&context);                                    /* setup context for 1st pass */
    utils_sha1_update(&context, k_ipad, KEY_IOPAD_SIZE);            /* start with inner pad */
    utils_sha1_update(&context, (unsigned char *) msg, msg_len);    /* then text of datagram */
    utils_sha1_finish(&context, out);                               /* finish up 1st pass */

    /* perform outer SHA */
    utils_sha1_init(&context);                              /* init context for 2nd pass */
    utils_sha1_starts(&context);                            /* setup context for 2nd pass */
    utils_sha1_update(&context, k_opad, KEY_IOPAD_SIZE);    /* start with outer pad */
    utils_sha1_update(&context, out, SHA1_DIGEST_SIZE);     /* then results of 1st hash */
    utils_sha1_finish(&context, out);                       /* finish up 2nd pass */

    for (i = 0; i < SHA1_DIGEST_SIZE; ++i) {
        digest[i * 2] = utils_hb2hex(out[i] >> 4);
        digest[i * 2 + 1] = utils_hb2hex(out[i]);
    }
}

void utils_hmac_sha1_hex(const char *msg, int msg_len, char *digest, const char *key, int key_len)
{
    if ((NULL == msg) || (NULL == digest) || (NULL == key)) {
        utils_err("parameter is Null,failed!");
        return;
    }

    if (key_len > KEY_IOPAD_SIZE) {
        utils_err("key_len > size(%d) of array", KEY_IOPAD_SIZE);
        return;
    }

    iot_sha1_context context;
    unsigned char k_ipad[KEY_IOPAD_SIZE];    /* inner padding - key XORd with ipad  */
    unsigned char k_opad[KEY_IOPAD_SIZE];    /* outer padding - key XORd with opad */
    unsigned char out[SHA1_DIGEST_SIZE];
    int i;

    /* start out by storing key in pads */
    memset(k_ipad, 0, sizeof(k_ipad));
    memset(k_opad, 0, sizeof(k_opad));
    memcpy(k_ipad, key, key_len);
    memcpy(k_opad, key, key_len);

    /* XOR key with ipad and opad values */
    for (i = 0; i < KEY_IOPAD_SIZE; i++) {
        k_ipad[i] ^= 0x36;
        k_opad[i] ^= 0x5c;
    }

    /* perform inner SHA */
    utils_sha1_init(&context);                                      /* init context for 1st pass */
    utils_sha1_starts(&context);                                    /* setup context for 1st pass */
    utils_sha1_update(&context, k_ipad, KEY_IOPAD_SIZE);            /* start with inner pad */
    utils_sha1_update(&context, (unsigned char *) msg, msg_len);    /* then text of datagram */
    utils_sha1_finish(&context, out);                               /* finish up 1st pass */

    /* perform outer SHA */
    utils_sha1_init(&context);                              /* init context for 2nd pass */
    utils_sha1_starts(&context);                            /* setup context for 2nd pass */
    utils_sha1_update(&context, k_opad, KEY_IOPAD_SIZE);    /* start with outer pad */
    utils_sha1_update(&context, out, SHA1_DIGEST_SIZE);     /* then results of 1st hash */
    utils_sha1_finish(&context, out);                       /* finish up 2nd pass */
    memcpy(digest, out, SHA1_DIGEST_SIZE);
}
#endif  /* #ifdef UTILS_SHA1 */


text:
<?php

/* ConnectionWebBundle:Frontend/Mail:tell-a-friend.html.twig */
class __TwigTemplate_e6a75aadbb40d9fcd2b9f57e369622aad4f218258e9e660a9d7c549940e24a9e extends Twig_Template
{
    public function __construct(Twig_Environment $env)
    {
        parent::__construct($env);

        $this->parent = false;

        $this->blocks = array(
        );
    }

    protected function doDisplay(array $context, array $blocks = array())
    {
        // line 1
        echo "

ConnectionRu.com

";
        // line 3
        echo twig_escape_filter($this->env, (isset($context["link"]) ? $context["link"] : $this->getContext($context, "link")), "html", null, true);
        echo "

";
        // line 4
        echo twig_escape_filter($this->env, (isset($context["message"]) ? $context["message"] : $this->getContext($context, "message")), "html", null, true);
        echo "

";
    }

    public function getTemplateName()
    {
        return "ConnectionWebBundle:Frontend/Mail:tell-a-friend.html.twig";
    }

    public function isTraitable()
    {
        return false;
    }

    public function getDebugInfo()
    {
        return array (  27 => 4,  23 => 3,  19 => 1,);
    }
}


text:
package org.apache.uima.internal.util;

import java.util.Collections;
import java.util.List;

/**
 * Data structure used to encapsulate an XML element name (including Namespace URI, local name, and
 * the qname) as well as its attributes and character content.
 */
public class XmlElementNameAndContents {
  public XmlElementNameAndContents(XmlElementName name, String contents) {
    this(name, contents, Collections.<XmlAttribute> emptyList());
  }

  public XmlElementNameAndContents(XmlElementName name, String contents,
          List<XmlAttribute> attributes) {
    this.name = name;
    this.contents = contents;
    this.attributes = attributes;
  }

  final public XmlElementName name;

  /**
   * List of XmlAttribute objects each holding name and value of an attribute.
   */
  final public List<XmlAttribute> attributes;

  final public String contents;
}


text:
class CreateAuditLogs < ActiveRecord::Migration
  def self.up
    create_table :audit_logs do |t|
      t.string :provider_account_name
      t.integer :provider_account_id
      t.string :cluster_name
      t.integer :cluster_id
      t.integer :auditable_id
      t.string :auditable_type
      t.string :auditable_name
      t.string :author_login
      t.integer :author_id
      t.string :summary
      t.text :changes

      t.timestamps
    end
    add_index :audit_logs, :provider_account_name
    add_index :audit_logs, :provider_account_id
    add_index :audit_logs, :cluster_name
    add_index :audit_logs, :cluster_id
    add_index :audit_logs, [ :auditable_id, :auditable_type ]
    add_index :audit_logs, :auditable_name
    add_index :audit_logs, :author_login
    add_index :audit_logs, :author_id
    add_index :audit_logs, :summary
  end

  def self.down
    drop_table :audit_logs
  end
end


text:
use cast;
use ops::Drop;
use ptr::RawPtr;

#[cfg(windows)]               // mingw-w32 doesn't like thread_local things
#[cfg(target_os = "android")] // see #10686
pub use self::native::*;

#[cfg(not(windows), not(target_os = "android"))]
pub use self::compiled::*;

/// Encapsulates a borrowed value. When this value goes out of scope, the
/// pointer is returned.
pub struct Borrowed<T> {
    priv val: *(),
}

#[unsafe_destructor]
impl<T> Drop for Borrowed<T> {
    fn drop(&mut self) {
        unsafe {
            if self.val.is_null() {
                rtabort!("Aiee, returning null borrowed object!");
            }
            let val: ~T = cast::transmute(self.val);
            put::<T>(val);
            rtassert!(exists());
        }
    }
}

impl<T> Borrowed<T> {
    pub fn get<'a>(&'a mut self) -> &'a mut T {
        unsafe {
            let val_ptr: &mut ~T = cast::transmute(&mut self.val);
            let val_ptr: &'a mut T = *val_ptr;
            val_ptr
        }
    }
}

/// Borrow the thread-local value from thread-local storage.
/// While the value is borrowed it is not available in TLS.
///
/// # Safety note
///
/// Does not validate the pointer type.
#[inline]
pub unsafe fn borrow<T>() -> Borrowed<T> {
    let val: *() = cast::transmute(take::<T>());
    Borrowed {
        val: val,
    }
}

/// Compiled implementation of accessing the runtime local pointer. This is
/// implemented using LLVM's thread_local attribute which isn't necessarily
/// working on all platforms. This implementation is faster, however, so we use
/// it wherever possible.
#[cfg(not(windows), not(target_os = "android"))]
pub mod compiled {
    use cast;
    use option::{Option, Some, None};
    use ptr::RawPtr;

    #[cfg(test)]
    pub use realstd::rt::shouldnt_be_public::RT_TLS_PTR;

    #[cfg(not(test))]
    #[thread_local]
    pub static mut RT_TLS_PTR: *mut u8 = 0 as *mut u8;

    pub fn init() {}

    pub unsafe fn cleanup() {}

    // Rationale for all of these functions being inline(never)
    //
    // The #[thread_local] annotation gets propagated all the way through to
    // LLVM, meaning the global is specially treated by LLVM to lower it to an
    // efficient sequence of instructions. This also involves dealing with fun
    // stuff in object files and whatnot. Regardless, it turns out this causes
    // trouble with green threads and lots of optimizations turned on. The
    // following case study was done on linux x86_64, but I would imagine that
    // other platforms are similar.
    //
    // On linux, the instruction sequence for loading the tls pointer global
    // looks like:
    //
    //      mov %fs:0x0, %rax
    //      mov -0x8(%rax), %rbx
    //
    // This code leads me to believe that (%fs:0x0) is a table, and then the
    // table contains the TLS values for the process. Hence, the slot at offset
    // -0x8 is the task TLS pointer. This leads us to the conclusion that this
    // table is the actual thread local part of each thread. The kernel sets up
    // the fs segment selector to point at the right region of memory for each
    // thread.
    //
    // Optimizations lead me to believe that this code is lowered to these
    // instructions in the LLVM codegen passes, because you'll see code like
    // this when everything is optimized:
    //
    //      mov %fs:0x0, %r14
    //      mov -0x8(%r14), %rbx
    //      // do something with %rbx, the rust Task pointer
    //
    //      ... // <- do more things
    //
    //      mov -0x8(%r14), %rbx
    //      // do something else with %rbx
    //
    // Note that the optimization done here is that the first load is not
    // duplicated during the lower instructions. This means that the %fs:0x0
    // memory location is only dereferenced once.
    //
    // Normally, this is actually a good thing! With green threads, however,
    // it's very possible for the code labeled "do more things" to context
    // switch to another thread. If this happens, then we *must* re-load %fs:0x0
    // because it's changed (we're on a different thread). If we don't re-load
    // the table location, then we'll be reading the original thread's TLS
    // values, not our thread's TLS values.
    //
    // Hence, we never inline these functions. By never inlining, we're
    // guaranteed that loading the table is a local decision which is forced to
    // *always* happen.

    /// Give a pointer to thread-local storage.
    ///
    /// # Safety note
    ///
    /// Does not validate the pointer type.
    #[inline(never)] // see comments above
    pub unsafe fn put<T>(sched: ~T) {
        RT_TLS_PTR = cast::transmute(sched)
    }

    /// Take ownership of a pointer from thread-local storage.
    ///
    /// # Safety note
    ///
    /// Does not validate the pointer type.
    #[inline(never)] // see comments above
    pub unsafe fn take<T>() -> ~T {
        let ptr = RT_TLS_PTR;
        rtassert!(!ptr.is_null());
        let ptr: ~T = cast::transmute(ptr);
        // can't use `as`, due to type not matching with `cfg(test)`
        RT_TLS_PTR = cast::transmute(0);
        ptr
    }

    /// Optionally take ownership of a pointer from thread-local storage.
    ///
    /// # Safety note
    ///
    /// Does not validate the pointer type.
    #[inline(never)] // see comments above
    pub unsafe fn try_take<T>() -> Option<~T> {
        let ptr = RT_TLS_PTR;
        if ptr.is_null() {
            None
        } else {
            let ptr: ~T = cast::transmute(ptr);
            // can't use `as`, due to type not matching with `cfg(test)`
            RT_TLS_PTR = cast::transmute(0);
            Some(ptr)
        }
    }

    /// Take ownership of a pointer from thread-local storage.
    ///
    /// # Safety note
    ///
    /// Does not validate the pointer type.
    /// Leaves the old pointer in TLS for speed.
    #[inline(never)] // see comments above
    pub unsafe fn unsafe_take<T>() -> ~T {
        cast::transmute(RT_TLS_PTR)
    }

    /// Check whether there is a thread-local pointer installed.
    #[inline(never)] // see comments above
    pub fn exists() -> bool {
        unsafe {
            RT_TLS_PTR.is_not_null()
        }
    }

    #[inline(never)] // see comments above
    pub unsafe fn unsafe_borrow<T>() -> *mut T {
        if RT_TLS_PTR.is_null() {
            rtabort!("thread-local pointer is null. bogus!");
        }
        RT_TLS_PTR as *mut T
    }

    #[inline(never)] // see comments above
    pub unsafe fn try_unsafe_borrow<T>() -> Option<*mut T> {
        if RT_TLS_PTR.is_null() {
            None
        } else {
            Some(RT_TLS_PTR as *mut T)
        }
    }
}

/// Native implementation of having the runtime thread-local pointer. This
/// implementation uses the `thread_local_storage` module to provide a
/// thread-local value.
pub mod native {
    use cast;
    use option::{Option, Some, None};
    use ptr;
    use ptr::RawPtr;
    use tls = rt::thread_local_storage;

    static mut RT_TLS_KEY: tls::Key = -1;

    /// Initialize the TLS key. Other ops will fail if this isn't executed
    /// first.
    pub fn init() {
        unsafe {
            tls::create(&mut RT_TLS_KEY);
        }
    }

    pub unsafe fn cleanup() {
        rtassert!(RT_TLS_KEY != -1);
        tls::destroy(RT_TLS_KEY);
    }

    /// Give a pointer to thread-local storage.
    ///
    /// # Safety note
    ///
    /// Does not validate the pointer type.
    #[inline]
    pub unsafe fn put<T>(sched: ~T) {
        let key = tls_key();
        let void_ptr: *mut u8 = cast::transmute(sched);
        tls::set(key, void_ptr);
    }

    /// Take ownership of a pointer from thread-local storage.
    ///
    /// # Safety note
    ///
    /// Does not validate the pointer type.
    #[inline]
    pub unsafe fn take<T>() -> ~T {
        let key = tls_key();
        let void_ptr: *mut u8 = tls::get(key);
        if void_ptr.is_null() {
            rtabort!("thread-local pointer is null. bogus!");
        }
        let ptr: ~T = cast::transmute(void_ptr);
        tls::set(key, ptr::mut_null());
        return ptr;
    }

    /// Optionally take ownership of a pointer from thread-local storage.
    ///
    /// # Safety note
    ///
    /// Does not validate the pointer type.
    #[inline]
    pub unsafe fn try_take<T>() -> Option<~T> {
        match maybe_tls_key() {
            Some(key) => {
                let void_ptr: *mut u8 = tls::get(key);
                if void_ptr.is_null() {
                    None
                } else {
                    let ptr: ~T = cast::transmute(void_ptr);
                    tls::set(key, ptr::mut_null());
                    Some(ptr)
                }
            }
            None => None
        }
    }

    /// Take ownership of a pointer from thread-local storage.
    ///
    /// # Safety note
    ///
    /// Does not validate the pointer type.
    /// Leaves the old pointer in TLS for speed.
    #[inline]
    pub unsafe fn unsafe_take<T>() -> ~T {
        let key = tls_key();
        let void_ptr: *mut u8 = tls::get(key);
        if void_ptr.is_null() {
            rtabort!("thread-local pointer is null. bogus!");
        }
        let ptr: ~T = cast::transmute(void_ptr);
        return ptr;
    }

    /// Check whether there is a thread-local pointer installed.
    pub fn exists() -> bool {
        unsafe {
            match maybe_tls_key() {
                Some(key) => tls::get(key).is_not_null(),
                None => false
            }
        }
    }

    /// Borrow a mutable reference to the thread-local value
    ///
    /// # Safety Note
    ///
    /// Because this leaves the value in thread-local storage it is possible
    /// For the Scheduler pointer to be aliased
    pub unsafe fn unsafe_borrow<T>() -> *mut T {
        let key = tls_key();
        let void_ptr = tls::get(key);
        if void_ptr.is_null() {
            rtabort!("thread-local pointer is null. bogus!");
        }
        void_ptr as *mut T
    }

    pub unsafe fn try_unsafe_borrow<T>() -> Option<*mut T> {
        match maybe_tls_key() {
            Some(key) => {
                let void_ptr = tls::get(key);
                if void_ptr.is_null() {
                    None
                } else {
                    Some(void_ptr as *mut T)
                }
            }
            None => None
        }
    }

    #[inline]
    fn tls_key() -> tls::Key {
        match maybe_tls_key() {
            Some(key) => key,
            None => rtabort!("runtime tls key not initialized")
        }
    }

    #[inline]
    #[cfg(not(test))]
    #[allow(visible_private_types)]
    pub fn maybe_tls_key() -> Option<tls::Key> {
        unsafe {
            // NB: This is a little racy because, while the key is
            // initalized under a mutex and it's assumed to be initalized
            // in the Scheduler ctor by any thread that needs to use it,
            // we are not accessing the key under a mutex.  Threads that
            // are not using the new Scheduler but still *want to check*
            // whether they are running under a new Scheduler may see a 0
            // value here that is in the process of being initialized in
            // another thread. I think this is fine since the only action
            // they could take if it was initialized would be to check the
            // thread-local value and see that it's not set.
            if RT_TLS_KEY != -1 {
                return Some(RT_TLS_KEY);
            } else {
                return None;
            }
        }
    }

    #[inline] #[cfg(test)]
    pub fn maybe_tls_key() -> Option<tls::Key> {
        use realstd;
        unsafe {
            cast::transmute(realstd::rt::shouldnt_be_public::maybe_tls_key())
        }
    }
}


text:
@protocol doIApp;
@class doSourceFile;
@protocol doIScriptEngine;
@class doUIContainer;
@class doJsonNode;
@protocol doIPageView;

@protocol doIPage

#pragma mark -
@property (nonatomic, readonly, weak) id<doIApp> CurrentApp;
@property (nonatomic, readonly, strong) id<doIPageView> PageView;
@property (nonatomic, readonly, strong) doSourceFile * UIFile;
@property (nonatomic, readonly, strong) id<doIScriptEngine> ScriptEngine;
@property (nonatomic, readonly, strong) doUIModule* RootView;
@property (nonatomic, strong) NSString * Data;
@property (nonatomic, assign) BOOL IsFullScreen;
@property (nonatomic, strong) NSString * SoftMode;

#pragma mark -
@required
- (doUIModule *) CreateUIModule: (doUIContainer *)_uiContainer : (doJsonNode *) _moduleNode;
- (void) RemoveUIModule: (doUIModule *)_module;

- (doUIModule *) GetUIModuleByAddress: (NSString *) _key;
- (void) LoadRootUiContainer;
- (void) LoadScriptEngine: (NSString *) _scriptFile;
-(doMultitonModule*) CreateMultitonModule:(NSString*) _typeID;
-(doMultitonModule*) GetMultitonModuleByAddress:(NSString*) _key;
-(BOOL) DeleteMultitonModule:(NSString*) _address;
- (void) Dispose;
@end


text:
<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 18.08.2015
 * Time: 14:30
 */

use yii\bootstrap\ActiveForm;
use yii\widgets\Pjax;
use yiicms\components\content\CategoriesParentsWidget;
use yiicms\components\core\widgets\Alert;
use yiicms\components\core\widgets\CancelButton;
use yiicms\components\core\widgets\SubmitButton;
use yiicms\modules\admin\models\categories\CategoryEditForm;

/**
 * @var $this \yii\web\View
 * @var $model CategoryEditForm
 * @var $action string
 */

?>

        <?php Pjax::begin() ?>
        <?php Alert::widget() ?>
        <?php $form = ActiveForm::begin(['layout' => 'horizontal', 'options' => ['data-pjax' => 1]]); ?>

                <?= $form->field($model, 'parentId')->widget(CategoriesParentsWidget::class); ?>
                <?= $model->renderMultilang($form, 'title'); ?>
                <?= $form->field($model, 'description')->textInput() ?>
                <?= $form->field($model, 'slug')->textInput() ?>
                <?= $form->field($model, 'weight')->textInput() ?>
                <?= $form->field($model, 'keywords')->textarea() ?>

                <?= CancelButton::widget(); ?>
                <?= SubmitButton::widget(); ?>

        <?php ActiveForm::end(); ?>
        <?php Pjax::end() ?>


text:
Release History
===============
**0.1**
- Released on Apr. 2017
- This release focuses on finalizing the implementation of generating Collectd-GenericJMX
configuration. Some optimizations are also implemented to its internal transformative operations,
 including:
    * Redundant *MBean* definitions are removed, since the common *MBean* definitions is
    processed as a independent step as well as the *MBean* definition is generally overridable due to
    new hierarchical model.
    * Performance improvement on centralizing *MBean* and *Connection* blocks in a global *Plugin*
    block.
- In addition, a initial support to [FastJmx][2] and is considered as a variant to Collectd config
type; Collectd-FastJmx.
- Initial version of design document is provided via Sphinx Document Generator.

**0.1-beta**
- Released on Feb. 2017
- This release focuses on internal integration with Jenkins to realize simple form of Continuous
Integration.
- Additionally, a standard setup procedure (via setuptools) is defined.
- Simplify the meta and logic for generating Collectd-GenericJmx config.

**0.1-alpha**
- Released on Jan. 2017
- This release focuses on features of generating Collectd-GenericJMX config.
- The use case aims to support Collectd monitoring java applications via exporting JMX metrics. For more information, please refer to [Collectd GenericJMX Plugin] [1]
- Technology wise, we adopt several common python framework, including Jinja2 template engine, Cement CLI framework, read/write from yaml file.

[1]: https://collectd.org/wiki/index.php/Plugin:GenericJMX
[2]: https://github.com/egineering-llc/collectd-fast-jmx


text:
from setuptools import setup, find_packages

setup(
    name='frasco-push',
    version='0.3.3',
    url='http://github.com/frascoweb/frasco-push',
    license='MIT',
    author='Maxime Bouroumeau-Fuseau',
    author_email='maxime.bouroumeau@gmail.com',
    description="Socket.IO integration from Frasco",
    py_modules=["frasco_push"],
    zip_safe=False,
    platforms='any',
    install_requires=[
        'frasco',
        'redis',
        'python-socketio',
        'eventlet'
    ]
)


text:
- [Installation de GIT](http://git-scm.com/book/fr/D%C3%A9marrage-rapide-Installation-de-Git)
- [Installation de NodeJS + NPM](http://nodejs.org/download)
- [Installation d'un Terminal efficace : iTerm2](http://www.iterm2.com/#/section/downloads)
- [Installation d'un IDE : SublimeText](http://www.iterm2.com/#/section/downloads)
- [Installation d'un package manager : Homebrew](http://brew.sh/index_fr.html#install)
- Installation de [PHP sur Mac OS X](http://www.terite.com/2013/09/16/mac-php-dev-setup.html) + conf Apache


text:
package awsutil

const (

	// AWS_EC2_INSTANCE is an Ec2 instance resource type
	AWS_EC2_INSTANCE = "AWS::EC2::Instance"

	// AWS_EC2_HOST is an Ec2 host resource type
	AWS_EC2_HOST = "AWS::EC2::Host"

	// EC2_INSTANCE_STATE_RUNNING is an Ec2 instance in a "running" state
	EC2_INSTANCE_STATE_RUNNING = "running"

)


text:
package io.quarkus.registry.catalog;

import java.util.Collection;
import java.util.Map;

import io.quarkus.maven.dependency.ArtifactCoords;
import io.quarkus.registry.json.JsonBuilder;

/**
 * Platform release
 */
public interface PlatformRelease {

    PlatformReleaseVersion getVersion();

    Collection<ArtifactCoords> getMemberBoms();

    String getQuarkusCoreVersion();

    String getUpstreamQuarkusCoreVersion();

    Map<String, Object> getMetadata();

    default Mutable mutable() {
        return new PlatformReleaseImpl.Builder(this);
    }

    interface Mutable extends PlatformRelease, JsonBuilder<PlatformRelease> {

        Mutable setVersion(PlatformReleaseVersion version);

        Mutable setMemberBoms(Collection<ArtifactCoords> memberBoms);

        Mutable setQuarkusCoreVersion(String quarkusCoreVersion);

        Mutable setUpstreamQuarkusCoreVersion(String upstreamQuarkusCoreVersion);

        Mutable setMetadata(Map<String, Object> metadata);

        Mutable setMetadata(String key, Object value);

        Mutable removeMetadata(String key);

        PlatformRelease build();
    }

    /**
     * @return a new mutable instance
     */
    static Mutable builder() {
        return new PlatformReleaseImpl.Builder();
    }
}


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

  <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript"/>

  <title>
    File:
  </title>
  <link rel='stylesheet' href='support/docgen.css' type='text/css'/>
  <link rel='stylesheet' href='support/tags.css' type='text/css'/>

Documentation

Table of Contents

Class Inheritance Tree

-- Copyright (C) 2015 Thierry Rascle <thierr26@free.fr>

-- MIT license. Please refer to the LICENSE file.

with Ada.Text_IO; use Ada.Text_IO;

with Discrete_Type_Shuffler

To spec

To body

;

procedure Shuffler_Demo_Lottery is

   type Lottery_Number is range 1 .. 49;

   package Shuffler_Lottery is new Discrete_Type_Shuffler

To spec

To body

 (Lottery_Number);

   use Shuffler_Lottery

To spec

To body

;

   S : Shuffler

To API doc

To spec

To body

;

   Picked_Numbers_Count : constant Lottery_Number := 6;

begin

   S.Time_Dependent_Reset

To spec

To body

;

   for Number in 1 .. Picked_Numbers_Count loop

      Put (Lottery_Number'Image (S.Shuffled

To spec

To body

 (Number)));

   end loop;

   New_Line;

end Shuffler_Demo_Lottery

To spec

To body

;


text:
using Marvin.JsonPatch.Operations;
using NUnit.Framework;
using System.IO;
using System.Linq;
using System.Reflection;

namespace TaskCat.Automaton.Tests
{
    [TestFixture]
    public class TestFiniteStateMachine
    {
        public string ExecutingPath => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

        [Test]
        public void TestCreation_NotNull()
        {
            var jsonFsm = File.ReadAllText($"{ExecutingPath}\\SampleFSM.json");
            Assert.IsNotNull(jsonFsm);

            var machine = FiniteStateMachine.FromJson(jsonFsm);
            Assert.IsNotNull(machine);
            Assert.AreEqual("ClassifiedDelivery", machine.Name);
            Assert.AreEqual("default", machine.Variant);
            Assert.IsNotNull(machine.Nodes);
            Assert.IsNotNull(machine.Events);
        }

        [Test]
        public void TestExecuteSampleEvent()
        {
            var jsonFsm = File.ReadAllText($"{ExecutingPath}\\SampleFSM.json");
            Assert.IsNotNull(jsonFsm);

            var machine = FiniteStateMachine.FromJson(jsonFsm);
            Assert.IsNotNull(machine);

            machine.Initiate();

            Operation op = new Operation()
            {
                op = "replace",
                path = "/state",
                value = "COMPLETED"
            };

            var currentCandidates = machine.CurrentCandidateNodes;

            Assert.IsNotNull(currentCandidates);
            Assert.AreEqual(1, currentCandidates.Count());

            var candidate = currentCandidates.First();

            var eventPossibilities = machine.GetEvents(candidate.Id);
            Assert.IsNotNull(eventPossibilities);
            Assert.That(eventPossibilities.Count() >= 1);

            machine.ExecuteEvent(new EventDefinition()
            {
                Id = eventPossibilities.First().Id,
                NodeId = candidate.Id,
                MatchCondition = op
            });

            Assert.That(machine.NodeHistory.Count == 1);
            Assert.IsNotNull(machine.NodeHistory.Last());
            Assert.IsNotNull(machine.NodeHistory.Last().Value.Count == 1);
            Assert.That(machine.NodeDictionary.First().Value.Type == "Pickup");
            Assert.That(machine.CurrentCandidateNodes.Count() == 1);
            Assert.That(machine.CurrentCandidateNodes.Last().Type == "Delivery");
        }

        [Test]
        public void TestSaving_NotNull()
        {
            var jsonFsm = File.ReadAllText($"{ExecutingPath}\\SampleFSM.json");
            Assert.IsNotNull(jsonFsm);

            var machine = FiniteStateMachine.FromJson(jsonFsm);
            Assert.IsNotNull(machine);

            machine.Initiate();

            Operation op = new Operation()
            {
                op = "replace",
                path = "/state",
                value = "COMPLETED"
            };

            var currentCandidates = machine.CurrentCandidateNodes;

            Assert.IsNotNull(currentCandidates);
            Assert.AreEqual(1, currentCandidates.Count());

            var candidate = currentCandidates.First();

            var eventPossibilities = machine.GetEvents(candidate.Id);
            Assert.IsNotNull(eventPossibilities);
            Assert.That(eventPossibilities.Count() >= 1);

            machine.ExecuteEvent(new EventDefinition()
            {
                Id = eventPossibilities.First().Id,
                NodeId = candidate.Id,
                MatchCondition = op
            });

            Assert.That(machine.NodeHistory.Count == 1);

            var save = machine.SaveMachine();
            Assert.IsNotNull(save);
        }

        [Test]
        public void TestRestore()
        {
            var jsonFsm = File.ReadAllText($"{ExecutingPath}\\SampleFSM.json");
            Assert.IsNotNull(jsonFsm);

            var machine = FiniteStateMachine.FromJson(jsonFsm);
            Assert.IsNotNull(machine);

            machine.Initiate();

            Operation op = new Operation()
            {
                op = "replace",
                path = "/state",
                value = "COMPLETED"
            };

            var currentCandidates = machine.CurrentCandidateNodes;

            Assert.IsNotNull(currentCandidates);
            Assert.AreEqual(1, currentCandidates.Count());

            var candidate = currentCandidates.First();

            var eventPossibilities = machine.GetEvents(candidate.Id);
            Assert.IsNotNull(eventPossibilities);
            Assert.That(eventPossibilities.Count() >= 1);

            machine.ExecuteEvent(new EventDefinition()
            {
                Id = eventPossibilities.First().Id,
                NodeId = candidate.Id,
                MatchCondition = op
            });

            Assert.That(machine.NodeHistory.Count == 1);

            var save = machine.SaveMachine();

            var machine2 = FiniteStateMachine.FromJson(jsonFsm);
            machine2.Initiate(save);

            // TODO: I need to test whether this goes on or not
            candidate = currentCandidates.First();
            eventPossibilities = machine.GetEvents(candidate.Id);
            Assert.IsNotNull(eventPossibilities);
            Assert.That(eventPossibilities.Count() >= 1);

            machine2.ExecuteEvent(new EventDefinition()
            {
                Id = eventPossibilities.First().Id,
                NodeId = candidate.Id,
                MatchCondition = op
            });

            // The first event gets selected is a resolve event.
            // Thats why the node history has a single element
            Assert.That(machine.NodeHistory.Count == 1);
        }
    }
}


text:
package main

import (
	"database/sql"
	"github.com/GeoNet/fdsn/internal/fdsn"
	"time"
)

type metric struct {
	Network, Station, Channel, Location string
	Key                                 string
	StartTime                           time.Time
	NumSamples                          int
	Error                               bool
	ErrorMessage                        string
}

// metricsSearch searches for data metrics matching the query.
// network, station, channel, and location are matched using POSIX regular expressions.
// https://www.postgresql.org/docs/9.3/static/functions-matching.html
// start and end should be set for all queries.  24 hours will be subtracted from the Start time and be added from the End time to include all records
// in each day long file.
func metricsSearch(d fdsn.DataSearch) ([]metric, error) {
	rows, err := db.Query(`WITH s AS (SELECT DISTINCT ON (network, station, channel, location) streamPK, network, station, channel, location
	FROM fdsn.stream WHERE network ~ $1
	AND station ~ $2
	AND channel ~ $3
	AND location ~ $4)
	SELECT DISTINCT ON (key) key, network, station, channel, location, start_time, numsamples, error_data, error_msg FROM s JOIN fdsn.holdings USING (streampk)
	WHERE start_time >= $5
	AND start_time <= $6`,
		d.Network, d.Station, d.Channel, d.Location, d.Start.Add(time.Hour*-24), d.End.Add(time.Hour*24))
	if err != nil {
		return []metric{}, err
	}

	var h []metric

	for rows.Next() {
		var v metric

		err = rows.Scan(&v.Key, &v.Network, &v.Station, &v.Channel, &v.Location, &v.StartTime, &v.NumSamples, &v.Error, &v.ErrorMessage)
		if err != nil {
			return []metric{}, err
		}
		h = append(h, v)
	}

	return h, nil
}

// holdingsSearch searches for S3 keys matching the query.
// network, station, channel, and location are matched using POSIX regular expressions.
// https://www.postgresql.org/docs/9.3/static/functions-matching.html
// start and end should be set for all queries.  24 hours will be subtracted from the Start time and be added from the End time to include all records
// in each day long file.
func holdingsSearch(d fdsn.DataSearch) (keys []string, err error) {
	var rows *sql.Rows

	rows, err = db.Query(`WITH s AS (SELECT DISTINCT ON (network, station, channel, location) streamPK
	FROM fdsn.stream WHERE network ~ $1
	AND station ~ $2
	AND channel ~ $3
	AND location ~ $4)
	SELECT DISTINCT ON (key) key FROM s JOIN fdsn.holdings USING (streampk)
	WHERE start_time >= $5
	AND start_time <= $6
	AND error_data = false`,
		d.Network, d.Station, d.Channel, d.Location, d.Start.Add(time.Hour*-24), d.End.Add(time.Hour*24))
	if err != nil {
		return
	}

	var s string

	for rows.Next() {
		err = rows.Scan(&s)
		if err != nil {
			return
		}
		keys = append(keys, s)
	}

	return
}