text:
module.exports = function(hljs) {
  return {
    keywords:
      'abstract and as assert base begin class default delegate do done ' +
      'downcast downto elif else end exception extern false finally for ' +
      'fun function global if in inherit inline interface internal lazy let ' +
      'match member module mutable namespace new null of open or ' +
      'override private public rec return sig static struct then to ' +
      'true try type upcast use val void when while with yield',
    contains: [

      {
        className: 'string',
        begin: '@"', end: '"',
        contains: [{begin: '""'}]
      },
      {
        className: 'string',
        begin: '"""', end: '"""'
      },
      {
        className: 'comment',
        begin: '//', end: '$', returnBegin: true
      },
      {
        className: 'comment',
        begin: '\\(\\*', end: '\\*\\)'
      },
      {
        className: 'class',
        beginWithKeyword: true, end: '\\(|=|$',
        keywords: 'type',
        contains: [
          {
            className: 'title',
            begin: hljs.UNDERSCORE_IDENT_RE
          }
        ]
      },
      {
        className: 'annotation',
        begin: '\\[<', end: '>\\]'
      },
      hljs.C_LINE_COMMENT_MODE,
      hljs.C_BLOCK_COMMENT_MODE,
      hljs.inherit(hljs.APOS_STRING_MODE, {illegal: null}),
      hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null}),
      hljs.C_NUMBER_MODE
    ]
  }
};


text:
/*
 * ArrayData.h
 *
 *  Created on: Nov 14, 2012
 *      Author: Mitchell Wills
 */

#ifndef ARRAYDATA_H_
#define ARRAYDATA_H_

class ArrayData;

#include "ArrayEntryType.h"
#include "ComplexData.h"
#include "networktables2/NetworkTableEntry.h"

/**
 * Defines the internal representation for an array.
 */
class ArrayData : public ComplexData{
private:
    ArrayEntryType& m_data_type;
    unsigned int m_size;
    EntryValue* data;
public:
    /**
     * Creates a new ArrayData of the given type.
     *
     * @param type The ArrayEntryType representing the type
     * 	information that this ArrayData should satisfy.
     */
    ArrayData(ArrayEntryType& type);

protected:
    /**
     * Gets the value stored at the specified index.
     *
     * @param index The array index to retrieve.
     */
    EntryValue _get(unsigned int index);

    /**
     * Updates the value stored at the specified index.
     *
     * The value currently stored at the given index is deleted.
     *
     * @param index The array index to update.
     * @param value The value to store. This value must have
     * 	the same type as the ArrayEntryType indicates.
     */
    void _set(unsigned int index, EntryValue value);

    /**
     * Appends the given value to the end of this array.
     *
     * @param value The value to store. This value must have
     * 	the same type as the ArrayEntryType indicates.
     */
    void _add(EntryValue value);

public:
    /**
     * Removes and deletes the value stored at the specified index.
     *
     * @param index The index of the value to remove.
     */
    void remove(unsigned int index);

    /**
     * Sets the new size of this array data structure.
     *
     * @param size The new size that this array should assume.
     */
    void setSize(unsigned int size);

    /**
     * Gets the current size of this array data structure.
     *
     * @return The current number of elements that this array may contain.
     */
    unsigned int size();

    friend class ArrayEntryType;
};

#endif /* ARRAYDATA_H_ */

redpajama_set_name: RedPajamaGithub


text:
import React, { Component } from 'react'
import PropTypes from '../utils/proptypes'
import { substitute } from '../utils/strings'
import { Checkbox } from '../Checkbox'
import PureRender from '../mixins/PureRender'

import _tables from '../styles/_tables.scss'

class Tr extends Component {
  render () {
    const { columns, data, checked, onSelect, disableCheck } = this.props

    let disabled
    if (disableCheck) {
      disabled = disableCheck(data)
    }

    let tds = []
    if (onSelect) {
      tds.push(

          <Checkbox isIndicator
            checked={checked}
            readOnly={disabled}
            onChange={onSelect.bind(this, data)} />

      )
    }
    columns.map((h, j) => {
      if (h.hidden) return

      let content = h.content
      if (typeof content === 'string') {
        content = substitute(content, data)
      } else if (typeof content === 'function') {
        content = content(data)
      } else {
        content = data[h.name]
      }
      tds.push({content}	)
    })
    return
{tds}

  }
}

Tr.propTypes = {
  checked: PropTypes.bool,
  columns: PropTypes.array,
  data: PropTypes.object,
  disableCheck: PropTypes.func,
  onSelect: PropTypes.func
}

export default PureRender(true)(Tr)


text:
package transferstore

import (
	"context"
	"crypto/rand"
	"encoding/hex"
	"fmt"
	"io"
	"strings"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/awserr"
	"github.com/aws/aws-sdk-go/aws/corehandlers"
	"github.com/aws/aws-sdk-go/aws/credentials"
	"github.com/aws/aws-sdk-go/aws/endpoints"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/s3"
	"github.com/aws/aws-sdk-go/service/s3/s3iface"
	"github.com/aws/aws-sdk-go/service/s3/s3manager"
	"github.com/aws/aws-sdk-go/service/s3/s3manager/s3manageriface"
	"github.com/pkg/errors"
)

var (
	//ErrObjectNotExists is returned when a object does not exist
	ErrObjectNotExists = errors.New("object does not exist")

	awsErrCodeNotFound  = "ErrCodeNoSuchKey"
	awsErrCodeForbidden = "Forbidden"
)

//S3Store provides an S3 Backed store
type S3Store struct {
	bucket string
	prefix string

	sess *session.Session
	dwn  s3manageriface.DownloaderAPI
	upl  s3manageriface.UploaderAPI
	api  s3iface.S3API
}

//NewS3Store creates an s3 implementation of the object store
func NewS3Store(cfg StoreOptions) (store *S3Store, err error) {
	store = &S3Store{
		bucket: cfg.S3StoreBucket,
		prefix: cfg.S3StorePrefix,
	}

	if store.prefix != "" && !strings.HasSuffix(store.prefix, "/") {
		return nil, errors.Errorf("store prefix must end with a forward slash")
	}

	if cfg.S3StoreAWSRegion == "" {
		cfg.S3StoreAWSRegion = endpoints.UsEast1RegionID //this will make the sdk use the global s3 endpoint
	}

	awscfg := &aws.Config{Region: aws.String(cfg.S3StoreAWSRegion)}
	if cfg.S3StoreAWSRegion != "" { //if we have some credentials, configure the session as such
		awscfg.Credentials = credentials.NewStaticCredentials(
			cfg.S3StoreAccessKey, cfg.S3StoreSecretKey, cfg.S3SessionToken,
		)
	}

	var sess *session.Session
	if sess, err = session.NewSession(awscfg); err != nil {
		return nil, errors.Wrapf(err, "failed to create AWS session")
	}

	s3api := s3.New(sess)
	if cfg.S3StoreAccessKey == "" { //without credentials we'll disable request signing
		s3api.Handlers.Sign.Clear()
		s3api.Handlers.Sign.PushBackNamed(corehandlers.BuildContentLengthHandler)
		//we delibrately don't add actual signing middleware for anonymous access
	} else {
		store.upl = s3manager.NewUploaderWithClient(s3api)
	}

	store.dwn = s3manager.NewDownloaderWithClient(s3api)
	// s3dwn.PartSize = 1024 * 1024 * 1024 * 5 //5Gib @TODO, test if this is necessary

	store.api = s3api

	return store, nil
}

//Head returns metadata for the object
func (store *S3Store) Head(ctx context.Context, k string) (size int64, err error) {
	var out *s3.HeadObjectOutput
	if out, err = store.api.HeadObjectWithContext(ctx, &s3.HeadObjectInput{
		Bucket: aws.String(store.bucket),
		Key:    aws.String(k),
	}); err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			if aerr.Code() == awsErrCodeNotFound || aerr.Code() == awsErrCodeForbidden {
				return 0, ErrObjectNotExists
			}
		}

		return 0, errors.Wrapf(err, "failed to download object")
	}

	size = aws.Int64Value(out.ContentLength)
	return size, nil
}

//Get a object from the store with key 'k' and write it to 'w'
func (store *S3Store) Get(ctx context.Context, k string, w io.WriterAt) (err error) {
	if _, err = store.dwn.DownloadWithContext(ctx, w, &s3.GetObjectInput{
		Bucket: aws.String(store.bucket),
		Key:    aws.String(k),
	}); err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			if aerr.Code() == awsErrCodeNotFound || aerr.Code() == awsErrCodeForbidden {
				return ErrObjectNotExists
			}
		}

		return errors.Wrapf(err, "failed to multi-part download object")
	}

	return nil
}

//Put an object into the store at key 'k' by reading from 'r'
func (store *S3Store) Put(ctx context.Context, k string, r io.ReadSeeker) (err error) {
	if store.upl != nil {
		if _, err := store.upl.UploadWithContext(ctx, &s3manager.UploadInput{
			Body:   r,
			Bucket: aws.String(store.bucket),
			Key:    aws.String(k),
		}); err != nil {
			return errors.Wrap(err, "failed to multi-part upload object")
		}

		return nil
	}

	if _, err := store.api.PutObjectWithContext(ctx, &s3.PutObjectInput{
		Body:   r,
		Bucket: aws.String(store.bucket),
		Key:    aws.String(k),
	}); err != nil {
		return errors.Wrap(err, "failed to upload object")
	}

	return nil
}

//Del will remove an object from the store at key 'k'
func (store *S3Store) Del(ctx context.Context, k string) error {
	if _, err := store.api.DeleteObjectWithContext(ctx, &s3.DeleteObjectInput{
		Bucket: aws.String(store.bucket),
		Key:    aws.String(k),
	}); err != nil {
		if aerr, ok := err.(awserr.Error); ok {
			if aerr.Code() == awsErrCodeNotFound || aerr.Code() == awsErrCodeForbidden {
				return ErrObjectNotExists
			}
		}

		return errors.Wrap(err, "failed to delete object")
	}

	return nil
}

//TempS3Bucket creates a temporary s3 bucket that can be removed again
//by calling clean(). This is mainly usefull for testing purposes throughout
//the codebase of this project. The name will be a randomly generated name
//prefixed with 'nerd-tests-'
func TempS3Bucket() (name string, clean func(), err error) {
	s3api := s3.New(session.Must(session.NewSession()))

	d := make([]byte, 16)
	_, err = rand.Read(d)
	if err != nil {
		return "", nil, errors.Wrap(err, "failed to read random bytes")
	}

	name = fmt.Sprintf("nerd-tests-%s", hex.EncodeToString(d))
	if _, err = s3api.CreateBucket(&s3.CreateBucketInput{
		Bucket: aws.String(name),
	}); err != nil {
		return "", nil, errors.Wrap(err, "failed to create bucket")
	}

	return name, func() {
		_, err = s3api.DeleteBucket(&s3.DeleteBucketInput{
			Bucket: aws.String(name),
		})

		if err != nil {
			panic(err)
		}
	}, nil
}


text:
package chess

import (
	"strings"
)

// A piece with type and color.
type Piece struct {
	pieceType PieceTypes
	color     Colors
}

func NewPiece(pieceType PieceTypes, color Colors) *Piece {
	return &Piece{pieceType, color}
}

