text:
/** @var The AJAX proxy URL */
var admintools_ajax_url = "";

/** @var The callback function to call on error */
var admintools_error_callback = dummy_error_handler;

/** @var The password sent to the restoration script */
var admintools_update_password = '';

var admintools_update_stat_inbytes = 0;
var admintools_update_stat_outbytes = 0;
var admintools_update_stat_files = 0;
var admintools_update_factory = null;

/**
 * An extremely simple error handler, dumping error messages to screen
 * @param error The error message string
 */
function dummy_error_handler(error)
{
	alert("ERROR:\n" + error);
}

/**
 * Performs an AJAX request and returns the parsed JSON output.
 * The global akeeba_ajax_url is used as the AJAX proxy URL.
 * If there is no errorCallback, the global akeeba_error_callback is used.
 * @param data An object with the query data, e.g. a serialized form
 * @param successCallback A function accepting a single object parameter, called on success
 * @param errorCallback A function accepting a single string parameter, called on failure
 */
function doAjax(data, successCallback, errorCallback)
{
	var json = JSON.stringify(data);
	if (admintools_update_password.length > 0)
	{
		json = AesCtr.encrypt(json, admintools_update_password, 128);
	}
	var post_data = 'json=' + encodeURIComponent(json);

	var structure =
	{
		onSuccess: function (msg, responseXML)
		{
			// Initialize
			var junk = null;
			var message = "";

			// Get rid of junk before the data
			var valid_pos = msg.indexOf('###');
			if (valid_pos == -1)
			{
				// Valid data not found in the response
				msg = 'Invalid AJAX data:\n' + msg;
				if (errorCallback == null)
				{
					if (admintools_error_callback != null)
					{
						admintools_error_callback(msg);
					}
				}
				else
				{
					errorCallback(msg);
				}
				return;
			}
			else if (valid_pos != 0)
			{
				// Data is prefixed with junk
				junk = msg.substr(0, valid_pos);
				message = msg.substr(valid_pos);
			}
			else
			{
				message = msg;
			}
			message = message.substr(3); // Remove triple hash in the beginning

			// Get of rid of junk after the data
			var valid_pos = message.lastIndexOf('###');
			message = message.substr(0, valid_pos); // Remove triple hash in the end
			// Decrypt if required
			if (admintools_update_password.length > 0)
			{
				try
				{
					var data = JSON.parse(message);
				}
				catch (err)
				{
					message = AesCtr.decrypt(message, admintools_update_password, 128);
				}
			}

			try
			{
				var data = JSON.parse(message);
			}
			catch (err)
			{
				var msg = err.message + "\n
\n
\n" + message + "\n
";
				if (errorCallback == null)
				{
					if (admintools_error_callback != null)
					{
						admintools_error_callback(msg);
					}
				}
				else
				{
					errorCallback(msg);
				}
				return;
			}

			// Call the callback function
			successCallback(data);
		},
		onFailure: function (req)
		{
			var message = 'AJAX Loading Error: ' + req.statusText;
			if (errorCallback == null)
			{
				if (admintools_error_callback != null)
				{
					admintools_error_callback(message);
				}
			}
			else
			{
				errorCallback(message);
			}
		}
	};

	var ajax_object = null;

	// Damn you, Internet Explorer!!!
	var randomJunk = new Date().getTime();
	var url = admintools_ajax_url + '?randomJunk=' + randomJunk;

	if (typeof(XHR) == 'undefined')
	{
		structure.url = url;
		ajax_object = new Request(structure);
		ajax_object.send(post_data);
	}
	else
	{
		ajax_object = new XHR(structure);
		ajax_object.send(url, post_data);
	}
}

/**
 * Pings the update script (making sure its executable!!)
 * @return
 */
function pingUpdate()
{
	// Reset variables
	admintools_update_stat_files = 0;
	admintools_update_stat_inbytes = 0;
	admintools_update_stat_outbytes = 0;

	// Do AJAX post
	var post = {task: 'ping'};
	doAjax(post, function (data)
	{
		startUpdate(data);
	});
}

/**
 * Starts the update
 * @return
 */
function startUpdate()
{
	// Reset variables
	admintools_update_stat_files = 0;
	admintools_update_stat_inbytes = 0;
	admintools_update_stat_outbytes = 0;

	var post = { task: 'startRestore' };
	doAjax(post, function (data)
	{
		processUpdateStep(data);
	});
}

/**
 * Steps through the update
 * @param data
 * @return
 */
function processUpdateStep(data)
{
	if (data.status == false)
	{
		// handle failure
		admintools_error_callback(data.message);
	}
	else
	{
		if (data.done)
		{
			admintools_update_factory = data.factory;
			finalizeUpdate();
		}
		else
		{
			// Add data to variables
			admintools_update_stat_inbytes += data.bytesIn;
			admintools_update_stat_outbytes += data.bytesOut;
			admintools_update_stat_files += data.files;

			// Display data
			document.getElementById('extbytesin').innerHTML = admintools_update_stat_inbytes;
			document.getElementById('extbytesout').innerHTML = admintools_update_stat_outbytes;
			document.getElementById('extfiles').innerHTML = admintools_update_stat_files;

			// Do AJAX post
			post = {
				task:    'stepRestore',
				factory: data.factory
			};
			doAjax(post, function (data)
			{
				processUpdateStep(data);
			});
		}
	}
}

function finalizeUpdate()
{
	// Do AJAX post
	var post = { task: 'finalizeRestore', factory: admintools_update_factory };
	doAjax(post, function (data)
	{
		updateFinished(data);
	});
}

function updateFinished()
{
	window.location = 'index.php?option=com_admintools&view=jupdate&task=finalize&file=' + admintools_file;
}

function showWhatthis()
{
	if (document.getElementById('admintools-whatsthis-info').style.display == 'block')
	{
		document.getElementById('admintools-whatsthis-info').style.display = 'none';
	}
	else
	{
		document.getElementById('admintools-whatsthis-info').style.display = 'block';
	}
}

function hideWhatthis()
{
	document.getElementById('admintools-whatsthis-info').style.display = 'none';
}


text:
package com.lmax.disruptor;

/**
 * Implement this interface in your {@link EventHandler} to be notified when a thread for the
 * {@link BatchEventProcessor} starts and shuts down.
 */
public interface LifecycleAware
{
    /**
     * Called once on thread start before first event is available.
     */
    void onStart();

    /**
     *
Called once just before the thread is shutdown.

     *
     * Sequence event processing will already have stopped before this method is called. No events will
     * be processed after this message.
     */
    void onShutdown();
}

redpajama_set_name: RedPajamaGithub


text:
using System;
using System.Collections.Generic;
using Thinktecture.Relay.Server.Dto;

namespace Thinktecture.Relay.Server.Repository
{
	public interface ILogRepository
	{
		void LogRequest(RequestLogEntry requestLogEntry);
		IEnumerable<RequestLogEntry> GetRecentLogEntriesForLink(Guid linkId, int amount);
		IEnumerable<ContentBytesChartDataItem> GetContentBytesChartDataItemsForLink(Guid id, TimeFrame timeFrame);
		IEnumerable<ContentBytesChartDataItem> GetContentBytesChartDataItems();
		IEnumerable<RequestLogEntry> GetRecentLogEntries(int amount);
	}
}


text:
package gobblin.util.request_allocation;

import org.testng.Assert;
import org.testng.annotations.Test;

public class VectorAlgebraTest {
  @Test
  public void testAddVector()
      throws Exception {
    Assert.assertEquals(VectorAlgebra.addVector(new double[]{1, 2}, new double[]{1, 3}, 1., null), new double[]{2, 5});
    Assert.assertEquals(VectorAlgebra.addVector(new double[]{1, 2}, new double[]{1, 3}, 2., null), new double[]{3, 8});
    Assert.assertEquals(VectorAlgebra.addVector(new double[]{1, 2}, new double[]{1, 3}, -1., null), new double[]{0, -1});

    // Check it uses reuse vector
    double[] reuse = new double[]{1, 2};
    VectorAlgebra.addVector(reuse, new double[]{1, 3}, 1., reuse);
    Assert.assertEquals(reuse, new double[]{2, 5});
  }

  @Test
  public void testExceedsVector()
      throws Exception {
    Assert.assertTrue(VectorAlgebra.exceedsVector(new double[]{1, 2}, new double[]{0, 3}, false));
    Assert.assertTrue(VectorAlgebra.exceedsVector(new double[]{1, 2}, new double[]{2, 0}, false));
    Assert.assertTrue(VectorAlgebra.exceedsVector(new double[]{1, 2}, new double[]{0, 2}, true));
    Assert.assertTrue(VectorAlgebra.exceedsVector(new double[]{1, 2}, new double[]{1, 0}, true));

    Assert.assertFalse(VectorAlgebra.exceedsVector(new double[]{1, 2}, new double[]{0, 1}, false));
    Assert.assertFalse(VectorAlgebra.exceedsVector(new double[]{1, 2}, new double[]{1, 2}, false));
  }
}


text:
Version 2.0.43 by Volodymyr Volynets

	<time class="change_log_date_commit" datetime="2019-09-29">2019-09-29</time>

Users

	Other #1245 (Updated module.ini file.)

Repository / Git:
	Name: Numbers\Users
	Title: Users Repository
	Version: 2.0.42
	Last Tag: 2.0.42
	User Name: Volodymyr Volynets
	User Email: volodymyr.volynets@gmail.com
Statistics:
	Addition: 2
	Deletion: 1
Modules:
	U/M User Management (Numbers\Users\Users, 1.0.27)                                         |     2    1
		    2    1	 | Users/module.ini


text:
using Elmah.Core.Models;
using Elmah.Core.Services;
using Elmah.Core.Util;
using Elmah.Service.Tasks.Impl;
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace Elmah.Service.Tests.Tasks
{
    public class FindApplicationsTaskTests
    {
        private FindApplicationsTask _task;
        private Mock<IDataService> _service;
        private Mock<IAppSettingsHelper> _helper;

        [SetUp]
        public void Setup()
        {
            _service = new Mock<IDataService>();
            _helper = new Mock<IAppSettingsHelper>();
            _task = new FindApplicationsTask();
            _task.DataService = _service.Object;
            _task.AppSettingsHelper = _helper.Object;

            Application application = Builder<Application>.CreateNew().Build();
            _service.Setup(x => x.GetAll<Application>())
                .Returns(new List<Application>() { application });

            _service.Setup(x => x.FindDistinct<Error>(It.IsAny<string>()))
                .Returns(Builder<Error>.CreateListOfSize(1)
                    .All()
                    .With(x => x.Application, "New One")
                    .Build());

            _service.Setup(x => x.Save(It.IsAny<Application>()));

            _helper.Setup(x => x.GetIntConfig(It.IsAny<string>())).Returns(1);
        }

        [Test]
        public void Task_Loads_Applications()
        {
            _task.RunTask();

            _service.Verify(x => x.GetAll<Application>());
        }

        [Test]
        public void Task_Adds_Application()
        {
            _task.RunTask();
            _service.Verify(x => x.Save(It.IsAny<Application>()));
        }
    }
}


text:
//
// keyvi - A key value store.
//
// Copyright 2015 Hendrik Muhs<hendrik.muhs@gmail.com>
//
// 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.
//

/*
 * memory_map_manager_test.cpp
 *
 *  Created on: May 8, 2014
 *      Author: hendrik
 */

#include <cstring>
#include <boost/test/unit_test.hpp>

#include "dictionary/fsa/internal/memory_map_manager.h"

