text:
// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-

// -- BEGIN LICENSE BLOCK ----------------------------------------------
// Copyright 2019 FZI Forschungszentrum Informatik
// Created on behalf of Universal Robots A/S
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// -- END LICENSE BLOCK ------------------------------------------------

//----------------------------------------------------------------------
/*!\file
 *
 * \author  Lea Steffen steffen@fzi.de
 * \date    2019-04-01
 *
 */
//----------------------------------------------------------------------

#ifndef UR_CLIENT_LIBRARY_RTDE__HEADER_H_INCLUDED
#define UR_CLIENT_LIBRARY_RTDE__HEADER_H_INCLUDED

#include <cstddef>
#include <endian.h>
#include "ur_client_library/types.h"
#include "ur_client_library/comm/package_serializer.h"

namespace urcl
{
namespace rtde_interface
{
/*!
 * \brief Possible package types
 */
enum class PackageType : uint8_t
{
  RTDE_REQUEST_PROTOCOL_VERSION = 86,       // ascii V
  RTDE_GET_URCONTROL_VERSION = 118,         // ascii v
  RTDE_TEXT_MESSAGE = 77,                   // ascii M
  RTDE_DATA_PACKAGE = 85,                   // ascii U
  RTDE_CONTROL_PACKAGE_SETUP_OUTPUTS = 79,  // ascii O
  RTDE_CONTROL_PACKAGE_SETUP_INPUTS = 73,   // ascii I
  RTDE_CONTROL_PACKAGE_START = 83,          // ascii S
  RTDE_CONTROL_PACKAGE_PAUSE = 80           // ascii P
};

/*!
 * \brief This class represents the header for RTDE packages.
 */
class PackageHeader
{
public:
  PackageHeader() = default;
  virtual ~PackageHeader() = default;
  using _package_size_type = uint16_t;

  /*!
   * \brief Reads a buffer, interpreting the next bytes as the size of the contained package.
   *
   * \param buf The given byte stream containing a serialized package
   *
   * \returns The size of the given serialized package
   */
  static size_t getPackageLength(uint8_t* buf)
  {
    return be16toh(*(reinterpret_cast<_package_size_type*>(buf)));
  }

  /*!
   * \brief Creates a serialization of a header based on given values.
   *
   * \param buffer The buffer to write the serialization to
   * \param package_type The type of the package
   * \param payload_length The length of the package's payload
   *
   * \returns
   */
  static size_t serializeHeader(uint8_t* buffer, PackageType package_type, uint16_t payload_length)
  {
    uint16_t header_size = sizeof(_package_size_type) + sizeof(PackageType);
    uint16_t size = header_size + payload_length;
    comm::PackageSerializer::serialize(buffer, size);
    comm::PackageSerializer::serialize(buffer + sizeof(size), package_type);
    return header_size;
  }
};

}  // namespace rtde_interface
}  // namespace urcl

#endif  // #ifndef UR_CLIENT_LIBRARY_RTDE__HEADER_H_INCLUDED


text:
package br.org.soujava.httpmock;

import com.github.kristofa.test.http.MockHttpServer;
import com.github.kristofa.test.http.SimpleHttpResponseProvider;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.testng.annotations.*;

import java.io.IOException;

import static org.testng.Assert.assertTrue;

/**
 * @author thomasmodeneis
 */
public abstract class BaseMockTest {

    protected static final String UTF_8 = "UTF-8";
    protected static MockHttpServer server;
    protected static SimpleHttpResponseProvider responseProvider;
    protected HttpClient client;
    protected static String baseUrl;

    @BeforeClass
    public void beforeSuite() throws IOException {
        responseProvider = new SimpleHttpResponseProvider();
        server = new MockHttpServer(0, responseProvider);
        final int port = server.start();
        assertTrue(port != -1);
        baseUrl = "http://localhost:" + server.getPort();
    }

    @AfterClass
    public void afterSuite() throws IOException {
        server.stop();
    }

    @BeforeMethod
    public void beforeClass() throws Exception {
        client = new DefaultHttpClient();
        responseProvider.reset();
    }
}

redpajama_set_name: RedPajamaGithub


text:
set(GTEST_H gtest/gtest.h)

find_path(GTEST_INCLUDE_DIR ${GTEST_H}
  PATHS ${GTEST_ROOT}/include
        $ENV{IMPALA_HOME}/thirdparty/gtest-1.6.0/include
        NO_DEFAULT_PATH
  DOC   "Path to the ${GTEST_H} file"
)

find_library(GTEST_LIBRARY NAMES gtest
  PATHS ${GTEST_ROOT}/lib
        $ENV{IMPALA_HOME}/thirdparty/gtest-1.6.0
        NO_DEFAULT_PATH
  DOC   "Google's framework for writing C++ tests (gtest)"
)

find_library(GTEST_MAIN_LIBRARY NAMES gtest_main
  PATHS ${GTEST_ROOT}/lib
        $ENV{IMPALA_HOME}/thirdparty/gtest-1.6.0
        NO_DEFAULT_PATH
  DOC   "Google's framework for writing C++ tests (gtest_main)"
)

if(GTEST_INCLUDE_DIR AND GTEST_LIBRARY AND GTEST_MAIN_LIBRARY)
  set(GTEST_LIBRARIES ${GTEST_LIBRARY} ${GTEST_MAIN_LIBRARY})
  set(GTEST_FOUND TRUE)
else(GTEST_INCLUDE_DIR AND GTEST_LIBRARY AND GTEST_MAIN_LIBRARY)
  set(GTEST_FOUND FALSE)
endif(GTEST_INCLUDE_DIR AND GTEST_LIBRARY AND GTEST_MAIN_LIBRARY)

if(GTEST_FOUND)
  if(NOT GTest_FIND_QUIETLY)
    message(STATUS "Found GTest: ${GTEST_LIBRARIES}")
  endif(NOT GTest_FIND_QUIETLY)
  add_library(gtest STATIC IMPORTED)
  set_target_properties(gtest PROPERTIES IMPORTED_LOCATION "${GTEST_LIBRARY}")
else(GTEST_FOUND)
  message(FATAL_ERROR "Could not find the GTest Library")
endif(GTEST_FOUND)

mark_as_advanced(
  GTEST_INCLUDE_DIR
  GTEST_LIBRARIES
  gtest)


text:
ACCEPTED

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

#### Published in
Gentes Herb. 7:242. 1947

#### Original name
null

### Remarks
null


text:
int main(int argc, char **argv)
{

#ifdef WIN32
	WSADATA wsa_data;
	WSAStartup(0x0201, &wsa_data);
#endif

	struct sockaddr_in server_address;
	memset( &server_address, 0, sizeof( server_address ) );
	server_address.sin_family = AF_INET;
	server_address.sin_addr.s_addr = inet_addr("127.0.0.1");
	server_address.sin_port = htons( 9995 );

	int sockfd = socket( PF_INET, SOCK_STREAM, 0 );
	assert( sockfd >= 0 );
	if ( connect( sockfd, ( struct sockaddr* )&server_address, sizeof( server_address ) ) < 0 )
	{
		printf( "connection failed\n" );
	}
	else
	{
		printf( "send oob data out\n" );
		const char* oob_data = "abc";
		const char* normal_data = "123";
		send( sockfd, normal_data, strlen( normal_data ), 0 );
		send( sockfd, oob_data, strlen( oob_data ), MSG_OOB );
		send( sockfd, normal_data, strlen( normal_data ), 0 );
	}
	return 0;
}


text:
using namespace llvm;

// Returns an SVN repository path, which is usually "trunk".
static std::string getRepositoryPath() {
  StringRef S = LLD_REPOSITORY_STRING;
  size_t Pos = S.find("lld/");
  if (Pos != StringRef::npos)
    return S.substr(Pos + 4);
  return S;
}

// Returns an SVN repository name, e.g., " (trunk 284614)"
// or an empty string if no repository info is available.
static std::string getRepository() {
  std::string Repo = getRepositoryPath();
  std::string Rev = LLD_REVISION_STRING;

  if (Repo.empty() && Rev.empty())
    return "";
  if (!Repo.empty() && !Rev.empty())
    return " (" + Repo + " " + Rev + ")";
  return " (" + Repo + Rev + ")";
}

// Returns a version string, e.g., "LLD 4.0 (lld/trunk 284614)".
std::string lld::getLLDVersion() {
  return "LLD " + std::string(LLD_VERSION_STRING) + getRepository();
}


text:
// Needs to be a multiple of 1, 2, 3, 4 and 8
#define WAVSAMPLEBUFFER 0xF000

#include <emuall/util/wavaudiofile.h>

#include <cassert>

WavException::WavException(const char *format, ...)
{
	va_list args;
	va_start(args, format);
	vsnprintf(errorMsg, sizeof(errorMsg), format, args);
	va_end(args);
}

WavChunk::WavChunk(RawFile &file)
{
	ReadFromFile(file);
}

WavChunk::WavChunk(const char *id)
{
	assert(id != NULL);
	int i = 0;
	while (*id != NULL && i < 4)
	{
		_id[i] = *id;
		id++;
		i++;
	}
	while (i < 4)
	{
		_id[i] = ' ';
		i++;
	}
	_location = -1;
	_size = 0;
}

WavChunk::~WavChunk()
{

}

void WavChunk::WriteToFile(RawFile &file) const
{
	file.PutI8(_id[0]);
	file.PutI8(_id[1]);
	file.PutI8(_id[2]);
	file.PutI8(_id[3]);
	file.PutU32(_size);
}

void WavChunk::ReadFromFile(RawFile &file)
{
	_location = file.GetPosition();
	_id[0] = file.GetI8();
	_id[1] = file.GetI8();
	_id[2] = file.GetI8();
	_id[3] = file.GetI8();
	_size = file.GetU32();
}

bool WavChunk::IsID(const char *id) const
{
	if (id == NULL || strlen(id) < 4)
		return false;
	return _id[0] == id[0] && _id[1] == id[1] && _id[2] == id[2] && _id[3] == id[3];
}

WavUnkChunk::WavUnkChunk(RawFile &file) :
	WavChunk(file), _payload(NULL)
{
	_payload = new char[WavChunk::_size];
	ReadFromFile(file);
}

WavUnkChunk::~WavUnkChunk()
{
	if (_payload != NULL)
		delete[] _payload;
}

void WavUnkChunk::WriteToFile(RawFile &file) const
{
	WavChunk::WriteToFile(file);
	if (_payload != NULL)
	{
		file.Write(_payload, WavChunk::_size);
	}
	else {
		size_t i = WavChunk::_size;
		while (i--)
		{
			file.PutC((char)0);
		}
	}
}

void WavUnkChunk::ReadFromFile(RawFile &file)
{
	//WavChunk::ReadFromFile(file);
	if (_payload != NULL)
		file.Read(_payload, WavChunk::_size);
	file.Seek(WavChunk::_location + WavChunk::_size + 8, File::seekBeginning);
}

WavFmtChunk::WavFmtChunk(RawFile &file) :
	WavChunk(file)
{
	ReadFromFile(file);
	WavChunk::_size = 16;
}

WavFmtChunk::WavFmtChunk() :
	WavChunk("fmt ")
{
	WavChunk::_size = 16;
}

void WavFmtChunk::ReadFromFile(RawFile &file)
{
	//WavChunk::ReadFromFile(file);
	_compression = (CompressionCode)file.GetU16();
	_channels = file.GetU16();
	_samplerate = file.GetU32();
	_bytesPerSecond = file.GetU32();
	_blockAlign = file.GetU16();
	_bitsPerSample = file.GetU16();
	// Skip extra format bytes
	file.Seek(WavChunk::_location + WavChunk::_size + 8, File::seekBeginning);

	if (_compression != PCM && _compression != IEEE_FLOAT)
	{
		throw WavException("Only uncompressed wave files are supported");
	}
}

void WavFmtChunk::WriteToFile(RawFile &file) const
{
	WavChunk::WriteToFile(file);
	file.PutU16(_compression);
	file.PutU16(_channels);
	file.PutU32(_samplerate);
	file.PutU32(_bytesPerSecond);
	file.PutU16(_blockAlign);
	file.PutU16(_bitsPerSample);
}

WavDataChunk::WavDataChunk(WavFmtChunk *format) :
	_format(format), _count(0), WavChunk("data")
{
}

WavDataChunk::WavDataChunk(RawFile &file, WavFmtChunk *format) :
	_format(format), _count(0), WavChunk(file)
{
	_audioSamples = new std::vector<int16_t *>;
	ReadFromFile(file);
}