// Gets the symbol `P`, `N`, `B`, `R`, `Q` or `K` for white pieces or the
// lower-case variants for the black pieces.
func (p *Piece) String() string {
	if p.color == White {
		return strings.ToUpper(PieceSymbols[p.pieceType])
	}
	return PieceSymbols[p.pieceType]
}

// Creates a piece instance from a piece symbol.
// Returns nil if the symbol is invalid.
func PieceFromSymbol(symbol string) *Piece {
	if strings.ToLower(symbol) == symbol {
		for pieceType, pieceSymbol := range PieceSymbols {
			if pieceSymbol == symbol {
				return NewPiece(PieceTypes(pieceType), Black)
			}
		}
	}
	for pieceType, pieceSymbol := range PieceSymbols {
		if pieceSymbol == strings.ToLower(symbol) {
			return NewPiece(PieceTypes(pieceType), White)
		}
	}

	return nil
}


text:
var Benchmark = require('benchmark');

var suite = new Benchmark.Suite();

var str = "IN";

var reg = /^IN$/i;

suite
.add('use str', function () {
    if (str.toUpperCase() === 'IN') {

    };
})
.add('use reg', function () {
    if(reg.test(str)){

    }
})
// add listeners
.on('cycle', function (event) {
  console.log(String(event.target));
})
.on('complete', function () {
  console.log('Fastest is ' + this.filter('fastest').pluck('name'));
})
.run({ async: true });


text:
require 'spec_helper'

describe "Groups" do
  describe "GET /groups" do
    it "works! (now write some real specs)" do
      # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
      get groups_path
      response.status.should be(302)
    end
  end
end


text:
package net.shmin.core.util;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

public class ExceptionUtils {

    /**
     * 将异常信息的堆栈转换为字符串
     *
     * @param e 异常
     * @return
     */
    public static String exception2String(Throwable e) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PrintStream ps = new PrintStream(baos);
        e.printStackTrace(ps);
        return baos.toString();
    }
}


text:
import React from 'react';
import { Route } from 'react-router';
import Layout from './components/Layout';
import Home from './components/Home';
import Counter from './components/Counter';
import FetchData from './components/FetchData';

export default () => (
  <Layout>
    <Route exact path='/' component={Home} />
    <Route path='/counter' component={Counter} />
    <Route path='/fetch-data/:startDateIndex?' component={FetchData} />
  </Layout>
);


text:
import os

from django import template

register = template.Library()

@register.filter()
def get_file_extension(f):
    """
    Returns a file extension for a given path or filename

    >>> get_file_extension("test.pdf")
    pdf

    >>> get_file_extension("/tmp/test.pdf")
    pdf

    """
    basename, ext = os.path.splitext(str(f))
    return ext.replace('.', '').lower()


text:
from __future__ import absolute_import
from zerver.lib.actions import check_send_message
from zerver.lib.response import json_success
from zerver.decorator import REQ, has_request_variables, api_key_only_webhook_view
from zerver.models import UserProfile, Client
from django.http import HttpRequest, HttpResponse
from typing import Optional

import ujson

@api_key_only_webhook_view('Yo')
@has_request_variables
def api_yo_app_webhook(request, user_profile, client, email=REQ(default=None),
                       username=REQ(default='Yo Bot'), topic=REQ(default=None),
                       user_ip=REQ(default=None)):
    # type: (HttpRequest, UserProfile, Client, Optional[str], str, Optional[str], Optional[str]) -> HttpResponse

    body = ('Yo from %s') % (username,)
    check_send_message(user_profile, client, 'private', [email], topic, body)
    return json_success()


text:
package io.netty.example.http.websocketx.autobahn;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.socket.nio.NioEventLoop;
import io.netty.channel.socket.nio.NioServerSocketChannel;

/**
 * A Web Socket echo server for running the autobahn test
 * suite
 */
public class AutobahnServer {

    private final int port;

    public AutobahnServer(int port) {
        this.port = port;
    }

    public void run() throws Exception {
        ServerBootstrap b = new ServerBootstrap();
        try {
            b.eventLoop(new NioEventLoop(), new NioEventLoop())
             .channel(new NioServerSocketChannel())
             .localAddress(port)
             .childInitializer(new AutobahnServerInitializer());

            ChannelFuture f = b.bind().sync();
            System.out.println("Web Socket Server started at port " + port);
            f.channel().closeFuture().sync();

        } finally {
            b.shutdown();
        }
    }

    public static void main(String[] args) throws Exception {
        int port;
        if (args.length > 0) {
            port = Integer.parseInt(args[0]);
        } else {
            port = 9000;
        }
        new AutobahnServer(port).run();
    }
}


text:
.clearfix {
  *zoom: 1;
}
.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
  line-height: 0;
}
.clearfix:after {
  clear: both;
}

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}
a:focus {
  outline: thin dotted #333;
  outline: 5px auto -webkit-focus-ring-color;
  outline-offset: -2px;
}
a:hover,
a:active {
  outline: 0;
}
img {
  /* Responsive images (ensure images don't scale beyond their parents) */
  max-width: 100%;
  /* Part 1: Set a maxium relative to the parent */

  width: auto\9;
  /* IE7-8 need help adjusting responsive images */

  height: auto;
  /* Part 2: Scale the height according to the width, otherwise you get stretching */

  vertical-align: middle;
  border: 0;
  -ms-interpolation-mode: bicubic;
}
#map_canvas img {
  max-width: none;
}
button,
input,
select,
textarea {
  margin: 0;
  font-size: 100%;
  vertical-align: middle;
}
button,
input {
  *overflow: visible;
  line-height: normal;
}
button::-moz-focus-inner,
input::-moz-focus-inner {
  padding: 0;
  border: 0;
}
button,
input[type="button"],
input[type="reset"],
input[type="submit"] {
  cursor: pointer;
  -webkit-appearance: button;
}
body {
  margin: 0;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 20px;
  color: #333333;
  background-color: #ffffff;
}
a {
  color: #0088cc;
  text-decoration: none;
}
a:hover {
  color: #005580;
  text-decoration: underline;
}

p {
  margin: 0 0 10px;
}

