text:
<?php
/**
 * vpopqmail
 *
 * @license http://opensource.org/licenses/MIT MIT
 */

class MazelabVpopqmail_ForwarderController extends Zend_Controller_Action
{
    /**
     * @var mixed | null
     */
    protected $_identity;

    /**
     * @var string
     */
    protected $_domainId;

    /**
     * message when conflicts were resolved
     */
    CONST MESSAGE_CONFLICTS_RESOLVED = "Differences resolved!";

    /**
     * message when forwarder wasn't found
     */
    CONST MESSAGE_FORWARDER_NOT_FOUND = 'Forwarder %1$s not found';

    /**
     * message when deleting a import account
     */
    CONST MESSAGE_IMPORT_DELETE_FAILED= 'Forwarder %1$s was added but could\'t be automaticaly deleted. Please delete %1$s manually';

    /**
     * message when import forwarder has a invalid context
     */
    CONST MESSAGE_IMPORT_INVALID = 'Invalid context for forwarder import';

    /**
     * checks whether target with current client id matches
     *
     * @param  string $targetId
     * @return boolean
     */
    public function isOwner($targetId)
    {
        return($targetId == $this->_identity["_id"]);
    }

    public function init()
    {
        $this->_identity = Zend_Auth::getInstance()->getIdentity();

        $ajaxContext = $this->_helper->getHelper('AjaxContext');
        $ajaxContext->addActionContext('detail', 'json')
                    ->addActionContext('delete', 'json')
                    ->addActionContext('addtarget', 'json')
                    ->addActionContext('changestate', 'json')
                    ->addActionContext('index', array('html'))
                    ->addActionContext('domain', 'html')
                    ->initContext();

        if ($this->getRequest()->getQuery("domainFilter")) {
            $this->_domainId = $this->getParam("domainFilter");
            setcookie("domainId", $this->getParam("domainFilter"));
        } else {
            $this->_domainId = $this->_request->getCookie("domainId");
        }

        // set view messages from MessageManager
        $this->_helper->getHelper("SetDefaultViewVars");
    }

    public function indexAction()
    {
        if ($this->_domainId){
            $this->_forward("domain");
            return;
        }

        $this->view->conflicts = MazelabVpopqmail_Model_DiFactory::getForwarderManager()
                ->getConflictedForwardersByOwner($this->_identity['_id']);

        $this->view->client = $this->_identity;
        $this->view->pager = $this->getPager($this->_identity['_id'], null, 10);
    }

    public function domainAction()
    {
        $domain = Core_Model_DiFactory::getDomainManager()->getDomainAsArray($this->_domainId);
        if(!$this->getRequest()->isXmlHttpRequest() && $this->isOwner($domain["owner"])) {
            $this->view->domain = $domain;
        }else{
            setcookie("domainId");
            $this->redirect($this->view->url(array(), "mazelab-vpopqmail_forwarder"));
        }

        $this->view->conflicts = MazelabVpopqmail_Model_DiFactory::getForwarderManager()
                ->getConflictedForwardersOfDomain($this->_domainId);

        $this->view->domainId = $this->_domainId;
        $this->view->pager = $this->getPager($this->_identity['_id'], $this->_domainId, 10);
    }

    public function addAction()
    {
        $forwarderManager = MazelabVpopqmail_Model_DiFactory::getForwarderManager();
        $form = new MazelabVpopqmail_Form_AddForwarder();
        $form->setDomainSelectByOwner($this->_identity['_id']);

        if($this->_request->isPost()) {
            if ($form->isValid($this->_request->getPost())) {
                $forwarderId = $forwarderManager->createForwarder($form->getValues());
                if ($forwarderId && ($forwarder = $forwarderManager->getForwarder($forwarderId))) {
                    $this->_redirect($this->view->url(array($forwarder->getEmail()),
                            'mazelab-vpopqmail_forwarderdetail'), array('exit' => false));
                }
            }
        }

        if($this->_domainId) {
            $form->showOnlyDomainAndDisableSelectbox($this->_domainId);
        }

        $this->view->domainId = $this->getParam('domainId', false);
        $this->view->form = $form;
    }

    public function detailAction()
    {
        $forwarderManager = MazelabVpopqmail_Model_DiFactory::getForwarderManager();
        if(!($forwarder = $forwarderManager->getForwarderByEmail($this->getParam('email'))) ||
                !$this->isOwner($forwarder->getData("ownerId"))) {
            Core_Model_DiFactory::getMessageManager()
                    ->addError(self::MESSAGE_FORWARDER_NOT_FOUND, $this->getParam('email'));
            return $this->_forward('index');
        }

        $form = new MazelabVpopqmail_Form_Forwarder();
        $form->setAccountSelect($forwarder)->setForwarderTargets($forwarder);

        if($this->_request->getPost()) {
            $values = $form->getValidValues($this->_request->getPost());

            if (!empty($values) && $forwarderManager->updateForwarder($forwarder->getId(), $values)) {
                $this->view->result = true;
                $this->view->forwardTo = $forwarderManager->getForwarderTargets($forwarder->getId(), true);
            }

            $this->view->formErrors = $form->getMessages();
        }

        $data = $forwarder->getData();

        $this->view->forwarder = $data;
        $this->view->form = $form->disableAccountSelectboxIfEmpty()->setDefaults($data);
    }

    public function addtargetAction()
    {
        $forwarderManager = MazelabVpopqmail_Model_DiFactory::getForwarderManager();
        if(!($forwarder = $forwarderManager->getForwarderByEmail($this->getParam('email'))) ||
                !$this->isOwner($forwarder->getData("ownerId"))) {
            Core_Model_DiFactory::getMessageManager()
                    ->addError(self::MESSAGE_FORWARDER_NOT_FOUND, $this->getParam('email'));
            return null;
        }

        if($this->_request->getPost()) {
            $form = new MazelabVpopqmail_Form_Forwarder();
            $form->setValidatorForwarderTarget($forwarder->getId());

            if ($form->isValidPartial($this->getRequest()->getPost())) {
                if ($forwarderManager->addForwarderTarget($forwarder->getId(), $form->getValue('addForward'))) {
                    $this->view->result = true;
                    $this->view->forwardTo = $forwarder->getForwarderTargets(true);
                }
            }

            $this->view->formErrors = $form->getMessages();
        }
    }

    public function deleteAction()
    {
        $forwarderManager = MazelabVpopqmail_Model_DiFactory::getForwarderManager();
        if(!($forwarder = $forwarderManager->getForwarderByEmail($this->getParam('email'))) ||
                !$this->isOwner($forwarder->getData("ownerId"))) {
            Core_Model_DiFactory::getMessageManager()
                    ->addError(self::MESSAGE_FORWARDER_NOT_FOUND, $this->getParam('email'));
            return null;
        }

        $this->view->status = $forwarderManager->flagDelete($forwarder->getId());
    }

    public function changestateAction()
    {
        $forwarderManager = MazelabVpopqmail_Model_DiFactory::getForwarderManager();
        if(!($forwarder = $forwarderManager->getForwarderByEmail($this->getParam('email'))) ||
                !$this->isOwner($forwarder->getData("ownerId"))) {
            Core_Model_DiFactory::getMessageManager()
                    ->addError(self::MESSAGE_FORWARDER_NOT_FOUND, $this->getParam('email'));
            return null;
        }

        if($forwarderManager->changeForwarderState($forwarder->getId())) {
            if($forwarder->getConflicts(MazeLib_Bean::STATUS_MANUALLY)) {
                $this->view->conflictedUrl = $this->view->url(array($forwarder->getEmail())
                        , 'mazelab-vpopqmail_diffForwarderDetail');
            }

            $this->view->forwarder = $forwarder->getData();
        }
    }

    public function diffAction()
    {
        $this->view->conflictsInDomains = MazelabVpopqmail_Model_DiFactory::getForwarderManager()
                ->getConflictedForwardersPerDomainByOwner($this->_identity['_id']);
    }

    public function diffdomainAction()
    {
        $this->view->conflicts = MazelabVpopqmail_Model_DiFactory::getForwarderManager()
                ->getConflictedForwardersOfDomain($this->_domainId);

        $this->view->domain = Core_Model_DiFactory::getDomainManager()
                ->getDomainAsArray($this->_domainId);
    }

    public function diffdetailAction()
    {
        $forwarderManager  = MazelabVpopqmail_Model_DiFactory::getForwarderManager();
        if(!($forwarder = $forwarderManager->getForwarderByEmail($this->getParam('email'))) ||
                !$this->isOwner($forwarder->getData("ownerId"))) {
            Core_Model_DiFactory::getMessageManager()
                    ->addError(self::MESSAGE_FORWARDER_NOT_FOUND, $this->getParam('email'));
            return null;
        }

        $form = new MazelabVpopqmail_Form_DiffForwarder();
        $form->initDiff($forwarder->getId());

        if($this->getRequest()->isPost()) {
            if($form->isValid($this->getRequest()->getPost())) {
                $selectedForwarder = $this->_request->getPost();

                if ($forwarderManager->resolveForwarderConflicts($forwarder->getId(), $selectedForwarder)){
                    Core_Model_DiFactory::getMessageManager()
                            ->addSuccess(self::MESSAGE_CONFLICTS_RESOLVED);
                    $form->reset()->initDiff($forwarder->getId());
                }
            }
        }

        $this->view->form = $form;
        $this->view->forwarder = $forwarder->getData();
        $this->view->domain = Core_Model_DiFactory::getDomainManager()
                ->getDomainAsArray($forwarder->getData('domainId'));
    }

    /**
     * get account pager data
     *
     * @param array|string $domainId
     * @param int $limit
     * @return array
     */
    public function getPager($ownerId, $domainId = null, $limit = null)
    {
        if(!$ownerId) {
            return array();
        }

        $pager = MazelabVpopqmail_Model_DiFactory::newForwarderPager($ownerId, $domainId);
        $pager->setLimit($limit);

        if($this->getParam('term')) {
            $pager->setSearchTerm($this->getParam('term'));
        }

        $action = $this->getParam('pagerAction');
        if($action == 'last') {
            $pager->last();
        } else {
            $pager->setPage($this->getParam('page', 1))->page();
        }

        return $pager->asArray();
    }

}

redpajama_set_name: RedPajamaGithub


text:
describe('My Hooks Test Suite', () => {

    // Runs once before all tests in the block
    before( () => {
        cy.log("*** This is a TEST SETUP block ***");
    })

    // Runs once after all tests in the block
    after( () => {
        cy.log("*** This is a TEST TEARDOWN block ***");
    })

    // Runs before each test in the block
    beforeEach( () => {
        cy.log("*** This a LOGIN block ***");
    })

    // Runs after each test in the block
    afterEach( () => {
        cy.log("*** This a LOGOUT block ***");
    })

    it('Searching Test', function() {
        cy.log("*** This is a searching test ***");
    })

    it('Advanced Searching Test', function() {
        cy.log("*** This is an advanced searching test ***");
    })

    it('Listing Products Test', function() {
        cy.log("*** This is a listing products test ***");
    })

})