WavDataChunk::~WavDataChunk()
{
	ClearSamples();
	delete _audioSamples;
}

void WavDataChunk::ReadFromFile(RawFile &file)
{
	file.Seek(WavChunk::_location + 8, File::seekBeginning);
	//WavChunk::ReadFromFile(file);
	if (_format != NULL)
	{
		// read data
		LoadData(file);
	}
	// Goto next chunk
	file.Seek(WavChunk::_location + WavChunk::_size + 8, File::seekBeginning);
}

void WavDataChunk::WriteToFile(RawFile &file) const
{
	WavFmtChunk format = GetOutputFormat();
	file.PutC('d'); file.PutC('a'); file.PutC('t'); file.PutC('a');
	file.PutU32(format.GetBlockAlign()*_count);

	for (unsigned int i = 0; i < _count; ++i)
	{
		for (int j = 0; j < format.GetChannels(); ++j)
		{
			uint32_t offset = i * format.GetChannels()*sizeof(int16_t) +j * sizeof(int16_t);
			uint32_t bufferIndex = offset / WAVSAMPLEBUFFER;
			uint32_t sampleIndex = offset % WAVSAMPLEBUFFER;
			if (_audioSamples->size() <= bufferIndex)
			{
				throw WavException("Audiosample size is not equal to the sample count");
			}
			int16_t *ptr = (*_audioSamples)[bufferIndex] + (sampleIndex / sizeof(int16_t));
			file.PutI16(*ptr);
		}
	}
}

void WavDataChunk::LoadData(RawFile &file)
{
	WavChunk::GotoPosition(file);
	file.Seek(8); // Goto data

	if (_format == NULL)
		throw WavException("Format chunk is not loaded");

	// Remove the old samples
	ClearSamples();

	unsigned int bytespersample = (_format->GetBitsPerSample()+7)/8;
	if (bytespersample != 4 && _format->GetCompression() == WavFmtChunk::IEEE_FLOAT)
	{
		throw WavException("Samples are not valid floating points");
	}

	// Load the new samples
	_count = WavChunk::_size / _format->GetBlockAlign();
	for (uint32_t i = 0; i < _count; ++i)
	{
		for (int j = 0; j < _format->GetChannels(); ++j)
		{
			uint32_t offset = i * _format->GetChannels()*sizeof(int16_t) + j * sizeof(int16_t);
			uint32_t bufferIndex = offset / WAVSAMPLEBUFFER;
			uint32_t sampleIndex = offset % WAVSAMPLEBUFFER;
			if (_audioSamples->size() <= bufferIndex)
			{
				_audioSamples->push_back(new int16_t[WAVSAMPLEBUFFER / sizeof(int16_t)]);
			}
			int16_t *ptr = (*_audioSamples)[bufferIndex] + (sampleIndex / sizeof(int16_t));
			switch (_format->GetCompression())
			{
			case WavFmtChunk::PCM:
				switch (bytespersample)
				{
				case 1:
					*ptr = (int16_t) (file.GetI8() * 256);
					break;
				case 2:
					*ptr = file.GetI16();
					break;
				case 3:
					*ptr = (int16_t) (file.GetI24() / 256);
					break;
				case 4:
					*ptr = (int16_t) (file.GetI32() / (256*256));
					break;
				default:
					throw WavException("Unsupported bits per sample: %d", _format->GetBitsPerSample());
				}
				break;
			case WavFmtChunk::IEEE_FLOAT:
				*ptr = (int16_t)(file.GetFloat()*INT16_MAX);
				break;
			default:
				throw WavException("Unsupported compression %d used", _format->GetCompression());
			}
		}
	}

}

void WavDataChunk::ClearSamples()
{
	std::vector<int16_t *>::iterator it;
	for (it = _audioSamples->begin(); it != _audioSamples->end(); ++it)
	{
		delete[] * it;
	}
	_audioSamples->clear();
}

unsigned int WavDataChunk::ReadSamples(int16_t *buffer, unsigned int pos, unsigned int samples) const
{
	if (_format == NULL)
		throw WavException("Format chunk is not loaded");

	uint32_t start = pos * _format->GetBlockAlign();
	uint32_t size = samples * sizeof(int16_t) * _format->GetChannels();
	uint32_t offset = start;

	if (pos + size / (sizeof(int16_t) *_format->GetChannels()) > _count)
		size = (_count - pos)*(sizeof(int16_t) *_format->GetChannels());

	while (size > 0)
	{
		uint32_t bufferIndex = offset / WAVSAMPLEBUFFER;
		uint32_t sampleIndex = offset % WAVSAMPLEBUFFER;
		if (size > WAVSAMPLEBUFFER - sampleIndex)
		{
			memcpy(buffer, (*_audioSamples)[bufferIndex] + sampleIndex, WAVSAMPLEBUFFER - sampleIndex);
			size -= WAVSAMPLEBUFFER - sampleIndex;
			offset += WAVSAMPLEBUFFER - sampleIndex;
			buffer += (WAVSAMPLEBUFFER - sampleIndex) / sizeof(int16_t);
		}
		else {
			memcpy(buffer, (*_audioSamples)[bufferIndex] + sampleIndex, size);
			size -= size;
			offset += size;
			buffer += size / sizeof(int16_t);
		}
	}
	return offset-start;
}

unsigned int WavDataChunk::WriteSamples(int16_t *buffer, unsigned int samples)
{
	if (_format == NULL)
		throw WavException("Format chunk is not loaded");

	uint32_t start = _count * sizeof(int16_t) * _format->GetChannels();

	for (unsigned int i = 0; i < samples; i++)
	{
		for (int j = 0; j < _format->GetChannels(); ++j)
		{
			uint32_t offset = start + i * _format->GetChannels()*sizeof(int16_t) +j * sizeof(int16_t);
			uint32_t bufferIndex = offset / WAVSAMPLEBUFFER;
			uint32_t sampleIndex = offset % WAVSAMPLEBUFFER;
			if (_audioSamples->size() <= bufferIndex)
			{
				_audioSamples->push_back(new int16_t[WAVSAMPLEBUFFER/sizeof(int16_t)]);
			}
			int16_t *ptr = (*_audioSamples)[bufferIndex] + (sampleIndex / sizeof(int16_t));
			*ptr = *buffer;
			buffer += 1;
		}
	}
	_count += samples;
	return samples;
}

WavFmtChunk WavDataChunk::GetOutputFormat() const
{
	if (_format == NULL)
		throw WavException("No format loaded");
	WavFmtChunk out = *_format;
	out.SetCompression(WavFmtChunk::PCM);
	out.SetBitsPerSample(16);
	out.SetBlockAlign((out.GetBitsPerSample()+7)/8 * out.GetChannels());
	out.SetBytesPerSecond(out.GetBlockAlign()*out.GetSampleRate());
	return out;
}

WavFactChunk::WavFactChunk(RawFile &file)
	: WavChunk(file), _samplesPerChannel(0)
{
	ReadFromFile(file);
}

WavFactChunk::~WavFactChunk()
{

}

void WavFactChunk::WriteToFile(RawFile &file) const
{

}

void WavFactChunk::ReadFromFile(RawFile &file)
{
	//WavChunk::ReadFromFile(file);
	_samplesPerChannel = file.GetU32();
}

WavFile::WavFile() :
	_file(true), _waveFormatInfo(NULL), _position(0), WavChunk("RIFF"), _waveData(NULL)
{

}

WavFile::WavFile(const char *path, bool create) :
	_file(true), _waveFormatInfo(NULL), _position(0), WavChunk("RIFF"), _waveData(NULL)
{
	_chunks = new std::list<WavChunk *>;
	try
	{
		OpenWavFile(path, create);
	}
	catch (...)
	{
		Release();
		throw;
	}
}

WavFile::~WavFile()
{
	Release();
	delete _chunks;
}

void WavFile::Release()
{
	std::list<WavChunk *>::iterator it;
	for (it = _chunks->begin(); it != _chunks->end(); ++it)
	{
		delete *it;
	}
	_chunks->clear();
	if (_waveData != NULL)
		delete _waveData;
	if (_waveFormatInfo != NULL)
		delete _waveFormatInfo;
}

void WavFile::OpenWavFile(const char *path, bool create)
{
	try {
		if (create)
		{
			// File was not found so we create one
			_file = RawFile(path, File::openRawRWCreate);
			WavChunk::_id[0] = 'R'; WavChunk::_id[1] = 'I'; WavChunk::_id[2] = 'F'; WavChunk::_id[3] = 'F';
			WavChunk::_location = 0;
			WavChunk::_size = 0;
			_waveFormatInfo = new WavFmtChunk();
			_waveFormatInfo->SetBitsPerSample(16);
			_waveFormatInfo->SetCompression(WavFmtChunk::PCM);
			_waveData = new WavDataChunk(_waveFormatInfo);
		}
		else {
			_file = RawFile(path, File::openRawRW, true);
			// Get first chunk
			WavChunk::ReadFromFile(_file);
			char riffType[4];
			riffType[0] = _file.GetI8();
			riffType[1] = _file.GetI8();
			riffType[2] = _file.GetI8();
			riffType[3] = _file.GetI8();
			if (!IsID("RIFF") || riffType[0] != 'W' || riffType[1] != 'A' || riffType[2] != 'V' || riffType[3] != 'E')
			{
				throw WavException("File is not a wave file");
			}
			ReadChunks();
			if (_waveData == NULL)
			{
				_waveData = new WavDataChunk();
			}
			if (_waveData->GetWavFmt() == NULL)
			{
				_waveData->SetWavFmt(_waveFormatInfo);
				_waveData->LoadData(_file);
			}
		}
	}
	catch (EndOfFileException)
	{
		throw WavException("EOF reached before filetype could be determined");
	}

}

void WavFile::ReadChunks()
{
	// Read chunks
	while (!_file.IsEOF())
	{
		try {
			WavChunk chunkHeader(_file);
			WavChunk *chunk;
			chunkHeader.GotoPosition(_file);
			if (chunkHeader.IsID("fmt "))
			{
				if (_waveFormatInfo != NULL)
				{
					throw WavException("Multiple format chunks found");
				}
				_waveFormatInfo = new WavFmtChunk(_file);
				chunk = _waveFormatInfo;
				//_chunks.push_back(chunk);
			}
			else if (chunkHeader.IsID("data"))
			{
				if (_waveData != NULL)
					throw WavException("Multiple data segments not supported");
				_waveData = new WavDataChunk(_file, _waveFormatInfo);
				chunk = _waveData;
				//_chunks.push_back(chunk);
			}
			else if (chunkHeader.IsID("fact"))
			{
				chunk = new WavFactChunk(_file);
				_chunks->push_back(chunk);
			}
			else {
				chunk = new WavUnkChunk(_file);
				_chunks->push_back(chunk);
			}
		}
		catch (EndOfFileException)
		{
			break;
		}
	}
}

unsigned int WavFile::ReadPCM16(int16_t *buffer, unsigned int samples)
{
	if (_waveData == NULL  || _waveFormatInfo == NULL)
	{
		throw WavException("Tried reading from uninitialized wav file");
	}

	unsigned int samplesRead = _waveData->ReadSamples(buffer, _position, samples);
	_position += samplesRead;

	return samplesRead;
}

unsigned int WavFile::GetSampleRate() const
{
	if (_waveFormatInfo == NULL)
	{
		return 0;
	}
	return _waveFormatInfo->GetSampleRate();
}

unsigned int WavFile::GetChannels() const
{
	if (_waveFormatInfo == NULL)
	{
		return 0;
	}
	return _waveFormatInfo->GetChannels();
}

unsigned int WavFile::Count() const
{
	if (_waveData == NULL)
	{
		return 0;
	}
	return _waveData->Count();
}

void WavFile::SetFormat(unsigned int sampleRate, unsigned short channels)
{
	if (_waveFormatInfo == NULL)
		throw WavException("Wave format information not loaded");
	_waveFormatInfo->SetSampleRate(sampleRate);
	_waveFormatInfo->SetChannels(channels);
	_waveFormatInfo->SetBlockAlign((_waveFormatInfo->GetBitsPerSample()+7)/8*_waveFormatInfo->GetChannels());
	_waveFormatInfo->SetBytesPerSecond(_waveFormatInfo->GetBlockAlign()*_waveFormatInfo->GetSampleRate());
}

