text:
import React, { Component, PropTypes } from 'react';
import ReactDOM from 'react-dom';
import { connect } from 'react-redux';

import classNames from 'classnames';

import Immutable from 'immutable';

import connectToTailer from './connectToTailer';

import * as Selectors from '../selectors';

import LogLines, { LOG_LINE_HEIGHT } from './LogLines';

const SCROLL_LOAD_THRESHOLD = 300;

class Log extends Component {
  constructor() {
    super();

    this.isLineLoaded = this.isLineLoaded.bind(this);
    this.loadLine = this.loadLine.bind(this);
    this.tailLog = this.tailLog.bind(this);
    this.pollScroll = this.pollScroll.bind(this);
    this.handleTail = this.handleTail.bind(this);
    this.getTailDelayMs = this.getTailDelayMs.bind(this);
    this.scheduleNextHandleTail = this.scheduleNextHandleTail.bind(this);

    this.scrollTop = undefined;
    this.scrollHeight = undefined;
    this.invalidate = false;

    this.fakeLineCount = 0;
    this.scrollDelta = 0;

    this.tailAttempt = 0;

    this.state = {
      tailing: false
    };
  }

  componentWillMount() {
    if (this.props.goToOffset === -1 && !this.state.tailing) {
      this.setState({
        tailing: true
      });
    }
  }

  componentDidMount() {
    if (!this.props.isLoaded) {
      this.props.initializeFile(this.props.goToOffset);
    } else {
      this.tailLog();
    }

    this.rafRequestId = window.requestAnimationFrame(this.pollScroll);
  }

  componentWillUpdate(nextProps, nextState) {
    if (nextProps.lines !== this.props.lines) {
      this.invalidate = true;
      if (this.state.tailing) {
        this.scrollDelta = -1;
      }
    }

    if (nextProps.lines.size > 1 && this.props.lines.size > 1) {
      const oldLines = this.props.lines;
      const newLines = nextProps.lines;

      const addedToBeginning = newLines.findIndex((l) => { return l.start >= oldLines.get(0).end; }) - 1;
      const removedFromBeginning = oldLines.findIndex((l) => { return l.end >= newLines.get(0).end; });

      if (removedFromBeginning) {
        this.fakeLineCount += removedFromBeginning - 1;
      }

      if (addedToBeginning) {
        if (this.fakeLineCount - addedToBeginning >= 0) {
          this.fakeLineCount -= addedToBeginning;
        } else {
          this.scrollDelta += LOG_LINE_HEIGHT * (addedToBeginning - this.fakeLineCount);
          this.fakeLineCount = 0;
        }
      }
    }

    if (nextState.tailing && this.tailTimeoutId == null) {
      this.handleTail()
    } else if (!nextState.tailing && this.tailTimeoutId != null) {
      clearTimeout(this.tailTimeoutId);
      this.tailTimeoutId = null;
    }
  }

  getTailDelayMs() {
    return Math.min(this.props.maxTailDelayMs, Math.max(this.props.minTailDelayMs, this.props.calculateTailDelayMs(this.tailAttempt)));
  }

  scheduleNextHandleTail() {
    if (this.state.tailing) {
      this.tailTimeoutId = setTimeout(this.handleTail, this.getTailDelayMs());
    }
  }

  handleTail() {
    if (this.props.lines.size > 1) {
      this.loadLine(this.props.lines.size - 1, false).then((data) => {
        if (data && data.hasOwnProperty('chunk')) {
          if (data.chunk.start === data.chunk.end) {
            this.tailAttempt++;
          } else {
            this.tailAttempt = 0;
          }
        }
        this.scheduleNextHandleTail();
      });
    } else {
      this.scheduleNextHandleTail();
    }
  }

  componentDidUpdate(prevProps) {
    const idMatches = this.props.tailerId === prevProps.tailerId;
    const offsetMatches = this.props.goToOffset === prevProps.goToOffset;

    if (!idMatches || !offsetMatches) {
      this.props.initializeFile(this.props.goToOffset);
    }
  }

  componentWillUnmount() {
    window.cancelAnimationFrame(this.rafRequestId);
    clearInterval(this.tailTimeoutId);
  }

  isLineLoaded(index) {
    return (
      index < this.props.lines.size
      && (
        !this.props.lines.get(index).isMissingMarker &&
        !this.props.requests.has(this.props.lines.get(index).start)
      )
    );
  }

  // detect when dom has changed underneath us- either scrollTop or scrollHeight (layout reflow)
  // may have changed.
  pollScroll () {
    const domNode = ReactDOM.findDOMNode(this);

    // let's update the scroll now, in a raf.
    if (this.scrollDelta > 0) {
      domNode.scrollTop += this.scrollDelta;
      this.scrollDelta = 0;
    } else if (this.scrollDelta === -1) {
      domNode.scrollTop = domNode.scrollHeight;
      this.scrollDelta = 0;
    }

    const { scrollTop, scrollHeight, clientHeight } = domNode;
    if (scrollTop !== this.scrollTop || this.invalidate) {
      this.invalidate = false;
      const scrollLoadThreshold = LOG_LINE_HEIGHT * SCROLL_LOAD_THRESHOLD;
      const nearTop = (scrollTop - this.fakeLineCount * LOG_LINE_HEIGHT) <= scrollLoadThreshold;
      const nearBottom = scrollTop >= (scrollHeight - clientHeight - scrollLoadThreshold);
      const atBottom = scrollTop >= (scrollHeight - clientHeight - 1);

      const { lines } = this.props;
      if (nearTop && nearBottom && lines.size === 1) {
        // wait until the first chunk is loaded.
      } else {
        // we are at the top/bottom, load some stuff.
        if (nearTop && !this.isLineLoaded(0)) {
          // don't dispatch in the raf, do it later
          setTimeout(() => this.loadLine(0, true), 0);
        }

        if (nearBottom && lines.size) {
          // if we haven't reached the end of the file yet
          if (lines.last().isMissingMarker) {
            // don't dispatch in the raf, do it later
            setTimeout(() => this.loadLine(lines.size - 1, false), 0);
          } else if (atBottom) {
            // we're tailing here.
            if (!this.state.tailing) {
              this.setState({
                tailing: true
              });
            }
          }
        }
      }

      if (!atBottom && this.state.tailing) {
        this.setState({
          tailing: false
        });
      }
      // update the scroll position.
      this.scrollTop = domNode.scrollTop;
      this.scrollHeight = domNode.scrollHeight;
    }
    // do another raf.
    this.rafRequestId = window.requestAnimationFrame(this.pollScroll);
  }

  loadLine(index, loadUp) {
    return this.props.loadLine(
      index,
      loadUp,
      this.props.lines,
      this.props.chunks
    );
  }

  tailLog() {
    return this.props.tailLog(this.props.lines);
  }

  render() {
    const { props } = this;

    const hrefFunc = props.hrefFunc
      ? (offset) => props.hrefFunc(props.tailerId, offset)
      : undefined;

    const logPaneClasses = classNames({
      'log-pane': true,
      tailing: this.state.tailing
    });

    return (

          <LogLines
            isLoaded={props.isLoaded}
            lines={props.lines}
            fakeLineCount={this.fakeLineCount}
            isLineLoaded={this.isLineLoaded}
            hrefFunc={hrefFunc}
            lineLinkRenderer={props.lineLinkRenderer}
            highlightedOffset={props.goToOffset}
          />

    );
  }
}

Log.propTypes = {
  tailerId: PropTypes.string.isRequired,
  goToOffset: PropTypes.number,
  hrefFunc: PropTypes.func,
  minTailDelayMs: PropTypes.number.isRequired,
  maxTailDelayMs: PropTypes.number.isRequired,
  calculateTailDelayMs: PropTypes.func.isRequired,
  // from connectToTailer HOC
  getTailerState: PropTypes.func.isRequired,
  // from tailer implementation
  // actions
  initializeFile: PropTypes.func.isRequired,
  loadLine: PropTypes.func.isRequired,
  tailLog: PropTypes.func.isRequired,
  // from connect
  isLoaded: PropTypes.bool.isRequired,
  fileSize: PropTypes.number,
  lines: PropTypes.instanceOf(Immutable.List),
  chunks: PropTypes.instanceOf(Immutable.List),
  requests: PropTypes.instanceOf(Immutable.Map),
  config: PropTypes.object.isRequired,
  lineLinkRenderer: PropTypes.func
};

Log.defaultProps = {
  minTailDelayMs: 100,
  maxTailDelayMs: 5000,
  calculateTailDelayMs: (attempt) => 100 * attempt
};

const makeMapStateToProps = () => {
  const getEnhancedLines = Selectors.makeGetEnhancedLines();
  const mapStateToProps = (state, ownProps) => ({
    isLoaded: Selectors.getIsLoaded(state, ownProps),
    fileSize: Selectors.getFileSize(state, ownProps),
    lines: getEnhancedLines(state, ownProps),
    chunks: Selectors.getChunks(state, ownProps),
    requests: Selectors.getRequests(state, ownProps),
    config: Selectors.getConfig(state, ownProps)
  });
  return mapStateToProps;
};

