text:
#ifndef THRIFT_TRANSPORT_THEADER_H_
#define THRIFT_TRANSPORT_THEADER_H_ 1

#include <functional>

#include <thrift/lib/cpp/protocol/TBinaryProtocol.h>
#include <thrift/lib/cpp/protocol/TCompactProtocol.h>
#include <thrift/lib/cpp/protocol/TProtocolTypes.h>
#include <thrift/lib/cpp/concurrency/Thread.h>
#include <thrift/lib/cpp/util/THttpParser.h>

#include <folly/io/IOBuf.h>
#include <folly/io/IOBufQueue.h>

#include <bitset>
#include "boost/scoped_array.hpp"  // nolint
#include <pwd.h>
#include <unistd.h>
#include <chrono>

// Don't include the unknown client.
#define CLIENT_TYPES_LEN 7

// These are local to this build and never appear on the wire.
enum CLIENT_TYPE {
  THRIFT_HEADER_CLIENT_TYPE = 0,
  THRIFT_FRAMED_DEPRECATED = 1,
  THRIFT_UNFRAMED_DEPRECATED = 2,
  THRIFT_HTTP_SERVER_TYPE = 3,
  THRIFT_HTTP_CLIENT_TYPE = 4,
  THRIFT_FRAMED_COMPACT = 5,
  THRIFT_HEADER_SASL_CLIENT_TYPE = 6,
  THRIFT_HTTP_GET_CLIENT_TYPE = 7,
  THRIFT_UNKNOWN_CLIENT_TYPE = 8,
};

// These appear on the wire.
enum HEADER_FLAGS {
  HEADER_FLAG_SUPPORT_OUT_OF_ORDER = 0x01,
  // Set for reverse messages (server->client requests, client->server replies)
  HEADER_FLAG_DUPLEX_REVERSE = 0x08,
};

enum THRIFT_SECURITY_POLICY {
  THRIFT_SECURITY_DISABLED = 1,
  THRIFT_SECURITY_PERMITTED = 2,
  THRIFT_SECURITY_REQUIRED = 3,
};

namespace apache { namespace thrift { namespace transport {

using apache::thrift::protocol::T_COMPACT_PROTOCOL;

/**
 * Class that will take an IOBuf and wrap it in some thrift headers.
 * see thrift/doc/HeaderFormat.txt for details.
 *
 * Supports transforms: zlib snappy hmac qlz
 * Supports headers: http-style key/value per request and per connection
 * other: Protocol Id and seq ID in header.
 *
 * Backwards compatible with TFramed format, and unframed format, assuming
 * your server transport is compatible (some server types require 4-byte size
 * at the start, such as TNonblockingServer).
 */
class THeader {
 public:

  virtual ~THeader() {}

  explicit THeader()
    : queue_(new folly::IOBufQueue)
    , protoId_(T_COMPACT_PROTOCOL)
    , protoVersion(-1)
    , clientType(THRIFT_UNKNOWN_CLIENT_TYPE)
    , prevClientType(THRIFT_HEADER_CLIENT_TYPE)
    , seqId(0)
    , flags_(0)
    , identity(s_identity)
    , minCompressBytes_(0)
  {
    setSupportedClients(nullptr);
  }

  explicit THeader(std::bitset<CLIENT_TYPES_LEN> const* clientTypes)
    : queue_(new folly::IOBufQueue)
    , protoId_(T_COMPACT_PROTOCOL)
    , protoVersion(-1)
    , clientType(THRIFT_UNKNOWN_CLIENT_TYPE)
    , prevClientType(THRIFT_HEADER_CLIENT_TYPE)
    , seqId(0)
    , flags_(0)
    , identity(s_identity)
    , minCompressBytes_(0)
  {
    setSupportedClients(clientTypes);
  }

  // If clients is nullptr, a security policy of THRIFT_SECURITY_DISABLED
  // will be used.
  void setSupportedClients(std::bitset<CLIENT_TYPES_LEN> const* clients);
  void setSecurityPolicy(THRIFT_SECURITY_POLICY policy);
  THRIFT_SECURITY_POLICY getSecurityPolicy() {
    return securityPolicy_;
  }

  void setClientType(CLIENT_TYPE ct);

  CLIENT_TYPE getClientType() {
    return clientType;
  }

  bool isSupportedClient();
  void checkSupportedClient();

  uint16_t getProtocolId() const;
  void setProtocolId(uint16_t protoId) { this->protoId_ = protoId; }

  int8_t getProtocolVersion() const;

  void setProtocolVersion(uint8_t ver) { this->protoVersion = ver; }

  virtual void resetProtocol();

  uint16_t getFlags() const { return flags_; }
  void setFlags(uint16_t flags) {
    flags_ = flags;
  }

  /**
   * We know we got a packet in header format here, try to parse the header
   *
   * @param IObuf of the header + data.  Untransforms the data as appropriate.
   * @return Just the data section in an IOBuf
   */
  std::unique_ptr<folly::IOBuf> readHeaderFormat(std::unique_ptr<folly::IOBuf>);

  /**
   * Untransform the data based on the received header flags
   * On conclusion of function, setReadBuffer is called with the
   * untransformed data.
   *
   * @param IOBuf input data section
   * @return IOBuf output data section
   */
  static std::unique_ptr<folly::IOBuf> untransform(
    std::unique_ptr<folly::IOBuf>,
    std::vector<uint16_t>& readTrans);

  /**
   * Transform the data based on our write transform flags
   * At conclusion of function the write buffer is set to the
   * transformed data.
   *
   * @param IOBuf to transform.  Returns transformed IOBuf (or chain)
   * @return transformed data IOBuf
   */
  static std::unique_ptr<folly::IOBuf> transform(
    std::unique_ptr<folly::IOBuf>,
    std::vector<uint16_t>& writeTrans,
    uint32_t minCompressBytes);

  uint16_t getNumTransforms(std::vector<uint16_t>& transforms) const {
    int trans = transforms.size();
    if (macCallback_) {
      trans += 1;
    }
    return trans;
  }

  void setTransform(uint16_t transId) {
    for (auto& trans : writeTrans_) {
      if (trans == transId) {
        return;
      }
    }
    writeTrans_.push_back(transId);
  }

  void setTransforms(const std::vector<uint16_t>& trans) {
    writeTrans_ = trans;
  }
  const std::vector<uint16_t>& getTransforms() const { return readTrans_; }
  const std::vector<uint16_t>& getWriteTransforms() const {
    return writeTrans_; }

  // Info headers
  typedef std::map<std::string, std::string> StringToStringMap;

  // these work with write headers
  void setHeader(const std::string& key, const std::string& value);
  void setHeaders(StringToStringMap&&);
  void setPersistentHeader(const std::string& key, const std::string& value);
  void clearHeaders();
  /**
   * this function only clears the local persistent
   * header. does not affect the persistent header
   * that already set
   */
  void clearPersistentHeaders();

  StringToStringMap& getWriteHeaders() {
    return writeHeaders_;
  }

  StringToStringMap& getPersistentWriteHeaders() {
    return persisWriteHeaders_;
  }

  // these work with read headers
  const StringToStringMap& getHeaders() const {
    return readHeaders_;
  }

  StringToStringMap releaseHeaders() {
    StringToStringMap headers;
    readHeaders_.swap(headers);
    return headers;
  }

  StringToStringMap&& releaseWriteHeaders() {
    return std::move(writeHeaders_);
  }

  std::string getPeerIdentity();
  void setIdentity(const std::string& identity);

  // accessors for seqId
  int32_t getSequenceNumber() const { return seqId; }
  void setSequenceNumber(int32_t sid) { this->seqId = sid; }

  enum TRANSFORMS {
    NONE = 0x0,
    ZLIB_TRANSFORM = 0x01,
    HMAC_TRANSFORM = 0x02,
    SNAPPY_TRANSFORM = 0x03,
    QLZ_TRANSFORM = 0x04,
  };

  /**
   * Callbacks to get and verify a mac transform.

   * If a mac callback is provided, it will be called with the outgoing packet,
   * with the returned string appended at the end of the data.
   *
   * If a verify callback is provided, all incoming packets will be called with
   * their mac data and packet data to verify.  If false is returned, an
   * exception is thrown. Packets without any mac also throw an exception if a
   * verify function is provided.
   *
   * If no verify callback is provided, and an incoming packet contains a mac,
   * the mac is ignored.
   *
   **/
  typedef std::function<std::string(const std::string&)> MacCallback;
  typedef std::function<
    bool(const std::string&, const std::string)> VerifyMacCallback;