unsigned int WavFile::WritePCM(int16_t *buffer, unsigned int samples)
{
	if (_waveData == NULL || _waveFormatInfo == NULL)
	{
		throw WavException("Tried writing files to uninitialized wav file");
	}

	unsigned int samplesWritten = _waveData->WriteSamples(buffer, samples);

	return samplesWritten;
}

void WavFile::WriteToFile(const char *path)
{
	RawFile file;
	assert(_waveData != NULL);

	if (path == NULL)
	{
		file = _file;
	}
	else {
		file = RawFile(path,File::openRawWriteOnly,true);
	}
	WavFmtChunk format = _waveData->GetOutputFormat();
	std::list<WavChunk *>::const_iterator it;

	size_t size = format.Size();
	size += _waveData->Size();

	for (it = _chunks->cbegin(); it != _chunks->cend(); ++it)
	{
		size += (*it)->Size();
	}

	file.PutC('R');
	file.PutC('I');
	file.PutC('F');
	file.PutC('F');
	file.PutU32((uint32_t)size);
	file.PutC('W');
	file.PutC('A');
	file.PutC('V');
	file.PutC('E');
	format.WriteToFile(file);
	_waveData->WriteToFile(file);

	for (it = _chunks->cbegin(); it != _chunks->cend(); ++it)
	{
		(*it)->WriteToFile(file);
	}
}

WavFileInStream::WavFileInStream(const char *path) :
	_file(true), _position(0), _dataOffset(0), _dataSize(0),
	_waveFormatInfo(NULL), WavChunk("RIFF")
{
	try
	{
		OpenWavFile(path);
	}
	catch (...)
	{
		Release();
		throw;
	}
}

WavFileInStream::~WavFileInStream()
{
	Release();
}

unsigned int WavFileInStream::Read(void* buffer, unsigned int samples)
{
	if (_waveFormatInfo == NULL || _dataSize == 0)
		throw WavException("Tried reading from uninitialized wav file");

	if (_position + samples > _dataSize / _waveFormatInfo->GetBlockAlign())
	{
		samples = (unsigned int)(_dataSize / _waveFormatInfo->GetBlockAlign() - _position);
	}

	_file.Seek((long)(_dataOffset + _position*_waveFormatInfo->GetBlockAlign()), File::seekBeginning); // Goto data
	unsigned int read =  (unsigned int)_file.Read(buffer, samples * _waveFormatInfo->GetBlockAlign());
	_position += read / _waveFormatInfo->GetBlockAlign();
	return read;
}

unsigned int WavFileInStream::ReadFloat(float *buffer, unsigned int samples)
{
	if (_waveFormatInfo == NULL || _dataSize == 0)
		throw WavException("Tried reading from uninitialized wav file");

	if (_waveFormatInfo->GetCompression() == WavFmtChunk::IEEE_FLOAT && _waveFormatInfo->GetBitsPerSample() == 32 && Endian::isHostLittleEndian())
		return Read(buffer, samples); // use native

	if (_position + samples > _dataSize / _waveFormatInfo->GetBlockAlign())
	{
		samples = (unsigned int)(_dataSize / _waveFormatInfo->GetBlockAlign() - _position);
	}

	if (_waveFormatInfo->GetCompression() != WavFmtChunk::PCM && _waveFormatInfo->GetCompression() != WavFmtChunk::IEEE_FLOAT)
		throw WavException("Unsupported audio format");

	_file.Seek((long)(_position*_waveFormatInfo->GetBlockAlign() + _dataOffset), File::seekBeginning);

	unsigned int read;
	float *ptr = buffer;
	for (read = 0; read < samples; read++)
	{
		for (int i = 0; i < _waveFormatInfo->GetChannels(); i++)
		{
			switch (_waveFormatInfo->GetCompression())
			{
			case WavFmtChunk::PCM:
				switch (_waveFormatInfo->GetBitsPerSample())
				{
				case 8:
					*ptr = (float) (((int16_t) _file.GetU8() - 128) / (float) INT8_MAX);
					break;
				case 16:
					*ptr = (float) (_file.GetI16() / (float) INT16_MAX);
					break;
				case 24:
					*ptr = (float) (_file.GetI24() / 8388607.0);
					break;
				case 32:
					*ptr = (float) (_file.GetI32() / (float) INT32_MAX);
					break;
				default:
					throw WavException("Unsupported bits per sample: %d", _waveFormatInfo->GetBitsPerSample());
				}
				break;
			case WavFmtChunk::IEEE_FLOAT:
				switch (_waveFormatInfo->GetBitsPerSample())
				{
				case 32:
					*ptr = _file.GetFloat();
					break;
				case 64:
					*ptr = (float)_file.GetDouble();
					break;
				default:
					throw WavException("Unsupported bits per sample: %d", _waveFormatInfo->GetBitsPerSample());
				}
				break;
			default:
				throw WavException("Unsupported compression %d used", _waveFormatInfo->GetCompression());
			}
			ptr++;
		}
		_position += _waveFormatInfo->GetBlockAlign();
	}
	return read;
}

unsigned int WavFileInStream::ReadPCM16(int16_t *buffer, unsigned int samples)
{
	if (_waveFormatInfo == NULL || _dataSize == 0)
		throw WavException("Tried reading from uninitialized wav file");

	if (_waveFormatInfo->GetCompression() != WavFmtChunk::PCM && _waveFormatInfo->GetCompression() != WavFmtChunk::IEEE_FLOAT)
		throw WavException("Unsupported audio format");

	if (_waveFormatInfo->GetCompression() == WavFmtChunk::PCM && _waveFormatInfo->GetBitsPerSample() == 16 && Endian::isHostLittleEndian())
		return Read(buffer, samples); // use native

	if (_position + samples > _dataSize / _waveFormatInfo->GetBlockAlign())
	{
		samples = (unsigned int)(_dataSize / _waveFormatInfo->GetBlockAlign() - _position);
	}

	_file.Seek((long)(_position*_waveFormatInfo->GetBlockAlign()+ _dataOffset), File::seekBeginning);

	unsigned int read;
	int16_t *ptr = buffer;
	for (read = 0; read < samples; read++)
	{
		for (int i = 0; i < _waveFormatInfo->GetChannels(); i++)
		{
			switch (_waveFormatInfo->GetCompression())
			{
			case WavFmtChunk::PCM:
				switch (_waveFormatInfo->GetBitsPerSample())
				{
				case 8:
					*ptr = (int16_t) (((int16_t)_file.GetU8()-128) * 256);
					break;
				case 16:
					*ptr = _file.GetI16();
					break;
				case 24:
					*ptr = (int16_t) (_file.GetI24() / 256);
					break;
				case 32:
					*ptr = (int16_t) (_file.GetI32() / (256 * 256));
					break;
				default:
					throw WavException("Unsupported bits per sample: %d", _waveFormatInfo->GetBitsPerSample());
				}
				break;
			case WavFmtChunk::IEEE_FLOAT:
				switch (_waveFormatInfo->GetBitsPerSample())
				{
				case 32:
					*ptr = (int16_t) (_file.GetFloat()*INT16_MAX);
					break;
				case 64:
					*ptr = (int16_t) (_file.GetDouble() * INT16_MAX);
					break;
				default:
					throw WavException("Unsupported bits per sample: %d", _waveFormatInfo->GetBitsPerSample());
				}
				break;
			default:
				throw WavException("Unsupported compression %d used", _waveFormatInfo->GetCompression());
			}
			ptr++;
		}
		_position += _waveFormatInfo->GetBlockAlign();
	}
	return read;
}

unsigned int WavFileInStream::GetBitsPerSample() const
{
	if (_waveFormatInfo == NULL)
		return 0;
	return _waveFormatInfo->GetBitsPerSample();
}

unsigned int WavFileInStream::GetSampleRate() const
{
	if (_waveFormatInfo == NULL)
		return 0;
	return _waveFormatInfo->GetSampleRate();
}

unsigned int WavFileInStream::GetChannels() const
{
	if (_waveFormatInfo == NULL)
		return 0;
	return _waveFormatInfo->GetChannels();
}

unsigned int WavFileInStream::Count() const
{
	if (_waveFormatInfo == NULL)
		return 0;
	return (unsigned int)(_dataSize/_waveFormatInfo->GetBlockAlign());
}

void WavFileInStream::Release()
{
	if (_waveFormatInfo != NULL)
		delete _waveFormatInfo;
}

void WavFileInStream::OpenWavFile(const char *path)
{
	try {
		_file = RawFile(path, File::openRawReadOnly, true);
		// Get first chunk
		WavChunk::ReadFromFile(_file);
		char riffType[4];
		riffType[0] = _file.GetI8();
		riffType[1] = _file.GetI8();
		riffType[2] = _file.GetI8();
		riffType[3] = _file.GetI8();
		if (!IsID("RIFF") || riffType[0] != 'W' || riffType[1] != 'A' || riffType[2] != 'V' || riffType[3] != 'E')
		{
			throw WavException("File is not a wave file");
		}
		ReadChunks();
	}
	catch (EndOfFileException)
	{
		throw WavException("EOF reached before filetype could be determined");
	}
}

void WavFileInStream::ReadChunks()
{
	// Read chunks
	while (!_file.IsEOF())
	{
		try {
			WavChunk chunkHeader(_file);
			chunkHeader.GotoPosition(_file);
			if (chunkHeader.IsID("fmt "))
			{
				if (_waveFormatInfo != NULL)
				{
					throw WavException("Multiple format chunks found");
				}
				_waveFormatInfo = new WavFmtChunk(_file);
			}
			else if (chunkHeader.IsID("data"))
			{
				if (_dataSize != 0)
					throw WavException("Multiple data segments not supported");
				_dataOffset = chunkHeader.GetLocation()+8;
				_dataSize = chunkHeader.ContentSize();
				_file.Seek((long)(_dataSize+8+_dataOffset), File::seekBeginning);
			}
			else {
				chunkHeader.Skip(_file);
			}
		}
		catch (EndOfFileException)
		{
			break;
		}
	}
}

WavFileOutStream::WavFileOutStream(const char *path, OutFormat compression, unsigned int sampleRate, unsigned int channels) :
	_waveFormatInfo(NULL), _file(true), _dataOffset(0), _dataSize(0), _factOffset(0)
{
	_chunks = new std::list<WavChunk *>;
	try
	{
		WavFmtChunk::CompressionCode code;
		int bps;
		switch (compression)
		{
		case PCM8:
			code = WavFmtChunk::PCM;
			bps = 8;
			break;
		case PCM16:
			code = WavFmtChunk::PCM;
			bps = 16;
			break;
		case PCM32:
			code = WavFmtChunk::PCM;
			bps = 32;
			break;
		case IEEE_FLOAT:
			code = WavFmtChunk::IEEE_FLOAT;
			bps = 32;
			break;
		case IEEE_DOUBLE:
			code = WavFmtChunk::IEEE_FLOAT;
			bps = 64;
			break;
		default:
			throw WavException("Unknown output format %d", compression);
		}
		SetFormat(code, bps, sampleRate, channels);
		CreateWavFile(path);
	}
	catch (...)
	{
		Release();
		throw;
	}
}

WavFileOutStream::~WavFileOutStream()
{
	Release();
	delete _chunks;
}

unsigned int WavFileOutStream::Write(void* buffer, unsigned int samples)
{
	if (_waveFormatInfo == NULL)
		return 0;

	/*
	// Goto end of datastream
	if (_file.GetPosition() != _dataOffset + _dataSize)
		_file.Seek(_dataOffset + _dataSize, File::seekBeginning);
	*/
	// Possible big endian error
	unsigned int written = (unsigned int)_file.Write(buffer, samples * _waveFormatInfo->GetBlockAlign());
	_dataSize += written;
	return written;
}