namespace keyvi {
namespace dictionary {
namespace fsa {
namespace internal {

BOOST_AUTO_TEST_SUITE( MemoryMapManagerTests )

BOOST_AUTO_TEST_CASE( basic ) {
  size_t chunkSize = 1024 * 1024;

  boost::filesystem::path path = boost::filesystem::temp_directory_path();
  path /= boost::filesystem::unique_path(
      "dictionary-fsa-unittest-%%%%-%%%%-%%%%-%%%%");
  boost::filesystem::create_directory(path);
  MemoryMapManager m(chunkSize, path, "basic test");

  m.GetAddress(0);
  char* testptr = (char*) m.GetAddress(2 * chunkSize);
  std::memset(testptr, 42, chunkSize);

  BOOST_CHECK_EQUAL(testptr[42], 42);
  char* testptr2 = (char*) m.GetAddress(chunkSize);
  std::memset(testptr2, 24, chunkSize);

  BOOST_CHECK_EQUAL(testptr[42], 42);
  BOOST_CHECK_EQUAL(testptr2[42], 24);

  boost::filesystem::remove_all(path);
}

BOOST_AUTO_TEST_CASE( GetAddressOverflowCheck ) {
  size_t chunkSize = 1024 * 1024;

  boost::filesystem::path path = boost::filesystem::temp_directory_path();
  path /= boost::filesystem::unique_path(
      "dictionary-fsa-unittest-%%%%-%%%%-%%%%-%%%%");
  boost::filesystem::create_directory(path);
  MemoryMapManager m(chunkSize, path, "basic test");

  m.GetAddress(0);

  BOOST_CHECK(m.GetAddressQuickTestOk(chunkSize -1, 1));
  BOOST_CHECK(m.GetAddressQuickTestOk(chunkSize -3, 2));
  BOOST_CHECK(m.GetAddressQuickTestOk(chunkSize -5, 5));

  BOOST_CHECK(!m.GetAddressQuickTestOk(chunkSize -1, 2));
  BOOST_CHECK(!m.GetAddressQuickTestOk(chunkSize -1, 3));
  BOOST_CHECK(!m.GetAddressQuickTestOk(chunkSize -1, 4));
  BOOST_CHECK(!m.GetAddressQuickTestOk(chunkSize -1, 5));

  char* testptr = (char*) m.GetAddress(chunkSize-1);

  boost::filesystem::remove_all(path);
}

BOOST_AUTO_TEST_CASE( GetBuffer ) {
  size_t chunkSize = 1024 * 1024;

  boost::filesystem::path path = boost::filesystem::temp_directory_path();
  path /= boost::filesystem::unique_path(
      "dictionary-fsa-unittest-%%%%-%%%%-%%%%-%%%%");
  boost::filesystem::create_directory(path);
  MemoryMapManager m(chunkSize, path, "basic test");

  m.GetAddress(0);
  char* testptr = (char*) m.GetAddress(chunkSize-2);
  *testptr = 104;

  testptr = (char*) m.GetAddress(chunkSize-1);
  *testptr = 101;

  testptr = (char*) m.GetAddress(chunkSize);
  *testptr = 108;

  testptr = (char*) m.GetAddress(chunkSize+1);
  *testptr = 108;

  testptr = (char*) m.GetAddress(chunkSize+2);
  *testptr = 111;

  char buffer[20];
  buffer[5] = 0;

  m.GetBuffer(chunkSize -2, buffer, 20);
  BOOST_CHECK_EQUAL("hello", std::string(buffer));

  boost::filesystem::remove_all(path);
}

BOOST_AUTO_TEST_CASE( AppendLargeChunk ) {
  size_t chunkSize = 4096;

  boost::filesystem::path path = boost::filesystem::temp_directory_path();
  path /= boost::filesystem::unique_path(
      "dictionary-fsa-unittest-%%%%-%%%%-%%%%-%%%%");
  boost::filesystem::create_directory(path);
  MemoryMapManager m(chunkSize, path, "append large chunk test");

  char buffer[16384];
  std::fill(buffer, buffer+4096, 'y');
  std::fill(buffer+4096, buffer+16384, 'x');
  buffer[8887] = 'w';
  buffer[8889] = 'y';

  buffer[9503] = 'a';
  buffer[9504] = 'b';

  buffer[12003] = 'c';
  buffer[12005] = 'd';

  buffer[14000] = 'e';
  buffer[14001] = 'f';

  buffer[16382] = 'g';
  buffer[16383] = 'h';

  m.Append(buffer, 16384);

  BOOST_CHECK_EQUAL('x', ((char*)m.GetAddress(8888))[0]);
  BOOST_CHECK_EQUAL('a', ((char*)m.GetAddress(9503))[0]);
  BOOST_CHECK_EQUAL('x', ((char*)m.GetAddress(12004))[0]);
  BOOST_CHECK_EQUAL('e', ((char*)m.GetAddress(14000))[0]);
  BOOST_CHECK_EQUAL('h', ((char*)m.GetAddress(16383))[0]);

  boost::filesystem::remove_all(path);
}

BOOST_AUTO_TEST_CASE( Appendchunkoverflow ) {
  size_t chunkSize = 4096;

  boost::filesystem::path path = boost::filesystem::temp_directory_path();
  path /= boost::filesystem::unique_path(
      "dictionary-fsa-unittest-%%%%-%%%%-%%%%-%%%%");
  boost::filesystem::create_directory(path);
  MemoryMapManager m(chunkSize, path, "append large chunk test");

  char buffer[1000];
  std::fill(buffer, buffer+1000, 'x');
  m.Append(buffer, 1000);
  std::fill(buffer, buffer+1000, 'y');
  m.Append(buffer, 1000);
  std::fill(buffer, buffer+1000, 'z');
  m.Append(buffer, 1000);
  std::fill(buffer, buffer+1000, '1');
  m.Append(buffer, 1000);
  std::fill(buffer, buffer+1000, '2');
  m.Append(buffer, 1000);
  std::fill(buffer, buffer+1000, '3');
  m.Append(buffer, 1000);

  BOOST_CHECK_EQUAL('x', ((char*)m.GetAddress(999))[0]);
  BOOST_CHECK_EQUAL('y', ((char*)m.GetAddress(1567))[0]);
  BOOST_CHECK_EQUAL('z', ((char*)m.GetAddress(2356))[0]);
  BOOST_CHECK_EQUAL('1', ((char*)m.GetAddress(3333))[0]);
  BOOST_CHECK_EQUAL('2', ((char*)m.GetAddress(4444))[0]);
  BOOST_CHECK_EQUAL('3', ((char*)m.GetAddress(5555))[0]);
  BOOST_CHECK_EQUAL(6000, m.GetSize());
  boost::filesystem::remove_all(path);
}

BOOST_AUTO_TEST_CASE( chunkbehindtail ) {
  size_t chunkSize = 4096;

  boost::filesystem::path path = boost::filesystem::temp_directory_path();
  path /= boost::filesystem::unique_path(
      "dictionary-fsa-unittest-%%%%-%%%%-%%%%-%%%%");
  boost::filesystem::create_directory(path);
  MemoryMapManager m(chunkSize, path, "append large chunk test");

  char buffer[1024];
  std::fill(buffer, buffer+1024, 'x');
  m.Append(buffer, 1024);
  std::fill(buffer, buffer+1024, 'y');
  m.Append(buffer, 1024);
  std::fill(buffer, buffer+1024, 'z');
  m.Append(buffer, 1024);
  std::fill(buffer, buffer+1024, '1');
  m.Append(buffer, 1023);

  // tail should now be at 4096
  BOOST_CHECK_EQUAL(4095, m.GetSize());

  // force a new chunk to be created, although tail does not require it
  m.GetBuffer(4094, &buffer, 10);

  auto filename = path;
  filename /= "out";
  std::ofstream out_stream(filename.native(), std::ios::binary);
  m.Write(out_stream, m.GetSize() );
  BOOST_CHECK_EQUAL(4095, out_stream.tellp());
  out_stream.close();

  boost::filesystem::remove_all(path);
}

BOOST_AUTO_TEST_CASE( Persist ) {
  size_t chunkSize = 4096;

  boost::filesystem::path path = boost::filesystem::temp_directory_path();
  path /= boost::filesystem::unique_path(
      "dictionary-fsa-unittest-%%%%-%%%%-%%%%-%%%%");
  boost::filesystem::create_directory(path);
  MemoryMapManager m(chunkSize, path, "append large chunk test");

  char buffer[4096];
  std::fill(buffer, buffer+4096, 'x');
  m.Append(buffer, 4096);
  m.Append(buffer, 1);

  m.Persist();

  auto filename = path;
  filename /= "out";
  std::ofstream out_stream(filename.native(), std::ios::binary);
  m.Write(out_stream, 0 );
  BOOST_CHECK_EQUAL(4097, out_stream.tellp());
  out_stream.close();

  boost::filesystem::remove_all(path);
}

BOOST_AUTO_TEST_SUITE_END()

} /* namespace internal */
} /* namespace fsa */
} /* namespace dictionary */
} /* namespace keyvi */


text:
/**
 * Return the size of the GlType in bytes
 * @param gl
 * @param type
 */
export function getGlTypeSizeBytes(gl: WebGLRenderingContext, type: number): number {
  switch (type) {
    case gl.FLOAT:
      return 4;
    case gl.SHORT:
      return 2;
    case gl.UNSIGNED_SHORT:
      return 2;
    case gl.BYTE:
      return 1;
    case gl.UNSIGNED_BYTE:
      return 1;
    default:
      return 1;
  }
}

/**
 * Based on the type return the number of attribute components
 *
 * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer
 * @param gl
 * @param type
 */
export function getAttributeComponentSize(gl: WebGLRenderingContext, type: number): number {
  switch (type) {
    case gl.LOW_FLOAT:
    case gl.HIGH_FLOAT:
    case gl.FLOAT:
      return 1;
    case gl.FLOAT_VEC2:
      return 2;
    case gl.FLOAT_VEC3:
      return 3;
    case gl.FLOAT_VEC4:
      return 4;
    case gl.BYTE:
      return 1;
    case gl.UNSIGNED_BYTE:
      return 1;
    case gl.UNSIGNED_SHORT:
    case gl.SHORT:
      return 1;
    default:
      return 1;
  }
}

/**
 * Based on the attribute return the corresponding supported attrib pointer type
 * https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer
 *
 * @param gl
 * @param type
 */
export function getAttributePointerType(gl: WebGLRenderingContext, type: number) {
  switch (type) {
    case gl.LOW_FLOAT:
    case gl.HIGH_FLOAT:
    case gl.FLOAT:
    case gl.FLOAT_VEC2:
    case gl.FLOAT_VEC3:
    case gl.FLOAT_VEC4:
      return gl.FLOAT;
    case gl.BYTE:
      return gl.BYTE;
    case gl.UNSIGNED_BYTE:
      return gl.UNSIGNED_BYTE;
    case gl.SHORT:
      return gl.SHORT;
    case gl.UNSIGNED_SHORT:
      return gl.UNSIGNED_SHORT;
    default:
      return gl.FLOAT;
  }
}


text:
package cn.fraudmetrix.http.impl.client;

import static java.lang.System.out;
import static org.testng.Assert.assertEquals;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.util.EntityUtils;
import org.testng.annotations.Test;

/**
 * 类KeepAliveHttpClientsTest.java的实现描述:Test for {@link KeepAliveHttpClients} instance.
 *
 * @author huagang.li 2014年11月1日 下午2:42:54
 */
public class KeepAliveHttpClientsTest {

    @Test(invocationCount = 3, threadPoolSize = 3)
    public void doKeepAliveRequest() throws IOException, InterruptedException {
        String uri = "http://localhost";

        CloseableHttpClient httpClient = KeepAliveHttpClients.create(5); // 连接5min存活时间
        HttpUriRequest request = new HttpGet(uri);
        try {
            for (int j = 0; j < 2; j++) {
                for (int i = 0; i < 3; i++) {
                    this.execute(httpClient, request);
                    TimeUnit.SECONDS.sleep(10L);
                }
                out.println("");
                if (j < 1) {
                    TimeUnit.MINUTES.sleep(7L); // 模拟"Keep-Alive" HTTP连接失效过期而被关闭,会重新握手连接(结合tcpdump)
                }
            }
        } finally {
            // resource deallocation (资源再分配)
            httpClient.close();
        }
    }