small {
  font-size: 85%;
}
strong {
  font-weight: bold;
}
em {
  font-style: italic;
}
h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 10px 0;
  font-family: inherit;
  font-weight: bold;
  line-height: 1;
  color: inherit;
  text-rendering: optimizelegibility;
}
h1 {
  font-size: 36px;
  line-height: 40px;
}
h2 {
  font-size: 30px;
  line-height: 40px;
}
h3 {
  font-size: 24px;
  line-height: 40px;
}
h4 {
  font-size: 18px;
  line-height: 20px;
}
h5 {
  font-size: 14px;
  line-height: 20px;
}
h6 {
  font-size: 12px;
  line-height: 20px;
}
ul,
ol {
  padding: 0;
  margin: 0 0 10px 25px;
}
ul ul,
ul ol,
ol ol,
ol ul {
  margin-bottom: 0;
}
li {
  line-height: 20px;
}
hr {
  margin: 20px 0;
  border: 0;
  border-top: 1px solid #eeeeee;
  border-bottom: 1px solid #ffffff;
}
form {
  margin: 0 0 20px;
}
label,
input,
button,
select,
textarea {
  font-size: 14px;
  font-weight: normal;
  line-height: 20px;
}
input,
button,
select,
textarea {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
label {
  display: block;
  margin-bottom: 5px;
}
select,
textarea,
input[type="text"],
input[type="password"],
input[type="datetime"],
input[type="datetime-local"],
input[type="date"],
input[type="month"],
input[type="time"],
input[type="week"],
input[type="number"],
input[type="email"],
input[type="url"],
input[type="search"],
input[type="tel"],
input[type="color"],
.uneditable-input {
  display: inline-block;
  height: 20px;
  padding: 4px 6px;
  margin-bottom: 9px;
  font-size: 14px;
  line-height: 20px;
  color: #555555;
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;
}
input,
textarea,
.uneditable-input {
  width: 206px;
}
textarea {
  height: auto;
}
textarea,
input[type="text"],
input[type="password"],
input[type="datetime"],
input[type="datetime-local"],
input[type="date"],
input[type="month"],
input[type="time"],
input[type="week"],
input[type="number"],
input[type="email"],
input[type="url"],
input[type="search"],
input[type="tel"],
input[type="color"],
.uneditable-input {
  background-color: #ffffff;
  border: 1px solid #cccccc;
  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
  -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
  -webkit-transition: border linear .2s, box-shadow linear .2s;
  -moz-transition: border linear .2s, box-shadow linear .2s;
  -o-transition: border linear .2s, box-shadow linear .2s;
  transition: border linear .2s, box-shadow linear .2s;
}
textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="datetime"]:focus,
input[type="datetime-local"]:focus,
input[type="date"]:focus,
input[type="month"]:focus,
input[type="time"]:focus,
input[type="week"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
input[type="color"]:focus,
.uneditable-input:focus {
  border-color: rgba(82, 168, 236, 0.8);
  outline: 0;
  outline: thin dotted \9;
  /* IE6-9 */

  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
  -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
}
input[type="radio"],
input[type="checkbox"] {
  margin: 4px 0 0;
  *margin-top: 0;
  /* IE7 */

  margin-top: 1px \9;
  /* IE8-9 */

  line-height: normal;
  cursor: pointer;
}
input[type="file"],
input[type="image"],
input[type="submit"],
input[type="reset"],
input[type="button"],
input[type="radio"],
input[type="checkbox"] {
  width: auto;
}
select,
input[type="file"] {
  height: 30px;
  /* In IE7, the height of the select element cannot be changed by height, only font-size */

  *margin-top: 4px;
  /* For IE7, add top margin to align select with labels */

  line-height: 30px;
}
select {
  width: 220px;
  border: 1px solid #cccccc;
  background-color: #ffffff;
}
select[multiple],
select[size] {
  height: auto;
}
select:focus,
input[type="file"]:focus,
input[type="radio"]:focus,
input[type="checkbox"]:focus {
  outline: thin dotted #333;
  outline: 5px auto -webkit-focus-ring-color;
  outline-offset: -2px;
}
input:-moz-placeholder,
textarea:-moz-placeholder {
  color: #999999;
}
input:-ms-input-placeholder,
textarea:-ms-input-placeholder {
  color: #999999;
}
input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder {
  color: #999999;
}
.radio,
.checkbox {
  min-height: 18px;
  padding-left: 18px;
}
.radio input[type="radio"],
.checkbox input[type="checkbox"] {
  float: left;
  margin-left: -18px;
}
.controls > .radio:first-child,
.controls > .checkbox:first-child {
  padding-top: 5px;
}
.radio.inline,
.checkbox.inline {
  display: inline-block;
  padding-top: 5px;
  margin-bottom: 0;
  vertical-align: middle;
}
.radio.inline + .radio.inline,
.checkbox.inline + .checkbox.inline {
  margin-left: 10px;
}
input[class*="span"],
select[class*="span"],
textarea[class*="span"],
.uneditable-input[class*="span"],
.row-fluid input[class*="span"],
.row-fluid select[class*="span"],
.row-fluid textarea[class*="span"],
.row-fluid .uneditable-input[class*="span"] {
  float: none;
  margin-left: 0;
}
.input-append input[class*="span"],
.input-append .uneditable-input[class*="span"],
.input-prepend input[class*="span"],
.input-prepend .uneditable-input[class*="span"],
.row-fluid input[class*="span"],
.row-fluid select[class*="span"],
.row-fluid textarea[class*="span"],
.row-fluid .uneditable-input[class*="span"],
.row-fluid .input-prepend [class*="span"],
.row-fluid .input-append [class*="span"] {
  display: inline-block;
}
input,
textarea,
.uneditable-input {
  margin-left: 0;
}

input[disabled],
select[disabled],
textarea[disabled],
input[readonly],
select[readonly],
textarea[readonly] {
  cursor: not-allowed;
  background-color: #eeeeee;
}
input[type="radio"][disabled],
input[type="checkbox"][disabled],
input[type="radio"][readonly],
input[type="checkbox"][readonly] {
  background-color: transparent;
}
input:focus:required:invalid,
textarea:focus:required:invalid,
select:focus:required:invalid {
  color: #b94a48;
  border-color: #ee5f5b;
}
input:focus:required:invalid:focus,
textarea:focus:required:invalid:focus,
select:focus:required:invalid:focus {
  border-color: #e9322d;
  -webkit-box-shadow: 0 0 6px #f8b9b7;
  -moz-box-shadow: 0 0 6px #f8b9b7;
  box-shadow: 0 0 6px #f8b9b7;
}
.btn {
  display: inline-block;
  *display: inline;
  /* IE7 inline-block hack */

  *zoom: 1;
  padding: 4px 14px;
  margin-bottom: 0;
  font-size: 14px;
  line-height: 20px;
  *line-height: 20px;
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  color: #333333;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
  background-color: #f5f5f5;
  background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
  background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
  background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
  background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
  background-repeat: repeat-x;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);
  border-color: #e6e6e6 #e6e6e6 #bfbfbf;
  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
  *background-color: #e6e6e6;
  /* Darken IE7 buttons by default so they stand out more given they won't have borders */

  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
  border: 1px solid #bbbbbb;
  *border: 0;
  border-bottom-color: #a2a2a2;
  -webkit-border-radius: 4px;
  -moz-border-radius: 4px;
  border-radius: 4px;
  *margin-left: .3em;
  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
  -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
}
.btn:hover,
.btn:active,
.btn.active,
.btn.disabled,
.btn[disabled] {
  color: #333333;
  background-color: #e6e6e6;
  *background-color: #d9d9d9;
}
.btn:active,
.btn.active {
  background-color: #cccccc \9;
}
.btn:first-child {
  *margin-left: 0;
}
.btn:hover {
  color: #333333;
  text-decoration: none;
  background-color: #e6e6e6;
  *background-color: #d9d9d9;
  /* Buttons in IE7 don't get borders, so darken on hover */

  background-position: 0 -15px;
  -webkit-transition: background-position 0.1s linear;
  -moz-transition: background-position 0.1s linear;
  -o-transition: background-position 0.1s linear;
  transition: background-position 0.1s linear;
}
.btn:focus {
  outline: thin dotted #333;
  outline: 5px auto -webkit-focus-ring-color;
  outline-offset: -2px;
}
.btn.active,
.btn:active {
  background-color: #e6e6e6;
  background-color: #d9d9d9 \9;
  background-image: none;
  outline: 0;
  -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
  -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
}
.btn.disabled,
.btn[disabled] {
  cursor: default;
  background-color: #e6e6e6;
  background-image: none;
  opacity: 0.65;
  filter: alpha(opacity=65);
  -webkit-box-shadow: none;
  -moz-box-shadow: none;
  box-shadow: none;
}
input[type="submit"].btn-block,
input[type="reset"].btn-block,
input[type="button"].btn-block {
  width: 100%;
}
.btn-primary.active,
.btn-warning.active,
.btn-danger.active,
.btn-success.active,
.btn-info.active,
.btn-inverse.active {
  color: rgba(255, 255, 255, 0.75);
}
.btn {
  border-color: #c5c5c5;
  border-color: rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.15) rgba(0, 0, 0, 0.25);
}
.btn-inverse {
  color: #ffffff;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
  background-color: #363636;
  background-image: -moz-linear-gradient(top, #444444, #222222);
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#444444), to(#222222));
  background-image: -webkit-linear-gradient(top, #444444, #222222);
  background-image: -o-linear-gradient(top, #444444, #222222);
  background-image: linear-gradient(to bottom, #444444, #222222);
  background-repeat: repeat-x;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff444444', endColorstr='#ff222222', GradientType=0);
  border-color: #222222 #222222 #000000;
  border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
  *background-color: #222222;
  /* Darken IE7 buttons by default so they stand out more given they won't have borders */

  filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
}
.btn-inverse:hover,
.btn-inverse:active,
.btn-inverse.active,
.btn-inverse.disabled,
.btn-inverse[disabled] {
  color: #ffffff;
  background-color: #222222;
  *background-color: #151515;
}
.btn-inverse:active,
.btn-inverse.active {
  background-color: #080808 \9;
}
button.btn,
input[type="submit"].btn {
  *padding-top: 3px;
  *padding-bottom: 3px;
}
button.btn::-moz-focus-inner,
input[type="submit"].btn::-moz-focus-inner {
  padding: 0;
  border: 0;
}
.btn-group {
  position: relative;
  font-size: 0;
  vertical-align: middle;
  white-space: nowrap;
  *margin-left: .3em;
}
.btn-group:first-child {
  *margin-left: 0;
}
.btn-group + .btn-group {
  margin-left: 5px;
}
.btn-group > .btn {
  position: relative;
  -webkit-border-radius: 0;
  -moz-border-radius: 0;
  border-radius: 0;
}
.btn-group > .btn + .btn {
  margin-left: -1px;
}

.btn-group > .btn:first-child {
  margin-left: 0;
  -webkit-border-top-left-radius: 4px;
  -moz-border-radius-topleft: 4px;
  border-top-left-radius: 4px;
  -webkit-border-bottom-left-radius: 4px;
  -moz-border-radius-bottomleft: 4px;
  border-bottom-left-radius: 4px;
}

.btn-group > .btn:hover,
.btn-group > .btn:focus,
.btn-group > .btn:active,
.btn-group > .btn.active {
  z-index: 2;
}

.carousel {
  position: relative;
  margin-bottom: 20px;
  line-height: 1;
}
.carousel-inner {
  overflow: hidden;
  width: 100%;
  position: relative;
}
.carousel .item {
  display: none;
  position: relative;
  -webkit-transition: 0.6s ease-in-out left;
  -moz-transition: 0.6s ease-in-out left;
  -o-transition: 0.6s ease-in-out left;
  transition: 0.6s ease-in-out left;
}
.carousel .item > img {
  display: block;
  line-height: 1;
}
.carousel .active,
.carousel .next,
.carousel .prev {
  display: block;
}
.carousel .active {
  left: 0;
}
.carousel .next,
.carousel .prev {
  position: absolute;
  top: 0;
  width: 100%;
}
.carousel .next {
  left: 100%;
}
.carousel .prev {
  left: -100%;
}
.carousel .next.left,
.carousel .prev.right {
  left: 0;
}
.carousel .active.left {
  left: -100%;
}
.carousel .active.right {
  left: 100%;
}
.carousel-control {
  position: absolute;
  top: 40%;
  left: 15px;
  width: 40px;
  height: 40px;
  margin-top: -20px;
  font-size: 60px;
  font-weight: 100;
  line-height: 30px;
  color: #ffffff;
  text-align: center;
  background: #222222;
  border: 3px solid #ffffff;
  -webkit-border-radius: 23px;
  -moz-border-radius: 23px;
  border-radius: 23px;
  opacity: 0.5;
  filter: alpha(opacity=50);
}
.carousel-control.right {
  left: auto;
  right: 15px;
}
.carousel-control:hover {
  color: #ffffff;
  text-decoration: none;
  opacity: 0.9;
  filter: alpha(opacity=90);
}

.close {
  float: right;
  font-size: 20px;
  font-weight: bold;
  line-height: 20px;
  color: #000000;
  text-shadow: 0 1px 0 #ffffff;
  opacity: 0.2;
  filter: alpha(opacity=20);
}
.close:hover {
  color: #000000;
  text-decoration: none;
  cursor: pointer;
  opacity: 0.4;
  filter: alpha(opacity=40);
}

.pull-right {
  float: right;
}
.pull-left {
  float: left;
}


text:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using InfiniteCity.Model;

namespace InfiniteCity.Tests.Model
{
    internal sealed class MockDeck : Deck, IEnumerable<Tile>
    {
        private readonly int _seed;
        private readonly LinkedList<Tile> _tiles;

        public MockDeck() : this(0x53454544) {}

        public MockDeck(int seed) : this(seed, YieldDeck()) {}

        public MockDeck(IEnumerable<Tile> tiles) : this(0x53454544, tiles) {}

        public MockDeck(int seed, IEnumerable<Tile> tiles)
        {
            _seed = seed;
            _tiles = new LinkedList<Tile>(tiles);
        }

        /// <summary>
        ///   Gets the number of cards remaining in the deck. This property is not supported by infinite decks.
        /// </summary>
        /// <exception cref = "System.NotSupportedException" />
        public override int Remaining
        {
            get { return _tiles.Count; }
        }

        /// <summary>
        ///   Places a tile on the bottom of the deck.
        /// </summary>
        public override void Enqueue(Tile tile)
        {
            _tiles.AddLast(tile);
        }

        /// <summary>
        ///   Removes and returns the first tile off the top of the deck.
        /// </summary>
        public override Tile Pop()
        {
            if (_tiles.Count == 0)
                throw new InvalidOperationException();
            LinkedListNode<Tile> node = _tiles.First;
            _tiles.RemoveFirst();
            return node.Value;
        }

        /// <summary>
        ///   Places a tile on the top of the deck.
        /// </summary>
        public override void Push(Tile tile)
        {
            _tiles.AddFirst(tile);
        }

        /// <summary>
        ///   Randomizes the deck.
        /// </summary>
        public override void Shuffle()
        {
            Shuffle(_seed);
        }

        /// <summary>
        ///   Returns an enumerator that iterates through the collection.
        /// </summary>
        /// <returns>
        ///   A <see cref = "T:System.Collections.Generic.IEnumerator`1" /> that can be used to iterate through the collection.
        /// </returns>
        /// <filterpriority>1</filterpriority>
        public IEnumerator<Tile> GetEnumerator()
        {
            return _tiles.GetEnumerator();
        }

        /// <summary>
        ///   Randomizes the deck.
        /// </summary>
        public void Shuffle(int seed)
        {
            Shuffle(_tiles, new Random(seed));
        }

        private static void Shuffle<T>(LinkedList<T> list, Random random)
        {
            T[] array = list.ToArray();
            list.Clear();

            for (int i = array.Length; i>0; i--)
            {
                int item = random.Next(0, i);
                list.AddFirst(array[item]);
                Array.Copy(array, item+1, array, item, array.Length-(item+1));
            }
        }

        private static IEnumerable<Tile> YieldDeck()
        {
            for (int i = 0; i<120; i++)
                yield return new MockTile();
        }

        /// <summary>
        ///   Returns an enumerator that iterates through a collection.
        /// </summary>
        /// <returns>
        ///   An <see cref = "T:System.Collections.IEnumerator" /> object that can be used to iterate through the collection.
        /// </returns>
        /// <filterpriority>2</filterpriority>
        IEnumerator IEnumerable.GetEnumerator()
        {
            return _tiles.GetEnumerator();
        }
    }
}


text:
import axios from 'axios';
import { GET_INITIAL_BEATMAPS, CHECK_VALID_MAP, GET_NEW_BEATMAPS, CLEAR_BEATMAPS_BEFORE_SEARCH } from "./types";

const ROOT_URL = `http://localhost:8088/api`;

// Responsible for reaching out to the local API and grabbing 100 initial beatmaps.
// These beatmaps are random in the sense that they can be from game modes 0-3.
// They'll be displayed to the user upon first loading the page.
export function getInitialBeatmaps(offset = 0) {
    return function(dispatch) {
        axios.get(`${ROOT_URL}/initialbeatmaps?offset=${offset}`)
            .then((response) => {
                dispatch({ type: GET_INITIAL_BEATMAPS, payload: response.data });
            })
            .catch((error) => {
                console.log(error);
            });
    }
}

// Responsible for reaching out to the local API and checking if the beatmap
// we have entered is a set first off, and if it's a valid beatmap.
// This function is used when downloading shareable beatmap links
export function checkValidMap({ isBeatmapSet, id }) {
    return function(dispatch) {
        const beatmapSetOrIdText = (isBeatmapSet) ? 's' : 'b';

        axios.get(`${ROOT_URL}/${beatmapSetOrIdText}/${id}`)
            .then((response) => {
                dispatch({ type: CHECK_VALID_MAP, payload: response.data });
            })
            .catch((err) => {
                dispatch({ type: CHECK_VALID_MAP, payload: false });
            })
    }
}

// Responsible for reaching out to the local API and getting a list of
// new beatmaps. These beatmaps will be displayed to the user.
export function getNewBeatmaps({ query, status, mode, keys }) {
    return function(dispatch) {
        axios.get(`${ROOT_URL}/search?query=${query}&status=${status}&mode=${mode}&keys=${keys}`)
            .then((response) => {
                // Here, we'll create a new variable on the beatmaps object named "beatmaps" instead of "sets"
                // This way it will be consistent with the initialBeatmaps, so we can render them on the screen
                // in a DRY way.
                let returnedData = response.data;
                response.data.beatmaps = response.data.sets;

                dispatch({ type: GET_NEW_BEATMAPS, payload: response.data });
            })
            .catch((err) => {
                console.log(err);
                dispatch({ type: GET_NEW_BEATMAPS, payload: [] });
            })
    }
}

// Responsible for dispatching a payload of undefined, so that we can clear
// the searched beatmaps and initial beatmaps. This is usually done before a search
// So that we can properly display the loading animation
export function clearBeatmapsBeforeSearch() {
    return function(dispatch) {
        dispatch({ type: CLEAR_BEATMAPS_BEFORE_SEARCH, payload: undefined });
    }
}


text:
/* error.h  -  Foundation library  -  Public Domain  -  2013 Mattias Jansson / Rampant Pixels
 *
 * This library provides a cross-platform foundation library in C11 providing basic support data types and
 * functions to write applications and games in a platform-independent fashion. The latest source code is
 * always available at
 *
 * https://github.com/rampantpixels/foundation_lib
 *
 * This library is put in the public domain; you can redistribute it and/or modify it without any restrictions.
 *
 */

#pragma once

#include <foundation/platform.h>
#include <foundation/types.h>

FOUNDATION_API error_t            error( void );
FOUNDATION_API int                error_report( error_level_t level, error_t err );
FOUNDATION_API error_callback_fn  error_callback( void );
FOUNDATION_API void               error_set_callback( error_callback_fn callback );

#if BUILD_ENABLE_ERROR_CONTEXT

#define error_context_push( name, data )      do { _error_context_push( (name), (data) ); } while(0)
#define error_context_pop()                   do { _error_context_pop(); } while(0)
#define error_context_clear()                 do { _error_context_clear(); } while(0)
#define error_context_buffer( buffer, size )  do { _error_context_buffer( buffer, size ); } while(0)
#define error_context()                       _error_context()
#define error_context_declare_local( decl )   decl
#define error_context_thread_deallocate()     do { _error_context_thread_deallocate(); } while(0)

FOUNDATION_API void                           _error_context_push( const char* name, const char* data );
FOUNDATION_API void                           _error_context_pop( void );
FOUNDATION_API void                           _error_context_clear( void );
FOUNDATION_API void                           _error_context_buffer( char* buffer, int size );
FOUNDATION_API error_context_t*               _error_context( void );
FOUNDATION_API void                           _error_context_thread_deallocate( void );

#else

#define error_context_push( name, data )      /*lint -save -e506 -e751 */ do { (void)sizeof( name ); (void)sizeof( data ); } while(0) /*lint -restore -e506 -e751 */
#define error_context_pop()                   do { /* */ } while(0)
#define error_context_clear()                 do { /* */ } while(0)
#define error_context_buffer( buffer, size )  /*lint -save -e506 -e751 */ do { (void)sizeof( buffer ); (void)sizeof( size ); } while(0) /*lint -restore -e506 -e751 */
#define error_context()                       0
#define error_context_declare_local( decl )   do { /* */ } while(0)
#define error_context_thread_deallocate()     do { /* */ } while(0)

#endif


text:
Template.adminTmpl.helpers({
    adminLink: function () {
        var username = Meteor.user().username;
        var role = Session.get("myRole");
        if (role === ROLE_DEVOPS){
            return "Admin";
        }
    },
});

Template.roleTmpl.helpers({
    role: function () {
        return Meteor.call('getRole', username);
    },
    myRole: function (){
        var username = Meteor.user().username;
        getRoleCall(username);
        return Session.get("myRole");
    }
});

Template.userList.helpers({
  users: function () {
    return Meteor.users.find({},{sort: {username: 1}});
  },
  username: function () {
        if (this.username !== undefined)
            return this.username;
        return "";
  },
  email: function () {
        if (this.emails !== undefined)
            return this.emails[0].address;
        return "";
  },
  id:function() {
        if (this._id !== undefined)
          return this._id;
        return "";
  }
});

Template.adminButtonsTmpl.helpers({
    adminButtons: function () {
        var username = Meteor.user().username;
        var role = Session.get("myRole");
        if (role === ROLE_DEVOPS){
            var b1 = '<button id="btnCsvDeploy"  title="Deploy this list to SIEM." onclick="deployCall()">Deploy</button> ';
            var b2 = '<button id="btnCsvExport"  title="Export all list data as CSV and download." onclick="window.open(\'/lists.csv\', \'DownloadWin\')">Export All</button> ';
            return b1 + b2;
        }
        return "";
    },
});


text:
//Write a program to convert hexadecimal numbers to their decimal representation.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class HexadecimalToDecimal
{
    static void Main()
    {
        Console.Write("Enter hexadecimal number:");
        string number = Console.ReadLine();
        Console.WriteLine(HexToDec(number));
    }

    static long HexToDec(string hex)
    {
        long decNumber = 0;
        for (int i = 0; i < hex.Length; i++)
        {
            int digit = 0;
            if (hex[i] >= '0' && hex[i] <= '9')
            {
                digit = hex[i] - '0';
            }
            else if (hex[i] >= 'A' && hex[i] <= 'F')
            {
                digit = hex[i] - 'A' + 10;
            }
            decNumber = decNumber + digit * (long)Math.Pow(16, hex.Length - i - 1);
        }

        return decNumber;
    }
}


text:
module.exports = exports = build

/**
 * Module dependencies.
 */

var fs = require('graceful-fs')
  , rm = require('rimraf')
  , path = require('path')
  , glob = require('glob')
  , log = require('npmlog')
  , which = require('which')
  , exec = require('child_process').exec
  , processRelease = require('./process-release')
  , win = process.platform === 'win32'

exports.usage = 'Invokes `' + (win ? 'msbuild' : 'make') + '` and builds the module'

function build (gyp, argv, callback) {
  var platformMake = 'make'
  if (process.platform === 'aix') {
    platformMake = 'gmake'
  } else if (process.platform.indexOf('bsd') !== -1) {
    platformMake = 'gmake'
  } else if (win && argv.length > 0) {
    argv = argv.map(function(target) {
      return '/t:' + target
    })
  }

  var release = processRelease(argv, gyp, process.version, process.release)
    , makeCommand = gyp.opts.make || process.env.MAKE || platformMake
    , command = win ? 'msbuild' : makeCommand
    , buildDir = path.resolve('build')
    , configPath = path.resolve(buildDir, 'config.gypi')
    , jobs = gyp.opts.jobs || process.env.JOBS
    , buildType
    , config
    , arch
    , nodeDir

  loadConfigGypi()

  /**
   * Load the "config.gypi" file that was generated during "configure".
   */

  function loadConfigGypi () {
    fs.readFile(configPath, 'utf8', function (err, data) {
      if (err) {
        if (err.code == 'ENOENT') {
          callback(new Error('You must run `node-gyp configure` first!'))
        } else {
          callback(err)
        }
        return
      }
      config = JSON.parse(data.replace(/\#.+\n/, ''))

      // get the 'arch', 'buildType', and 'nodeDir' vars from the config
      buildType = config.target_defaults.default_configuration
      arch = config.variables.target_arch
      nodeDir = config.variables.nodedir

      if ('debug' in gyp.opts) {
        buildType = gyp.opts.debug ? 'Debug' : 'Release'
      }
      if (!buildType) {
        buildType = 'Release'
      }

      log.verbose('build type', buildType)
      log.verbose('architecture', arch)
      log.verbose('node dev dir', nodeDir)

      if (win) {
        findSolutionFile()
      } else {
        doWhich()
      }
    })
  }

  /**
   * On Windows, find the first build/*.sln file.
   */

  function findSolutionFile () {
    glob('build/*.sln', function (err, files) {
      if (err) return callback(err)
      if (files.length === 0) {
        return callback(new Error('Could not find *.sln file. Did you run "configure"?'))
      }
      guessedSolution = files[0]
      log.verbose('found first Solution file', guessedSolution)
      doWhich()
    })
  }

  /**
   * Uses node-which to locate the msbuild / make executable.
   */

  function doWhich () {
    // First make sure we have the build command in the PATH
    which(command, function (err, execPath) {
      if (err) {
        if (win && /not found/.test(err.message)) {
          // On windows and no 'msbuild' found. Let's guess where it is
          findMsbuild()
        } else {
          // Some other error or 'make' not found on Unix, report that to the user
          callback(err)
        }
        return
      }
      log.verbose('`which` succeeded for `' + command + '`', execPath)
      doBuild()
    })
  }

  /**
   * Search for the location of "msbuild.exe" file on Windows.
   */

  function findMsbuild () {
    if (config.variables.msbuild_path) {
      command = config.variables.msbuild_path
      log.verbose('using MSBuild:', command)
      doBuild()
      return
    }

    log.verbose('could not find "msbuild.exe" in PATH - finding location in registry')
    var notfoundErr = 'Can\'t find "msbuild.exe". Do you have Microsoft Visual Studio C++ 2008+ installed?'
    var cmd = 'reg query "HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions" /s'
    if (process.arch !== 'ia32')
      cmd += ' /reg:32'
    exec(cmd, function (err, stdout, stderr) {
      if (err) {
        return callback(new Error(err.message + '\n' + notfoundErr))
      }
      var reVers = /ToolsVersions\\([^\\]+)$/i
        , rePath = /\r\n[ \t]+MSBuildToolsPath[ \t]+REG_SZ[ \t]+([^\r]+)/i
        , msbuilds = []
        , r
        , msbuildPath
      stdout.split('\r\n\r\n').forEach(function(l) {
        if (!l) return
        l = l.trim()
        if (r = reVers.exec(l.substring(0, l.indexOf('\r\n')))) {
          var ver = parseFloat(r[1], 10)
          if (ver >= 3.5) {
            if (r = rePath.exec(l)) {
              msbuilds.push({
                version: ver,
                path: r[1]
              })
            }
          }
        }
      })
      msbuilds.sort(function (x, y) {
        return (x.version < y.version ? -1 : 1)
      })
      ;(function verifyMsbuild () {
        if (!msbuilds.length) return callback(new Error(notfoundErr))
        msbuildPath = path.resolve(msbuilds.pop().path, 'msbuild.exe')
        fs.stat(msbuildPath, function (err, stat) {
          if (err) {
            if (err.code == 'ENOENT') {
              if (msbuilds.length) {
                return verifyMsbuild()
              } else {
                callback(new Error(notfoundErr))
              }
            } else {
              callback(err)
            }
            return
          }
          command = msbuildPath
          doBuild()
        })
      })()
    })
  }

  /**
   * Actually spawn the process and compile the module.
   */

  function doBuild () {

    // Enable Verbose build
    var verbose = log.levels[log.level] <= log.levels.verbose
    if (!win && verbose) {
      argv.push('V=1')
    }
    if (win && !verbose) {
      argv.push('/clp:Verbosity=minimal')
    }

    if (win) {
      // Turn off the Microsoft logo on Windows
      argv.push('/nologo')
    }

    // Specify the build type, Release by default
    if (win) {
      var archLower = arch.toLowerCase()
      var p = archLower === 'x64' ? 'x64' :
              (archLower === 'arm' ? 'ARM' : 'Win32')
      argv.push('/p:Configuration=' + buildType + ';Platform=' + p)
      if (jobs) {
        var j = parseInt(jobs, 10)
        if (!isNaN(j) && j > 0) {
          argv.push('/m:' + j)
        } else if (jobs.toUpperCase() === 'MAX') {
          argv.push('/m:' + require('os').cpus().length)
        }
      }
    } else {
      argv.push('BUILDTYPE=' + buildType)
      // Invoke the Makefile in the 'build' dir.
      argv.push('-C')
      argv.push('build')
      if (jobs) {
        var j = parseInt(jobs, 10)
        if (!isNaN(j) && j > 0) {
          argv.push('--jobs')
          argv.push(j)
        } else if (jobs.toUpperCase() === 'MAX') {
          argv.push('--jobs')
          argv.push(require('os').cpus().length)
        }
      }
    }

    if (win) {
      // did the user specify their own .sln file?
      var hasSln = argv.some(function (arg) {
        return path.extname(arg) == '.sln'
      })
      if (!hasSln) {
        argv.unshift(gyp.opts.solution || guessedSolution)
      }
    }

    var proc = gyp.spawn(command, argv)
    proc.on('exit', onExit)
  }

  /**
   * Invoked after the make/msbuild command exits.
   */

  function onExit (code, signal) {
    if (code !== 0) {
      return callback(new Error('`' + command + '` failed with exit code: ' + code))
    }
    if (signal) {
      return callback(new Error('`' + command + '` got signal: ' + signal))
    }
    callback()
  }

}


text:
/**
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

var URL = window.location,
    $BODY = $('body'),
    $MENU_TOGGLE = $('#menu_toggle'),
    $SIDEBAR_MENU = $('#sidebar-menu'),
    $SIDEBAR_FOOTER = $('.sidebar-footer'),
    $LEFT_COL = $('.left_col'),
    $RIGHT_COL = $('.right_col'),
    $NAV_MENU = $('.nav_menu'),
    $FOOTER = $('footer');

// Sidebar
$(function () {

    $MENU_TOGGLE.on('click', function() {
        if ($BODY.hasClass('nav-md')) {
            $BODY.removeClass('nav-md').addClass('nav-sm', 1000);
            $LEFT_COL.removeClass('scroll-view').removeAttr('style');
            $SIDEBAR_FOOTER.hide();

            if ($SIDEBAR_MENU.find('li').hasClass('active')) {
                $SIDEBAR_MENU.find('li.active').addClass('active-sm').removeClass('active');
            }
        } else {
            $BODY.removeClass('nav-sm').addClass('nav-md', 1000);
            $SIDEBAR_FOOTER.show();

            if ($SIDEBAR_MENU.find('li').hasClass('active-sm')) {
                $SIDEBAR_MENU.find('li.active-sm').addClass('active').removeClass('active-sm');
            }
        }
    });
var setContentHeight = function () {
        // reset height
        $RIGHT_COL.css('min-height', $(window).height());

        var bodyHeight = $BODY.height(),
            leftColHeight = $LEFT_COL.height() + $SIDEBAR_FOOTER.height(),
            contentHeight = bodyHeight < leftColHeight ? leftColHeight : bodyHeight;

        // normalize content
        contentHeight -= $NAV_MENU.height() + $FOOTER.height();

        $RIGHT_COL.css('min-height', contentHeight);
    };
    // check active menu
    $SIDEBAR_MENU.find('a[href="' + URL + '"]').parent('li').addClass('current-page');

    $SIDEBAR_MENU.find('a').filter(function () {
        return this.href == URL;
    }).parent('li').addClass('current-page').parent('ul').slideDown(function() {
        setContentHeight();
    }).parent().addClass('active');
});

    validator.message['date'] = 'not a real date';
    $('form')
      .on('blur', 'input[required], input.optional, select.required', validator.checkField)
      .on('change', 'select.required', validator.checkField)
      .on('keypress', 'input[required][pattern]', validator.keypress);

//文件输入框改写
      $('input[type=file]').on('change',function(){
        var flieAddress =  $('input[type=file]').val() ? $('input[type=file]').val(): "未选择文件" ;
        $("#file-value").val(flieAddress)
      })
      $(".file-container").width($('input[type=file]').width())
    $('.multi.required')
      .on('keyup blur', 'input', function() {
        validator.checkField.apply($(this).siblings().last()[0]);
      });

      $("li.child-menu-show").click(function(){
        $(this).find(".child_menu").slideToggle();
      })

    $('form').submit(function(e) {
      e.preventDefault();
      var submit = true;
      // evaluate the form using generic validaing
      if (!validator.checkAll($(this))) {
        submit = false;
      }

      if (submit)
        this.submit();
      return false;
    });

    /* FOR DEMO ONLY */
    $('#vfields').change(function() {
      $('form').toggleClass('mode2');
    }).prop('checked', false);

    $('#alerts').change(function() {
      validator.defaults.alerts = (this.checked) ? false : true;
      if (this.checked)
        $('form .alert').remove();
    }).prop('checked', false);


text:
using System.Collections.Generic;
using LottieUWP.Value;
using LottieUWP.Model.Animatable;

namespace LottieUWP.Parser
{
    public static class AnimatableValueParser
    {
        public static AnimatableFloatValue ParseFloat(JsonReader reader, LottieComposition composition)
        {
            return ParseFloat(reader, composition, true);
        }

        public static AnimatableFloatValue ParseFloat(JsonReader reader, LottieComposition composition, bool isDp)
        {
            return new AnimatableFloatValue(Parse(reader, isDp ? Utils.Utils.DpScale() : 1f, composition, FloatParser.Instance));
        }

        internal static AnimatableIntegerValue ParseInteger(JsonReader reader, LottieComposition composition)
        {
            return new AnimatableIntegerValue(Parse(reader, composition, IntegerParser.Instance));
        }

        internal static AnimatablePointValue ParsePoint(JsonReader reader, LottieComposition composition)
        {
            return new AnimatablePointValue(Parse(reader, Utils.Utils.DpScale(), composition, PointFParser.Instance));
        }

        internal static AnimatableScaleValue ParseScale(JsonReader reader, LottieComposition composition)
        {
            return new AnimatableScaleValue(Parse(reader, composition, ScaleXyParser.Instance));
        }

        internal static AnimatableShapeValue ParseShapeData(JsonReader reader, LottieComposition composition)
        {
            return new AnimatableShapeValue(Parse(reader, Utils.Utils.DpScale(), composition, ShapeDataParser.Instance));
        }

        internal static AnimatableTextFrame ParseDocumentData(JsonReader reader, LottieComposition composition)
        {
            return new AnimatableTextFrame(Parse(reader, composition, DocumentDataParser.Instance));
        }

        internal static AnimatableColorValue ParseColor(JsonReader reader, LottieComposition composition)
        {
            return new AnimatableColorValue(Parse(reader, composition, ColorParser.Instance));
        }

        internal static AnimatableGradientColorValue ParseGradientColor(JsonReader reader, LottieComposition composition, int points)
        {
            return new AnimatableGradientColorValue(Parse(reader, composition, new GradientColorParser(points)));
        }

        /// <summary>
        /// Will return null if the animation can't be played such as if it has expressions.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="reader"></param>
        /// <param name="composition"></param>
        /// <param name="valueParser"></param>
        /// <returns></returns>
        private static List<Keyframe<T>> Parse<T>(JsonReader reader, LottieComposition composition, IValueParser<T> valueParser)
        {
            return KeyframesParser.Parse(reader, composition, 1, valueParser);
        }

        /// <summary>
        /// Will return null if the animation can't be played such as if it has expressions.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="reader"></param>
        /// <param name="scale"></param>
        /// <param name="composition"></param>
        /// <param name="valueParser"></param>
        /// <returns></returns>
        private static List<Keyframe<T>> Parse<T>(JsonReader reader, float scale, LottieComposition composition, IValueParser<T> valueParser)
        {
            return KeyframesParser.Parse(reader, composition, scale, valueParser);
        }
    }
}


text:
import React from 'react';
import Modal from './Modal';
export interface ModalFuncProps {
    visible?: boolean;
    title?: React.ReactNode | string;
    content?: React.ReactNode | string;
    onOk?: (func: Function) => any;
    onCancel?: (func: Function) => any;
    width?: string | number;
    iconClassName?: string;
    okText?: string;
    cancelText?: string;
    iconType?: string;
}
export default Modal;


text:
'''
You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint that indicates how many digits in said guess match your secret number exactly in both digit and position (called "bulls") and how many digits match the secret number but locate in the wrong position (called "cows"). Your friend will use successive guesses and hints to eventually derive the secret number.

For example:

Secret number:  "1807"
Friend's guess: "7810"
Hint: 1 bull and 3 cows. (The bull is 8, the cows are 0, 1 and 7.)
Write a function to return a hint according to the secret number and friend's guess, use A to indicate the bulls and B to indicate the cows. In the above example, your function should return "1A3B".

Please note that both secret number and friend's guess may contain duplicate digits, for example:

Secret number:  "1123"
Friend's guess: "0111"
In this case, the 1st 1 in friend's guess is a bull, the 2nd or 3rd 1 is a cow, and your function should return "1A1B".
You may assume that the secret number and your friend's guess only contain digits, and their lengths are always equal.
'''

class Solution(object):
    def getHint(self, secret, guess):
        """
        :type secret: str
        :type guess: str
        :rtype: str
        """
        import collections
        setA = [0] * 10
        setB = [0] * 10
        A = 0
        size = len(secret)
        for index in range(size):
            if secret[index] == guess[index]:
                A += 1
            else:
                setA[int(secret[index])] += 1
                setB[int(guess[index])] += 1
        B = sum([ min(setA[index], setB[index]) for index in range(10) ])
        return "%dA%dB" % (A, B)


text:
.class Lcom/htc/widget/AbsSpinner$WaveRunnable;
.super Ljava/lang/Object;
.source "AbsSpinner.java"

# interfaces
.implements Ljava/lang/Runnable;

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/htc/widget/AbsSpinner;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x2
    name = "WaveRunnable"
.end annotation

# static fields
.field private static final DURATION:I = 0xc8

.field private static final MOVE_MODE:I = 0x1

.field private static final STOP_MODE:I

# instance fields
.field private mDistance:I

.field private mMode:I

.field private mMovedDistance:I

.field private mStartTime:J

.field final synthetic this$0:Lcom/htc/widget/AbsSpinner;

# direct methods
.method private constructor <init>(Lcom/htc/widget/AbsSpinner;)V
    .locals 2
    .parameter

    .prologue
    const/4 v0, 0x0

    .line 1023
    iput-object p1, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-direct/range {p0 .. p0}, Ljava/lang/Object;-><init>()V

    .line 1026
    iput v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->mMode:I

    .line 1029
    iput v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->mDistance:I

    .line 1030
    invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J

    move-result-wide v0

    iput-wide v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->mStartTime:J

    return-void
.end method

.method synthetic constructor <init>(Lcom/htc/widget/AbsSpinner;Lcom/htc/widget/AbsSpinner$1;)V
    .locals 0
    .parameter "x0"
    .parameter "x1"

    .prologue
    .line 1023
    invoke-direct {p0, p1}, Lcom/htc/widget/AbsSpinner$WaveRunnable;-><init>(Lcom/htc/widget/AbsSpinner;)V

    return-void
.end method

.method static synthetic access$1500(Lcom/htc/widget/AbsSpinner$WaveRunnable;)V
    .locals 0
    .parameter "x0"

    .prologue
    .line 1023
    invoke-direct {p0}, Lcom/htc/widget/AbsSpinner$WaveRunnable;->end()V

    return-void
.end method

.method private changeWidthHeight(I)V
    .locals 2
    .parameter "step"

    .prologue
    .line 1143
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    #getter for: Lcom/htc/widget/AbsSpinner;->isPortrait:Z
    invoke-static {v0}, Lcom/htc/widget/AbsSpinner;->access$700(Lcom/htc/widget/AbsSpinner;)Z

    move-result v0

    if-eqz v0, :cond_0

    .line 1145
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    iget-object v1, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    #getter for: Lcom/htc/widget/AbsSpinner;->mExpandedWidth:I
    invoke-static {v1}, Lcom/htc/widget/AbsSpinner;->access$900(Lcom/htc/widget/AbsSpinner;)I

    move-result v1

    add-int/2addr v1, p1

    #setter for: Lcom/htc/widget/AbsSpinner;->mExpandedWidth:I
    invoke-static {v0, v1}, Lcom/htc/widget/AbsSpinner;->access$902(Lcom/htc/widget/AbsSpinner;I)I

    .line 1146
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    iget-object v1, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    #getter for: Lcom/htc/widget/AbsSpinner;->mReducedWidth:I
    invoke-static {v1}, Lcom/htc/widget/AbsSpinner;->access$800(Lcom/htc/widget/AbsSpinner;)I

    move-result v1

    sub-int/2addr v1, p1

    #setter for: Lcom/htc/widget/AbsSpinner;->mReducedWidth:I
    invoke-static {v0, v1}, Lcom/htc/widget/AbsSpinner;->access$802(Lcom/htc/widget/AbsSpinner;I)I

    .line 1153
    :goto_0
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v0}, Lcom/htc/widget/AbsSpinner;->requestLayout()V

    .line 1154
    return-void

    .line 1150
    :cond_0
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    iget-object v1, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    #getter for: Lcom/htc/widget/AbsSpinner;->mExpandedHeight:I
    invoke-static {v1}, Lcom/htc/widget/AbsSpinner;->access$1100(Lcom/htc/widget/AbsSpinner;)I

    move-result v1

    add-int/2addr v1, p1

    #setter for: Lcom/htc/widget/AbsSpinner;->mExpandedHeight:I
    invoke-static {v0, v1}, Lcom/htc/widget/AbsSpinner;->access$1102(Lcom/htc/widget/AbsSpinner;I)I

    .line 1151
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    iget-object v1, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    #getter for: Lcom/htc/widget/AbsSpinner;->mReducedHeight:I
    invoke-static {v1}, Lcom/htc/widget/AbsSpinner;->access$1000(Lcom/htc/widget/AbsSpinner;)I

    move-result v1

    sub-int/2addr v1, p1

    #setter for: Lcom/htc/widget/AbsSpinner;->mReducedHeight:I
    invoke-static {v0, v1}, Lcom/htc/widget/AbsSpinner;->access$1002(Lcom/htc/widget/AbsSpinner;I)I

    goto :goto_0
.end method

.method private end()V
    .locals 3

    .prologue
    const/4 v2, 0x0

    .line 1158
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v0, p0}, Lcom/htc/widget/AbsSpinner;->removeCallbacks(Ljava/lang/Runnable;)Z

    .line 1160
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    #getter for: Lcom/htc/widget/AbsSpinner;->isPortrait:Z
    invoke-static {v0}, Lcom/htc/widget/AbsSpinner;->access$700(Lcom/htc/widget/AbsSpinner;)Z

    move-result v0

    if-eqz v0, :cond_0

    .line 1162
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    iget-object v1, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v1}, Lcom/htc/widget/AbsSpinner;->getLayoutParamsWidth()I

    move-result v1

    mul-int/lit8 v1, v1, 0x2

    add-int/lit8 v1, v1, -0x1

    #setter for: Lcom/htc/widget/AbsSpinner;->mExpandedWidth:I
    invoke-static {v0, v1}, Lcom/htc/widget/AbsSpinner;->access$902(Lcom/htc/widget/AbsSpinner;I)I

    .line 1163
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    iget-object v1, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v1}, Lcom/htc/widget/AbsSpinner;->getLayoutParamsWidth()I

    move-result v1

    #setter for: Lcom/htc/widget/AbsSpinner;->mReducedWidth:I
    invoke-static {v0, v1}, Lcom/htc/widget/AbsSpinner;->access$802(Lcom/htc/widget/AbsSpinner;I)I

    .line 1171
    :goto_0
    iput v2, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->mMode:I

    .line 1172
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    #setter for: Lcom/htc/widget/AbsSpinner;->mWaveRunnableRunning:Z
    invoke-static {v0, v2}, Lcom/htc/widget/AbsSpinner;->access$1202(Lcom/htc/widget/AbsSpinner;Z)Z

    .line 1173
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    #getter for: Lcom/htc/widget/AbsSpinner;->mLateShrinkedFlag:Z
    invoke-static {v0}, Lcom/htc/widget/AbsSpinner;->access$1300(Lcom/htc/widget/AbsSpinner;)Z

    move-result v0

    if-eqz v0, :cond_1

    .line 1175
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    #setter for: Lcom/htc/widget/AbsSpinner;->mLateShrinkedFlag:Z
    invoke-static {v0, v2}, Lcom/htc/widget/AbsSpinner;->access$1302(Lcom/htc/widget/AbsSpinner;Z)Z

    .line 1176
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    const/4 v1, -0x1

    invoke-virtual {v0, v1}, Lcom/htc/widget/AbsSpinner;->setShrinkedPosition(I)V

    .line 1177
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    #calls: Lcom/htc/widget/AbsSpinner;->onAnimationEnd()V
    invoke-static {v0}, Lcom/htc/widget/AbsSpinner;->access$1400(Lcom/htc/widget/AbsSpinner;)V

    .line 1181
    :goto_1
    return-void

    .line 1167
    :cond_0
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    iget-object v1, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v1}, Lcom/htc/widget/AbsSpinner;->getLayoutParamsHeight()I

    move-result v1

    mul-int/lit8 v1, v1, 0x2

    add-int/lit8 v1, v1, -0x1

    #setter for: Lcom/htc/widget/AbsSpinner;->mExpandedHeight:I
    invoke-static {v0, v1}, Lcom/htc/widget/AbsSpinner;->access$1102(Lcom/htc/widget/AbsSpinner;I)I

    .line 1168
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    iget-object v1, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v1}, Lcom/htc/widget/AbsSpinner;->getLayoutParamsHeight()I

    move-result v1

    #setter for: Lcom/htc/widget/AbsSpinner;->mReducedHeight:I
    invoke-static {v0, v1}, Lcom/htc/widget/AbsSpinner;->access$1002(Lcom/htc/widget/AbsSpinner;I)I

    goto :goto_0

    .line 1180
    :cond_1
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v0}, Lcom/htc/widget/AbsSpinner;->requestLayout()V

    goto :goto_1
