text:
module UseragentApi
  VERSION = '0.1.3'
end


text:
======================
The ``horizon`` Module
======================

.. module:: horizon

Horizon ships with a single point of contact for hooking into your project if
you aren't developing your own :class:`~horizon.Dashboard` or
:class:`~horizon.Panel`::

    import horizon

From there you can access all the key methods you need.

Horizon
=======

.. attribute:: urls

    The auto-generated URLconf for horizon. Usage::

        url(r'', include(horizon.urls)),

.. autofunction:: register
.. autofunction:: unregister
.. autofunction:: get_absolute_url
.. autofunction:: get_user_home
.. autofunction:: get_dashboard
.. autofunction:: get_default_dashboard
.. autofunction:: get_dashboards

Dashboard
=========

.. autoclass:: Dashboard
    :members:

Panel
=====

.. autoclass:: Panel
    :members:

.. autoclass:: PanelGroup
    :members:

redpajama_set_name: RedPajamaGithub


text:
using UnityEngine;
using System.Collections;

public class DetonatorSprayHelper : MonoBehaviour {
public float startTimeMin = 0;
public float startTimeMax = 0;
public float stopTimeMin = 10;
public float stopTimeMax = 10;

public Material firstMaterial;
public Material secondMaterial;

private float startTime;
private float stopTime;

//the time at which this came into existence
private bool  isReallyOn;

void Start (){
	isReallyOn = GetComponent<ParticleEmitter>().emit;

	//this kind of emitter should always start off
	GetComponent<ParticleEmitter>().emit = false;

	//get a random number between startTimeMin and Max
	startTime = (Random.value * (startTimeMax - startTimeMin)) + startTimeMin + Time.time;
	stopTime = (Random.value * (stopTimeMax - stopTimeMin)) + stopTimeMin + Time.time;

	//assign a random material
	GetComponent<Renderer>().material = Random.value > 0.5f ? firstMaterial : secondMaterial;
}

void FixedUpdate (){
	//is the start time passed? turn emit on
	if (Time.time > startTime)
	{
		GetComponent<ParticleEmitter>().emit = isReallyOn;
	}

	if (Time.time > stopTime)
	{
		GetComponent<ParticleEmitter>().emit = false;
	}
}
}


text:
<?php
namespace _2UpMedia\Hooky\integration;

use _2UpMedia\Hooky\fixtures\Client;
use _2UpMedia\Hooky\Constants;
use _2UpMedia\Hooky\BaseTestCase;

class InstanceHooksTest extends BaseTestCase
{
    public function testBeforeHooks()
    {
        $this->callInaccessibleMethodWithArgs(
            $this->client,
            'setDefaultAccessibility',
            [Constants::PUBLIC_ACCESSIBLE | Constants::PROTECTED_ACCESSIBLE]
        );

        /**
         * var self
         */
        $that = $this;

        $this->client->before_getTextHook(function ($resourceLocation) use ($that) {
            $that->assertInstanceOf('_2UpMedia\Hooky\fixtures\Client', $this);
        });

        $this->client->beforeGetTextHook(array($this, 'getBeforeGetTextCallable'));

        $this->client->beforeGetTextHook(function ($resourceLocation) use ($that) {
            $that->assertInstanceOf('_2UpMedia\Hooky\fixtures\Client', $this);
            $that->assertEquals('/path/to/resource1', $resourceLocation);
        });

        $this->client->beforeAllHook(function ($method) use ($that) {
            $that->assertInstanceOf('_2UpMedia\Hooky\fixtures\Client', $this);
            $that->assertContains($method, ['getText', '_getText']);
        });

        $this->client->beforeAllHook(function ($method) use ($that) {
            $that->assertInstanceOf('_2UpMedia\Hooky\fixtures\Client', $this);
            $that->assertContains($method, ['getText', '_getText']);
        });

        $this->client->getText('/path/to/resource');
    }

    /**
     * @param $instance
     * @param $resourceLocation
     *
     * @return string
     */
    public function getBeforeGetTextCallable($instance, &$resourceLocation)
    {
        $resourceLocation = '/path/to/resource1';

        $this->assertInstanceOf('_2UpMedia\Hooky\fixtures\Client', $instance);
        $this->assertEquals('/path/to/resource1', $resourceLocation);

        return $resourceLocation;
    }

    public function testOnceBeforePublicMethod()
    {
        $this->setPublicAccessible();
        /**
         * var self
         */
        $that = $this;
        $count = 0;

        $this->client->onceBeforeGetTextHook(function ($resourceLocation) use ($that, &$count) {
            ++$count;

            $that->assertInstanceOf('_2UpMedia\Hooky\fixtures\Client', $this);
            $that->assertEquals('/path/to/resource', $resourceLocation);
        });

        $this->client->getText('/path/to/resource');
        $this->client->getText('/path/to/resource');

        $this->assertEquals(1, $count);
    }