text:
(function() {
"use strict";

angular.module("Week1App", [])
    .controller("Week1Controller", Week1Controller);

Week1Controller.$inject = ["$scope"];
function Week1Controller($scope) {
    $scope.itemsList = "";

    $scope.checkResult = "";
    $scope.checkIfTooMuch = function() {
        var items;

        if ($scope.itemsList === "") {
            $scope.checkResult = "Please enter data first";
        } else {
            items = $scope.itemsList.split(",");

            if (items.length < 4) {
                $scope.checkResult = "Enjoy!";
            } else {
                $scope.checkResult = "Too much!";
            }
        }
    }
}

})();


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>404 - Page not found</title>
    <meta name="description" content="This is the jekyllTheme example blog. It only exists to demonstrate how the theme looks and feels.">

    <meta name="keywords" content="demo, theme, example, github, jekyll, features" />

    <meta name="HandheldFriendly" content="True">
    <meta name="robots" content="index,follow">
    <meta name="googlebot" content="index,follow">

	<meta property="og:title" content="404 - Page not found" />
	<meta property="og:type" content="article" />

<meta property="og:image" content="/assets/mountain-cover.jpg" />

<meta property="og:site_name" content="Life  is  Short  Do  More" />
<meta property="og:description" content="This is the jekyllTheme example blog. It only exists to demonstrate how the theme looks and feels." />

<meta property="og:url" content="/404" />

	<meta property="article:author" content="https://poonamagarwal.in/about" />
	<link rel="author" href="https://poonamagarwal.in/about" />

<meta name="twitter:card" content="summary">

<meta name="twitter:site" content="@jenswillmer">

<meta name="twitter:title" content="404 - Page not found">

<meta name="twitter:url" content="/404">

<meta name="twitter:description" content="This is the jekyllTheme example blog. It only exists to demonstrate how the theme looks and feels.">

<meta name="twitter:image:src" content="/assets/mountain-cover.jpg">

    <link href='https://fonts.googleapis.com/css?family=Mrs+Saint+Delafield|Merriweather:300italic,700,300,700italic|Open+Sans:400,700' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="/css/screen.css">
    <link rel="stylesheet" href="/css/prism.css">
    <link rel="alternate" type="application/rss+xml" title="Life  is  Short  Do  More" href="/feed.xml">

    <link rel="icon" href="/assets/favicon-16.png" sizes="16x16" type="image/png">
    <link rel="icon" href="/assets/favicon-32.png" sizes="32x32" type="image/png">
    <link rel="icon" href="/assets/favicon-48.png" sizes="48x48" type="image/png">
    <link rel="icon" href="/assets/favicon-62.png" sizes="62x62" type="image/png">

Life  is  Short  Do  More

Home

Offline

About

Page not found

The page you requested could not be found.

Similar URLs

    <button class="go-to-top"></button>

Life  is  Short  Do  More © 2021 | RSS Feed

</script>


text:
using ArkeCLR.Utilities;

namespace ArkeCLR.Runtime.Streams {
    public class BlobHeap : Heap<byte[]> {
        public BlobHeap() : base("#Blob", HeapType.Blob) { }

        protected override byte[] Get(ByteReader reader) => reader.ReadArray<byte>(reader.ReadCompressedU4());

        public void GetAt<T>(HeapToken token, out T value) where T : ICustomByteReader, new() => value = this.GetAt<T>(token);

        public T GetAt<T>(HeapToken token) where T : ICustomByteReader, new() {
            var obj = new T();

            obj.Read(new ByteReader(this.GetAt(token)));

            return obj;
        }
    }
}


text:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.connectedvmware.generated;

import com.azure.core.util.Context;
import com.azure.resourcemanager.connectedvmware.models.StopVirtualMachineOptions;

/** Samples for VirtualMachines Stop. */
public final class VirtualMachinesStopSamples {
    /*
     * x-ms-original-file: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/preview/2022-01-10-preview/examples/StopVirtualMachine.json
     */
    /**
     * Sample code: StopVirtualMachine.
     *
     * @param manager Entry point to ConnectedVMwareManager.
     */
    public static void stopVirtualMachine(com.azure.resourcemanager.connectedvmware.ConnectedVMwareManager manager) {
        manager
            .virtualMachines()
            .stop("testrg", "DemoVM", new StopVirtualMachineOptions().withSkipShutdown(true), Context.NONE);
    }
}


text:
#include <android/system/window.h>
#include <android/hardware/gralloc.h>
#include "support.h"
#include <stdarg.h>

#include "nativewindowbase.h"

BaseNativeWindowBuffer::BaseNativeWindowBuffer()
{
	// done in ANativeWindowBuffer::ANativeWindowBuffer
	// common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
	// common.version = sizeof(ANativeWindow);
	// memset(common.reserved, 0, sizeof(window->native.common.reserved));

	ANativeWindowBuffer::common.decRef = &_decRef;
	ANativeWindowBuffer::common.incRef = &_incRef;
	ANativeWindowBuffer::width = 0;
	ANativeWindowBuffer::height = 0;
	ANativeWindowBuffer::stride = 0;
	ANativeWindowBuffer::format = 0;
	ANativeWindowBuffer::usage = 0;
	ANativeWindowBuffer::handle = 0;
}

void BaseNativeWindowBuffer::_decRef(struct android_native_base_t* base)
{
	ANativeWindowBuffer* self = container_of(base, ANativeWindowBuffer, common);
	static_cast<BaseNativeWindowBuffer*>(self)->refcount--;
};

void BaseNativeWindowBuffer::_incRef(struct android_native_base_t* base)
{
	ANativeWindowBuffer* self = container_of(base, ANativeWindowBuffer, common);
	static_cast<BaseNativeWindowBuffer*>(self)->refcount++;
};

BaseNativeWindow::BaseNativeWindow()
{
	TRACE("%s this=%p or A %p\n",__PRETTY_FUNCTION__, this, (ANativeWindow*)this);
	// done in ANativeWindow
	// common.magic = ANDROID_NATIVE_WINDOW_MAGIC;
	// common.version = sizeof(ANativeWindow);
	// memset(common.reserved, 0, sizeof(window->native.common.reserved));
	common.decRef = &_decRef;
	common.incRef = &_incRef;

	ANativeWindow::flags = 0;
	ANativeWindow::minSwapInterval = 0;
	ANativeWindow::maxSwapInterval = 0;
	ANativeWindow::xdpi = 0;
	ANativeWindow::ydpi = 0;

	ANativeWindow::setSwapInterval = _setSwapInterval;
	ANativeWindow::lockBuffer = &_lockBuffer;
	ANativeWindow::dequeueBuffer = &_dequeueBuffer;
	ANativeWindow::queueBuffer = &_queueBuffer;
	ANativeWindow::query = &_query;
	ANativeWindow::perform = &_perform;
	ANativeWindow::cancelBuffer = &_cancelBuffer;
	refcount = 0;
};

BaseNativeWindow::~BaseNativeWindow()
{
	TRACE("%s\n",__PRETTY_FUNCTION__);
};

void BaseNativeWindow::_decRef(struct android_native_base_t* base)
{
	ANativeWindow* self = container_of(base, ANativeWindow, common);
	static_cast<BaseNativeWindow*>(self)->refcount--;
};

void BaseNativeWindow::_incRef(struct android_native_base_t* base)
{
	ANativeWindow* self = container_of(base, ANativeWindow, common);
	static_cast<BaseNativeWindow*>(self)->refcount++;
};

int BaseNativeWindow::_setSwapInterval(struct ANativeWindow* window, int interval)
{
	TRACE("%s interval=%i\n",__PRETTY_FUNCTION__, interval);
	return static_cast<BaseNativeWindow*>(window)->setSwapInterval(interval);
}

int BaseNativeWindow::_dequeueBuffer(ANativeWindow* window, ANativeWindowBuffer** buffer)
{
	TRACE("%s pointer dest %p, contains %p\n",__PRETTY_FUNCTION__, buffer, *buffer);
	BaseNativeWindowBuffer* temp = static_cast<BaseNativeWindowBuffer*>(*buffer);
	TRACE("temp %p\n", temp);
	int ret = static_cast<BaseNativeWindow*>(window)->dequeueBuffer(&temp);
	TRACE("temp now %p\n", temp);
	*buffer = static_cast<ANativeWindowBuffer*>(temp);
	TRACE("now pointer dest %p, contains %p\n", buffer, *buffer);
	return ret;
}

const char *BaseNativeWindow::_native_window_operation(int what)
{
	switch (what) {
		case NATIVE_WINDOW_SET_USAGE: return "NATIVE_WINDOW_SET_USAGE";
		case NATIVE_WINDOW_CONNECT: return "NATIVE_WINDOW_CONNECT";
		case NATIVE_WINDOW_DISCONNECT: return "NATIVE_WINDOW_DISCONNECT";
		case NATIVE_WINDOW_SET_CROP: return "NATIVE_WINDOW_SET_CROP";
		case NATIVE_WINDOW_SET_BUFFER_COUNT: return "NATIVE_WINDOW_SET_BUFFER_COUNT";
		case NATIVE_WINDOW_SET_BUFFERS_GEOMETRY: return "NATIVE_WINDOW_SET_BUFFERS_GEOMETRY";
		case NATIVE_WINDOW_SET_BUFFERS_TRANSFORM: return "NATIVE_WINDOW_SET_BUFFERS_TRANSFORM";
		case NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP: return "NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP";
		case NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS: return "NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS";
		case NATIVE_WINDOW_SET_BUFFERS_FORMAT: return "NATIVE_WINDOW_SET_BUFFERS_FORMAT";
		case NATIVE_WINDOW_SET_SCALING_MODE: return "NATIVE_WINDOW_SET_SCALING_MODE";
		case NATIVE_WINDOW_LOCK: return "NATIVE_WINDOW_LOCK";
		case NATIVE_WINDOW_UNLOCK_AND_POST: return "NATIVE_WINDOW_UNLOCK_AND_POST";
		case NATIVE_WINDOW_API_CONNECT: return "NATIVE_WINDOW_API_CONNECT";
		case NATIVE_WINDOW_API_DISCONNECT: return "NATIVE_WINDOW_API_DISCONNECT";
		case NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS: return "NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS";
		case NATIVE_WINDOW_SET_POST_TRANSFORM_CROP: return "NATIVE_WINDOW_SET_POST_TRANSFORM_CROP";
		default: return "NATIVE_UNKNOWN_OPERATION";
	}
}
const char *BaseNativeWindow::_native_query_operation(int what)
{
	switch (what) {
		case NATIVE_WINDOW_WIDTH: return "NATIVE_WINDOW_WIDTH";
		case NATIVE_WINDOW_HEIGHT: return "NATIVE_WINDOW_HEIGHT";
		case NATIVE_WINDOW_FORMAT: return "NATIVE_WINDOW_FORMAT";
		case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS: return "NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS";
		case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER: return "NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER";
		case NATIVE_WINDOW_CONCRETE_TYPE: return "NATIVE_WINDOW_CONCRETE_TYPE";
		case NATIVE_WINDOW_DEFAULT_WIDTH: return "NATIVE_WINDOW_DEFAULT_WIDTH";
		case NATIVE_WINDOW_DEFAULT_HEIGHT: return "NATIVE_WINDOW_DEFAULT_HEIGHT";
		case NATIVE_WINDOW_TRANSFORM_HINT: return "NATIVE_WINDOW_TRANSFORM_HINT";
		case NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND: return "NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND";
		default: return "NATIVE_UNKNOWN_QUERY";
	}
}