  void setHmac(MacCallback macCb, VerifyMacCallback verifyCb) {
    macCallback_ = macCb;
    verifyCallback_ = verifyCb;
  }

  /* IOBuf interface */

  /**
   * Adds the header based on the type of transport:
   * unframed - does nothing.
   * framed - prepends frame size
   * header - prepends header, optionally appends mac
   * http - only supported for sync case, prepends http header.
   *
   * @return IOBuf chain with header _and_ data.  Data is not copied
   */
  std::unique_ptr<folly::IOBuf> addHeader(std::unique_ptr<folly::IOBuf>,
                                         bool transform=true);
  /**
   * Given an IOBuf Chain, remove the header.  Supports unframed (sync
   * only), framed, header, and http (sync case only).  This doesn't
   * check if the client type implied by the header is valid.
   * isSupportedClient() or checkSupportedClient() should be called
   * after.
   *
   * @param IOBufQueue - queue to try to read message from.
   *
   * @param needed - if the return is nullptr (i.e. we didn't read a full
   *                 message), needed is set to the number of bytes needed
   *                 before you should call removeHeader again.
   *
   * @return IOBuf - the message chain.  May be shared, may be chained.
   *                 If nullptr, we didn't get enough data for a whole message,
   *                 call removeHeader again after reading needed more bytes.
   */
  std::unique_ptr<folly::IOBuf> removeHeader(folly::IOBufQueue*,
                                             size_t& needed);

  void setMinCompressBytes(uint32_t bytes) {
    minCompressBytes_ = bytes;
  }

  uint32_t getMinCompressBytes() {
    return minCompressBytes_;
  }

  apache::thrift::concurrency::PRIORITY
  getCallPriority();

  void setCallPriority(
      apache::thrift::concurrency::PRIORITY prio);

  std::chrono::milliseconds getClientTimeout() const;

  void setClientTimeout(std::chrono::milliseconds timeout);

  /**
   * Sets the THeader up in HTTP CLIENT mode. host can be an empty string
   */
  void useAsHttpClient(const std::string& host, const std::string& uri);

  // 0 and 16th bits must be 0 to differentiate from framed & unframed
  static const uint32_t HEADER_MAGIC = 0x0FFF0000;
  static const uint32_t HEADER_MASK = 0xFFFF0000;
  static const uint32_t FLAGS_MASK = 0x0000FFFF;
  static const uint32_t HTTP_SERVER_MAGIC = 0x504F5354; // POST
  static const uint32_t HTTP_CLIENT_MAGIC = 0x48545450; // HTTP
  static const uint32_t HTTP_GET_CLIENT_MAGIC = 0x47455420; // GET
  static const uint32_t HTTP_HEAD_CLIENT_MAGIC = 0x48454144; // HEAD

  static const uint32_t MAX_FRAME_SIZE = 0x3FFFFFFF;

 protected:

  void setBestClientType();

  std::bitset<CLIENT_TYPES_LEN> supported_clients;

  std::unique_ptr<folly::IOBufQueue> queue_;

  // Http client parser
  std::unique_ptr<apache::thrift::util::THttpClientParser> httpClientParser_;

  int16_t protoId_;
  int8_t protoVersion;
  CLIENT_TYPE clientType;
  uint16_t prevClientType;
  uint32_t seqId;
  uint16_t flags_;
  std::string identity;
  THRIFT_SECURITY_POLICY securityPolicy_;

  std::vector<uint16_t> readTrans_;
  std::vector<uint16_t> writeTrans_;

  // Map to use for headers
  StringToStringMap readHeaders_;
  StringToStringMap writeHeaders_;

  // Map to use for persistent headers
  StringToStringMap persisReadHeaders_;
  StringToStringMap persisWriteHeaders_;

  static const std::string IDENTITY_HEADER;
  static const std::string ID_VERSION_HEADER;
  static const std::string ID_VERSION;
  static const std::string PRIORITY_HEADER;
  static const std::string CLIENT_TIMEOUT_HEADER;

  static std::string s_identity;

  MacCallback macCallback_;
  VerifyMacCallback verifyCallback_;

  uint32_t minCompressBytes_;

  /**
   * Returns the maximum number of bytes that write k/v headers can take
   */
  size_t getMaxWriteHeadersSize() const;

  /**
   * Returns whether the 1st byte of the protocol payload should be hadled
   * as compact framed.
   */
  bool compactFramed(uint32_t magic);

  struct infoIdType {
    enum idType {
      // start at 1 to avoid confusing header padding for an infoId
      KEYVALUE = 1,
      // for persistent header
      PKEYVALUE = 2,
      END        // signal the end of infoIds we can handle
    };
  };
};

}}} // apache::thrift::transport

#endif // #ifndef THRIFT_TRANSPORT_THEADER_H_


