text:
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { PageConfig, URLExt } from '@jupyterlab/coreutils';

/**
 * Handle the default `fetch` and `WebSocket` providers.
 */
declare let global: any;

let FETCH: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
let HEADERS: typeof Headers;
let REQUEST: typeof Request;
let WEBSOCKET: typeof WebSocket;

if (typeof window === 'undefined') {
  // Mangle the require statements so it does not get picked up in the
  // browser assets.
  /* tslint:disable */
  const fetchMod = require('node-fetch');
  FETCH = global.fetch ?? fetchMod;
  REQUEST = global.Request ?? fetchMod.Request;
  HEADERS = global.Headers ?? fetchMod.Headers;
  WEBSOCKET = require('ws');
  /* tslint:enable */
} else {
  FETCH = fetch;
  REQUEST = Request;
  HEADERS = Headers;
  WEBSOCKET = WebSocket;
}

/**
 * The namespace for ServerConnection functions.
 *
 * #### Notes
 * This is only intended to manage communication with the Jupyter server.
 *
 * The default values can be used in a JupyterLab or Jupyter Notebook context.
 *
 * We use `token` authentication if available, falling back on an XSRF
 * cookie if one has been provided on the `document`.
 *
 * A content type of `'application/json'` is added when using authentication
 * and there is no body data to allow the server to prevent malicious forms.
 */
export namespace ServerConnection {
  /**
   * A Jupyter server settings object.
   * Note that all of the settings are optional when passed to
   * [[makeSettings]].  The default settings are given in [[defaultSettings]].
   */
  export interface ISettings {
    /**
     * The base url of the server.
     */
    readonly baseUrl: string;

    /**
     * The app url of the JupyterLab application.
     */
    readonly appUrl: string;

    /**
     * The base ws url of the server.
     */
    readonly wsUrl: string;

    /**
     * The default request init options.
     */
    readonly init: RequestInit;

    /**
     * The authentication token for requests.  Use an empty string to disable.
     */
    readonly token: string;

    /**
     * Whether to append a token to a Websocket url.  The default is `false` in the browser
     * and `true` in node or jest.
     */
    readonly appendToken: boolean;

    /**
     * The `fetch` method to use.
     */
    readonly fetch: (
      input: RequestInfo,
      init?: RequestInit
    ) => Promise<Response>;

    /**
     * The `Request` object constructor.
     */
    readonly Request: typeof Request;

    /**
     * The `Headers` object constructor.
     */
    readonly Headers: typeof Headers;

    /**
     * The `WebSocket` object constructor.
     */
    readonly WebSocket: typeof WebSocket;
  }

  /**
   * Create a settings object given a subset of options.
   *
   * @param options - An optional partial set of options.
   *
   * @returns The full settings object.
   */
  export function makeSettings(options?: Partial<ISettings>): ISettings {
    return Private.makeSettings(options);
  }

  /**
   * Make an request to the notebook server.
   *
   * @param url - The url for the request.
   *
   * @param init - The initialization options for the request.
   *
   * @param settings - The server settings to apply to the request.
   *
   * @returns a Promise that resolves with the response.
   *
   * @throws If the url of the request is not a notebook server url.
   *
   * #### Notes
   * The `url` must start with `settings.baseUrl`.  The `init` settings are
   * merged with `settings.init`, with `init` taking precedence.
   * The headers in the two objects are not merged.
   * If there is no body data, we set the content type to `application/json`
   * because it is required by the Notebook server.
   */
  export function makeRequest(
    url: string,
    init: RequestInit,
    settings: ISettings
  ): Promise<Response> {
    return Private.handleRequest(url, init, settings);
  }

  /**
   * A wrapped error for a fetch response.
   */
  export class ResponseError extends Error {
    /**
     * Create a ResponseError from a response, handling the traceback and message
     * as appropriate.
     *
     * @param response The response object.
     *
     * @returns A promise that resolves with a `ResponseError` object.
     */
    static async create(response: Response): Promise<ResponseError> {
      try {
        const data = await response.json();
        if (data['traceback']) {
          console.error(data['traceback']);
        }
        if (data['message']) {
          return new ResponseError(response, data['message']);
        }
        return new ResponseError(response);
      } catch (e) {
        console.debug(e);
        return new ResponseError(response);
      }
    }

    /**
     * Create a new response error.
     */
    constructor(
      response: Response,
      message = `Invalid response: ${response.status} ${response.statusText}`,
      traceback = ''
    ) {
      super(message);
      this.response = response;
      this.traceback = traceback;
    }

    /**
     * The response associated with the error.
     */
    response: Response;

    /**
     * The traceback associated with the error.
     */
    traceback: string;
  }

  /**
   * A wrapped error for a network error.
   */
  export class NetworkError extends TypeError {
    /**
     * Create a new network error.
     */
    constructor(original: TypeError) {
      super(original.message);
      this.stack = original.stack;
    }
  }
}

/**
 * The namespace for module private data.
 */
namespace Private {
  /**
   * Handle the server connection settings, returning a new value.
   */
  export function makeSettings(
    options: Partial<ServerConnection.ISettings> = {}
  ): ServerConnection.ISettings {
    const pageBaseUrl = PageConfig.getBaseUrl();
    const pageWsUrl = PageConfig.getWsUrl();
    const baseUrl = URLExt.normalize(options.baseUrl) || pageBaseUrl;
    let wsUrl = options.wsUrl;
    // Prefer the default wsUrl if we are using the default baseUrl.
    if (!wsUrl && baseUrl === pageBaseUrl) {
      wsUrl = pageWsUrl;
    }
    // Otherwise convert the baseUrl to a wsUrl if possible.
    if (!wsUrl && baseUrl.indexOf('http') === 0) {
      wsUrl = 'ws' + baseUrl.slice(4);
    }
    // Otherwise fall back on the default wsUrl.
    wsUrl = wsUrl ?? pageWsUrl;

    return {
      init: { cache: 'no-store', credentials: 'same-origin' },
      fetch: FETCH,
      Headers: HEADERS,
      Request: REQUEST,
      WebSocket: WEBSOCKET,
      token: PageConfig.getToken(),
      appUrl: PageConfig.getOption('appUrl'),
      appendToken:
        typeof window === 'undefined' ||
        process?.env?.JEST_WORKER_ID !== undefined ||
        URLExt.getHostName(pageBaseUrl) !== URLExt.getHostName(wsUrl),
      ...options,
      baseUrl,
      wsUrl
    };
  }

  /**
   * Handle a request.
   *
   * @param url - The url for the request.
   *
   * @param init - The overrides for the request init.
   *
   * @param settings - The settings object for the request.
   *
   * #### Notes
   * The `url` must start with `settings.baseUrl`.  The `init` settings
   * take precedence over `settings.init`.
   */
  export function handleRequest(
    url: string,
    init: RequestInit,
    settings: ServerConnection.ISettings
  ): Promise<Response> {
    // Handle notebook server requests.
    if (url.indexOf(settings.baseUrl) !== 0) {
      throw new Error('Can only be used for notebook server requests');
    }

    // Use explicit cache buster when `no-store` is set since
    // not all browsers use it properly.
    const cache = init.cache ?? settings.init.cache;
    if (cache === 'no-store') {
      // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Bypassing_the_cache
      url += (/\?/.test(url) ? '&' : '?') + new Date().getTime();
    }

    const request = new settings.Request(url, { ...settings.init, ...init });

    // Handle authentication. Authentication can be overdetermined by
    // settings token and XSRF token.
    let authenticated = false;
    if (settings.token) {
      authenticated = true;
      request.headers.append('Authorization', `token ${settings.token}`);
    }
    if (typeof document !== 'undefined' && document?.cookie) {
      const xsrfToken = getCookie('_xsrf');
      if (xsrfToken !== undefined) {
        authenticated = true;
        request.headers.append('X-XSRFToken', xsrfToken);
      }
    }

    // Set the content type if there is no given data and we are
    // using an authenticated connection.
    if (!request.headers.has('Content-Type') && authenticated) {
      request.headers.set('Content-Type', 'application/json');
    }

    // Use `call` to avoid a `TypeError` in the browser.
    return settings.fetch.call(null, request).catch((e: TypeError) => {
      // Convert the TypeError into a more specific error.
      throw new ServerConnection.NetworkError(e);
    });
    // TODO: *this* is probably where we need a system-wide connectionFailure
    // signal we can hook into.
  }

  /**
   * Get a cookie from the document.
   */
  function getCookie(name: string): string | undefined {
    // From http://www.tornadoweb.org/en/stable/guide/security.html
    const matches = document.cookie.match('\\b' + name + '=([^;]*)\\b');
    return matches?.[1];
  }
}


text:
package com.hazelcast.collection.impl.txncollection.operations;

import com.hazelcast.collection.impl.collection.CollectionContainer;
import com.hazelcast.collection.impl.collection.CollectionDataSerializerHook;
import com.hazelcast.collection.impl.collection.CollectionItem;
import com.hazelcast.collection.impl.collection.operations.CollectionBackupAwareOperation;
import com.hazelcast.collection.impl.txncollection.CollectionTxnOperation;
import com.hazelcast.core.ItemEventType;
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.spi.impl.operationservice.Operation;
import com.hazelcast.spi.impl.operationservice.MutatingOperation;

import java.io.IOException;

public class CollectionTxnRemoveOperation extends CollectionBackupAwareOperation implements CollectionTxnOperation,
        MutatingOperation {

    private long itemId;
    private transient CollectionItem item;

    public CollectionTxnRemoveOperation() {
    }

    public CollectionTxnRemoveOperation(String name, long itemId) {
        super(name);
        this.itemId = itemId;
    }

    @Override
    public boolean shouldBackup() {
        return true;
    }

    @Override
    public Operation getBackupOperation() {
        return new CollectionTxnRemoveBackupOperation(name, itemId);
    }

    @Override
    public void run() throws Exception {
        CollectionContainer collectionContainer = getOrCreateContainer();
        item = collectionContainer.commitRemove(itemId);
    }

    @Override
    public void afterRun() throws Exception {
        if (item != null) {
            publishEvent(ItemEventType.REMOVED, item.getValue());
        }
    }

    @Override
    public long getItemId() {
        return itemId;
    }

    @Override
    public boolean isRemoveOperation() {
        return true;
    }

    @Override
    public int getClassId() {
        return CollectionDataSerializerHook.COLLECTION_TXN_REMOVE;
    }

    @Override
    protected void writeInternal(ObjectDataOutput out) throws IOException {
        super.writeInternal(out);
        out.writeLong(itemId);
    }

    @Override
    protected void readInternal(ObjectDataInput in) throws IOException {
        super.readInternal(in);
        itemId = in.readLong();
    }
}

redpajama_set_name: RedPajamaGithub


text:
/*******************************************************************************
* mvEth.h - Header File for : Marvell Gigabit Ethernet Controller
*
* DESCRIPTION:
*       This header file contains macros typedefs and function declaration specific to
*       the Marvell Gigabit Ethernet Controller.
*
* DEPENDENCIES:
*       None.
*
*******************************************************************************/

#ifndef __mvEthGbe_h__
#define __mvEthGbe_h__