int BaseNativeWindow::_lockBuffer(struct ANativeWindow* window, ANativeWindowBuffer* buffer)
{
	TRACE("%s buffer=%p\n",__PRETTY_FUNCTION__, buffer);
	return static_cast<BaseNativeWindow*>(window)->lockBuffer(static_cast<BaseNativeWindowBuffer*>(buffer));
}

int BaseNativeWindow::_queueBuffer(struct ANativeWindow* window, ANativeWindowBuffer* buffer)
{
	TRACE("%s buffer=%p\n",__PRETTY_FUNCTION__, buffer);
	return static_cast<BaseNativeWindow*>(window)->queueBuffer(static_cast<BaseNativeWindowBuffer*>(buffer));
	return 0;
}

int BaseNativeWindow::_query(const struct ANativeWindow* window, int what, int* value)
{
	TRACE("_query window %p %i %s %p\n", window, what, _native_query_operation(what), value);
	const BaseNativeWindow* self=static_cast<const BaseNativeWindow*>(window);
	switch (what) {
		case NATIVE_WINDOW_WIDTH:
			*value = self->width();
			return NO_ERROR;
		case NATIVE_WINDOW_HEIGHT:
			*value = self->height();
			return NO_ERROR;
		case NATIVE_WINDOW_FORMAT:
			*value = self->format();
			return NO_ERROR;
		case NATIVE_WINDOW_CONCRETE_TYPE:
			*value = self->type();
			return NO_ERROR;
		case NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER:
			*value = self->queueLength();
			return NO_ERROR;
		case NATIVE_WINDOW_DEFAULT_WIDTH:
			*value = self->defaultWidth();
			return NO_ERROR;
		case NATIVE_WINDOW_DEFAULT_HEIGHT:
			*value = self->defaultHeight();
			return NO_ERROR;
		case NATIVE_WINDOW_TRANSFORM_HINT:
			*value = self->transformHint();
			return NO_ERROR;
		case NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS:
			*value = 1;
			return NO_ERROR;
	}
	TRACE("EGL error: unkown window attribute! %i\n", what);
	*value = 0;
	return BAD_VALUE;
}

int BaseNativeWindow::_perform(struct ANativeWindow* window, int operation, ... )
{
	BaseNativeWindow* self = static_cast<BaseNativeWindow*>(window);
	va_list args;
	va_start(args, operation);

	// FIXME
	TRACE("%s operation = %s\n", __PRETTY_FUNCTION__, _native_window_operation(operation));
	switch(operation) {
	case NATIVE_WINDOW_SET_USAGE                 : //  0,
	{
		int usage = va_arg(args, int);
		return self->setUsage(usage);
	}
	case NATIVE_WINDOW_CONNECT                   : //  1,   /* deprecated */
		TRACE("connect\n");
		break;
	case NATIVE_WINDOW_DISCONNECT                : //  2,   /* deprecated */
		TRACE("disconnect\n");
		break;
	case NATIVE_WINDOW_SET_CROP                  : //  3,   /* private */
		TRACE("set crop\n");
		break;
	case NATIVE_WINDOW_SET_BUFFER_COUNT          : //  4,
		TRACE("set buffer count\n");
		break;
	case NATIVE_WINDOW_SET_BUFFERS_GEOMETRY      : //  5,   /* deprecated */
		TRACE("set buffers geometry\n");
		break;
	case NATIVE_WINDOW_SET_BUFFERS_TRANSFORM     : //  6,
		TRACE("set buffers transform\n");
		break;
	case NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP     : //  7,
		TRACE("set buffers timestamp\n");
		break;
	case NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS    : //  8,
	{
		int width  = va_arg(args, int);
		int height = va_arg(args, int);
		return self->setBuffersDimensions(width, height);
	}
	case NATIVE_WINDOW_SET_BUFFERS_FORMAT        : //  9,
	{
		int format = va_arg(args, int);
		return self->setBuffersFormat(format);
	}
	case NATIVE_WINDOW_SET_SCALING_MODE          : // 10,   /* private */
		TRACE("set scaling mode\n");
		break;
	case NATIVE_WINDOW_LOCK                      : // 11,   /* private */
		TRACE("window lock\n");
		break;
	case NATIVE_WINDOW_UNLOCK_AND_POST           : // 12,   /* private */
		TRACE("unlock and post\n");
		break;
	case NATIVE_WINDOW_API_CONNECT               : // 13,   /* private */
		TRACE("api connect\n");
		break;
	case NATIVE_WINDOW_API_DISCONNECT            : // 14,   /* private */
		TRACE("api disconnect\n");
		break;
	case NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS : // 15, /* private */
		TRACE("set buffers user dimensions\n");
		break;
	case NATIVE_WINDOW_SET_POST_TRANSFORM_CROP   : // 16,
		TRACE("set post transform crop\n");
		break;
	}
	return NO_ERROR;
}

int BaseNativeWindow::_cancelBuffer(struct ANativeWindow* window, ANativeWindowBuffer* buffer)
{
	TRACE("%s buffer = %p\n",__PRETTY_FUNCTION__, buffer);
	return static_cast<BaseNativeWindow*>(window)->cancelBuffer(static_cast<BaseNativeWindowBuffer*>(buffer));
}


text:
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com

/* AsnException.cs --
 * Ars Magna project, http://arsmagna.ru
 * -------------------------------------------------------
 * Status: poor
 */

#region Using directives

using System;

using JetBrains.Annotations;

#endregion

namespace AM.Asn1
{
    /// <summary>
    ///
    /// </summary>
    [PublicAPI]
    public class AsnException
        : Exception
    {
        #region Construciton

        /// <summary>
        /// Constructor.
        /// </summary>
        public AsnException()
        {
        }

        /// <summary>
        /// Constructor.
        /// </summary>
        public AsnException
            (
                string message
            )
            : base(message)
        {
        }

        /// <summary>
        /// Constructor.
        /// </summary>
        public AsnException
            (
                string message,
                Exception innerException
            )
            : base
            (
                message,
                innerException
            )
        {
        }

        #endregion
    }
}


text:
<?php defined('G_IN_ADMIN')or exit('No permission resources.'); ?>
<!DOCTYPE html>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" href="<?php echo G_GLOBAL_STYLE; ?>/global/css/global.css" type="text/css">
<link rel="stylesheet" href="<?php echo G_GLOBAL_STYLE; ?>/global/css/style.css" type="text/css">

	<?php echo $this->headerment();?>

<form name="myform" action="" method="post" enctype="multipart/form-data">

			链接名称:
			<input type="text" name="name" value="<?php echo $linkinfo['name'];?>" class="input-text">

			链接地址:
			<input type="text" name="url" value="<?php echo $linkinfo['url'];?>" class="input-text">

	<?php if($linkinfo['type']==2){ ?>

        	链接图片:

           	<input type="text" id="imagetext" value="<?php echo $linkinfo['logo'];?>"  class="input-text wid300">
            <input type="button" class="button" onClick="upImage()" value="选择图片"/>
			<input type="file" id="imgfield" name="image" class="button"
            onchange="document.getElementById('imagetext').value=this.value"
            style=" display:none;" />

	<?php }?>

            <input type="submit" class="button" name="submit" value="提交" >

</form>


text:
<?php

namespace ByTIC\Payments\Tests\Gateways\Providers\AbstractGateway\Message;

/**
 * Trait ServerCompletePurchaseResponseTrait
 * @package ByTIC\Payments\Tests\Gateways\Providers\AbstractGateway\Message
 * @deprecated use \Paytic\Payments\Tests\Gateways\Message\ServerCompletePurchaseResponseTrait;
 */
trait ServerCompletePurchaseResponseTrait
{
    use \Paytic\Payments\Tests\Gateways\Message\ServerCompletePurchaseResponseTrait;
}


text:
import {
  lotamePanoramaIdSubmodule,
  storage,
} from 'modules/lotamePanoramaIdSystem.js';
import { uspDataHandler } from 'src/adapterManager.js';
import * as utils from 'src/utils.js';
import { server } from 'test/mocks/xhr.js';
import sinon from 'sinon';

const responseHeader = { 'Content-Type': 'application/json' };