    @Test(invocationCount = 3, threadPoolSize = 3)
    public void doKeepAlivePoolRequest() throws IOException, InterruptedException {
        String uri = "http://localhost";

        PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager();
        connManager.setMaxTotal(128);
        connManager.setDefaultMaxPerRoute(16);

        CloseableHttpClient httpClient = KeepAliveHttpClients.create(connManager, 5); // 连接5min存活时间
        HttpUriRequest request = new HttpGet(uri);
        try {
            // for (int j = 0; j < 2; j++) {
            for (int i = 0; i < 3; i++) {
                this.execute(httpClient, request);
                TimeUnit.SECONDS.sleep(10L);
            }
            out.println("");
            // [leased: 0; pending: 0; available: 1; max: 128]
            out.println(connManager.getTotalStats().toString());
            // if (j < 1) {
            // TimeUnit.MINUTES.sleep(7L); // 模拟"Keep-Alive" HTTP连接失效过期而被关闭,会重新握手连接(结合tcpdump)
            // }
            // }
        } finally {
            // resource deallocation (资源再分配)
            httpClient.close();
        }
    }

    private void execute(CloseableHttpClient httpClient, HttpUriRequest request) throws IOException {
        CloseableHttpResponse response = httpClient.execute(request);

        out.println("Status Line: " + response.getStatusLine());
        assertEquals(response.getStatusLine().getStatusCode(), HttpStatus.SC_OK);
        HttpEntity entity = response.getEntity();
        // String responseContent = EntityUtils.toString(entity, StandardCharsets.UTF_8);
        // out.println("Response Content: " + responseContent);
        EntityUtils.consume(entity);

        response.close();
    }

}


text: Some shortcuts for common `UIScrollView` operations.


text:
* Workshop
* Presentation

## Abstract
Are you an expert? (Hint: Yes.)

Solidifying and owning your expertise — your knowledge and experience — is the foundation of speaking at conferences contributing to open source, and changing the world! Using research-backed exercises, you'll learn to overcome Imposter Syndrome, own your expertise and present yourself and your accomplishments with confidence.

## Description
Solidifying and owning your expertise — your knowledge and experience — is the foundation of speaking at conferences contributing to open source, and changing the world!

Own Your Expertise will include an introduction to Imposter Syndrome and the factors that contribute to woman downplaying their accomplishments.  Then we will go through proven exercises and learn tools and techniques for framing yourself as an expert and presenting your accomplishments with confidence.

This workshop is an abbreviated workshop of a day-long Write/Speak/Code workshop and has been given to audiences as large as 100 people.  The exercises are individual or small group based and can scale to any size.

## Audience
This workshop is for any technical woman who doesn't think she is an expert and any technical woman who has not spoken, written, or publicly expressed her expertise.

While it may seem that this talk to for students and early career professionals, we at Write/Speak/Code have found that our resident "experts" get just as much out of our workshops as the attendees.   This workshop has been powerful for women just beginning in tech to woman who have been in the industry for 15 years.

## Outcomes/Conclusions
Attendees will leave the workshop with an understanding of Imposter Syndrome and societal factors that contribute to their feelings about their success.  They will generate a list of accomplishments, write about their values, and learn exercises they can work into their daily lives in the future.

## Outline

## Submitted to

## Given at


text:
package org.pentaho.di.core.logging;

import com.google.common.annotations.VisibleForTesting;
import org.pentaho.di.core.Const;
import org.pentaho.di.core.util.Utils;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * This class keeps the last N lines in a buffer
 *
 * @author matt
 */
public class LoggingBuffer {
  private String name;

  private List<BufferLine> buffer;
  private ReadWriteLock lock = new ReentrantReadWriteLock();

  private int bufferSize;

  private KettleLogLayout layout;

  private List<KettleLoggingEventListener> eventListeners;

  private LoggingRegistry loggingRegistry = LoggingRegistry.getInstance();

  public LoggingBuffer( int bufferSize ) {
    this.bufferSize = bufferSize;
    // The buffer overflow protection allows it to be overflowed for 1 item within a single thread.
    // Considering a possible high contention, let's set it's max overflow size to be 10%.
    // Anyway, even an overflow goes higher than 10%, it wouldn't cost us too much.
    buffer = new ArrayList<>( (int) ( bufferSize * 1.1 ) );
    layout = new KettleLogLayout( true );
    eventListeners = new CopyOnWriteArrayList<>();
  }

  /**
   * @return the number (sequence, 1..N) of the last log line. If no records are present in the buffer, 0 is returned.
   */
  public int getLastBufferLineNr() {
    lock.readLock().lock();
    try {
      if ( buffer.size() > 0 ) {
        return buffer.get( buffer.size() - 1 ).getNr();
      } else {
        return 0;
      }
    } finally {
      lock.readLock().unlock();
    }
  }

  /**
   * @param channelId      channel IDs to grab
   * @param includeGeneral include general log lines
   * @param from
   * @param to
   * @return
   */
  public List<KettleLoggingEvent> getLogBufferFromTo( List<String> channelId, boolean includeGeneral, int from,
                                                      int to ) {
    lock.readLock().lock();
    try {
      Stream<BufferLine> bufferStream = buffer.stream().filter( line -> line.getNr() > from && line.getNr() <= to );
      if ( !Utils.isEmpty( channelId ) ) {
        bufferStream = bufferStream.filter( line -> {
          String logChannelId = getLogChId( line );
          return includeGeneral ? isGeneral( logChannelId ) || channelId.contains( logChannelId ) : channelId.contains( logChannelId );
        } );
      }
      return bufferStream.map( BufferLine::getEvent ).collect( Collectors.toList() );
    } finally {
      lock.readLock().unlock();
    }
  }

  /**
   * @param parentLogChannelId the parent log channel ID to grab
   * @param includeGeneral     include general log lines
   * @param from
   * @param to
   * @return
   */
  public List<KettleLoggingEvent> getLogBufferFromTo( String parentLogChannelId, boolean includeGeneral, int from,
                                                      int to ) {

    // Typically, the log channel id is the one from the transformation or job running currently.
    // However, we also want to see the details of the steps etc.
    // So we need to look at the parents all the way up if needed...
    //
    List<String> childIds = loggingRegistry.getLogChannelChildren( parentLogChannelId );

    return getLogBufferFromTo( childIds, includeGeneral, from, to );
  }

  public StringBuffer getBuffer( String parentLogChannelId, boolean includeGeneral, int startLineNr, int endLineNr ) {
    StringBuilder eventBuffer = new StringBuilder( 10000 );

    List<KettleLoggingEvent> events =
      getLogBufferFromTo( parentLogChannelId, includeGeneral, startLineNr, endLineNr );
    for ( KettleLoggingEvent event : events ) {
      eventBuffer.append( layout.format( event ) ).append( Const.CR );
    }

    return new StringBuffer( eventBuffer );
  }

  public StringBuffer getBuffer( String parentLogChannelId, boolean includeGeneral ) {
    return getBuffer( parentLogChannelId, includeGeneral, 0 );
  }

  public StringBuffer getBuffer( String parentLogChannelId, boolean includeGeneral, int startLineNr ) {
    return getBuffer( parentLogChannelId, includeGeneral, startLineNr, getLastBufferLineNr() );
  }

  public StringBuffer getBuffer() {
    return getBuffer( null, true );
  }

  public void close() {
  }

  public void doAppend( KettleLoggingEvent event ) {
    if ( event.getMessage() instanceof LogMessage ) {
      lock.writeLock().lock();
      try {
        buffer.add( new BufferLine( event ) );
        while ( bufferSize > 0 && buffer.size() > bufferSize ) {
          buffer.remove( 0 );
        }
      } finally {
        lock.writeLock().unlock();
      }
    }
  }

  public void setName( String name ) {
    this.name = name;
  }

  public String getName() {
    return name;
  }

  public void setLayout( KettleLogLayout layout ) {
    this.layout = layout;
  }

  public KettleLogLayout getLayout() {
    return layout;
  }

  public boolean requiresLayout() {
    return true;
  }

  public void clear() {
    lock.writeLock().lock();
    try {
      buffer.clear();
    } finally {
      lock.writeLock().unlock();
    }
  }

  /**
   * @return the maximum number of lines that this buffer contains, 0 or lower means: no limit
   */
  public int getMaxNrLines() {
    return bufferSize;
  }

  /**
   * @param maxNrLines the maximum number of lines that this buffer should contain, 0 or lower means: no limit
   */
  public void setMaxNrLines( int maxNrLines ) {
    this.bufferSize = maxNrLines;
  }

  /**
   * @return the nrLines
   */
  public int getNrLines() {
    return buffer.size();
  }

  /**
   * Removes all rows for the channel with the specified id
   *
   * @param id the id of the logging channel to remove
   */
  public void removeChannelFromBuffer( String id ) {
    lock.writeLock().lock();
    try {
      buffer.removeIf( line -> id.equals( getLogChId( line ) ) );
    } finally {
      lock.writeLock().unlock();
    }
  }

  public int size() {
    return buffer.size();
  }

  public void removeGeneralMessages() {
    lock.writeLock().lock();
    try {
      buffer.removeIf( line -> isGeneral( getLogChId( line ) ) );
    } finally {
      lock.writeLock().unlock();
    }
  }

  /**
   * We should not expose iterator out of the class.
   * Looks like it's only used in tests.
   *
   * Marked deprecated for now.
   * TODO: To be made package-level in future.
   */
  @Deprecated
  @VisibleForTesting
  public Iterator<BufferLine> getBufferIterator() {
    return buffer.iterator();
  }

  /**
   * It looks like this method is not used in the project.
   */
  @Deprecated
  public String dump() {
    StringBuilder buf = new StringBuilder( 50000 );
    lock.readLock().lock();
    try {
      buffer.forEach( line -> {
        LogMessage message = (LogMessage) line.getEvent().getMessage();
        buf.append( message.getLogChannelId() ).append( "\t" )
                .append( message.getSubject() ).append( "\n" );
      } );
      return buf.toString();
    } finally {
      lock.readLock().unlock();
    }
  }

  /**
   * Was used in a pair with {@link #getBufferLinesBefore(long)}.
   *
   * @deprecated in favor of {@link #removeBufferLinesBefore(long)}.
   */
  @Deprecated
  public void removeBufferLines( List<BufferLine> linesToRemove ) {
    lock.writeLock().lock();
    try {
      buffer.removeAll( linesToRemove );
    } finally {
      lock.writeLock().unlock();
    }
  }

  /**
   * Was used in a pair with {@link #removeBufferLines(List)}.
   *
   * @deprecated in favor of {@link #removeBufferLinesBefore(long)}.
   */
  @Deprecated
  public List<BufferLine> getBufferLinesBefore( long minTimeBoundary ) {
    lock.readLock().lock();
    try {
      return buffer.stream().filter( line -> line.getEvent().timeStamp < minTimeBoundary )
        .collect( Collectors.toList() );
    } finally {
      lock.readLock().unlock();
    }
  }

  public void removeBufferLinesBefore( long minTimeBoundary ) {
    // Using HashSet even though BufferLine does not implement hashcode and equals,
    // we just need to remove the exact objects we have found and put in the set.
    Set<BufferLine> linesToRemove = new HashSet<>();
    lock.writeLock().lock();
    try {
      for ( BufferLine bufferLine : buffer ) {
        if ( bufferLine.getEvent().timeStamp < minTimeBoundary ) {
          linesToRemove.add( bufferLine );
        } else {
          break;
        }
      }
      // removeAll should run fast against a HashSet,
      // since ArrayList.batchRemove check for each element of a collection given if it is in the ArrayList.
      // Thus, removeAll should run in a linear time.
      buffer.removeAll( linesToRemove );
    } finally {
      lock.writeLock().unlock();
    }
  }

  public void addLogggingEvent( KettleLoggingEvent loggingEvent ) {
    doAppend( loggingEvent );
    eventListeners.forEach( event -> event.eventAdded( loggingEvent ) );
  }