extern MV_BOOL         ethDescInSram;
extern MV_BOOL         ethDescSwCoher;
extern ETH_PORT_CTRL*  ethPortCtrl[];

static INLINE MV_ULONG  ethDescVirtToPhy(ETH_QUEUE_CTRL* pQueueCtrl, MV_U8* pDesc)
{
#if defined (ETH_DESCR_IN_SRAM)
    if( ethDescInSram )
        return mvSramVirtToPhy(pDesc);
    else
#endif /* ETH_DESCR_IN_SRAM */
        return (pQueueCtrl->descBuf.bufPhysAddr + (pDesc - pQueueCtrl->descBuf.bufVirtPtr));
}
/* Return port handler */
#define mvEthPortHndlGet(port)  ethPortCtrl[port]

/* Used as WA for HW/SW race on TX */
static INLINE int      mvEthPortTxEnable(void* pPortHndl, int queue, int max_deep)
{
    int                 deep = 0;
    MV_U32              txCurrReg, txEnReg;
    ETH_TX_DESC*        pTxLastDesc;
    ETH_QUEUE_CTRL*     pQueueCtrl;
    ETH_PORT_CTRL*      pPortCtrl = (ETH_PORT_CTRL*)pPortHndl;

    txEnReg = MV_REG_VALUE(ETH_TX_QUEUE_COMMAND_REG(pPortCtrl->portNo));
    if( (txEnReg & MV_32BIT_LE_FAST(ETH_TXQ_ENABLE_MASK)) == 0)
    {
        MV_REG_VALUE(ETH_TX_QUEUE_COMMAND_REG(pPortCtrl->portNo)) = pPortCtrl->portTxQueueCmdReg;
        return 0;
    }

    pQueueCtrl = &pPortCtrl->txQueue[queue];
    pTxLastDesc = pQueueCtrl->pCurrentDescr;
    txCurrReg = MV_REG_READ(ETH_TX_CUR_DESC_PTR_REG(pPortCtrl->portNo, queue));
    if(ethDescVirtToPhy(pQueueCtrl, (MV_U8*)pTxLastDesc) == txCurrReg)
    {
        /* All descriptors are processed, no chance for race */
        return 0;
    }

    /* Check distance betwee HW and SW location: */
    /* If distance between HW and SW pointers is less than max_deep descriptors */
    /* Race condition is possible, so wait end of TX and restart TXQ */
    while(deep < max_deep)
    {
        pTxLastDesc = TX_PREV_DESC_PTR(pTxLastDesc, pQueueCtrl);
        if(ethDescVirtToPhy(pQueueCtrl, (MV_U8*)pTxLastDesc) == txCurrReg)
        {
            int count = 0;

            while( (txEnReg & MV_32BIT_LE_FAST(ETH_TXQ_ENABLE_MASK)) != 0)
            {
                count++;
                if(count > 10000)
                {
                    mvOsPrintf("mvEthPortTxEnable: timeout - TXQ_CMD=0x%08x\n",
                                MV_REG_READ(ETH_TX_QUEUE_COMMAND_REG(pPortCtrl->portNo)) );
                    break;
                }
                txEnReg = MV_REG_VALUE(ETH_TX_QUEUE_COMMAND_REG(pPortCtrl->portNo));
            }

            MV_REG_VALUE(ETH_TX_QUEUE_COMMAND_REG(pPortCtrl->portNo)) = pPortCtrl->portTxQueueCmdReg;
            return count;
        }
        deep++;
    }
    /* Distance between HW and SW pointers is more than max_deep descriptors, */
    /* So NO race condition - do nothing */
    return -1;
}

/* defines  */
#define ETH_CSUM_MIN_BYTE_COUNT     72

/* Tailgate and Kirwood have only 2K TX FIFO */
#if (MV_ETH_VERSION == 2) || (MV_ETH_VERSION == 4)
#define ETH_CSUM_MAX_BYTE_COUNT     1600
#else
#define ETH_CSUM_MAX_BYTE_COUNT     9*1024
#endif /* MV_ETH_VERSION */

#define ETH_MV_HEADER_SIZE	    2
#define ETH_MV_TX_EN

/* An offest in Tx descriptors to store data for buffers less than 8 Bytes */
#define MIN_TX_BUFF_LOAD            8
#define TX_BUF_OFFSET_IN_DESC       (ETH_TX_DESC_ALIGNED_SIZE - MIN_TX_BUFF_LOAD)

/* Default port configuration value */
#define PORT_CONFIG_VALUE                       \
             ETH_DEF_RX_QUEUE_MASK(0)       |   \
             ETH_DEF_RX_ARP_QUEUE_MASK(0)   |   \
             ETH_DEF_RX_TCP_QUEUE_MASK(0)   |   \
             ETH_DEF_RX_UDP_QUEUE_MASK(0)   |   \
             ETH_DEF_RX_BPDU_QUEUE_MASK(0)  |   \
             ETH_RX_CHECKSUM_WITH_PSEUDO_HDR

/* Default port extend configuration value */
#define PORT_CONFIG_EXTEND_VALUE            0

#define PORT_SERIAL_CONTROL_VALUE                           \
            ETH_DISABLE_FC_AUTO_NEG_MASK                |   \
            BIT9                                        |   \
            ETH_DO_NOT_FORCE_LINK_FAIL_MASK             |   \
            ETH_MAX_RX_PACKET_1552BYTE                  |   \
            ETH_SET_FULL_DUPLEX_MASK

#define PORT_SERIAL_CONTROL_100MB_FORCE_VALUE               \
            ETH_FORCE_LINK_PASS_MASK                    |   \
            ETH_DISABLE_DUPLEX_AUTO_NEG_MASK            |   \
            ETH_DISABLE_FC_AUTO_NEG_MASK                |   \
            BIT9                                        |   \
            ETH_DO_NOT_FORCE_LINK_FAIL_MASK             |   \
            ETH_DISABLE_SPEED_AUTO_NEG_MASK             |   \
            ETH_SET_FULL_DUPLEX_MASK                    |   \
            ETH_SET_MII_SPEED_100_MASK                  |   \
            ETH_MAX_RX_PACKET_1552BYTE

#define PORT_SERIAL_CONTROL_1000MB_FORCE_VALUE              \
            ETH_FORCE_LINK_PASS_MASK                    |   \
            ETH_DISABLE_DUPLEX_AUTO_NEG_MASK            |   \
            ETH_DISABLE_FC_AUTO_NEG_MASK                |   \
            BIT9                                        |   \
            ETH_DO_NOT_FORCE_LINK_FAIL_MASK             |   \
            ETH_DISABLE_SPEED_AUTO_NEG_MASK             |   \
            ETH_SET_FULL_DUPLEX_MASK                    |   \
            ETH_SET_GMII_SPEED_1000_MASK                |   \
            ETH_MAX_RX_PACKET_1552BYTE

#define PORT_SERIAL_CONTROL_SGMII_IBAN_VALUE                \
            ETH_DISABLE_FC_AUTO_NEG_MASK                |   \
            BIT9                                        |   \
            ETH_IN_BAND_AN_EN_MASK                      |   \
            ETH_DO_NOT_FORCE_LINK_FAIL_MASK             |   \
            ETH_MAX_RX_PACKET_1552BYTE

/* Function headers: */
MV_VOID     mvEthSetSpecialMcastTable(int portNo, int queue);
MV_STATUS   mvEthArpRxQueue(void* pPortHandle, int arpQueue);
MV_STATUS   mvEthUdpRxQueue(void* pPortHandle, int udpQueue);
MV_STATUS   mvEthTcpRxQueue(void* pPortHandle, int tcpQueue);
MV_STATUS   mvEthMacAddrGet(int portNo, unsigned char *pAddr);
MV_VOID     mvEthSetOtherMcastTable(int portNo, int queue);
MV_STATUS   mvEthHeaderModeSet(void* pPortHandle, MV_ETH_HEADER_MODE headerMode);
/* Interrupt Coalesting functions */
MV_U32      mvEthRxCoalSet(void* pPortHndl, MV_U32 uSec);
MV_U32      mvEthTxCoalSet(void* pPortHndl, MV_U32 uSec);
MV_STATUS   mvEthCoalGet(void* pPortHndl, MV_U32* pRxCoal, MV_U32* pTxCoal);

/******************************************************************************/
/*                          Data Flow functions                               */
/******************************************************************************/
static INLINE void      mvEthPortTxRestart(void* pPortHndl)
{
    ETH_PORT_CTRL*      pPortCtrl = (ETH_PORT_CTRL*)pPortHndl;

    MV_REG_VALUE(ETH_TX_QUEUE_COMMAND_REG(pPortCtrl->portNo)) = pPortCtrl->portTxQueueCmdReg;
}

/* Get number of Free resources in specific TX queue */
static INLINE int     mvEthTxResourceGet(void* pPortHndl, int txQueue)
{
    ETH_PORT_CTRL*  pPortCtrl = (ETH_PORT_CTRL*)pPortHndl;

    return (pPortCtrl->txQueue[txQueue].resource);
}

/* Get number of Free resources in specific RX queue */
static INLINE int     mvEthRxResourceGet(void* pPortHndl, int rxQueue)
{
    ETH_PORT_CTRL*  pPortCtrl = (ETH_PORT_CTRL*)pPortHndl;

    return (pPortCtrl->rxQueue[rxQueue].resource);
}

static INLINE int     mvEthTxQueueIsFull(void* pPortHndl, int txQueue)
{
    ETH_PORT_CTRL*  pPortCtrl = (ETH_PORT_CTRL*)pPortHndl;

    if(pPortCtrl->txQueue[txQueue].resource == 0)
        return MV_TRUE;

    return MV_FALSE;
}

/* Get number of Free resources in specific RX queue */
static INLINE int     mvEthRxQueueIsFull(void* pPortHndl, int rxQueue)
{
    ETH_PORT_CTRL*  pPortCtrl = (ETH_PORT_CTRL*)pPortHndl;
    ETH_QUEUE_CTRL* pQueueCtrl = &pPortCtrl->rxQueue[rxQueue];

    if( (pQueueCtrl->pUsedDescr == pQueueCtrl->pCurrentDescr) &&
        (pQueueCtrl->resource != 0) )
        return MV_TRUE;

    return MV_FALSE;
}

static INLINE int     mvEthTxQueueIsEmpty(void* pPortHndl, int txQueue)
{
    ETH_PORT_CTRL*  pPortCtrl = (ETH_PORT_CTRL*)pPortHndl;
    ETH_QUEUE_CTRL* pQueueCtrl = &pPortCtrl->txQueue[txQueue];

    if( (pQueueCtrl->pUsedDescr == pQueueCtrl->pCurrentDescr) &&
        (pQueueCtrl->resource != 0) )
    {
        return MV_TRUE;
    }
    return MV_FALSE;
}

/* Get number of Free resources in specific RX queue */
static INLINE int     mvEthRxQueueIsEmpty(void* pPortHndl, int rxQueue)
{
    ETH_PORT_CTRL*  pPortCtrl = (ETH_PORT_CTRL*)pPortHndl;

    if(pPortCtrl->rxQueue[rxQueue].resource == 0)
        return MV_TRUE;

    return MV_FALSE;
}