describe('LotameId', function() {
  let logErrorStub;
  let getCookieStub;
  let setCookieStub;
  let getLocalStorageStub;
  let setLocalStorageStub;
  let removeFromLocalStorageStub;
  let timeStampStub;
  let uspConsentDataStub;

  const nowTimestamp = new Date().getTime();

  beforeEach(function () {
    logErrorStub = sinon.stub(utils, 'logError');
    getCookieStub = sinon.stub(storage, 'getCookie');
    setCookieStub = sinon.stub(storage, 'setCookie');
    getLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage');
    setLocalStorageStub = sinon.stub(storage, 'setDataInLocalStorage');
    removeFromLocalStorageStub = sinon.stub(
      storage,
      'removeDataFromLocalStorage'
    );
    timeStampStub = sinon.stub(utils, 'timestamp').returns(nowTimestamp);
    uspConsentDataStub = sinon.stub(uspDataHandler, 'getConsentData');
  });

  afterEach(function () {
    logErrorStub.restore();
    getCookieStub.restore();
    setCookieStub.restore();
    getLocalStorageStub.restore();
    setLocalStorageStub.restore();
    removeFromLocalStorageStub.restore();
    timeStampStub.restore();
    uspConsentDataStub.restore();
  });

  describe('caching initial data received from the remote server', function () {
    let request;
    let callBackSpy = sinon.spy();

    beforeEach(function() {
      let submoduleCallback = lotamePanoramaIdSubmodule.getId({}).callback;
      submoduleCallback(callBackSpy);

      request = server.requests[0];

      request.respond(
        200,
        responseHeader,
        JSON.stringify({
          profile_id: '4ec137245858469eb94a4e248f238694',
          expiry_ts: 10,
          core_id:
            'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87a',
        })
      );
    });

    it('should call the remote server when getId is called', function () {
      expect(request.url).to.be.eq('https://id.crwdcntrl.net/id');
      expect(callBackSpy.calledOnce).to.be.true;
    });

    it('should save the first party id', function () {
      sinon.assert.calledWith(
        setLocalStorageStub,
        '_cc_id',
        '4ec137245858469eb94a4e248f238694'
      );
      sinon.assert.calledWith(
        setCookieStub,
        '_cc_id',
        '4ec137245858469eb94a4e248f238694'
      );
    });

    it('should save the expiry', function () {
      sinon.assert.calledWith(
        setLocalStorageStub,
        'panoramaId_expiry', 10);

      sinon.assert.calledWith(
        setCookieStub,
        'panoramaId_expiry', 10
      );
    });

    it('should save the id', function () {
      sinon.assert.calledWith(
        setLocalStorageStub,
        'panoramaId',
        'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87a'
      );

      sinon.assert.calledWith(
        setCookieStub,
        'panoramaId',
        'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87a'
      );
    });
  });

  describe('No stored values', function() {
    describe('and receives the profile id but no panorama id', function() {
      let request;
      let callBackSpy = sinon.spy();

      beforeEach(function() {
        let submoduleCallback = lotamePanoramaIdSubmodule.getId({}).callback;
        submoduleCallback(callBackSpy);
        request = server.requests[0];

        request.respond(
          200,
          responseHeader,
          JSON.stringify({
            profile_id: '4ec137245858469eb94a4e248f238694',
            expiry_ts: 3800000,
          })
        );
      });

      it('should save the profile id', function() {
        sinon.assert.calledWith(
          setLocalStorageStub,
          '_cc_id',
          '4ec137245858469eb94a4e248f238694'
        );
        sinon.assert.calledWith(
          setCookieStub,
          '_cc_id',
          '4ec137245858469eb94a4e248f238694'
        );
      });

      it('should save the panorama id expiry', function () {
        sinon.assert.calledWith(
          setLocalStorageStub,
          'panoramaId_expiry',
          3800000
        );

        sinon.assert.calledWith(setCookieStub, 'panoramaId_expiry', 3800000);
      });

      it('should NOT save the panorama id', function () {
        sinon.assert.neverCalledWith(
          setLocalStorageStub,
          'panoramaId',
          sinon.match.any
        );

        sinon.assert.calledWith(
          removeFromLocalStorageStub,
          'panoramaId'
        );

        sinon.assert.calledWith(
          setCookieStub,
          'panoramaId',
          '',
          'Thu, 01 Jan 1970 00:00:00 GMT',
          'Lax'
        );
      });
    });

    describe('and receives both the profile id and the panorama id', function () {
      let request;
      let callBackSpy = sinon.spy();

      beforeEach(function () {
        let submoduleCallback = lotamePanoramaIdSubmodule.getId({}).callback;
        submoduleCallback(callBackSpy);
        request = server.requests[0];

        request.respond(
          200,
          responseHeader,
          JSON.stringify({
            profile_id: '4ec137245858469eb94a4e248f238694',
            core_id:
              'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87b',
            expiry_ts: 3600000,
          })
        );
      });
      it('should save the profile id', function () {
        sinon.assert.calledWith(
          setLocalStorageStub,
          '_cc_id',
          '4ec137245858469eb94a4e248f238694'
        );
        sinon.assert.calledWith(
          setCookieStub,
          '_cc_id',
          '4ec137245858469eb94a4e248f238694'
        );
      });

      it('should save the panorama id expiry', function () {
        sinon.assert.calledWith(
          setLocalStorageStub,
          'panoramaId_expiry',
          3600000
        );

        sinon.assert.calledWith(setCookieStub, 'panoramaId_expiry', 3600000);
      });

      it('should save the panorama id', function () {
        sinon.assert.calledWith(
          setLocalStorageStub,
          'panoramaId',
          'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87b'
        );

        sinon.assert.calledWith(
          setCookieStub,
          'panoramaId',
          'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87b'
        );
      });
    });
  });

  describe('With a panorama id found', function() {
    describe('and it is too early to try again', function () {
      let submoduleCallback;

      beforeEach(function () {
        getCookieStub
          .withArgs('panoramaId_expiry')
          .returns(String(Date.now() + 100000));
        getCookieStub
          .withArgs('panoramaId')
          .returns(
            'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87c'
          );

        submoduleCallback = lotamePanoramaIdSubmodule.getId({});
      });

      it('should not call the remote server when getId is called', function () {
        expect(submoduleCallback).to.be.eql({
          id: 'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87c',
        });
      });
    });

    describe('and can try again', function () {
      let request;
      let callBackSpy = sinon.spy();

      beforeEach(function () {
        getCookieStub.withArgs('panoramaId_expiry').returns('1000');
        getCookieStub
          .withArgs('panoramaId')
          .returns(
            'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87d'
          );

        let submoduleCallback = lotamePanoramaIdSubmodule.getId({}).callback;
        submoduleCallback(callBackSpy);

        request = server.requests[0];

        request.respond(
          200,
          responseHeader,
          JSON.stringify({
            profile_id: '4ec137245858469eb94a4e248f238694',
            core_id:
              'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87d',
            expiry_ts: 3600000
          })
        );
      });

      it('should call the remote server when getId is called', function () {
        expect(callBackSpy.calledOnce).to.be.true;
      });
    });

    describe('receives an optout request', function () {
      let request;
      let callBackSpy = sinon.spy();

      beforeEach(function () {
        getCookieStub.withArgs('panoramaId_expiry').returns('1000');
        getCookieStub
          .withArgs('panoramaId')
          .returns(
            'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87d'
          );

        let submoduleCallback = lotamePanoramaIdSubmodule.getId({}).callback;
        submoduleCallback(callBackSpy);

        request = server.requests[0];

        request.respond(
          200,
          responseHeader,
          JSON.stringify({
            expiry_ts: Date.now() + (30 * 24 * 60 * 60 * 1000),
          })
        );
      });

      it('should call the remote server when getId is called', function () {
        expect(callBackSpy.calledOnce).to.be.true;
      });

      it('should clear the panorama id', function () {
        sinon.assert.calledWith(
          removeFromLocalStorageStub,
          'panoramaId'
        );

        sinon.assert.calledWith(
          setCookieStub,
          'panoramaId',
          '',
          'Thu, 01 Jan 1970 00:00:00 GMT',
          'Lax'
        );
      });

      it('should clear the profile id', function () {
        sinon.assert.calledWith(removeFromLocalStorageStub, '_cc_id');

        sinon.assert.calledWith(
          setCookieStub,
          '_cc_id',
          '',
          'Thu, 01 Jan 1970 00:00:00 GMT',
          'Lax'
        );
      });
    });
  });

  describe('With no panorama id found', function() {
    beforeEach(function() {
      getCookieStub.withArgs('panoramaId').returns(null);
      getLocalStorageStub.withArgs('panoramaId').returns(null);
    })
    describe('and it is too early to try again', function () {
      let submoduleCallback;

      beforeEach(function () {
        getCookieStub
          .withArgs('panoramaId_expiry')
          .returns(String(Date.now() + 100000));

        submoduleCallback = lotamePanoramaIdSubmodule.getId({});
      });

      it('should not call the remote server when getId is called', function () {
        expect(submoduleCallback).to.be.eql({
          id: null
        });
      });
    });

    describe('and can try again', function () {
      let request;
      let callBackSpy = sinon.spy();

      beforeEach(function () {
        getLocalStorageStub
          .withArgs('panoramaId_expiry')
          .returns('1000');

        let submoduleCallback = lotamePanoramaIdSubmodule.getId({}).callback;
        submoduleCallback(callBackSpy);

        request = server.requests[0];

        request.respond(
          200,
          responseHeader,
          JSON.stringify({
            profile_id: '4ec137245858469eb94a4e248f238694',
            core_id:
              'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87e',
            expiry_ts: 3600000
          })
        );
      });

      it('should call the remote server when getId is called', function () {
        expect(callBackSpy.calledOnce).to.be.true;
      });
    });
  });

  describe('when gdpr applies', function () {
    let request;
    let callBackSpy = sinon.spy();

    beforeEach(function () {
      let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, {
        gdprApplies: true,
        consentString: 'consentGiven'
      }).callback;
      submoduleCallback(callBackSpy);

      request = server.requests[0];

      request.respond(
        200,
        responseHeader,
        JSON.stringify({
          profile_id: '4ec137245858469eb94a4e248f238694',
          core_id:
            'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87f',
          expiry_ts: 3600000,
        })
      );
    });

    it('should call the remote server when getId is called', function () {
      expect(callBackSpy.calledOnce).to.be.true;
    });

    it('should pass the gdpr consent string back', function() {
      expect(request.url).to.be.eq(
        'https://id.crwdcntrl.net/id?gdpr_applies=true&gdpr_consent=consentGiven'
      );
    });
  });

  describe('when gdpr applies and falls back to eupubconsent cookie', function () {
    let request;
    let callBackSpy = sinon.spy();
    let consentData = {
      gdprApplies: true,
      consentString: undefined
    };

    beforeEach(function () {
      getCookieStub
        .withArgs('eupubconsent-v2')
        .returns('consentGiven');

      let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, consentData).callback;
      submoduleCallback(callBackSpy);

      // the contents of the response don't matter for this
      request = server.requests[0];
      request.respond(200, responseHeader, '');
    });

    it('should call the remote server when getId is called', function () {
      expect(callBackSpy.calledOnce).to.be.true;
    });

    it('should pass the gdpr consent string back', function() {
      expect(request.url).to.be.eq(
        'https://id.crwdcntrl.net/id?gdpr_applies=true&gdpr_consent=consentGiven'
      );
    });
  });

  describe('when gdpr applies and falls back to euconsent cookie', function () {
    let request;
    let callBackSpy = sinon.spy();
    let consentData = {
      gdprApplies: true,
      consentString: undefined
    };

    beforeEach(function () {
      getCookieStub
        .withArgs('euconsent-v2')
        .returns('consentGiven');

      let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, consentData).callback;
      submoduleCallback(callBackSpy);

      // the contents of the response don't matter for this
      request = server.requests[0];
      request.respond(200, responseHeader, '');
    });

    it('should call the remote server when getId is called', function () {
      expect(callBackSpy.calledOnce).to.be.true;
    });

    it('should pass the gdpr consent string back', function() {
      expect(request.url).to.be.eq(
        'https://id.crwdcntrl.net/id?gdpr_applies=true&gdpr_consent=consentGiven'
      );
    });
  });

  describe('when gdpr applies but no consent string is available', function () {
    let request;
    let callBackSpy = sinon.spy();
    let consentData = {
      gdprApplies: true,
      consentString: undefined
    };

    beforeEach(function () {
      let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, consentData).callback;
      submoduleCallback(callBackSpy);

      // the contents of the response don't matter for this
      request = server.requests[0];
      request.respond(200, responseHeader, '');
    });

    it('should call the remote server when getId is called', function () {
      expect(callBackSpy.calledOnce).to.be.true;
    });

    it('should not include the gdpr consent string on the url', function() {
      expect(request.url).to.be.eq(
        'https://id.crwdcntrl.net/id?gdpr_applies=true'
      );
    });
  });

  describe('when no consentData and falls back to eupubconsent cookie', function () {
    let request;
    let callBackSpy = sinon.spy();
    let consentData;

    beforeEach(function () {
      getCookieStub
        .withArgs('eupubconsent-v2')
        .returns('consentGiven');

      let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, consentData).callback;
      submoduleCallback(callBackSpy);

      // the contents of the response don't matter for this
      request = server.requests[0];
      request.respond(200, responseHeader, '');
    });

    it('should call the remote server when getId is called', function () {
      expect(callBackSpy.calledOnce).to.be.true;
    });

    it('should pass the gdpr consent string back', function() {
      expect(request.url).to.be.eq(
        'https://id.crwdcntrl.net/id?gdpr_consent=consentGiven'
      );
    });
  });

  describe('when no consentData and falls back to euconsent cookie', function () {
    let request;
    let callBackSpy = sinon.spy();
    let consentData;

    beforeEach(function () {
      getCookieStub
        .withArgs('euconsent-v2')
        .returns('consentGiven');

      let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, consentData).callback;
      submoduleCallback(callBackSpy);

      // the contents of the response don't matter for this
      request = server.requests[0];
      request.respond(200, responseHeader, '');
    });

    it('should call the remote server when getId is called', function () {
      expect(callBackSpy.calledOnce).to.be.true;
    });

    it('should pass the gdpr consent string back', function() {
      expect(request.url).to.be.eq(
        'https://id.crwdcntrl.net/id?gdpr_consent=consentGiven'
      );
    });
  });

  describe('when no consentData and no cookies', function () {
    let request;
    let callBackSpy = sinon.spy();
    let consentData;

    beforeEach(function () {
      let submoduleCallback = lotamePanoramaIdSubmodule.getId({}, consentData).callback;
      submoduleCallback(callBackSpy);

      // the contents of the response don't matter for this
      request = server.requests[0];
      request.respond(200, responseHeader, '');
    });

    it('should call the remote server when getId is called', function () {
      expect(callBackSpy.calledOnce).to.be.true;
    });

    it('should pass the gdpr consent string back', function() {
      expect(request.url).to.be.eq('https://id.crwdcntrl.net/id');
    });
  });

  describe('with an empty cache, ignore profile id for error 111', function () {
    let request;
    let callBackSpy = sinon.spy();

    beforeEach(function () {
      let submoduleCallback = lotamePanoramaIdSubmodule.getId({}).callback;
      submoduleCallback(callBackSpy);

      request = server.requests[0];

      request.respond(
        200,
        responseHeader,
        JSON.stringify({
          profile_id: '4ec137245858469eb94a4e248f238694',
          expiry_ts: 10,
          errors: [111],
          core_id:
            'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87a',
        })
      );
    });

    it('should not save the first party id', function () {
      sinon.assert.neverCalledWith(
        setLocalStorageStub,
        '_cc_id',
        '4ec137245858469eb94a4e248f238694'
      );
      sinon.assert.neverCalledWith(
        setCookieStub,
        '_cc_id',
        '4ec137245858469eb94a4e248f238694'
      );
    });

    it('should save the expiry', function () {
      sinon.assert.calledWith(setLocalStorageStub, 'panoramaId_expiry', 10);

      sinon.assert.calledWith(setCookieStub, 'panoramaId_expiry', 10);
    });

    it('should save the id', function () {
      sinon.assert.calledWith(
        setLocalStorageStub,
        'panoramaId',
        'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87a'
      );

      sinon.assert.calledWith(
        setCookieStub,
        'panoramaId',
        'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87a'
      );
    });
  });

  describe('receives an optout request with an error 111', function () {
    let request;
    let callBackSpy = sinon.spy();

    beforeEach(function () {
      getCookieStub.withArgs('panoramaId_expiry').returns('1000');
      getCookieStub
        .withArgs('panoramaId')
        .returns(
          'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87d'
        );

      let submoduleCallback = lotamePanoramaIdSubmodule.getId({}).callback;
      submoduleCallback(callBackSpy);

      request = server.requests[0];

      request.respond(
        200,
        responseHeader,
        JSON.stringify({
          errors: [111],
          expiry_ts: Date.now() + 30 * 24 * 60 * 60 * 1000,
        })
      );
    });

    it('should call the remote server when getId is called', function () {
      expect(callBackSpy.calledOnce).to.be.true;
    });

    it('should clear the panorama id', function () {
      sinon.assert.calledWith(removeFromLocalStorageStub, 'panoramaId');

      sinon.assert.calledWith(
        setCookieStub,
        'panoramaId',
        '',
        'Thu, 01 Jan 1970 00:00:00 GMT',
        'Lax'
      );
    });

    it('should not clear the profile id', function () {
      sinon.assert.neverCalledWith(removeFromLocalStorageStub, '_cc_id');

      sinon.assert.neverCalledWith(
        setCookieStub,
        '_cc_id',
        '',
        'Thu, 01 Jan 1970 00:00:00 GMT',
        'Lax'
      );
    });
  });

  describe('with a custom client id', function () {
    describe('with a client expiry set', function () {
      beforeEach(function () {
        getCookieStub
          .withArgs('panoramaId_expiry_1234')
          .returns(String(Date.now() + 500 * 1000));
      });

      describe('and an existing pano id', function() {
        let submoduleCallback;
        beforeEach(function () {
          getCookieStub
            .withArgs('panoramaId_expiry')
            .returns(String(Date.now() + 100000));
          getCookieStub
            .withArgs('panoramaId')
            .returns(
              'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87c'
            );
          submoduleCallback = lotamePanoramaIdSubmodule.getId(
            {
              params: {
                clientId: '1234',
              },
            },
            {
              gdprApplies: false,
            }
          );
        });

        it('should not call the remote server when getId is called nor get an id', function () {
          expect(submoduleCallback).to.be.eql({
            id: undefined,
            reason: 'NO_CLIENT_CONSENT',
          });
        });
      });

      describe('and no existing pano id', function () {
        let submoduleCallback;

        beforeEach(function () {
          // Let the panoramaId_expiry be empty

          submoduleCallback = lotamePanoramaIdSubmodule.getId(
            {
              params: {
                clientId: '1234',
              },
            },
            {
              gdprApplies: false,
            }
          );
        });

        it('should not call the remote server nor return an id', function () {
          expect(submoduleCallback).to.be.eql({
            id: undefined,
            reason: 'NO_CLIENT_CONSENT',
          });
        });
      });
    });

    describe('with no client expiry set', function () {
      describe('and no existing pano id', function () {
        let request;
        let callBackSpy = sinon.spy();

        beforeEach(function () {
          uspConsentDataStub.returns('1NNN');
          let submoduleCallback = lotamePanoramaIdSubmodule.getId(
            {
              params: {
                clientId: '1234',
              },
            },
            {
              gdprApplies: false,
            }
          ).callback;
          submoduleCallback(callBackSpy);

          request = server.requests[0];

          request.respond(
            200,
            responseHeader,
            JSON.stringify({
              profile_id: '4ec137245858469eb94a4e248f238694',
              core_id:
                'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87f',
              expiry_ts: 3600000,
            })
          );
        });

        it('should call the remote server when getId is called', function () {
          expect(callBackSpy.calledOnce).to.be.true;
        });

        it('should pass the usp consent string and client id back', function () {
          expect(request.url).to.be.eq(
            'https://id.crwdcntrl.net/id?gdpr_applies=false&us_privacy=1NNN&c=1234'
          );
        });

        it('should NOT set an expiry for the client', function () {
          sinon.assert.neverCalledWith(
            setCookieStub,
            'panoramaId_expiry_1234',
            sinon.match.number
          );
        });
      });

      describe('and an existing pano id', function () {
        let submoduleCallback;

        beforeEach(function () {
          getCookieStub
            .withArgs('panoramaId_expiry')
            .returns(String(Date.now() + 100000));
          getCookieStub
            .withArgs('panoramaId')
            .returns(
              'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87c'
            );
          submoduleCallback = lotamePanoramaIdSubmodule.getId(
            {
              params: {
                clientId: '1234',
              },
            },
            {
              gdprApplies: false,
            }
          );
        });

        it('should not call the remote server but use the cached value', function () {
          expect(submoduleCallback).to.be.eql({
            id: 'ca22992567e3cd4d116a5899b88a55d0d857a23610db939ae6ac13ba2335d87c',
          });
        });

        it('should NOT set an expiry for the client', function () {
          sinon.assert.neverCalledWith(
            setCookieStub,
            'panoramaId_expiry_1234',
            sinon.match.number
          );
        });
      });
    });
    describe('when client consent has errors', function () {
      let request;
      let callBackSpy = sinon.spy();

      beforeEach(function () {
        let submoduleCallback = lotamePanoramaIdSubmodule.getId(
          {
            params: {
              clientId: '1234',
            },
          },
          {
            gdprApplies: false,
          }
        ).callback;
        submoduleCallback(callBackSpy);

        request = server.requests[0];

        request.respond(
          200,
          responseHeader,
          JSON.stringify({
            expiry_ts: 3600000,
            errors: [111],
            no_consent: 'CLIENT',
          })
        );
      });

      it('should call the remote server when getId is called', function () {
        expect(callBackSpy.calledOnce).to.be.true;
      });

      it('should pass client id back', function () {
        expect(request.url).to.be.eq(
          'https://id.crwdcntrl.net/id?gdpr_applies=false&c=1234'
        );
      });

      it('should set the received expiry for the client', function() {
        sinon.assert.calledWith(
          setCookieStub,
          'panoramaId_expiry_1234',
          3600000
        );
      });

      it('should not clear the cache for the panorama id', function() {
        sinon.assert.neverCalledWith(
          setCookieStub,
          'panoramaId',
          sinon.match.any
        );
      });

      it('should not clear the cache for the panorama id expiry', function () {
        sinon.assert.neverCalledWith(
          setCookieStub,
          'panoramaId_expiry',
          sinon.match.any
        );
      });
    });
  });
});