    public function testOnceBeforeProtectedMethod()
    {
        $this->callInaccessibleMethodWithArgs(
            $this->client,
            'setDefaultAccessibility',
            [Constants::PUBLIC_ACCESSIBLE | Constants::PROTECTED_ACCESSIBLE]
        );

        /**
         * var self
         */
        $that = $this;
        $count = 0;

        $this->client->onceBefore_getTextHook(function ($resourceLocation) use ($that, &$count) {
            ++$count;

            $that->assertInstanceOf('_2UpMedia\Hooky\fixtures\Client', $this);
        });

        $this->client->getText('/path/to/resource');
        $this->client->getText('/path/to/resource');

        $this->assertEquals(1, $count);
    }

    public function testOnceBeforeAll()
    {
        /**
         * var self
         */
        $that = $this;
        $count = 0;

        $this->client->onceBeforeAllHook(function ($method) use ($that, &$count) {
            ++$count;

            $that->assertInstanceOf('_2UpMedia\Hooky\fixtures\Client', $this);
            $that->assertContains($method, ['getText', '_getText']);
        });

        $this->client->getText('/path/to/resource');
        $this->client->getText('/path/to/resource');

        $this->assertEquals(1, $count);
    }

    public function testOnceAfterMethod()
    {
        $this->setPublicAccessible();

        /**
         * var self
         */
        $that = $this;
        $count = 0;

        $this->client->onceAfterGetTextHook(function (&$resourceLocation) use ($that, &$count) {
            ++$count;

            $resourceLocation = '/path/to/resource1';

            $that->assertInstanceOf('_2UpMedia\Hooky\fixtures\Client', $this);
            $that->assertEquals('/path/to/resource1', $resourceLocation);
        });

        $this->client->getText('/path/to/resource');
        $this->client->getText('/path/to/resource');

        $this->assertEquals(1, $count);
    }

    public function testOnceAfterAll()
    {
        /**
         * var self
         */
        $that = $this;
        $count = 0;

        $this->client->onceAfterAllHook(function ($method) use ($that, &$count) {
            ++$count;

            $that->assertInstanceOf('_2UpMedia\Hooky\fixtures\Client', $this);
            $that->assertContains($method, ['getText', '_getText']);
        });

        $this->client->getText('/path/to/resource');
        $this->client->getText('/path/to/resource');

        $this->assertEquals(1, $count);
    }

    public function testAfterProtectedMethod()
    {
        $this->callInaccessibleMethodWithArgs(
            $this->client,
            'setDefaultAccessibility',
            [Constants::PUBLIC_ACCESSIBLE | Constants::PROTECTED_ACCESSIBLE]
        );

        /**
         * var self
         */
        $that = $this;
        $count = 0;

        $this->client->after_getTextHook(function ($resourceLocation) use ($that, &$count) {
            ++$count;

            $that->assertInstanceOf('_2UpMedia\Hooky\fixtures\Client', $this);
        });

        $this->client->getText('/path/to/resource');
        $this->client->getText('/path/to/resource');

        $this->assertEquals(2, $count);
    }

    public function testAfterPrivateMethod()
    {
        $this->callInaccessibleMethodWithArgs(
            $this->client,
            'setDefaultAccessibility',
            [Constants::PUBLIC_ACCESSIBLE | Constants::PROTECTED_ACCESSIBLE | Constants::PRIVATE_ACCESSIBLE]
        );

        /**
         * var self
         */
        $that = $this;
        $count = 0;

        $this->client->afterPrivateMethodHook(function () use ($that, &$count) {
            ++$count;

            $that->assertInstanceOf('_2UpMedia\Hooky\fixtures\Client', $this);
        });

        $this->client->publicMethod();
        $this->client->publicMethod();

        $this->assertEquals(2, $count);
    }

    public function testAfterHooks()
    {
        $this->callInaccessibleMethodWithArgs(
            $this->client,
            'setDefaultAccessibility',
            [Constants::PUBLIC_ACCESSIBLE | Constants::PROTECTED_ACCESSIBLE]
        );

        /**
         * var self
         */
        $that = $this;

        $this->client->after_getTextHook(function ($resourceLocation) use ($that) {
            $that->assertInstanceOf('_2UpMedia\Hooky\fixtures\Client', $this);
        });

        $this->client->afterGetTextHook(function (&$resourceLocation) use ($that) {
            $resourceLocation = '/path/to/resource1';

            $that->assertInstanceOf('_2UpMedia\Hooky\fixtures\Client', $this);
            $that->assertEquals('/path/to/resource1', $resourceLocation);
        });

        $this->client->afterGetTextHook(function ($resourceLocation) use ($that) {
            $that->assertInstanceOf('_2UpMedia\Hooky\fixtures\Client', $this);
            $that->assertEquals('/path/to/resource1', $resourceLocation);
        });

        $this->client->afterAllHook(function ($method) use ($that) {
            $that->assertInstanceOf('_2UpMedia\Hooky\fixtures\Client', $this);
            $that->assertContains($method, ['getText', '_getText']);
        });

        $this->client->afterAllHook(function ($method) use ($that) {
            $that->assertInstanceOf('_2UpMedia\Hooky\fixtures\Client', $this);
            $that->assertContains($method, ['getText', '_getText']);
        });

        $this->client->getText('/path/to/resource');
    }