/*******************************************************************************
* mvEthPortTx - Send an Ethernet packet
*
* DESCRIPTION:
*       This routine send a given packet described by pPktInfo parameter.
*       Single buffer only.
*
* INPUT:
*       void*       pEthPortHndl  - Ethernet Port handler.
*       int         txQueue       - Number of Tx queue.
*       MV_PKT_INFO *pPktInfo     - User packet to send.
*
* RETURN:
*       MV_NO_RESOURCE  - No enough resources to send this packet.
*       MV_ERROR        - Unexpected Fatal error.
*       MV_OK           - Packet send successfully.
*
*******************************************************************************/
static INLINE MV_STATUS   mvEthPortTx(void* pEthPortHndl, int txQueue, MV_PKT_INFO* pPktInfo)
{
    ETH_TX_DESC*    pTxCurrDesc;
    ETH_PORT_CTRL*  pPortCtrl = (ETH_PORT_CTRL*)pEthPortHndl;
    ETH_QUEUE_CTRL* pQueueCtrl;
    int             portNo;
    MV_BUF_INFO*    pBufInfo = pPktInfo->pFrags;

#ifdef ETH_DEBUG
    if(pPortCtrl->portState != MV_ACTIVE)
        return MV_BAD_STATE;
#endif /* ETH_DEBUG */

    portNo = pPortCtrl->portNo;
    pQueueCtrl = &pPortCtrl->txQueue[txQueue];

    /* Get the Tx Desc ring indexes */
    pTxCurrDesc = pQueueCtrl->pCurrentDescr;

    /* Check if there is enough resources to send the packet */
    if(pQueueCtrl->resource == 0)
        return MV_NO_RESOURCE;

    pTxCurrDesc->byteCnt = pBufInfo->dataSize;

    /* Flash Buffer */
    if(pPktInfo->pktSize != 0)
    {
#ifdef MV_NETBSD
        pTxCurrDesc->bufPtr = pBufInfo->bufPhysAddr;
        ETH_PACKET_CACHE_FLUSH(pBufInfo->bufVirtPtr, pPktInfo->pktSize);
#else
        pTxCurrDesc->bufPtr = ETH_PACKET_CACHE_FLUSH(pBufInfo->bufVirtPtr, pPktInfo->pktSize);
#endif
        pPktInfo->pktSize = 0;
    }
    else
        pTxCurrDesc->bufPtr = pBufInfo->bufPhysAddr;

    pTxCurrDesc->returnInfo = (MV_ULONG)pPktInfo;

    /* There is only one buffer in the packet */
    /* The OSG might set some bits for checksum offload, so add them to first descriptor */
    pTxCurrDesc->cmdSts = pPktInfo->status              |
                          ETH_BUFFER_OWNED_BY_DMA       |
                          ETH_TX_GENERATE_CRC_MASK      |
                          ETH_TX_ENABLE_INTERRUPT_MASK  |
                          ETH_TX_ZERO_PADDING_MASK      |
                          ETH_TX_FIRST_DESC_MASK        |
                          ETH_TX_LAST_DESC_MASK;

    ETH_DESCR_FLUSH_INV(pPortCtrl, pTxCurrDesc);

    pQueueCtrl->resource--;
    pQueueCtrl->pCurrentDescr = TX_NEXT_DESC_PTR(pTxCurrDesc, pQueueCtrl);

    /* Apply send command */
    MV_REG_VALUE(ETH_TX_QUEUE_COMMAND_REG(portNo)) = pPortCtrl->portTxQueueCmdReg;

    return MV_OK;
}

/*******************************************************************************
* mvEthPortSgTx - Send an Ethernet packet
*
* DESCRIPTION:
*       This routine send a given packet described by pBufInfo parameter. It
*       supports transmitting of a packet spaned over multiple buffers.
*
* INPUT:
*       void*       pEthPortHndl  - Ethernet Port handler.
*       int         txQueue       - Number of Tx queue.
*       MV_PKT_INFO *pPktInfo     - User packet to send.
*
* RETURN:
*       MV_NO_RESOURCE  - No enough resources to send this packet.
*       MV_ERROR        - Unexpected Fatal error.
*       MV_OK           - Packet send successfully.
*
*******************************************************************************/
static INLINE MV_STATUS   mvEthPortSgTx(void* pEthPortHndl, int txQueue, MV_PKT_INFO* pPktInfo)
{
    ETH_TX_DESC*    pTxFirstDesc;
    ETH_TX_DESC*    pTxCurrDesc;
    ETH_PORT_CTRL*  pPortCtrl = (ETH_PORT_CTRL*)pEthPortHndl;
    ETH_QUEUE_CTRL* pQueueCtrl;
    int             portNo, bufCount;
    MV_BUF_INFO*    pBufInfo = pPktInfo->pFrags;
    MV_U8*          pTxBuf;

#ifdef ETH_DEBUG
    if(pPortCtrl->portState != MV_ACTIVE)
        return MV_BAD_STATE;
#endif /* ETH_DEBUG */

    portNo = pPortCtrl->portNo;
    pQueueCtrl = &pPortCtrl->txQueue[txQueue];

    /* Get the Tx Desc ring indexes */
    pTxCurrDesc = pQueueCtrl->pCurrentDescr;

    /* Check if there is enough resources to send the packet */
    if(pQueueCtrl->resource < pPktInfo->numFrags)
        return MV_NO_RESOURCE;

    /* Remember first desc */
    pTxFirstDesc  = pTxCurrDesc;

    bufCount = 0;
    while(MV_TRUE)
    {
        if(pBufInfo[bufCount].dataSize <= MIN_TX_BUFF_LOAD)
        {
            /* Buffers with a payload smaller than MIN_TX_BUFF_LOAD (8 bytes) must be aligned    */
            /* to 64-bit boundary. Two options here:                                             */
            /* 1) Usually, copy the payload to the reserved 8 bytes inside descriptor.           */
            /* 2) In the Half duplex workaround, the reserved 8 bytes inside descriptor are used */
            /*    as a pointer to the aligned buffer, copy the small payload to this buffer.     */
            pTxBuf = ((MV_U8*)pTxCurrDesc)+TX_BUF_OFFSET_IN_DESC;
            mvOsBCopy(pBufInfo[bufCount].bufVirtPtr, pTxBuf, pBufInfo[bufCount].dataSize);
            pTxCurrDesc->bufPtr = ethDescVirtToPhy(pQueueCtrl, pTxBuf);
        }
        else
        {
            /* Flash Buffer */
#ifdef MV_NETBSD
            pTxCurrDesc->bufPtr = pBufInfo[bufCount].bufPhysAddr;
	    ETH_PACKET_CACHE_FLUSH(pBufInfo[bufCount].bufVirtPtr, pBufInfo[bufCount].dataSize);
#else
            pTxCurrDesc->bufPtr = ETH_PACKET_CACHE_FLUSH(pBufInfo[bufCount].bufVirtPtr, pBufInfo[bufCount].dataSize);
#endif
        }

        pTxCurrDesc->byteCnt = pBufInfo[bufCount].dataSize;
        bufCount++;

        if(bufCount >= pPktInfo->numFrags)
            break;

        if(bufCount > 1)
        {
            /* There is middle buffer of the packet Not First and Not Last */
            pTxCurrDesc->cmdSts = ETH_BUFFER_OWNED_BY_DMA;
            ETH_DESCR_FLUSH_INV(pPortCtrl, pTxCurrDesc);
        }
        /* Go to next descriptor and next buffer */
        pTxCurrDesc = TX_NEXT_DESC_PTR(pTxCurrDesc, pQueueCtrl);
    }
    /* Set last desc with DMA ownership and interrupt enable. */
    pTxCurrDesc->returnInfo = (MV_ULONG)pPktInfo;
    if(bufCount == 1)
    {
        /* There is only one buffer in the packet */
        /* The OSG might set some bits for checksum offload, so add them to first descriptor */
        pTxCurrDesc->cmdSts = pPktInfo->status              |
                              ETH_BUFFER_OWNED_BY_DMA       |
                              ETH_TX_GENERATE_CRC_MASK      |
                              ETH_TX_ENABLE_INTERRUPT_MASK  |
                              ETH_TX_ZERO_PADDING_MASK      |
                              ETH_TX_FIRST_DESC_MASK        |
                              ETH_TX_LAST_DESC_MASK;

        ETH_DESCR_FLUSH_INV(pPortCtrl, pTxCurrDesc);
    }
    else
    {
        /* Last but not First */
        pTxCurrDesc->cmdSts = ETH_BUFFER_OWNED_BY_DMA       |
                              ETH_TX_ENABLE_INTERRUPT_MASK  |
                              ETH_TX_ZERO_PADDING_MASK      |
                              ETH_TX_LAST_DESC_MASK;

        ETH_DESCR_FLUSH_INV(pPortCtrl, pTxCurrDesc);

        /* Update First when more than one buffer in the packet */
        /* The OSG might set some bits for checksum offload, so add them to first descriptor */
        pTxFirstDesc->cmdSts = pPktInfo->status             |
                               ETH_BUFFER_OWNED_BY_DMA      |
                               ETH_TX_GENERATE_CRC_MASK     |
                               ETH_TX_FIRST_DESC_MASK;

        ETH_DESCR_FLUSH_INV(pPortCtrl, pTxFirstDesc);
    }
    /* Update txQueue state */
    pQueueCtrl->resource -= bufCount;
    pQueueCtrl->pCurrentDescr = TX_NEXT_DESC_PTR(pTxCurrDesc, pQueueCtrl);

    /* Apply send command */
    MV_REG_VALUE(ETH_TX_QUEUE_COMMAND_REG(portNo)) = pPortCtrl->portTxQueueCmdReg;

    return MV_OK;
}

/*******************************************************************************
* mvEthPortTxDone - Free all used Tx descriptors and mBlks.
*
* DESCRIPTION:
*       This routine returns the transmitted packet information to the caller.
*
* INPUT:
*       void*       pEthPortHndl    - Ethernet Port handler.
*       int         txQueue         - Number of Tx queue.
*
* OUTPUT:
*       MV_PKT_INFO *pPktInfo       - Pointer to packet was sent.
*
* RETURN:
*       MV_NOT_FOUND    - No transmitted packets to return. Transmit in progress.
*       MV_EMPTY        - No transmitted packets to return. TX Queue is empty.
*       MV_ERROR        - Unexpected Fatal error.
*       MV_OK           - There is transmitted packet in the queue,
*                       'pPktInfo' filled with relevant information.
*
*******************************************************************************/
static INLINE MV_PKT_INFO*    mvEthPortTxDone(void* pEthPortHndl, int txQueue)
{
    ETH_TX_DESC*    pTxCurrDesc;
    ETH_TX_DESC*    pTxUsedDesc;
    ETH_QUEUE_CTRL* pQueueCtrl;
    ETH_PORT_CTRL*  pPortCtrl = (ETH_PORT_CTRL*)pEthPortHndl;
    MV_PKT_INFO*    pPktInfo;
    MV_U32          commandStatus;

    pQueueCtrl = &pPortCtrl->txQueue[txQueue];

    pTxUsedDesc = pQueueCtrl->pUsedDescr;
    pTxCurrDesc = pQueueCtrl->pCurrentDescr;

    while(MV_TRUE)
    {
        /* No more used descriptors */
        commandStatus = pTxUsedDesc->cmdSts;
        if (commandStatus  & (ETH_BUFFER_OWNED_BY_DMA))
        {
            ETH_DESCR_INV(pPortCtrl, pTxUsedDesc);
            return NULL;
        }
        if( (pTxUsedDesc == pTxCurrDesc) &&
            (pQueueCtrl->resource != 0) )
        {
            return NULL;
        }
        pQueueCtrl->resource++;
        pQueueCtrl->pUsedDescr = TX_NEXT_DESC_PTR(pTxUsedDesc, pQueueCtrl);
        if(commandStatus & (ETH_TX_LAST_DESC_MASK))
        {
            pPktInfo = (MV_PKT_INFO*)pTxUsedDesc->returnInfo;
            pPktInfo->status  = commandStatus;
            return pPktInfo;
        }
        pTxUsedDesc = pQueueCtrl->pUsedDescr;
    }
}