text:
package com.fasterxml.jackson.databind.ser.std;

import java.lang.reflect.Type;
import java.io.IOException;

import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.JacksonStdImpl;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;

/**
 * This is a simple dummy serializer that will just output literal
 * JSON null value whenever serialization is requested.
 * Used as the default "null serializer" (which is used for serializing
 * null object references unless overridden), as well as for some
 * more exotic types (java.lang.Void).
 */
@JacksonStdImpl
@SuppressWarnings("serial")
public class NullSerializer
    extends StdSerializer<Object>
{
    public final static NullSerializer instance = new NullSerializer();

    private NullSerializer() { super(Object.class); }

    @Override
    public void serialize(Object value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
        jgen.writeNull();
    }

    @Override
    public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException {
        return createSchemaNode("null");
    }

    @Override
    public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException {
        visitor.expectNullFormat(typeHint);
    }
}


text:
            {{ problemIndex+$index+1 }}. ({{ type }})
            {{ problem.title }}

            <input type='text' id='problem{{ problem.id }}'
                   class="font-size-small singlefilling-text-{{ problemResult }}"
                   name='choices_{{problem.id}}'
                   placeholder="填写答案"
                   ng-model='answer[problem.id]'
                   ng-change="writeAnswer(answer[problem.id])"
                   ng-disabled="submitted"/>

                       提示