  public void addLoggingEventListener( KettleLoggingEventListener listener ) {
    eventListeners.add( listener );
  }

  public void removeLoggingEventListener( KettleLoggingEventListener listener ) {
    eventListeners.remove( listener );
  }

  private boolean isGeneral( String logChannelId ) {
    LoggingObjectInterface loggingObject = loggingRegistry.getLoggingObject( logChannelId );
    return loggingObject != null && LoggingObjectType.GENERAL.equals( loggingObject.getObjectType() );
  }

  private static String getLogChId( BufferLine bufferLine ) {
    return ( (LogMessage) bufferLine.getEvent().getMessage() ).getLogChannelId();
  }
}


text:
#ifndef __ANISOTROPICITERATIVECLOSESTPOINTREGISTRATION_H__
#define __ANISOTROPICITERATIVECLOSESTPOINTREGISTRATION_H__

//MITK
#include <mitkCommon.h>
#include <mitkVector.h>

//EXPORTS
#include "MitkAlgorithmsExtExports.h"

// STL
#include <vector>

// ITK
#include <itkMatrix.h>

// forward declarations
class vtkPoints;
class vtkKdTreePointLocator;

namespace mitk
{

class Surface;
class WeightedPointTransform;

/**
  * \ingroup AnisotropicRegistration
  *
  * @brief Implementation of the anisotropic iterative closest point (A-ICP)
  * algoritm.
  *
  * This class implements the anisotropic interative closest point (A-ICP)
  * algorithm presented in L. Maier-Hein et al. in "Convergent Iterative
  * Closest-Point Algorithm to Accomodate Anisotropic and Inhomogenous
  * Localization Error.", IEEE T Pattern Anal 34 (8), 1520-1532, 2012.
  * The algorithm computes the optimal transformation to align two surfaces.
  * In addition to the surfaces a list of covariance matrices is used as
  * input for every surface. Each covariance matrix represents the error of
  * a specific vertex in the Surface. The covariance matrices
  * for each surface can be defined by the user, or calculated
  * by the CovarianceMatrixCalculator. In addition a trimmed algorithm version
  * is provided to compute the registration of partial overlapping surfaces.
  * The algorithm needs a clean surface non manifold edges and without duplicated
  * vertices. In addition vtkCleanPolyData can be used to ensure a correct
  * Surface representation.
  *
  * \note The correspondence search is accelerated when OpenMP is enabled.
  *
  * \b Example:
  *
  *
  * \code
  * typedef itk::Matrix < double, 3, 3 > Matrix3x3;
  * typedef itk::Vector < double, 3 > Vector3;
  * typedef std::vector < Matrix3x3 > CovarianceMatrixList;
  *
  * // compute the covariance matrices
  * mitk::CovarianceMatrixCalculator::Pointer matrixCalculator =
  *                                    mitk::CovarianceMatrixCalculator::New();
  *
  * // compute the covariance matrices for the moving surface (X)
  * matrixCalculator->SetInputSurface(movingSurface);
  * matrixCalculator->ComputeCovarianceMatrices();
  * CovarianceMatrixList sigmas_X = matrixCalculator->GetCovarianceMatrices();
  * double meanVarX = matrixCalculator->GetMeanVariance();
  *
  * // compute the covariance matrices for the fixed surface (Y)
  * matrixCalculator->SetInputSurface(fixedSurface);
  * matrixCalculator->ComputeCovarianceMatrices();
  * CovarianceMatrixList sigmas_Y = matrixCalculator->GetCovarianceMatrices();
  * double meanVarY = matrixCalculator->GetMeanVariance();
  *
  * // the FRE normalization factor
  * double normalizationFactor = sqrt( meanVarX + meanVarY);
  *
  * // A-ICP algorithm
  * mitk::AnisotropicIterativeClosestPointRegistration::Pointer aICP =
  *    mitk::AnisotropicIterativeClosestPointRegistration::New();
  *
  * // set up parameters
  * aICP->SetMovingSurface(movingSurface);
  * aICP->SetFixedSurface(fixedSurface);
  * aICP->SetCovarianceMatricesMovingSurface(sigmas_X);
  * aICP->SetCovarianceMatricesFixedSurface(sigmas_Y);
  * aICP->SetFRENormalizationFactor(normalizationFactor);
  *
  * // Trimming is enabled if a fator > 0.0 is set.
  * // 40 percent of the moving point set
  * // will be used for registration in this example.
  * // To disable trimming set the trim factor back to 0.0
  * aICP->SetTrimmFactor(0.4);
  *
  * // run the algorithm
  * aICP->Update();
  *
  * // retrieve the computed transformation
  * Matrix3x3 rotation = aICP->GetRotation();
  * Vector3 translation = aICP->GetTranslation();
  * \endcode
  *
  */
class MITKALGORITHMSEXT_EXPORT AnisotropicIterativeClosestPointRegistration : public itk::Object
{

protected:

  /** Definition of a 3x3 covariance matrix.*/
  typedef itk::Matrix < double, 3, 3 > CovarianceMatrix;
  /** Definition of a list of covariance matrices.*/
  typedef std::vector< CovarianceMatrix > CovarianceMatrixList;
  /** Definition of a translation vector.*/
  typedef mitk::Vector3D Translation;
  /** Definition of a 3x3 rotation matrix.*/
  typedef CovarianceMatrix Rotation;
  /** Definition of a correspondeces, index and distance.*/
  typedef std::pair < unsigned int, double > Correspondence;
  /** Definition of a list of correspondences.*/
  typedef std::vector < Correspondence > CorrespondenceList;

  AnisotropicIterativeClosestPointRegistration();
  ~AnisotropicIterativeClosestPointRegistration();

  /** Max amount of iterations. Default is 1000.*/
  unsigned int m_MaxIterations;

  /** Threshold used for termination. Default is 1.0e-6.*/
  double m_Threshold;

  /** Normalization factor for the feducial registration error. default is 0.0.*/
  double m_FRENormalizationFactor;

  /** Search radius for the correspondence search. Default is 30.*/
  double m_SearchRadius;

  /** The maximum number of iterations in the weighted point based
    * registration. Default is 1000.
    */
  double m_MaxIterationsInWeightedPointTransform;

  /** The fiducial registration error (FRE).*/
  double m_FRE;

  /** Trimmfactor for partial overlapping registration. Default is 0.*/
  double m_TrimmFactor;

  /** Amount of iterations used by the algorithm.*/
  unsigned int m_NumberOfIterations;

  /** Moving surface that is transformed on the fixed surface.*/
  itk::SmartPointer < Surface > m_MovingSurface;
  /** The fixed / target surface.*/
  itk::SmartPointer < Surface > m_FixedSurface;

  /** The weighted point based registration algorithm.*/
  itk::SmartPointer < WeightedPointTransform > m_WeightedPointTransform;

  /** The covariance matrices belonging to the moving surface (X).*/
  CovarianceMatrixList m_CovarianceMatricesMovingSurface;

  /** The covariance matrices belonging to the moving surface (Y).*/
  CovarianceMatrixList m_CovarianceMatricesFixedSurface;

  /** The computed 3x1 translation vector.*/
  Translation m_Translation;
  /** The computed 3x3 rotation matrix.*/
  Rotation    m_Rotation;

  /**
    * Method that computes the correspondences between the moving point set X
    * and the fixed point set Y. The distances between the points
    * are weighted with weight matrices that are computed from the covariances
    * along the surfaces axes. This method implements the runtime optimization
    * presented by L. Maier-Hein et al.. The correspondences are computed with
    * the help of a kd tree. The correspondences are searched in a given radius
    * in the euklidian space. Every correspondence found in this radius is
    * weighted based on the covariance matrices and the best weighting will be
    * used as a correspondence.
    *
    * @param X The moving point set.
    * @param Z The returned correspondences from the fixed point set.
    * @param Y The fixed point set saved in a kd tree.
    * @param sigma_X Covariance matrices belonging to the moving point set.
    * @param sigma_Y Covariance matrices belonging to the fixed point set.
    * @param sigma_Z Covariance matrices belonging to the correspondences found.
    * @param correspondences Saved correspondences, in a pair containing the
    *        their index in Y and distance.
    * @param radius The search radius used in in kd tree.
    *
    */
  void ComputeCorrespondences ( vtkPoints* X,
                                vtkPoints* Z,
                                vtkKdTreePointLocator *Y,
                                const CovarianceMatrixList& sigma_X,
                                const CovarianceMatrixList& sigma_Y,
                                CovarianceMatrixList& sigma_Z,
                                CorrespondenceList &correspondences,
                                const double radius
                               );

public:
  mitkClassMacroItkParent(AnisotropicIterativeClosestPointRegistration, itk::Object)
  itkFactorylessNewMacro(Self)
  itkCloneMacro(Self)

  /** Set the maximum amount of iterations used by the algorithm. */
  itkSetMacro(MaxIterations, unsigned int)

  /** Set the threshold used to terminate the algorithm.*/
  itkSetMacro(Threshold, double)

  /** Set the normalization factor for the fiducial registration error (FRE).
   *  The normalization factor is computed with the help of the mean variance
   *  of both CovarianceMatrixList that can be obtained when the covariance
   *  matrices are calculated with the CovarianceMatrixCalculator:
   *
   *  \code{.cpp}
   *  double FRENormalizationFactor = sqrt ( MeanVarianceX + MeanVarianceY );
   *  \endcode
   *
   *  if no FRE normalization is used the normalization factor is set to 1.0
   *  as default value.
   */
  itkSetMacro(FRENormalizationFactor, double)

  /** Set search radius for the correspondence search.*/
  itkSetMacro(SearchRadius, double)

  /** Set the maximim number of iterations used by the point based registration
    * algorithm.
    */
  itkSetMacro(MaxIterationsInWeightedPointTransform, double)

  /** Get the fiducial registration error (FRE).*/
  itkGetMacro(FRE,double)

  /** Get the number of iterations used by the algorithm.*/
  itkGetMacro(NumberOfIterations, unsigned int)

  /**
    * Factor that trimms the point set in percent for
    * partial overlapping surfaces. E.g. 0.4 will use 40 precent
    * of the point set. To enable the trimmed version a
    * factor > 0 and < 1 must be set. The default value is 0.0.
    */
  itkSetMacro(TrimmFactor,double)

  /**
    * Set moving surface that includes the point set (X).
    */
  itkSetMacro(MovingSurface,itk::SmartPointer<Surface>)

  /**
    * Set fixed surface that includes the point set (Y).
    */
  itkSetMacro(FixedSurface,itk::SmartPointer<Surface>)

  /**
    * Returns the 3x1 translation vector computed by the algorithm.
    */
  itkGetConstReferenceMacro(Translation,Translation)

  /**
    * Returns the 3x3 rotation matrix computed by the algorithm.
    */
  itkGetConstReferenceMacro(Rotation,Rotation)

  /**
    * Set the covariance matrices of the moving surface. The algorithm
    * need the same amount of covariance and points available in the surface.
    * The covariance matrix for every vertex in a Surface can be calculated by
    * the CovarianceMatrixCalculator. It is also possible to define
    * arbitrary matrices by hand.
    */
  void SetCovarianceMatricesMovingSurface( CovarianceMatrixList& list )
  {
    m_CovarianceMatricesMovingSurface = list;
  }

  /**
    * Set the covariance matrices of the fixed surface. The algorithm
    * need the same amount of covariance and points available in the surface.
    * The covariance matrix for every vertex in a Surface can be calculated by
    * the CovarianceMatrixCalculator. It is also possible to define
    * arbitrary matrices by hand.
    */
  void SetCovarianceMatricesFixedSurface( CovarianceMatrixList& list )
  {
    m_CovarianceMatricesFixedSurface = list;
  }