export default connectToTailer(connect(
  makeMapStateToProps
)(Log));


text:
package com.facebook.buck.util;

import com.facebook.buck.util.function.ThrowingConsumer;
import com.google.common.base.Supplier;
import java.util.function.Consumer;

/**
 * Convenience wrapper class to attach closeable functionality to suppliers of resources to be
 * closed. Suppliers will be memoized such that the resources are only closed if we have requested
 * them.
 *
 *
Example:
 *
 *
{@code
 * class Main {
 *  public static void main() {
 *    try (CloseableMemoizedSupplier<Resource> closeableSupplier =
 *        CloseableMemoizedSupplier.of(Resource::new, resource::shutDown)) {
 *      if (condition) {
 *        useResource(closeableSupplier.get())
 *      }
 *    }
 *  }
 * }
 *
 * }

 *
 *
The above will only construct the Resource if condition is true, and close the constructed
 * resource appropriately.
 */
public class CloseableMemoizedSupplier<T>
    extends AbstractCloseableMemoizedSupplier<T, RuntimeException> {

  private CloseableMemoizedSupplier(
      Supplier<T> supplier, ThrowingConsumer<T, RuntimeException> closer) {
    super(supplier, closer);
  }

  /**
   * Wrap a supplier with {@code AutoCloseable} interface and close only if the supplier has been
   * used. Close is idempotent.
   *
   * @param supplier the Supplier of a resource to be closed
   * @param closer the method to close the resource
   */
  public static <T, E extends Exception> CloseableMemoizedSupplier<T> of(
      Supplier<T> supplier, Consumer<T> closer) {
    return new CloseableMemoizedSupplier<>(supplier, toClose -> closer.accept(toClose));
  }
}

redpajama_set_name: RedPajamaGithub


text:
package com.amazonaws.services.lambda.model;

import java.io.Serializable;
import javax.annotation.Generated;

import com.amazonaws.AmazonWebServiceRequest;

/**
 *
 * @see AWS API
 *      Documentation
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class UntagResourceRequest extends com.amazonaws.AmazonWebServiceRequest implements Serializable, Cloneable {

    /**
     *

     * The function's Amazon Resource Name (ARN).
     *

     */
    private String resource;
    /**
     *

     * A list of tag keys to remove from the function.
     *

     */
    private com.amazonaws.internal.SdkInternalList<String> tagKeys;

    /**
     *

     * The function's Amazon Resource Name (ARN).
     *

     *
     * @param resource
     *        The function's Amazon Resource Name (ARN).
     */

    public void setResource(String resource) {
        this.resource = resource;
    }

    /**
     *

     * The function's Amazon Resource Name (ARN).
     *

     *
     * @return The function's Amazon Resource Name (ARN).
     */

    public String getResource() {
        return this.resource;
    }

    /**
     *

     * The function's Amazon Resource Name (ARN).
     *

     *
     * @param resource
     *        The function's Amazon Resource Name (ARN).
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UntagResourceRequest withResource(String resource) {
        setResource(resource);
        return this;
    }

    /**
     *

     * A list of tag keys to remove from the function.
     *

     *
     * @return A list of tag keys to remove from the function.
     */

    public java.util.List<String> getTagKeys() {
        if (tagKeys == null) {
            tagKeys = new com.amazonaws.internal.SdkInternalList<String>();
        }
        return tagKeys;
    }

    /**
     *

     * A list of tag keys to remove from the function.
     *

     *
     * @param tagKeys
     *        A list of tag keys to remove from the function.
     */

    public void setTagKeys(java.util.Collection<String> tagKeys) {
        if (tagKeys == null) {
            this.tagKeys = null;
            return;
        }

        this.tagKeys = new com.amazonaws.internal.SdkInternalList<String>(tagKeys);
    }

    /**
     *

     * A list of tag keys to remove from the function.
     *

     *

     * NOTE: This method appends the values to the existing list (if any). Use
     * {@link #setTagKeys(java.util.Collection)} or {@link #withTagKeys(java.util.Collection)} if you want to override
     * the existing values.
     *

     *
     * @param tagKeys
     *        A list of tag keys to remove from the function.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UntagResourceRequest withTagKeys(String... tagKeys) {
        if (this.tagKeys == null) {
            setTagKeys(new com.amazonaws.internal.SdkInternalList<String>(tagKeys.length));
        }
        for (String ele : tagKeys) {
            this.tagKeys.add(ele);
        }
        return this;
    }

    /**
     *

     * A list of tag keys to remove from the function.
     *

     *
     * @param tagKeys
     *        A list of tag keys to remove from the function.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public UntagResourceRequest withTagKeys(java.util.Collection<String> tagKeys) {
        setTagKeys(tagKeys);
        return this;
    }

    /**
     * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
     * redacted from this string using a placeholder value.
     *
     * @return A string representation of this object.
     *
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getResource() != null)
            sb.append("Resource: ").append(getResource()).append(",");
        if (getTagKeys() != null)
            sb.append("TagKeys: ").append(getTagKeys());
        sb.append("}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;

        if (obj instanceof UntagResourceRequest == false)
            return false;
        UntagResourceRequest other = (UntagResourceRequest) obj;
        if (other.getResource() == null ^ this.getResource() == null)
            return false;
        if (other.getResource() != null && other.getResource().equals(this.getResource()) == false)
            return false;
        if (other.getTagKeys() == null ^ this.getTagKeys() == null)
            return false;
        if (other.getTagKeys() != null && other.getTagKeys().equals(this.getTagKeys()) == false)
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;

        hashCode = prime * hashCode + ((getResource() == null) ? 0 : getResource().hashCode());
        hashCode = prime * hashCode + ((getTagKeys() == null) ? 0 : getTagKeys().hashCode());
        return hashCode;
    }

    @Override
    public UntagResourceRequest clone() {
        return (UntagResourceRequest) super.clone();
    }

}


text:
<?php

/**
 * Pheanstalk is a pure PHP 5.2+ client for the beanstalkd workqueue.
 * The Pheanstalk class is a simple facade for the various underlying components.
 *
 * @see http://github.com/kr/beanstalkd
 * @see http://xph.us/software/beanstalkd/
 *
 * @author Paul Annesley
 * @package Pheanstalk
 * @licence http://www.opensource.org/licenses/mit-license.php
 */

$pheanstalkClassRoot = dirname(__FILE__);
require_once($pheanstalkClassRoot . '/Pheanstalk/ClassLoader.php');

Pheanstalk_ClassLoader::register($pheanstalkClassRoot);

class Pheanstalk
{
	const DEFAULT_PORT = 11300;
	const DEFAULT_DELAY = 0; // no delay
	const DEFAULT_PRIORITY = 1024; // most urgent: 0, least urgent: 4294967295
	const DEFAULT_TTR = 60; // 1 minute

	private $_connection;

	/**
	 * @param string $host
	 * @param int $port
	 */
	public function __construct($host, $port = self::DEFAULT_PORT, $connectTimeout = null)
	{
		$this->setConnection(new Pheanstalk_Connection($host, $port, $connectTimeout));
	}

	/**
	 * @param Pheanstalk_Connection
	 * @chainable
	 */
	public function setConnection($connection)
	{
		$this->_connection = $connection;
		return $this;
	}

	// ----------------------------------------

	/**
	 * Puts a job into a 'buried' state, revived only by 'kick' command.
	 *
	 * @param Pheanstalk_Job $job
	 * @return void
	 */
	public function bury($job, $priority = self::DEFAULT_PRIORITY)
	{
		$this->_dispatch(new Pheanstalk_Command_BuryCommand($job, $priority));
	}

	/**
	 * Permanently deletes a job.
	 *
	 * @param object $job Pheanstalk_Job
	 * @chainable
	 */
	public function delete($job)
	{
		$this->_dispatch(new Pheanstalk_Command_DeleteCommand($job));
		return $this;
	}

	/**
	 * Remove the specified tube from the watchlist
	 *
	 * @param string $tube
	 * @chainable
	 */
	public function ignore($tube)
	{
		$this->_dispatch(new Pheanstalk_Command_IgnoreCommand($tube));
		return $this;
	}

	/**
	 * Kicks buried or delayed jobs into a 'ready' state.
	 * If there are buried jobs, it will kick up to $max of them.
	 * Otherwise, it will kick up to $max delayed jobs.
	 *
	 * @param int $max The maximum jobs to kick
	 * @return int Number of jobs kicked
	 */
	public function kick($max)
	{
		$response = $this->_dispatch(new Pheanstalk_Command_KickCommand($max));
		return $response['kicked'];
	}

	/**
	 * The names of all tubes on the server.
	 *
	 * @return array
	 */
	public function listTubes()
	{
		return (array) $this->_dispatch(
			new Pheanstalk_Command_ListTubesCommand()
		);
	}

	/**
	 * The names of the tubes being watched, to reserve jobs from.
	 *
	 * @return array
	 */
	public function listTubesWatched()
	{
		return (array) $this->_dispatch(
			new Pheanstalk_Command_ListTubesWatchedCommand()
		);
	}