text:
function [w, A, C, sbc, fpe, th]=arfit(v, pmin, pmax, selector, no_const)
%ARFIT	Stepwise least squares estimation of multivariate AR model.
%
%  [w,A,C,SBC,FPE,th]=ARFIT(v,pmin,pmax) produces estimates of the
%  parameters of a multivariate AR model of order p,
%
%      v(k,:)' = w' + A1*v(k-1,:)' +...+ Ap*v(k-p,:)' + noise(C),
%
%  where p lies between pmin and pmax and is chosen as the optimizer
%  of Schwarz's Bayesian Criterion. The input matrix v must contain
%  the time series data, with columns of v representing variables
%  and rows of v representing observations.  ARFIT returns least
%  squares estimates of the intercept vector w, of the coefficient
%  matrices A1,...,Ap (as A=[A1 ... Ap]), and of the noise covariance
%  matrix C.
%
%  As order selection criteria, ARFIT computes approximations to
%  Schwarz's Bayesian Criterion and to the logarithm of Akaike's Final
%  Prediction Error. The order selection criteria for models of order
%  pmin:pmax are returned as the vectors SBC and FPE.
%
%  The matrix th contains information needed for the computation of
%  confidence intervals. ARMODE and ARCONF require th as input
%  arguments.
%
%  If the optional argument SELECTOR is included in the function call,
%  as in ARFIT(v,pmin,pmax,SELECTOR), SELECTOR is used as the order
%  selection criterion in determining the optimum model order. The
%  three letter string SELECTOR must have one of the two values 'sbc'
%  or 'fpe'. (By default, Schwarz's criterion SBC is used.) If the
%  bounds pmin and pmax coincide, the order of the estimated model
%  is p=pmin=pmax.
%
%  If the function call contains the optional argument 'zero' as the
%  fourth or fifth argument, a model of the form
%
%         v(k,:)' = A1*v(k-1,:)' +...+ Ap*v(k-p,:)' + noise(C)
%
%  is fitted to the time series data. That is, the intercept vector w
%  is taken to be zero, which amounts to assuming that the AR(p)
%  process has zero mean.

%  Modified 14-Oct-00
%  Authors: Tapio Schneider
%           tapio@gps.caltech.edu
%
%           Arnold Neumaier
%           neum@cma.univie.ac.at

  % n: number of observations; m: dimension of state vectors
  [n,m]   = size(v);

  if (pmin ~= round(pmin) | pmax ~= round(pmax))
    error('Order must be integer.');
  end
  if (pmax < pmin)
    error('PMAX must be greater than or equal to PMIN.')
  end

  % set defaults and check for optional arguments
  if (nargin == 3)              % no optional arguments => set default values
    mcor       = 1;               % fit intercept vector
    selector   = 'sbc';	          % use SBC as order selection criterion
  elseif (nargin == 4)          % one optional argument
    if strcmp(selector, 'zero')
      mcor     = 0;               % no intercept vector to be fitted
      selector = 'sbc';	          % default order selection
    else
      mcor     = 1; 		  % fit intercept vector
    end
  elseif (nargin == 5)          % two optional arguments
    if strcmp(no_const, 'zero')
      mcor     = 0;               % no intercept vector to be fitted
    else
      error(['Bad argument. Usage: ', ...
	     '[w,A,C,SBC,FPE,th]=AR(v,pmin,pmax,SELECTOR,''zero'')'])
    end
  end

  ne  	= n-pmax;               % number of block equations of size m
  npmax	= m*pmax+mcor;          % maximum number of parameter vectors of length m

  if (ne <= npmax)
    error('Time series too short.')
  end

  % compute QR factorization for model of order pmax
  [R, scale]   = arqr(v, pmax, mcor);

  % compute approximate order selection criteria for models
  % of order pmin:pmax
  [sbc, fpe]   = arord(R, m, mcor, ne, pmin, pmax);

  % get index iopt of order that minimizes the order selection
  % criterion specified by the variable selector
  [val, iopt]  = min(eval(selector));

  % select order of model
  popt         = pmin + iopt-1; % estimated optimum order
  np           = m*popt + mcor; % number of parameter vectors of length m

  % decompose R for the optimal model order popt according to
  %
  %   | R11  R12 |
  % R=|          |
  %   | 0    R22 |
  %
  R11   = R(1:np, 1:np);
  R12   = R(1:np, npmax+1:npmax+m);
  R22   = R(np+1:npmax+m, npmax+1:npmax+m);

  % get augmented parameter matrix Aaug=[w A] if mcor=1 and Aaug=A if mcor=0
  if (np > 0)
    if (mcor == 1)
      % improve condition of R11 by re-scaling first column
      con 	= max(scale(2:npmax+m)) / scale(1);
      R11(:,1)	= R11(:,1)*con;
    end;
    Aaug = (R11\R12)';

    %  return coefficient matrix A and intercept vector w separately
    if (mcor == 1)
      % intercept vector w is first column of Aaug, rest of Aaug is
      % coefficient matrix A
      w = Aaug(:,1)*con;        % undo condition-improving scaling
      A = Aaug(:,2:np);
    else
      % return an intercept vector of zeros
      w = zeros(m,1);
      A = Aaug;
    end
  else
    % no parameters have been estimated
    % => return only covariance matrix estimate and order selection
    % criteria for ``zeroth order model''
    w   = zeros(m,1);
    A   = [];
  end

  % return covariance matrix
  dof   = ne-np;                % number of block degrees of freedom
  C     = R22'*R22./dof;        % bias-corrected estimate of covariance matrix

  % for later computation of confidence intervals return in th:
  % (i)  the inverse of U=R11'*R11, which appears in the asymptotic
  %      covariance matrix of the least squares estimator
  % (ii) the number of degrees of freedom of the residual covariance matrix
  invR11 = inv(R11);
  if (mcor == 1)
    % undo condition improving scaling
    invR11(1, :) = invR11(1, :) * con;
  end
  Uinv   = invR11*invR11';
  th     = [dof zeros(1,size(Uinv,2)-1); Uinv];

redpajama_set_name: RedPajamaGithub


text:
import re

re.compile(r"(?<!a|b)");
re.compile(r"(?<!<error descr="Alternation alternatives needs to have the same length inside lookbehind">a|bc</error>)");
re.compile(r"(?<!a{3}})");
re.compile(r"(?<!a<weak_warning descr="Fixed repetition range">{3,3}</weak_warning>})");
re.compile(r"(?<!a<error descr="Unequal min and max in counted quantifier not allowed inside lookbehind">{3,4}</error>})");


text:
import {Scheduler} from '../Scheduler';
import {Observable} from '../Observable';
import {SubscribeOnObservable} from '../observable/SubscribeOnObservable';

export function subscribeOn<T>(scheduler: Scheduler, delay: number = 0): Observable<T> {
  return new SubscribeOnObservable(this, delay, scheduler);
}


text:
"use strict";

class JSONProvider {

    read(data) {
        let parsedData = data;

        try {
            parsedData = JSON.parse(data);
        } catch (err) {

        }

        return parsedData;
    }

    write(data) {
        return JSON.stringify(data);
    }
}

module.exports = JSONProvider;


text:
<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
    <action name="sales/guest/reorder">

    </action>
    <action name="sales/order/reorder">

    </action>
</config>


text:
``GaussianProcess``
============================================================================

.. autoclass:: ibex.sklearn.gaussian_process.GaussianProcess
    :members:
    :special-members:
    :show-inheritance:


text:
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>

Do you even Register brah?

                <form role="form">

                      Username
                      <input type="email" class="form-control" id="inputusername" placeholder="Enter username">

                      Email
                      <input type="email" class="form-control" id="inputemail" placeholder="Enter email">

                      Password
                      <input type="password" class="form-control" id="inputpassword1" placeholder="Enter password">

                      Confirm Password
                      <input type="password" class="form-control" id="inputpassword2" placeholder="Re-enter password">

                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                        <button type="submit" class="btn btn-primary">Submit</button>

                </form>


text:
using System;

namespace Commons.Messaging
{
    public interface IConfigurator
    {
        IMessageConfig For(Type type);
        IMessageConfig For<T>();
        IMessageConfig For(string topic);
        IMessageConfig For(byte[] bytes);
    }
}


text:
title: TiDB 2.1.12 Release Notes
aliases: ['/docs/dev/releases/release-2.1.12/','/docs/dev/releases/2.1.12/']
---

# TiDB 2.1.12 Release Notes

Release date: June 13, 2019

TiDB version: 2.1.12

TiDB Ansible version: 2.1.12

## TiDB

- Fix the issue caused by unmatched data types when using the index query feedback [#10755](https://github.com/pingcap/tidb/pull/10755)
- Fix the issue that the blob column is changed to the text column caused by charset altering in some cases [#10745](https://github.com/pingcap/tidb/pull/10745)
- Fix the issue that the `GRANT` operation in the transaction mistakenly reports "Duplicate Entry" in some cases [#10739](https://github.com/pingcap/tidb/pull/10739)
- Improve the compatibility with MySQL of the following features
    - The `DAYNAME` function [#10732](https://github.com/pingcap/tidb/pull/10732)
    - The `MONTHNAME` function [#10733](https://github.com/pingcap/tidb/pull/10733)
    - Support the 0 value for the `EXTRACT` function when processing `MONTH` [#10702](https://github.com/pingcap/tidb/pull/10702)
    - The `DECIMAL` type can be converted to `TIMESTAMP` or `DATETIME` [#10734](https://github.com/pingcap/tidb/pull/10734)
- Change the column charset while changing the table charset [#10714](https://github.com/pingcap/tidb/pull/10714)
- Fix the overflow issue when converting a decimal to a float in some cases [#10730](https://github.com/pingcap/tidb/pull/10730)
- Fix the issue that some extremely large messages report the "grpc: received message larger than max" error caused by inconsistent maximum sizes of messages sent/received by gRPC of TiDB and TiKV [#10710](https://github.com/pingcap/tidb/pull/10710)
- Fix the panic issue caused by `ORDER BY` not filtering NULL in some cases [#10488](https://github.com/pingcap/tidb/pull/10488)
- Fix the issue that values returned by the `UUID` function might be duplicate when multiple nodes exist [#10711](https://github.com/pingcap/tidb/pull/10711)
- Change the value returned by `CAST(-num as datetime)` from `error` to NULL [#10703](https://github.com/pingcap/tidb/pull/10703)
- Fix the issue that an unsigned histogram meets signed ranges in some cases [#10695](https://github.com/pingcap/tidb/pull/10695)
- Fix the issue that an error is reported mistakenly for reading data when the statistics feedback meets the bigint unsigned primary key [#10307](https://github.com/pingcap/tidb/pull/10307)
- Fix the issue that the result of `Show Create Table` for partitioned tables is not correctly displayed in some cases [#10690](https://github.com/pingcap/tidb/pull/10690)
- Fix the issue that the calculation result of the `GROUP_CONCAT` aggregate function is not correct for some correlated subqueries [#10670](https://github.com/pingcap/tidb/pull/10670)
- Fix the issue that the result is wrongly displayed when the memory table of slow queries parses the slow query log in some cases [#10776](https://github.com/pingcap/tidb/pull/10776)

## PD

- Fix the issue that etcd leader election is blocked in extreme conditions [#1576](https://github.com/pingcap/pd/pull/1576)

## TiKV

- Fix the issue that Regions are not available during the leader transfer process in extreme conditions [#4799](https://github.com/tikv/tikv/pull/4734)
- Fix the issue that TiKV loses data when the power of the machine fails abnormally, caused by delayed data flush to the disk when receiving snapshots [#4850](https://github.com/tikv/tikv/pull/4850)


text:
<?php
namespace Tonis\Router\Resolver;

use Tonis\Container as LeagueContainer;
use StdClass;

class ContainerTest extends \PHPUnit_Framework_TestCase
{
    public function testResolve()
    {
        $c = new LeagueContainer;
        $r = new Container($c);
        $this->assertSame(false, $r->resolve(false));
        $this->assertInstanceOf(StdClass::class, $r->resolve('StdClass'));
    }
}


text: My configuration files for various games that I played during 1999-2005 under the nick *ZmAsteR*.


text:
'use strict';

describe('Users E2E Tests:', function () {
  var user1 = {
    firstName: 'test',
    lastName: 'user',
    email: 'test.user@meanjs.com',
    username: 'testUser',
    password: 'P@$$w0rd!!'
  };

  var user2 = {
    firstName: 'test',
    lastName: 'user2',
    email: 'test.user2@meanjs.com',
    username: 'testUser2',
    password: 'P@$$w0rd!!'
  };

  var signout = function () {
    // Make sure user is signed out first
    browser.get('http://localhost:3001/authentication/signout');
    // Delete all cookies
    browser.driver.manage().deleteAllCookies();
  };

  describe('Signup Validation', function () {
    it('Should report missing first name', function () {
      browser.get('http://localhost:3001/authentication/signup');
      // Enter Last Name
      element(by.model('credentials.lastName')).sendKeys(user1.lastName);
      // Enter Email
      element(by.model('credentials.email')).sendKeys(user1.email);
      // Enter Username
      element(by.model('credentials.username')).sendKeys(user1.username);
      // Enter Password
      element(by.model('credentials.password')).sendKeys(user1.password);
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // First Name Error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('First name is required.');
    });

    it('Should report missing last name', function () {
      browser.get('http://localhost:3001/authentication/signup');
      // Enter First Name
      element(by.model('credentials.firstName')).sendKeys(user1.firstName);
      // Enter Email
      element(by.model('credentials.email')).sendKeys(user1.email);
      // Enter Username
      element(by.model('credentials.username')).sendKeys(user1.username);
      // Enter Password
      element(by.model('credentials.password')).sendKeys(user1.password);
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Last Name Error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('Last name is required.');
    });

    it('Should report missing email address', function () {
      browser.get('http://localhost:3001/authentication/signup');
      // Enter First Name
      element(by.model('credentials.firstName')).sendKeys(user1.firstName);
      // Enter Last Name
      element(by.model('credentials.lastName')).sendKeys(user1.lastName);
      // Enter Username
      element(by.model('credentials.username')).sendKeys(user1.username);
      // Enter Password
      element(by.model('credentials.password')).sendKeys(user1.password);
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Email address error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('Email address is required.');
    });

    it('Should report invalid email address - "123"', function () {
      browser.get('http://localhost:3001/authentication/signup');
      // Enter First Name
      element(by.model('credentials.firstName')).sendKeys(user1.firstName);
      // Enter Last Name
      element(by.model('credentials.lastName')).sendKeys(user1.lastName);
      // Enter Email
      element(by.model('credentials.email')).sendKeys('123');
      // Enter Username
      element(by.model('credentials.username')).sendKeys(user1.username);
      // Enter Password
      element(by.model('credentials.password')).sendKeys(user1.password);
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Email address error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('Email address is invalid.');
    });

    /**
     * Note: 123@123 is a valid email adress according to HTML5.
     * However, 123@123@123 is an invalid email address.
     */
    it('Should report invalid email address - "123@123@123"', function () {
      browser.get('http://localhost:3001/authentication/signup');
      // Enter First Name
      element(by.model('credentials.firstName')).sendKeys(user1.firstName);
      // Enter Last Name
      element(by.model('credentials.lastName')).sendKeys(user1.lastName);
      // Enter Email
      element(by.model('credentials.email')).sendKeys('123@123@123');
      // Enter Username
      element(by.model('credentials.username')).sendKeys(user1.username);
      // Enter Password
      element(by.model('credentials.password')).sendKeys(user1.password);
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Email address error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('Email address is invalid.');
    });

    it('Should report missing username', function () {
      browser.get('http://localhost:3001/authentication/signup');
      // Enter First Name
      element(by.model('credentials.firstName')).sendKeys(user1.firstName);
      // Enter Last Name
      element(by.model('credentials.lastName')).sendKeys(user1.lastName);
      // Enter Email
      element(by.model('credentials.email')).sendKeys(user1.email);
      // Enter Password
      element(by.model('credentials.password')).sendKeys(user1.password);
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Username Error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('Username is required.');
    });

    it('Should report a password with less than 10 characters long - "P@$$w0rd!"', function () {
      browser.get('http://localhost:3001/authentication/signup');
      // Enter First Name
      element(by.model('credentials.firstName')).sendKeys(user1.firstName);
      // Enter Last Name
      element(by.model('credentials.lastName')).sendKeys(user1.lastName);
      // Enter Email
      element(by.model('credentials.email')).sendKeys(user1.email);
      // Enter Username
      element(by.model('credentials.username')).sendKeys(user1.username);
      // Enter Invalid Password
      element(by.model('credentials.password')).sendKeys('P@$$w0rd!');
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Password Error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('The password must be at least 10 characters long.');
    });

    it('Should report a password with greater than 128 characters long.', function () {
      browser.get('http://localhost:3001/authentication/signup');
      // Enter First Name
      element(by.model('credentials.firstName')).sendKeys(user1.firstName);
      // Enter Last Name
      element(by.model('credentials.lastName')).sendKeys(user1.lastName);
      // Enter Email
      element(by.model('credentials.email')).sendKeys(user1.email);
      // Enter Username
      element(by.model('credentials.username')).sendKeys(user1.username);
      // Enter Invalid Password
      element(by.model('credentials.password')).sendKeys(')!/uLT="lh&:`6X!]|15o!$!TJf,.13l?vG].-j],lFPe/QhwN#{Z<[*1nX@n1^?WW-%_.*D)m$toB+N7z}kcN#B_d(f41h%w@0F!]igtSQ1gl~6sEV&r~}~1ub>If1c+');
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Password Error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('The password must be fewer than 128 characters.');
    });

    it('Should report a password with more than 3 or more repeating characters - "P@$$w0rd!!!"', function () {
      browser.get('http://localhost:3001/authentication/signup');
      // Enter First Name
      element(by.model('credentials.firstName')).sendKeys(user1.firstName);
      // Enter Last Name
      element(by.model('credentials.lastName')).sendKeys(user1.lastName);
      // Enter Email
      element(by.model('credentials.email')).sendKeys(user1.email);
      // Enter Username
      element(by.model('credentials.username')).sendKeys(user1.username);
      // Enter Invalid Password
      element(by.model('credentials.password')).sendKeys('P@$$w0rd!!!');
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Password Error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('The password may not contain sequences of three or more repeated characters.');
    });

    it('Should report a password with no uppercase letters - "p@$$w0rd!!"', function () {
      browser.get('http://localhost:3001/authentication/signup');
      // Enter First Name
      element(by.model('credentials.firstName')).sendKeys(user1.firstName);
      // Enter Last Name
      element(by.model('credentials.lastName')).sendKeys(user1.lastName);
      // Enter Email
      element(by.model('credentials.email')).sendKeys(user1.email);
      // Enter Username
      element(by.model('credentials.username')).sendKeys(user1.username);
      // Enter Invalid Password
      element(by.model('credentials.password')).sendKeys('p@$$w0rd!!');
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Password Error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('The password must contain at least one uppercase letter.');
    });

    it('Should report a password with less than one number - "P@$$word!!"', function () {
      browser.get('http://localhost:3001/authentication/signup');
      // Enter First Name
      element(by.model('credentials.firstName')).sendKeys(user1.firstName);
      // Enter Last Name
      element(by.model('credentials.lastName')).sendKeys(user1.lastName);
      // Enter Email
      element(by.model('credentials.email')).sendKeys(user1.email);
      // Enter Username
      element(by.model('credentials.username')).sendKeys(user1.username);
      // Enter Invalid Password
      element(by.model('credentials.password')).sendKeys('P@$$word!!');
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Password Error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('The password must contain at least one number.');
    });

    it('Should report a password with less than one special character - "Passw0rdss"', function () {
      browser.get('http://localhost:3001/authentication/signup');
      // Enter First Name
      element(by.model('credentials.firstName')).sendKeys(user1.firstName);
      // Enter Last Name
      element(by.model('credentials.lastName')).sendKeys(user1.lastName);
      // Enter Email
      element(by.model('credentials.email')).sendKeys(user1.email);
      // Enter Username
      element(by.model('credentials.username')).sendKeys(user1.username);
      // Enter Invalid Password
      element(by.model('credentials.password')).sendKeys('Passw0rdss');
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Password Error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('The password must contain at least one special character.');
    });

    it('Should Successfully register new user', function () {
      browser.get('http://localhost:3001/authentication/signup');
      // Enter FirstName
      element(by.model('credentials.firstName')).sendKeys(user1.firstName);
      // Enter LastName
      element(by.model('credentials.lastName')).sendKeys(user1.lastName);
      // Enter Email
      element(by.model('credentials.email')).sendKeys(user1.email);
      // Enter UserName
      element(by.model('credentials.username')).sendKeys(user1.username);
      // Enter Password
      element(by.model('credentials.password')).sendKeys(user1.password);
      // Click Submit button
      element(by.css('button[type="submit"]')).click();
      expect(browser.getCurrentUrl()).toEqual('http://localhost:3001/');
    });

    it('Should report Email already exists', function () {
      // Make sure user is signed out first
      signout();
      // Signup
      browser.get('http://localhost:3001/authentication/signup');
      // Enter First Name
      element(by.model('credentials.firstName')).sendKeys(user2.firstName);
      // Enter Last Name
      element(by.model('credentials.lastName')).sendKeys(user2.lastName);
      // Enter Email
      element(by.model('credentials.email')).sendKeys(user1.email);
      // Enter Username
      element(by.model('credentials.username')).sendKeys(user2.username);
      // Enter Invalid Password
      element(by.model('credentials.password')).sendKeys(user2.password);
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Password Error
      expect(element.all(by.css('strong')).get(0).getText()).toBe('Email already exists');
    });

    it('Should report Username already exists', function () {
      // Signup
      browser.get('http://localhost:3001/authentication/signup');
      // Enter First Name
      element(by.model('credentials.firstName')).sendKeys(user2.firstName);
      // Enter Last Name
      element(by.model('credentials.lastName')).sendKeys(user2.lastName);
      // Enter Email
      element(by.model('credentials.email')).sendKeys(user2.email);
      // Enter Username
      element(by.model('credentials.username')).sendKeys(user1.username);
      // Enter Invalid Password
      element(by.model('credentials.password')).sendKeys(user2.password);
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Password Error
      expect(element.all(by.css('strong')).get(0).getText()).toBe('Username already exists');
    });

  });

  describe('Signin Validation', function () {

    it('Should report missing credentials', function () {
      //Make sure user is signed out first
      signout();
      //Sign in
      browser.get('http://localhost:3001/authentication/signin');
      // Click Submit button
      element(by.css('button[type="submit"]')).click();
      // Username Error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('Username is required.');
      // Password Error
      expect(element.all(by.css('.error-text')).get(1).getText()).toBe('Password is required.');
    });

    it('Verify that the user is logged in', function() {
      //Make sure user is signed out first
      signout();
      //Sign in
      browser.get('http://localhost:3001/authentication/signin');
      // Enter UserName
      element(by.model('credentials.username')).sendKeys(user1.username);
      // Enter Password
      element(by.model('credentials.password')).sendKeys(user1.password);
      // Click Submit button
      element(by.css('button[type="submit"]')).click();
      expect(browser.getCurrentUrl()).toEqual('http://localhost:3001/');
    });

  });

  describe ('Change Password Settings Validation', function () {

    it('Should report missing passwords', function () {
      browser.get('http://localhost:3001/settings/password');
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Password Errors
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('Your current password is required.');
      expect(element.all(by.css('.error-text')).get(1).getText()).toBe('Enter a new password.');
      expect(element.all(by.css('.error-text')).get(2).getText()).toBe('Verify your new password.');
    });

    it('Should report a password with less than 10 characters long - "P@$$w0rd!"', function () {
      browser.get('http://localhost:3001/settings/password');
      // Enter Current Password
      element(by.model('passwordDetails.currentPassword')).sendKeys(user1.password);
      // Enter Invalid Password
      element(by.model('passwordDetails.newPassword')).sendKeys('P@$$w0rd!');
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Password Error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('The password must be at least 10 characters long.');
    });

    it('Should report a password with greater than 128 characters long.', function () {
      browser.get('http://localhost:3001/settings/password');
      // Enter Current Password
      element(by.model('passwordDetails.currentPassword')).sendKeys(user1.password);
      // Enter Invalid Password
      element(by.model('passwordDetails.newPassword')).sendKeys(')!/uLT="lh&:`6X!]|15o!$!TJf,.13l?vG].-j],lFPe/QhwN#{Z<[*1nX@n1^?WW-%_.*D)m$toB+N7z}kcN#B_d(f41h%w@0F!]igtSQ1gl~6sEV&r~}~1ub>If1c+');
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Password Error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('The password must be fewer than 128 characters.');
    });

    it('Should report a password with more than 3 or more repeating characters - "P@$$w0rd!!!"', function () {
      browser.get('http://localhost:3001/settings/password');
      // Enter Current Password
      element(by.model('passwordDetails.currentPassword')).sendKeys(user1.password);
      // Enter Invalid Password
      element(by.model('passwordDetails.newPassword')).sendKeys('P@$$w0rd!!!');
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Password Error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('The password may not contain sequences of three or more repeated characters.');
    });

    it('Should report a password with no uppercase letters - "p@$$w0rd!!"', function () {
      browser.get('http://localhost:3001/settings/password');
      // Enter Current Password
      element(by.model('passwordDetails.currentPassword')).sendKeys(user1.password);
      // Enter Invalid Password
      element(by.model('passwordDetails.newPassword')).sendKeys('p@$$w0rd!!');
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Password Error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('The password must contain at least one uppercase letter.');
    });

    it('Should report a password with less than one number - "P@$$word!!"', function () {
      browser.get('http://localhost:3001/settings/password');
      // Enter Current Password
      element(by.model('passwordDetails.currentPassword')).sendKeys(user1.password);
      // Enter Invalid Password
      element(by.model('passwordDetails.newPassword')).sendKeys('P@$$word!!');
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Password Error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('The password must contain at least one number.');
    });

    it('Should report a password with less than one special character - "Passw0rdss"', function () {
      browser.get('http://localhost:3001/settings/password');
      // Enter Current Password
      element(by.model('passwordDetails.currentPassword')).sendKeys(user1.password);
      // Enter Invalid Password
      element(by.model('passwordDetails.newPassword')).sendKeys('Passw0rdss');
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Password Error
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('The password must contain at least one special character.');
    });

    it('Should report passwords do not match', function () {
      browser.get('http://localhost:3001/settings/password');
      // Enter Current Password
      element(by.model('passwordDetails.currentPassword')).sendKeys(user1.password);
      // Enter New Password
      element(by.model('passwordDetails.newPassword')).sendKeys('P@$$w0rds!!');
      // Verify New Password
      element(by.model('passwordDetails.verifyPassword')).sendKeys(user1.password);
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Password Errors
      expect(element.all(by.css('.error-text')).get(0).getText()).toBe('Passwords do not match.');
    });

    it('Should change the password to - "P@$$w0rds!!"', function () {
      browser.get('http://localhost:3001/settings/password');
      // Enter Current Password
      element(by.model('passwordDetails.currentPassword')).sendKeys(user1.password);
      // Enter New Password
      element(by.model('passwordDetails.newPassword')).sendKeys('P@$$w0rds!!');
      // Verify New Password
      element(by.model('passwordDetails.verifyPassword')).sendKeys('P@$$w0rds!!');
      // Click Submit button
      element(by.css('button[type=submit]')).click();
      // Password Changed
      expect(element.all(by.css('.text-success')).get(0).getText()).toBe('Password Changed Successfully');
    });
  });
});


text:
@extends('layouts.dash')

@section('title', 'Tablas usuario | Analytics Website')

@section('css')

@stop

@section('content')

@endsection

@section('js')

@stop


text:
package org.apache.fluo.recipes.data;

import org.apache.fluo.api.data.Bytes;
import org.junit.Assert;
import org.junit.Test;

public class RowHasherTest {

  @Test
  public void testBadPrefixes() {
    String[] badPrefixes =
        {"q:she6:test1", "q:she6:test1", "p:Mhe6:test1", "p;she6:test1", "p:she6;test1",
            "p;she6;test1", "p:+he6:test1", "p:s?e6:test1", "p:sh{6:test1", "p:sh6:"};

    RowHasher rh = new RowHasher("p");
    for (String badPrefix : badPrefixes) {
      try {
        rh.removeHash(Bytes.of(badPrefix));
        Assert.fail();
      } catch (IllegalArgumentException e) {
      }
    }
  }

  @Test
  public void testBasic() {
    RowHasher rh = new RowHasher("p");
    Assert.assertTrue(rh.removeHash(rh.addHash("abc")).toString().equals("abc"));
    rh = new RowHasher("p2");
    Assert.assertTrue(rh.removeHash(rh.addHash("abc")).toString().equals("abc"));

    Assert.assertTrue(rh.addHash("abc").toString().startsWith("p2:"));

    // test to ensure hash is stable over time
    Assert.assertEquals("p2:she6:test1", rh.addHash("test1").toString());
    Assert.assertEquals("p2:hgt0:0123456789abcdefghijklmnopqrstuvwxyz",
        rh.addHash("0123456789abcdefghijklmnopqrstuvwxyz").toString());
    Assert.assertEquals("p2:fluo:86ce3b094982c6a", rh.addHash("86ce3b094982c6a").toString());
  }

  @Test
  public void testBalancerRegex() {
    RowHasher rh = new RowHasher("p");
    String regex = rh.getTableOptimizations(3).getTabletGroupingRegex();
    Assert.assertEquals("(\\Qp:\\E).*", regex);
  }
}


text:
var basicAuth = require('basic-auth');
var ldap      = require('ldapjs');
var util      = require('util');

module.exports = function (req, res, next) {
    function unauthorized(res) {
        res.set('WWW-Authenticate', 'Basic realm=Authorization Required');
        return res.sendStatus(401);
    }

    var user = basicAuth(req);

    if (!user || !user.name || !user.pass) {
        return unauthorized(res);
    }

    var ldap_server = 'ldap://' + process.env.LDAP_HOST
    var ldap_dn = util.format('uid=%s,%s', user.name, process.env.LDAP_BASEDN);

    var client = ldap.createClient({
        url: ldap_server,
        timeout: 5000
    });

    client.bind(ldap_dn, user.pass, function(err){
        if (err) {
            return unauthorized(res);
        }
    });

    client.search(ldap_dn, function(err, response) {
        if (err) {
            console.log(err.message);
            return false;
        }
        response.on('searchEntry', function(entry) {
            req.session.email = entry.object.mail;
            next();
        });
    });
}


text:
package com.yandex.money.test;

import com.yandex.money.test.properties.LocalProperties;

/**
 * @author Slava Yasevich (vyasevich@yamoney.ru)
 */
public interface ApiTest {
    LocalProperties LOCAL_PROPERTIES = new LocalProperties();
    String CLIENT_ID = LOCAL_PROPERTIES.getClientId();
    String ACCESS_TOKEN = LOCAL_PROPERTIES.getAccessToken();
}


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.
// ============================================================
//
// Assembly.cpp
//

//
// Implements the Assembly class
//
// ============================================================
#include "common.h"
#include "clrprivbinderutil.h"
#include "assembly.hpp"
#include "utils.hpp"

namespace BINDER_SPACE
{
    namespace
    {
        BOOL IsPlatformArchitecture(PEKIND kArchitecture)
        {
            return ((kArchitecture != peMSIL) && (kArchitecture != peNone));
        }
    };

    STDMETHODIMP Assembly::QueryInterface(REFIID   riid,
                                          void   **ppv)
    {
        HRESULT hr = S_OK;

        if (ppv == NULL)
        {
            hr = E_POINTER;
        }
        else
        {
            if (IsEqualIID(riid, IID_IUnknown))
            {
                AddRef();
                *ppv = static_cast<IUnknown *>(this);
            }
            else
            {
                *ppv = NULL;
                hr = E_NOINTERFACE;
            }
        }

        return hr;
    }

    STDMETHODIMP_(ULONG) Assembly::AddRef()
    {
        return InterlockedIncrement(&m_cRef);
    }

    STDMETHODIMP_(ULONG) Assembly::Release()
    {
        ULONG ulRef = InterlockedDecrement(&m_cRef);

        if (ulRef == 0)
        {
            delete this;
        }

        return ulRef;
    }

    Assembly::Assembly()
    {
        m_cRef = 1;
        m_pPEImage = NULL;
        m_pNativePEImage = NULL;
        m_pAssemblyName = NULL;
        m_pMDImport = NULL;
        m_dwAssemblyFlags = FLAG_NONE;
        m_pBinder = NULL;
    }

    Assembly::~Assembly()
    {
        BINDER_LOG_ASSEMBLY_NAME(L"destructing assembly", m_pAssemblyName);

        if (m_pPEImage != NULL)
        {
            BinderReleasePEImage(m_pPEImage);
            m_pPEImage = NULL;
        }

#ifdef  FEATURE_PREJIT
        if (m_pNativePEImage != NULL)
        {
            BinderReleasePEImage(m_pNativePEImage);
            m_pNativePEImage = NULL;
        }
#endif

        SAFE_RELEASE(m_pAssemblyName);
        SAFE_RELEASE(m_pMDImport);
    }

    HRESULT Assembly::Init(IMDInternalImport       *pIMetaDataAssemblyImport,
                           PEKIND                   PeKind,
                           PEImage                 *pPEImage,
                           PEImage                 *pNativePEImage,
                           SString                 &assemblyPath,
                           BOOL                     fIsInGAC)
    {
        HRESULT hr = S_OK;
        BINDER_LOG_ENTER(L"Assembly::Init");

        ReleaseHolder<AssemblyName> pAssemblyName;
        SAFE_NEW(pAssemblyName, AssemblyName);

        // Get assembly name def from meta data import and store it for later refs access
        IF_FAIL_GO(pAssemblyName->Init(pIMetaDataAssemblyImport, PeKind));
        SetMDImport(pIMetaDataAssemblyImport);
        if (!fIsInGAC)
        {
            GetPath().Set(assemblyPath);
        }

        BINDER_LOG_ASSEMBLY_NAME(L"AssemblyNameDef", pAssemblyName);
        BINDER_LOG_STRING(L"System Architecture",
                          AssemblyName::ArchitectureToString(GetSystemArchitecture()));

        // Safe architecture for validation
        PEKIND kAssemblyArchitecture;
        kAssemblyArchitecture = pAssemblyName->GetArchitecture();
        SetIsInGAC(fIsInGAC);
        SetPEImage(pPEImage);
        SetNativePEImage(pNativePEImage);
        pAssemblyName->SetIsDefinition(TRUE);

        // Now take ownership of assembly names
        SetAssemblyName(pAssemblyName.Extract(), FALSE /* fAddRef */);

        // Finally validate architecture
        if (!IsValidArchitecture(kAssemblyArchitecture))
        {
            // Assembly image can't be executed on this platform
            IF_FAIL_GO(HRESULT_FROM_WIN32(ERROR_BAD_FORMAT));
        }

    Exit:
        BINDER_LOG_LEAVE_HR(L"Assembly::Init", hr);
        return hr;
    }

    HRESULT Assembly::GetMVID(GUID *pMVID)
    {
        // Zero init the GUID incase we fail
        ZeroMemory(pMVID, sizeof(GUID));

        return m_pMDImport->GetScopeProps(NULL, pMVID);
    }

    /* static */
    PEKIND Assembly::GetSystemArchitecture()
    {
#if defined(_TARGET_X86_)
        return peI386;
#elif defined(_TARGET_AMD64_)
        return peAMD64;
#elif defined(_TARGET_ARM_)
        return peARM;
#elif defined(_TARGET_ARM64_)
        return peARM64;
#else
        PORTABILITY_ASSERT("Assembly::GetSystemArchitecture");
#endif
    }

    /* static */
    BOOL Assembly::IsValidArchitecture(PEKIND kArchitecture)
    {
        if (!IsPlatformArchitecture(kArchitecture))
            return TRUE;

        return (kArchitecture == GetSystemArchitecture());
    }

    // --------------------------------------------------------------------
    // ICLRPrivAssembly methods
    // --------------------------------------------------------------------
    LPCWSTR Assembly::GetSimpleName()
    {
        AssemblyName *pAsmName = GetAssemblyName();
        return (pAsmName == nullptr ? nullptr : (LPCWSTR)pAsmName->GetSimpleName());
    }

    HRESULT Assembly::BindAssemblyByName(IAssemblyName * pIAssemblyName, ICLRPrivAssembly ** ppAssembly)
    {
        return (m_pBinder == NULL) ? E_FAIL : m_pBinder->BindAssemblyByName(pIAssemblyName, ppAssembly);
    }

    HRESULT Assembly::GetBinderID(UINT_PTR *pBinderId)
    {
        return (m_pBinder == NULL) ? E_FAIL : m_pBinder->GetBinderID(pBinderId);
    }

    HRESULT Assembly::GetLoaderAllocator(LPVOID* pLoaderAllocator)
    {
        return (m_pBinder == NULL) ? E_FAIL : m_pBinder->GetLoaderAllocator(pLoaderAllocator);
    }

    HRESULT Assembly::IsShareable(
        BOOL * pbIsShareable)
    {
        if(pbIsShareable == nullptr)
            return E_INVALIDARG;

        *pbIsShareable = GetIsSharable();
        return S_OK;
    }

    HRESULT Assembly::GetAvailableImageTypes(
        LPDWORD pdwImageTypes)
    {
        HRESULT hr = E_FAIL;

        if(pdwImageTypes == nullptr)
            return E_INVALIDARG;

        *pdwImageTypes = ASSEMBLY_IMAGE_TYPE_ASSEMBLY;

        return S_OK;
    }

    HRESULT Assembly::GetImageResource(
        DWORD dwImageType,
        DWORD * pdwImageType,
        ICLRPrivResource ** ppIResource)
    {
        HRESULT hr = S_OK;
        if(ppIResource == nullptr)
            return E_INVALIDARG;

        if ((dwImageType & ASSEMBLY_IMAGE_TYPE_ASSEMBLY) == ASSEMBLY_IMAGE_TYPE_ASSEMBLY)
        {
            *ppIResource = clr::SafeAddRef(&m_clrPrivRes);
            if (pdwImageType != nullptr)
                *pdwImageType = ASSEMBLY_IMAGE_TYPE_ASSEMBLY;
        }
        else
        {
            hr = CLR_E_BIND_IMAGE_UNAVAILABLE;
        }

        return hr;
    }

    // get parent pointer from nested type
    #define GetPThis() ((BINDER_SPACE::Assembly*)(((PBYTE)this) - offsetof(BINDER_SPACE::Assembly, m_clrPrivRes)))

    HRESULT Assembly::CLRPrivResourceAssembly::QueryInterface(REFIID riid, void ** ppv)
    {
        HRESULT hr = S_OK;
        VALIDATE_ARG_RET(ppv != NULL);

        if (IsEqualIID(riid, IID_IUnknown))
        {
            AddRef();
            *ppv = this;
        }
		else if (IsEqualIID(riid, __uuidof(ICLRPrivResource)))
		{
			AddRef();
			// upcasting is safe
			*ppv = static_cast<ICLRPrivResource *>(this);
		}
        else if (IsEqualIID(riid, __uuidof(ICLRPrivResourceAssembly)))
        {
            AddRef();
            *ppv = static_cast<ICLRPrivResourceAssembly *>(this);
        }
        else
        {
            *ppv = NULL;
            hr = E_NOINTERFACE;
        }

        return hr;
    }

    ULONG Assembly::CLRPrivResourceAssembly::AddRef()
    {
        return GetPThis()->AddRef();
    }

    ULONG Assembly::CLRPrivResourceAssembly::Release()
    {
        return GetPThis()->Release();
    }

    HRESULT Assembly::CLRPrivResourceAssembly::GetResourceType(IID *pIID)
    {
        VALIDATE_ARG_RET(pIID != nullptr);
        *pIID = __uuidof(ICLRPrivResourceAssembly);
        return S_OK;
    }

    HRESULT Assembly::CLRPrivResourceAssembly::GetAssembly(LPVOID *ppAssembly)
    {
        VALIDATE_ARG_RET(ppAssembly != nullptr);
        AddRef();
        *ppAssembly = GetPThis();
        return S_OK;
    }

}


text:
[![Build Status](https://travis-ci.org/arkraft/jenkins-java.svg?branch=master)](https://travis-ci.org/arkraft/jenkins-java)
[![Coverage Status](https://coveralls.io/repos/github/arkraft/jenkins-java/badge.svg?branch=master)](https://coveralls.io/github/arkraft/jenkins-java?branch=master)
[![license](https://img.shields.io/github/license/arkraft/jenkins-java.svg?maxAge=2592000)]()

## About ##
A java library to access the [Jenkins CI][1] API using [retrofit][2].

## Usage ##
Latest version: [![Maven Central](https://img.shields.io/maven-central/v/de.arkraft/jenkins-java.svg?maxAge=2592000?style=flat)]()
```xml
<dependency>
  <groupId>de.arkraft</groupId>
  <artifactId>jenkins-java</artifactId>
  <version>0.4-SNAPSHOT</version>
</dependency>
```

## License ##
    Copyright 2016 Artur Kraft

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

[1]:[https://jenkins.io/]
[2]:[http://square.github.io/retrofit/]


text:
{% extends "base.html" %}
{% block content %}

  {% if session['logged_in'] %}

You're logged in already!

  {% else %}

      Sign Up

    {% if message %}

      {{message}}

    {% else %}
    {% endif %}

    <form action="/signup" method="POST">
      <input type="username" class="form-control" name="username" placeholder="Username">
      <input type="password" class="form-control" name="password" placeholder="Password">
      <button type="submit" class="btn btn-primary btn-block">Signup</button>
    </form>

  {% endif %}

{% endblock %}


text:
"use strict";

const GameOfRisk = require('./');
const sqlite3 = require('sqlite3').verbose();
const knex = require('knex')({ client: 'sqlite3', useNullAsDefault: true });

const DATABASE_FILE = __dirname + '/winstats.sqlite';
const ITERATIONS = 1000000;
const CREATE_SQL = `
CREATE TABLE IF NOT EXISTS winstats (
    num_offense INTEGER NOT NULL,
    num_defense INTEGER NOT NULL,
    win_offense INTEGER NOT NULL,
    win_defense INTEGER NOT NULL,
    total_armies INTEGER NOT NULL,
    loss_count_offense INTEGER NOT NULL,
    loss_average_offense DOUBLE NOT NULL,
    loss_stdev_offense DOUBLE NOT NULL,
    loss_count_defense INTEGER NOT NULL,
    loss_average_defense DOUBLE NOT NULL,
    loss_stdev_defense DOUBLE NOT NULL,
    PRIMARY KEY (num_offense, num_defense)
)`;

// const INSERT_IGNORE = `
// INSERT INTO winstats (num_offense, num_defense, win_offense, win_defense, total_armies, loss_count_offense, loss_average_offense, loss_stdev_offense) VALUES ()`;

module.exports = generate;

function generate() {
    return new Promise((resolve, reject) => {
        let db = new sqlite3.Database(DATABASE_FILE);

        db.run(CREATE_SQL);
        process.on('exit', () => db.close());

        db.serialize(function(err) {
            if (err) {
                return reject(err);
            }

            GameOfRisk.generateDatabase(15, 15, ITERATIONS)
                .then(function(results) {
                    try {

                        let insert;
                        results = results.map(function(battle) {
                            let summary = battle.summary();
                            let q = knex('winstats').insert({
                                num_offense: summary.numOffense,
                                num_defense: summary.numDefense,
                                win_offense: summary.winOffense,
                                win_defense: summary.winDefense,
                                total_armies: summary.totalArmies,
                                loss_count_offense: summary.lossOffense.count,
                                loss_average_offense: summary.lossOffense.average,
                                loss_stdev_offense: summary.lossOffense.stdev,
                                loss_count_defense: summary.lossDefense.count,
                                loss_average_defense: summary.lossDefense.average,
                                loss_stdev_defense: summary.lossDefense.stdev,
                            }).toSQL();

                            if (!insert) {
                                insert = db.prepare(q.sql.replace(/^insert/i, 'replace'));
                            }

                            insert.run(q.bindings);

                            return q;
                        });
                        insert.finalize();

                    } catch (e) {
                        return reject(e);
                    }

                    resolve();
                });
        });
    });
};

generate();


text:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PrtgAPI.Tests.UnitTests.Support.TestItems;

namespace PrtgAPI.Tests.UnitTests.Support.TestResponses
{
    class SlowPathProbesOnlyScenario : TreeScenario
    {
        protected override IWebResponse GetResponse(string address)
        {
            switch (requestNum)
            {
                case 1:
                    Assert.AreEqual(UnitRequest.Objects("filter_objid=1001"), address);
                    return new ProbeResponse(new ProbeItem(objid: "1001", groupnum: "0", groupnumRaw: "0", devicenum: "0", devicenumRaw: "0"));

                case 2:
                    Assert.AreEqual(UnitRequest.Probes("filter_objid=1001&filter_parentid=0"), address);
                    return new ProbeResponse(new ProbeItem(objid: "1001", groupnum: "0", groupnumRaw: "0", devicenum: "0", devicenumRaw: "0"));

                default:
                    throw UnknownRequest(address);
            }
        }
    }
}


text:
package com.hazelcast.spi.impl.operationservice.impl;

import com.hazelcast.instance.HazelcastThreadGroup;
import com.hazelcast.internal.metrics.MetricsProvider;
import com.hazelcast.internal.metrics.MetricsRegistry;
import com.hazelcast.internal.metrics.Probe;
import com.hazelcast.internal.util.concurrent.MPSCQueue;
import com.hazelcast.logging.ILogger;
import com.hazelcast.nio.Packet;
import com.hazelcast.spi.impl.PacketHandler;
import com.hazelcast.spi.impl.operationexecutor.OperationHostileThread;
import com.hazelcast.spi.properties.HazelcastProperties;
import com.hazelcast.spi.properties.HazelcastProperty;
import com.hazelcast.util.concurrent.BackoffIdleStrategy;
import com.hazelcast.util.concurrent.BusySpinIdleStrategy;
import com.hazelcast.util.concurrent.IdleStrategy;

import java.util.concurrent.BlockingQueue;

import static com.hazelcast.instance.OutOfMemoryErrorDispatcher.inspectOutOfMemoryError;
import static com.hazelcast.internal.metrics.ProbeLevel.MANDATORY;
import static com.hazelcast.nio.Packet.FLAG_OP_RESPONSE;
import static com.hazelcast.util.EmptyStatement.ignore;
import static com.hazelcast.util.Preconditions.checkNotNull;
import static com.hazelcast.util.Preconditions.checkTrue;
import static java.util.concurrent.TimeUnit.MICROSECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;

/**
 * The {@link AsyncInboundResponseHandler} is a PacketHandler that asynchronously process operation-response packets. The
 * actual processing is done by the {@link InboundResponseHandler}.
 *
 * So when a response is received from a remote system, it is put in the responseQueue of the ResponseThread.
 * Then the ResponseThread takes it from this responseQueue and calls the {@link PacketHandler} for the
 * actual processing.
 *
 * The reason that the IO thread doesn't immediately deals with the response is that deserializing the
 * {@link com.hazelcast.spi.impl.operationservice.impl.responses.Response} and let the invocation-future
 * deal with the response can be rather expensive.
 */
public class AsyncInboundResponseHandler implements PacketHandler, MetricsProvider {

    public static final HazelcastProperty IDLE_STRATEGY
            = new HazelcastProperty("hazelcast.operation.responsequeue.idlestrategy", "block");

    private static final long IDLE_MAX_SPINS = 20;
    private static final long IDLE_MAX_YIELDS = 50;
    private static final long IDLE_MIN_PARK_NS = NANOSECONDS.toNanos(1);
    private static final long IDLE_MAX_PARK_NS = MICROSECONDS.toNanos(100);

    final ResponseThread responseThread;
    private final ILogger logger;

    AsyncInboundResponseHandler(HazelcastThreadGroup threadGroup,
                                ILogger logger,
                                PacketHandler responsePacketHandler,
                                HazelcastProperties properties) {
        this.logger = logger;
        this.responseThread = new ResponseThread(threadGroup, responsePacketHandler, properties);
    }

    @Probe(name = "responseQueueSize", level = MANDATORY)
    public int getQueueSize() {
        return responseThread.responseQueue.size();
    }

    @Override
    public void handle(Packet packet) {
        checkNotNull(packet, "packet can't be null");
        checkTrue(packet.getPacketType() == Packet.Type.OPERATION, "Packet type is not OPERATION");
        checkTrue(packet.isFlagRaised(FLAG_OP_RESPONSE), "FLAG_OP_RESPONSE is not set");
        responseThread.responseQueue.add(packet);
    }

    @Override
    public void provideMetrics(MetricsRegistry registry) {
        registry.scanAndRegister(this, "operation");
    }

    public void start() {
        responseThread.start();
    }

    public void shutdown() {
        responseThread.shutdown();
    }

    public static IdleStrategy getIdleStrategy(HazelcastProperties properties, HazelcastProperty property) {
        String idleStrategyString = properties.getString(property);
        if ("block".equals(idleStrategyString)) {
            return null;
        } else if ("backoff".equals(idleStrategyString)) {
            return new BackoffIdleStrategy(IDLE_MAX_SPINS, IDLE_MAX_YIELDS, IDLE_MIN_PARK_NS, IDLE_MAX_PARK_NS);
        } else if ("busyspin".equals(idleStrategyString)) {
            return new BusySpinIdleStrategy();
        } else {
            throw new IllegalStateException("Unrecognized " + property.getName() + " value=" + idleStrategyString);
        }
    }

    /**
     * The ResponseThread needs to implement the OperationHostileThread interface to make sure that the OperationExecutor
     * is not going to schedule any operations on this task due to retry.
     */
    private final class ResponseThread extends Thread implements OperationHostileThread {

        private final BlockingQueue<Packet> responseQueue;
        private final PacketHandler responsePacketHandler;
        private volatile boolean shutdown;

        private ResponseThread(HazelcastThreadGroup threadGroup,
                               PacketHandler responsePacketHandler,
                               HazelcastProperties properties) {
            super(threadGroup.getInternalThreadGroup(), threadGroup.getThreadNamePrefix("response"));
            setContextClassLoader(threadGroup.getClassLoader());
            this.responsePacketHandler = responsePacketHandler;
            this.responseQueue = new MPSCQueue<Packet>(this, getIdleStrategy(properties, IDLE_STRATEGY));
        }

        @Override
        public void run() {
            try {
                doRun();
            } catch (InterruptedException e) {
                ignore(e);
            } catch (Throwable t) {
                inspectOutOfMemoryError(t);
                logger.severe(t);
            }
        }

        private void doRun() throws InterruptedException {
            while (!shutdown) {
                Packet response = responseQueue.take();
                try {
                    responsePacketHandler.handle(response);
                } catch (Throwable e) {
                    inspectOutOfMemoryError(e);
                    logger.severe("Failed to process response: " + response + " on:" + getName(), e);
                }
            }
        }

        private void shutdown() {
            shutdown = true;
            interrupt();
        }
    }
}


text:
TERMS AND CONDITIONS

The intent of the Makeathon is to encourage the free exchange of ideas and problem solving by participants.
    I will take precautions not to disclose my own or third party confidential or proprietary information during the Makeathon process.
    I understand that ideas shared publicly during the process will not be treated as confidential and may be used by participants and sponsors.


text:
require File.dirname(__FILE__) + '/../spec_helper'

describe Content do
  before(:each) do
    @content = Content.new
  end

  it "should not be valid" do
    @content.should_not be_valid
  end

  it "should know about its owner"

  describe "with a title" do
    before(:each) do
      @content.title = "Some Title"
    end
    it do
      @content.should be_valid
    end
  end
end

describe 'The Love letter' do
  fixtures :contents
  before(:each) do
    @love_letter = contents(:love_letter)
  end
  it "should be a Document" do
    @love_letter.should be_an_instance_of(Document)
  end
end


text:
import * as Enums from '../enums/index';
import * as Models from './index';

/**
 * Tax Notice Priority Model
 * @export
 * @interface NoticePriorityModel
 */
 export interface NoticePriorityModel {
    /**
     * @type {number}
     * @memberof NoticePriorityModel
     */
   id: number;
    /**
     * @type {string}
     * @memberof NoticePriorityModel
     */
   description: string;
    /**
     * @type {boolean}
     * @memberof NoticePriorityModel
     */
   activeFlag?: boolean;
    /**
     * @type {number}
     * @memberof NoticePriorityModel
     */
   sortOrder?: number;
 }