  /**
    * This method executes the algorithm.
    *
    * @warning The algorithm is only a simple calculation filter and can not be
    * used in a mitk filter pipline.
    *
    * @throws Exception if the search radius was doubled more than 20 times to
    * prevent endless loops. Re-run the with a different search radius that
    * will find the correspondences.
    */
  void Update();
};

}
#endif


text:
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>shadow</groupId>
    <artifactId>compiler</artifactId>
    <version>0.8</version>
    <name>Shadow Compiler</name>
    <url>www.shadow-language.org</url>
    <description>A compiler for the Shadow programming language</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>src</directory>
                            <includes>
                                <include>**/*.meta</include>
                                <include>**/*.ll</include>
                                <include>**/*.s</include>
                                <include>**/*.o</include>
                                <include>**/*.bc</include>
                            </includes>
                            <excludes>
                                <exclude>**/*.native.ll</exclude>
                                <exclude>Linux.ll</exclude>
                                <exclude>Mac.ll</exclude>
                                <exclude>Main.ll</exclude>
                                <exclude>NoArguments.ll</exclude>
                                <exclude>MainWindows.ll</exclude>
                                <exclude>NoArgumentsWindows.ll</exclude>
                                <exclude>Unwind32.ll</exclude>
                                <exclude>Unwind64.ll</exclude>
                                <exclude>UnwindWindows32.ll</exclude>
                                <exclude>UnwindWindows64.ll</exclude>
                                <exclude>Windows.ll</exclude>
                                <exclude>Shared.ll</exclude>
                            </excludes>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                        <fileset>
                            <directory>bin</directory>
                            <includes>
                                <include>**/*</include>
                            </includes>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                        <fileset>
                            <directory>tests</directory>
                            <includes>
                                <include>**/*.meta</include>
                            </includes>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                        <fileset>
                            <directory>tests-negative</directory>
                            <includes>
                                <include>**/*.meta</include>
                            </includes>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                        <fileset>
                            <directory>src/main/java/shadow/parse</directory>
                            <includes>
                                <include>*.tokens</include>
                                <include>*.interp</include>
                                <include>ShadowBaseVisitor.java</include>
                                <include>ShadowLexer.java</include>
                                <include>ShadowParser.java</include>
                                <include>ShadowVisitor.java</include>
                            </includes>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>shadow.Main</mainClass>
                                    <manifestEntries>
                                        <Multi-Release>true</Multi-Release>
                                    </manifestEntries>
                                </transformer>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.0</version>
            </plugin>
            <plugin>
                <groupId>org.antlr</groupId>
                <artifactId>antlr4-maven-plugin</artifactId>
                <version>4.9.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>antlr4</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>src/main/java/shadow/parse</outputDirectory>
                            <visitor>true</visitor>
                            <listener>false</listener>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <!-- The contents of this pluginManagement section are Unfortunate nonsense that m2e requires to work -->
        <!-- Do NOT confuse this with the normal plugin section, it is completely ignored by Maven -->
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.antlr</groupId>
                                        <artifactId>antlr4-maven-plugin</artifactId>
                                        <versionRange>[4.9.2,)</versionRange>
                                        <goals>
                                            <goal>antlr4</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <execute>
                                            <runOnIncremental>true</runOnIncremental>
                                        </execute>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    <dependencies>
        <dependency>
            <groupId>commons-cli</groupId>
            <artifactId>commons-cli</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.7</version>
        </dependency>
        <dependency>
            <groupId>org.antlr</groupId>
            <artifactId>antlr4-runtime</artifactId>
            <version>4.9.2</version>
        </dependency>
        <dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-api</artifactId>
			<version>2.17.0</version>
		</dependency>
		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-core</artifactId>
			<version>2.17.0</version>
		</dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.8.0-M1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.8.0-M1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>5.8.0-M1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite-api</artifactId>
            <version>1.8.0-M1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite-engine</artifactId>
            <version>1.8.0-M1</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.12.3</version>
        </dependency>
        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna-platform</artifactId>
            <version>5.10.0</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
            <version>13.0</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
</project>


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

#ifndef __INCLUDE_SMART_H
#define __INCLUDE_SMART_H

/****************************************************************************
 * Included Files
 ****************************************************************************/
#include <tinyara/config.h>
#include <sys/types.h>
#include <stdint.h>
#include <tinyara/fs/fs.h>

/****************************************************************************
 * Pre-processor Definitions
 ****************************************************************************/

/* Macros to hide implementation */

#define SMART_FMT_ISFORMATTED   0x01
#define SMART_FMT_HASBYTEWRITE  0x02

/****************************************************************************
 * Public Types
 ****************************************************************************/

/* The following defines the format information for the device.  This
 * information is retrieved via the BIOC_GETFORMAT ioctl.
 */

struct smart_format_s {
	uint16_t sectorsize;		/* Size of one read/write sector */
	uint16_t availbytes;		/* Number of bytes available in each sector */
	uint16_t nsectors;			/* Total number of sectors on device */
	uint16_t nfreesectors;		/* Number of free sectors on device */
	uint8_t flags;				/* Format flags (see above) */
	uint8_t namesize;			/* Size of filenames on this volume */
#ifdef CONFIG_SMARTFS_MULTI_ROOT_DIRS
	uint8_t nrootdirentries;	/* Number of root directories on this device */
	uint8_t rootdirnum;			/* Root directory number for this dev entry */
#endif
};

/* The following defines the information for writing a logical sector
 * to the device.
 */

struct smart_read_write_s {
	uint16_t logsector;			/* The logical sector number */
	uint16_t offset;			/* Offset within the sector to write to */
	uint16_t count;				/* Number of bytes to write */
	const uint8_t *buffer;		/* Pointer to the data to write */
};

/* The following defines the procfs data exchange interface between the
 * SMART MTD and FS layers.
 */

#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_SMARTFS)
struct smart_procfs_data_s {
#ifdef CONFIG_MTD_SMART_ERASE_DEBUG
	const uint16_t *erasecounts;	/* Pointer to the erase counts array */
	uint16_t erasesize;		/* Number of entries in the erase counts array */
#endif
};
#endif

/****************************************************************************
 * Public Data
 ****************************************************************************/
#ifdef CONFIG_SMARTFS_DYNAMIC_HEADER
uint16_t chunk_shift;
uint16_t used_block_divident;
size_t smart_sect_header_size;
#endif

#ifndef __ASSEMBLY__

#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif

/****************************************************************************
 * Public Function Prototypes
 ****************************************************************************/

/****************************************************************************
 * Description:
 *   This is used to format the flash in smartFs
 *
 ****************************************************************************/
void smart_set_format_status(bool value);

/****************************************************************************
 * Description:
 *   This is used to know if flash is already formated by smartFs
 *
 ****************************************************************************/
bool smart_get_format_status(void);

#undef EXTERN
#ifdef __cplusplus
}
#endif

#endif							/* __ASSEMBLY__ */
#endif							/* __INCLUDE_SMART_H */


text:
cask "screens" do
  version "4.9.2,1642017112"
  sha256 "ce214c4f7a44d85ce2e51e5e9111886953ed46b49031fd8fd4cca17a080560e7"

  url "https://updates.edovia.com/com.edovia.screens#{version.major}.mac/Screens_#{version.csv.first}b#{version.csv.second}.zip"
  name "Screens"
  desc "Remote access software focusing on usability"
  homepage "https://edovia.com/screens-mac/"

  livecheck do
    url "https://updates.edovia.com/com.edovia.screens#{version.major}.mac/appcast.xml"
    strategy :sparkle
  end

  auto_updates true
  depends_on macos: ">= :sierra"

  app "Screens #{version.major}.app"

  uninstall launchctl: "com.edovia.screens.launcher",
            quit:      "com.edovia.screens#{version.major}.mac"

  zap trash: [
    "~/Library/Application Scripts/com.edovia.screens#{version.major}.mac",
    "~/Library/Application Scripts/com.edovia.screens.launcher",
    "~/Library/Containers/com.edovia.screens#{version.major}.mac",
    "~/Library/Containers/com.edovia.screens.launcher",
    "~/Library/Preferences/com.edovia.screens#{version.major}.mac.plist",
    "~/Library/Logs/Screens",
  ]
end