	/**
	 * The name of the current tube used for publishing jobs to.
	 *
	 * @return string
	 */
	public function listTubeUsed()
	{
		$response = $this->_dispatch(
			new Pheanstalk_Command_ListTubeUsedCommand()
		);

		return $response['tube'];
	}

	/**
	 * Temporarily prevent jobs being reserved from the given tube.
	 *
	 * @param string $tube The tube to pause
	 * @param int $delay Seconds before jobs may be reserved from this queue.
	 * @chainable
	 */
	public function pauseTube($tube, $delay)
	{
		$this->_dispatch(new Pheanstalk_Command_PauseTubeCommand($tube, $delay));
		return $this;
	}

	/**
	 * Inspect a job in the system, regardless of what tube it is in.
	 *
	 * @param int $jobId
	 * @return object Pheanstalk_Job
	 */
	public function peek($jobId)
	{
		$response = $this->_dispatch(
			new Pheanstalk_Command_PeekCommand($jobId)
		);

		return new Pheanstalk_Job($response['id'], $response['jobdata']);
	}

	/**
	 * Inspect the next ready job in the currently used tube.
	 *
	 * @return object Pheanstalk_Job
	 */
	public function peekReady()
	{
		$response = $this->_dispatch(
			new Pheanstalk_Command_PeekCommand(Pheanstalk_Command_PeekCommand::TYPE_READY)
		);

		return new Pheanstalk_Job($response['id'], $response['jobdata']);
	}

	/**
	 * Inspect the shortest-remaining-delayed job in the currently used tube.
	 *
	 * @return object Pheanstalk_Job
	 */
	public function peekDelayed()
	{
		$response = $this->_dispatch(
			new Pheanstalk_Command_PeekCommand(Pheanstalk_Command_PeekCommand::TYPE_DELAYED)
		);

		return new Pheanstalk_Job($response['id'], $response['jobdata']);
	}

	/**
	 * Inspect the next job in the list of buried jobs of the currently used tube.
	 *
	 * @return object Pheanstalk_Job
	 */
	public function peekBuried()
	{
		$response = $this->_dispatch(
			new Pheanstalk_Command_PeekCommand(Pheanstalk_Command_PeekCommand::TYPE_BURIED)
		);

		return new Pheanstalk_Job($response['id'], $response['jobdata']);
	}

	/**
	 * Puts a job on the queue.
	 *
	 * @param string $data The job data
	 * @param int $priority From 0 (most urgent) to 0xFFFFFFFF (least urgent)
	 * @param int $delay Seconds to wait before job becomes ready
	 * @param int $ttr Time To Run: seconds a job can be reserved for
	 * @return int The new job ID
	 */
	public function put(
		$data,
		$priority = self::DEFAULT_PRIORITY,
		$delay = self::DEFAULT_DELAY,
		$ttr = self::DEFAULT_TTR
	)
	{
		$response = $this->_dispatch(
			new Pheanstalk_Command_PutCommand($data, $priority, $delay, $ttr)
		);

		return $response['id'];
	}

	/**
	 * Puts a reserved job back into the ready queue.
	 *
	 * Marks the jobs state as "ready" to be run by any client.
	 * It is normally used when the job fails because of a transitory error.
	 *
	 * @param object $job Pheanstalk_Job
	 * @param int $priority From 0 (most urgent) to 0xFFFFFFFF (least urgent)
	 * @param int $delay Seconds to wait before job becomes ready
	 * @chainable
	 */
	public function release(
		$job,
		$priority = self::DEFAULT_PRIORITY,
		$delay = self::DEFAULT_DELAY
	)
	{
		$this->_dispatch(
			new Pheanstalk_Command_ReleaseCommand($job, $priority, $delay)
		);

		return $this;
	}

	/**
	 * Reserves/locks a ready job in a watched tube.
	 *
	 * A non-null timeout uses the 'reserve-with-timeout' instead of 'reserve'.
	 *
	 * A timeout value of 0 will cause the server to immediately return either a
	 * response or TIMED_OUT.  A positive value of timeout will limit the amount of
	 * time the client will block on the reserve request until a job becomes
	 * available.
	 *
	 * @param int $timeout
	 * @return object Pheanstalk_Job
	 */
	public function reserve($timeout = null)
	{
		$response = $this->_dispatch(
			new Pheanstalk_Command_ReserveCommand($timeout)
		);

		$falseResponses = array(
			Pheanstalk_Response::RESPONSE_DEADLINE_SOON,
			Pheanstalk_Response::RESPONSE_TIMED_OUT,
		);

		if (in_array($response->getResponseName(), $falseResponses))
		{
			return false;
		}
		else
		{
			return new Pheanstalk_Job($response['id'], $response['jobdata']);
		}
	}

	/**
	 * Gives statistical information about the specified job if it exists.
	 *
	 * @param Pheanstalk_Job or int $job
	 * @return object
	 */
	public function statsJob($job)
	{
		return $this->_dispatch(new Pheanstalk_Command_StatsJobCommand($job));
	}

	/**
	 * Gives statistical information about the specified tube if it exists.
	 *
	 * @param string $tube
	 * @return object
	 */
	public function statsTube($tube)
	{
		return $this->_dispatch(new Pheanstalk_Command_StatsTubeCommand($tube));
	}

	/**
	 * Gives statistical information about the beanstalkd system as a whole.
	 *
	 * @return object
	 */
	public function stats()
	{
		return $this->_dispatch(new Pheanstalk_Command_StatsCommand());
	}

	/**
	 * Allows a worker to request more time to work on a job.
	 *
	 * This is useful for jobs that potentially take a long time, but you still want
	 * the benefits of a TTR pulling a job away from an unresponsive worker.  A worker
	 * may periodically tell the server that it's still alive and processing a job
	 * (e.g. it may do this on DEADLINE_SOON).
	 *
	 * @param Pheanstalk_Job $job
	 * @chainable
	 */
	public function touch($job)
	{
		$this->_dispatch(new Pheanstalk_Command_TouchCommand($job));
		return $this;
	}

	/**
	 * Change to the specified tube name for publishing jobs to.
	 * This method would be called 'use' if it were not a PHP reserved word.
	 *
	 * @param string $tube
	 * @chainable
	 */
	public function useTube($tube)
	{
		$this->_dispatch(new Pheanstalk_Command_UseCommand($tube));
		return $this;
	}

	/**
	 * Add the specified tube to the watchlist, to reserve jobs from.
	 *
	 * @param string $tube
	 * @chainable
	 */
	public function watch($tube)
	{
		$this->_dispatch(new Pheanstalk_Command_WatchCommand($tube));
		return $this;
	}

	// ----------------------------------------

	/**
	 * @param Pheanstalk_Command $command
	 * @return Pheanstalk_Response
	 */
	private function _dispatch($command)
	{
		return $this->_connection->dispatchCommand($command);
	}
}


text:
<?php

namespace app\controllers;

use app\components\FileComponent;
use app\models\Category;
use app\models\City;
use app\models\Factura;
use app\models\InvoiceData;
use app\models\Place;
use app\models\Proforma;
use app\models\Settings;
use app\models\Ticket;
use app\models\User;
use Yii;
use yii\db\Query;
use yii\filters\AccessControl;
use yii\log\Logger;
use yii\web\Controller;
use yii\filters\VerbFilter;
use app\models\LoginForm;
use app\models\ContactForm;