/*******************************************************************************
* mvEthPortRx - Get new received packets from Rx queue.
*
* DESCRIPTION:
*       This routine returns the received data to the caller. There is no
*       data copying during routine operation. All information is returned
*       using pointer to packet information struct passed from the caller.
*
* INPUT:
*       void*       pEthPortHndl    - Ethernet Port handler.
*       int         rxQueue         - Number of Rx queue.
*
* OUTPUT:
*       MV_PKT_INFO *pPktInfo       - Pointer to received packet.
*
* RETURN:
*       MV_NO_RESOURCE  - No free resources in RX queue.
*       MV_ERROR        - Unexpected Fatal error.
*       MV_OK           - New packet received and 'pBufInfo' structure filled
*                       with relevant information.
*
*******************************************************************************/
static INLINE MV_PKT_INFO*    mvEthPortRx(void* pEthPortHndl, int rxQueue)
{
    ETH_RX_DESC     *pRxCurrDesc;
    MV_U32          commandStatus;
    ETH_PORT_CTRL*  pPortCtrl = (ETH_PORT_CTRL*)pEthPortHndl;
    ETH_QUEUE_CTRL* pQueueCtrl;
    MV_PKT_INFO*    pPktInfo;

    pQueueCtrl = &(pPortCtrl->rxQueue[rxQueue]);

    /* Check resources */
    if(pQueueCtrl->resource == 0)
    {
        mvOsPrintf("ethPortRx: no more resources\n");
        return NULL;
    }
    while(MV_TRUE)
    {
        /* Get the Rx Desc ring 'curr and 'used' indexes */
        pRxCurrDesc = pQueueCtrl->pCurrentDescr;

	commandStatus   = pRxCurrDesc->cmdSts;
        if (commandStatus & (ETH_BUFFER_OWNED_BY_DMA))
        {
            /* Nothing to receive... */
            ETH_DESCR_INV(pPortCtrl, pRxCurrDesc);
            return NULL;
        }

        /* Valid RX only if FIRST and LAST bits are set */
        if( (commandStatus & (ETH_RX_LAST_DESC_MASK | ETH_RX_FIRST_DESC_MASK)) ==
                             (ETH_RX_LAST_DESC_MASK | ETH_RX_FIRST_DESC_MASK) )
        {
            pPktInfo = (MV_PKT_INFO*)pRxCurrDesc->returnInfo;
            pPktInfo->pFrags->dataSize  = pRxCurrDesc->byteCnt - 4;
            pPktInfo->status            = commandStatus;
            pPktInfo->fragIP            = pRxCurrDesc->bufSize & ETH_RX_IP_FRAGMENTED_FRAME_MASK;

            pQueueCtrl->resource--;
            /* Update 'curr' in data structure */
            pQueueCtrl->pCurrentDescr = RX_NEXT_DESC_PTR(pRxCurrDesc, pQueueCtrl);

#ifdef INCLUDE_SYNC_BARR
            mvCpuIfSyncBarr(DRAM_TARGET);
#endif
            return pPktInfo;
        }
        else
        {
            ETH_RX_DESC*    pRxUsedDesc = pQueueCtrl->pUsedDescr;

#ifdef ETH_DEBUG
            mvOsPrintf("ethDrv: Unexpected Jumbo frame: "
                       "status=0x%08x, byteCnt=%d, pData=0x%x\n",
                        commandStatus, pRxCurrDesc->byteCnt, pRxCurrDesc->bufPtr);
#endif /* ETH_DEBUG */

            /* move buffer from pCurrentDescr position to pUsedDescr position */
            pRxUsedDesc->bufPtr     = pRxCurrDesc->bufPtr;
            pRxUsedDesc->returnInfo = pRxCurrDesc->returnInfo;
            pRxUsedDesc->bufSize    = pRxCurrDesc->bufSize & ETH_RX_BUFFER_MASK;

            /* Return the descriptor to DMA ownership */
            pRxUsedDesc->cmdSts = ETH_BUFFER_OWNED_BY_DMA |
                                  ETH_RX_ENABLE_INTERRUPT_MASK;

            /* Flush descriptor and CPU pipe */
            ETH_DESCR_FLUSH_INV(pPortCtrl, pRxUsedDesc);

            /* Move the used descriptor pointer to the next descriptor */
            pQueueCtrl->pUsedDescr = RX_NEXT_DESC_PTR(pRxUsedDesc, pQueueCtrl);
            pQueueCtrl->pCurrentDescr = RX_NEXT_DESC_PTR(pRxCurrDesc, pQueueCtrl);
        }
    }
}

/*******************************************************************************
* mvEthPortRxDone - Returns a Rx buffer back to the Rx ring.
*
* DESCRIPTION:
*       This routine returns a Rx buffer back to the Rx ring.
*
* INPUT:
*       void*       pEthPortHndl    - Ethernet Port handler.
*       int         rxQueue         - Number of Rx queue.
*       MV_PKT_INFO *pPktInfo       - Pointer to received packet.
*
* RETURN:
*       MV_ERROR        - Unexpected Fatal error.
*       MV_OUT_OF_RANGE - RX queue is already FULL, so this buffer can't be
*                       returned to this queue.
*       MV_FULL         - Buffer returned successfully and RX queue became full.
*                       More buffers should not be returned at the time.
*       MV_OK           - Buffer returned successfully and there are more free
*                       places in the queue.
*
*******************************************************************************/
static INLINE MV_STATUS   mvEthPortRxDone(void* pEthPortHndl, int rxQueue, MV_PKT_INFO *pPktInfo)
{
    ETH_RX_DESC*    pRxUsedDesc;
    ETH_QUEUE_CTRL* pQueueCtrl;
    ETH_PORT_CTRL*  pPortCtrl = (ETH_PORT_CTRL*)pEthPortHndl;

    pQueueCtrl = &pPortCtrl->rxQueue[rxQueue];

    /* Get 'used' Rx descriptor */
    pRxUsedDesc = pQueueCtrl->pUsedDescr;

    /* Check that ring is not FULL */
    if( (pQueueCtrl->pUsedDescr == pQueueCtrl->pCurrentDescr) &&
        (pQueueCtrl->resource != 0) )
    {
        mvOsPrintf("%s %d: out of range Error resource=%d, curr=%p, used=%p\n",
                    __FUNCTION__, pPortCtrl->portNo, pQueueCtrl->resource,
                    pQueueCtrl->pCurrentDescr, pQueueCtrl->pUsedDescr);
        return MV_OUT_OF_RANGE;
    }

    pRxUsedDesc->bufPtr     = pPktInfo->pFrags->bufPhysAddr;
    pRxUsedDesc->returnInfo = (MV_ULONG)pPktInfo;
    pRxUsedDesc->bufSize    = pPktInfo->pFrags->bufSize & ETH_RX_BUFFER_MASK;

    /* Invalidate data buffer accordingly with pktSize */
    if(pPktInfo->pktSize != 0)
    {
        ETH_PACKET_CACHE_INVALIDATE(pPktInfo->pFrags->bufVirtPtr, pPktInfo->pktSize);
        pPktInfo->pktSize = 0;
    }

    /* Return the descriptor to DMA ownership */
    pRxUsedDesc->cmdSts = ETH_BUFFER_OWNED_BY_DMA | ETH_RX_ENABLE_INTERRUPT_MASK;

    /* Flush descriptor and CPU pipe */
    ETH_DESCR_FLUSH_INV(pPortCtrl, pRxUsedDesc);

    pQueueCtrl->resource++;

    /* Move the used descriptor pointer to the next descriptor */
    pQueueCtrl->pUsedDescr = RX_NEXT_DESC_PTR(pRxUsedDesc, pQueueCtrl);

    /* If ring became Full return MV_FULL */
    if(pQueueCtrl->pUsedDescr == pQueueCtrl->pCurrentDescr)
        return MV_FULL;

    return MV_OK;
}

#endif /* __mvEthGbe_h__ */


text:
require 'spec_helper'