text:
namespace ColladaDOM150 {
daeElementRef
domProfile_gles2::create(DAE& dae)
{
	domProfile_gles2Ref ref = new domProfile_gles2(dae);
	return ref;
}

daeMetaElement *
domProfile_gles2::registerElement(DAE& dae)
{
	daeMetaElement* meta = dae.getMeta(ID());
	if ( meta != NULL ) return meta;

	meta = new daeMetaElement(dae);
	dae.setMeta(ID(), *meta);
	meta->setName( "profile_gles2" );
	meta->registerClass(domProfile_gles2::create);

	daeMetaCMPolicy *cm = NULL;
	daeMetaElementAttribute *mea = NULL;
	cm = new daeMetaSequence( meta, cm, 0, 1, 1 );

	mea = new daeMetaElementAttribute( meta, cm, 0, 0, 1 );
	mea->setName( "asset" );
	mea->setOffset( daeOffsetOf(domProfile_gles2,elemAsset) );
	mea->setElementType( domAsset::registerElement(dae) );
	cm->appendChild( mea );

	cm = new daeMetaChoice( meta, cm, 0, 1, 0, -1 );

	mea = new daeMetaElementArrayAttribute( meta, cm, 0, 1, 1 );
	mea->setName( "include" );
	mea->setOffset( daeOffsetOf(domProfile_gles2,elemInclude_array) );
	mea->setElementType( domFx_include::registerElement(dae) );
	cm->appendChild( mea );

	mea = new daeMetaElementArrayAttribute( meta, cm, 0, 1, 1 );
	mea->setName( "code" );
	mea->setOffset( daeOffsetOf(domProfile_gles2,elemCode_array) );
	mea->setElementType( domFx_code::registerElement(dae) );
	cm->appendChild( mea );

	cm->setMaxOrdinal( 0 );
	cm->getParent()->appendChild( cm );
	cm = cm->getParent();

	mea = new daeMetaElementArrayAttribute( meta, cm, 3002, 0, -1 );
	mea->setName( "newparam" );
	mea->setOffset( daeOffsetOf(domProfile_gles2,elemNewparam_array) );
	mea->setElementType( domProfile_gles2::domNewparam::registerElement(dae) );
	cm->appendChild( mea );

	mea = new daeMetaElementArrayAttribute( meta, cm, 3003, 1, -1 );
	mea->setName( "technique" );
	mea->setOffset( daeOffsetOf(domProfile_gles2,elemTechnique_array) );
	mea->setElementType( domProfile_gles2::domTechnique::registerElement(dae) );
	cm->appendChild( mea );

	mea = new daeMetaElementArrayAttribute( meta, cm, 3004, 0, -1 );
	mea->setName( "extra" );
	mea->setOffset( daeOffsetOf(domProfile_gles2,elemExtra_array) );
	mea->setElementType( domExtra::registerElement(dae) );
	cm->appendChild( mea );

	cm->setMaxOrdinal( 3004 );
	meta->setCMRoot( cm );
	// Ordered list of sub-elements
	meta->addContents(daeOffsetOf(domProfile_gles2,_contents));
	meta->addContentsOrder(daeOffsetOf(domProfile_gles2,_contentsOrder));

	meta->addCMDataArray(daeOffsetOf(domProfile_gles2,_CMData), 1);
	//	Add attribute: id
	{
		daeMetaAttribute *ma = new daeMetaAttribute;
		ma->setName( "id" );
		ma->setType( dae.getAtomicTypes().get("xsID"));
		ma->setOffset( daeOffsetOf( domProfile_gles2 , attrId ));
		ma->setContainer( meta );

		meta->appendAttribute(ma);
	}

	//	Add attribute: language
	{
		daeMetaAttribute *ma = new daeMetaAttribute;
		ma->setName( "language" );
		ma->setType( dae.getAtomicTypes().get("xsNCName"));
		ma->setOffset( daeOffsetOf( domProfile_gles2 , attrLanguage ));
		ma->setContainer( meta );
		ma->setIsRequired( true );

		meta->appendAttribute(ma);
	}

	//	Add attribute: platforms
	{
		daeMetaAttribute *ma = new daeMetaArrayAttribute;
		ma->setName( "platforms" );
		ma->setType( dae.getAtomicTypes().get("List_of_names"));
		ma->setOffset( daeOffsetOf( domProfile_gles2 , attrPlatforms ));
		ma->setContainer( meta );

		meta->appendAttribute(ma);
	}

	meta->setElementSize(sizeof(domProfile_gles2));
	meta->validate();

	return meta;
}

daeElementRef
domProfile_gles2::domNewparam::create(DAE& dae)
{
	domProfile_gles2::domNewparamRef ref = new domProfile_gles2::domNewparam(dae);
	return ref;
}

daeMetaElement *
domProfile_gles2::domNewparam::registerElement(DAE& dae)
{
	daeMetaElement* meta = dae.getMeta(ID());
	if ( meta != NULL ) return meta;

	meta = new daeMetaElement(dae);
	dae.setMeta(ID(), *meta);
	meta->setName( "newparam" );
	meta->registerClass(domProfile_gles2::domNewparam::create);

	meta->setIsInnerClass( true );
	daeMetaCMPolicy *cm = NULL;
	daeMetaElementAttribute *mea = NULL;
	cm = new daeMetaSequence( meta, cm, 0, 1, 1 );

	cm = new daeMetaSequence( meta, cm, 0, 1, 1 );

	mea = new daeMetaElementArrayAttribute( meta, cm, 0, 0, -1 );
	mea->setName( "annotate" );
	mea->setOffset( daeOffsetOf(domProfile_gles2::domNewparam,elemAnnotate_array) );
	mea->setElementType( domFx_annotate::registerElement(dae) );
	cm->appendChild( mea );

	mea = new daeMetaElementAttribute( meta, cm, 1, 0, 1 );
	mea->setName( "semantic" );
	mea->setOffset( daeOffsetOf(domProfile_gles2::domNewparam,elemSemantic) );
	mea->setElementType( domSemantic::registerElement(dae) );
	cm->appendChild( mea );

	mea = new daeMetaElementAttribute( meta, cm, 2, 0, 1 );
	mea->setName( "modifier" );
	mea->setOffset( daeOffsetOf(domProfile_gles2::domNewparam,elemModifier) );
	mea->setElementType( domModifier::registerElement(dae) );
	cm->appendChild( mea );

	mea = new daeMetaElementAttribute( meta, cm, 3, 1, 1 );
	mea->setName( "gles2_value" );
	mea->setOffset( daeOffsetOf(domProfile_gles2::domNewparam,elemGles2_value) );
	mea->setElementType( domGles2_value::registerElement(dae) );
	cm->appendChild( new daeMetaGroup( mea, meta, cm, 3, 1, 1 ) );

	cm->setMaxOrdinal( 3 );
	cm->getParent()->appendChild( cm );
	cm = cm->getParent();

	cm->setMaxOrdinal( 3 );
	meta->setCMRoot( cm );

	//	Add attribute: sid
	{
		daeMetaAttribute *ma = new daeMetaAttribute;
		ma->setName( "sid" );
		ma->setType( dae.getAtomicTypes().get("Sid"));
		ma->setOffset( daeOffsetOf( domProfile_gles2::domNewparam , attrSid ));
		ma->setContainer( meta );
		ma->setIsRequired( true );

		meta->appendAttribute(ma);
	}

	meta->setElementSize(sizeof(domProfile_gles2::domNewparam));
	meta->validate();

	return meta;
}

daeElementRef
domProfile_gles2::domTechnique::create(DAE& dae)
{
	domProfile_gles2::domTechniqueRef ref = new domProfile_gles2::domTechnique(dae);
	return ref;
}

daeMetaElement *
domProfile_gles2::domTechnique::registerElement(DAE& dae)
{
	daeMetaElement* meta = dae.getMeta(ID());
	if ( meta != NULL ) return meta;

	meta = new daeMetaElement(dae);
	dae.setMeta(ID(), *meta);
	meta->setName( "technique" );
	meta->registerClass(domProfile_gles2::domTechnique::create);

	meta->setIsInnerClass( true );
	daeMetaCMPolicy *cm = NULL;
	daeMetaElementAttribute *mea = NULL;
	cm = new daeMetaSequence( meta, cm, 0, 1, 1 );

	mea = new daeMetaElementAttribute( meta, cm, 0, 0, 1 );
	mea->setName( "asset" );
	mea->setOffset( daeOffsetOf(domProfile_gles2::domTechnique,elemAsset) );
	mea->setElementType( domAsset::registerElement(dae) );
	cm->appendChild( mea );

	mea = new daeMetaElementArrayAttribute( meta, cm, 1, 0, -1 );
	mea->setName( "annotate" );
	mea->setOffset( daeOffsetOf(domProfile_gles2::domTechnique,elemAnnotate_array) );
	mea->setElementType( domFx_annotate::registerElement(dae) );
	cm->appendChild( mea );

	mea = new daeMetaElementArrayAttribute( meta, cm, 2, 1, -1 );
	mea->setName( "pass" );
	mea->setOffset( daeOffsetOf(domProfile_gles2::domTechnique,elemPass_array) );
	mea->setElementType( domGles2_pass::registerElement(dae) );
	cm->appendChild( mea );

	mea = new daeMetaElementArrayAttribute( meta, cm, 3, 0, -1 );
	mea->setName( "extra" );
	mea->setOffset( daeOffsetOf(domProfile_gles2::domTechnique,elemExtra_array) );
	mea->setElementType( domExtra::registerElement(dae) );
	cm->appendChild( mea );

	cm->setMaxOrdinal( 3 );
	meta->setCMRoot( cm );

	//	Add attribute: id
	{
		daeMetaAttribute *ma = new daeMetaAttribute;
		ma->setName( "id" );
		ma->setType( dae.getAtomicTypes().get("xsID"));
		ma->setOffset( daeOffsetOf( domProfile_gles2::domTechnique , attrId ));
		ma->setContainer( meta );

		meta->appendAttribute(ma);
	}

	//	Add attribute: sid
	{
		daeMetaAttribute *ma = new daeMetaAttribute;
		ma->setName( "sid" );
		ma->setType( dae.getAtomicTypes().get("Sid"));
		ma->setOffset( daeOffsetOf( domProfile_gles2::domTechnique , attrSid ));
		ma->setContainer( meta );
		ma->setIsRequired( true );

		meta->appendAttribute(ma);
	}

	meta->setElementSize(sizeof(domProfile_gles2::domTechnique));
	meta->validate();

	return meta;
}

} // ColladaDOM150


text:
    <link href="./index.lol" type="intl/l20n" />

    <link rel="stylesheet" type="text/css" href="../_lib/jasmine/jasmine.css">
    <link rel="stylesheet" type="text/css" href="../_lib/test.css">

      This example introduces a "l10nData" property of the document object that
      enables the developer to manipulate the document level context data
      provided to the localizer.

    <input type="text" data-l10n-id="name_input"/>

    <button onclick="test()">retranslate</button>


text:
import { between, extend, warn } from '@better-scroll/shared-utils'
import BScroll from '@better-scroll/core'
import { SlideConfig } from './index'
import PagesMatrix, { PageStats } from './PagesMatrix'
import { BASE_PAGE } from './constants'

export interface PageIndex {
  pageX: number
  pageY: number
}
export interface Position {
  x: number
  y: number
}

export type Page = PageIndex & Position

const enum Direction {
  Positive = 'positive',
  Negative = 'negative',
}

export default class SlidePages {
  loopX: boolean
  loopY: boolean
  slideX: boolean = false
  slideY: boolean = false
  wannaLoop: boolean
  pagesMatrix: PagesMatrix
  currentPage: Page
  constructor(public scroll: BScroll, private slideOptions: SlideConfig) {
    this.currentPage = extend({}, BASE_PAGE)
  }

  refresh() {
    this.pagesMatrix = new PagesMatrix(this.scroll)
    this.checkSlideLoop()
    this.currentPage = this.getAdjustedCurrentPage()
  }

  getAdjustedCurrentPage(): Page {
    let { pageX, pageY } = this.currentPage
    // page index should be handled
    // because page counts may reduce
    pageX = Math.min(pageX, this.pagesMatrix.pageLengthOfX - 1)
    pageY = Math.min(pageY, this.pagesMatrix.pageLengthOfY - 1)
    // loop scene should also be respected
    // because clonedNode will cause pageLength increasing
    if (this.loopX) {
      pageX = Math.min(pageX, this.pagesMatrix.pageLengthOfX - 2)
    }
    if (this.loopY) {
      pageY = Math.min(pageY, this.pagesMatrix.pageLengthOfY - 2)
    }
    const { x, y } = this.pagesMatrix.getPageStats(pageX, pageY)
    return { pageX, pageY, x, y }
  }

  setCurrentPage(newPage: Page) {
    this.currentPage = newPage
  }

  getInternalPage(pageX: number, pageY: number): Page {
    if (pageX >= this.pagesMatrix.pageLengthOfX) {
      pageX = this.pagesMatrix.pageLengthOfX - 1
    } else if (pageX < 0) {
      pageX = 0
    }

    if (pageY >= this.pagesMatrix.pageLengthOfY) {
      pageY = this.pagesMatrix.pageLengthOfY - 1
    } else if (pageY < 0) {
      pageY = 0
    }

    let { x, y } = this.pagesMatrix.getPageStats(pageX, pageY)

    return {
      pageX,
      pageY,
      x,
      y,
    }
  }

  getInitialPage(
    showFirstPage: boolean = false,
    firstInitialised: boolean = false
  ): Page {
    const { startPageXIndex, startPageYIndex } = this.slideOptions
    let firstPageX = this.loopX ? 1 : 0
    let firstPageY = this.loopY ? 1 : 0

    let pageX = showFirstPage ? firstPageX : this.currentPage.pageX
    let pageY = showFirstPage ? firstPageY : this.currentPage.pageY

    if (firstInitialised) {
      pageX = this.loopX ? startPageXIndex + 1 : startPageXIndex
      pageY = this.loopY ? startPageYIndex + 1 : startPageYIndex
    } else {
      pageX = showFirstPage ? firstPageX : this.currentPage.pageX
      pageY = showFirstPage ? firstPageY : this.currentPage.pageY
    }

    const { x, y } = this.pagesMatrix.getPageStats(pageX, pageY)

    return {
      pageX,
      pageY,
      x,
      y,
    }
  }

  getExposedPage(page: Page): Page {
    let exposedPage = extend({}, page)
    // only pageX or pageY need fix
    if (this.loopX) {
      exposedPage.pageX = this.fixedPage(
        exposedPage.pageX,
        this.pagesMatrix.pageLengthOfX - 2
      )
    }
    if (this.loopY) {
      exposedPage.pageY = this.fixedPage(
        exposedPage.pageY,
        this.pagesMatrix.pageLengthOfY - 2
      )
    }
    return exposedPage
  }

  getExposedPageByPageIndex(pageIndexX: number, pageIndexY: number): Page {
    const page = {
      pageX: pageIndexX,
      pageY: pageIndexY,
    }
    if (this.loopX) {
      page.pageX = pageIndexX + 1
    }
    if (this.loopY) {
      page.pageY = pageIndexY + 1
    }
    const { x, y } = this.pagesMatrix.getPageStats(page.pageX, page.pageY)
    return {
      x,
      y,
      pageX: pageIndexX,
      pageY: pageIndexY,
    }
  }

  getWillChangedPage(page: Page): Page {
    page = extend({}, page)
    // Page need fix
    if (this.loopX) {
      page.pageX = this.fixedPage(
        page.pageX,
        this.pagesMatrix.pageLengthOfX - 2
      )
      page.x = this.pagesMatrix.getPageStats(page.pageX + 1, 0).x
    }
    if (this.loopY) {
      page.pageY = this.fixedPage(
        page.pageY,
        this.pagesMatrix.pageLengthOfY - 2
      )
      page.y = this.pagesMatrix.getPageStats(0, page.pageY + 1).y
    }
    return page
  }