.end method

.method private getTargetDistance()I
    .locals 9

    .prologue
    const-wide/16 v7, 0xc8

    .line 1129
    invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J

    move-result-wide v0

    .line 1130
    .local v0, now:J
    const/4 v2, 0x0

    .line 1132
    .local v2, targetDistance:I
    iget-wide v3, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->mStartTime:J

    sub-long v3, v0, v3

    cmp-long v3, v3, v7

    if-ltz v3, :cond_0

    .line 1133
    iget v2, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->mDistance:I

    .line 1137
    :goto_0
    return v2

    .line 1135
    :cond_0
    iget-wide v3, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->mStartTime:J

    sub-long v3, v0, v3

    iget v5, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->mDistance:I

    int-to-long v5, v5

    mul-long/2addr v3, v5

    div-long/2addr v3, v7

    long-to-int v2, v3

    goto :goto_0
.end method

.method private startCommon()V
    .locals 2

    .prologue
    .line 1099
    iget v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->mMode:I

    const/4 v1, 0x1

    if-ne v0, v1, :cond_0

    .line 1100
    invoke-direct {p0}, Lcom/htc/widget/AbsSpinner$WaveRunnable;->end()V

    .line 1101
    :cond_0
    iget-object v0, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v0, p0}, Lcom/htc/widget/AbsSpinner;->removeCallbacks(Ljava/lang/Runnable;)Z

    .line 1102
    return-void