RSpec.describe Spam::SpamVerdictService do
  include_context 'includes Spam constants'

  let(:fake_ip) { '1.2.3.4' }
  let(:fake_user_agent) { 'fake-user-agent' }
  let(:fake_referrer) { 'fake-http-referrer' }
  let(:env) do
    { 'action_dispatch.remote_ip' => fake_ip,
      'HTTP_USER_AGENT' => fake_user_agent,
      'HTTP_REFERRER' => fake_referrer }
  end

  let(:request) { double(:request, env: env) }

  let(:check_for_spam) { true }
  let_it_be(:user) { create(:user) }
  let(:issue) { build(:issue, author: user) }
  let(:service) do
    described_class.new(user: user, target: issue, request: request, options: {})
  end

  describe '#execute' do
    subject { service.execute }

    before do
      allow(service).to receive(:akismet_verdict).and_return(nil)
      allow(service).to receive(:external_verdict).and_return(nil)
    end

    context 'if all services return nil' do
      it 'renders ALLOW verdict' do
        expect(subject).to eq ALLOW
      end
    end

    context 'if only one service returns a verdict' do
      context 'and it is supported' do
        before do
          allow(service).to receive(:akismet_verdict).and_return(DISALLOW)
        end

        it 'renders that verdict' do
          expect(subject).to eq DISALLOW
        end
      end

      context 'and it is unexpected' do
        before do
          allow(service).to receive(:akismet_verdict).and_return("unexpected")
        end

        it 'allows' do
          expect(subject).to eq ALLOW
        end
      end
    end

    context 'if more than one service returns a verdict' do
      context 'and they are supported' do
        before do
          allow(service).to receive(:akismet_verdict).and_return(DISALLOW)
          allow(service).to receive(:external_verdict).and_return(BLOCK_USER)
        end

        it 'renders the more restrictive verdict' do
          expect(subject).to eq BLOCK_USER
        end
      end

      context 'and one is supported' do
        before do
          allow(service).to receive(:akismet_verdict).and_return('nonsense')
          allow(service).to receive(:external_verdict).and_return(BLOCK_USER)
        end

        it 'renders the more restrictive verdict' do
          expect(subject).to eq BLOCK_USER
        end
      end

      context 'and none are supported' do
        before do
          allow(service).to receive(:akismet_verdict).and_return('nonsense')
          allow(service).to receive(:external_verdict).and_return('rubbish')
        end

        it 'renders the more restrictive verdict' do
          expect(subject).to eq ALLOW
        end
      end
    end
  end

  describe '#akismet_verdict' do
    subject { service.send(:akismet_verdict) }

    context 'if Akismet is enabled' do
      before do
        stub_application_setting(akismet_enabled: true)
        allow_next_instance_of(Spam::AkismetService) do |service|
          allow(service).to receive(:spam?).and_return(akismet_result)
        end
      end

      context 'if Akismet considers it spam' do
        let(:akismet_result) { true }

        context 'if reCAPTCHA is enabled' do
          before do
            stub_application_setting(recaptcha_enabled: true)
          end

          it 'returns conditionally allow verdict' do
            expect(subject).to eq CONDITIONAL_ALLOW
          end
        end

        context 'if reCAPTCHA is not enabled' do
          before do
            stub_application_setting(recaptcha_enabled: false)
          end

          it 'renders disallow verdict' do
            expect(subject).to eq DISALLOW
          end
        end
      end

      context 'if Akismet does not consider it spam' do
        let(:akismet_result) { false }

        it 'renders allow verdict' do
          expect(subject).to eq ALLOW
        end
      end
    end

    context 'if Akismet is not enabled' do
      before do
        stub_application_setting(akismet_enabled: false)
      end

      it 'renders allow verdict' do
        expect(subject).to eq ALLOW
      end
    end
  end

  describe '#external_verdict' do
    subject { service.send(:external_verdict) }

    context 'if a Spam Check endpoint enabled and set to a URL' do
      let(:spam_check_body) { {} }
      let(:spam_check_http_status) { nil }

      before do
        stub_application_setting(spam_check_endpoint_enabled: true)
        stub_application_setting(spam_check_endpoint_url: "http://www.spamcheckurl.com/spam_check")
        stub_request(:post, /.*spamcheckurl.com.*/).to_return( body: spam_check_body.to_json, status: spam_check_http_status )
      end

      context 'if the endpoint is accessible' do
        let(:spam_check_http_status) { 200 }
        let(:error) { nil }
        let(:verdict) { nil }
        let(:spam_check_body) do
          { verdict: verdict, error: error }
        end

        context 'the result is a valid verdict' do
          let(:verdict) { 'allow' }

          it 'returns the verdict' do
            expect(subject).to eq ALLOW
          end
        end

        context 'the verdict is an unexpected string' do
          let(:verdict) { 'this is fine' }

          it 'returns the string' do
            expect(subject).to eq verdict
          end
        end

        context 'the JSON is malformed' do
          let(:spam_check_body) { 'this is fine' }

          it 'returns allow' do
            expect(subject).to eq ALLOW
          end
        end

        context 'the verdict is an empty string' do
          let(:verdict) { '' }

          it 'returns nil' do
            expect(subject).to eq verdict
          end
        end

        context 'the verdict is nil' do
          let(:verdict) { nil }

          it 'returns nil' do
            expect(subject).to be_nil
          end
        end

        context 'there is an error' do
          let(:error) { "Sorry Dave, I can't do that" }

          it 'returns nil' do
            expect(subject).to be_nil
          end
        end

        context 'the HTTP status is not 200' do
          let(:spam_check_http_status) { 500 }

          it 'returns nil' do
            expect(subject).to be_nil
          end
        end

        context 'the confused API endpoint returns both an error and a verdict' do
          let(:verdict) { 'disallow' }
          let(:error) { 'oh noes!' }

          it 'renders the verdict' do
            expect(subject).to eq DISALLOW
          end
        end
      end

      context 'if the endpoint times out' do
        before do
          stub_request(:post, /.*spamcheckurl.com.*/).to_timeout
        end

        it 'returns nil' do
          expect(subject).to be_nil
        end
      end
    end

    context 'if a Spam Check endpoint is not set' do
      before do
        stub_application_setting(spam_check_endpoint_url: nil)
      end

      it 'returns nil' do
        expect(subject).to be_nil
      end
    end

    context 'if Spam Check endpoint is not enabled' do
      before do
        stub_application_setting(spam_check_endpoint_enabled: false)
      end

      it 'returns nil' do
        expect(subject).to be_nil
      end
    end
  end
end


text:
<?php

/*
|--------------------------------------------------------------------------
| Maintenance
|--------------------------------------------------------------------------
|
| Here you can activate site maintenance mode by setting $maintenance variable to 'enable'.
|
| Maintenance mode will only affect your site's frontend so visitors are able to see
| wp-admin page. Authenticated administrators can edit pages, posts etc. and they
| are able to see frontend. However, if you want to activate maintenance mode
| for the entire site, set the $maintenance variable to 'full'
|
| Supported: false, 'enable', 'full'
|
*/
$maintenance = bc_env('MAINTENANCE', false);

/*
|--------------------------------------------------------------------------
| Maintenance page
|--------------------------------------------------------------------------
|
| Define here your maintenance page template file.
| Template file root folder is 'resources/views'
|
*/
$template = 'maintenance.twig';

/*****************************************************************************************/
base_camp_maintenance($maintenance, $template);


text:
var chart_store_template = Datanium.util.CommonUtils.getStoreTemplate();

function genLineChartStore(template, fields) {
	template.fields = mergeFields(fields);
	if (Datanium.GlobalData.queryResult4Chart != null) {
		// clone
		var queryResult = JSON.parse(JSON.stringify(Datanium.GlobalData.queryResult4Chart));
		if (Datanium.GlobalData.autoScale) {
			template.data = Datanium.util.CommonUtils.scaleMeasures(queryResult, yFields);
		} else {
			template.data = Datanium.GlobalData.queryResult4Chart;
		}
	}
	eval("LineChartStore = Ext.create('Ext.data.Store'," + Ext.encode(template) + ");");
	LineChartStore.load();
	return LineChartStore;
}

/*
 * function mergeDimensions(queryResult) { // never pass this condition since
 * there is only one dimension now if (queryResult != null && queryResult.result !=
 * null && xFields.length > 1) { for ( var i = 0; i < queryResult.result.length;
 * i++) { for ( var j = 0; j < xFields.length; j++) { if (xFields[j] in
 * queryResult.result[i]) { if (queryResult.result[i][xFieldsLabel] == null) {
 * queryResult.result[i][xFieldsLabel] = queryResult.result[i][xFields[j]] }
 * else { queryResult.result[i][xFieldsLabel] =
 * queryResult.result[i][xFieldsLabel] + "/" + queryResult.result[i][xFields[j]] } } } } }
 * return queryResult; }
 */

function mergeFields(fields) {
	if (xFields.length > 1) {
		fields = [];
		fields.push(xFieldsLabel);
		fields.push.apply(fields, yFields);
	}
	return fields;
}

function generateSeries4Line(yFields, yFieldsTxt, xFieldsLabel) {
	var series = [];
	Ext.Array.each(yFields, function(yfld, index) {
		var s = {
			type : 'line',
			axis : false,
			highlight : true,
			smooth : true,
			showMarkers : false,
			fill : true,
			xField : xFieldsLabel,
			yField : yfld,
			title : yFieldsTxt[index]
		};
		if (!Datanium.GlobalData.autoScale) {
			s.tips = {
				style : 'background:#fff; text-align: center;',
				trackMouse : true,
				width : 140,
				height : 42,
				renderer : function(storeItem, item) {
					var tooltipTitle = yFieldsTxt[index] + ' ' + storeItem.get(xFieldsLabel) + '<br>';
					var tooltipValue = storeItem.get(yfld);
					this.setTitle(tooltipTitle + tooltipValue);
					this.width = tooltipTitle.length * 10;
				}
			};
		}
		series.push(s);
	});
	return series;
}

var fields = [];
var xFields = [];
var yFields = [];
var xFieldsLabel = "";

Ext.define('Datanium.view.charts.LineChart', {
	extend : 'Ext.chart.Chart',
	alias : 'widget.linechart',
	initComponent : function() {
		Ext.apply(this, {
			layout : 'fit',
			region : 'center',
			style : 'background:#fff',
			animate : true,
			insetPadding : 50,
			shadow : true,
			hidden : true,
			legend : {
				position : 'right',
				visible : Datanium.GlobalData.showLegend
			}
		});
		fields = [];
		xFields = [];
		yFields = [];
		yFieldsTxt = [];
		xFieldsLabel = "";
		var fields_json = null;
		if (Datanium.GlobalData.enableQuery) {
			if (Datanium.GlobalData.queryParam != null) {
				fields_json = Datanium.GlobalData.queryParam;
				if (Datanium.GlobalData.queryResult4Chart != null) {
					this.hidden = false;
				}
			} else {
				fields = [];
			}
		}
		if (fields_json != null) {
			if ("dimensions" in fields_json) {
				for ( var i = 0; i < fields_json.dimensions.length; i++) {
					var f = fields_json.dimensions[i];
					f.field_type = 'xField';
					if (f.display && f.uniqueName == Datanium.GlobalData.queryParam.primaryDimension) {
						fields.push(f.uniqueName);
						xFields.push(f.uniqueName);
						if (xFieldsLabel.length > 0) {
							xFieldsLabel = xFieldsLabel + "/" + f.uniqueName;
						} else {
							xFieldsLabel = f.uniqueName;
						}
					}
				}
				for ( var i = 0; i < fields_json.measures.length; i++) {
					if (fields_json.isSplit && fields_json.isSplit !== 'false') {
						var splitMeasures = Datanium.util.CommonUtils.getSplitMeasures(fields_json.measures[i],
								fields_json.split.splitValue);
						for ( var j = 0; j < splitMeasures.length; j++) {
							var f = splitMeasures[j];
							f.field_type = 'yField';
							if (f.display) {
								fields.push(f.uniqueName);
								yFields.push(f.uniqueName);
								yFieldsTxt.push(f.text);
							}
						}
					} else {
						var f = fields_json.measures[i];
						f.field_type = 'yField';
						if (f.display) {
							fields.push(f.uniqueName);
							yFields.push(f.uniqueName);
							yFieldsTxt.push(f.text);
						}
					}
				}
			}
		}
		var store = genLineChartStore(chart_store_template, fields);
		this.store = store;
		var yLabel = function() {
			return ''
		};
		if (!Datanium.GlobalData.autoScale) {
			yLabel = function(v) {
				if (v > 1000000000)
					return String(v / 1000000000) + ' B';
				if (v > 1000000)
					return String(v / 1000000) + ' M';
				if (v > 1000)
					return String(v / 1000) + ' K';
				return Ext.util.Format.number(v, '0,0.###');
			};
		}
		this.axes = [ {
			type : 'Numeric',
			position : 'left',
			fields : yFields,
			label : {
				renderer : yLabel
			},
			grid : true
		}, {
			type : 'Category',
			position : 'bottom',
			fields : xFieldsLabel,
			label : {
				rotate : {
					degrees : 330
				}
			}
		} ];
		// console.log(fields);
		// console.log(xFields);
		// console.log(xFieldsLabel);
		this.series = generateSeries4Line(yFields, yFieldsTxt, xFieldsLabel);
		this.callParent();
	}
});