unsigned int WavFileOutStream::WriteFloat(float *buffer, unsigned int samples)
{
	if (_waveFormatInfo == NULL)
		return 0;

	if (_waveFormatInfo->GetCompression() == WavFmtChunk::IEEE_FLOAT && _waveFormatInfo->GetBitsPerSample() == 32 && Endian::isHostLittleEndian())
	{
		return Write(buffer, samples);
	}
	/*
	// Goto end of datastream
	if (_file.GetPosition() != _dataOffset + _dataSize)
		_file.Seek(_dataOffset + _dataSize, File::seekBeginning);
	*/
	unsigned int written;
	float *ptr = buffer;
	for (written = 0; written < samples; written++)
	{
		for (int i = 0; i < _waveFormatInfo->GetChannels(); i++)
		{
			float val = *ptr;
			if (val > 1.0f) val = 1.0f;
			else if (val < -1.0f) val = -1.0f;
			switch (_waveFormatInfo->GetCompression())
			{
			case WavFmtChunk::PCM:
				switch (_waveFormatInfo->GetBitsPerSample())
				{
				case 8:
					_file.PutU8((uint8_t)(val * INT8_MAX + 128));
					break;
				case 16:
					_file.PutI16((int16_t)(val * INT16_MAX));
					break;
				case 24:
					_file.PutI24((int32_t)(val * 8388607));
					break;
				case 32:
					_file.PutI32((int32_t)(val * INT32_MAX));
					break;
				default:
					throw WavException("Unsupported bits per sample: %d", _waveFormatInfo->GetBitsPerSample());
				}
				break;
			case WavFmtChunk::IEEE_FLOAT:
				switch (_waveFormatInfo->GetBitsPerSample())
				{
				case 32:
					_file.PutFloat(val);
					break;
				case 64:
					_file.PutDouble(val);
					break;
				default:
					throw WavException("Unsupported bits per sample: %d", _waveFormatInfo->GetBitsPerSample());
				}
				break;
			default:
				throw WavException("Unsupported compression %d used", _waveFormatInfo->GetCompression());
			}
			ptr++;
			_dataSize += (_waveFormatInfo->GetBitsPerSample() + 7) / 8;
		}
	}
	return written;
}

unsigned int WavFileOutStream::WritePCM16(int16_t *buffer, unsigned int samples)
{
	if (_waveFormatInfo == NULL)
		throw WavException("Tried writing to uninitialized wav file");

	if (_waveFormatInfo->GetCompression() == WavFmtChunk::PCM && _waveFormatInfo->GetBitsPerSample() == 16 && Endian::isHostLittleEndian())
	{
		return Write(buffer, samples);
	}
	/*
	// Goto end of datastream
	if (_file.GetPosition() != _dataOffset + _dataSize)
		_file.Seek(_dataOffset + _dataSize, File::seekBeginning);
		*/
	unsigned int written;
	int16_t *ptr = buffer;
	for (written = 0; written < samples; written++)
	{
		for (int i = 0; i < _waveFormatInfo->GetChannels(); i++)
		{
			switch (_waveFormatInfo->GetCompression())
			{
			case WavFmtChunk::PCM:
				switch (_waveFormatInfo->GetBitsPerSample())
				{
				case 8:
					_file.PutU8((*ptr >> 8) + 128);
					break;
				case 16:
					_file.PutI16(*ptr);
					break;
				case 24:
					_file.PutI24(*ptr << 8);
					break;
				case 32:
					_file.PutI32(*ptr << 16);
					break;
				default:
					throw WavException("Unsupported bits per sample: %d", _waveFormatInfo->GetBitsPerSample());
				}
				break;
			case WavFmtChunk::IEEE_FLOAT:
				switch (_waveFormatInfo->GetBitsPerSample())
				{
				case 32:
					_file.PutFloat(*ptr/(float)INT16_MAX);
					break;
				case 64:
					_file.PutDouble(*ptr / (double) INT16_MAX);
					break;
				default:
					throw WavException("Unsupported bits per sample: %d", _waveFormatInfo->GetBitsPerSample());
				}
				break;
			default:
				throw WavException("Unsupported compression %d used", _waveFormatInfo->GetCompression());
			}
			ptr++;
			_dataSize += (_waveFormatInfo->GetBitsPerSample() + 7)/8;
		}
	}

	return written;
}

unsigned int WavFileOutStream::WritePCM8(uint8_t *buffer, unsigned int samples)
{
	if (_waveFormatInfo == NULL)
		throw WavException("Tried writing to uninitialized wav file");

	if (_waveFormatInfo->GetCompression() == WavFmtChunk::PCM && _waveFormatInfo->GetBitsPerSample() == 8 && Endian::isHostLittleEndian())
	{
		return Write(buffer, samples);
	}
	/*
	// Goto end of datastream
	if (_file.GetPosition() != _dataOffset + _dataSize)
	_file.Seek(_dataOffset + _dataSize, File::seekBeginning);
	*/
	unsigned int written;
	uint8_t *ptr = buffer;
	for (written = 0; written < samples; written++)
	{
		for (int i = 0; i < _waveFormatInfo->GetChannels(); i++)
		{
			switch (_waveFormatInfo->GetCompression())
			{
			case WavFmtChunk::PCM:
				switch (_waveFormatInfo->GetBitsPerSample())
				{
				case 8:
					_file.PutU8(*ptr);
					break;
				case 16:
					_file.PutI16(*ptr << 8);
					break;
				case 24:
					_file.PutI24(*ptr << 16);
					break;
				case 32:
					_file.PutI32(*ptr << 24);
					break;
				default:
					throw WavException("Unsupported bits per sample: %d", _waveFormatInfo->GetBitsPerSample());
				}
				break;
			case WavFmtChunk::IEEE_FLOAT:
				switch (_waveFormatInfo->GetBitsPerSample())
				{
				case 32:
					_file.PutFloat(*ptr / (float) INT8_MAX);
					break;
				case 64:
					_file.PutDouble(*ptr / (double) INT8_MAX);
					break;
				default:
					throw WavException("Unsupported bits per sample: %d", _waveFormatInfo->GetBitsPerSample());
				}
				break;
			default:
				throw WavException("Unsupported compression %d used", _waveFormatInfo->GetCompression());
			}
			ptr++;
			_dataSize += (_waveFormatInfo->GetBitsPerSample() + 7) / 8;
		}
	}

	return written;
}

unsigned int WavFileOutStream::GetBitsPerSample() const
{
	if (_waveFormatInfo == NULL)
		return 0;
	return _waveFormatInfo->GetBitsPerSample();
}

unsigned int WavFileOutStream::GetSampleRate() const
{
	if (_waveFormatInfo == NULL)
		return 0;
	return _waveFormatInfo->GetSampleRate();
}

unsigned int WavFileOutStream::GetChannels() const
{
	if (_waveFormatInfo == NULL)
		return 0;
	return _waveFormatInfo->GetChannels();
}

unsigned int WavFileOutStream::Count() const
{
	if (_waveFormatInfo == NULL)
		return 0;
	return _dataSize / _waveFormatInfo->GetBlockAlign();
}

void WavFileOutStream::Release()
{
	if (_file.IsOpen())
	{
		if ((_dataSize & 1) != 0)
		{
			// Need to word align
			_file.Seek((long)(_dataOffset+_dataSize), File::seekBeginning);
			_file.PutU8(0);
		}
		// File is open so finish writing
		// Write all the chunks
		std::list<WavChunk *>::iterator it;
		for (it = _chunks->begin(); it != _chunks->end(); ++it)
		{
			(*it)->WriteToFile(_file);
			delete *it;
		}
		// Write datasize
		_file.Seek((long)(_dataOffset-4), File::seekBeginning);
		_file.PutU32(_dataSize);

		// Write number of samples per channel if there is a fact chunk
		if (_factOffset != 0 && _waveFormatInfo != NULL)
		{
			_file.Seek((long)(_factOffset), File::seekBeginning);
			_file.PutU32(_dataSize/_waveFormatInfo->GetBlockAlign());
		}

		// Write container size
		_file.Seek(4, File::seekBeginning);
		_file.PutU32(_file.GetSize()-8);
	}
	if (_waveFormatInfo != NULL)
		delete _waveFormatInfo;
}

void WavFileOutStream::CreateWavFile(const char *path)
{
	assert(_waveFormatInfo != NULL);
	_file = RawFile(path, File::openRawRWCreate);
	_file.PutC('R'); _file.PutC('I'); _file.PutC('F'); _file.PutC('F');
	_file.PutU32(0); // Empty size for now
	_file.PutC('W'); _file.PutC('A'); _file.PutC('V'); _file.PutC('E');

	// Write format table
	_waveFormatInfo->WriteToFile(_file);

	// Todo other sections
	if (_waveFormatInfo->GetCompression() != WavFmtChunk::PCM)
	{
		// Add fact chunk
		_file.PutC('f'); _file.PutC('a'); _file.PutC('c'); _file.PutC('t');
		_file.PutU32(4);
		_factOffset = _file.GetPosition();
		_file.PutU32(0);
	}

	// Initialize data section
	_file.PutC('d'); _file.PutC('a'); _file.PutC('t'); _file.PutC('a');
	_file.PutU32(0);
	_dataOffset = _file.GetPosition();

}

void WavFileOutStream::SetFormat(WavFmtChunk::CompressionCode compression, unsigned int bitsPerSample, unsigned int sampleRate, unsigned int channels)
{
	if (_waveFormatInfo != NULL)
	{
		delete _waveFormatInfo;
		_waveFormatInfo = NULL;
	}
	_waveFormatInfo = new WavFmtChunk();
	_waveFormatInfo->SetBitsPerSample(bitsPerSample);
	_waveFormatInfo->SetCompression(compression);
	_waveFormatInfo->SetChannels(channels);
	_waveFormatInfo->SetSampleRate(sampleRate);
	_waveFormatInfo->SetBlockAlign(channels * ((bitsPerSample+7)/8));
	_waveFormatInfo->SetBytesPerSecond(_waveFormatInfo->GetBlockAlign() * sampleRate);
}