.end method

# virtual methods
.method public run()V
    .locals 3

    .prologue
    .line 1110
    iget v2, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->mMode:I

    if-nez v2, :cond_0

    .line 1111
    invoke-direct {p0}, Lcom/htc/widget/AbsSpinner$WaveRunnable;->end()V

    .line 1126
    :goto_0
    return-void

    .line 1115
    :cond_0
    invoke-direct {p0}, Lcom/htc/widget/AbsSpinner$WaveRunnable;->getTargetDistance()I

    move-result v1

    .line 1116
    .local v1, targetDistance:I
    iget v2, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->mDistance:I

    if-ne v1, v2, :cond_1

    .line 1117
    invoke-direct {p0}, Lcom/htc/widget/AbsSpinner$WaveRunnable;->end()V

    goto :goto_0

    .line 1121
    :cond_1
    iget v2, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->mMovedDistance:I

    sub-int v0, v1, v2

    .line 1122
    .local v0, step:I
    invoke-direct {p0, v0}, Lcom/htc/widget/AbsSpinner$WaveRunnable;->changeWidthHeight(I)V

    .line 1123
    iput v1, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->mMovedDistance:I

    .line 1124
    iget-object v2, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v2, p0}, Lcom/htc/widget/AbsSpinner;->post(Ljava/lang/Runnable;)Z

    goto :goto_0