text:
<?php if ( ! defined('DENY_ACCESS')) exit('403: No direct file access allowed');

/**
 * A Bright CMS
 *
 * Open source, lightweight, web application framework and content management
 * system in PHP.
 *
 * @package A Bright CMS
 * @author Gabriel Liwerant
 */

/**
 * MyException Class
 *
 * @subpackage core
 * @author Gabriel Liwerant
 *
 * @uses Exception
 */
class MyException extends Exception
{
	/**
	 * Holds an instance of the log class for error logging
	 *
	 * @var object $_logger
	 */
	private $_logger;

	/**
	 * Call the parent constructor when we throw a new exception.
	 *
	 * @param object $logger_obj
	 * @param string|void $msg Exception message
	 * @param integer|void $code Reference code for exception
	 * @param object|void $previous Previous exception, if one exists
	 */
	public function __construct($logger_obj, $msg = null, $code = null, $previous = null)
	{
		$this->_setLogger($logger_obj);

		if (PHP_VERSION < 5.3)
		{
			parent::__construct($msg, $code);
		}
		else
		{
			parent::__construct($msg, $code, $previous);
		}
	}

	/**
	 * Logger Setter
	 *
	 * @param object $logger_obj
	 *
	 * @return object MyException
	 */
	private function _setLogger($logger_obj)
	{
		$this->_logger = $logger_obj;

		return $this;
	}

	/**
	 * Create error logs for exceptions.
	 *
	 * @param object $exception Exception object to use for logging
	 *
	 * @return object MyException
	 */
	public function createLog($exception)
	{
		if ( ! IS_MODE_LOGGING)
		{
			return $this;
		}

		$log_data['message']	= $exception->getMessage();
		$log_data['code']		= $exception->getCode();
		$log_data['file']		= $exception->getFile();
		$log_data['line']		= $exception->getLine();
		$log_data['stack_trace']= "\r\n" . $exception->getTraceAsString();

		$log_message = null;
		foreach ($log_data as $key => $value)
		{
			$log_message .= $key . ' => ' . $value . ', ';
		}

		$log_message = rtrim($log_message, ', ');

		$this->_logger->writeLogToFile($log_message, 'exception', 'exceptionLog');

		return $this;
	}

	/**
	 * Caught exceptions are handled here and logged to a file for reference.
	 */
	public function caughtException()
	{
		$this
			->createLog($this)
			->exception_msg = 'Caught ' . $this->getMessage() . '. Exception code: #' . $this->getCode();

		require_once TEMPLATE_PATH	. '/exception.php';
	}

	/**
	 * Uncaught exceptions are handled here.
	 *
	 * @param object $e Exception object to handle
	 */
	public function uncaughtException($e)
	{
		$this
			->createLog($e)
			->exception_msg = 'Uncaught ' . $e->getMessage() . '. Exception code: #' . $e->getCode();

		require_once TEMPLATE_PATH	. '/exception.php';
	}
}
// End of MyException Class

/* EOF system/core/MyException.php */


text:
import * as React from 'react';
import { IconBaseProps } from 'react-icon-base';
declare class MdLocalCarWash extends React.Component<IconBaseProps> { }
export = MdLocalCarWash;


text:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable

using System;
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeRefactorings;
using Microsoft.CodeAnalysis.CSharp.Syntax;

namespace Microsoft.CodeAnalysis.CSharp.MakeLocalFunctionStatic
{
    [ExportCodeRefactoringProvider(LanguageNames.CSharp, Name = nameof(MakeLocalFunctionStaticCodeRefactoringProvider)), Shared]
    internal sealed class MakeLocalFunctionStaticCodeRefactoringProvider : CodeRefactoringProvider
    {
        public override async Task ComputeRefactoringsAsync(CodeRefactoringContext context)
        {
            var (document, textSpan, cancellationToken) = context;

            var syntaxTree = (await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false))!;
            if (!MakeLocalFunctionStaticHelper.IsStaticLocalFunctionSupported(syntaxTree))
            {
                return;
            }

            var localFunction = await context.TryGetRelevantNodeAsync<LocalFunctionStatementSyntax>().ConfigureAwait(false);
            if (localFunction == null)
            {
                return;
            }

            if (localFunction.Modifiers.Any(SyntaxKind.StaticKeyword))
            {
                return;
            }

            var semanticModel = (await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false))!;

            if (MakeLocalFunctionStaticHelper.TryGetCaputuredSymbolsAndCheckApplicability(localFunction, semanticModel, out var captures))
            {
                context.RegisterRefactoring(new MyCodeAction(
                    FeaturesResources.Make_local_function_static,
                    c => MakeLocalFunctionStaticHelper.MakeLocalFunctionStaticAsync(document, localFunction, captures, c)));
            }
        }

        private class MyCodeAction : CodeAction.DocumentChangeAction
        {
            public MyCodeAction(string title, Func<CancellationToken, Task<Document>> createChangedDocument)
                : base(title, createChangedDocument)
            {
            }
        }
    }
}


text:
// Copyright David Abrahams 2001.
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

# ifndef MAKE_HOLDER_DWA20011215_HPP
#  define MAKE_HOLDER_DWA20011215_HPP

#  include <boost/python/detail/prefix.hpp>

#  include <boost/python/object/instance.hpp>
#  include <boost/python/converter/registry.hpp>
#if !defined( BOOST_PYTHON_NO_PY_SIGNATURES) && defined( BOOST_PYTHON_PY_SYGNATURES_PROPER_INIT_SELF_TYPE)
#  include <boost/python/detail/python_type.hpp>
#endif

#  include <boost/python/object/forward.hpp>
#  include <boost/python/detail/preprocessor.hpp>

#  include <boost/mpl/next.hpp>
#  include <boost/mpl/begin_end.hpp>
#  include <boost/mpl/deref.hpp>

#  include <boost/preprocessor/iterate.hpp>
#  include <boost/preprocessor/iteration/local.hpp>
#  include <boost/preprocessor/repeat.hpp>
#  include <boost/preprocessor/debug/line.hpp>
#  include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>

#  include <cstddef>

namespace boost { namespace python { namespace objects {

template <int nargs> struct make_holder;

#  define BOOST_PYTHON_DO_FORWARD_ARG(z, index, _) , f##index(a##index)

// specializations...
#  define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/object/make_holder.hpp>))
#  include BOOST_PP_ITERATE()

#  undef BOOST_PYTHON_DO_FORWARD_ARG

}}} // namespace boost::python::objects

# endif // MAKE_HOLDER_DWA20011215_HPP

#elif BOOST_PP_ITERATION_DEPTH() == 1
# if !(BOOST_WORKAROUND(__MWERKS__, > 0x3100)                      \
        && BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3201)))
#  line BOOST_PP_LINE(__LINE__, make_holder.hpp)
# endif

# define N BOOST_PP_ITERATION()

template <>
struct make_holder<N>
{
    template <class Holder, class ArgList>
    struct apply
    {
# if N
        // Unrolled iteration through each argument type in ArgList,
        // choosing the type that will be forwarded on to the holder's
        // templated constructor.
        typedef typename mpl::begin<ArgList>::type iter0;

#  define BOOST_PP_LOCAL_MACRO(n)               \
    typedef typename mpl::deref<iter##n>::type t##n;        \
    typedef typename forward<t##n>::type f##n;  \
    typedef typename mpl::next<iter##n>::type   \
        BOOST_PP_CAT(iter,BOOST_PP_INC(n)); // Next iterator type

#  define BOOST_PP_LOCAL_LIMITS (0, N-1)
#  include BOOST_PP_LOCAL_ITERATE()
# endif

        static void execute(
#if !defined( BOOST_PYTHON_NO_PY_SIGNATURES) && defined( BOOST_PYTHON_PY_SYGNATURES_PROPER_INIT_SELF_TYPE)
            boost::python::detail::python_class<BOOST_DEDUCED_TYPENAME Holder::value_type> *p
#else
            PyObject *p
#endif
            BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(1, N, t, a))
        {
            typedef instance<Holder> instance_t;

            void* memory = Holder::allocate(p, offsetof(instance_t, storage), sizeof(Holder));
            try {
                (new (memory) Holder(
                    p BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_DO_FORWARD_ARG, nil)))->install(p);
            }
            catch(...) {
                Holder::deallocate(p, memory);
                throw;
            }
        }
    };
};

# undef N

#endif


text:
@interface Movie : NSObject

@property (strong, nonatomic) UIImage *posterImage;
@property (strong, nonatomic) NSString *title;

@end


text:
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'

class ActiveSupport::TestCase
  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  fixtures :all

  def setup_order
    order = Order.new
    order.order_number = 234567
    order.campaign = "Campaña de Prueba"
    order.agency_id = 1
    order.start_date = "2015-01-01"
    order.end_date = "2015-02-01"
    order.site_id = 1

    order
  end

  def setup_creative(order)
    creative = order.creatives.build()
    creative.creative_name = "Algo"

    creative
  end

  def setup_line(creative)
    line = creative.lines.new
    line.line_number = 12321112
    line.format_id = 1
    line.start_date = '2015-01-01'
    line.end_date = '2015-01-01'

    line
  end

  # Add more helper methods to be used by all tests here...
end


text:
package org.apache.hadoop.typedbytes;

import java.io.DataInput;
import java.io.EOFException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;

import org.apache.hadoop.io.WritableUtils;
import org.apache.hadoop.record.Buffer;

/**
 * Provides functionality for reading typed bytes.
 */
public class TypedBytesInput {

  private DataInput in;

  private TypedBytesInput() {}

  private void setDataInput(DataInput in) {
    this.in = in;
  }

  private static ThreadLocal tbIn = new ThreadLocal() {
    protected synchronized Object initialValue() {
      return new TypedBytesInput();
    }
  };

  /**
   * Get a thread-local typed bytes input for the supplied {@link DataInput}.
   * @param in data input object
   * @return typed bytes input corresponding to the supplied {@link DataInput}.
   */
  public static TypedBytesInput get(DataInput in) {
    TypedBytesInput bin = (TypedBytesInput) tbIn.get();
    bin.setDataInput(in);
    return bin;
  }

  /** Creates a new instance of TypedBytesInput. */
  public TypedBytesInput(DataInput in) {
    this.in = in;
  }