  private fixedPage(page: number, realPageLen: number): number {
    const pageIndex = []
    for (let i = 0; i < realPageLen; i++) {
      pageIndex.push(i)
    }
    pageIndex.unshift(realPageLen - 1)
    pageIndex.push(0)
    return pageIndex[page]
  }

  getPageStats(): PageStats {
    return this.pagesMatrix.getPageStats(
      this.currentPage.pageX,
      this.currentPage.pageY
    )
  }

  getValidPageIndex(x: number, y: number): PageIndex {
    let lastX = this.pagesMatrix.pageLengthOfX - 1
    let lastY = this.pagesMatrix.pageLengthOfY - 1
    let firstX = 0
    let firstY = 0
    if (this.loopX) {
      x += 1
      firstX = firstX + 1
      lastX = lastX - 1
    }
    if (this.loopY) {
      y += 1
      firstY = firstY + 1
      lastY = lastY - 1
    }
    x = between(x, firstX, lastX)
    y = between(y, firstY, lastY)

    return {
      pageX: x,
      pageY: y,
    }
  }

  nextPageIndex(): PageIndex {
    return this.getPageIndexByDirection(Direction.Positive)
  }

  prevPageIndex(): PageIndex {
    return this.getPageIndexByDirection(Direction.Negative)
  }

  getNearestPage(x: number, y: number): Page {
    const pageIndex = this.pagesMatrix.getNearestPageIndex(x, y)
    let { pageX, pageY } = pageIndex

    let newX = this.pagesMatrix.getPageStats(pageX, 0).x
    let newY = this.pagesMatrix.getPageStats(0, pageY).y

    return {
      x: newX,
      y: newY,
      pageX,
      pageY,
    }
  }

  getPageByDirection(page: Page, directionX: number, directionY: number): Page {
    let { pageX, pageY } = page
    if (pageX === this.currentPage.pageX) {
      pageX = between(pageX + directionX, 0, this.pagesMatrix.pageLengthOfX - 1)
    }
    if (pageY === this.currentPage.pageY) {
      pageY = between(pageY + directionY, 0, this.pagesMatrix.pageLengthOfY - 1)
    }

    const x = this.pagesMatrix.getPageStats(pageX, 0).x
    const y = this.pagesMatrix.getPageStats(0, pageY).y

    return {
      x,
      y,
      pageX,
      pageY,
    }
  }

  resetLoopPage(): PageIndex | undefined {
    if (this.loopX) {
      if (this.currentPage.pageX === 0) {
        return {
          pageX: this.pagesMatrix.pageLengthOfX - 2,
          pageY: this.currentPage.pageY,
        }
      }
      if (this.currentPage.pageX === this.pagesMatrix.pageLengthOfX - 1) {
        return {
          pageX: 1,
          pageY: this.currentPage.pageY,
        }
      }
    }
    if (this.loopY) {
      if (this.currentPage.pageY === 0) {
        return {
          pageX: this.currentPage.pageX,
          pageY: this.pagesMatrix.pageLengthOfY - 2,
        }
      }
      if (this.currentPage.pageY === this.pagesMatrix.pageLengthOfY - 1) {
        return {
          pageX: this.currentPage.pageX,
          pageY: 1,
        }
      }
    }
  }

  private getPageIndexByDirection(direction: Direction): PageIndex {
    let x = this.currentPage.pageX
    let y = this.currentPage.pageY
    if (this.slideX) {
      x = direction === Direction.Negative ? x - 1 : x + 1
    }
    if (this.slideY) {
      y = direction === Direction.Negative ? y - 1 : y + 1
    }
    return {
      pageX: x,
      pageY: y,
    }
  }

  private checkSlideLoop() {
    this.wannaLoop = this.slideOptions.loop
    if (this.pagesMatrix.pageLengthOfX > 1) {
      this.slideX = true
    } else {
      this.slideX = false
    }
    if (this.pagesMatrix.pages[0] && this.pagesMatrix.pageLengthOfY > 1) {
      this.slideY = true
    } else {
      this.slideY = false
    }
    this.loopX = this.wannaLoop && this.slideX
    this.loopY = this.wannaLoop && this.slideY

    if (this.slideX && this.slideY) {
      warn('slide does not support two direction at the same time.')
    }
  }
}


text:
module.exports = function (grunt) {
    grunt.config('csslint', {
            options: {
                'known-properties'              : false,
                'box-sizing'                    : false,
                'box-model'                     : false,
                'compatible-vendor-prefixes'    : false,
                'regex-selectors'               : false,
                'duplicate-background-images'   : false,
                'gradients'                     : false,
                'fallback-colors'               : false,
                'font-sizes'                    : false,
                'font-faces'                    : false,
                'floats'                        : false,
                'star-property-hack'            : false,
                'outline-none'                  : false,
                'import'                        : false,
                'underscore-property-hack'      : false,
                'rules-count'                   : false,
                'qualified-headings'            : false,
                'shorthand'                     : false,
                'text-indent'                   : false,
                'unique-headings'               : false,
                'unqualified-attributes'        : false,
                'vendor-prefix'                 : false,
                'overqualified-elements'        : false,
                'adjoining-classes'				: false,
                'ids'							: false,
                'empty-rules'					: false,
                'force'                         : true
            },
            src: ['./content/<%= pkg.services.default %>/css/main.css']
        });
    grunt.loadNpmTasks('grunt-contrib-csslint');
};


text:
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE134_Uncontrolled_Format_String__char_console_w32_vsnprintf_83_goodB2G.cpp
Label Definition File: CWE134_Uncontrolled_Format_String.vasinks.label.xml
Template File: sources-vasinks-83_goodB2G.tmpl.cpp
*/
/*
 * @description
 * CWE: 134 Uncontrolled Format String
 * BadSource: console Read input from the console
 * GoodSource: Copy a fixed string into data
 * Sinks: w32_vsnprintf
 *    GoodSink: vsnprintf with a format string
 *    BadSink : vsnprintf without a format string
 * Flow Variant: 83 Data flow: data passed to class constructor and destructor by declaring the class object on the stack
 *
 * */
#ifndef OMITGOOD

#include <stdarg.h>
#include "std_testcase.h"
#include "CWE134_Uncontrolled_Format_String__char_console_w32_vsnprintf_83.h"

namespace CWE134_Uncontrolled_Format_String__char_console_w32_vsnprintf_83
{
CWE134_Uncontrolled_Format_String__char_console_w32_vsnprintf_83_goodB2G::CWE134_Uncontrolled_Format_String__char_console_w32_vsnprintf_83_goodB2G(char * dataCopy)
{
    data = dataCopy;
    {
        /* Read input from the console */
        size_t dataLen = strlen(data);
        /* if there is room in data, read into it from the console */
        if (100-dataLen > 1)
        {
            /* POTENTIAL FLAW: Read data from the console */
            if (fgets(data+dataLen, (int)(100-dataLen), stdin) != NULL)
            {
                /* The next few lines remove the carriage return from the string that is
                 * inserted by fgets() */
                dataLen = strlen(data);
                if (dataLen > 0 && data[dataLen-1] == '\n')
                {
                    data[dataLen-1] = '\0';
                }
            }
            else
            {
                printLine("fgets() failed");
                /* Restore NUL terminator if fgets fails */
                data[dataLen] = '\0';
            }
        }
    }
}

static void goodB2GVaSink(char * data, ...)
{
    {
        char dest[100] = "";
        va_list args;
        va_start(args, data);
        /* FIX: Specify the format disallowing a format string vulnerability */
        vsnprintf(dest, 100-1, "%s", args);
        va_end(args);
        printLine(dest);
    }
}

CWE134_Uncontrolled_Format_String__char_console_w32_vsnprintf_83_goodB2G::~CWE134_Uncontrolled_Format_String__char_console_w32_vsnprintf_83_goodB2G()
{
    goodB2GVaSink(data, data);
}
}
#endif /* OMITGOOD */


text:
module MediaFileUtil
  VERSION = '0.0.1'
end


text:
package ru.pavkin.todoist.api.circe.decoders

import cats.data.Xor
import io.circe.Decoder._
import io.circe.generic.decoding.DerivedDecoder
import io.circe.{DecodingFailure, Decoder, HCursor}
import shapeless._

trait PlainCoproductDecoder {

  implicit val decodeCNil: Decoder[CNil] =
    new DerivedDecoder[CNil] {
      final def apply(c: HCursor): Decoder.Result[CNil] =
        Xor.left(DecodingFailure("CNil", c.history))
    }

  implicit def plainCoproductDecoder[H, T <: Coproduct]
  (implicit
   decodeHead: Decoder[H],
   decodeTail: Decoder[T]): Decoder[H :+: T] = new Decoder[H :+: T] {
    def apply(c: HCursor): Result[H :+: T] =
      decodeTail(c).map(Inr(_)).orElse(decodeHead(c).map(Inl(_)))
  }

}


text:
${TARGET_PATH}: bilingual.bin transfer_rules.t1x.bin ${SOURCE_PATH}
	${FLEXTOOLS_PATH}\apertium-transfer -t tr.t1x transfer_rules.t1x.bin bilingual.bin ${SOURCE_PATH} > ${TARGET_PATH} 2> apertium_log.txt
bilingual.bin: ${DICTIONARY_PATH}
	${FLEXTOOLS_PATH}\lt-comp lr ${DICTIONARY_PATH} bilingual.bin
transfer_rules.t1x.bin: tr.t1x
	${FLEXTOOLS_PATH}\apertium-preprocess-transfer tr.t1x transfer_rules.t1x.bin
clean:
	del ${TARGET_PATH} bilingual.bin transfer_rules.t1x.bin


text:
package us.the.mac.android.jni.helpers;

/**
 * Common values for tests which pass objects through JNI.
 * NB: This file is GENERATED. DO NOT EDIT.
 */
public class TestConstants {
    public static final String TEST_URL = "https://httpbin.org/post";
    public static final String TEST_REQUEST = "{ \"parameter\": \"parameterValue\" }";
    public static final String TEST_PARAMETER = "parameterValue";
    public static final String TEST_RESULT = "{ \"args\": {}, \"data\": \"\", \"files\": {}, \"form\": {}, \"headers\": { \"Accept\": \": application/json\", \"Content-Length\": \"0\", \"Content-Type\": \"application/json\", \"Host\": \"httpbin.org\", \"User-Agent\": \"Apache-HttpClient/UNAVAILABLE (java 1.4)\" }, \"json\": null, \"origin\": \"172.58.153.6\", \"url\": \"https://httpbin.org/post\" } ";
    public static final String TEST_HEADERS = "application/json";

    public static final String TEST_DECODED_ENCRYPTION_KEY = "\u0014zis&Ф$l\u001D9\n";
    public static final String TEST_ENCRYPTION_KEY = "FHppc7om5dCkJGzhHYc5ug==\n";

    public static final String TEST_ENCRYPTED = "Up cf ps opu up cf, Uibu jt uif rvftujpo";
    public static final String TEST_ENCRYPTED_RESOURCE = "HiYJ+OroGm0hwPv5hz9V0g==:Vm7lfkeQgs0p4G//PFjq7C9eePpwq3PU4mnIDLY2yQWmFITN2JeE7UfuQUb2sdqZ";
    public static final String TEST_DECRYPT = "To be or not to be, That is the question";
    public static final String TEST_NATIVE_DECRYPT = "Called AndroidJniApp.onLowMemory";