.end method

.method public start()V
    .locals 11

    .prologue
    const/4 v10, 0x1

    const-wide/high16 v8, 0x3ff8

    .line 1040
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    const/4 v5, -0x1

    iput v5, v4, Lcom/htc/widget/AbsSpinner;->mReducedPos:I

    .line 1042
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    #getter for: Lcom/htc/widget/AbsSpinner;->isPortrait:Z
    invoke-static {v4}, Lcom/htc/widget/AbsSpinner;->access$700(Lcom/htc/widget/AbsSpinner;)Z

    move-result v4

    if-eqz v4, :cond_2

    .line 1044
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    iget-object v5, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v5}, Lcom/htc/widget/AbsSpinner;->getLayoutParamsWidth()I

    move-result v5

    #setter for: Lcom/htc/widget/AbsSpinner;->mReducedWidth:I
    invoke-static {v4, v5}, Lcom/htc/widget/AbsSpinner;->access$802(Lcom/htc/widget/AbsSpinner;I)I

    .line 1045
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    iget-object v5, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v5}, Lcom/htc/widget/AbsSpinner;->getLayoutParamsWidth()I

    move-result v5

    #setter for: Lcom/htc/widget/AbsSpinner;->mExpandedWidth:I
    invoke-static {v4, v5}, Lcom/htc/widget/AbsSpinner;->access$902(Lcom/htc/widget/AbsSpinner;I)I

    .line 1053
    :goto_0
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v4}, Lcom/htc/widget/AbsSpinner;->getFirstVisiblePosition()I

    move-result v1

    .line 1054
    .local v1, firstVisPos:I
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v4}, Lcom/htc/widget/AbsSpinner;->getChildCount()I

    move-result v0

    .line 1056
    .local v0, count:I
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v4}, Lcom/htc/widget/AbsSpinner;->getAdapter()Landroid/widget/SpinnerAdapter;

    move-result-object v4

    if-eqz v4, :cond_0

    .line 1057
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v4}, Lcom/htc/widget/AbsSpinner;->getAdapter()Landroid/widget/SpinnerAdapter;

    move-result-object v4

    invoke-interface {v4}, Landroid/widget/SpinnerAdapter;->getCount()I

    move-result v0

    .line 1059
    :cond_0
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    #getter for: Lcom/htc/widget/AbsSpinner;->isPortrait:Z
    invoke-static {v4}, Lcom/htc/widget/AbsSpinner;->access$700(Lcom/htc/widget/AbsSpinner;)Z

    move-result v4

    if-eqz v4, :cond_4

    .line 1061
    move v2, v1

    .local v2, i:I
    :goto_1
    if-gt v2, v0, :cond_1

    .line 1063
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    sub-int v5, v2, v1

    invoke-virtual {v4, v5}, Lcom/htc/widget/AbsSpinner;->getChildAt(I)Landroid/view/View;

    move-result-object v3

    .line 1064
    .local v3, view:Landroid/view/View;
    if-eqz v3, :cond_3

    invoke-virtual {v3}, Landroid/view/View;->getWidth()I

    move-result v4

    int-to-double v4, v4

    iget-object v6, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v6}, Lcom/htc/widget/AbsSpinner;->getLayoutParamsWidth()I

    move-result v6

    int-to-double v6, v6

    mul-double/2addr v6, v8

    cmpl-double v4, v4, v6

    if-lez v4, :cond_3

    .line 1066
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    iput v2, v4, Lcom/htc/widget/AbsSpinner;->mReducedPos:I

    .line 1067
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    iget-object v5, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v5}, Lcom/htc/widget/AbsSpinner;->getLayoutParamsWidth()I

    move-result v5

    mul-int/lit8 v5, v5, 0x2

    add-int/lit8 v5, v5, -0x1

    #setter for: Lcom/htc/widget/AbsSpinner;->mReducedWidth:I
    invoke-static {v4, v5}, Lcom/htc/widget/AbsSpinner;->access$802(Lcom/htc/widget/AbsSpinner;I)I

    .line 1086
    .end local v3           #view:Landroid/view/View;
    :cond_1
    :goto_2
    invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J

    move-result-wide v4

    iput-wide v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->mStartTime:J

    .line 1087
    invoke-direct {p0}, Lcom/htc/widget/AbsSpinner$WaveRunnable;->startCommon()V

    .line 1089
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    #getter for: Lcom/htc/widget/AbsSpinner;->isPortrait:Z
    invoke-static {v4}, Lcom/htc/widget/AbsSpinner;->access$700(Lcom/htc/widget/AbsSpinner;)Z

    move-result v4

    if-eqz v4, :cond_6

    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v4}, Lcom/htc/widget/AbsSpinner;->getLayoutParamsWidth()I

    move-result v4

    add-int/lit8 v4, v4, -0x1

    :goto_3
    iput v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->mDistance:I

    .line 1091
    iput v10, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->mMode:I

    .line 1092
    const/4 v4, 0x0

    iput v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->mMovedDistance:I

    .line 1093
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    #setter for: Lcom/htc/widget/AbsSpinner;->mWaveRunnableRunning:Z
    invoke-static {v4, v10}, Lcom/htc/widget/AbsSpinner;->access$1202(Lcom/htc/widget/AbsSpinner;Z)Z

    .line 1094
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v4, p0}, Lcom/htc/widget/AbsSpinner;->post(Ljava/lang/Runnable;)Z

    .line 1095
    return-void

    .line 1049
    .end local v0           #count:I
    .end local v1           #firstVisPos:I
    .end local v2           #i:I
    :cond_2
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    iget-object v5, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v5}, Lcom/htc/widget/AbsSpinner;->getLayoutParamsHeight()I

    move-result v5

    #setter for: Lcom/htc/widget/AbsSpinner;->mReducedHeight:I
    invoke-static {v4, v5}, Lcom/htc/widget/AbsSpinner;->access$1002(Lcom/htc/widget/AbsSpinner;I)I

    .line 1050
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    iget-object v5, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v5}, Lcom/htc/widget/AbsSpinner;->getLayoutParamsHeight()I

    move-result v5

    #setter for: Lcom/htc/widget/AbsSpinner;->mExpandedHeight:I
    invoke-static {v4, v5}, Lcom/htc/widget/AbsSpinner;->access$1102(Lcom/htc/widget/AbsSpinner;I)I

    goto/16 :goto_0

    .line 1061
    .restart local v0       #count:I
    .restart local v1       #firstVisPos:I
    .restart local v2       #i:I
    .restart local v3       #view:Landroid/view/View;
    :cond_3
    add-int/lit8 v2, v2, 0x1

    goto :goto_1

    .line 1074
    .end local v2           #i:I
    .end local v3           #view:Landroid/view/View;
    :cond_4
    move v2, v1

    .restart local v2       #i:I
    :goto_4
    if-gt v2, v0, :cond_1

    .line 1076
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    sub-int v5, v2, v1

    invoke-virtual {v4, v5}, Lcom/htc/widget/AbsSpinner;->getChildAt(I)Landroid/view/View;

    move-result-object v3

    .line 1077
    .restart local v3       #view:Landroid/view/View;
    if-eqz v3, :cond_5

    invoke-virtual {v3}, Landroid/view/View;->getHeight()I

    move-result v4

    int-to-double v4, v4

    iget-object v6, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v6}, Lcom/htc/widget/AbsSpinner;->getLayoutParamsHeight()I

    move-result v6

    int-to-double v6, v6

    mul-double/2addr v6, v8

    cmpl-double v4, v4, v6

    if-lez v4, :cond_5

    .line 1079
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    iput v2, v4, Lcom/htc/widget/AbsSpinner;->mReducedPos:I

    .line 1080
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    iget-object v5, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v5}, Lcom/htc/widget/AbsSpinner;->getLayoutParamsHeight()I

    move-result v5

    mul-int/lit8 v5, v5, 0x2

    add-int/lit8 v5, v5, -0x1

    #setter for: Lcom/htc/widget/AbsSpinner;->mReducedHeight:I
    invoke-static {v4, v5}, Lcom/htc/widget/AbsSpinner;->access$1002(Lcom/htc/widget/AbsSpinner;I)I

    goto :goto_2

    .line 1074
    :cond_5
    add-int/lit8 v2, v2, 0x1

    goto :goto_4

    .line 1089
    .end local v3           #view:Landroid/view/View;
    :cond_6
    iget-object v4, p0, Lcom/htc/widget/AbsSpinner$WaveRunnable;->this$0:Lcom/htc/widget/AbsSpinner;

    invoke-virtual {v4}, Lcom/htc/widget/AbsSpinner;->getLayoutParamsHeight()I

    move-result v4

    add-int/lit8 v4, v4, -0x1

    goto :goto_3