  /**
   * Reads a typed bytes sequence and converts it to a Java object. The first
   * byte is interpreted as a type code, and then the right number of
   * subsequent bytes are read depending on the obtained type.
   * @return the obtained object or null when the end of the file is reached
   * @throws IOException
   */
  public Object read() throws IOException {
    int code = 1;
    try {
      code = in.readUnsignedByte();
    } catch (EOFException eof) {
      return null;
    }
    if (code == Type.BYTES.code) {
      return new Buffer(readBytes());
    } else if (code == Type.BYTE.code) {
      return readByte();
    } else if (code == Type.BOOL.code) {
      return readBool();
    } else if (code == Type.INT.code) {
      return readInt();
    } else if (code == Type.LONG.code) {
      return readLong();
    } else if (code == Type.FLOAT.code) {
      return readFloat();
    } else if (code == Type.DOUBLE.code) {
      return readDouble();
    } else if (code == Type.STRING.code) {
      return readString();
    } else if (code == Type.VECTOR.code) {
      return readVector();
    } else if (code == Type.LIST.code) {
      return readList();
    } else if (code == Type.MAP.code) {
      return readMap();
    } else if (code == Type.MARKER.code) {
      return null;
    } else {
      throw new RuntimeException("unknown type");
    }
  }

  /**
   * Reads a typed bytes sequence. The first byte is interpreted as a type code,
   * and then the right number of subsequent bytes are read depending on the
   * obtained type.
   *
   * @return the obtained typed bytes sequence or null when the end of the file
   *         is reached
   * @throws IOException
   */
  public byte[] readRaw() throws IOException {
    int code = -1;
    try {
      code = in.readUnsignedByte();
    } catch (EOFException eof) {
      return null;
    }
    if (code == Type.BYTES.code) {
      return readRawBytes();
    } else if (code == Type.BYTE.code) {
      return readRawByte();
    } else if (code == Type.BOOL.code) {
      return readRawBool();
    } else if (code == Type.INT.code) {
      return readRawInt();
    } else if (code == Type.LONG.code) {
      return readRawLong();
    } else if (code == Type.FLOAT.code) {
      return readRawFloat();
    } else if (code == Type.DOUBLE.code) {
      return readRawDouble();
    } else if (code == Type.STRING.code) {
      return readRawString();
    } else if (code == Type.VECTOR.code) {
      return readRawVector();
    } else if (code == Type.LIST.code) {
      return readRawList();
    } else if (code == Type.MAP.code) {
      return readRawMap();
    } else if (code == Type.MARKER.code) {
      return null;
    } else {
      throw new RuntimeException("unknown type");
    }
  }

  /**
   * Reads a type byte and returns the corresponding {@link Type}.
   * @return the obtained Type or null when the end of the file is reached
   * @throws IOException
   */
  public Type readType() throws IOException {
    int code = -1;
    try {
      code = in.readUnsignedByte();
    } catch (EOFException eof) {
      return null;
    }
    for (Type type : Type.values()) {
      if (type.code == code) {
        return type;
      }
    }
    return null;
  }

  /**
   * Skips a type byte.
   * @return true iff the end of the file was not reached
   * @throws IOException
   */
  public boolean skipType() throws IOException {
    try {
      in.readByte();
      return true;
    } catch (EOFException eof) {
      return false;
    }
  }

  /**
   * Reads the bytes following a Type.BYTES code.
   * @return the obtained bytes sequence
   * @throws IOException
   */
  public byte[] readBytes() throws IOException {
    int length = in.readInt();
    byte[] bytes = new byte[length];
    in.readFully(bytes);
    return bytes;
  }

  /**
   * Reads the raw bytes following a Type.BYTES code.
   * @return the obtained bytes sequence
   * @throws IOException
   */
  public byte[] readRawBytes() throws IOException {
    int length = in.readInt();
    byte[] bytes = new byte[5 + length];
    bytes[0] = (byte) Type.BYTES.code;
    bytes[1] = (byte) (0xff & (length >> 24));
    bytes[2] = (byte) (0xff & (length >> 16));
    bytes[3] = (byte) (0xff & (length >> 8));
    bytes[4] = (byte) (0xff & length);
    in.readFully(bytes, 5, length);
    return bytes;
  }

  /**
   * Reads the byte following a Type.BYTE code.
   * @return the obtained byte
   * @throws IOException
   */
  public byte readByte() throws IOException {
    return in.readByte();
  }

  /**
   * Reads the raw byte following a Type.BYTE code.
   * @return the obtained byte
   * @throws IOException
   */
  public byte[] readRawByte() throws IOException {
    byte[] bytes = new byte[2];
    bytes[0] = (byte) Type.BYTE.code;
    in.readFully(bytes, 1, 1);
    return bytes;
  }

  /**
   * Reads the boolean following a Type.BOOL code.
   * @return the obtained boolean
   * @throws IOException
   */
  public boolean readBool() throws IOException {
    return in.readBoolean();
  }

  /**
   * Reads the raw bytes following a Type.BOOL code.
   * @return the obtained bytes sequence
   * @throws IOException
   */
  public byte[] readRawBool() throws IOException {
    byte[] bytes = new byte[2];
    bytes[0] = (byte) Type.BOOL.code;
    in.readFully(bytes, 1, 1);
    return bytes;
  }

  /**
   * Reads the integer following a Type.INT code.
   * @return the obtained integer
   * @throws IOException
   */
  public int readInt() throws IOException {
    return in.readInt();
  }

  /**
   * Reads the raw bytes following a Type.INT code.
   * @return the obtained bytes sequence
   * @throws IOException
   */
  public byte[] readRawInt() throws IOException {
    byte[] bytes = new byte[5];
    bytes[0] = (byte) Type.INT.code;
    in.readFully(bytes, 1, 4);
    return bytes;
  }

  /**
   * Reads the long following a Type.LONG code.
   * @return the obtained long
   * @throws IOException
   */
  public long readLong() throws IOException {
    return in.readLong();
  }

  /**
   * Reads the raw bytes following a Type.LONG code.
   * @return the obtained bytes sequence
   * @throws IOException
   */
  public byte[] readRawLong() throws IOException {
    byte[] bytes = new byte[9];
    bytes[0] = (byte) Type.LONG.code;
    in.readFully(bytes, 1, 8);
    return bytes;
  }

  /**
   * Reads the float following a Type.FLOAT code.
   * @return the obtained float
   * @throws IOException
   */
  public float readFloat() throws IOException {
    return in.readFloat();
  }

  /**
   * Reads the raw bytes following a Type.FLOAT code.
   * @return the obtained bytes sequence
   * @throws IOException
   */
  public byte[] readRawFloat() throws IOException {
    byte[] bytes = new byte[5];
    bytes[0] = (byte) Type.FLOAT.code;
    in.readFully(bytes, 1, 4);
    return bytes;
  }

  /**
   * Reads the double following a Type.DOUBLE code.
   * @return the obtained double
   * @throws IOException
   */
  public double readDouble() throws IOException {
    return in.readDouble();
  }

  /**
   * Reads the raw bytes following a Type.DOUBLE code.
   * @return the obtained bytes sequence
   * @throws IOException
   */
  public byte[] readRawDouble() throws IOException {
    byte[] bytes = new byte[9];
    bytes[0] = (byte) Type.DOUBLE.code;
    in.readFully(bytes, 1, 8);
    return bytes;
  }

  /**
   * Reads the string following a Type.STRING code.
   * @return the obtained string
   * @throws IOException
   */
  public String readString() throws IOException {
    return WritableUtils.readString(in);
  }

  /**
   * Reads the raw bytes following a Type.STRING code.
   * @return the obtained bytes sequence
   * @throws IOException
   */
  public byte[] readRawString() throws IOException {
    int length = in.readInt();
    byte[] bytes = new byte[5 + length];
    bytes[0] = (byte) Type.STRING.code;
    bytes[1] = (byte) (0xff & (length >> 24));
    bytes[2] = (byte) (0xff & (length >> 16));
    bytes[3] = (byte) (0xff & (length >> 8));
    bytes[4] = (byte) (0xff & length);
    in.readFully(bytes, 5, length);
    return bytes;
  }

  /**
   * Reads the vector following a Type.VECTOR code.
   * @return the obtained vector
   * @throws IOException
   */
  @SuppressWarnings("unchecked")
  public ArrayList readVector() throws IOException {
    int length = readVectorHeader();
    ArrayList result = new ArrayList(length);
    for (int i = 0; i < length; i++) {
      result.add(read());
    }
    return result;
  }

  /**
   * Reads the raw bytes following a Type.VECTOR code.
   * @return the obtained bytes sequence
   * @throws IOException
   */
  public byte[] readRawVector() throws IOException {
    Buffer buffer = new Buffer();
    int length = readVectorHeader();
    buffer.append(new byte[] {
      (byte) Type.VECTOR.code,
      (byte) (0xff & (length >> 24)), (byte) (0xff & (length >> 16)),
      (byte) (0xff & (length >> 8)), (byte) (0xff & length)
    });
    for (int i = 0; i < length; i++) {
      buffer.append(readRaw());
    }
    return buffer.get();
  }

  /**
   * Reads the header following a Type.VECTOR code.
   * @return the number of elements in the vector
   * @throws IOException
   */
  public int readVectorHeader() throws IOException {
    return in.readInt();
  }

  /**
   * Reads the list following a Type.LIST code.
   * @return the obtained list
   * @throws IOException
   */
  @SuppressWarnings("unchecked")
  public List readList() throws IOException {
    List list = new ArrayList();
    Object obj = read();
    while (obj != null) {
      list.add(obj);
      obj = read();
    }
    return list;
  }

  /**
   * Reads the raw bytes following a Type.LIST code.
   * @return the obtained bytes sequence
   * @throws IOException
   */
  public byte[] readRawList() throws IOException {
    Buffer buffer = new Buffer(new byte[] { (byte) Type.LIST.code });
    byte[] bytes = readRaw();
    while (bytes != null) {
      buffer.append(bytes);
      bytes = readRaw();
    }
    buffer.append(new byte[] { (byte) Type.MARKER.code });
    return buffer.get();
  }

  /**
   * Reads the map following a Type.MAP code.
   * @return the obtained map
   * @throws IOException
   */
  @SuppressWarnings("unchecked")
  public TreeMap readMap() throws IOException {
    int length = readMapHeader();
    TreeMap result = new TreeMap();
    for (int i = 0; i < length; i++) {
      Object key = read();
      Object value = read();
      result.put(key, value);
    }
    return result;
  }

  /**
   * Reads the raw bytes following a Type.MAP code.
   * @return the obtained bytes sequence
   * @throws IOException
   */
  public byte[] readRawMap() throws IOException {
    Buffer buffer = new Buffer();
    int length = readMapHeader();
    buffer.append(new byte[] {
      (byte) Type.MAP.code,
      (byte) (0xff & (length >> 24)), (byte) (0xff & (length >> 16)),
      (byte) (0xff & (length >> 8)), (byte) (0xff & length)
    });
    for (int i = 0; i < length; i++) {
      buffer.append(readRaw());
      buffer.append(readRaw());
    }
    return buffer.get();
  }

  /**
   * Reads the header following a Type.MAP code.
   * @return the number of key-value pairs in the map
   * @throws IOException
   */
  public int readMapHeader() throws IOException {
    return in.readInt();
  }

}


text:
Vous devez spécifier ici les valeurs correspondantes &agrave; votre site web.

Vous pouvez utiliser certains codes-raccourcis dans les valeurs choisies.
Les codes-raccourcis sont un mot spécifique encadré par des crochets ex: [DUTEXTE], où DUTEXTE sera remplacé par la valeur
qui a été définie par le concepteur du programme.
Ci-dessous, vous trouverez une liste de quelques codes-raccourcis utiles installés par défaut
que vous pouvez utiliser.