class AdminController extends Controller
{

    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'rules' => [
                    [
                        'actions' => [
                            'profiles',
                            'delete-user',
                            'edit-user',
                            'invoice-data',
                            'proformi',
                            'preview',
                            'categories',
                            'create-invoice',
                            'invoices',
                            'preview-invoice',
                            'delete-invoice-modal',
                            'delete-invoice',
                            'edit-place',
                            'places',
                            'profiles-users'
                        ],
                        'allow' => true,
                        'roles' => ['@'],
                        'matchCallback' => function ($rule, $action) {
                            if (!Yii::$app->user->isUserAdmin())
                                return $this->redirect(yii::$app->urlManager->createAbsoluteUrl(['site/index']));
                            return true;
                        }
                    ],
                ],
            ],
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                ],
            ],
        ];
    }

    /**
     * @inheritdoc
     */
    public function actions()
    {
        return [
            'error' => [
                'class' => 'yii\web\ErrorAction',
            ],
        ];
    }

    public function actionProfiles()
    {
        $users = User::findAll(['type' => User::TYPE_COMPANY]);
        return $this->render('profiles', ['users' => $users]);
    }

    public function actionDeleteUser()
    {
        $request = Yii::$app->request;
        if ($request->isGet) {
            $userId = $request->get('userId');
            $user = User::getUser($userId);
            return $this->renderPartial('_delete-user', ['user' => $user]);
        } elseif ($request->isAjax) {
            $userId = $request->post('userId');
            $user = User::getUser($userId);
            $user->delete();
            return $this->redirect(Yii::$app->urlManager->createUrl('admin/profiles'));
        }
        return $this->redirect(Yii::$app->urlManager->createUrl('site/index'));
    }

    public function actionEditUser()
    {
        $request = Yii::$app->request;
        if ($request->isGet) {
            $userId = $request->get('userId');
            $user = User::getUser($userId);
            return $this->renderPartial('_edit-user', ['user' => $user]);
        } elseif ($request->isPost) {
            $userId = (int)$_POST['User']['id'];
            $user = User::findOne($userId);
            $oldStatus = $user->active;
            /* @var $user User */
            $user->setAttributes($request->post('User'));
            if ($user->active == 1 && $user->active != $oldStatus) {
                User::sendEmailToUsersByCompany($user);
            }
            $user->save();
            return $this->redirect(Yii::$app->urlManager->createUrl('admin/profiles'));
        }
        return $this->redirect(Yii::$app->urlManager->createUrl('site/index'));
    }

    public function actionInvoiceData()
    {
        if (isset($_POST['updateCompany']) && !empty($_POST['Company'])) {
            $companyData = $_POST['Company'];
            foreach ($companyData as $name => $value) {
                Settings::set($name, $value);
            }
        }
        return $this->render('invoice-data');
    }

    public function actionProformi()
    {
        $proformi = Proforma::findAll(['paid' => 0]);
        return $this->render('proformi', ['proformi' => $proformi]);
    }

    public function actionPreview()
    {
        $proforma = Proforma::findOne(intval($_GET['id']));
        if ($proforma) {

            $user = $proforma->getUser();
            $file = new FileComponent($user);
            $path = $file->filePathProforma . Proforma::FILE_NAME . '_' . $proforma->place_id . '.pdf';
            $pdf = file_get_contents($path);
            header('Content-Type: application/pdf');
            header('Content-Disposition: inline; filename="' . Proforma::FILE_NAME . '"');
            echo $pdf;
        }
    }

    public function actionPreviewInvoice()
    {
        $factura = Factura::findOne(intval($_GET['id']));
        if ($factura) {
            $user = $factura->getUser();
            $file = new FileComponent($user);
            $path = $file->filePathFactura . $factura->path;
            $pdf = file_get_contents($path);
            header('Content-Type: application/pdf');
            header('Content-Disposition: inline; filename="' . Proforma::FILE_NAME . '"');
            echo $pdf;
        }
    }

    public function actionCreateInvoice()
    {
        $proforma = Proforma::findOne(intval($_GET['id']));
        if ($proforma) {
            $company = $proforma->getUser();
            $file = new FileComponent($company);
            $pdf = $file->preparePdfData();
            $model = new InvoiceData();
            $model->getRecipientData($company->id);
            $timestamp = strtotime($proforma->date);
            $model->date = $timestamp;
            $model->date = date('d.m.Y', $model->date);

            $place = Place::findOne($proforma->place_id);

            $items = [];
            $items[0]['name'] = 'Абонамент за ползване на сайт до ' . date('d.m.Y', strtotime('+1 years,+7 days', $timestamp));
            $items[0]['price'] = number_format($place->price / 1.2, 2);
            $items[0]['q'] = 1;

            $path = $file->filePathFactura;
            $fileName = 'factura-' . $place->id . '_' . date('Y-m-d') . '.pdf';
            if (!file_exists($path)) {
                mkdir($path, 0777, true);
            }
            if (!file_exists($path . $fileName)) {
                $file = fopen($path . $fileName, 'w');
                fclose($file);
            }

            $factura = new Factura();
            $factura->user_id = $company->id;
            $factura->date = date('Y-m-d');
            $factura->path = $fileName;
            $factura->place_id = $place->id;
            $factura->save();

            $model->number = $factura->id;

            $sum = round($items[0]['q'] * $items[0]['price'], 2);
            $sumWord = $this->getSumWord(round($sum * 1.2, 2));

            $pdf->writeHTML($this->renderPartial('_factura',
                ['model' => $model, 'items' => $items, 'type' => FileComponent::TYPE_FACTURA, 'origin' => FileComponent::TYPE_ORIGINAL, 'sumWord' => $sumWord, 'sum' => $sum]));
            $pdf->AddPage();
            $pdf->writeHTML($this->renderPartial('_factura',
                ['model' => $model, 'items' => $items, 'type' => FileComponent::TYPE_FACTURA, 'origin' => FileComponent::TYPE_DUBLICATE, 'sumWord' => $sumWord, 'sum' => $sum]));

            $pdf->Output($path . $fileName, 'F');
            $pdf->get();

            $newPaidDate = date('Y-m-d', strtotime('+1 years,+7 days', $timestamp));
            $company->paid_until = $newPaidDate;
            $company->active = 1;
            $company->save();
            $proforma->paid = 1;
            $proforma->save();

            $oldActive = $place->active;
            $place->active = 1;
            if ($place->active != $oldActive)
                User::sendEmailToUsersByPlace($place);
            $place->paid_until = $newPaidDate;
            $place->save();
        }
    }

    private function getSumWord($sum)
    {
        $sum *= 100;
        $sum = intval(round($sum));
        $lastDigitStot = $sum % 10;
        $sum /= 10;
        $firstDigitStot = $sum % 10;
        $sum /= 10;
        $lastDigitLev = $sum % 10;
        $sum /= 10;
        $firstDigitLev = $sum % 10;
        $stotString = '';
        $levString = '';
        switch ($firstDigitStot) {
            case 1:
                switch ($lastDigitStot) {
                    case 1:
                        $stotString = 'единадесет';
                        break;
                    case 2:
                        $stotString = 'дванадесет';
                        break;
                    case 3:
                        $stotString = 'тринадесет';
                        break;
                    case 4:
                        $stotString = 'четиринадесет';
                        break;
                    case 5:
                        $stotString = 'петнадесет';
                        break;
                    case 6:
                        $stotString = 'шестнадесет';
                        break;
                    case 7:
                        $stotString = 'седемнадесет';
                        break;
                    case 8:
                        $stotString = 'осемнадесет';
                        break;
                    case 9:
                        $stotString = 'деветнадесет';
                        break;
                    case 0:
                        $stotString = 'десет';
                        break;
                }
                break;
            case 2:
                $stotString = 'двадесет';
                $stotString = $this->handleMoney($stotString, $lastDigitStot);
                break;
            case 3:
                $stotString = 'тридесет';
                $stotString = $this->handleMoney($stotString, $lastDigitStot);
                break;
            case 4:
                $stotString = 'четиридесет';
                $stotString = $this->handleMoney($stotString, $lastDigitStot);
                break;
            case 5:
                $stotString = 'петдесет';
                $stotString = $this->handleMoney($stotString, $lastDigitStot);
                break;
            case 6:
                $stotString = 'шестдесет';
                $stotString = $this->handleMoney($stotString, $lastDigitStot);
                break;
            case 7:
                $stotString = 'седемдесет';
                $stotString = $this->handleMoney($stotString, $lastDigitStot);
                break;
            case 8:
                $stotString = 'осемдесет';
                $stotString = $this->handleMoney($stotString, $lastDigitStot);
                break;
            case 9:
                $stotString = 'деветдесет';
                $stotString = $this->handleMoney($stotString, $lastDigitStot);
                break;
            case 0:
                $stotString = $this->handleMoney($stotString, $lastDigitStot);
                break;
        }
        switch ($firstDigitLev) {
            case 1:
                switch ($lastDigitLev) {
                    case 1:
                        $levString = 'единадесет';
                        break;
                    case 2:
                        $levString = 'дванадесет';
                        break;
                    case 3:
                        $levString = 'тринадесет';
                        break;
                    case 4:
                        $levString = 'четиринадесет';
                        break;
                    case 5:
                        $levString = 'петнадесет';
                        break;
                    case 6:
                        $levString = 'шестнадесет';
                        break;
                    case 7:
                        $levString = 'седемнадесет';
                        break;
                    case 8:
                        $levString = 'осемнадесет';
                        break;
                    case 9:
                        $levString = 'деветнадесет';
                        break;
                    case 0:
                        $levString = 'десет';
                        break;
                }
                break;
            case 2:
                $levString = 'двадесет';
                $levString = $this->handleMoney($levString, $lastDigitLev, 'lev');
                break;
            case 3:
                $levString = 'тридесет';
                $levString = $this->handleMoney($levString, $lastDigitLev, 'lev');
                break;
            case 4:
                $levString = 'четиридесет';
                $levString = $this->handleMoney($levString, $lastDigitLev, 'lev');
                break;
            case 5:
                $levString = 'петдесет';
                $levString = $this->handleMoney($levString, $lastDigitLev, 'lev');
                break;
            case 6:
                $levString = 'шестдесет';
                $levString = $this->handleMoney($levString, $lastDigitLev, 'lev');
                break;
            case 7:
                $levString = 'седемдесет';
                $levString = $this->handleMoney($levString, $lastDigitLev, 'lev');
                break;
            case 8:
                $levString = 'осемдесет';
                $levString = $this->handleMoney($levString, $lastDigitLev, 'lev');
                break;
            case 9:
                $levString = 'деветдесет';
                $levString = $this->handleMoney($levString, $lastDigitLev, 'lev');
                break;
            case 0:
                $levString = $this->handleMoney($levString, $lastDigitLev, 'lev');
                break;
        }
        $stotString .= ' стотинки';
        $levString .= ' лева';
        return $levString . ', ' . $stotString;
    }

    private function handleMoney($stotString, $digit, $type = 'stot')
    {
        switch ($digit) {
            case 1:
                if ($type == 'lev') {
                    $stotString .= ' и един';
                } else {
                    $stotString .= ' и една';
                }
                break;
            case 2:
                if ($type == 'lev') {
                    $stotString .= ' и два';
                } else {
                    $stotString .= ' и две';
                }
                break;
            case 3:
                $stotString .= ' и три';
                break;
            case 4:
                $stotString .= ' и четири';
                break;
            case 5:
                $stotString .= ' и пет';
                break;
            case 6:
                $stotString .= ' и шест';
                break;
            case 7:
                $stotString .= ' и седем';
                break;
            case 8:
                $stotString .= ' и осем';
                break;
            case 9:
                $stotString .= ' и девет';
                break;
            case 0:
                if ($stotString == '') {
                    if ($type == 'lev') {
                        $stotString .= 'нула';
                    } else {
                        $stotString .= ' и нула';
                    }
                }
                break;
        }
        return $stotString;
    }

    public function actionCategories()
    {
        if (!empty($_POST['Category'])) {
            $cat = new Category();
            $cat->setAttributes($_POST['Category']);
            $cat->save();
        }
        $categories = Category::find()->all();
        return $this->render('categories', ['categories' => $categories]);
    }

    public function actionInvoices()
    {
        $facturi = Factura::find()->all();
        return $this->render('invoices', ['facturi' => $facturi]);
    }

    public function actionDeleteInvoiceModal()
    {
        $factura = Factura::findOne(intval($_GET['id']));
        return $this->renderPartial('_delete-invoice-modal', ['factura' => $factura]);
    }

    public function actionDeleteInvoice()
    {
        if (Yii::$app->request->isAjax) {
            $factura = Factura::findOne(intval($_POST['invoiceId']));
            if ($factura) {
                $factura->active = 0;
                $factura->save();
            }
            return $this->redirect(Yii::$app->urlManager->createUrl('admin/invoices'));
        }
        return false;
    }

    public function actionPlaces()
    {
        $companyId = intval(Yii::$app->request->get('companyId'));
        $company = User::findOne($companyId);
        if ($company) {
            return $this->render('places', ['company' => $company]);
        }
        return $this->redirect(Yii::$app->urlManager->createUrl('admin/profiles'));
    }

    public function actionEditPlace()
    {
        $place = Place::findOne(intval(Yii::$app->request->get('id')));
        $req = Yii::$app->request;
        if ($place) {
            if (!empty($req->post('Place'))) {
                $place->setAttributes($req->post('Place'));
                $place->checked = 1;
                if ($place->save()) {
                    if ($place->active)
                        User::sendEmailToUsersByPlace($place);
                    Yii::$app->session->setFlash('success', 'Промените са записани!');
                }
            }
            return $this->render('edit-place', ['place' => $place]);
        }
        return $this->redirect(Yii::$app->urlManager->createUrl('admin/profiles'));
    }

    public function actionProfilesUsers()
    {
        // get all users
        $users = User::findAll(['type' => User::TYPE_USER]);
        return $this->render('list-users', ['users' => $users]);
    }

    private function getListOfRegionsCities()
    {
        $regions = [];
        $communities = [];
        $cities = [];
        $cityRelations = [];
        $citiesArray = (new Query())->select('c.id AS c_id, c.name as c_name, com.id AS com_id, com.name as com_name, r.id AS reg_id, r.name as reg_name')
            ->from(City::tableName() . ' c')
            ->innerJoin('communities com', 'c.community_id=com.id')
            ->innerJoin('regions r', 'com.region_id=r.id')->all();
        foreach ($citiesArray as $item) {
            $cityRelations[$item['reg_id']][$item['com_id']][] = $item['c_id'];
            $cities[$item['c_id']] = $item['c_name'];
            $communities[$item['com_id']] = $item['com_name'];
            $regions[$item['reg_id']] = $item['reg_name'];
        }

        return [$regions, $cities, $communities, $cityRelations];
    }

    /**
     * @return null|\yii\web\Response|static|User
     */
    private function getCurrentUser()
    {
        $user = User::findOne(Yii::$app->user->id);
        if (!$user) {
            Yii::$app->session->setFlash('error', 'Няма такъв потребител!');
            return $this->redirect(Yii::$app->urlManager->createUrl('site/index'));
        }
        return $user;
    }

    /**
     * @param $cityId
     * @param bool $asIndexedArray
     * @return array|bool - community and region
     */
    private function getRegionCommunityByCityId($cityId, $asIndexedArray = false)
    {
        $result = (new Query())
            ->select('c.community_id as selectedCommunityId, com.region_id as selectedRegionId')
            ->from(City::tableName() . ' c')
            ->innerJoin('communities com', 'c.community_id=com.id')
            ->where(['c.id' => $cityId])->one();
        if ($asIndexedArray) {
            $result = array_values($result);
        }
        return $result;
    }
}