text:
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace SST.Playground.Models.Mapping
{
    public class EventMap : EntityTypeConfiguration<Event>
    {
        public EventMap()
        {
            // Primary Key
            this.HasKey(t => t.EventId);

            // Properties
            this.Property(t => t.Title)
                .IsRequired()
                .HasMaxLength(512);

            this.Property(t => t.Description)
                .IsRequired();

            // Table & Column Mappings
            this.ToTable("Events");
            this.Property(t => t.EventId).HasColumnName("EventId");
            this.Property(t => t.UserId).HasColumnName("UserId");
            this.Property(t => t.Title).HasColumnName("Title");
            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.StartTime).HasColumnName("StartTime");
            this.Property(t => t.EndTime).HasColumnName("EndTime");
            this.Property(t => t.Latitude).HasColumnName("Latitude");
            this.Property(t => t.Longitude).HasColumnName("Longitude");
            this.Property(t => t.Address).HasColumnName("Address");
            this.Property(t => t.EventType).HasColumnName("EventType");
            this.Property(t => t.EventSocialType).HasColumnName("EventSocialType");
            this.Property(t => t.EventWorkingHourType).HasColumnName("EventWorkingHourType");
            this.Property(t => t.IsActive).HasColumnName("IsActive");
        }
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <TextView
        android:id="@+id/match"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="@string/match"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <include
        android:id="@+id/item1"
        layout="@layout/item_message" />

    <View
        android:id="@+id/divider"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginStart="24dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="24dp"
        android:background="?dividerHorizontal" />

    <include
        android:id="@+id/item2"
        layout="@layout/item_message" />

</LinearLayout>


text:
package org.orekit.data;

import java.util.Arrays;

import org.apache.commons.math3.RealFieldElement;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.util.MathArrays;
import org.orekit.errors.OrekitException;

/** Base class for nutation series terms.
 * @param <T> the type of the field elements
 * @author Luc Maisonobe
 * @see PoissonSeries
 */
abstract class SeriesTerm<T extends RealFieldElement<T>> {

    /** Coefficients for the sine part. */
    private double[][] sinCoeff;

    /** Coefficients for the cosine part. */
    private double[][] cosCoeff;

    /** Simple constructor for the base class.
     */
    protected SeriesTerm() {
        this.sinCoeff = new double[0][0];
        this.cosCoeff = new double[0][0];
    }

    /** Get the degree of the function component.
     * @param index index of the function component (must be less than dimension)
     * @return degree of the function component
     */
    public int getDegree(final int index) {
        return  sinCoeff[index].length - 1;
    }

    /** Add a pair of values to existing term coefficients.
     *

     * Despite it would seem logical to simply set coefficients
     * rather than add to them, this does not work for some IERS
     * files. As an example in table 5.3a in IERS conventions 2003,
     * the coefficients for luni-solar term for 2F+Ω with period
     * 13.633 days appears twice with different coefficients, as
     * well as term for 2(F+D+Ω)+l with period 5.643 days, term for
     * 2(F+D+Ω)-l with period 9.557 days, term for 2(Ω-l') with
     * period -173.318 days, term for 2D-l with period 31.812 days ...
     * 35 different duplicated terms have been identified in the
     * tables 5.3a and 5.3b in IERS conventions 2003.
     * The coefficients read in lines duplicating a term must be
     * added together.
     *

     * @param index index of the components (will automatically
     * increase dimension if needed)
     * @param degree degree of the coefficients, may be negative if
     * the term does not contribute to component (will automatically
     * increase {@link #getDegree() degree} of the component if needed)
     * @param sinID coefficient for the sine part, at index and degree
     * @param cosID coefficient for the cosine part, at index and degree
     */
    public void add(final int index, final int degree,
                    final double sinID, final double cosID) {
        sinCoeff = extendArray(index, degree, sinCoeff);
        cosCoeff = extendArray(index, degree, cosCoeff);
        if (degree >= 0) {
            sinCoeff[index][degree] += sinID;
            cosCoeff[index][degree] += cosID;
        }
    }

    /** Get a coefficient for the sine part.
     * @param index index of the function component (must be less than dimension)
     * @param degree degree of the coefficients
     * (must be less than {@link #getDegree() degree} for the component)
     * @return coefficient for the sine part, at index and degree
     */
    public double getSinCoeff(final int index, final int degree) {
        return sinCoeff[index][degree];
    }

    /** Get a coefficient for the cosine part.
     * @param index index of the function component (must be less than dimension)
     * @param degree degree of the coefficients
     * (must be less than {@link #getDegree() degree} for the component)
     * @return coefficient for the cosine part, at index and degree
     */
    public double getCosCoeff(final int index, final int degree) {
        return cosCoeff[index][degree];
    }

    /** Evaluate the value of the series term.
     * @param elements bodies elements for nutation
     * @return value of the series term
     */
    public double[] value(final BodiesElements elements) {

        // preliminary computation
        final double tc  = elements.getTC();
        final double a   = argument(elements);
        final double sin = FastMath.sin(a);
        final double cos = FastMath.cos(a);

        // compute each function
        final double[] values = new double[sinCoeff.length];
        for (int i = 0; i < values.length; ++i) {
            double s = 0;
            double c = 0;
            for (int j = sinCoeff[i].length - 1; j >= 0; --j) {
                s = s * tc + sinCoeff[i][j];
                c = c * tc + cosCoeff[i][j];
            }
            values[i] = s * sin + c * cos;
        }

        return values;

    }

    /** Compute the argument for the current date.
     * @param elements luni-solar and planetary elements for the current date
     * @return current value of the argument
     */
    protected abstract double argument(final BodiesElements elements);

    /** Evaluate the value of the series term.
     * @param elements bodies elements for nutation
     * @return value of the series term
     */
    public T[] value(final FieldBodiesElements<T> elements) {

        // preliminary computation
        final T tc  = elements.getTC();
        final T a   = argument(elements);
        final T sin = a.sin();
        final T cos = a.cos();

        // compute each function
        final T[] values = MathArrays.buildArray(tc.getField(), sinCoeff.length);
        for (int i = 0; i < values.length; ++i) {
            T s = tc.getField().getZero();
            T c = tc.getField().getZero();
            for (int j = sinCoeff[i].length - 1; j >= 0; --j) {
                s = s.multiply(tc).add(sinCoeff[i][j]);
                c = c.multiply(tc).add(cosCoeff[i][j]);
            }
            values[i] = s.multiply(sin).add(c.multiply(cos));
        }

        return values;

    }

    /** Compute the argument for the current date.
     * @param elements luni-solar and planetary elements for the current date
     * @return current value of the argument
     */
    protected abstract T argument(final FieldBodiesElements<T> elements);

    /** Factory method for building the appropriate object.
     *
The method checks the null coefficients and build an instance
     * of an appropriate type to avoid too many unnecessary multiplications
     * by zero coefficients.

     * @param <S> the type of the field elements
     * @param cGamma coefficient for γ = GMST + π tide parameter
     * @param cL coefficient for mean anomaly of the Moon
     * @param cLPrime coefficient for mean anomaly of the Sun
     * @param cF coefficient for L - Ω where L is the mean longitude of the Moon
     * @param cD coefficient for mean elongation of the Moon from the Sun
     * @param cOmega coefficient for mean longitude of the ascending node of the Moon
     * @param cMe coefficient for mean Mercury longitude
     * @param cVe coefficient for mean Venus longitude
     * @param cE coefficient for mean Earth longitude
     * @param cMa coefficient for mean Mars longitude
     * @param cJu coefficient for mean Jupiter longitude
     * @param cSa coefficient for mean Saturn longitude
     * @param cUr coefficient for mean Uranus longitude
     * @param cNe coefficient for mean Neptune longitude
     * @param cPa coefficient for general accumulated precession in longitude
     * @return a nutation serie term instance well suited for the set of coefficients
     */
    public static <S extends RealFieldElement<S>> SeriesTerm<S> buildTerm(final int cGamma,
                                                                          final int cL, final int cLPrime, final int cF,
                                                                          final int cD, final int cOmega,
                                                                          final int cMe, final int cVe, final int cE,
                                                                          final int cMa, final int cJu, final int cSa,
                                                                          final int cUr, final int cNe, final int cPa) {
        if (cGamma == 0 && cL == 0 && cLPrime == 0 && cF == 0 && cD == 0 && cOmega == 0) {
            return new PlanetaryTerm<S>(cMe, cVe, cE, cMa, cJu, cSa, cUr, cNe, cPa);
        } else if (cGamma == 0 &&
                   cMe == 0 && cVe == 0 && cE == 0 && cMa == 0 && cJu == 0 &&
                   cSa == 0 && cUr == 0 && cNe == 0 && cPa == 0) {
            return new LuniSolarTerm<S>(cL, cLPrime, cF, cD, cOmega);
        } else if (cGamma != 0 &&
                   cMe == 0 && cVe == 0 && cE == 0 && cMa == 0 && cJu == 0 &&
                   cSa == 0 && cUr == 0 && cNe == 0 && cPa == 0) {
            return new TideTerm<S>(cGamma, cL, cLPrime, cF, cD, cOmega);
        } else if (cGamma == 0 && cLPrime == 0 && cUr == 0 && cNe == 0 && cPa == 0) {
            return new NoFarPlanetsTerm<S>(cL, cF, cD, cOmega,
                                           cMe, cVe, cE, cMa, cJu, cSa);
        } else if (cGamma == 0) {
            return new GeneralTerm<S>(cL, cLPrime, cF, cD, cOmega,
                                      cMe, cVe, cE, cMa, cJu, cSa, cUr, cNe, cPa);
        } else {
            throw OrekitException.createInternalError(null);
        }

    }

    /** Extend an array to old at least index and degree.
     * @param index index of the function
     * @param degree degree of the coefficients
     * @param array to extend
     * @return extended array
     */
    private static double[][] extendArray(final int index, final int degree,
                                          final double[][] array) {

        // extend the number of rows if needed
        final double[][] extended;
        if (array.length > index) {
            extended = array;
        } else {
            extended = new double[index + 1][];
            System.arraycopy(array, 0, extended, 0, array.length);
            Arrays.fill(extended, array.length, index + 1, new double[0]);
        }

        // extend the number of elements in the row if needed
        extended[index] = extendArray(degree, extended[index]);

        return extended;

    }

    /** Extend an array to old at least index and degree.
     * @param degree degree of the coefficients
     * @param array to extend
     * @return extended array
     */
    private static double[] extendArray(final int degree, final double[] array) {
        // extend the number of elements if needed
        if (array.length > degree) {
            return array;
        } else {
            final double[] extended = new double[degree + 1];
            System.arraycopy(array, 0, extended, 0, array.length);
            return extended;
        }
    }

}


text:
/*
This file in the main entry point for defining Gulp tasks and using Gulp plugins.
Click here to learn more. http://go.microsoft.com/fwlink/?LinkId=518007
*/

'use strict'
var gulp = require('gulp');
var webpack = require('webpack');
var gutil = require('gulp-util');
var inject = require('gulp-inject');
var runSequence = require('run-sequence');
const zip = require('gulp-zip');
var nodemon = require('nodemon');
var fs = require('fs');
var replace = require('gulp-replace');

var injectSources = ["./dist/web/scripts/**/*.js", "./dist/web/assets/**/*.css"]
var typeScriptFiles = ["./tabs/src/**/*.ts"]
var staticFiles = ["./tabs/src/app/**/*.html", "./tabs/src/app/web/assets/**/*"]
var htmlFiles = ["./tabs/src/app/**/*.html"]
var watcherfiles = ["./tabs/src/**/*.*"]
var manifestFiles = ["./tabs/src/manifest/**/*.*"]

/**
 * Watches source files and invokes the build task
 */
gulp.task('watch', function () {
    gulp.watch('./src/**/*.*', ['build']);
});

/**
 * Creates the tab manifest
 */
gulp.task('manifest', () => {
    // This file isnt commited to source as its the keys, normally this runs via VSOnline build pipeline variables
    var botId = fs.readFileSync("botid.txt", "utf8");

    gulp.src('TeamsAppPackage/*')
        .pipe(replace('%BOT_FRAMEWORK_ID%', botId))
        .pipe(zip('silverstoneteamsapp.zip'))
        .pipe(gulp.dest('dist'))
});

/**
 * Webpack bundling
 */
gulp.task('webpack', function (callback) {
    var webpackConfig = require(process.cwd() + '/webpack.config')
    webpack(webpackConfig
        , function (err, stats) {
            if (err) throw new gutil.PluginError("webpack", err);

            var jsonStats = stats.toJson();
            if (jsonStats.errors.length > 0) {
                var errs =
                    jsonStats.errors.map(function (e) {
                        gutil.log('[Webpack error] ' + e)
                    });
                throw new gutil.PluginError("webpack", "Webpack errors, see log");
            }
            if (jsonStats.warnings.length > 0) {
                var errs =
                    jsonStats.warnings.map(function (e) {
                        gutil.log('[Webpack warning] ' + e)
                    });

            }
            gutil.log("[Webpack]\n", stats.toString('minimal'));
            callback();
        });
});

/**
 * Copies static files
 */
gulp.task('static:copy', function () {
    return gulp.src(staticFiles, { base: "./tabs/src/app" })
        .pipe(gulp.dest('./dist/'));
})

/**
 * Injects script into pages
 */
gulp.task('static:inject', ['static:copy'], function () {

    var injectSrc = gulp.src(injectSources);

    var injectOptions = {
        relative: false,
        ignorePath: 'dist/web',
        addRootSlash: false
    };

    return gulp.src(htmlFiles)
        .pipe(inject(injectSrc, injectOptions)) // inserts custom sources
        .pipe(gulp.dest('./dist'));
});

/**
 * Build task, that uses webpack and injects scripts into pages
 */
gulp.task('build', function () {
    runSequence('webpack', 'static:inject')
});

/**
 * Task for local debugging
 */
gulp.task('serve', ['build', 'watch'], function (cb) {
    var started = false;
    return nodemon({
        script: 'dist/server.js',
        watch: ['dist/server.js']
    }).on('start', function () {
        if (!started) {
            cb();
            started = true;
        }
    });
});


text:
from django.test import TestCase
from .factories import GalleryFactory

class RequestGalleryTest(TestCase):

    urls = 'photologue.tests.test_urls'

    def setUp(self):
        super(RequestGalleryTest, self).setUp()
        self.gallery = GalleryFactory(slug='test-gallery')

    def test_archive_gallery_url_works(self):
        response = self.client.get('/ptests/gallery/')
        self.assertEqual(response.status_code, 200)

    def test_archive_gallery_empty(self):
        """If there are no galleries to show, tell the visitor - don't show a
        404."""

        self.gallery.is_public = False
        self.gallery.save()

        response = self.client.get('/ptests/gallery/')
        self.assertEqual(response.status_code, 200)

        self.assertEqual(response.context['latest'].count(),
                         0)

    def test_paginated_gallery_url_works(self):
        response = self.client.get('/ptests/gallerylist/')
        self.assertEqual(response.status_code, 200)

    def test_gallery_works(self):
        response = self.client.get('/ptests/gallery/test-gallery/')
        self.assertEqual(response.status_code, 200)

    def test_archive_year_gallery_works(self):
        response = self.client.get('/ptests/gallery/2011/')
        self.assertEqual(response.status_code, 200)

    def test_archive_month_gallery_works(self):
        response = self.client.get('/ptests/gallery/2011/12/')
        self.assertEqual(response.status_code, 200)

    def test_archive_day_gallery_works(self):
        response = self.client.get('/ptests/gallery/2011/12/23/')
        self.assertEqual(response.status_code, 200)

    def test_detail_gallery_works(self):
        response = self.client.get('/ptests/gallery/2011/12/23/test-gallery/')
        self.assertEqual(response.status_code, 200)

    def test_redirect_to_list(self):
        """Trivial test - if someone requests the root url of the app
        (i.e. /ptests/'), redirect them to the gallery list page."""
        response = self.client.get('/ptests/')
        self.assertRedirects(response, '/ptests/gallery/', 301, 200)

class GalleryPaginationTest(TestCase):

    urls = 'photologue.tests.test_urls'

    def test_pagination(self):
        for i in range(1, 23):
            GalleryFactory(title='gallery{0:0>3}'.format(i))

        response = self.client.get('/ptests/gallerylist/')
        self.assertEqual(response.status_code, 200)

        self.assertEqual(len(response.context['object_list']),
                         20)
        # Check first and last items.
        self.assertEqual(response.context['object_list'][0].title,
                         'gallery022')
        self.assertEqual(response.context['object_list'][19].title,
                         'gallery003')

        # Now get the second page of results.
        response = self.client.get('/ptests/gallerylist/?page=2')
        self.assertEqual(response.status_code, 200)

        self.assertEqual(len(response.context['object_list']),
                         2)
        # Check first and last items.
        self.assertEqual(response.context['object_list'][0].title,
                         'gallery002')
        self.assertEqual(response.context['object_list'][1].title,
                         'gallery001')


text:
Hello, world.

I've lived here my whole life. I can't believe we haven't met before, world.

The pleasure is all mine. Or, hopefully it's both of ours.


text:
      <slot name="state-icon-holder"></slot>

      <slot name="text"></slot>

    <slot name="extra-button"></slot>


text:
export const environment = {
  production: true,
  version: require('../../package.json').version,
  jsonPort: 3000,
  websocketPort: 3000,
  websocketPath: '/ws',
};


text:
'use strict'
var url = require('url')
var asyncMap = require('slide').asyncMap
var validate = require('aproba')
var iferr = require('iferr')
var realizePackageSpecifier = require('realize-package-specifier')
var fetchPackageMetadata = require('../fetch-package-metadata.js')
var annotateMetadata = require('../fetch-package-metadata.js').annotateMetadata
var addShrinkwrap = require('../fetch-package-metadata.js').addShrinkwrap
var addBundled = require('../fetch-package-metadata.js').addBundled
var inflateBundled = require('./inflate-bundled.js')
var npm = require('../npm.js')
var createChild = require('./node.js').create
var moduleName = require('../utils/module-name.js')
var childPath = require('../utils/child-path.js')

var inflateShrinkwrap = module.exports = function (tree, swdeps, finishInflating) {
  validate('OOF', arguments)
  if (!npm.config.get('shrinkwrap')) return finishInflating()
  var onDisk = {}
  tree.children.forEach(function (child) { onDisk[moduleName(child)] = child })
  tree.children = []
  asyncMap(Object.keys(swdeps), function (name, next) {
    var sw = swdeps[name]
    var spec = sw.resolved
             ? name + '@' + sw.resolved
             : (sw.from && url.parse(sw.from).protocol)
             ? name + '@' + sw.from
             : name + '@' + sw.version
    var child = onDisk[name]
    if (child && (child.fromShrinkwrap ||
                  (sw.resolved && child.package._resolved === sw.resolved) ||
                  (sw.from && url.parse(sw.from).protocol && child.package._from === sw.from) ||
                  child.package.version === sw.version)) {
      if (!child.fromShrinkwrap) child.fromShrinkwrap = spec
      tree.children.push(child)

      return realizePackageSpecifier(spec, tree.path, iferr(next, function (requested) {
        annotateMetadata(child.package, requested, spec, tree.path)
        return inflateShrinkwrap(child, sw.dependencies || {}, next)
      }))
    }
    fetchPackageMetadata(spec, tree.path, iferr(next, function (pkg) {
      pkg._from = sw.from || spec
      addShrinkwrap(pkg, iferr(next, function () {
        addBundled(pkg, iferr(next, function () {
          var child = createChild({
            package: pkg,
            loaded: false,
            parent: tree,
            fromShrinkwrap: spec,
            path: childPath(tree.path, pkg),
            realpath: childPath(tree.realpath, pkg),
            children: pkg._bundled || []
          })
          tree.children.push(child)
          if (pkg._bundled) {
            delete pkg._bundled
            inflateBundled(child, child.children)
          }
          inflateShrinkwrap(child, sw.dependencies || {}, next)
        }))
      }))
    }))
  }, finishInflating)
}


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

namespace UnityTools.SceneManager
{
    /// <summary>
    ///     Args for events notifying that a scene has finished loading.
    /// </summary>
    /// <remarks>
    ///     We make the class inherit from EventArgs so the scene manager can raise
    ///     events, howerver they are used as parameters in serveral Action<SceneLoadingArgs>
    ///     callbacks so this class is not only used in events.
    /// </remarks>
    public class SceneLoadingArgs : EventArgs
    {
        // Register the load start time and when the scene finished loading.
        private long _loadStartTime, _loadLoadEndTime;
        private static int NextId = 1;
        private int _id;
        private Action<SceneLoadingArgs> _loadSceneStepCallback;
        private UnityEngine.AsyncOperation _asyncOp;

        public SceneLoadingArgs(string sceneName,
                                bool loadAdditive,
                                bool loadAsync,
                                Action<SceneLoadingArgs> loadSceneStepCallback)

        {
            if (string.IsNullOrEmpty(sceneName)) throw new ArgumentNullException ("sceneName");

            _id = NextId++;
            _loadStartTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
            _loadSceneStepCallback = loadSceneStepCallback;

            SceneName = sceneName;
            IsSceneLoadingAdditive = loadAdditive;
            IsSceneLoadingAsync = loadAsync;
        }

        internal void SaveAsyncOperationReference(UnityEngine.AsyncOperation asyncOp)
        {
            _asyncOp = asyncOp;
        }

        /// <summary>
        ///     Name of the scene being loaded
        /// </summary>
        public string SceneName {get; private set; }

        /// <summary>
        ///     True if the scene was loaded additive: contents of the newly scene are added to the scene
        ///     currently playing.
        /// </summary>
        public bool IsSceneLoadingAdditive {get; private set; }

        /// <summary>
        ///     True if the scene was loaded asyncronously
        /// </summary>
        public bool IsSceneLoadingAsync {get; private set; }

        /// <summary>
        ///     Loading progress percent. Range is [0,1]
        /// </summary>
        public float LoadingProgress { get; private set;}

        /// <summary>
        ///   True if the scene was loaded in memory.
        ///   Note: for async loaded scenes, the scene may be loaded in memory but not activated
        ///   meaning, the scene contents are not available yet in the scene tree.
        /// </summary>
        public bool IsSceneInMemory  {get; private set; }

        /// <summary>
        ///   True if the scene was loaded and ready to use.
        /// </summary>
        public bool IsSceneLoaded { get { return IsSceneInMemory && IsSceneActivated; } }

        /// <summary>
        ///   True if the scene is active in unity. Call ActivateScene() to actually activate a loaded scene
        /// </summary>
        public bool IsSceneActivated {get; private set;}

        /// <summary>
        ///     If <c>true</c> the scene will activate automatically (loaded in the scene tree)
        ///     after loading.
        /// </summary>
        /// <default>true</default>
        public bool IsSceneActivatedOnLoad
        {
            get
            {
                return _asyncOp == null? true : _asyncOp.allowSceneActivation;
            }
        }

        /// <summary>
        ///     Call this method for scenes loaded asynchronously to activate the scene in unity and
        ///     load its contents into the scene tree.
        /// </summary>
        /// <remarks>
        ///     You can call this method even if the scene has not finished loading, in which case
        ///     the scene will be activated after is finished loading, effectively behaving as if
        ///     the IsSceneActivatedOnLoad flag were set to true.
        /// </remarks>
        public void ActivateScene()
        {
            if (_asyncOp == null) return;
            _asyncOp.allowSceneActivation = true;
        }

        /// <summary>
        ///     Time that took the scene to load
        /// </summary>
        public long ElapsedMsecs
        {
            get
            {
                if (IsSceneInMemory) return _loadLoadEndTime - _loadStartTime;
                return (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) - _loadStartTime;
            }
        }

        /// <summary>
        ///     Time when the scene finished loading
        /// </summary>
        public long LoadEndTime
        {
            get
            {
                return IsSceneInMemory? _loadLoadEndTime : 0;
            }
        }

        internal void NotifySceneLoadingProgress(float progress)
        {
            if (IsSceneInMemory) throw new Exception("Scene load finished, Progress update not allowed");

            LoadingProgress = progress;

            OnLoadSceneStep();
        }

        internal void NotifySceneLoaded()
        {
            IsSceneInMemory = true;
            LoadingProgress = 1.0f;

            OnLoadSceneStep();
        }

        internal void NotifySceneLoadedAndActive()
        {
            if (IsSceneInMemory) return;

            IsSceneInMemory = true;
            IsSceneActivated = true;

            LoadingProgress = 1.0f;
            _loadLoadEndTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;

            _asyncOp = null;

            OnLoadSceneStep();
        }

        public override string ToString()
        {
            return string.Format("Scene \"{0}\"{1}{2} Id:{3}",
                SceneName,
                IsSceneLoadingAdditive? " Additive" : string.Empty,
                IsSceneLoadingAsync? " Async" : string.Empty,
                _id);
        }

        void OnLoadSceneStep()
        {
            if (_loadSceneStepCallback != null)
            {
                _loadSceneStepCallback(this);
            }
        }
    }

    /// <summary>
    ///     Central point for loading scenes either syncronous or asynchronous.
    ///     When loading scenes in an async way the SceneManager manages the loading process,
    ///     so you don't need to spawn Coroutines.
    ///
    ///     The SceneManager keeps track of:
    ///     - The name of the scene used to initialize the game (allows testing individual
    ///         scenes along the project depending on which scene you started from)
    ///     - The names of the scenes loaded in the game and the order in which they were loaded.
    ///       You'll need to put the inspector in debug mode to check this information
    ///
    ///     When loading a new scene you can be notified of the progress using these events:
    ///         SceneWillLoad:              raised when the SceneManager starts to load the scene
    ///
    ///         SceneDidLoad:               raised when the SceneManager finished loading the scene
    ///                                     and the elements of the scene are accesible
    ///
    ///         AsyncSceneLoadingProgress:  raised periodically to notify the load progress when
    ///                                     a scene is being loaded asynchronous
    ///
    ///     When loading an scene in an asynchronous way, the method will return a SceneLoadingArgs
    ///     instance, that raises events notifying only of the that scene loading progress or if the
    ///     scene finished loading. This serves as a simple way to attach a listener if you only are
    ///     interested on the events related to that scene. It is similar to the AsyncOperation
    ///     instance returned by the Application.LoadLevelAsync methods but they are not an
    ///     IEnumerator and thus they can't called with a Coroutine. No need to worry: the SceneManager
    ///     will take care of this plumbing.
    /// </summary>
    /// <remarks>
    ///     Monobehaviour Singleton: either if accessed by code or added to a scene this script will
    ///     always be located inside a GameObject marked as DontDestroyOnLoad so it lives during
    ///     all the execution of the app.
    ///     This MonoBehaviour should be the first thing executed when the app starts so remember
    ///     to update the ScriptExecutionOrder in the ProjectSettings
    /// </remarks>
    public class SceneManager : MonoBehaviourSingleton<SceneManager>
    {
        [Range(0.8f, 1f)]
        public float PercentTriggerSceneLoaded = 0.9f;

        #region State
        // We use fields so its values shows up in the inspector on debug mode
        private string _initialSceneName;
        private int _initialSceneIndex;
        List<string> _loadedScenes = new List<string>();

        SceneLoadingArgs CurrentlyLoadingSceneArgs{ get; set; }
        #endregion

        /// <summary>
        ///     Raised when the SceneManager starts to load the scene
        /// </summary>
        public event EventHandler<SceneLoadingArgs> SceneWillLoad;

        /// <summary>
        ///     Raised when the SceneManager finished loading the scene
        ///     and the elements of the scene are accesible
        /// </summary>
        public event EventHandler<SceneLoadingArgs> SceneDidLoad;

        /// <summary>
        ///     Raised periodically to notify the load progress when a scene is being
        ///     loaded asynchronous
        /// </summary>
        public event EventHandler<SceneLoadingArgs> AsyncSceneLoadingProgress;

        /// <summary>
        ///     Returns the name of the scene used to initializea the game
        /// </summary>
        /// <value>The initial name of the scene.</value>
        public string InitialSceneName { get {return _initialSceneName; } }

        /// <summary>
        ///     Returns the index of the scene used to initialize the game
        /// </summary>
        /// <value>The initial name of the scene.</value>
        public int InitialSceneIndex { get {return _initialSceneIndex; } }

        /// <summary>
        ///     Returns true if we are currently loading an scene.
        /// </summary>
        public bool IsLoadingScene { get { return CurrentlyLoadingSceneArgs != null; } }

        public System.Collections.ObjectModel.ReadOnlyCollection<string> LoadedScenes
        {
            get
            {
                return _loadedScenes.AsReadOnly();
            }

        }

        /// <summary>
        ///     Adds the contents of the scene with the given name to the current scene and the waits one frame
        ///     so all the newly loaded objects are actually accessible.
        ///     The SceneDidLoad event is raised after that frame has passed
        ///     This is equivalent to Application.LoadLevelAdditive() method
        /// </summary>
        /// <param name="sceneName">
        ///     The scene name which contents will be added to the current scene
        /// </param>
        /// <param name="finishedCallback">
        ///     This optional callback will be called when all the scenes have been loaded and one frame has passed,
        ///     which is the moment the contents of the scenes are actually accesible by code.
        /// </param>
        public void AddScene(string sceneName, Action<SceneLoadingArgs> finishedCallback = null)
        {
            var loadArgs = new SceneLoadingArgs(sceneName, true, false, finishedCallback);

            PrintLog("Start {0}", loadArgs);

            OnSceneWillLoad(loadArgs);

            Application.LoadLevelAdditive(loadArgs.SceneName);

            // Wait one frame so the GameObjects of the loaded scene are accesible, and then
            // this scene will be added to the list of loaded scenes
            StartCoroutine(WaitOneFrameUntilSceneIsAvailableCO(loadArgs));
        }

        /// <summary>
        ///     Adds the contents of a list of scenes to the current scene. After all the scenes are loaded
        ///     it waits one frame so all the newly loaded objects in all the scenes are accessible
        /// </summary>
        /// <param name="sceneNames">
        ///     A list with the names of the scenes to be added to the current scene. Scenes are added in
        ///     the order they appear in the list.
        /// </param>
        /// <param name="finishedCallback">
        ///     This optional callback will be called when all the scenes have been loaded and one frame has passed,
        ///     which is the moment the contents of the scenes are actually accesible by code.
        /// </param>
        public void AddScenes(IList<string> sceneNames, Action<SceneLoadingArgs> finishedCallback = null)
        {
            if (sceneNames.Count <= 0) return;

            int i = 0;
            SceneLoadingArgs loadArgs = null;

            do
            {
                loadArgs = new SceneLoadingArgs(sceneNames[i], true, false, finishedCallback);
                PrintLog("Start {0}", loadArgs);
                OnSceneWillLoad(loadArgs);
                Application.LoadLevelAdditive(loadArgs.SceneName);
                CurrentlyLoadingSceneArgs = null;
                i++;

            } while(i < sceneNames.Count);

            CurrentlyLoadingSceneArgs = loadArgs;

            // Wait one frame so the GameObjects of the loaded scene are accesible, and then
            // this scene will be added to the list of loaded scenes
            StartCoroutine(WaitOneFrameUntilSceneIsAvailableCO(loadArgs));
        }

        /// <summary>
        ///     Adds the contents of the scene with the given name to the current scene in an asynchronous process
        ///     so all the newly loaded objects are actually accessible. The scene is activated after it has
        ///     finished loading.
        ///     The SceneDidLoad event is raised after that frame has passed
        ///     This is equivalent to Application.LoadLevelAdditive() method
        /// </summary>
        /// <param name="sceneName">
        ///     The scene name which contents will be added to the current scene
        /// </param>
        /// <returns>
        ///     An SceneLoadingArgs instance that allows subscribing to events related
        ///     to this scene loading process
        /// </returns>
        /// <param name="finishedCallback">
        ///     This callback is called each frame until the scene is being loaded, so you can query the
        ///     loading progress, using SceneLoadingArgs.Progress. The callback is called one last
        ///     time when the scene has actually finished loading, has been loaded, and the elements in
        ///     the scene are accesible by code.
        ///     The property SceneLoadingArgs.IsLoaded can be queried to check in which of the
        ///     two states we are.
        /// </param>
        public void AddSceneAsync(string sceneName, Action<SceneLoadingArgs> finishedCallback = null)
        {
            AddSceneAsyncInternal(sceneName, true, finishedCallback);
        }

        /// <summary>
        ///     Adds the contents of the scene with the given name to the current scene in an asynchronous process
        ///     so all the newly loaded objects are actually accessible. The scene is NOT activated after it has
        ///     finished loading, you need to use the SceneLoadingArgs instance passed in the callback method
        ///     to manually activate the scene after it finished loading.
        ///
        ///     The SceneDidLoad event is raised after one frame has passed after the activation of the scene
        ///     This is equivalent to Application.LoadLevelAdditive() method and setting the
        ///     AsyncOperation.allowSceneActivation property returned by that method call to false.
        /// </summary>
        /// <param name="sceneName">
        ///     The scene name which contents will be added to the current scene
        /// </param>
        /// <returns>
        ///     An SceneLoadingArgs instance that allows subscribing to events related
        ///     to this scene loading process
        /// </returns>
        /// <param name="finishedCallback">
        ///     This callback is called each frame until the scene is being loaded, so you can query the
        ///     loading progress, using SceneLoadingArgs.Progress.
        ///     When the scene has finished loading, the callback is called once again to notify about this
        ///     and will wait until you manually call SceneLoadingArgs.ActivateScene() to actually load the
        ///     scene into Unity's scene tree
        ///     The callback is called one last time after the scene is activated and when the elements in
        ///     the scene are accesible by code.
        ///     The properties SceneLoadingArgs.IsLoaded and SceneLoadingArgs.IsActivated can be queried to check in which
        ///     state of the loading progress we are.
        /// </param>
        public void AddSceneAsyncWaitActivation(string sceneName, Action<SceneLoadingArgs> finishedCallback)
        {
            AddSceneAsyncInternal(sceneName, false, finishedCallback);
        }

        /// <summary>
        ///     Changes the current scene to the new one specified.
        ///     All GameObjects in the current scene will be deleted (except those marked as
        ///     DontDestroyOnLoad) and replaced by the contents of the new scene.
        /// </summary>
        /// <param name="sceneName">
        ///     The new scene to load
        /// </param>
        /// <param name="finishedCallback">
        ///     When the scene has been loaded and a frame has passed, this callback is called
        /// </param>
        public void ChangeSceneTo(string sceneName, Action<SceneLoadingArgs> finishedCallback = null)
        {
            var loadArgs = new SceneLoadingArgs(sceneName, false, false, finishedCallback);

            PrintLog("Start {0}", loadArgs);

            OnSceneWillLoad(loadArgs);

            Application.LoadLevel(loadArgs.SceneName);

            StartCoroutine(WaitOneFrameUntilSceneIsAvailableCO(loadArgs));
        }

        /// <summary>
        ///     Changes the current scene to the new one specified in an asynchronous way.
        ///     All GameObjects in the current scene will be deleted (except those marked as DontDestroyOnLoad) and
        ///     replaced by the contents of the new scene.
        /// </summary>
        /// <param name="sceneName">
        ///     The new scene to load.
        /// </param>
        /// <param name="activateOnLoad">
        ///     If set to <c>true</c> the GameObjects in the scene will activate automatically
        ///     when the scene is finished loading.
        /// </param>
        /// <param name="finishedCallback">
        ///     This callback is called each frame until the scene is loaded, so you can query the loading progress,
        ///     using SceneLoadingArgs.Progress. The callback is called one last time when the scene has actually
        ///     finished loading and the elements in the scene are accesible.
        ///     Property SceneLoadingArgs.IsLoaded can be queried to check in which of the two cases we are.
        /// </param>
        public void ChangeSceneToAsync(string sceneName, bool activateOnLoad, Action<SceneLoadingArgs> finishedCallback)
        {
            var loadArgs = new SceneLoadingArgs(sceneName, false, true, finishedCallback);

            PrintLog("Start {0}", loadArgs);

            OnSceneWillLoad(loadArgs);

            StartCoroutine(LoadLevelAsyncCO(activateOnLoad));
        }

        /// <summary>
        ///     Queries if the given scene is already loaded
        /// </summary>
        /// <param name="sceneName">
        ///     Name of the scene to check
        /// </param>
        /// <returns>
        ///     <c>true</c> if the given scene is loaded otherwise, <c>false</c>.
        /// </returns>
        public bool IsSceneLoaded(string sceneName)
        {
            return LoadedScenes.Contains(sceneName);
        }

        #region MonobehaviourSingleton overrides

        protected override void SingletonAwakened()
        {
            _initialSceneName = Application.loadedLevelName;
            _initialSceneIndex = Application.loadedLevel;
            _loadedScenes.Add(_initialSceneName);

            PrintLog("Game started with scene {0}", _initialSceneName);
        }
        #endregion

        #region Helpers

        private void AddSceneAsyncInternal(string sceneName, bool activateOnLoad, Action<SceneLoadingArgs> finishedCallback)
        {
            var loadArgs = new SceneLoadingArgs(sceneName, true, true, finishedCallback);

            PrintLog("Start {0}", loadArgs);

            OnSceneWillLoad(loadArgs);

            StartCoroutine(LoadLevelAsyncCO(activateOnLoad));
        }

        /// <summary>
        ///     Used by a coroutine to load a scene in an async way and to issue progress events
        /// </summary>
        IEnumerator LoadLevelAsyncCO(bool activateOnLoad)
        {
            var asyncOp = CurrentlyLoadingSceneArgs.IsSceneLoadingAdditive
                    ? Application.LoadLevelAdditiveAsync(CurrentlyLoadingSceneArgs.SceneName)
                    : Application.LoadLevelAsync(CurrentlyLoadingSceneArgs.SceneName);

            asyncOp.allowSceneActivation = activateOnLoad;
            CurrentlyLoadingSceneArgs.SaveAsyncOperationReference(asyncOp);

            // As of Unity 5.3 loads scenes asynchronous while defering the activation of the scene.
            // If AsyncOperation.allowSceneActivation is false Unity loads the scene but
            // does not activate it. That means the scene is loaded in memory but no scene
            // change will take place until you assign that property a value of true.
            // The trick is that Unity considers an scene fully loaded
            // when the scene is loaded AND activated, so until you activate the scene
            // asyncOp.isDone is false, and asyncOp.percent is not 1, so if you set
            // asyncOp.allowSceneActivation  to false, asyncOp.isDone, will never be true until you set
            // it by code.
            // This prevent using a loop yielding the async operation coroutine and checking for the
            // scene to be loaded, as it would never exit the loop.
            // The common hack to solve this is check that the progress is around
            // 90%, as that is considered the moment that the scene is loaded but
            // just not activated. I've seen this recomended by Unity devs,
            // however looks more like a magic number based on common experience.
            while(!IsSceneLoaded(asyncOp))
            {
                CurrentlyLoadingSceneArgs.NotifySceneLoadingProgress(asyncOp.progress);

                yield return null;
            }

            // Notify that the scene was loaded but is not active
            if(!asyncOp.allowSceneActivation) CurrentlyLoadingSceneArgs.NotifySceneLoaded();

            // Wait until we activate the scene
            while (!asyncOp.allowSceneActivation)
            {
                yield return null;
            }

            OnSceneDidLoad();
        }

        bool IsSceneLoaded(AsyncOperation asyncOp)
        {
            if(!asyncOp.allowSceneActivation)
            {
                return asyncOp.progress >= this.PercentTriggerSceneLoaded;;
            }
            else
            {
                return asyncOp.isDone;
            }

        }
        /// <summary>
        ///     Waits a frame after the scene is loaded so the GameObjects
        ///     it contains are accessible by code.
        /// </summary>
        IEnumerator WaitOneFrameUntilSceneIsAvailableCO(SceneLoadingArgs eventArgs)
        {
            yield return null;

            OnSceneDidLoad();
        }

        void OnSceneDidLoad()
        {
            // If is not an additive operation, clean the list of loaded scenes
            if (!CurrentlyLoadingSceneArgs.IsSceneLoadingAdditive)
            {
                _loadedScenes.Clear();
            }

            _loadedScenes.Add(CurrentlyLoadingSceneArgs.SceneName);

            // If CurrentlyLoadingSceneArgs is not null means that we  we are in the process
            // of loading a scene. We need to set it to null before raising any event / callback
            // notifing that the scene was loaded to allow loading a new scene inside those events.
            var justLoadedSceneArgs = CurrentlyLoadingSceneArgs;
            CurrentlyLoadingSceneArgs = null;

            justLoadedSceneArgs.NotifySceneLoadedAndActive();

            if (SceneDidLoad != null) SceneDidLoad(this, justLoadedSceneArgs);

            PrintLog("Loaded {0}", justLoadedSceneArgs);
        }

        void OnSceneWillLoad(SceneLoadingArgs args)
        {
            // Unity does not allow loading several async scenes at the same time:
            // the second async loaded scene would fail silently so at least we
            // log the problem

            if (IsLoadingScene)
            {
                Debug.Log (string.Format ("Could not load {0}: Already loading {1}",
                    args,
                    CurrentlyLoadingSceneArgs));

                return;
            }

            CurrentlyLoadingSceneArgs = args;

            if (SceneWillLoad != null) SceneWillLoad(this, CurrentlyLoadingSceneArgs);
        }

        #endregion

    }
}


text:
package gorm_test

import "testing"

type BasePost struct {
	Id    int64
	Title string
	URL   string
}

type HNPost struct {
	BasePost
	Upvotes int32
}

type EngadgetPost struct {
	BasePost BasePost `gorm:"embedded"`
	ImageUrl string
}

func TestSaveAndQueryEmbeddedStruct(t *testing.T) {
	DB.Save(&HNPost{BasePost: BasePost{Title: "news"}})
	DB.Save(&HNPost{BasePost: BasePost{Title: "hn_news"}})
	var news HNPost
	if err := DB.First(&news, "title = ?", "hn_news").Error; err != nil {
		t.Errorf("no error should happen when query with embedded struct, but got %v", err)
	} else if news.Title != "hn_news" {
		t.Errorf("embedded struct's value should be scanned correctly")
	}

	DB.Save(&EngadgetPost{BasePost: BasePost{Title: "engadget_news"}})
	var egNews EngadgetPost
	if err := DB.First(&egNews, "title = ?", "engadget_news").Error; err != nil {
		t.Errorf("no error should happen when query with embedded struct, but got %v", err)
	} else if egNews.BasePost.Title != "engadget_news" {
		t.Errorf("embedded struct's value should be scanned correctly")
	}

	if DB.NewScope(&HNPost{}).PrimaryField() == nil {
		t.Errorf("primary key with embedded struct should works")
	}

	for _, field := range DB.NewScope(&HNPost{}).Fields() {
		if field.Name == "BasePost" {
			t.Errorf("scope Fields should not contain embedded struct")
		}
	}
}


text:
'use strict';

// core requires
var fs = require('fs');
var path = require('path');
var net = require('net');

// external requires
var assert = require('chai').assert;
var mkdirp = require('mkdirp');
var restify = require('restify');
var restifyClients = require('restify-clients');
var rimraf = require('rimraf');

// local files
var helper = require('./lib/helper');
var plugins = require('../lib');

// local globals
var SERVER;
var CLIENT;
var PORT;
var FILES_TO_DELETE = [];
var DIRS_TO_DELETE = [];

describe('static resource plugin', function () {

    beforeEach(function (done) {
        SERVER = restify.createServer({
            dtrace: helper.dtrace,
            log: helper.getLog('server')
        });

        SERVER.listen(0, '127.0.0.1', function () {
            PORT = SERVER.address().port;
            CLIENT = restifyClients.createJsonClient({
                url: 'http://127.0.0.1:' + PORT,
                dtrace: helper.dtrace,
                retry: false
            });

            done();
        });
    });

    afterEach(function (done) {
        var i;

        for (i = 0; i < FILES_TO_DELETE.length; ++i) {
            try {
                fs.unlinkSync(FILES_TO_DELETE[i]);
            }
            catch (err) {
                /* normal */
            }
        }

        for (i = 0; i < DIRS_TO_DELETE.length; ++i) {
            try {
                rimraf.sync(DIRS_TO_DELETE[i]);
            }
            catch (err) {
                /* normal */
            }
        }

        CLIENT.close();
        SERVER.close(done);
    });

    function serveStaticTest(done, testDefault, tmpDir, regex, staticFile) {
        var staticContent = '{"content": "abcdefg"}';
        var staticObj = JSON.parse(staticContent);
        var testDir = 'public';
        var testFileName = 'index.json';
        var routeName = 'GET wildcard';
        var tmpPath = path.join(__dirname, '../', tmpDir);

        mkdirp(tmpPath, function (err) {
            assert.ifError(err);
            DIRS_TO_DELETE.push(tmpPath);
            var folderPath = path.join(tmpPath, testDir);

            mkdirp(folderPath, function (err2) {
                assert.ifError(err2);

                DIRS_TO_DELETE.push(folderPath);
                var file = path.join(folderPath, testFileName);

                fs.writeFile(file, staticContent, function (err3) {
                    assert.ifError(err3);
                    FILES_TO_DELETE.push(file);
                    var p = '/' + testDir + '/' + testFileName;
                    var opts = { directory: tmpPath };

                    if (staticFile) {
                        opts.file = p;
                    }

                    if (testDefault) {
                        p = '/' + testDir + '/';
                        opts.default = testFileName;
                        routeName += ' with default';
                    }
                    var re = regex ||
                        new RegExp('/' + testDir + '/?.*');

                    SERVER.get({
                        path: re,
                        name: routeName
                    }, plugins.serveStatic(opts));

                    CLIENT.get(p, function (err4, req, res, obj) {
                        assert.ifError(err4);
                        assert.equal(res.headers['cache-control'],
                            'public, max-age=3600');
                        assert.deepEqual(obj, staticObj);
                        done();
                    });
                });
            });
        });
    }

    function testNoAppendPath(done, testDefault, tmpDir, regex, staticFile) {
        var staticContent = '{"content": "abcdefg"}';
        var staticObj = JSON.parse(staticContent);
        var testDir = 'public';
        var testFileName = 'index.json';
        var routeName = 'GET wildcard';
        var tmpPath = path.join(__dirname, '../', tmpDir);

        mkdirp(tmpPath, function (err) {
            assert.ifError(err);
            DIRS_TO_DELETE.push(tmpPath);
            var folderPath = path.join(tmpPath, testDir);

            mkdirp(folderPath, function (err2) {
                assert.ifError(err2);

                DIRS_TO_DELETE.push(folderPath);
                var file = path.join(folderPath, testFileName);

                fs.writeFile(file, staticContent, function (err3) {
                    assert.ifError(err3);
                    FILES_TO_DELETE.push(file);
                    var p = '/' + testDir + '/' + testFileName;
                    var opts = { directory: folderPath };
                    opts.appendRequestPath = false;

                    if (staticFile) {
                        opts.file = testFileName;
                    }

                    if (testDefault) {
                        p = '/' + testDir + '/';
                        opts.default = testFileName;
                        routeName += ' with default';
                    }
                    var re = regex ||
                        new RegExp('/' + testDir + '/?.*');

                    SERVER.get({
                        path: re,
                        name: routeName
                    }, plugins.serveStatic(opts));

                    CLIENT.get(p, function (err4, req, res, obj) {
                        assert.ifError(err4);
                        assert.equal(res.headers['cache-control'],
                            'public, max-age=3600');
                        assert.deepEqual(obj, staticObj);
                        done();
                    });
                });
            });
        });
    }

    it('static serves static files', function (done) {
        serveStaticTest(done, false, '.tmp');
    });

    it('static serves static files in nested folders', function (done) {
        serveStaticTest(done, false, '.tmp/folder');
    });

    it('static serves static files in with a root regex', function (done) {
        serveStaticTest(done, false, '.tmp', new RegExp('/.*'));
    });

    it('static serves static files with a root, !greedy, regex',
    function (done) {
        serveStaticTest(done, false, '.tmp', new RegExp('/?.*'));
    });

    it('static serves default file', function (done) {
        serveStaticTest(done, true, '.tmp');
    });

    it('restify-GH-379 static serves file with parentheses in path',
    function (done) {
        serveStaticTest(done, false, '.(tmp)');
    });

    it('restify-GH-719 serve a specific static file', function (done) {
        // serve the same default file .tmp/public/index.json
        // but get it from opts.file
        serveStaticTest(done, false, '.tmp', null, true);
    });

    it('static serves static file with appendRequestPath = false',
        function (done) {
        testNoAppendPath(done, false, '.tmp');
    });

    it('static serves default file with appendRequestPath = false',
        function (done) {
        testNoAppendPath(done, true, '.tmp');
    });

    it('restify serve a specific static file with appendRequestPath = false',
        function (done) {
        testNoAppendPath(done, false, '.tmp', null, true);
    });

    // To ensure this will always get properly restored (even in case of a test
    // failure) we do it here.
    var originalCreateReadStream = fs.createReadStream;
    afterEach(function () {
        fs.createReadStream = originalCreateReadStream;
    });

    var TMP_PATH = path.join(__dirname, '../', '.tmp');
    var RAW_REQUEST =
        'GET /index.html HTTP/1.1\r\n' +
        'Host: 127.0.0.1:' + PORT + '\r\n' +
        'User-Agent: curl/7.48.0\r\n' +
        'Accept: */*\r\n' +
        '\r\n';

    it('static does not leak the file stream and next() is properly called ' +
       'when the client disconnects before receiving a reply', function (done) {
        var streamWasAlreadyCreated = false;
        var streamWasClosed = false;
        var socket = new net.Socket();

        fs.createReadStream = function () {
            // Just in case the code would open more streams in the future.
            assert.strictEqual(streamWasAlreadyCreated, false);
            streamWasAlreadyCreated = true;

            var stream = originalCreateReadStream.apply(this, arguments);
            stream.once('close', function () {
                streamWasClosed = true;
            });

            socket.end();
            return stream;
        };

        mkdirp(TMP_PATH, function (err) {
            assert.ifError(err);
            DIRS_TO_DELETE.push(TMP_PATH);
            fs.writeFileSync(path.join(TMP_PATH, 'index.html'), 'Hello world!');

            var serve = plugins.serveStatic({
                directory: TMP_PATH
            });

            SERVER.get(/.*/, function (req, res, next) {
                serve(req, res, function (nextRoute) {
                    assert.strictEqual(streamWasClosed, true);
                    assert.strictEqual(nextRoute, false);
                    done();
                });
            });

            socket.connect({host: '127.0.0.1', port: PORT}, function () {
                socket.write(RAW_REQUEST, 'utf-8', function (err2, data) {
                    assert.ifError(err2);
                });
            });
        });
    });

    it('static does not open a file stream and next() is properly called ' +
       'when the client disconnects immediately after sending a request',
    function (done) {
        fs.createReadStream = function () {
            assert(false);
        };

        mkdirp(TMP_PATH, function (err) {
            assert.ifError(err);
            DIRS_TO_DELETE.push(TMP_PATH);
            fs.writeFileSync(path.join(TMP_PATH, 'index.html'), 'Hello world!');

            var serve = plugins.serveStatic({
                directory: TMP_PATH
            });

            SERVER.get(/.*/, function (req, res, next) {
                serve(req, res, function (nextRoute) {
                    assert.strictEqual(nextRoute, false);
                    done();
                });
            });

            var socket = new net.Socket();
            socket.connect({host: '127.0.0.1', port: PORT}, function () {
                socket.write(RAW_REQUEST, 'utf-8', function (err2, data) {
                    assert.ifError(err2);
                    socket.end();
                });
            });
        });
    });
});


text:
Analyst-Dashboard
=================

A platform for analyst to view, report, and correlate network data from multiple data feeds.


text:
require 'spec_helper'
require 'goliath/validation/standard_http_errors'

describe Goliath::Validation::Error do
  it 'defines exceptions for each standard error response' do
    lambda { Goliath::Validation::BadRequestError.new }.should_not raise_error
    Goliath::Validation::BadRequestError.should < Goliath::Validation::Error
  end

  it 'defines InternalServerError not InternalServerErrorError' do
    lambda { Goliath::Validation::InternalServerError.new }.should_not raise_error
    Goliath::Validation::InternalServerError.should < Goliath::Validation::Error
  end

  it 'sets a default status code and message' do
    nfe = Goliath::Validation::NotFoundError.new
    nfe.status_code.should == '404'
    nfe.message.should == 'Not Found'
  end
end