WEBSITE - l'adresse de votre site web.

DOMAIN - votre nom de domaine : le nom de domaine ne comprend jamais les "www".

Soyons précis : (www.votre-domaine.com) est un sous-domaine de "votre-domaine.com" qui est le nom de domaine enregistré.

SUBSCRIBEURL - l'adresse utilisée pour les inscriptions sur votre site.

UNSUBSCRIBEURL - l'adresse utilisée pour les désinscriptions.

PREFERENCESURL - l'adresse de la page permettant aux destinataires de mettre &agrave; jour les renseignements les concernant.

CONFIRMATIONURL - l'adresse de la page où les destinataires doivent confirmer leur inscription.

N'oubliez pas les crochets pour que &ccedil;&agrave; fonctionne.


text:
package handlers

import (
	"mqserver/lib/api"
	"mqserver/lib/httprouter"
	"net/http"
)

func GetAllUsers(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
	api.Respond(w, r, http.StatusOK, p)
}


text:
<?php
include_once( 'class.jetpack-admin-page.php' );

// Builds the landing page and its menu
class Jetpack_Landing_Page extends Jetpack_Admin_Page {
	protected $dont_show_if_not_active = false;

	function get_page_hook() {
		$title = _x( 'Jetpack', 'The menu item label', 'jetpack' );

		list( $jetpack_version ) = explode( ':', Jetpack_Options::get_option( 'version' ) );
		if (
			$jetpack_version
		&&
			$jetpack_version != JETPACK__VERSION
		&&
			( $new_modules = Jetpack::get_default_modules( $jetpack_version, JETPACK__VERSION ) )
		&&
			is_array( $new_modules )
		&&
			( $new_modules_count = count( $new_modules ) )
		&&
			( Jetpack::is_active() || Jetpack::is_development_mode() )
		) {
			$new_count_i18n = number_format_i18n( $new_modules_count );
			$span_title     = esc_attr( sprintf( _n( 'One New Jetpack Module', '%s New Jetpack Modules', $new_modules_count, 'jetpack' ), $new_count_i18n ) );
			$format         = _x( 'Jetpack %s', 'The menu item label with a new module count as %s', 'jetpack' );
			$update_markup  = "$new_count_i18n";
			$title          = sprintf( $format, $update_markup );
		}

		// Add the main admin Jetpack menu with possible information about new
		// modules
		add_menu_page( 'Jetpack', $title, 'jetpack_admin_page', 'jetpack', array( $this, 'render' ), 'div' );
		// also create the submenu
		return add_submenu_page( 'jetpack', $title, $title, 'jetpack_admin_page', 'jetpack' );
	}

	function add_page_actions( $hook ) {
		// Add landing page specific underscore templates
		add_action( "admin_footer-$hook",        array( $this, 'js_templates' ) );
		/** This action is documented in class.jetpack.php */
		do_action( 'jetpack_admin_menu', $hook );

		// Place the Jetpack menu item on top and others in the order they
		// appear
		add_filter( 'custom_menu_order',         '__return_true' );
		add_filter( 'menu_order',                array( $this, 'jetpack_menu_order' ) );

		add_action( 'jetpack_notices_update_settings', array( $this, 'show_notices_update_settings' ), 10, 1 );
	}

	/*
	 * Build an array of a specific module tag.
	 *
	 * @param  string Name of the module tag
	 * @return array  The module slug, config url, and name of each Jump Start module
	 */
	function jumpstart_module_tag( $tag ) {
		$modules = Jetpack_Admin::init()->get_modules();

		$module_info = array();
		foreach ( $modules as $module => $value ) {
			if ( in_array( $tag, $value['feature'] ) ) {
				$module_info[] = array(
					'module_slug'   => $value['module'],
					'module_name'   => $value['name'],
					'configure_url' => $value['configure_url'],
				);
			}
		}
		return $module_info;
	}

	/*
	 * Only show Jump Start on first activation.
	 * Any option 'jumpstart' other than 'new connection' will hide it.
	 *
	 * The option can be of 4 things, and will be stored as such:
	 * new_connection      : Brand new connection - Show
	 * jumpstart_activated : Jump Start has been activated - dismiss
	 * jetpack_action_taken: Manual activation of a module already happened - dismiss
	 * jumpstart_dismissed : Manual dismissal of Jump Start - dismiss
	 *
	 * @return bool | show or hide
	 */
	function jetpack_show_jumpstart() {
		$jumpstart_option = Jetpack_Options::get_option( 'jumpstart' );

		$hide_options = array(
			'jumpstart_activated',
			'jetpack_action_taken',
			'jumpstart_dismissed'
		);

		if ( ! $jumpstart_option || in_array( $jumpstart_option, $hide_options ) ) {
			return false;
		}

		return true;
	}

	/*
	 * List of recommended modules for the Jump Start paragraph text.
	 * Will only show up in the paragraph if they are not active.
	 *
	 * @return string | comma-separated recommended modules that are not active
	 */
	function jumpstart_list_modules() {
		$jumpstart_recommended = $this->jumpstart_module_tag( 'Jumpstart' );

		$module_name = array();
		foreach ( $jumpstart_recommended as $module => $val ) {
			if ( ! Jetpack::is_module_active( $val['module_slug'] ) ) {
				$module_name[] = $val['module_name'];
			}
		}
		$jumpstart_module_list = implode( $module_name, ', ' );

		return $jumpstart_module_list;
	}

	function jetpack_menu_order( $menu_order ) {
		$jp_menu_order = array();

		foreach ( $menu_order as $index => $item ) {
			if ( $item != 'jetpack' )
				$jp_menu_order[] = $item;

			if ( $index == 0 )
				$jp_menu_order[] = 'jetpack';
		}

		return $jp_menu_order;
	}

	function js_templates() {
		Jetpack::init()->load_view( 'admin/landing-page-templates.php' );
	}

	function page_render() {
		// Handle redirects to configuration pages
		if ( ! empty( $_GET['configure'] ) ) {
			return $this->render_nojs_configurable();
		}

		global $current_user;

		$is_connected      = Jetpack::is_active();
		$user_token        = Jetpack_Data::get_access_token( $current_user->ID );
		$is_user_connected = $user_token && ! is_wp_error( $user_token );
		$is_master_user    = $current_user->ID == Jetpack_Options::get_option( 'master_user' );

		if ( Jetpack::is_development_mode() ) {
			$is_connected      = true;
			$is_user_connected = true;
			$is_master_user    = false;
		}

		// Set template data for the admin page template
		$data = array(
			'is_connected'      => $is_connected,
			'is_user_connected' => $is_user_connected,
			'is_master_user'    => $is_master_user,
			'show_jumpstart'    => $this->jetpack_show_jumpstart(),
			'jumpstart_list'    => $this->jumpstart_list_modules(),
			'recommended_list'  => $this->jumpstart_module_tag( 'Recommended' ),
		);
		Jetpack::init()->load_view( 'admin/admin-page.php', $data );
	}

	/**
	 * Shows a notice message to users after they save Module config settings
	 * @param  string $module_id
	 * @return null
	 */
	function show_notices_update_settings( $module_id ) {
		$state = Jetpack::state( 'message' );

		switch( $state ) {
			case 'module_activated' :
				if ( $module = Jetpack::get_module( Jetpack::state( 'module' ) ) ) {
					$message = sprintf( __( '%s Activated! You can change the setting of it here.', 'jetpack' ), $module['name'] );
				}
				break;
			case 'module_configured':
				$message = __( 'Module settings were saved. ', 'jetpack' );
				break;
			case 'no_message' :
				break;
		}

		if ( isset( $message ) ) {
			?>

<?php echo wp_kses( $message, array( 'strong' => array(), 'a' => array( 'href' => true ), 'br' => true ) ); ?>

					<?php
					/**
					 * Fires within the displayed message when a feature configuation is updated.
					 *
					 * This is a dynamic hook with `$module_id` being the slug of the module being updated.
					 *
					 * @since 3.4.0
					 */
					do_action( 'jetpack_notices_update_settings_' . $module_id ); ?>

			<?php
		}
		add_action( 'jetpack_notices', array( Jetpack::init(), 'admin_notices' ) );
	}

	// Render the configuration page for the module if it exists and an error
	// screen if the module is not configurable
	function render_nojs_configurable() {
		echo '

';
		echo '
';

		$module_name = preg_replace( '/[^\da-z\-]+/', '', $_GET['configure'] );
		if ( Jetpack::is_module( $module_name ) && current_user_can( 'jetpack_configure_modules' ) ) {
			Jetpack::admin_screen_configure_module( $module_name );
		} else {
			echo '
' . esc_html__( 'Error, bad module.', 'jetpack' ) . '
';
		}

		echo '
';
	}

	/*
     * Build an array of Jump Start stats urls.
     * requires the build URL args passed as an array
     *
	 * @param array $jumpstart_stats
     * @return (array) of built stats urls
     */
	function build_jumpstart_stats_urls( $jumpstart_stats ) {
		$jumpstart_urls = array();

		foreach ( $jumpstart_stats as $value) {
			$jumpstart_urls[$value] = Jetpack::build_stats_url( array( 'x_jetpack-jumpstart' => $value ) );
		}

		return $jumpstart_urls;

	}

	function page_admin_scripts() {
		// Enqueue jp.js and localize it
		wp_enqueue_script( 'jetpack-js', plugins_url( '_inc/jp.js', JETPACK__PLUGIN_FILE ),
			array( 'jquery', 'wp-util' ), JETPACK__VERSION . '-20121111' );
		wp_localize_script(
			'jetpack-js',
			'jetpackL10n',
			array(
				'ays_disconnect'    => __( "This will deactivate all Jetpack modules.\nAre you sure you want to disconnect?", 'jetpack' ),
				'ays_unlink'        => __( "This will prevent user-specific modules such as Publicize, Notifications and Post By Email from working.\nAre you sure you want to unlink?", 'jetpack' ),
				'ays_dismiss'       => __( "This will deactivate Jetpack.\nAre you sure you want to deactivate Jetpack?", 'jetpack' ),
				'view_all_features' => __( 'View all Jetpack features', 'jetpack' ),
				'no_modules_found'  => sprintf( __( 'Sorry, no modules were found for the search term "%s"', 'jetpack' ), '{term}' ),
				'modules'           => array_values( Jetpack_Admin::init()->get_modules() ),
				'currentVersion'    => JETPACK__VERSION,
				'ajaxurl'           => admin_url( 'admin-ajax.php' ),
				'jumpstart_modules' => $this->jumpstart_module_tag( 'Jumpstart' ),
				'show_jumpstart'    => $this->jetpack_show_jumpstart(),
				'activate_nonce'    => wp_create_nonce( 'jetpack-jumpstart-nonce' ),
				'jumpstart_stats_urls'  => $this->build_jumpstart_stats_urls( array( 'dismiss', 'jumpstarted', 'learnmore', 'viewed', 'manual' ) ),
				'site_url_manage'   => Jetpack::build_raw_urls( get_site_url() ),
			)
		);
	}
}