{{ hint }}

                       正确答案

{{ correct_answers }}

                       题目解析


text:
package org.apache.logging.log4j.core.config;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.async.AsyncLoggerContextSelector;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
import org.apache.logging.log4j.core.config.plugins.PluginElement;
import org.apache.logging.log4j.core.config.plugins.PluginFactory;
import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
import org.apache.logging.log4j.core.filter.AbstractFilterable;
import org.apache.logging.log4j.core.impl.DefaultLogEventFactory;
import org.apache.logging.log4j.core.impl.Log4jLogEvent;
import org.apache.logging.log4j.core.impl.LogEventFactory;
import org.apache.logging.log4j.core.lookup.StrSubstitutor;
import org.apache.logging.log4j.core.util.Booleans;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.core.util.Loader;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.util.PerformanceSensitive;
import org.apache.logging.log4j.util.PropertiesUtil;
import org.apache.logging.log4j.util.Strings;

/**
 * Logger object that is created via configuration.
 */
@Plugin(name = "logger", category = Node.CATEGORY, printObject = true)
public class LoggerConfig extends AbstractFilterable {

    public static final String ROOT = "root";
    private static LogEventFactory LOG_EVENT_FACTORY = null;

    private List<AppenderRef> appenderRefs = new ArrayList<>();
    private final AppenderControlArraySet appenders = new AppenderControlArraySet();
    private final String name;
    private LogEventFactory logEventFactory;
    private Level level;
    private boolean additive = true;
    private boolean includeLocation = true;
    private LoggerConfig parent;
    private final Map<Property, Boolean> properties;
    private final Configuration config;
    private final ReliabilityStrategy reliabilityStrategy;

    static {
        final String factory = PropertiesUtil.getProperties().getStringProperty(Constants.LOG4J_LOG_EVENT_FACTORY);
        if (factory != null) {
            try {
                final Class<?> clazz = Loader.loadClass(factory);
                if (clazz != null && LogEventFactory.class.isAssignableFrom(clazz)) {
                    LOG_EVENT_FACTORY = (LogEventFactory) clazz.newInstance();
                }
            } catch (final Exception ex) {
                LOGGER.error("Unable to create LogEventFactory {}", factory, ex);
            }
        }
        if (LOG_EVENT_FACTORY == null) {
            LOG_EVENT_FACTORY = new DefaultLogEventFactory();
        }
    }

    /**
     * Default constructor.
     */
    public LoggerConfig() {
        this.logEventFactory = LOG_EVENT_FACTORY;
        this.level = Level.ERROR;
        this.name = Strings.EMPTY;
        this.properties = null;
        this.config = null;
        this.reliabilityStrategy = new DefaultReliabilityStrategy(this);
    }

    /**
     * Constructor that sets the name, level and additive values.
     *
     * @param name The Logger name.
     * @param level The Level.
     * @param additive true if the Logger is additive, false otherwise.
     */
    public LoggerConfig(final String name, final Level level, final boolean additive) {
        this.logEventFactory = LOG_EVENT_FACTORY;
        this.name = name;
        this.level = level;
        this.additive = additive;
        this.properties = null;
        this.config = null;
        this.reliabilityStrategy = new DefaultReliabilityStrategy(this);
    }

    protected LoggerConfig(final String name, final List<AppenderRef> appenders, final Filter filter,
            final Level level, final boolean additive, final Property[] properties, final Configuration config,
            final boolean includeLocation) {
        super(filter);
        this.logEventFactory = LOG_EVENT_FACTORY;
        this.name = name;
        this.appenderRefs = appenders;
        this.level = level;
        this.additive = additive;
        this.includeLocation = includeLocation;
        this.config = config;
        if (properties != null && properties.length > 0) {
            final Map<Property, Boolean> map = new HashMap<>(properties.length);
            for (final Property prop : properties) {
                final boolean interpolate = prop.getValue().contains("${");
                map.put(prop, interpolate);
            }
            this.properties = Collections.unmodifiableMap(map);
        } else {
            this.properties = null;
        }
        this.reliabilityStrategy = config.getReliabilityStrategy(this);
    }

    @Override
    public Filter getFilter() {
        return super.getFilter();
    }

    /**
     * Returns the name of the LoggerConfig.
     *
     * @return the name of the LoggerConfig.
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the parent of this LoggerConfig.
     *
     * @param parent the parent LoggerConfig.
     */
    public void setParent(final LoggerConfig parent) {
        this.parent = parent;
    }

    /**
     * Returns the parent of this LoggerConfig.
     *
     * @return the LoggerConfig that is the parent of this one.
     */
    public LoggerConfig getParent() {
        return this.parent;
    }

    /**
     * Adds an Appender to the LoggerConfig.
     *
     * @param appender The Appender to add.
     * @param level The Level to use.
     * @param filter A Filter for the Appender reference.
     */
    public void addAppender(final Appender appender, final Level level, final Filter filter) {
        appenders.add(new AppenderControl(appender, level, filter));
    }

    /**
     * Removes the Appender with the specific name.
     *
     * @param name The name of the Appender.
     */
    public void removeAppender(final String name) {
        AppenderControl removed = null;
        while ((removed = appenders.remove(name)) != null) {
            cleanupFilter(removed);
        }
    }

    /**
     * Returns all Appenders as a Map.
     *
     * @return a Map with the Appender name as the key and the Appender as the value.
     */
    public Map<String, Appender> getAppenders() {
        return appenders.asMap();
    }

    /**
     * Removes all Appenders.
     */
    protected void clearAppenders() {
        do {
            final AppenderControl[] original = appenders.clear();
            for (final AppenderControl ctl : original) {
                cleanupFilter(ctl);
            }
        } while (!appenders.isEmpty());
    }

    private void cleanupFilter(final AppenderControl ctl) {
        final Filter filter = ctl.getFilter();
        if (filter != null) {
            ctl.removeFilter(filter);
            filter.stop();
        }
    }

    /**
     * Returns the Appender references.
     *
     * @return a List of all the Appender names attached to this LoggerConfig.
     */
    public List<AppenderRef> getAppenderRefs() {
        return appenderRefs;
    }

    /**
     * Sets the logging Level.
     *
     * @param level The logging Level.
     */
    public void setLevel(final Level level) {
        this.level = level;
    }

    /**
     * Returns the logging Level.
     *
     * @return the logging Level.
     */
    public Level getLevel() {
        return level == null ? parent.getLevel() : level;
    }

    /**
     * Returns the LogEventFactory.
     *
     * @return the LogEventFactory.
     */
    public LogEventFactory getLogEventFactory() {
        return logEventFactory;
    }

    /**
     * Sets the LogEventFactory. Usually the LogEventFactory will be this LoggerConfig.
     *
     * @param logEventFactory the LogEventFactory.
     */
    public void setLogEventFactory(final LogEventFactory logEventFactory) {
        this.logEventFactory = logEventFactory;
    }

    /**
     * Returns the valid of the additive flag.
     *
     * @return true if the LoggerConfig is additive, false otherwise.
     */
    public boolean isAdditive() {
        return additive;
    }

    /**
     * Sets the additive setting.
     *
     * @param additive true if the LoggerConfig should be additive, false otherwise.
     */
    public void setAdditive(final boolean additive) {
        this.additive = additive;
    }

    /**
     * Returns the value of logger configuration attribute {@code includeLocation}, or, if no such attribute was
     * configured, {@code true} if logging is synchronous or {@code false} if logging is asynchronous.
     *
     * @return whether location should be passed downstream
     */
    public boolean isIncludeLocation() {
        return includeLocation;
    }

    /**
     * Returns an unmodifiable map with the configuration properties, or {@code null} if this {@code LoggerConfig} does
     * not have any configuration properties.
     * <p>
     * For each {@code Property} key in the map, the value is {@code true} if the property value has a variable that
     * needs to be substituted.
     *
     * @return an unmodifiable map with the configuration properties, or {@code null}
     * @see Configuration#getStrSubstitutor()
     * @see StrSubstitutor
     */
    // LOG4J2-157
    public Map<Property, Boolean> getProperties() {
        return properties;
    }

    /**
     * Logs an event.
     *
     * @param loggerName The name of the Logger.
     * @param fqcn The fully qualified class name of the caller.
     * @param marker A Marker or null if none is present.
     * @param level The event Level.
     * @param data The Message.
     * @param t A Throwable or null.
     */
    public void log(final String loggerName, final String fqcn, final Marker marker, final Level level,
            final Message data, final Throwable t) {
        List<Property> props = null;
        if (properties != null) {
            props = new ArrayList<>(properties.size());
            final LogEvent event = Log4jLogEvent.newBuilder()
                .setMessage(data)
                .setMarker(marker)
                .setLevel(level)
                .setLoggerName(loggerName)
                .setLoggerFqcn(fqcn)
                .setThrown(t)
                .build();
            for (final Map.Entry<Property, Boolean> entry : properties.entrySet()) {
                final Property prop = entry.getKey();
                final String value = entry.getValue() ? config.getStrSubstitutor().replace(event, prop.getValue())
                        : prop.getValue();
                props.add(Property.createProperty(prop.getName(), value));
            }
        }
        log(logEventFactory.createEvent(loggerName, marker, fqcn, level, data, props, t));
    }

    /**
     * Logs an event.
     *
     * @param event The log event.
     */
    public void log(final LogEvent event) {
        if (!isFiltered(event)) {
            processLogEvent(event);
        }
    }