text:
package org.kde9.model.card;

import org.kde9.util.PinYin;

class MyName {
	private String firstName;
	private String lastName;
	private String pinYinFirstName;
	private String pinYinLastName;
	private String pYFirstName;
	private String pYLastName;

	public String getFirstName() {
		return firstName;
	}

	public boolean setFirstName(String firstName) {
		if(firstName == null)
			return false;
		this.firstName = firstName;
		this.pinYinFirstName = PinYin.getPingYin(firstName);
		this.pYFirstName = PinYin.getPinYinHeadChar(firstName);
		if(pinYinFirstName == null || pYFirstName == null)
			return false;
		else
			return true;
	}

	public String getLastName() {
		return lastName;
	}

	public boolean setLastName(String lastName) {
		if(lastName == null)
			return false;
		this.lastName = lastName;
		this.pinYinLastName = PinYin.getPingYin(lastName);
		this.pYLastName = PinYin.getPinYinHeadChar(lastName);
		if(pinYinLastName == null || pYLastName == null)
			return false;
		else
			return true;
	}

	public String getPinYinFirstName() {
		return pinYinFirstName;
	}

	public String getPinYinLastName() {
		return pinYinLastName;
	}

	public String getPYFirstName() {
		return pYFirstName;
	}

	public String getPYLastName() {
		return pYLastName;
	}

//	public static void main(String args[]) {
//		MyName myName = new MyName("胡", "玮玮");
//		System.out.println(myName.pinYinFirstName + " " + myName.pinYinLastName);
//		System.out.println(myName.pYFirstName + ' ' + myName.pYLastName);
//	}
}


text:
<?php
/////////////////////////////////////////////////////////////////////////////////////
// xbtit - Bittorrent tracker/frontend
//
// Copyright (C) 2004 - 2011  Btiteam
//
//    This file is part of xbtit.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//   1. Redistributions of source code must retain the above copyright notice,
//      this list of conditions and the following disclaimer.
//   2. Redistributions in binary form must reproduce the above copyright notice,
//      this list of conditions and the following disclaimer in the documentation
//      and/or other materials provided with the distribution.
//   3. The name of the author may not be used to endorse or promote products
//      derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
////////////////////////////////////////////////////////////////////////////////////

global $CURUSER;

   block_begin(BLOCK_MENU);
   //print("