.end method


text:
from django.test import TestCase
from django.contrib.auth.models import User
from .. import models

class ProductTestCase(TestCase):
    def setUp(self):
        user_1 = User.objects.create_user(
            username='user_1',
            password='password_1',
        )
        user_2 = User.objects.create_user(
            username='user_2',
            password='password_2',
        )
        product_1 = models.Product.objects.create(
            id=1,
            name='product_1',
            price='29.99',
            stock=3,
            description='',
            image='product_1.jpg',
        )
        product_2 = models.Product.objects.create(
            id=2,
            name='product_2',
            price='999.99',
            stock=15,
            description='',
            image='product_2.jpg',
        )
        order_1 = models.Order.objects.create(user=user_1, total='29.99')
        order_2 = models.Order.objects.create(user=user_2, total='49.98')
        models.OrderItem.objects.create(
            product=product_1,
            order=order_1,
            purchase_price=product_1.price,
            quantity=1,
        )
        models.OrderItem.objects.create(
            product=product_1,
            order=order_2,
            purchase_price=product_1.price,
            quantity=2,
        )
        models.Review.objects.create(
            user=user_1,
            product=product_1,
            title='review_1',
            body='',
            rating=78,
        )
        models.Review.objects.create(
            user=user_2,
            product=product_1,
            title='review_2',
            body='',
            rating=98,
        )

    def test_purchase_count(self):
        '''
        Test purchase_count property on product that has 3 purchases.
        '''

        product = models.Product.objects.get(pk=1)
        self.assertEqual(product.purchase_count, 3)

    def test_no_purchase_count(self):
        '''
        Test purchase_count property on product that has not been purchased.
        '''

        product = models.Product.objects.get(pk=2)
        self.assertEqual(product.purchase_count, 0)

    def test_rating(self):
        '''
        Test rating property on product with 2 reviews.
        '''

        product = models.Product.objects.get(pk=1)
        self.assertEqual(product.rating, 88)

    def test_no_rating(self):
        '''
        Test rating property on product with no reviews.
        '''

        product = models.Product.objects.get(pk=2)
        self.assertEqual(product.rating, 0)

    def test_in_stock(self):
        '''
        Test in_stock property on product that is in stock.
        '''

        product = models.Product.objects.get(pk=2)
        self.assertEqual(product.in_stock, True)

    def test_not_in_stock(self):
        '''
        Test in_stock property on product that is not in stock.
        '''

        product = models.Product.objects.get(pk=1)
        self.assertEqual(product.in_stock, False)