    /**
     * Returns the object responsible for ensuring log events are delivered to a working appender, even during or after
     * a reconfiguration.
     *
     * @return the object responsible for delivery of log events to the appender
     */
    public ReliabilityStrategy getReliabilityStrategy() {
        return reliabilityStrategy;
    }

    private void processLogEvent(final LogEvent event) {
        event.setIncludeLocation(isIncludeLocation());
        callAppenders(event);
        logParent(event);
    }

    private void logParent(final LogEvent event) {
        if (additive && parent != null) {
            parent.log(event);
        }
    }

    @PerformanceSensitive("allocation")
    protected void callAppenders(final LogEvent event) {
        final AppenderControl[] controls = appenders.get();
        //noinspection ForLoopReplaceableByForEach
        for (int i = 0; i < controls.length; i++) {
            controls[i].callAppender(event);
        }
    }

    @Override
    public String toString() {
        return Strings.isEmpty(name) ? ROOT : name;
    }

    /**
     * Factory method to create a LoggerConfig.
     *
     * @param additivity True if additive, false otherwise.
     * @param level The Level to be associated with the Logger.
     * @param loggerName The name of the Logger.
     * @param includeLocation whether location should be passed downstream
     * @param refs An array of Appender names.
     * @param properties Properties to pass to the Logger.
     * @param config The Configuration.
     * @param filter A Filter.
     * @return A new LoggerConfig.
     * @deprecated Use {@link #createLogger(boolean, Level, String, String, AppenderRef[], Property[], Configuration, Filter)}
     */
    @Deprecated
    public static LoggerConfig createLogger(@PluginAttribute("additivity") final String additivity,
            @PluginAttribute("level") final Level level, @PluginAttribute("name") final String loggerName,
            @PluginAttribute("includeLocation") final String includeLocation,
            @PluginElement("AppenderRef") final AppenderRef[] refs,
            @PluginElement("Properties") final Property[] properties, @PluginConfiguration final Configuration config,
            @PluginElement("Filter") final Filter filter) {
        if (loggerName == null) {
            LOGGER.error("Loggers cannot be configured without a name");
            return null;
        }

        final List<AppenderRef> appenderRefs = Arrays.asList(refs);
        final String name = loggerName.equals(ROOT) ? Strings.EMPTY : loggerName;
        final boolean additive = Booleans.parseBoolean(additivity, true);

        return new LoggerConfig(name, appenderRefs, filter, level, additive, properties, config,
                includeLocation(includeLocation));
    }

    /**
     * Factory method to create a LoggerConfig.
     *
     * @param additivity True if additive, false otherwise.
     * @param level The Level to be associated with the Logger.
     * @param loggerName The name of the Logger.
     * @param includeLocation whether location should be passed downstream
     * @param refs An array of Appender names.
     * @param properties Properties to pass to the Logger.
     * @param config The Configuration.
     * @param filter A Filter.
     * @return A new LoggerConfig.
     * @since 2.6
     */
    @PluginFactory
    public static LoggerConfig createLogger(
        @PluginAttribute(value = "additivity", defaultBoolean = true) final boolean additivity,
        @PluginAttribute("level") final Level level,
        @Required(message = "Loggers cannot be configured without a name") @PluginAttribute("name") final String loggerName,
        @PluginAttribute("includeLocation") final String includeLocation,
        @PluginElement("AppenderRef") final AppenderRef[] refs,
        @PluginElement("Properties") final Property[] properties,
        @PluginConfiguration final Configuration config,
        @PluginElement("Filter") final Filter filter
    ) {
        final String name = loggerName.equals(ROOT) ? Strings.EMPTY : loggerName;
        return new LoggerConfig(name, Arrays.asList(refs), filter, level, additivity, properties, config,
            includeLocation(includeLocation));
    }

    // Note: for asynchronous loggers, includeLocation default is FALSE,
    // for synchronous loggers, includeLocation default is TRUE.
    protected static boolean includeLocation(final String includeLocationConfigValue) {
        if (includeLocationConfigValue == null) {
            final boolean sync = !AsyncLoggerContextSelector.isSelected();
            return sync;
        }
        return Boolean.parseBoolean(includeLocationConfigValue);
    }

    /**
     * The root Logger.
     */
    @Plugin(name = ROOT, category = "Core", printObject = true)
    public static class RootLogger extends LoggerConfig {

        @PluginFactory
        public static LoggerConfig createLogger(
                // @formatter:off
                @PluginAttribute("additivity") final String additivity,
                @PluginAttribute("level") final Level level,
                @PluginAttribute("includeLocation") final String includeLocation,
                @PluginElement("AppenderRef") final AppenderRef[] refs,
                @PluginElement("Properties") final Property[] properties,
                @PluginConfiguration final Configuration config,
                @PluginElement("Filter") final Filter filter) {
                // @formatter:on
            final List<AppenderRef> appenderRefs = Arrays.asList(refs);
            final Level actualLevel = level == null ? Level.ERROR : level;
            final boolean additive = Booleans.parseBoolean(additivity, true);

            return new LoggerConfig(LogManager.ROOT_LOGGER_NAME, appenderRefs, filter, actualLevel, additive,
                    properties, config, includeLocation(includeLocation));
        }
    }

}


text:
require "spec_helper"
require "helpful_configuration"

describe HelpfulConfiguration do
  let(:config) { HelpfulConfiguration.new({"spam" => "foo"}, "some_file") }

  describe "when a configuration key is explained but missing" do
    before do
      config.explain("eggs", "This is eggs")
    end

    it "should raise an error" do
      expect { config["eggs"] }.to raise_error(HelpfulConfiguration::ConfigurationMissingError)
    end

    it "should mention the explanation" do
      expect { config["eggs"] }.to raise_error(/key.*missing.*This is eggs/)
    end

    it "should mention the file name" do
      expect { config["eggs"] }.to raise_error(/key.*missing.*some_file/)
    end
  end

  it "should complain when a configuration key has not been explained" do
    expect { config["spam"] }.to raise_error(/explanation/)
    expect { config["eggs"] }.to raise_error(/explanation/)
    expect { config.with_default("foo", "spam") }.to raise_error(/explanation/)
    expect { config.with_default("foo", "eggs") }.to raise_error(/explanation/)
    expect { config.configured?("spam") }.to raise_error(/explanation/)
    expect { config.configured?("eggs") }.to raise_error(/explanation/)
  end

  it "should return a configuration key's value" do
    config.explain("spam", "This is spam")
    config["spam"].should == "foo"
  end

  it "should check if a configuration key has been configured" do
    config.explain("spam", "This is spam")
    config.explain("eggs", "This is eggs")
    config.should be_configured("spam")
    config.should_not be_configured("eggs")
  end

  it "should allow defaults for missing configuration keys" do
    config.explain("eggs", "This is eggs")
    config.with_default("bar", "eggs").should == "bar"
  end

  it "should allow setting keys manually" do
    config = HelpfulConfiguration.new
    config.explain("spam", "This is spam")
    config["spam"] = "bar"
    config["spam"].should == "bar"
  end
end


text:
<?xml version="1.0" encoding="UTF-8"?>
<article id="1189">
	<title>Organizing Nonprint Material	</title>
	<author>Daily, T.E.	</author>
	<text>
		  The object of this book is to establish a means for organizing
		collections of nonprint material so that greatest efficiency can match
		most effective service.  No lesser goal is worthy of consideration.
		In discussing the problems of organization, the examples of material
		have been used to explain differences in treatment that can be made
		responsive to the needs of the community that the library serves.
		Nonprint material is a vital part of a modern library of whatever
		type.  School libraries have made the greatest use of the material so
		far, to the point of becoming media-centers, but the avalanche of
		information is not only in print form and the need for information
		may often be satisfied only by nonprint material.
	</text>
</article>


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Collections;
using System.Globalization;

namespace FsprgEmbeddedStore.Model
{
    public class Plist : PlistDict
    {
        private const string PLIST = "plist";
        private const string DICT = "dict";
        private const string KEY = "key";
        private const string ARRAY = "array";
        private const string REAL = "real";
        private const string INTEGER = "integer";
        private const string TRUE = "true";
        private const string FALSE = "false";
        private const string DATE = "date";
        private const string STRING = "string";
        private const string DATA = "data";

        public XmlDocument OriginalDoc { internal set; get; }

        private Plist(XmlDocument originalDoc, Dictionary<string, object> dict) : base(dict) {
            OriginalDoc = originalDoc;
        }

        public static Plist Parse(string plistXml) {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(plistXml);

            return Parse(doc);
        }

        public static Plist Parse(XmlDocument plistDoc)
        {
            XmlElement plistE = plistDoc.DocumentElement;

            if (!plistE.LocalName.Equals(PLIST))
            {
                throw new Exception("Expected plist top element, was: " + plistE.LocalName);
            }

            // Assure that the top element is a dict and the single child element.
            if (plistE.ChildNodes.Count != 1 || !plistE.FirstChild.Name.Equals(DICT))
            {
                throw new Exception("Expected single 'dict' child element.");
            }
            XmlElement dictE = (XmlElement)plistE.FirstChild;

            return new Plist(plistDoc, ParseDict(dictE));
        }

        private static Dictionary<string, object> ParseDict(XmlElement dictE) {
            Dictionary<string, object> dict = new Dictionary<string, object>(dictE.ChildNodes.Count);

            IEnumerator childNodes = dictE.ChildNodes.GetEnumerator();
            while(childNodes.MoveNext()) {
                XmlElement keyE = (XmlElement)childNodes.Current;
                if (!keyE.Name.Equals(KEY)) {
                    throw new Exception("Expected key element but was " + keyE.Name);
                }
                if(childNodes.MoveNext()) {
                    XmlElement valueE = (XmlElement)childNodes.Current;
                    dict.Add(keyE.InnerText, ParseElement(valueE));
                }
            }

            return dict;
        }

        private static object[] ParseArray(XmlElement listE) {
            object[] list = new object[listE.ChildNodes.Count];

            int i = 0;
            foreach (XmlNode childNode in listE.ChildNodes)
            {
                list[i] = ParseElement((XmlElement)childNode);
                i++;
            }

            return list;
        }

        private static object ParseElement(XmlElement element)
        {
            string type = element.Name;
            switch (type)
            {
                case INTEGER:
                    return long.Parse(element.InnerText);
                case REAL:
                    return decimal.Parse(element.InnerText);
                case STRING:
                    return element.InnerText;
                case DATE:
                    return DateTime.ParseExact(element.InnerText, "yyyy-MM-dd'T'HH:mm:ss'Z'", new CultureInfo("en-US"));
                case DATA:
                    return Convert.FromBase64String(element.InnerText);
                case ARRAY:
                    return ParseArray(element);
                case TRUE:
                    return true;
                case FALSE:
                    return false;
                case DICT:
                    return new PlistDict(ParseDict(element));
                default:
                    throw new Exception("Unexpected type: " + type);
            }
        }
    }

}