    public function testConstructorHooks()
    {
        $this->setPublicAccessible();

        $beforeCount = 0;
        $beforeCallable = function ($parameterOne, $parameterTwo) use (&$beforeCount) {
            ++$beforeCount;
        };

        Client::beforeConstructorHook($beforeCallable);

        $afterCount = 0;
        $afterCallable = function () use (&$afterCount) {
            ++$afterCount;
        };

        Client::afterConstructorHook($afterCallable);

        $one = new Client();

        $this->assertEquals(1, $beforeCount);
        $this->assertEquals(1, $afterCount);

        $beforeCount = 0;
        $afterCount = 0;

        $one = new Client();

        $this->assertEquals(0, $beforeCount);
        $this->assertEquals(0, $afterCount);

        $beforeCount = 0;
        $afterCount = 0;

        Client::beforeConstructorHook($beforeCallable);
        Client::afterConstructorHook($afterCallable);

        $three = new Client();

        $this->assertEquals(1, $beforeCount);
        $this->assertEquals(1, $afterCount);
    }

    public function testDestructorHooks()
    {
        $this->setPublicAccessible();

        $beforeCount = 0;
        $this->client->before__destructHook(function () use (&$beforeCount) {
            ++$beforeCount;
        });

        $afterCount = 0;
        $this->client->after__destructHook(function () use (&$afterCount) {
            ++$afterCount;
        });

        unset($this->client);

        $this->assertEquals(1, $beforeCount);
        $this->assertEquals(1, $afterCount);
    }

    public function testNoCallablesSetUp()
    {
        $client = new Client();

        $this->assertEquals('/path/to/resource', $client->getText('/path/to/resource'));
    }

}


text:
using AWS
using AWS.AWSServices: kinesis_video_signaling
using AWS.Compat
using AWS.UUIDs