text:
package org.apache.shardingsphere.encrypt.distsql.handler.converter;

import org.apache.shardingsphere.encrypt.api.config.EncryptRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptColumnRuleConfiguration;
import org.apache.shardingsphere.encrypt.api.config.rule.EncryptTableRuleConfiguration;
import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptColumnSegment;
import org.apache.shardingsphere.encrypt.distsql.parser.segment.EncryptRuleSegment;
import org.apache.shardingsphere.infra.config.algorithm.ShardingSphereAlgorithmConfiguration;

import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * Encrypt rule statement converter.
 */
public final class EncryptRuleStatementConverter {

    /**
     * Convert encrypt rule segments to encrypt rule configuration.
     *
     * @param ruleSegments encrypt rule segments
     * @return encrypt rule configuration
     */
    public static EncryptRuleConfiguration convert(final Collection<EncryptRuleSegment> ruleSegments) {
        Collection<EncryptTableRuleConfiguration> tables = new LinkedList<>();
        Map<String, ShardingSphereAlgorithmConfiguration> encryptors = new HashMap<>();
        for (EncryptRuleSegment each : ruleSegments) {
            tables.add(createEncryptTableRuleConfiguration(each));
            encryptors.putAll(createEncryptorConfigurations(each));
        }
        return new EncryptRuleConfiguration(tables, encryptors);
    }

    private static EncryptTableRuleConfiguration createEncryptTableRuleConfiguration(final EncryptRuleSegment ruleSegment) {
        Collection<EncryptColumnRuleConfiguration> columns = new LinkedList<>();
        for (EncryptColumnSegment each : ruleSegment.getColumns()) {
            columns.add(createEncryptColumnRuleConfiguration(ruleSegment.getTableName(), each));
        }
        return new EncryptTableRuleConfiguration(ruleSegment.getTableName(), columns, ruleSegment.getQueryWithCipherColumn());
    }

    private static EncryptColumnRuleConfiguration createEncryptColumnRuleConfiguration(final String tableName, final EncryptColumnSegment columnSegment) {
        return new EncryptColumnRuleConfiguration(columnSegment.getName(), columnSegment.getDataType(), columnSegment.getCipherColumn(),
                columnSegment.getCipherDataType(), columnSegment.getAssistedQueryColumn(), columnSegment.getAssistedQueryDataType(),
                columnSegment.getPlainColumn(), columnSegment.getPlainDataType(), getEncryptorName(tableName, columnSegment.getName()));
    }

    private static Map<String, ShardingSphereAlgorithmConfiguration> createEncryptorConfigurations(final EncryptRuleSegment ruleSegment) {
        return ruleSegment.getColumns().stream().collect(Collectors
                .toMap(each -> getEncryptorName(ruleSegment.getTableName(), each.getName()), EncryptRuleStatementConverter::createEncryptorConfiguration));
    }

    private static ShardingSphereAlgorithmConfiguration createEncryptorConfiguration(final EncryptColumnSegment columnSegment) {
        return new ShardingSphereAlgorithmConfiguration(columnSegment.getEncryptor().getName(), columnSegment.getEncryptor().getProps());
    }

    private static String getEncryptorName(final String tableName, final String columnName) {
        return String.format("%s_%s", tableName, columnName);
    }
}


text:
<?php

namespace serverdensity\HttpClient;

use serverdensity\Exception\TwoFactorAuthenticationRequiredException;
use serverdensity\Exception\ErrorException;
use serverdensity\Exception\RuntimeException;
use serverdensity\HttpClient\Listener\AuthListener;
use serverdensity\HttpClient\Listener\ErrorListener;

use GuzzleHttp\Event\HasEmitterTrait;
use GuzzleHttp\Event\BeforeEvent;
use GuzzleHttp\Event\ErrorEvent;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Message\Request;
use GuzzleHttp\Message\Response;
use ReflectionClass;

/**
 * Performs requests on Server Density API. API documentation should be self-explanatory.
 *
 * @author Joseph Bielawski <stloyd@gmail.com>
 */
class HttpClient implements HttpClientInterface
{

    protected $options = array(
        'base_url'    => 'https://api.serverdensity.io/',
        'defaults'    => [
            'headers' => ['user-agent' => 'SD-php-api']],

        'timeout'     => 10,
        // 'api_limit'   => 5000,
        // 'api_version' => 'v2',
    );

    protected $headers = array();

    private $lastResponse;
    private $lastRequest;
    public $client;

    /**
     * @param array           $options
     * @param ClientInterface $client
     */
    public function __construct(array $options = array(), ClientInterface $client = null)
    {
        $this->options = array_merge($this->options, $options);
        $client = $client ?: new GuzzleClient($this->options);
        $this->client  = $client;
        $options = $this->options;

        $this->client->getEmitter()->on(
            'error', function (ErrorEvent $event) use ($options){
                $listener = new ErrorListener($this->options);
                $listener->onRequestError($event);
        });

        // $this->clearHeaders();
    }

    /**
     * {@inheritDoc}
     */
    public function setOption($name, $value)
    {
        $this->options[$name] = $value;
    }

    /**
     * {@inheritDoc}
     */
    public function setHeaders(array $headers)
    {
        $this->headers = array_merge($this->headers, $headers);
    }

    /**
     * Clears used headers.
     */
    public function clearHeaders()
    {
        // $this->headers = array(
        //     'Accept' => sprintf('application/vnd.github.%s+json', $this->options['api_version']),
        //     'User-Agent' => sprintf('%s', $this->options['defaults']['headers']['user-agent']),
        // );
    }

    public function addListener($eventName, $listener)
    {
        $emitter = $this->client->getEmitter();
        $emitter->on($eventName, $listener);
        // $this->client->getEventDispatcher()->addListener($eventName, $listener);
    }

    // public function addSubscriber(EventSubscriberInterface $subscriber)
    // {
    //     $this->client->addSubscriber($subscriber);
    // }

    /**
     * {@inheritDoc}
     */
    public function get($path, array $parameters = array(), array $headers = array())
    {
        return $this->request($path, null, 'GET', $headers, array('query' => $parameters));
    }

    /**
     * {@inheritDoc}
     */
    public function post($path, $body = null, array $headers = array())
    {
        return $this->request($path, $body, 'POST', $headers);
    }

    /**
     * {@inheritDoc}
     */
    public function patch($path, $body = null, array $headers = array())
    {
        return $this->request($path, $body, 'PATCH', $headers);
    }

    /**
     * {@inheritDoc}
     */
    public function delete($path, $body = null, array $headers = array())
    {
        return $this->request($path, $body, 'DELETE', $headers);
    }

    /**
     * {@inheritDoc}
     */
    public function put($path, $body, array $headers = array())
    {
        return $this->request($path, $body, 'PUT', $headers);
    }

    /**
     * {@inheritDoc}
     */
    public function request($path, $body = null, $httpMethod = 'GET', array $headers = array(), array $options = array())
    {
        if(!empty($body)){
            $options = array_merge($options, ['body' => $body]);
        }

        if(!empty($headers)){
            $options = array_merge($options, ['headers' => $headers]);
        }

        $request = $this->client->createRequest($httpMethod, $path, $options);

        // Errors handled in ErrorListener.php
        $response = $this->client->send($request);

        $this->lastRequest  = $request;
        $this->lastResponse = $response;

        return $response;
    }

    /**
     * {@inheritDoc}
     */
    public function authenticate($token, $method)
    {
        $this->client->getEmitter()->on(
            'before', function (BeforeEvent $event) use ($token, $method){
                $auth = new AuthListener($token, $method);
                $auth->onRequestBeforeSend($event);
            });
    }

    /**
     * @return Request
     */
    public function getLastRequest()
    {
        return $this->lastRequest;
    }

    /**
     * @return Response
     */
    public function getLastResponse()
    {
        return $this->lastResponse;
    }

}


text:
<?xml version="1.0" encoding="UTF-8"?>
<!--

  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements. See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership. The ASF licenses this file
  to you 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.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <artifactId>apache-lens</artifactId>
    <groupId>org.apache.lens</groupId>
    <version>2.5.0-beta-SNAPSHOT</version>
  </parent>

  <artifactId>lens-client</artifactId>
  <packaging>jar</packaging>
  <name>Lens client</name>
  <description>Lens client</description>

  <dependencies>
    <dependency>
      <groupId>org.apache.lens</groupId>
      <artifactId>lens-api</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.lens</groupId>
      <artifactId>lens-server</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
      <type>test-jar</type>
    </dependency>
    <dependency>
      <groupId>org.apache.lens</groupId>
      <artifactId>lens-server</artifactId>
      <version>${project.version}</version>
      <classifier>classes</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.hive</groupId>
      <artifactId>hive-exec</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.hive</groupId>
      <artifactId>hive-service</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-client</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.lens</groupId>
      <artifactId>lens-driver-hive</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
      <type>test-jar</type>
    </dependency>
    <dependency>
      <groupId>org.apache.lens</groupId>
      <artifactId>lens-driver-jdbc</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jersey.media</groupId>
      <artifactId>jersey-media-multipart</artifactId>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jersey.test-framework.providers</groupId>
      <artifactId>jersey-test-framework-provider-grizzly2</artifactId>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jersey.test-framework</groupId>
      <artifactId>jersey-test-framework-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </dependency>
    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jersey.core</groupId>
      <artifactId>jersey-client</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.lens</groupId>
      <artifactId>lens-server-api</artifactId>
      <type>test-jar</type>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-all</artifactId>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>log4j-over-slf4j</artifactId>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jcl-over-slf4j</artifactId>
    </dependency>
  </dependencies>
</project>


text:
function [OutColourProbabilities, OutColourPoints, GroundTruth] = ReplaceColourProbabilities(ColourProbabilities, ColourPoints, GroundTruthNames)
%ReplaceColourProbabilities  replaces the segmented colour probabilities
%                            with  values of ground truth.
%
%

OutColourProbabilities = ColourProbabilities;
OutColourPoints = ColourPoints;

WcsColourTable = WcsChart();
GroundTruth = WcsResults(GroundTruthNames);

GroundTruthBinary = GroundTruth;
nColourCategories = size(GroundTruthBinary, 3);
parfor c = 1:nColourCategories
  CurrentChannel = GroundTruthBinary(:, :, c);
  CurrentChannel(CurrentChannel > 0) = 1;
  GroundTruthBinary(:, :, c) = CurrentChannel;
end

nGts = numel(GroundTruthNames);
[rows, cols, ~] = size(WcsColourTable);
for i = 1:rows
  for j = 1:cols
    rgb = reshape(WcsColourTable(i, j, :), 1, 3);
    founds = ismember(ColourPoints, rgb, 'rows');
    if sum(founds) > 0
      OutColourProbabilities(founds, 1, :) = GroundTruthBinary(i, j, :);
      GroundTruth(i, j, :) = (GroundTruth(i, j, :) * nGts + ColourProbabilities(founds, 1, :)) ./ (nGts + 1);
    else
      OutColourProbabilities(end + 1, :) = GroundTruthBinary(i, j, :); %#ok
      OutColourPoints(end + 1, :) = rgb; %#ok
    end
  end
end

end