    public static final String TEST_BASE64_DECRYPT = "tO BE OR NOT TO BE, tHAT IS THE QUESTION";
    public static final String TEST_STRING = "hello, is it me you're looking for?";
    public static final String TEST_NULL_CHAR = "\0";
    public static final String TEST_STRING_WITH_NULL_CHAR = "hello \0 world";
    public static final String TEST_UTF16_STRING = "UTF16 hello: \u2018.";
    public static final String TEST_UTF8_STRING = "a \u0915\u093E\u091A\u0902 \u00F6 1 2 3";
    public static final int TEST_INTEGER = 42;
    public static final short TEST_SHORT = 777;
    public static final boolean TEST_BOOLEAN = true;
    public static final float TEST_FLOAT = 3.14159f;
    public static final double TEST_FLOAT_TOLERANCE = 0.01;
    public static final double TEST_DOUBLE = 2.71828;
    public static final byte TEST_BYTE = 72;
    public static final char TEST_CHAR = 'ö';
}


text:
/**
 * @author Farshad Sheykhi
 */

function SearchResult(id,fId,fTitle,fLogo,fDesc,fMinInvestment,fMaxInvestment,fFee,stablished,requestedInfoDate) {
    this.idSearch = id;
    this.idFranchise = fId;
    this.title = fTitle;
    this.logo = fLogo;
    this.description = fDesc;
    this.minInvestment = fMinInvestment;
    this.maxInvestment = fMaxInvestment;
    this.fee = fFee;
    this.stablished = stablished;
    this.requestedDate = requestedInfoDate;

    // return this;
};

SearchResult.prototype.getId = function () {
    return this.idSearch;
};

SearchResult.prototype.getFranchiseId = function () {
    return this.idFranchise;
};

SearchResult.prototype.getTitle = function () {
    return this.title;
};

SearchResult.prototype.getLogo = function () {
    return this.logo;
};

SearchResult.prototype.getDescription = function () {
    return this.description;
};

SearchResult.prototype.getMinInvestment = function () {
    return this.minInvestment;
};

SearchResult.prototype.getMaxInvestment = function () {
    return this.maxInvestment;
};

SearchResult.prototype.getFee = function () {
    return this.fee;
};

SearchResult.prototype.getStablished = function () {
    return this.stablished;
};

SearchResult.prototype.getRequestedDate = function () {
    return this.requestedDate;
};

module.exports = SearchResult;


text:
/**
 * JavaScript functions enhancing the SVG diagrams.
 *
 * @author Damien Obrist
 */

var diagrams = {};

/**
 * Initializes the diagrams in the main window.
 */
$(document).ready(function()
{
	// hide diagrams in browsers not supporting SVG
	if(Modernizr && !Modernizr.inlinesvg)
		return;

	// only execute this in the main window
	if(diagrams.isPopup)
		return;

	if($("#content-diagram").length)
		$("#inheritance-diagram").css("padding-bottom", "20px");

	$(".diagram-container").css("display", "block");

	$(".diagram").each(function() {
		// store inital dimensions
		$(this).data("width", $("svg", $(this)).width());
		$(this).data("height", $("svg", $(this)).height());
		// store unscaled clone of SVG element
		$(this).data("svg", $(this).get(0).childNodes[0].cloneNode(true));
	});

	// make diagram visible, hide container
	$(".diagram").css("display", "none");
	$(".diagram svg").css({
		"position": "static",
		"visibility": "visible",
		"z-index": "auto"
	});

	// enable linking to diagrams
	if($(location).attr("hash") == "#inheritance-diagram") {
		diagrams.toggle($("#inheritance-diagram-container"), true);
	} else if($(location).attr("hash") == "#content-diagram") {
		diagrams.toggle($("#content-diagram-container"), true);
	}

	$(".diagram-link").click(function() {
		diagrams.toggle($(this).parent());
	});

	// register resize function
	$(window).resize(diagrams.resize);

	// don't bubble event to parent div
	// when clicking on a node of a resized
	// diagram
	$("svg a").click(function(e) {
		e.stopPropagation();
	});

	diagrams.initHighlighting();
});

/**
 * Initializes the diagrams in the popup.
 */
diagrams.initPopup = function(id)
{
	// copy diagram from main window
	if(!jQuery.browser.msie)
		$("body").append(opener.$("#" + id).data("svg"));

	// positioning
	$("svg").css("position", "absolute");
	$(window).resize(function()
	{
		var svg_w = $("svg").css("width").replace("px", "");
		var svg_h = $("svg").css("height").replace("px", "");
		var x = $(window).width() / 2 - svg_w / 2;
		if(x < 0) x = 0;
		var y = $(window).height() / 2 - svg_h / 2;
		if(y < 0) y = 0;
		$("svg").css("left", x + "px");
		$("svg").css("top", y + "px");
	});
	$(window).resize();

	diagrams.initHighlighting();
	$("svg a").click(function(e) {
		opener.diagrams.redirectFromPopup(this.href.baseVal);
		window.close();
	});
	$(document).keyup(function(e) {
		if (e.keyCode == 27) window.close();
	});
}

/**
 * Initializes highlighting for nodes and edges.
 */
diagrams.initHighlighting = function()
{
	// helper function since $.hover doesn't work in IE

	function hover(elements, fn)
	{
		elements.mouseover(fn);
		elements.mouseout(fn);
	}

	// inheritance edges

	hover($("svg .edge.inheritance"), function(evt){
		var toggleClass = evt.type == "mouseout" ? diagrams.removeClass : diagrams.addClass;
		var parts = $(this).attr("id").split("_");
		toggleClass($("#" + parts[0] + "_" + parts[1]));
		toggleClass($("#" + parts[0] + "_" + parts[2]));
		toggleClass($(this));
	});

	// nodes

	hover($("svg .node"), function(evt){
		var toggleClass = evt.type == "mouseout" ? diagrams.removeClass : diagrams.addClass;
		toggleClass($(this));
		var parts = $(this).attr("id").split("_");
		var index = parts[1];
		$("svg#" + parts[0] + " .edge.inheritance").each(function(){
			var parts2 = $(this).attr("id").split("_");
			if(parts2[1] == index)
			{
				toggleClass($("#" + parts2[0] + "_" + parts2[2]));
				toggleClass($(this));
			} else if(parts2[2] == index)
			{
				toggleClass($("#" + parts2[0] + "_" + parts2[1]));
				toggleClass($(this));
			}
		});
	});

	// incoming implicits

	hover($("svg .node.implicit-incoming"), function(evt){
		var toggleClass = evt.type == "mouseout" ? diagrams.removeClass : diagrams.addClass;
		toggleClass($(this));
		toggleClass($("svg .edge.implicit-incoming"));
		toggleClass($("svg .node.this"));
	});

	hover($("svg .edge.implicit-incoming"), function(evt){
		var toggleClass = evt.type == "mouseout" ? diagrams.removeClass : diagrams.addClass;
		toggleClass($(this));
		toggleClass($("svg .node.this"));
		$("svg .node.implicit-incoming").each(function(){
			toggleClass($(this));
		});
	});

	// implicit outgoing nodes

	hover($("svg .node.implicit-outgoing"), function(evt){
		var toggleClass = evt.type == "mouseout" ? diagrams.removeClass : diagrams.addClass;
		toggleClass($(this));
		toggleClass($("svg .edge.implicit-outgoing"));
		toggleClass($("svg .node.this"));
	});

	hover($("svg .edge.implicit-outgoing"), function(evt){
		var toggleClass = evt.type == "mouseout" ? diagrams.removeClass : diagrams.addClass;
		toggleClass($(this));
		toggleClass($("svg .node.this"));
		$("svg .node.implicit-outgoing").each(function(){
			toggleClass($(this));
		});
	});
};

/**
 * Resizes the diagrams according to the available width.
 */
diagrams.resize = function()
{
	// available width
	var availableWidth = $("body").width() - 20;

	$(".diagram-container").each(function() {
		// unregister click event on whole div
		$(".diagram", this).unbind("click");
		var diagramWidth = $(".diagram", this).data("width");
		var diagramHeight = $(".diagram", this).data("height");

		if(diagramWidth > availableWidth)
		{
			// resize diagram
			var height = diagramHeight / diagramWidth * availableWidth;
			$(".diagram svg", this).width(availableWidth);
			$(".diagram svg", this).height(height);

			// register click event on whole div
			$(".diagram", this).click(function() {
				diagrams.popup($(this));
			});
			$(".diagram", this).addClass("magnifying");
		}
		else
		{
			// restore full size of diagram
			$(".diagram svg", this).width(diagramWidth);
			$(".diagram svg", this).height(diagramHeight);
			// don't show custom cursor any more
			$(".diagram", this).removeClass("magnifying");
		}
	});
};

/**
 * Shows or hides a diagram depending on its current state.
 */
diagrams.toggle = function(container, dontAnimate)
{
	// change class of link
	$(".diagram-link", container).toggleClass("open");
	// get element to show / hide
	var div = $(".diagram", container);
	if (div.is(':visible'))
	{
		$(".diagram-help", container).hide();
		div.unbind("click");
		div.removeClass("magnifying");
		div.slideUp(100);
	}
	else
	{
		diagrams.resize();
		if(dontAnimate)
			div.show();
		else
			div.slideDown(100);
		$(".diagram-help", container).show();
	}
};

/**
 * Opens a popup containing a copy of a diagram.
 */
diagrams.windows = {};
diagrams.popup = function(diagram)
{
	var id = diagram.attr("id");
	if(!diagrams.windows[id] || diagrams.windows[id].closed) {
		var title = $(".symbol .name", $("#signature")).text();
		// cloning from parent window to popup somehow doesn't work in IE
		// therefore include the SVG as a string into the HTML
		var svgIE = jQuery.browser.msie ? $("
").append(diagram.data("svg")).html() : "";
		var html = '' +
		'<?xml version="1.0" encoding="UTF-8"?>\n' +
		'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n' +
		'\n' +
		'	\n' +
		'		<title>' + title + '</title>\n' +
		'		<link href="' + $("#diagrams-css").attr("href") + '" media="screen" type="text/css" rel="stylesheet" />\n' +
		'		\n' +
		'		\n' +
		'		\n' +
		'	\n' +
		'	\n' +
		'		Close this window\n' +
		'		' + svgIE + '\n' +
		'	\n' +
		'';

		var padding = 30;
		var screenHeight = screen.availHeight;
		var screenWidth = screen.availWidth;
		var w = Math.min(screenWidth, diagram.data("width") + 2 * padding);
		var h = Math.min(screenHeight, diagram.data("height") + 2 * padding);
		var left = (screenWidth - w) / 2;
		var top = (screenHeight - h) / 2;
		var parameters = "height=" + h + ", width=" + w + ", left=" + left + ", top=" + top + ", scrollbars=yes, location=no, resizable=yes";
		var win = window.open("about:blank", "_blank", parameters);
		win.document.open();
		win.document.write(html);
		win.document.close();
		diagrams.windows[id] = win;
	}
	win.focus();
};

/**
 * This method is called from within the popup when a node is clicked.
 */
diagrams.redirectFromPopup = function(url)
{
	window.location = url;
};

/**
 * Helper method that adds a class to a SVG element.
 */
diagrams.addClass = function(svgElem, newClass) {
	newClass = newClass || "over";
	var classes = svgElem.attr("class");
	if ($.inArray(newClass, classes.split(/\s+/)) == -1) {
		classes += (classes ? ' ' : '') + newClass;
		svgElem.attr("class", classes);
	}
};

/**
 * Helper method that removes a class from a SVG element.
 */
diagrams.removeClass = function(svgElem, oldClass) {
	oldClass = oldClass || "over";
	var classes = svgElem.attr("class");
	classes = $.grep(classes.split(/\s+/), function(n, i) { return n != oldClass; }).join(' ');
	svgElem.attr("class", classes);
};


text:
A react application for watch drama

## quick start
* git clone https://github.com/wilsonwen/kanmeiju
* cd kanmeiju
* npm install
* npm start

## technology stack
* react
* express
* redis
Separate front end codes from backend codes using RESTFul interface.
Directory 'frontend' is created with 'create-react-app'.
Using heroku deploy hook to help fast deploying.