text:
using System;
using System.Runtime.InteropServices;

namespace Noesis
{

public class ResourceKeyType : BaseComponent {
  internal new static ResourceKeyType CreateProxy(IntPtr cPtr, bool cMemoryOwn) {
    return new ResourceKeyType(cPtr, cMemoryOwn);
  }

  internal ResourceKeyType(IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) {
  }

  internal static HandleRef getCPtr(ResourceKeyType obj) {
    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  }

  public Type Type {
    get {
      Noesis.Extend.NativeTypeInfo info = Noesis.Extend.GetNativeTypeInfo(GetTypeHelper());
      return info.Type;
    }
  }

  public ResourceKeyType() {
  }

  protected override IntPtr CreateCPtr(Type type, out bool registerExtend) {
    registerExtend = false;
    return NoesisGUI_PINVOKE.new_ResourceKeyType();
  }

  public IntPtr GetTypeHelper() {
    IntPtr ret = NoesisGUI_PINVOKE.ResourceKeyType_GetTypeHelper(swigCPtr);
    if (NoesisGUI_PINVOKE.SWIGPendingException.Pending) throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

  new internal static IntPtr GetStaticType() {
    IntPtr ret = NoesisGUI_PINVOKE.ResourceKeyType_GetStaticType();
    if (NoesisGUI_PINVOKE.SWIGPendingException.Pending) throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }

}

}


text:
require "singleton"

module Hipbot
  module Plugin
    extend ActiveSupport::Concern

    included do
      extend Reactable
      extend ClassMethods

      include Singleton
      include Helpers

      attr_accessor :response

      delegate :sender, :recipients, :body, :room, :reply, to: :response
      delegate :bot, to: Hipbot

      Hipbot.plugins.unshift(self.instance)
    end

    module ClassMethods
      def configure
        yield instance
      end

      def with_response response
        instance.tap{ |i| i.response = response }
      end
    end
  end
end


text:
package eu.monnetproject.coal;

import java.util.List;

import eu.monnetproject.align.Aligner;
import eu.monnetproject.align.Alignment;
import eu.monnetproject.align.AlignmentSerializer;
import eu.monnetproject.align.Matcher;
import eu.monnetproject.align.Match;
import eu.monnetproject.coal.svmrank.SVMRankMatcher;
import eu.monnetproject.framework.services.Services;
import eu.monnetproject.label.LabelExtractorFactory;
import eu.monnetproject.ontology.Entity;
import eu.monnetproject.ontology.Ontology;
import eu.monnetproject.ontology.OntologySerializer;
import eu.monnetproject.sim.EntitySimilarityMeasure;
import java.io.File;
import java.io.FileReader;
import java.util.Collections;
import java.util.logging.Logger;

/**
 * Coal implementation of an Aligner.
 *
 * @author Dennis Spohr
 *
 */
public class CoalAligner implements Aligner {

    private Logger log = Logger.getLogger(CoalAligner.class.getName());
    private final Matcher coalMatcher;
    public volatile int progress = 0;

    public CoalAligner(Matcher coalMatcher) {
        this.coalMatcher = coalMatcher;
    }

    public void reconfigure(File matcherCfg, File svmRankClassify, File svmRankLearn, File modelFile) {
        if (coalMatcher instanceof SVMRankMatcher) {
            ((SVMRankMatcher) coalMatcher).reconfigure(matcherCfg, svmRankClassify, svmRankLearn, modelFile);
        }
    }

    public Alignment align(Ontology ontlg, Ontology ontlg1) {
        Alignment alignment = new CoalAlignment(ontlg,ontlg1);
        align(alignment);
        return alignment;
    }

    public Alignment align(Ontology ontlg, Ontology ontlg1, int k) {
        Alignment alignment = new CoalAlignment(k,ontlg,ontlg1);
        align(alignment);
        return alignment;
    }

    public void align(Alignment alignment, boolean ignoreInstances) {

        this.progress = 0;

        final Ontology srcOntology = alignment.getSourceOntology();
        final Ontology tgtOntology = alignment.getTargetOntology();

        if (srcOntology == null) {
            log.severe("Source ontology is null!");
        }
        if (tgtOntology == null) {
            log.severe("Target ontology is null!");
        }
        if (srcOntology == null || tgtOntology == null) {
            System.exit(-1);
        }

        log.info("Aligning " + srcOntology + " and " + tgtOntology);

        for (Entity ent1 : srcOntology.getEntities()) {

            if (ignoreInstances) {
                if (ent1 instanceof eu.monnetproject.ontology.LiteralOrIndividual) {
                    log.info("Skipping individual " + ent1.getURI().toString());
                    this.progress++;
                    continue;
                }
            }

            log.info("Processing " + ent1);

            List<Match> matches = this.coalMatcher.getMatches(ent1, tgtOntology, alignment.getMaximumNumberOfMatches());

            try {
                alignment.addAllMatches(matches);
            } catch (IllegalArgumentException e) {
                log.warning("No matches for " + ent1.getURI());
            }

            this.progress++;

        }

    }

    /**
     * Align two ontologies and store the result in
     * alignment.
     *
     * @param srcOntology source ontology
     * @param tgtOntology target ontology
     * @param alignment alignment
     */
    @Override
    public void align(Alignment alignment) {

        align(alignment, true);

    }

    public int getProgress() {
        return this.progress;
    }

    public static void main(String[] args) throws Exception {
        //args = "load/SourceOntology.owl load/TargetOntology.owl out 5".split(" ");
        if (args.length != 3 && args.length != 4) {
            System.err.println("Usage:\tmvn exec:java -Dexec.mainClass=\"" + CoalAligner.class.getCanonicalName() + "\" -Dexec.args=\"ontology1 ontology2 output [noOfMatches]\"");
            System.exit(-1);
        }
        final OntologySerializer serializer = Services.get(OntologySerializer.class);
        final AlignmentSerializer alignSerializer = Services.get(AlignmentSerializer.class);
        final Aligner aligner = new CoalAligner(new SVMRankMatcher(Services.getAll(EntitySimilarityMeasure.class)));
        final Ontology ontology1 = serializer.read(new FileReader(args[0]));
        final Ontology ontology2 = serializer.read(new FileReader(args[1]));
        final int noOfMatches;
        if(args.length == 4) {
            noOfMatches = Integer.parseInt(args[3]);
        } else {
            noOfMatches = 1;
        }
        final Alignment alignment = aligner.align(ontology1, ontology2, noOfMatches);
        alignSerializer.writeAlignment(alignment, new File(args[2]));

        // Print scores (for Xichuan)
        for(Entity entity : alignment.getSourceEntities()) {
            for(Match match : alignment.getMatches(entity)) {
                System.out.println(match.getSourceEntity() + " -> " + match.getTargetEntity() + " (" + match.getScore() + ")");
            }
        }
    }
}


text:
#include "Kahan.hpp"
#include <iostream>
#include <math.h>
#include "util_real.hpp"
#include "util_mat.hpp"
#include "boost/multi_array.hpp"

namespace deformable_depth
{
  using namespace std;

  /// SECTION: Implements the Kahan Summation algorithm

  KahanSummation::KahanSummation() :
    summation(0),
    correction(0)
  {
  }

  KahanSummation& KahanSummation::operator=(double reset_to)
  {
    summation = reset_to;
    correction = 0;
    return *this;
  }

  KahanSummation& KahanSummation::operator=(const KahanSummation& reset_to)
  {
    summation = reset_to.summation;
    correction = reset_to.correction;
    return *this;
  }

  double KahanSummation::current_total() const
  {
    return summation;
  }

  KahanSummation& KahanSummation::operator+=(double amount)
  {
    double y = amount - correction;
    double t = summation + y;
    correction = (t - summation) - y;
    summation = t;
    return *this;
  }

  void kahan_test()
  {
    float f_sum = 0;
    KahanSummation k_sum;
    float inc = 1e-6;
    for(long iter = 0; iter < 1000000; iter++)
    {
      f_sum += inc;
      k_sum += inc;
      if(iter % 10000)
      {
	cout << "===============================" << endl;
	cout << "k_sum: " << k_sum.current_total() << endl;
	cout << "f_sum: " << f_sum << endl;
	cout << "times: " << inc*iter << endl;
      }
    }
  }

  /// SECTION: Implements the KahanVector of Summations
  KahanVector::KahanVector(size_t length) :
    values(length), dot_self_cache(qnan)
  {
  }

  KahanVector& KahanVector::operator=(const KahanVector& other)
  {
    values = other.values;
    dot_self_cache = other.dot_self_cache;
    return *this;
  }

  KahanVector::KahanVector() : dot_self_cache(qnan)
  {}

  KahanVector::KahanVector(const std::vector< double >& prime) :
    values(prime.size()), dot_self_cache(qnan)
  {
    for(int pos = 0; pos < prime.size(); pos++)
      values[pos] = prime[pos];
  }

  void KahanVector::onModified()
  {
    dot_self_cache = qnan;
  }

  KahanVector& KahanVector::operator+=(const vector<double>& other)
  {
    onModified();

    assert(values.size() == other.size());
    for(int pos = 0; pos < values.size(); pos++)
      values[pos] += other[pos];
    return *this;
  }

  KahanVector KahanVector::operator-(const KahanVector& other) const
  {
    KahanVector result(values.size());

    for(int pos = 0; pos < values.size(); pos++)
    {
      result.values[pos] = values[pos];
      result.values[pos] += -other.values[pos].current_total();
    }

    return result;
  }

  KahanVector::operator vector<double>() const
  {
    vector<double> result(values.size());

    for(int pos = 0; pos < values.size(); pos++)
      result[pos] = values[pos].current_total();

    return result;
  }

  double KahanVector::operator*(const std::vector< float > other) const
  {
    double ddot = 0;

    assert(other.size() == values.size());
    for(int pos = 0; pos < values.size(); pos++)
      ddot += values[pos].current_total()*other[pos];

    return ddot;
  }

  double KahanVector::dot_self() const
  {
    if(goodNumber(dot_self_cache))
      return dot_self_cache;

    KahanSummation d;

    for(const KahanSummation&value : values)
    {
      double current = value.current_total();
      assert(goodNumber(current));
      d += current*current;
    }

    dot_self_cache = d.current_total();
    return d.current_total();
  }

  size_t KahanVector::size() const
  {
    return values.size();
  }

  const KahanSummation&KahanVector::operator[](size_t idx) const
  {
    return values[idx];
  }
}