\n");
   print("
\n
".$language["MNU_INDEX"]."
\n");

   if ($CURUSER["view_torrents"]=="yes")
      {
      print("
".$language["MNU_TORRENT"]."
\n");
      print("
".$language["MNU_STATS"]."
\n");
      }
   if ($CURUSER["can_upload"]=="yes")
      print("
".$language["MNU_UPLOAD"]."
\n");
   if ($CURUSER["view_users"]=="yes")
      print("
".$language["MNU_MEMBERS"]."
\n");
   if ($CURUSER["view_news"]=="yes")
      print("
".$language["MNU_NEWS"]."
\n");
   if ($CURUSER["view_forum"]=="yes")
      {
        if ($GLOBALS["FORUMLINK"]=="" || $GLOBALS["FORUMLINK"]=="internal" || $GLOBALS["FORUMLINK"]=="smf")
           print("
".$language["MNU_FORUM"]."
\n");
        elseif ($GLOBALS["FORUMLINK"]=="smf")
           print("
".$language["MNU_FORUM"]."
\n");
        else
            print("
".$language["MNU_FORUM"]."
\n");
      }
   if ($CURUSER["uid"]==1 || !$CURUSER)
      print("
".$language["LOGIN"]."
\n
\n");
   else
       print("
".$language["LOGOUT"]."
\n
\n");

   block_end();
?>


text:
module VagrantPlugins
  module XenServer
    VERSION = "0.0.0"
  end
end


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Taskling.Blocks.RangeBlocks;
using Taskling.InfrastructureContracts.Blocks.CommonRequests;

namespace Taskling.InfrastructureContracts.Blocks
{
    public interface IRangeBlockRepository
    {
        Task ChangeStatusAsync(BlockExecutionChangeStatusRequest changeStatusRequest);
        Task<RangeBlock> GetLastRangeBlockAsync(LastBlockRequest lastRangeBlockRequest);
    }
}


text:
<?php

/*
 * This file is part of Sulu.
 *
 * (c) MASSIVE ART WebServices GmbH
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Sulu\Component\DocumentManager\Behavior\Path;

use Sulu\Component\DocumentManager\Behavior\Mapping\ParentBehavior;
use Sulu\Component\DocumentManager\Behavior\Mapping\TitleBehavior;

/**
 * The PHPCR nodes of objects implementing this behavior will have
 * names automatically assigned based on their title.
 */
interface AutoNameBehavior extends TitleBehavior, ParentBehavior
{
}


text:
Based on [Geometric progression](https://en.wikipedia.org/wiki/Geometric_progression)

Base value (14px / 2) = 7px

extra small - 3.5px (xs)

small - 7px (sm)

medium - 14px (md)

large - 28px (lg)

extra large - 56px (xlg)

xxlarge - 112px (xxlg)

Avaiable properties: **margin-[top|right|bottom|left], padding**

Resource:

* [Space in design systems](https://medium.com/eightshapes-llc/space-in-design-systems-188bcbae0d62)


text:
package org.roaringbitmap.art;

import java.util.Iterator;

public class KeyIterator implements Iterator<byte[]> {

  private LeafNode current;
  private LeafNodeIterator leafNodeIterator;

  public KeyIterator(Art art, Containers containers) {
    leafNodeIterator = new LeafNodeIterator(art, containers);
    current = null;
  }

  @Override
  public boolean hasNext() {
    boolean hasNext = leafNodeIterator.hasNext();
    if (hasNext) {
      current = leafNodeIterator.next();
    }
    return hasNext;
  }

  @Override
  public byte[] next() {
    return current.getKeyBytes();
  }

  public long currentContainerIdx() {
    return current.getContainerIdx();
  }

  public void remove() {
    leafNodeIterator.remove();
  }
}


text:
package com.google.common.base;

import com.google.common.base.Function;
import com.google.common.base.Supplier;
import java.io.Serializable;
import java.util.Set;

abstract public class Optional<T> implements Serializable
{
    Optional(){}
    public java.util.Optional<T> toJavaUtil(){ return null; }
    public abstract <V> Optional<V> transform(Function<? super T, V> p0);
    public abstract Optional<T> or(Optional<? extends T> p0);
    public abstract Set<T> asSet();
    public abstract String toString();
    public abstract T get();
    public abstract T or(Supplier<? extends T> p0);
    public abstract T or(T p0);
    public abstract T orNull();
    public abstract boolean equals(Object p0);
    public abstract boolean isPresent();
    public abstract int hashCode();
    public static <T> Iterable<T> presentInstances(Iterable<? extends Optional<? extends T>> p0){ return null; }
    public static <T> Optional<T> absent(){ return null; }
    public static <T> Optional<T> fromJavaUtil(java.util.Optional<T> p0){ return null; }
    public static <T> Optional<T> fromNullable(T p0){ return null; }
    public static <T> Optional<T> of(T p0){ return null; }
    public static <T> java.util.Optional<T> toJavaUtil(Optional<T> p0){ return null; }
}


text:
ACCEPTED

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
null

#### Original name
Laelia itambana Pabst

### Remarks
null


text:
package org.apache.tapestry5.internal.services;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;

import org.apache.tapestry5.Asset;
import org.apache.tapestry5.commons.Resource;
import org.apache.tapestry5.commons.util.CollectionFactory;
import org.apache.tapestry5.internal.AssetConstants;
import org.apache.tapestry5.services.AssetFactory;

public class ExternalUrlAssetFactory implements AssetFactory {

    final private String protocol;

    final private UrlResource rootResource;

    final private Map<URL, Asset> cache = CollectionFactory.newMap();

    public ExternalUrlAssetFactory(String protocol)
    {
        super();
        this.protocol = protocol;
//        try
//        {
            if (protocol.equals(AssetConstants.PROTOCOL_RELATIVE)) {
                protocol = "http";
            }
            this.rootResource = new UrlResource();
//        }
//        catch (MalformedURLException e)
//        {
//            throw new RuntimeException(e);
//        }
    }

    @Override
    public Resource getRootResource()
    {
        return rootResource;
    }

    @Override
    public Asset createAsset(Resource resource)
    {
        final URL url = resource.toURL();
        Asset asset = cache.get(url);
        if (asset == null)
        {
            asset = new UrlAsset(url.toExternalForm(), resource);
            cache.put(url, asset);
        }
        return asset;
    }

}


text:
using System;
using Android.Content;
using Android.Runtime;
using Android.Util;
using Android.Widget;
using BuildItArSample.Core;

namespace BuildItArSample.Android.Controls
{
    public class ArMarker : LinearLayout
    {
        private TextView distanceText;
        public TextView DistanceText => distanceText ?? (distanceText = FindViewById<TextView>(Resource.Id.distanceText));

        private TextView titleText;
        public TextView TitleText => titleText ?? (titleText = FindViewById<TextView>(Resource.Id.titleText));

        public POI POI { get; private set; }

        public ArMarker(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
        {
            Init();
        }

        public ArMarker(Context context, POI poi) : base(context)
        {
            Init();
            POI = poi;
        }

        public ArMarker(Context context, IAttributeSet attrs) : base(context, attrs)
        {
            Init();
        }

        public ArMarker(Context context, IAttributeSet attrs, int defStyleAttr) : base(context, attrs, defStyleAttr)
        {
            Init();
        }

        public ArMarker(Context context, IAttributeSet attrs, int defStyleAttr, int defStyleRes) : base(context, attrs, defStyleAttr, defStyleRes)
        {
            Init();
        }

        private void Init()
        {
            Inflate(Context, Resource.Layout.ArMarker, this);
        }
    }
}


text:
package org.drools.guvnor.client.widgets.drools.wizards;

import org.drools.guvnor.client.common.AssetFormats;
import org.drools.guvnor.client.explorer.ClientFactory;
import org.drools.guvnor.client.widgets.drools.wizards.assets.NewAssetWizardContext;
import org.drools.guvnor.client.widgets.drools.wizards.assets.NewGuidedDecisionTableAssetWizardContext;
import org.drools.guvnor.client.widgets.drools.wizards.assets.decisiontable.NewGuidedDecisionTableWizard;
import org.drools.guvnor.client.widgets.wizards.Wizard;
import org.drools.guvnor.client.widgets.wizards.WizardActivityView;
import org.drools.guvnor.client.widgets.wizards.WizardContext;
import org.drools.guvnor.client.widgets.wizards.WizardFactory;

import com.google.gwt.event.shared.EventBus;

/**
 * A Factory implementation to create different Wizards
 */
public class WizardFactoryImpl
    implements
    WizardFactory {

    private final ClientFactory clientFactory;
    private final EventBus      eventBus;

    public WizardFactoryImpl(ClientFactory clientFactory,
                             EventBus eventBus) {
        this.clientFactory = clientFactory;
        this.eventBus = eventBus;
    }

    public Wizard getWizard(WizardContext context,
                            WizardActivityView.Presenter presenter) {
        if ( context instanceof NewAssetWizardContext ) {
            NewGuidedDecisionTableAssetWizardContext newAssetContext = (NewGuidedDecisionTableAssetWizardContext) context;
            if ( newAssetContext.getFormat().equals( AssetFormats.DECISION_TABLE_GUIDED ) ) {
                return new NewGuidedDecisionTableWizard( clientFactory,
                                                         eventBus,
                                                         newAssetContext,
                                                         presenter );
            }
        }
        return null;
    }

}


text:
//<unit_header>
//----------------------------------------------------------------
//
// Martin Korneffel: IT Beratung/Softwareentwicklung
// Stuttgart, den 1.4.2014
//
//  Projekt.......: mko.Algo
//  Name..........: Evaluator.cs
//  Aufgabe/Fkt...: Wertet NaLisp- Ausdrücke aus
//
//
//
//
//
//<unit_environment>
//------------------------------------------------------------------
//  Zielmaschine..: PC
//  Betriebssystem: Windows 7 mit .NET 4.5
//  Werkzeuge.....: Visual Studio 2012
//  Autor.........: Martin Korneffel (mko)
//  Version 1.0...:
//
// </unit_environment>
//
//<unit_history>
//------------------------------------------------------------------
//
//  Version.......: 1.1
//  Autor.........: Martin Korneffel (mko)
//  Datum.........: 27.10.15
//  Änderungen....: Eval gibt jetzt kein Result sondern ein NaLisp zurück
//
//</unit_history>
//</unit_header>

using System;
//<unit_header>
//----------------------------------------------------------------
//
// Martin Korneffel: IT Beratung/Softwareentwicklung
// Stuttgart, den
//
//  Projekt.......: Projektkontext
//  Name..........: Dateiname
//  Aufgabe/Fkt...: Kurzbeschreibung
//
//
//
//
//
//<unit_environment>
//------------------------------------------------------------------
//  Zielmaschine..: PC
//  Betriebssystem: Windows 7 mit .NET 4.5
//  Werkzeuge.....: Visual Studio 2013
//  Autor.........: Martin Korneffel (mko)
//  Version 1.0...:
//
// </unit_environment>
//
//<unit_history>
//------------------------------------------------------------------
//
//  Version.......: 1.1
//  Autor.........: Martin Korneffel (mko)
//  Datum.........: 27.10.2015
//  Änderungen....: Rückgabewert von Evaluator- Result auf NaLisp umgestellt.
//                  Fehler beim Evaluieren werden jetzt durch Exceptions signalisiert.
//</unit_history>
//</unit_header>

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

using mko.Algo.Listprocessing;

namespace mko.NaLisp.Core
{
    public partial class Evaluator
    {
        public static Evaluator _ = new Evaluator();

        public class EvalException : Exception
        {
            public EvalException( INaLisp CurrentNode, string Message)
                : base(Message)
            {
                _CurrentNode = CurrentNode;
            }

            public EvalException(INaLisp CurrentNode, string Message, Exception InnerException)
                : base(Message)
            {
                _CurrentNode = CurrentNode;
            }

            public INaLisp CurrentNode
            {
                get
                {
                    return _CurrentNode;
                }
            }
            INaLisp _CurrentNode;

        }

        public NaLispStack StackInstance = new NaLispStack();

        public bool DebugOn { get; set; }

        /// <summary>
        /// Berechnet einen TASP- Term. Das Ergebnis ist wiederum ein TASP
        /// </summary>
        /// <param name="SubTerm"></param>
        /// <returns></returns>
        public INaLisp Eval(INaLisp RootTerm)
        {

            StackInstance.Clear();
            return EvalR(RootTerm);

        }

        /// <summary>
        /// mko, 10.11.2015
        /// Eval als asynchronem Methode
        /// </summary>
        /// <param name="RootTerm"></param>
        /// <returns></returns>
        public async Task<INaLisp> EvalAsync(INaLisp RootTerm)
        {
            INaLisp res = null;
            await Task.Run(() => res = Eval(RootTerm));
            return res;
        }

        INaLisp EvalR(INaLisp SubTerm)
        {
            try
            {
                StackInstance.Push(SubTerm);

                if (SubTerm is ITerminal)
                {
                    // Wert einer konstanten Funktion berechnen
                    var ITerm = (Core.ITerminal)SubTerm;
                    return ITerm.Eval(StackInstance, DebugOn);
                }
                else
                {
                    // Wert einer Funktion mit n Parametern berechnen.

                    var INonTerm = (Core.INonTerminal)SubTerm;

                    // Evaluierung von Funktionen, die den Kontrollfluss verändern erfolgt hier direkt.
                    // Die Eval- Methode der Funktionen selbst ist nicht implementiert
                    if (SubTerm is Control.IfThen)
                    {
                        // Eval von IfThen:
                        // Bei IfThen wird nur der Zweig ausgewertet, der lt. Bedingung zu durchlaufenn ist
                        var IfThen = (Control.IfThen)SubTerm;

                        var resCond = EvalR(IfThen.Condition);
                        var resCondBool = (Data.ConstVal<bool>)resCond;
                        if (resCondBool.Value)
                            return EvalR(IfThen.IfTrue);
                        else
                            return EvalR(IfThen.IfFalse);
                    }
                    else if (SubTerm is Control.Pipe)
                    {
                        // Eval von Pipe:
                        var Pipe = (Control.Pipe)SubTerm;

                        try
                        {

                            // 1. Form f(a) | g | ... umformen in ...(...g(f(a)) ...)
                            var f = Pipe.Transform();

                            // 2. Auswerten des umgeformten Terms
                            return EvalR(f);

                        }
                        catch (Exception ex)
                        {
                            throw new  EvalException(Pipe, mko.TraceHlp.FormatErrMsg(this, "Pipe", mko.ExceptionHelper.FlattenExceptionMessages(ex)));
                        }
                    }
                    else
                    {

                        // Funktionen in der Parameterlist evaluieren
                        INaLisp[] pList = INonTerm.Elements.Select(e => EvalR(e)).ToArray();

                        if (pList.Any(e => e is Lisp.Tuple))
                        {
                            // Ergebnisse von ausgewerteten Elementen, die Tupel sind, expandieren, wenn der SubTerm das zulässt
                            // a, (b,c,d), e -> a, b, c, d, e

                            IEnumerable<INaLisp> newPList = Fn.L<INaLisp>();
                            foreach (var res in pList)
                            {
                                //if (res.ResultTerm.Name == (int)Core.NameDir.Names.Tupel)
                                if (res is Lisp.Tuple)
                                {
                                    // Anwenden der Funktion auf die Elemente der Liste
                                    var Elems = ((Core.NaLispNonTerminal)res).Elements.ToArray();
                                    //newPList = newPList.Concat(Fn.L(SubTermNT.Eval(ElemsAsResults, StackInstance, DebugOn)));
                                    newPList = newPList.Concat(Elems);
                                }
                                else
                                    newPList = newPList.Concat(Fn.L(res));
                            }

                            // Subterm auswerten
                            return INonTerm.Eval(newPList.ToArray(), StackInstance, DebugOn);
                        }
                        else
                        {
                            // Subterm auswerten, ohne Expansion von Listen
                            return INonTerm.Eval(pList, StackInstance, DebugOn);
                        }
                    }
                }
            }
            finally
            {
                StackInstance.Pop();
            }
        }

    }
}


text:
@implementation SimpleForm

- (void)secondFormRow:(XEFormRowObject *)secondFormRow
{
    secondFormRow.title = @"额吉佛陪请问";
    // @"http://7xoszx.com1.z0.glb.clouddn.com/persona5.png"
    secondFormRow.logoStr = @"https://avatars3.githubusercontent.com/u/8864284?v=4&s=40";
    secondFormRow.valueTransformer = ^id(id input) {
        NSString *text = @"点击链接";
        NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:text];
        NSRange range = [text rangeOfString:@"链接"];
        // Link
        [attributedText yy_setTextHighlightRange:range
                                           color:[UIColor blueColor]
                                 backgroundColor:[UIColor grayColor]
                                       tapAction:^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect){
                                           NSLog(@"tap text range:...");
                                       }];
        // Image
        UIImage *image = [UIImage imageNamed:@"Nitendo"];
        NSMutableAttributedString *attachment = [NSMutableAttributedString yy_attachmentStringWithContent:image contentMode:UIViewContentModeCenter attachmentSize:image.size alignToFont:[UIFont systemFontOfSize:16] alignment:YYTextVerticalAlignmentCenter];
        [attachment appendAttributedString:attributedText];

        return attachment;
    };
}

- (void)secondForm2Row:(XEFormRowObject *)secondFormRow
{
    secondFormRow.valueTransformer = ^id(id input) {
        return @"二级菜单";
    };
}

- (void)textInputRow:(XEFormRowObject *)textInputRow
{
    XETextInputForm *textInputForm = [[XETextInputForm alloc] init];
    textInputForm.text = @"xenoblade";
    textInputRow.value = textInputForm;
}

- (void)textInlineRow:(XEFormRowObject *)textInlineRow
{
//    textInlineRow.value = @"默认值";
    textInlineRow.placeholder = @"请输入";
}

- (void)textViewRow:(XEFormRowObject *)textViewRow
{
    textViewRow.title = nil;
    textViewRow.type = XEFormRowTypeLongText;
    textViewRow.placeholder = @"Placeholder 大师级啊付了款;点撒就离开发;骄傲的看是否感觉阿卡;砥节奉公课啊我就烦刚看了;爱的枷锁发刻录机联发科;爱的枷锁卡乐付据鞍读书立刻放假啊鄂温克浪费精力;口味啊副经理库文件分类词库;撒DJ联发科;进度撒李开复解除了撒旦会计分录快点撒就发了看大家斯洛伐克;进度撒联发科;就离开适当放宽了;微积分零库存;焦恩俊擦伤看到了伐就离开;大家是否快乐;SD就离开;金额巧克力;我放假了开启违反纪律看;请问看起来放进去了;额我放假了可千万";
}

- (void)subTextViewRow:(XEFormRowObject *)subTextViewRow
{
    XETextInputForm *textInputForm = [[XETextInputForm alloc] init];
    textInputForm.text = @"大师级啊付了款;点撒就离开发;骄傲的看是否感觉阿卡;砥节奉公课啊我就烦刚看了;爱的枷锁发刻录机联发科;爱的枷锁卡乐付据鞍读书立刻放假啊鄂温克浪费精力;口味啊副经理库文件分类词库;撒DJ";
    textInputForm.type = XEFormRowTypeLongText;
    subTextViewRow.value = textInputForm;
}

@end


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

        <title>intrusive_ptr</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

intrusive_ptr class template

            Introduction

            Synopsis

            Members

            Free Functions

Introduction

The intrusive_ptr class template stores a pointer to an object with an
            embedded reference count. Every new intrusive_ptr instance increments
            the reference count by using an unqualified call to the function intrusive_ptr_add_ref,
            passing it the pointer as an argument. Similarly, when an intrusive_ptr
            is destroyed, it calls intrusive_ptr_release; this function is
            responsible for destroying the object when its reference count drops to zero.
            The user is expected to provide suitable definitions of these two functions. On
            compilers that support argument-dependent lookup, intrusive_ptr_add_ref
            and intrusive_ptr_release should be defined in the namespace
            that corresponds to their parameter; otherwise, the definitions need to go in
            namespace boost. The library provides a helper base class template
            intrusive_ref_counter which may
            help adding support for intrusive_ptr to user types.

The class template is parameterized on T, the type of the object pointed
            to. intrusive_ptr<T> can be implicitly converted to intrusive_ptr<U>
            whenever T* can be implicitly converted to U*.

The main reasons to use intrusive_ptr are:

            Some existing frameworks or OSes provide objects with embedded reference
            counts;

                The memory footprint of intrusive_ptr
            is the same as the corresponding raw pointer;

                intrusive_ptr<T> can be constructed from an arbitrary
                raw pointer of type T *.

As a general rule, if it isn't obvious whether intrusive_ptr better
            fits your needs than shared_ptr, try a shared_ptr-based
            design first.

Synopsis

namespace boost {

  template<class T> class intrusive_ptr {

    public:

      typedef T element_type;

      intrusive_ptr(); // never throws
      intrusive_ptr(T * p, bool add_ref = true);

      intrusive_ptr(intrusive_ptr const & r);
      template<class Y> intrusive_ptr(intrusive_ptr<Y> const & r);

      ~intrusive_ptr();

      intrusive_ptr & operator=(intrusive_ptr const & r);
      template<class Y> intrusive_ptr & operator=(intrusive_ptr<Y> const & r);
      intrusive_ptr & operator=(T * r);

      void reset();
      void reset(T * r);
      void reset(T * r, bool add_ref);

      T & operator*() const; // never throws
      T * operator->() const; // never throws
      T * get() const; // never throws
      T * detach(); // never throws

      operator unspecified-bool-type() const; // never throws

      void swap(intrusive_ptr & b); // never throws
  };

  template<class T, class U>
    bool operator==(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b); // never throws

  template<class T, class U>
    bool operator!=(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b); // never throws

  template<class T>
    bool operator==(intrusive_ptr<T> const & a, T * b); // never throws

  template<class T>
    bool operator!=(intrusive_ptr<T> const & a, T * b); // never throws

  template<class T>
    bool operator==(T * a, intrusive_ptr<T> const & b); // never throws

  template<class T>
    bool operator!=(T * a, intrusive_ptr<T> const & b); // never throws

  template<class T, class U>
    bool operator<(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b); // never throws

  template<class T> void swap(intrusive_ptr<T> & a, intrusive_ptr<T> & b); // never throws

  template<class T> T * get_pointer(intrusive_ptr<T> const & p); // never throws

  template<class T, class U>
    intrusive_ptr<T> static_pointer_cast(intrusive_ptr<U> const & r); // never throws

  template<class T, class U>
    intrusive_ptr<T> const_pointer_cast(intrusive_ptr<U> const & r); // never throws

  template<class T, class U>
    intrusive_ptr<T> dynamic_pointer_cast(intrusive_ptr<U> const & r); // never throws

  template<class E, class T, class Y>
    std::basic_ostream<E, T> & operator<< (std::basic_ostream<E, T> & os, intrusive_ptr<Y> const & p);

}

Members

element_type

typedef T element_type;

Provides the type of the template parameter T.

constructors

intrusive_ptr(); // never throws

Postconditions: get() == 0.

Throws: nothing.

intrusive_ptr(T * p, bool add_ref = true);

Effects: if(p != 0 && add_ref) intrusive_ptr_add_ref(p);.

Postconditions: get() == p.

intrusive_ptr(intrusive_ptr const & r);
template<class Y> intrusive_ptr(intrusive_ptr<Y> const & r);

Effects: if(r.get() != 0) intrusive_ptr_add_ref(r.get());.

Postconditions: get() == r.get().

destructor

~intrusive_ptr();

Effects: if(get() != 0) intrusive_ptr_release(get());.

assignment

intrusive_ptr & operator=(intrusive_ptr const & r);
template<class Y> intrusive_ptr & operator=(intrusive_ptr<Y> const & r);
intrusive_ptr & operator=(T * r);

Effects: Equivalent to intrusive_ptr(r).swap(*this).

Returns: *this.

reset

void reset();

Effects: Equivalent to intrusive_ptr().swap(*this).

void reset(T * r);

Effects: Equivalent to intrusive_ptr(r).swap(*this).

void reset(T * r, bool add_ref);

Effects: Equivalent to intrusive_ptr(r, add_ref).swap(*this).

indirection

T & operator*() const; // never throws

Requirements: get() != 0.

Returns: *get().

Throws: nothing.

T * operator->() const; // never throws

Requirements: get() != 0.

Returns: get().

Throws: nothing.

get

T * get() const; // never throws

Returns: the stored pointer.

Throws: nothing.

detach

T * detach(); // never throws

Returns: the stored pointer.

Throws: nothing.

Postconditions: get() == 0.

Notes: The returned pointer has an elevated reference count. This
                allows conversion of an intrusive_ptr back to a raw pointer,
                without the performance overhead of acquiring and dropping an extra
                reference. It can be viewed as the complement of the
                non-reference-incrementing constructor.

Caution: Using detach escapes the safety of automatic
                reference counting provided by intrusive_ptr. It should
                by used only where strictly necessary (such as when interfacing to an
                existing API), and when the implications are thoroughly understood.

conversions

operator unspecified-bool-type () const; // never throws

Returns: an unspecified value that, when used in boolean contexts, is
                equivalent to get() != 0.

Throws: nothing.

Notes: This conversion operator allows intrusive_ptr objects to be
                used in boolean contexts, like if (p && p->valid()) {}.
                The actual target type is typically a pointer to a member function, avoiding
                many of the implicit conversion pitfalls.

swap

void swap(intrusive_ptr & b); // never throws

Effects: Exchanges the contents of the two smart pointers.

Throws: nothing.

Free Functions

comparison

template<class T, class U>
  bool operator==(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b); // never throws

Returns: a.get() == b.get().

Throws: nothing.

template<class T, class U>
  bool operator!=(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b); // never throws

Returns: a.get() != b.get().

Throws: nothing.

template<class T, class U>
  bool operator==(intrusive_ptr<T> const & a, U * b); // never throws

Returns: a.get() == b.

Throws: nothing.

template<class T, class U>
  bool operator!=(intrusive_ptr<T> const & a, U * b); // never throws

Returns: a.get() != b.

Throws: nothing.

template<class T, class U>
  bool operator==(T * a, intrusive_ptr<U> const & b); // never throws

Returns: a == b.get().

Throws: nothing.

template<class T, class U>
  bool operator!=(T * a, intrusive_ptr<U> const & b); // never throws

Returns: a != b.get().

Throws: nothing.

template<class T, class U>
  bool operator<(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b); // never throws

Returns: std::less<T *>()(a.get(), b.get()).

Throws: nothing.

Notes: Allows intrusive_ptr objects to be used as keys
                in associative containers.

swap

template<class T>
  void swap(intrusive_ptr<T> & a, intrusive_ptr<T> & b); // never throws

Effects: Equivalent to a.swap(b).

Throws: nothing.

Notes: Matches the interface of std::swap. Provided as an aid to
                generic programming.

get_pointer

template<class T>
  T * get_pointer(intrusive_ptr<T> const & p); // never throws

Returns: p.get().

Throws: nothing.

Notes: Provided as an aid to generic programming. Used by
                    mem_fn.

static_pointer_cast

template<class T, class U>
  intrusive_ptr<T> static_pointer_cast(intrusive_ptr<U> const & r); // never throws

Returns: intrusive_ptr<T>(static_cast<T*>(r.get())).

Throws: nothing.

const_pointer_cast

template<class T, class U>
  intrusive_ptr<T> const_pointer_cast(intrusive_ptr<U> const & r); // never throws

Returns: intrusive_ptr<T>(const_cast<T*>(r.get())).

Throws: nothing.

dynamic_pointer_cast

template<class T, class U>
  intrusive_ptr<T> dynamic_pointer_cast(intrusive_ptr<U> const & r);

Returns: intrusive_ptr<T>(dynamic_cast<T*>(r.get())).

Throws: nothing.

operator<<

template<class E, class T, class Y>
    std::basic_ostream<E, T> & operator<< (std::basic_ostream<E, T> & os, intrusive_ptr<Y> const & p);

Effects: os << p.get();.

Returns: os.

$Date$

            Copyright © 2003-2005, 2013 Peter Dimov. Distributed under the Boost Software License, Version
            1.0. See accompanying file LICENSE_1_0.txt or
            copy at http://www.boost.org/LICENSE_1_0.txt.