"""
    get_ice_server_config(channel_arn)
    get_ice_server_config(channel_arn, params::Dict{String,<:Any})

Gets the Interactive Connectivity Establishment (ICE) server configuration information,
including URIs, username, and password which can be used to configure the WebRTC
connection. The ICE component uses this configuration information to setup the WebRTC
connection, including authenticating with the Traversal Using Relays around NAT (TURN)
relay server.  TURN is a protocol that is used to improve the connectivity of peer-to-peer
applications. By providing a cloud-based relay service, TURN ensures that a connection can
be established even when one or more peers are incapable of a direct peer-to-peer
connection. For more information, see A REST API For Access To TURN Services.  You can
invoke this API to establish a fallback mechanism in case either of the peers is unable to
establish a direct peer-to-peer connection over a signaling channel. You must specify
either a signaling channel ARN or the client ID in order to invoke this API.

# Arguments
- `channel_arn`: The ARN of the signaling channel to be used for the peer-to-peer
  connection between configured peers.

# Optional Parameters
Optional parameters can be passed as a `params::Dict{String,<:Any}`. Valid keys are:
- `"ClientId"`: Unique identifier for the viewer. Must be unique within the signaling
  channel.
- `"Service"`: Specifies the desired service. Currently, TURN is the only valid value.
- `"Username"`: An optional user ID to be associated with the credentials.
"""
function get_ice_server_config(
    ChannelARN; aws_config::AbstractAWSConfig=global_aws_config()
)
    return kinesis_video_signaling(
        "POST",
        "/v1/get-ice-server-config",
        Dict{String,Any}("ChannelARN" => ChannelARN);
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function get_ice_server_config(
    ChannelARN,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return kinesis_video_signaling(
        "POST",
        "/v1/get-ice-server-config",
        Dict{String,Any}(
            mergewith(_merge, Dict{String,Any}("ChannelARN" => ChannelARN), params)
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end

"""
    send_alexa_offer_to_master(channel_arn, message_payload, sender_client_id)
    send_alexa_offer_to_master(channel_arn, message_payload, sender_client_id, params::Dict{String,<:Any})

This API allows you to connect WebRTC-enabled devices with Alexa display devices. When
invoked, it sends the Alexa Session Description Protocol (SDP) offer to the master peer.
The offer is delivered as soon as the master is connected to the specified signaling
channel. This API returns the SDP answer from the connected master. If the master is not
connected to the signaling channel, redelivery requests are made until the message expires.

# Arguments
- `channel_arn`: The ARN of the signaling channel by which Alexa and the master peer
  communicate.
- `message_payload`: The base64-encoded SDP offer content.
- `sender_client_id`: The unique identifier for the sender client.

"""
function send_alexa_offer_to_master(
    ChannelARN,
    MessagePayload,
    SenderClientId;
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return kinesis_video_signaling(
        "POST",
        "/v1/send-alexa-offer-to-master",
        Dict{String,Any}(
            "ChannelARN" => ChannelARN,
            "MessagePayload" => MessagePayload,
            "SenderClientId" => SenderClientId,
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end
function send_alexa_offer_to_master(
    ChannelARN,
    MessagePayload,
    SenderClientId,
    params::AbstractDict{String};
    aws_config::AbstractAWSConfig=global_aws_config(),
)
    return kinesis_video_signaling(
        "POST",
        "/v1/send-alexa-offer-to-master",
        Dict{String,Any}(
            mergewith(
                _merge,
                Dict{String,Any}(
                    "ChannelARN" => ChannelARN,
                    "MessagePayload" => MessagePayload,
                    "SenderClientId" => SenderClientId,
                ),
                params,
            ),
        );
        aws_config=aws_config,
        feature_set=SERVICE_FEATURE_SET,
    )
end


text:
package dtprogrammer.github.io.p218;

import java.util.ArrayList;
import java.util.List;
import java.util.TreeMap;

public class Solution {
    public List<int[]> getSkyline(int[][] buildings) {
        List<int[]> skyline = new ArrayList<>();
        if (buildings == null || buildings.length == 0 || buildings[0] == null || buildings[0].length == 0) {
            return skyline;
        }
        // store all the critical points
        List<int[]> criticalPoints = new ArrayList<>();
        for (int[] building : buildings) {
            criticalPoints.add(new int[]{building[0], 0, building[2]}); // leftEnd, isRightEnd, height
            criticalPoints.add(new int[]{building[1], 1, building[2]}); // rightEnd, isRightEnd, height
        }

        // sort the critical points
        criticalPoints.sort((o1, o2) -> {
            return o1[0] == o2[0]
                    ? (o1[1] == o2[1] ? (o1[1] == 0 ? o2[2] - o1[2] : o1[2] - o2[2]) : o1[1] - o2[1])
                    : (o1[0] - o2[0]); // if the x coordinate are not equal then the one which starts before
        });

        TreeMap<Integer, Integer> currentBuildings = new TreeMap<>();
        for (int[] criticalPoint : criticalPoints) {
            boolean isStart = criticalPoint[1] == 0;
            int top;
            if (isStart) {
                currentBuildings.put(criticalPoint[2], currentBuildings.getOrDefault(criticalPoint[2], 0) + 1);
                top = currentBuildings.lastKey();
                if (top == criticalPoint[2] && currentBuildings.get(criticalPoint[2]) == 1) {
                    skyline.add(new int[]{criticalPoint[0], top});
                }
            } else {
                currentBuildings.put(criticalPoint[2], currentBuildings.get(criticalPoint[2]) - 1);
                if (currentBuildings.get(criticalPoint[2]) == 0) {
                    currentBuildings.remove(criticalPoint[2]);
                }
                if (currentBuildings.isEmpty()) {
                    skyline.add(new int[]{criticalPoint[0], 0});
                } else {
                    top = currentBuildings.lastKey();
                    if (criticalPoint[2] > top) {
                        skyline.add(new int[]{criticalPoint[0], top});
                    }
                }
            }
        }
        return skyline;
    }
}


text:
<?php
/**
 * This class is used to define custom level exceptions
 * @author pemanteau
 * @package kernel
 */

namespace Kernel\Exception;

/**
 * Is used for domainExceptions
 */
abstract class DomainException extends \Exception
{
}


text:
require 'base64'
require 'uri'
require 'time'
require 'json'
require 'openssl'

module Aws
  module CloudFront

    # Allows you to create signed cookie for Amazon CloudFront resources
    #
    #     signer = Aws::CloudFront::CookieSigner.new(
    #       key_pair_id: "cf-keypair-id",
    #       private_key_path: "./cf_private_key.pem"
    #     )
    #     cookies = signer.signed_cookie(url,
    #       policy: policy.to_json
    #     )
    #
    class CookieSigner
      include Signer

      # create a set of signed Amazon CloudFront cookie parameters
      # @param [String] url
      # @option params [Time, DateTime, Date, String, Integer<timestamp>] :expires
      # @option params [String<JSON>] :policy
      def signed_cookie(url, params = {})
        scheme, uri = scheme_and_uri(url)
        signed_content = signature(
          resource: resource(scheme, uri),
          expires: time(params[:expires]),
          policy: params[:policy]
        )

        cookie_parameters = {}
        signed_content.each { |k, v|
          cookie_parameters["CloudFront-#{k}"] = v.to_s.gsub("\n", '')
        }
        cookie_parameters
      end

    end
  end
end


text:
<?php

namespace Statamic\Extensions\View;

use Illuminate\View\Factory as ViewFactory;

class Factory extends ViewFactory
{
    /**
     * The extension to engine bindings.
     *
     * @var array
     */
    protected $extensions = [
        'blade.php' => 'blade',
        'php' => 'php',
        'html' => 'antlers'
    ];
}


text:
package pl.beriko.ioz.web.util.security;

import java.io.Serializable;
import java.security.Permission;
import java.security.PermissionCollection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;

/**
 * Project: Suggestion List User: Octavian Rusu Date: 05/24/2010
 */
public class AuthorizationPermission extends Permission {

	private static final long serialVersionUID = -7608045103870825874L;

	private final static int READ = 0x1;
	private final static String READ_ACTION = "read";
	private final static int CREATE = 0x2;
	private final static String CREATE_ACTION = "create";
	private final static int UPDATE = 0x4;
	private final static String UPDATE_ACTION = "update";
	private final static int DELETE = 0x8;
	private final static String DELETE_ACTION = "delete";
	private final static int ALL = READ | CREATE | UPDATE | DELETE;
	private final static String ALL_ACTION = "read,create,update,delete";
	private final static int NONE = 0x0;
	public static AuthorizationPermission ALL_AUTHORIZATIONS = new AuthorizationPermission("*", ALL, "All permissions");
	private String description;
	private transient int mask;

	public AuthorizationPermission(String name, String action, String description) {
		super("ALL".equalsIgnoreCase(name) ? "*" : name);
		this.description = description;
		init(getMask(action));
	}

	public AuthorizationPermission(String name, int mask, String description) {
		super("ALL".equalsIgnoreCase(name) ? "*" : name);
		this.description = description;
		init(mask);
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	private void init(int mask) {
		if ((mask & ALL) != mask) {
			throw new IllegalArgumentException("Invalid actions");
		}
		this.mask = mask;
	}

	public boolean implies(Permission permission) {
		if (!(permission instanceof AuthorizationPermission)) {
			return false;
		}
		AuthorizationPermission that = (AuthorizationPermission) permission;
		return ((this.mask & that.mask) == that.mask) && impliesIgnoreMask(that);
	}

	boolean impliesIgnoreMask(AuthorizationPermission that) {
		return getName().equals("*") || getName().equals(that.getName());
	}

	public boolean equals(Object obj) {
		if (obj == this) {
			return true;
		}
		if (!(obj instanceof AuthorizationPermission)) {
			return false;
		}
		AuthorizationPermission that = (AuthorizationPermission) obj;
		return this.mask == that.mask && this.getName().equalsIgnoreCase(that.getName());
	}

	public int hashCode() {
		return this.getName().hashCode();
	}

	public String getActions() {
		StringBuilder sb = new StringBuilder();
		boolean comma = false;
		if ((mask & READ) == READ) {
			comma = true;
			sb.append(READ_ACTION);
		}
		if ((mask & CREATE) == CREATE) {
			if (comma)
				sb.append(',');
			else
				comma = true;
			sb.append(CREATE_ACTION);
		}
		if ((mask & UPDATE) == UPDATE) {
			if (comma)
				sb.append(',');
			else
				comma = true;
			sb.append(UPDATE_ACTION);
		}
		if ((mask & DELETE) == DELETE) {
			if (comma)
				sb.append(',');
			sb.append(DELETE_ACTION);
		}

		return sb.toString();
	}

	public PermissionCollection newPermissionCollection() {
		return new AuthorizationPermissionCollection();
	}

	int getMask() {
		return mask;
	}

	/**
	 * Convert an action string to an integer actions mask.
	 *
	 * @param action
	 *            the action string
	 * @return the action mask
	 */
	private int getMask(String action) {

		if (action == null) {
			throw new NullPointerException("action can't be null");
		}
		if (action.equals("")) {
			throw new IllegalArgumentException("action can't be empty");
		}

		int mask = NONE;

		// Check against use of constants (used heavily within the JDK)
		if (action.equals(READ_ACTION)) {
			return READ;
		} else if (action.equals(CREATE_ACTION)) {
			return CREATE;
		} else if (action.equals(UPDATE_ACTION)) {
			return UPDATE;
		} else if (action.equals(DELETE_ACTION)) {
			return DELETE;
		} else if (action.equals(ALL_ACTION) || action.equals("*")) {
			return ALL;
		}

		char[] a = action.toCharArray();

		int i = a.length - 1;
		if (i < 0)
			return mask;

		while (i != -1) {
			char c;

			// skip whitespace
			while ((i != -1) && ((c = a[i]) == ' ' || c == '\r' || c == '\n' || c == '\f' || c == '\t'))
				i--;

			// check for the known strings
			int matchlen;
			if (i >= 3 && (a[i - 3] == 'r' || a[i - 3] == 'R') && (a[i - 2] == 'e' || a[i - 2] == 'E') && (a[i - 1] == 'a' || a[i - 1] == 'A')
					&& (a[i] == 'd' || a[i] == 'D')) {
				matchlen = 4;
				mask |= READ;

			} else if (i >= 5 && (a[i - 5] == 'c' || a[i - 5] == 'C') && (a[i - 4] == 'r' || a[i - 4] == 'R') && (a[i - 3] == 'e' || a[i - 3] == 'E')
					&& (a[i - 2] == 'a' || a[i - 2] == 'A') && (a[i - 1] == 't' || a[i - 1] == 'T') && (a[i] == 'e' || a[i] == 'E')) {
				matchlen = 6;
				mask |= CREATE;

			} else if (i >= 5 && (a[i - 5] == 'u' || a[i - 5] == 'U') && (a[i - 4] == 'p' || a[i - 4] == 'P') && (a[i - 3] == 'd' || a[i - 3] == 'D')
					&& (a[i - 2] == 'a' || a[i - 2] == 'A') && (a[i - 1] == 't' || a[i - 1] == 'T') && (a[i] == 'e' || a[i] == 'E')) {
				matchlen = 6;
				mask |= UPDATE;

			} else if (i >= 5 && (a[i - 5] == 'd' || a[i - 5] == 'D') && (a[i - 4] == 'e' || a[i - 4] == 'E') && (a[i - 3] == 'l' || a[i - 3] == 'L')
					&& (a[i - 2] == 'e' || a[i - 2] == 'E') && (a[i - 1] == 't' || a[i - 1] == 'T') && (a[i] == 'e' || a[i] == 'E')) {
				matchlen = 6;
				mask |= DELETE;

			} else {
				throw new IllegalArgumentException("invalid permission: " + action);
			}

			// make sure we didn't just match the tail of a word
			// like "ackbarfaccept". Also, skip to the comma.
			boolean seencomma = false;
			while (i >= matchlen && !seencomma) {
				switch (a[i - matchlen]) {
				case ',':
					seencomma = true;
					/* FALLTHROUGH */
				case ' ':
				case '\r':
				case '\n':
				case '\f':
				case '\t':
					break;
				default:
					throw new IllegalArgumentException("invalid permission: " + action);
				}
				i--;
			}
			// point i at the location of the comma minus one (or -1).
			i -= matchlen;
		}

		return mask;
	}

	public static void main(String[] args) {
		System.out.println(READ | CREATE);
		System.out.println(READ | UPDATE);
		System.out.println(READ | DELETE);
		System.out.println(CREATE | UPDATE);
		System.out.println(CREATE | DELETE);
		System.out.println(UPDATE | DELETE);
		System.out.println(READ | CREATE | UPDATE);
		System.out.println(READ | CREATE | DELETE);
		System.out.println(CREATE | UPDATE | DELETE);
		System.out.println(READ | CREATE | UPDATE | DELETE);

		int mask = READ | CREATE | UPDATE;
		System.out.println("------------");
		System.out.println(mask);
		System.out.println(mask & ALL);
	}
}

final class AuthorizationPermissionCollection extends PermissionCollection implements Serializable {

	private static final long serialVersionUID = -5559317100317040112L;

	private List<Permission> perms = new ArrayList<Permission>();

	public void add(Permission permission) {
		if (!(permission instanceof AuthorizationPermission)) {
			throw new IllegalArgumentException("invalid permission: " + permission);
		}
		if (isReadOnly()) {
			throw new SecurityException("attempt to add a Permission to a readonly PermissionCollection");
		}
		synchronized (this) {
			perms.add(0, permission);
		}
	}

	public boolean implies(Permission permission) {
		if (!(permission instanceof AuthorizationPermission)) {
			return false;
		}
		AuthorizationPermission np = (AuthorizationPermission) permission;
		int desired = np.getMask();
		int effective = 0;
		int needed = desired;
		synchronized (this) {
			int len = perms.size();
			for (int i = 0; i < len; i++) {
				AuthorizationPermission x = (AuthorizationPermission) perms.get(i);
				if (x.impliesIgnoreMask(np) && (needed & x.getMask()) != 0) {
					effective |= x.getMask();
					if (((effective & desired) == desired) && x.impliesIgnoreMask(np)) {
						return true;
					}
					needed = (desired ^ effective);
				}
			}
		}
		return false;
	}

	public Enumeration<Permission> elements() {
		synchronized (this) {
			return Collections.enumeration(perms);
		}
	}
}


text:
<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V5.0//EN"
"http://docbook.org/xml/5.0/dtd/docbook.dtd" [
<!ENTITY aqd_version SYSTEM "../version.txt">
]>
<refentry xml:id="aq_add_alias"
	  xmlns="http://docbook.org/ns/docbook"
	  xmlns:xi="http://www.w3.org/2001/XInclude">
    <refmeta>
	<refentrytitle>aq_add_alias</refentrytitle>
	<manvolnum>1</manvolnum>
	<refmiscinfo class="version">&aqd_version;</refmiscinfo>
	<refmiscinfo class="manual">Aquilon Commands</refmiscinfo>
    </refmeta>

    <refnamediv>
	<refname>aq add alias</refname>
	<refpurpose>
	    Add a DNS alias
	</refpurpose>
	<refclass>Aquilon</refclass>
    </refnamediv>

    <refsynopsisdiv>
	<cmdsynopsis>
	    <command>aq add alias</command>
	    <group>
		<synopfragmentref linkend="global-options">Global options</synopfragmentref>
	    </group>
	    <group>
		<synopfragmentref linkend="change-management">Change management</synopfragmentref>
	    </group>
	    <arg choice="plain"><option>--fqdn <replaceable>ALIAS</replaceable></option></arg>
	    <arg choice="plain"><option>--target <replaceable>TARGET</replaceable></option></arg>
	    <arg><option>--ttl <replaceable>TTL</replaceable></option></arg>
	    <arg><option>--comments <replaceable>COMMENTS</replaceable></option></arg>
	    <arg><option>--dns_environment <replaceable>ENV</replaceable></option></arg>
	    <arg><option>--target_environment <replaceable>ENV</replaceable></option></arg>
	    <group>
		<arg choice="plain"><option>--grn <replaceable>GRN</replaceable></option></arg>
		<arg choice="plain"><option>--eon_id <replaceable>EONID</replaceable></option></arg>
	    </group>
	    <xi:include href="../common/change_management.xml"/>
	    <xi:include href="../common/global_options.xml"/>
	</cmdsynopsis>
    </refsynopsisdiv>

    <refsect1>
	<title>Description</title>
	<para>
	    The <command>aq add alias</command> command creates a DNS alias (CNAME record).
	</para>
    </refsect1>

    <refsect1>
	<title>Options</title>
	<variablelist>
	    <title>Command-specific options</title>
	    <varlistentry>
		<term>
		    <option>--fqdn <replaceable>ALIAS</replaceable></option>
		</term>
		<listitem>
		    <para>
			The name of the alias to create.
		    </para>
		</listitem>
	    </varlistentry>
	    <varlistentry>
		<term>
		    <option>--target <replaceable>TARGET</replaceable></option>
		</term>
		<listitem>
		    <para>
			The name of the target the alias should point to. If the target does not exist,
			and the DNS domain of the target is marked as restricted, then a placeholder
			entry will be created. In all other cases, the target must exist prior to
			invoking the <command>aq add alias</command> command.
		    </para>
		</listitem>
	    </varlistentry>
	    <varlistentry>
		<term>
		    <option>--dns_environment <replaceable>ENV</replaceable></option>
		</term>
		<listitem>
		    <para>
			The name of the DNS environment where the alias should be created. It is possible to create
      an alias for a target in a different DNS environment by using --target_environment.
		    </para>
		</listitem>
	    </varlistentry>
	    <varlistentry>
		<term>
		    <option>--target_environment <replaceable>ENV</replaceable></option>
		</term>
		<listitem>
		    <para>
			The name of the DNS environment where the target lives if it is different from where the
			alias is created. The target would be in the same dns enviornment as the alias if it is
      not specified.
		    </para>
		</listitem>
	    </varlistentry>
	    <varlistentry>
		<term>
		    <option>--ttl <replaceable>TTL</replaceable></option>
		</term>
		<listitem>
		    <para>
			The TTL of the record in number of seconds.
		    </para>
		</listitem>
	    </varlistentry>
	    <varlistentry>
		<term>
		    <option>--comments <replaceable>COMMENTS</replaceable></option>
		</term>
		<listitem>
		    <para>
			Short description of the purpose of the alias.
		    </para>
		</listitem>
	    </varlistentry>
	    <varlistentry>
		<term>
		    <option>--grn <replaceable>GRN</replaceable></option>,
		    <option>--eon_id <replaceable>EON_ID</replaceable></option>
		</term>
		<listitem>
		    <para>
			The owner GRN of the personality to be created. Scripts should use the
			numeric <replaceable>EON_ID</replaceable>, the textual <replaceable>GRN</replaceable> is
			more suitable for humans.
		    </para>
		</listitem>
	    </varlistentry>
	</variablelist>
	<xi:include href="../common/change_management_desc.xml"/>
	<xi:include href="../common/global_options_desc.xml"/>
    </refsect1>

    <refsect1>
	<title>See also</title>
	<para>
	    <citerefentry><refentrytitle>aq_del_alias</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
	    <citerefentry><refentrytitle>aq_update_alias</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
	    <citerefentry><refentrytitle>aq_show_alias</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
	    <citerefentry><refentrytitle>aq_add_dns_environment</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
	    <citerefentry><refentrytitle>aq_search_dns</refentrytitle><manvolnum>1</manvolnum></citerefentry>
	</para>
    </refsect1>
</refentry>

<!-- vim: set ai sw=4: -->


text:
package io.femo.http;

import io.femo.http.transport.Http11Transport;
import org.jetbrains.annotations.Contract;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * Created by felix on 6/9/16.
 */
public abstract class HttpTransport implements Driver {

    private static ThreadLocal<HttpTransport> version11 = new ReadonlyThreadLocal<HttpTransport>() {
        @Contract(" -> !null")
        @Override
        protected HttpTransport initialValue() {
            return new Http11Transport();
        }

    };

    public abstract void write(HttpRequest httpRequest, OutputStream outputStream);
    public abstract void write(HttpResponse httpResponse, OutputStream outputStream, InputStream entityStream);

    public abstract HttpRequest readRequest(InputStream inputStream) throws IOException;
    public abstract HttpResponse readResponse(InputStream inputStream, OutputStream pipe) throws IOException;

    public static HttpTransport version11() {
        return version11.get();
    }

    public static HttpTransport def() {
        return version11();
    }
}


text:
package version

import (
	"fmt"
	"os"
	"runtime"
	"strconv"
	"time"
)

var (
	app       = "vpp-agent"
	version   = "v3.2.0-dev"
	gitCommit = "unknown"
	gitBranch = "HEAD"
	buildUser = "unknown"
	buildHost = "unknown"
	buildDate = ""
)

var buildTime time.Time
var revision string

func init() {
	if buildDate == "" {
		buildDate = getBuildDate()
	}
	if buildDate != "" {
		buildstampInt64, _ := strconv.ParseInt(buildDate, 10, 64)
		buildTime = time.Unix(buildstampInt64, 0)
	}
	revision = gitCommit
	if len(revision) > 7 {
		revision = revision[:7]
	}
	if gitBranch != "HEAD" {
		revision += fmt.Sprintf("@%s", gitBranch)
	}
}

func getBuildDate() string {
	bin, err := os.Executable()
	if err != nil {
		return ""
	}
	info, err := os.Stat(bin)
	if err != nil {
		return ""
	}
	return fmt.Sprint(info.ModTime().Unix())
}

// App returns app name.
func App() string {
	return app
}

// Version returns version string.
func Version() string {
	return version
}

// GitCommit returns git commit hash.
func GitCommit() string {
	return gitCommit
}

// GitBranch returns git branch name.
func GitBranch() string {
	return gitBranch
}

// BuildUser returns username.
func BuildUser() string {
	return buildUser
}

// BuildHost returns host name.
func BuildHost() string {
	return buildHost
}

// BuildTime returns Unix time when Agent was compiled.
func BuildTime() int64 {
	return buildTime.Unix()
}

// Data returns version data.
func Data() (ver, rev, date string) {
	return version, revision, buildTime.Format(time.UnixDate)
}

func Short() string {
	return fmt.Sprintf(`%s %s`, app, version)
}

func BuiltOn() string {
	stamp := buildTime.Format(time.UnixDate)
	if !buildTime.IsZero() {
		stamp += fmt.Sprintf(" (%s)", timeAgo(buildTime))
	}
	return stamp
}

func BuiltBy() string {
	return fmt.Sprintf("%s@%s (%s %s/%s)",
		buildUser, buildHost, runtime.Version(), runtime.GOOS, runtime.GOARCH,
	)
}

// Info returns string with complete version info on single line.
func Info() string {
	return fmt.Sprintf(`%s %s (%s) built by %s@%s on %v`,
		app, version, revision, buildUser, buildHost, BuiltOn(),
	)
}

// Detail returns string with detailed version info on separate lines.
func Detail() string {
	return fmt.Sprintf(`%s
  Version:   	%s
  Branch:   	%s
  Revision:  	%s
  Built By:  	%s@%s
  Build Date:	%s
  Go Runtime:	%s (%s/%s)`,
		app, version, gitBranch, revision,
		buildUser, buildHost, buildTime.Format(time.UnixDate),
		runtime.Version(), runtime.GOOS, runtime.GOARCH,
	)
}

func timeAgo(t time.Time) string {
	const timeDay = time.Hour * 24
	if ago := time.Since(t); ago > timeDay {
		return fmt.Sprintf("%v days ago", float64(ago.Round(timeDay)/timeDay))
	} else if ago > time.Hour {
		return fmt.Sprintf("%v hours ago", ago.Round(time.Hour).Hours())
	} else if ago > time.Minute {
		return fmt.Sprintf("%v minutes ago", ago.Round(time.Minute).Minutes())
	}
	return "just now"
}


text:
<!DOCTYPE html>
<meta charset=utf-8>
<title>IDBFactory deleteDatabase(): request properties on success</title>
<link rel="help" href="https://w3c.github.io/IndexedDB/#dom-idbfactory-deleteDatabase">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=resources/support.js></script>
<script>

async_test(t => {
  const dbname = document.location + '-' + t.name;
  const rq = indexedDB.deleteDatabase(dbname);
  rq.onerror = t.unreached_func('deleteDatabase should succeed');
  rq.onsuccess = t.step_func(() => {
    assert_equals(
      rq.readyState, 'done',
      'request done flag should be set on success');
    assert_equals(
      rq.result, undefined,
      'request result should still be set to undefined on success');
    assert_equals(
      rq.error, null,
      'request error should be null on success');
    t.done();
  });
}, 'Properties of IDBOpenDBRequest during IDBFactory deleteDatabase()');

</script>


text:
package com.bluesunshine.douban4droid.model.v2;

import com.bluesunshine.douban4droid.model.IDoubanObject;
import com.bluesunshine.douban4droid.model.common.DoubanImageObj;
import com.google.api.client.util.Key;

/**
 *
 * @author Sean Guo <seanguo85@qq.com>
 *
 */
public class DoubanCastObject implements IDoubanObject {

  private DoubanImageObj avatars;

  @Key
  private String alt;

  @Key
  private String id;

  @Key
  private String name;

  @Override
  public String getObjName() {
    return "DoubanCastObject";
  }

  public DoubanImageObj getAvatars() {
    return avatars;
  }

  public String getAlt() {
    return alt;
  }

  public String getId() {
    return id;
  }

  public String getName() {
    return name;
  }

  @Override
  public String toString() {
    return "DoubanCastObject [avatars=" + avatars + ", alt=" + alt + ", id=" + id + ", name=" + name + "]";
  }

}


text:
/**
 * Problem: Generate all combinations of n pairs of parentheses
 *
 * Solution: DFS--invariant is #left<#right, and if #left=n, can only add right parentheses.
 *           For normal cases, continue to add left parentheses and then add right parentheses
 */
import java.util.*;
public class GenerateParentheses{
	public ArrayList<String> generateParenthesis(int n){
		ArrayList<String> result = new ArrayList<String>();
		generate(result,n,0,0,"");
		return result;
	}

	public void generate(ArrayList<String> result, int n, int left, int right, String s){
		//invariant
		if(left < right){
			return;
		}
		//found a combination
		if(left==right && left==n){
			result.add(s);
			return;
		}

		//left parentheses reach maximum, can only add right parentheses
		if(left == n){
			generate(result,n,left,right+1,s+")");
			return;
		}

		//continue to add left and right parentheses
		generate(result,n,left+1,right,s+"(");
		generate(result,n,left,right+1,s+")");
	}
}