text:
(function($) {

	$.fn.diCrossfade = function(settings) {

		var transitions = {
			DEFAULT: 0,
			CROSSFADE: 1,
			SLIDE_L2R: 2,
			SLIDE_R2L: 3,
			SLIDE_T2B: 4,
			SLIDE_B2T: 5
		};

		var transition_styles = {
			DEFAULT: 0,
			BOTH_SLIDING: 1,
			ONLY_NEW_SLIDING: 2
		};

		var slides_mode = {
			SCREEN: 0, // old approach: pic/title/content shown on 'screen'
			SELF: 1 // new approach: each slide gets treated as a 'screen'
		};

		var slide_index = {
			OLD: 1,
			NEW: 2
		};

		settings = $.extend({
			$slide: null,
			href: null,
			hrefTarget: null,
			pic: null,
			transition: transitions.CROSSFADE,
			transition_style: transition_styles.BOTH_SLIDING,
			reverse_animation: false,
			duration: 2000
		}, settings || {});

		var mode = settings.pic ? slides_mode.SCREEN : slides_mode.SELF;

		// if set to 'default'
		settings.transition_style = settings.transition_style || transition_styles.BOTH_SLIDING;

		if (settings.reverse_animation)
		{
			switch (settings.transition)
			{
				case transitions.SLIDE_B2T:
					settings.transition = transitions.SLIDE_T2B;
					break;
				case transitions.SLIDE_T2B:
					settings.transition = transitions.SLIDE_B2T;
					break;
				case transitions.SLIDE_L2R:
					settings.transition = transitions.SLIDE_R2L;
					break;
				case transitions.SLIDE_R2L:
					settings.transition = transitions.SLIDE_L2R;
					break;
			}
		}

		function reset_href($e)
		{
			if ($e.get(0).tagName.toUpperCase() == 'A')
			{
				$e.attr('href', '#');
			}
			else
			{
				$e.css({cursor: 'default'}).off('click.trequartista');
			}
		}

		function set_href($e, href, hrefTarget)
		{
			if (!href)
			{
				$e.css({cursor: 'default'});

				return false;
			}

			hrefTarget = hrefTarget || '_self';

			if ($e.get(0).tagName.toUpperCase() == 'A')
			{
				$e.attr('href', href).attr('target', hrefTarget);
			}
			else
			{
				(function($e, href, hrefTarget) {
					$e
						.css({cursor: 'pointer'})
						.on('click.trequartista', function() {
							if (hrefTarget != '_self') {
								window.open(href, hrefTarget);
							} else {
								window.location.href = href;
							}

							return false;
						});
				})($e, href, hrefTarget);
			}
		}

		function dasAnimator($element, properties, duration, callback)
		{
			if ($.support.transition && $.transit)
			{
				$element.transit(properties, duration, callback);
			}
			else
			{
				$element.animate(properties, duration, callback);
			}
		}

		return this.each(function() {

			function getSlideElement(idx)
			{
				var $e;

				switch (mode)
				{
					default:
					case slides_mode.SCREEN:
						$e = $('

').css({
							backgroundPosition: 'center center',
							backgroundImage: idx == slide_index.OLD
								? $this.css('background-image')
								: 'url(' + settings.pic + ')',
							backgroundSize: 'cover'
						});
						break;

					case slides_mode.SELF:
						//console.log('cloning', $this.children());

						$e = idx == slide_index.OLD
							? $('

').append($this.children().clone())
							: settings.$slide.clone();
						break;
				}

				$e.css(css_ar2).css(get_initial_positions(idx));

				return $e;
			}

			var $this = $(this),
				$helper = $this.clone().attr('id', ''),
				w = '100%', //$this.width(),
				h = '100%', //$this.height(),

				css_ar = {
					display: 'block',
					position: 'absolute',
					//margin: 0,
					//padding: 0,
					zIndex: (parseInt($this.css('z-index'), 10) || 0) + 1,
					width: w,
					height: h
				},

				css_ar2 = {
					display: 'block',
					position: 'absolute',
					//margin: 0,
					//padding: 0,
					width: w,
					height: h
				};

			if (mode == slides_mode.SELF)
			{
				$helper.empty();
			}

			switch (settings.transition)
			{
				case transitions.DEFAULT:
				case transitions.CROSSFADE:

					$.extend(css_ar, {
						opacity: 0
					});

					switch (mode)
					{
						default:
						case slides_mode.SCREEN:
							$.extend(css_ar, {
								backgroundImage: 'url(' + settings.pic + ')'
							});
							break;

						case slides_mode.SELF:
							$helper.append(getSlideElement(slide_index.NEW));
							break;
					}

					break;

				case transitions.SLIDE_L2R:
				case transitions.SLIDE_R2L:
				case transitions.SLIDE_T2B:
				case transitions.SLIDE_B2T:

					var $slideContainer = $('

'),
						$oldSlide = getSlideElement(slide_index.OLD),
						$newSlide = getSlideElement(slide_index.NEW);

					$slideContainer.css($.extend(css_ar2, {
						width: w * 2,
						height: h * 2
					}));

					$.extend(css_ar, {
						overflow: 'hidden'
					});

					if (settings.transition_style == transition_styles.BOTH_SLIDING)
					{
						$helper.append($slideContainer.append($oldSlide).append($newSlide));
					}
					else if (settings.transition_style == transition_styles.ONLY_NEW_SLIDING)
					{
						$helper.append($newSlide);
					}

					break;
			}

			$helper.css(css_ar).insertBefore($this);

			reset_href($helper);
			set_href($helper, settings.href, settings.hrefTarget);
			reset_href($this);
			set_href($this, settings.href, settings.hrefTarget);

			switch (settings.transition)
			{
				case transitions.DEFAULT:
				case transitions.CROSSFADE:

					dasAnimator($helper, {opacity: 1}, settings.duration, function() {
						after_transition();
					});

					break;

				case transitions.SLIDE_L2R:
				case transitions.SLIDE_R2L:
				case transitions.SLIDE_T2B:
				case transitions.SLIDE_B2T:

					var $obj;

					if (settings.transition_style == transition_styles.BOTH_SLIDING)
					{
						$obj = $slideContainer;
					}
					else if (settings.transition_style == transition_styles.ONLY_NEW_SLIDING)
					{
						$obj = $newSlide;
					}

					dasAnimator($obj, get_animation(), settings.duration, function() {
						after_transition();
					});

					break;
			}

			function after_transition()
			{
				switch (mode)
				{
					default:
					case slides_mode.SCREEN:
						$this.css({
							backgroundImage: 'url(' + settings.pic + ')'
						});
						break;

					case slides_mode.SELF:
						$this.empty();
						$helper.children().appendTo($this);
						break;
				}

				$helper.remove();
			}

			function get_initial_positions(slideIdx)
			{
				var ar = {
					left: 0,
					top: 0
				};

				switch (settings.transition)
				{
					case transitions.SLIDE_L2R:
						ar.marginLeft = slideIdx == slide_index.OLD ? 0 : -w;

						break;

					case transitions.SLIDE_R2L:
						ar.marginLeft = slideIdx == slide_index.OLD ? 0 : w;

						break;

					case transitions.SLIDE_T2B:
						ar.marginTop = slideIdx == slide_index.OLD ? 0 : -h;

						break;

					case transitions.SLIDE_B2T:
						ar.marginTop = slideIdx == slide_index.OLD ? 0 : h;

						break;
				}

				return ar;
			}

			function get_animation()
			{
			    var ar = {};

				switch (settings.transition)
				{
					case transitions.SLIDE_L2R:
						if (settings.transition_style == transition_styles.BOTH_SLIDING)
							ar.marginLeft = w;
						else if (settings.transition_style == transition_styles.ONLY_NEW_SLIDING)
							ar.marginLeft = 0;

						break;

					case transitions.SLIDE_R2L:
						if (settings.transition_style == transition_styles.BOTH_SLIDING)
							ar.marginLeft = -w;
						else if (settings.transition_style == transition_styles.ONLY_NEW_SLIDING)
							ar.marginLeft = 0;

						break;

					case transitions.SLIDE_T2B:
						if (settings.transition_style == transition_styles.BOTH_SLIDING)
							ar.marginTop = h;
						else if (settings.transition_style == transition_styles.ONLY_NEW_SLIDING)
							ar.marginTop = 0;

						break;

					case transitions.SLIDE_B2T:
						if (settings.transition_style == transition_styles.BOTH_SLIDING)
							ar.marginTop = -h;
						else if (settings.transition_style == transition_styles.ONLY_NEW_SLIDING)
							ar.marginTop = 0;

						break;
				}

				return ar;
			}

		});

	}

}(jQuery));


text:
/**
 * Module dependencies.
 */
var util = require('util')
  , OAuth2Strategy = require('passport-oauth2')
  , Profile = require('./profile')
  , InternalOAuthError = require('passport-oauth2').InternalOAuthError
  , localOauth2 = require('./oauth2')
  , querystring= require('querystring')
  ;

/**
 * `Strategy` constructor.
 *
 * The weixin authentication strategy authenticates requests by delegating to
 * weixin using the OAuth 2.0 protocol.
 *
 * Applications must supply a `verify` callback which accepts an `accessToken`,
 * `refreshToken` and service-specific `profile`, and then calls the `done`
 * callback supplying a `user`, which should be set to `false` if the
 * credentials are not valid.  If an exception occured, `err` should be set.
 *
 * Options:
 *   - `clientID`      your weixin application's Client ID
 *   - `clientSecret`  your weixin application's Client Secret
 *   - `callbackURL`   URL to which weixin will redirect the user after granting authorization
 *   - `scope`         valid scopes include:
 *                     'snsapi_base', 'snsapi_login'.
 *                     (see http://developer.github.com/v3/oauth/#scopes for more info)
 *   — `userAgent`     optional, you can set your own userAgent
 *
 * Examples:
 *
 *     passport.use(new WeixinStrategy({
 *         clientID: '123-456-789',
 *         clientSecret: 'shhh-its-a-secret'
 *         callbackURL: 'https://www.example.net/auth/weixin/callback',
 *         userAgent: 'myapp.com'
 *       },
 *       function(accessToken, refreshToken, profile, done) {
 *         User.findOrCreate(..., function (err, user) {
 *           done(err, user);
 *         });
 *       }
 *     ));
 *
 * @param {Object} options
 * @param {Function} verify
 * @api public
 */
function Strategy(options, verify) {
  options = options || {};
  options.authorizationURL = options.authorizationURL || 'https://open.weixin.qq.com/connect/qrconnect';
  options.tokenURL = options.tokenURL || 'https://api.weixin.qq.com/sns/oauth2/access_token';
  options.scopeSeparator = options.scopeSeparator || ',';
  options.customHeaders = options.customHeaders || {};
  options.scope = options.scope || 'snsapi_login';

  if (!options.customHeaders['User-Agent']) {
    options.customHeaders['User-Agent'] = options.userAgent || 'passport-weixin';
  }

  OAuth2Strategy.call(this, options, verify);
  this.name = 'weixin';
  this._appid = options.clientID;
  this._secret = options.clientSecret;
  this._requireState = options.requireState === undefined ? true : options.requireState;
  this._userProfileURL = options.userProfileURL || 'https://api.weixin.qq.com/sns/userinfo';
  this._authorizationURL = options.authorizationURL;
  // hack for weixin
  this.authenticate = localOauth2.authenticate;
  this._loadUserProfile = localOauth2._loadUserProfile;
}

/**
 * Inherit from `OAuth2Strategy`.
 */
util.inherits(Strategy, OAuth2Strategy);

/**
 * Different with passport-oauth2's method 'getAuthorizeUrl', Weixin not include param 'client_id'
 * @param params
 * @returns {string}
 */
Strategy.prototype.getAuthorizeUrl= function( params ) {
  return this._authorizationURL + "?" + querystring.stringify(params);
}
Strategy.prototype.authorizationParams = function(options){
  options.appid = this._appid;
  if(this._requireState && !options.state){
    throw new Error('Authentication Parameter `state` Required');
  }else{
    return options;
  }
};

Strategy.prototype.tokenParams = function(options){
  options.appid = this._appid;
  options.secret = this._secret;
  return options;
};

/**
 * Retrieve user profile from weixin.
 *
 * This function constructs a normalized profile, with the following properties:
 *
 *   - `provider`         always set to `weixin`
 *   - `id`               the user's unionid ID
 *   - `displayName`      the user's nickname
 *   - `profileUrl`       the URL of the profile for the user on weixin
 *
 * @param {String} accessToken
 * @param {Function} done
 * @api protected
 */
Strategy.prototype.userProfile = function(accessToken, openid, done) {
  var userProfileURL = this._userProfileURL + '?openid=' + openid;
  this._oauth2.get(userProfileURL, accessToken, function(err, body, res) {
    var json;
    if (err) {
      return done(new InternalOAuthError('Failed to fetch user profile', err));
    }

    try {
      json = JSON.parse(body);
    } catch (ex) {
      return done(new Error('Failed to parse user profile'));
    }

    var profile = Profile.parse(json);
    profile.provider = 'weixin';
    profile._raw = body;
    profile._json = json;

    done(null, profile);
  });
}

/**
 * Expose `Strategy`.
 */
module.exports = Strategy;

redpajama_set_name: RedPajamaGithub


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.apache.lenya</groupId>
    <artifactId>lenya-parent</artifactId>
    <version>2.2.0-SNAPSHOT</version>
    <relativePath>../org.apache.lenya.parent/pom.xml</relativePath>
  </parent>

  <groupId>org.apache.lenya</groupId>
  <artifactId>lenya-core-cocoon</artifactId>
  <packaging>jar</packaging>
  <name>Apache Lenya Core Cocoon components</name>
  <description>Contains core cocoon components defined for Lenya</description>

  <dependencies>
  <dependency>
      <groupId>org.apache.lenya</groupId>
      <artifactId>lenya-core-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.lenya</groupId>
      <artifactId>lenya-core-impl</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.lenya</groupId>
      <artifactId>lenya-core-repository-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.lenya</groupId>
      <artifactId>lenya-core-publication-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.lenya</groupId>
      <artifactId>lenya-core-publication-impl</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.lenya</groupId>
      <artifactId>lenya-core-document-api</artifactId>
    </dependency>
     <dependency>
      <groupId>org.apache.lenya</groupId>
      <artifactId>lenya-core-utils</artifactId>
    </dependency>
  <!-- TODO : see if all theses dependencies are required -->
    <dependency>
      <groupId>org.apache.cocoon</groupId>
      <artifactId>cocoon-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.cocoon</groupId>
      <artifactId>cocoon-servlet-service-components</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.cocoon</groupId>
      <artifactId>cocoon-template-impl</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.cocoon</groupId>
      <artifactId>cocoon-flowscript-impl</artifactId>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.4</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
</project>


text:
package org.apache.geode.metrics.function.executions;

import java.io.Serializable;

public class ExecutionsTimerValues implements Serializable {
  final String functionId;
  final boolean succeeded;
  final long count;
  final double totalTime;

  ExecutionsTimerValues(String functionId, boolean succeeded, long count, double totalTime) {
    this.functionId = functionId;
    this.succeeded = succeeded;
    this.count = count;
    this.totalTime = totalTime;
  }

  @Override
  public String toString() {
    return "ExecutionsTimerValues{" +
        "functionId='" + functionId + '\'' +
        ", succeeded=" + succeeded +
        ", count=" + count +
        ", totalTime=" + totalTime +
        '}';
  }
}


text:
@-webkit-keyframes uil-ring-anim {
  0% {
    -ms-transform: rotate(0deg);
    -moz-transform: rotate(0deg);
    -webkit-transform: rotate(0deg);
    -o-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  100% {
    -ms-transform: rotate(360deg);
    -moz-transform: rotate(360deg);
    -webkit-transform: rotate(360deg);
    -o-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}
@-webkit-keyframes uil-ring-anim {
  0% {
    -ms-transform: rotate(0deg);
    -moz-transform: rotate(0deg);
    -webkit-transform: rotate(0deg);
    -o-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  100% {
    -ms-transform: rotate(360deg);
    -moz-transform: rotate(360deg);
    -webkit-transform: rotate(360deg);
    -o-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}
@-moz-keyframes uil-ring-anim {
  0% {
    -ms-transform: rotate(0deg);
    -moz-transform: rotate(0deg);
    -webkit-transform: rotate(0deg);
    -o-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  100% {
    -ms-transform: rotate(360deg);
    -moz-transform: rotate(360deg);
    -webkit-transform: rotate(360deg);
    -o-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}
@-ms-keyframes uil-ring-anim {
  0% {
    -ms-transform: rotate(0deg);
    -moz-transform: rotate(0deg);
    -webkit-transform: rotate(0deg);
    -o-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  100% {
    -ms-transform: rotate(360deg);
    -moz-transform: rotate(360deg);
    -webkit-transform: rotate(360deg);
    -o-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}
@-moz-keyframes uil-ring-anim {
  0% {
    -ms-transform: rotate(0deg);
    -moz-transform: rotate(0deg);
    -webkit-transform: rotate(0deg);
    -o-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  100% {
    -ms-transform: rotate(360deg);
    -moz-transform: rotate(360deg);
    -webkit-transform: rotate(360deg);
    -o-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}
@-webkit-keyframes uil-ring-anim {
  0% {
    -ms-transform: rotate(0deg);
    -moz-transform: rotate(0deg);
    -webkit-transform: rotate(0deg);
    -o-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  100% {
    -ms-transform: rotate(360deg);
    -moz-transform: rotate(360deg);
    -webkit-transform: rotate(360deg);
    -o-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}
@-o-keyframes uil-ring-anim {
  0% {
    -ms-transform: rotate(0deg);
    -moz-transform: rotate(0deg);
    -webkit-transform: rotate(0deg);
    -o-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  100% {
    -ms-transform: rotate(360deg);
    -moz-transform: rotate(360deg);
    -webkit-transform: rotate(360deg);
    -o-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}
@keyframes uil-ring-anim {
  0% {
    -ms-transform: rotate(0deg);
    -moz-transform: rotate(0deg);
    -webkit-transform: rotate(0deg);
    -o-transform: rotate(0deg);
    transform: rotate(0deg);
  }
  100% {
    -ms-transform: rotate(360deg);
    -moz-transform: rotate(360deg);
    -webkit-transform: rotate(360deg);
    -o-transform: rotate(360deg);
    transform: rotate(360deg);
  }
}
.uil-ring-css {
  background: none;
  position: relative;
  width: 200px;
  height: 200px;
}
.uil-ring-css > div {
  position: absolute;
  display: block;
  width: 160px;
  height: 160px;
  top: 20px;
  left: 20px;
  border-radius: 80px;
  box-shadow: 0 6px 0 0 #59ebff;
  -ms-animation: uil-ring-anim 1s linear infinite;
  -moz-animation: uil-ring-anim 1s linear infinite;
  -webkit-animation: uil-ring-anim 1s linear infinite;
  -o-animation: uil-ring-anim 1s linear infinite;
  animation: uil-ring-anim 1s linear infinite;
}
.uil-ring-css.mask {
	position: fixed !important;
	width: 100%;
	height: 100%;
	left: 0;
	top: 0;
	z-index: 99999999;
	background-image: url(../img/ring.svg);
	background-size: 250px 250px;
	background-repeat: no-repeat;
	background-position: center;
	background-color: rgba(0,0,0,0.5);
}
/*

Masked text

*/


text:
from concurrent import futures
import logging
from multiprocessing import cpu_count
from lxml import html
from lxml.cssselect import CSSSelector
from math import ceil
import re
from urlparse import urljoin
from .. import SITE_URL
from ..cache import cached_storage

TALKS_LIST_URL_FMT = "http://www.ted.com/talks/quick-list?sort=date&order=asc&page=%d"

_PAGINATION_INFO_SELECTOR = CSSSelector('div#wrapper-inner div:nth-child(2) h2')
_PAGINATION_INFO_RE = re.compile("Showing 1 - (\d+) of \s*(\d+)")

_TALKS_URLS_SELECTOR = CSSSelector('table.downloads tr td:nth-child(3) a')

TALKS_URLS_BLACKLIST = [
    # No downloads
    'http://www.ted.com/talks/rokia_traore_sings_m_bifo.html',
    'http://www.ted.com/talks/rokia_traore_sings_kounandi.html',
    'http://www.ted.com/talks/andrew_stanton_the_clues_to_a_great_story.html',
]

def _parse_page(page_num):
    return html.parse(TALKS_LIST_URL_FMT % page_num)

def _get_num_pages():
    logging.debug('Trying to find out the number of talk list pages...')
    elements = _PAGINATION_INFO_SELECTOR(_parse_page(1))
    match = _PAGINATION_INFO_RE.search(elements[0].text_content())

    num_talks_urls_per_page, num_talks_urls = [int(g) for g in match.groups()]
    logging.debug(
        "Found %d talk url(s), %d per talk list page",
        num_talks_urls, num_talks_urls_per_page
    )

    num_pages = int(ceil(1.0 * num_talks_urls / num_talks_urls_per_page))
    logging.info("Found %d talk list page(s)", num_pages)
    return num_pages

def _get_talks_urls_from_page(page_num):
    logging.debug("Looking for talk urls on page #%d", page_num)
    talks_urls = [
        urljoin(SITE_URL, a.get('href'))
        for a in _TALKS_URLS_SELECTOR(_parse_page(page_num))
    ]
    logging.info("Found %d talk url(s) on page #%d", len(talks_urls), page_num)
    return talks_urls

def _get_talks_urls():
    logging.debug('Looking for talk urls...')

    num_workers = 2*cpu_count() # Network IO is the bottleneck
    with futures.ProcessPoolExecutor(max_workers=num_workers) as executor:
        talks_urls = sum(executor.map(
            _get_talks_urls_from_page,
            xrange(1, _get_num_pages()+1) # Talk list pages are 1-indexed
        ), [])

    # Remove the well-known problematic talk URLs (i.e. no downloads available)
    talks_urls = [url for url in talks_urls if url not in TALKS_URLS_BLACKLIST]

    logging.info("Found %d talk url(s) in total", len(talks_urls))
    return talks_urls

def _check_talks_urls_cache():
    logging.info('Looking for a cached version of talk urls...')
    if 'talks_urls' in cached_storage:
        # Cached version of talk urls is considered valid if:
        # 1. Real number of talk list pages is equal to the cached number
        # 2. Real number of talk urls on the last list page is equal to the
        #    cached number
        logging.info('Found a cached version of talk urls. Validating...')
        num_pages = cached_storage.get('num_of_talk_list_pages')
        if num_pages and num_pages == _get_num_pages():
            num_talks = cached_storage.get('num_of_talks_urls_on_last_page')
            if num_talks and num_talks == len(_get_talks_urls_from_page(num_pages)):
                logging.info('Found a valid cached version of talk urls')
                return True
        logging.warning('Cached version of talk urls is invalid')
        return False
    logging.info('Failed to find the cached version of talk url(s)')
    return False

def get_talks_urls():
    if not _check_talks_urls_cache():
        cached_storage['num_of_talk_list_pages'] = _get_num_pages()
        cached_storage['num_of_talks_urls_on_last_page'] = len(
            _get_talks_urls_from_page(cached_storage['num_of_talk_list_pages'])
        )
        cached_storage['talks_urls'] = _get_talks_urls()
    return cached_storage['talks_urls']


text:
import React from 'react';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import Table from 'components/Table';

storiesOf('Table', module)
  .add('standard', () => (
    <Table
      headers={
        <Table.Row>
          <Table.Header>One</Table.Header>
          <Table.Header>Two</Table.Header>
          <Table.Header sortable>Three</Table.Header>
        </Table.Row>
      }
    >
      <Table.Row>
        <Table.Cell>1</Table.Cell>
        <Table.Cell>Foo</Table.Cell>
        <Table.Cell>Bar</Table.Cell>
      </Table.Row>
      <Table.Row>
        <Table.Cell>2</Table.Cell>
        <Table.Cell>Foo</Table.Cell>
        <Table.Cell>Bar</Table.Cell>
      </Table.Row>
      <Table.Row>
        <Table.Cell>3</Table.Cell>
        <Table.Cell>Foo</Table.Cell>
        <Table.Cell>Bar</Table.Cell>
      </Table.Row>
      <Table.Row>
        <Table.Cell>4</Table.Cell>
        <Table.Cell>Foo</Table.Cell>
        <Table.Cell>Bar</Table.Cell>
      </Table.Row>
    </Table>
  ))
  .add('skeleton', () => <Table.Skeleton />)
  .add('small', () => (
    <Table.Small
      headers={
        <Table.Row>
          <Table.Header.Small>One</Table.Header.Small>
          <Table.Header.Small>Two</Table.Header.Small>
          <Table.Header.Small sortable>Three</Table.Header.Small>
        </Table.Row>
      }
    >
      <Table.Row>
        <Table.Cell.Small>1</Table.Cell.Small>
        <Table.Cell.Small>Foo</Table.Cell.Small>
        <Table.Cell.Small>Bar</Table.Cell.Small>
      </Table.Row>
      <Table.Row>
        <Table.Cell.Small>2</Table.Cell.Small>
        <Table.Cell.Small>Foo</Table.Cell.Small>
        <Table.Cell.Small>Bar</Table.Cell.Small>
      </Table.Row>
      <Table.Row>
        <Table.Cell.Small>3</Table.Cell.Small>
        <Table.Cell.Small>Foo</Table.Cell.Small>
        <Table.Cell.Small>Bar</Table.Cell.Small>
      </Table.Row>
      <Table.Row>
        <Table.Cell.Small>4</Table.Cell.Small>
        <Table.Cell.Small>Foo</Table.Cell.Small>
        <Table.Cell.Small>Bar</Table.Cell.Small>
      </Table.Row>
    </Table.Small>
  ))
  .add('small skeleton', () => <Table.Small.Skeleton />);


text:
package uk.gov.hmrc.play.partials

import play.api.mvc.RequestHeader
import scala.concurrent.Future

trait NonBlockingPartial extends FormPartial {

  def loadPartialFuture(url: String)(implicit request: RequestHeader) : Future[Partial] = {
    httpGet.GET[Partial](urlWithCsrfToken(url))
  }

}


text:
package org.adbcj.mysql.codec.packets;

import org.adbcj.mysql.codec.ClientRequest;

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

public class CommandRequest extends ClientRequest {

    private final Command command;

    public CommandRequest(Command command) {
        super();
        this.command = command;
    }

    public Command getCommand() {
        return command;
    }

    @Override
    public int getLength() {
        return 1;
    }

    @Override
    protected boolean hasPayload() {
        return false;
    }

    @Override
    public final void writeToOutputStream(OutputStream out) throws IOException {
        out.write(command.getCommandCode());
        if (hasPayload()) {
            writePayLoad(out);
        }
    }

    protected void writePayLoad(OutputStream out) throws IOException {

    }

    @Override
    public String toString() {
        return "CommandRequest{" +
                "command=" + command +
                '}';
    }
}


text:
<?php

namespace Trello\Model;

use Trello\ClientInterface;
use Trello\Api\ApiInterface;
use Trello\Exception\BadMethodCallException;

/**
 * @codeCoverageIgnore
 */
abstract class AbstractObject
{
    /**
     * @var ClientInterface
     */
    protected $client;

    /**
     * @var string
     */
    protected $apiName;

    /**
     * @var ApiInterface
     */
    protected $api;

    /**
     * @var array
     */
    protected $fields;

    /**
     * Default load params, should be overwritten
     * in child classes
     *
     * @var array
     */
    protected $loadParams = ['fields' => 'all'];

    /**
     * @var string
     */
    protected $id;

    /**
     * @var array
     */
    protected $data;

    /**
     * Constructor.
     *
     * @param ClientInterface $client the Trello client
     * @param string $id the id of the object
     */
    public function __construct(ClientInterface $client, $id = null)
    {
        $this->client = $client;
        $this->api = $client->api($this->apiName);

        $this->fields = $this->api->getFields();

        if ($id) {
            $this->id = $id;
            $this->refresh();
        }
    }

    /**
     * {@inheritdoc}
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * {@inheritdoc}
     */
    public function refresh()
    {
        $this->preRefresh();
        $this->data = $this->api->show($this->id, $this->loadParams);
        $this->postRefresh();

        return $this;
    }

    /**
     * {@inheritdoc}
     */
    public function save()
    {
        try {
            $this->preSave();
            $this->id ? $this->update() : $this->create();
            $this->postSave();
        } catch (BadMethodCallException $e) {
            throw new BadMethodCallException(sprintf(
                "You can't %s %s objects.",
                $this->id ? 'update' : 'create',
                get_called_class()
            ));
        }

        return $this->refresh();
    }

    /**
     * {@inheritdoc}
     */
    public function remove()
    {
        try {
            $this->preRemove();
            $this->api->remove($this->id);
            $this->postRemove();
        } catch (BadMethodCallException $e) {
            throw new BadMethodCallException(sprintf(
                "You can't remove %s objects.",
                get_called_class()
            ));
        }

        return $this;
    }

    /**
     * {@inheritdoc}
     */
    public function getData()
    {
        return $this->data;
    }

    /**
     * {@inheritdoc}
     */
    public function setData(array $data)
    {
        $this->data = $data;

        return $this;
    }

    /**
     * Update the object through API
     *
     * @return AbstractObject
     */
    protected function update()
    {
        $this->preUpdate();
        $this->data = $this->api->update($this->id, $this->data);
        $this->postUpdate();

        return $this;
    }

    /**
     * Create the object through API
     *
     * @return AbstractObject
     */
    protected function create()
    {
        $this->preCreate();
        $this->data = $this->api->create($this->data);
        $this->id = $this->data['id'];
        $this->postCreate();

        return $this;
    }

    /**
     * Called before saving (creating or updating) an entity
     */
    protected function preSave()
    {
    }

    /**
     * Called after saving (creating or updating) an entity
     */
    protected function postSave()
    {
    }

    /**
     * Called before creating an entity
     */
    protected function preCreate()
    {
    }

    /**
     * Called after creating an entity
     */
    protected function postCreate()
    {
    }

    /**
     * Called before updating an entity
     */
    protected function preUpdate()
    {
    }

    /**
     * Called after updating an entity
     */
    protected function postUpdate()
    {
    }

    /**
     * Called before refreshing an entity
     */
    protected function preRefresh()
    {
    }

    /**
     * Called after refreshing an entity
     */
    protected function postRefresh()
    {
    }

    /**
     * Called before removing an entity
     */
    protected function preRemove()
    {
    }

    /**
     * Called after removing an entity
     */
    protected function postRemove()
    {
    }
}


text:
#include "config.h"
#include "WebDOMNodeFilter.h"

#include "WebDOMNode.h"
#include "WebNativeNodeFilterCondition.h"

short WebDOMNodeFilter::acceptNode(const WebDOMNode& n)
{
    if (!impl())
        return 0;

    return impl()->acceptNode(0, toWebCore(n));
}

WebDOMNodeFilter toWebKit(WebUserNodeFilter* value)
{
    RefPtr<WebCore::NodeFilter> listener = WebCore::NodeFilter::create(WebNativeNodeFilterCondition::create(value));
    return WebDOMNodeFilter(listener.get());
}


text:
class AddNotesColumnToGuides < ActiveRecord::Migration
  def change
    add_column :guides, :notes, :text
  end
end


text:
<?php

namespace Google\AdsApi\Dfp\v201611;

/**
 * This file was generated from WSDL. DO NOT EDIT.
 */
class BrowserPremiumFeature extends \Google\AdsApi\Dfp\v201611\PremiumFeature
{

    public function __construct()
    {

    }

}


text:
<?php

namespace Organizations\Factory\Controller;

use Interop\Container\ContainerInterface;
use Organizations\Controller\IndexController;
use Organizations\Form;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Organizations\Service\UploadHandler;

class IndexControllerFactory implements FactoryInterface
{
    /**
     * Create a IndexController controller
     *
     * @param  ContainerInterface $container
     * @param  string             $requestedName
     * @param  null|array         $options
     *
     * @return IndexController
     */
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
    {
        $organizationRepository = $container->get('repositories')->get('Organizations/Organization');
        $form = new Form\Organizations(null);
        $formManager = $container->get('FormElementManager');
        $viewHelper = $container->get('ViewHelperManager');
        $translator = $container->get('translator');
        $manageHandler = $container->get(UploadHandler::class);

        return new IndexController(
            $form,
            $organizationRepository,
            $translator,
            $formManager,
            $viewHelper,
            $manageHandler
        );
    }
}


text:
package tk.mybatis.mapper.common;

import tk.mybatis.mapper.common.special.InsertListMapper;
import tk.mybatis.mapper.common.special.InsertUseGeneratedKeysMapper;

/**
 * 通用Mapper接口,MySql独有的通用方法
 *
 * @param <T> 不能为空
 * @author liuzh
 */
public interface MySqlMapper<T> extends
        InsertListMapper<T>,
        InsertUseGeneratedKeysMapper<T> {

}


text:
#pragma once

#include "Core/src/EnvisionPlugin.h"
#include "visualizationbase_api.h"

namespace Visualization {

class VisualizationBase : public QObject, public Core::EnvisionPlugin
{
	Q_OBJECT
	Q_INTERFACES(Core::EnvisionPlugin)

	public:
		virtual bool initialize(Core::EnvisionManager&) override;
		virtual void unload() override;
		virtual void selfTest(QString testid) override;
};

VISUALIZATIONBASE_API Core::InitializationRegistry& nodeTypeInitializationRegistry();
VISUALIZATIONBASE_API Core::InitializationRegistry& itemTypeInitializationRegistry();
VISUALIZATIONBASE_API Core::InitializationRegistry& shapeTypeInitializationRegistry();

}


text:
package com.orientechnologies.orient.core.storage.index.nkbtree.normalizers;

import com.orientechnologies.common.comparator.OByteArrayComparator;
import com.orientechnologies.common.comparator.OUnsafeByteArrayComparator;
import com.orientechnologies.common.comparator.OUnsafeByteArrayComparatorV2;
import com.orientechnologies.orient.core.index.OCompositeKey;
import com.orientechnologies.orient.core.metadata.schema.OType;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.text.Collator;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
import java.util.function.Consumer;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

public class KeyNormalizationTest {
  KeyNormalizer keyNormalizer;

  @Before
  public void setup() {
    keyNormalizer = new KeyNormalizer();
  }

  @Test(expected = IllegalArgumentException.class)
  public void normalizeNullInput() {
    keyNormalizer.normalize(null, null, Collator.NO_DECOMPOSITION);
  }

  @Test(expected = IllegalArgumentException.class)
  public void normalizeUnequalInput() {
    final OCompositeKey compositeKey = new OCompositeKey();
    compositeKey.addKey(null);
    keyNormalizer.normalize(compositeKey, new OType[0], Collator.NO_DECOMPOSITION);
  }

  @Test
  public void normalizeCompositeNull() {
    final byte[] bytes = getNormalizedKeySingle(null, null);
    Assert.assertEquals((new byte[] {(byte) 0x1})[0], bytes[0]);
  }

  @Test
  public void normalizeCompositeNullInt() {
    final OCompositeKey compositeKey = new OCompositeKey();
    compositeKey.addKey(null);
    compositeKey.addKey(5);
    Assert.assertEquals(2, compositeKey.getKeys().size());

    final OType[] types = new OType[2];
    types[0] = null;
    types[1] = OType.INTEGER;

    final byte[] bytes = keyNormalizer.normalize(compositeKey, types, Collator.NO_DECOMPOSITION);
    Assert.assertEquals((new byte[] {(byte) 0x1})[0], bytes[0]);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[1]);
    Assert.assertEquals((new byte[] {(byte) 0x80})[0], bytes[2]);
    Assert.assertEquals((new byte[] {(byte) 0x5})[0], bytes[5]);
  }

  @Test
  public void normalizeCompositeInt() {
    final byte[] bytes = getNormalizedKeySingle(5, OType.INTEGER);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
    Assert.assertEquals((new byte[] {(byte) 0x5})[0], bytes[4]);
  }

  @Test
  public void normalizeCompositeIntZero() {
    final byte[] bytes = getNormalizedKeySingle(0, OType.INTEGER);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[4]);
  }

  @Test
  public void normalizeCompositeNegInt() {
    final byte[] bytes = getNormalizedKeySingle(-62, OType.INTEGER);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
    // -62 signed := 4294967234 unsigned := FFFFFFC2 hex
    Assert.assertEquals((new byte[] {(byte) 0x7f})[0], bytes[1]);
    Assert.assertEquals((new byte[] {(byte) 0xff})[0], bytes[2]);
    Assert.assertEquals((new byte[] {(byte) 0xff})[0], bytes[3]);
    Assert.assertEquals((new byte[] {(byte) 0xc2})[0], bytes[4]);
  }

  @Test
  public void normalizeCompositeIntCompare() {
    final byte[] negative = getNormalizedKeySingle(-62, OType.INTEGER);
    final byte[] zero = getNormalizedKeySingle(0, OType.INTEGER);
    final byte[] positive = getNormalizedKeySingle(5, OType.INTEGER);
    compareWithUnsafeByteArrayComparator(negative, zero, positive);
    compareWithByteArrayComparator(negative, zero, positive);
  }

  // long running, move to separate test?
  @Ignore
  @Test
  public void normalizeCompositeIntCompareLoop() {
    final byte[] zero = getNormalizedKeySingle(0, OType.INTEGER);

    for (int i = 1; i < Integer.MAX_VALUE; ++i) {
      final byte[] negative = getNormalizedKeySingle(-1 * i, OType.INTEGER);
      final byte[] positive = getNormalizedKeySingle(i, OType.INTEGER);
      compareWithUnsafeByteArrayComparator(negative, zero, positive);
      compareWithByteArrayComparator(negative, zero, positive);
    }
  }

  @Test
  public void normalizeCompositeDouble() {
    final byte[] bytes = getNormalizedKeySingle(1.5d, OType.DOUBLE);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
    Assert.assertEquals((new byte[] {(byte) 0xbf})[0], bytes[1]);
    Assert.assertEquals((new byte[] {(byte) 0xf8})[0], bytes[2]);
  }

  @Test
  public void normalizeCompositeDoubleCompare() {
    final byte[] negative = getNormalizedKeySingle(-62.0d, OType.DOUBLE);
    final byte[] zero = getNormalizedKeySingle(0.0d, OType.DOUBLE);
    final byte[] positive = getNormalizedKeySingle(1.5d, OType.DOUBLE);
    compareWithUnsafeByteArrayComparator(negative, zero, positive);
    compareWithByteArrayComparator(negative, zero, positive);
  }

  @Test
  public void normalizeCompositeFloat() {
    final byte[] bytes = getNormalizedKeySingle(1.5f, OType.FLOAT);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
    Assert.assertEquals((new byte[] {(byte) 0xbf})[0], bytes[1]);
    Assert.assertEquals((new byte[] {(byte) 0xc0})[0], bytes[2]);
  }

  @Test
  public void normalizeCompositeFloatCompare() {
    final byte[] negative = getNormalizedKeySingle(-62.0f, OType.FLOAT);
    final byte[] zero = getNormalizedKeySingle(0.0f, OType.FLOAT);
    final byte[] positive = getNormalizedKeySingle(1.5f, OType.FLOAT);
    compareWithUnsafeByteArrayComparator(negative, zero, positive);
    compareWithByteArrayComparator(negative, zero, positive);
  }

  // we do not compare across data types
  @Ignore
  @Test
  public void normalizeCompositeDoubleFloatCompare() {
    final byte[] negative = getNormalizedKeySingle(-62.5, OType.DOUBLE);
    final byte[] zero = getNormalizedKeySingle(-61.75f, OType.FLOAT);
    final byte[] smallerNegative = getNormalizedKeySingle(-61.0d, OType.DOUBLE);
    final byte[] smallerNegativeFloat = getNormalizedKeySingle(-61.0f, OType.FLOAT);
    compareWithUnsafeByteArrayComparatorIntertype(smallerNegative, smallerNegativeFloat);
    compareWithUnsafeByteArrayComparator(negative, zero, smallerNegative);
    compareWithByteArrayComparator(negative, zero, smallerNegative);
  }

  // we do not compare across data types
  @Ignore
  @Test
  public void normalizeCompositeIntFloatCompare() {
    final byte[] negative = getNormalizedKeySingle(-62, OType.INTEGER);
    final byte[] zero = getNormalizedKeySingle(-61.75f, OType.FLOAT);
    final byte[] smallerNegative = getNormalizedKeySingle(-61, OType.INTEGER);
    final byte[] smallerNegativeFloat = getNormalizedKeySingle(-61f, OType.FLOAT);
    compareWithUnsafeByteArrayComparatorIntertype(smallerNegative, smallerNegativeFloat);
    compareWithUnsafeByteArrayComparator(negative, zero, smallerNegative);
    compareWithByteArrayComparator(negative, zero, smallerNegative);
  }

  @Test
  public void testBigDecimal() {
    final BigDecimal matKey = new BigDecimal(87866787879879879768767554645.434);
    final ByteBuffer bb = ByteBuffer.allocate(1 + 8); // bytes.length);
    bb.order(ByteOrder.BIG_ENDIAN);
    bb.put((byte) 0);
    bb.putLong(Double.doubleToLongBits(matKey.doubleValue()) + Long.MAX_VALUE + 1);
    print(bb.array());

    System.out.println(matKey.toPlainString() + "-" + matKey.toEngineeringString());
    byte[] bytes = getNormalizedKeySingle(matKey.toPlainString(), OType.STRING);
    print(bytes);
    byte[] bytesNeg =
        getNormalizedKeySingle(new BigDecimal(-3.14159265359).toPlainString(), OType.STRING);
    print(bytesNeg);
    byte[] bytesMoreNeg =
        getNormalizedKeySingle(new BigDecimal(-3.14159265359).toPlainString(), OType.STRING);
    print(bytesMoreNeg);

    // compareWithUnsafeByteArrayComparator(bytesMoreNeg, bytesNeg, bytes);

    /*
     * final byte[] stream = new byte[9]; ODecimalSerializer decimalSerializer = new ODecimalSerializer();
     * decimalSerializer.serialize(matKey, stream, 0); print(ByteBuffer.wrap(stream).order(ByteOrder.BIG_ENDIAN).array());
     * Assert.assertEquals(decimalSerializer.deserialize(stream, 0), matKey);
     *
     * final BigDecimal matKeyNeg = new BigDecimal(new BigInteger("-2"), 2); final byte[] streamNeg = new byte[9];
     * decimalSerializer.serialize(matKeyNeg, streamNeg, 0); print(ByteBuffer.wrap(streamNeg).order(ByteOrder.BIG_ENDIAN).array());
     * Assert.assertEquals(decimalSerializer.deserialize(streamNeg, 0), matKeyNeg);
     *
     * final BigDecimal matKeyZero = new BigDecimal(new BigInteger("0"), 2); final byte[] streamZero = new byte[9];
     * decimalSerializer.serialize(matKeyZero, streamZero, 0);
     * print(ByteBuffer.wrap(streamZero).order(ByteOrder.BIG_ENDIAN).array());
     * Assert.assertEquals(decimalSerializer.deserialize(streamZero, 0), matKeyZero);
     *
     * compareWithUnsafeByteArrayComparator(streamNeg, streamZero, stream);
     */
  }

  @Test
  public void normalizeCompositeBigDecimal() {
    final byte[] bytes = getNormalizedKeySingle(new BigDecimal("3.14159265359"), OType.DECIMAL);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
    Assert.assertEquals((new byte[] {(byte) 0xc0})[0], bytes[1]);
    Assert.assertEquals((new byte[] {(byte) 0x9})[0], bytes[2]);
    Assert.assertEquals((new byte[] {(byte) 0x21})[0], bytes[3]);
    Assert.assertEquals((new byte[] {(byte) 0xfb})[0], bytes[4]);
    Assert.assertEquals((new byte[] {(byte) 0x54})[0], bytes[5]);
    Assert.assertEquals((new byte[] {(byte) 0x44})[0], bytes[6]);
    Assert.assertEquals((new byte[] {(byte) 0x2e})[0], bytes[7]);
    Assert.assertEquals((new byte[] {(byte) 0xea})[0], bytes[8]);
  }

  @Test
  public void normalizeCompositeNegBigDecimal() {
    final byte[] bytes = getNormalizedKeySingle(new BigDecimal("-3.14159265359"), OType.DECIMAL);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
    Assert.assertEquals((new byte[] {(byte) 0x40})[0], bytes[1]);
    Assert.assertEquals((new byte[] {(byte) 0x9})[0], bytes[2]);
    Assert.assertEquals((new byte[] {(byte) 0x21})[0], bytes[3]);
    Assert.assertEquals((new byte[] {(byte) 0xfb})[0], bytes[4]);
    Assert.assertEquals((new byte[] {(byte) 0x54})[0], bytes[5]);
    Assert.assertEquals((new byte[] {(byte) 0x44})[0], bytes[6]);
    Assert.assertEquals((new byte[] {(byte) 0x2e})[0], bytes[7]);
    Assert.assertEquals((new byte[] {(byte) 0xea})[0], bytes[8]);
  }

  @Test
  public void normalizeCompositeDecimalCompare() {
    final byte[] negative = getNormalizedKeySingle(new BigDecimal("-3.14159265359"), OType.DECIMAL);
    final byte[] zero = getNormalizedKeySingle(new BigDecimal("0.0"), OType.DECIMAL);
    final byte[] zero2 =
        getNormalizedKeySingle(new BigDecimal(new BigInteger("0"), 2), OType.DECIMAL);
    final byte[] positive = getNormalizedKeySingle(new BigDecimal(3.14159265359), OType.DECIMAL);
    final byte[] positive2 =
        getNormalizedKeySingle(new BigDecimal(new BigInteger("314159265359"), 11), OType.DECIMAL);
    compareWithUnsafeByteArrayComparator(negative, zero, positive);
    compareWithByteArrayComparator(negative, zero, positive);
    compareWithUnsafeByteArrayComparatorIntertype(zero, zero2);
    compareWithUnsafeByteArrayComparatorIntertype(positive, positive2);
  }

  @Test
  public void normalizeCompositeBoolean() {
    final byte[] bytes = getNormalizedKeySingle(true, OType.BOOLEAN);
    Assert.assertEquals((new byte[] {(byte) 0x1})[0], bytes[0]);
  }

  @Test
  public void normalizeCompositeLong() {
    final byte[] bytes = getNormalizedKeySingle(5L, OType.LONG);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
    Assert.assertEquals((new byte[] {(byte) 0x80})[0], bytes[1]);
    Assert.assertEquals((new byte[] {(byte) 0x5})[0], bytes[8]);
  }

  @Test
  public void normalizeCompositeNegLong() {
    final byte[] bytes = getNormalizedKeySingle(-62L, OType.LONG);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
    Assert.assertEquals((new byte[] {(byte) 0x7f})[0], bytes[1]);
    Assert.assertEquals((new byte[] {(byte) 0xff})[0], bytes[2]);
    Assert.assertEquals((new byte[] {(byte) 0xff})[0], bytes[3]);
    Assert.assertEquals((new byte[] {(byte) 0xff})[0], bytes[4]);
    Assert.assertEquals((new byte[] {(byte) 0xff})[0], bytes[5]);
    Assert.assertEquals((new byte[] {(byte) 0xff})[0], bytes[6]);
    Assert.assertEquals((new byte[] {(byte) 0xff})[0], bytes[7]);
    Assert.assertEquals((new byte[] {(byte) 0xc2})[0], bytes[8]);
  }

  @Test
  public void normalizeCompositeLongCompare() {
    final byte[] negative = getNormalizedKeySingle(-62L, OType.LONG);
    final byte[] zero = getNormalizedKeySingle(0L, OType.LONG);
    final byte[] positive = getNormalizedKeySingle(5L, OType.LONG);
    compareWithUnsafeByteArrayComparator(negative, zero, positive);
    compareWithByteArrayComparator(negative, zero, positive);
  }

  private byte getMostSignificantBit(final byte aByte) {
    return (byte) ((aByte & 0xFF00) >> 8);
  }

  private byte getLeastSignificantBit(final byte aByte) {
    return (byte) ((aByte & 0xFF) >> 8);
  }

  @Test
  public void normalizeCompositeByte() {
    final byte[] bytes = getNormalizedKeySingle((byte) 3, OType.BYTE);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
    Assert.assertEquals((new byte[] {(byte) 0x83})[0], bytes[1]);
  }

  @Test
  public void normalizeCompositeNegByte() {
    final byte[] bytes = getNormalizedKeySingle((byte) -62, OType.BYTE);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
    Assert.assertEquals((new byte[] {(byte) 0x42})[0], bytes[1]);
  }

  @Test
  public void normalizeCompositeByteCompare() {
    final byte[] negative = getNormalizedKeySingle((byte) -62, OType.BYTE);
    final byte[] zero = getNormalizedKeySingle((byte) 0, OType.BYTE);
    final byte[] positive = getNormalizedKeySingle((byte) 5, OType.BYTE);
    compareWithUnsafeByteArrayComparator(negative, zero, positive);
    compareWithByteArrayComparator(negative, zero, positive);
  }

  @Test
  public void normalizeCompositeShort() {
    final byte[] bytes = getNormalizedKeySingle((short) 3, OType.SHORT);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
    Assert.assertEquals((new byte[] {(byte) 0x80})[0], bytes[1]);
    Assert.assertEquals((new byte[] {(byte) 0x3})[0], bytes[2]);
  }

  @Test
  public void normalizeCompositeNegShort() {
    final byte[] bytes = getNormalizedKeySingle((short) -62, OType.SHORT);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
    Assert.assertEquals((new byte[] {(byte) 0x7f})[0], bytes[1]);
    Assert.assertEquals((new byte[] {(byte) 0xc2})[0], bytes[2]);
  }

  @Test
  public void normalizeCompositeShortCompare() {
    final byte[] negative = getNormalizedKeySingle((short) -62, OType.SHORT);
    final byte[] zero = getNormalizedKeySingle((short) 0, OType.SHORT);
    final byte[] positive = getNormalizedKeySingle((short) 5, OType.SHORT);
    compareWithUnsafeByteArrayComparator(negative, zero, positive);
    compareWithByteArrayComparator(negative, zero, positive);
  }

  @Test
  @Ignore
  public void normalizeCompositeString() {
    final OType[] types = new OType[1];
    types[0] = OType.STRING;

    assertCollationOfCompositeKeyString(
        types,
        getCompositeKey("abc"),
        (byte[] bytes) -> {
          Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
          Assert.assertEquals((new byte[] {(byte) 0x2a})[0], bytes[1]);
          Assert.assertEquals((new byte[] {(byte) 0x2c})[0], bytes[2]);
          Assert.assertEquals((new byte[] {(byte) 0x2e})[0], bytes[3]);
          Assert.assertEquals((new byte[] {(byte) 0x1})[0], bytes[4]);
          Assert.assertEquals((new byte[] {(byte) 0x7})[0], bytes[5]);
          Assert.assertEquals((new byte[] {(byte) 0x1})[0], bytes[6]);
          Assert.assertEquals((new byte[] {(byte) 0x7})[0], bytes[7]);
          Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[8]);
        });

    assertCollationOfCompositeKeyString(
        types,
        getCompositeKey("Abc"),
        (byte[] bytes) -> {
          Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
          Assert.assertEquals((new byte[] {(byte) 0x2a})[0], bytes[1]);
          Assert.assertEquals((new byte[] {(byte) 0x2c})[0], bytes[2]);
          Assert.assertEquals((new byte[] {(byte) 0x2e})[0], bytes[3]);
          Assert.assertEquals((new byte[] {(byte) 0x1})[0], bytes[4]);
          Assert.assertEquals((new byte[] {(byte) 0x7})[0], bytes[5]);
          Assert.assertEquals((new byte[] {(byte) 0x1})[0], bytes[6]);
          Assert.assertEquals((new byte[] {(byte) 0xdc})[0], bytes[7]);
          Assert.assertEquals((new byte[] {(byte) 0x6})[0], bytes[8]);
          Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[9]);
        });

    assertCollationOfCompositeKeyString(
        types,
        getCompositeKey("abC"),
        (byte[] bytes) -> {
          Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
          Assert.assertEquals((new byte[] {(byte) 0x2a})[0], bytes[1]);
          Assert.assertEquals((new byte[] {(byte) 0x2c})[0], bytes[2]);
          Assert.assertEquals((new byte[] {(byte) 0x2e})[0], bytes[3]);
          Assert.assertEquals((new byte[] {(byte) 0x1})[0], bytes[4]);
          Assert.assertEquals((new byte[] {(byte) 0x7})[0], bytes[5]);
          Assert.assertEquals((new byte[] {(byte) 0x1})[0], bytes[6]);
          Assert.assertEquals((new byte[] {(byte) 0xc4})[0], bytes[7]);
          Assert.assertEquals((new byte[] {(byte) 0xdc})[0], bytes[8]);
          Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[9]);
        });
  }

  @Test
  public void normalizeCompositeStringCompare() {
    final byte[] smallest = getNormalizedKeySingle("a", OType.STRING);
    final byte[] middle = getNormalizedKeySingle("b", OType.STRING);
    final byte[] largest = getNormalizedKeySingle("c", OType.STRING);
    compareWithUnsafeByteArrayComparator(smallest, middle, largest);
    compareWithByteArrayComparator(smallest, middle, largest);
  }

  @Test
  @Ignore
  public void normalizeCompositeIntStringCompare() {
    final byte[] smallest = getNormalizedKeySingle("-1", OType.STRING);
    final byte[] smaller = getNormalizedKeySingle("-13", OType.STRING);
    final byte[] middle = getNormalizedKeySingle("0", OType.STRING);
    final byte[] largest = getNormalizedKeySingle("1", OType.STRING);
    compareWithUnsafeByteArrayComparator(smallest, middle, largest);
    compareWithUnsafeByteArrayComparator(smallest, smaller, middle);
  }

  @Test
  public void normalizeCompositeStringSequenceCompare() {
    // compare: http://demo.icu-project.org/icu-bin/collation.html
    final byte[] smallest = getNormalizedKeySingle("abc", OType.STRING);
    final byte[] middle = getNormalizedKeySingle("abC", OType.STRING);
    final byte[] largest = getNormalizedKeySingle("Abc", OType.STRING);
    compareWithUnsafeByteArrayComparator(smallest, middle, largest);
    compareWithByteArrayComparator(smallest, middle, largest);
  }

  @Test
  @Ignore
  public void normalizeCompositeStringUmlaute() {
    final OType[] types = new OType[1];
    types[0] = OType.STRING;

    assertCollationOfCompositeKeyString(
        types,
        getCompositeKey("ü"),
        (byte[] bytes) -> {
          Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
          Assert.assertEquals((new byte[] {(byte) 0x52})[0], bytes[1]);
          Assert.assertEquals((new byte[] {(byte) 0x1})[0], bytes[2]);
          Assert.assertEquals((new byte[] {(byte) 0x45})[0], bytes[3]);
          Assert.assertEquals((new byte[] {(byte) 0x96})[0], bytes[4]);
          Assert.assertEquals((new byte[] {(byte) 0x1})[0], bytes[5]);
          Assert.assertEquals((new byte[] {(byte) 0x6})[0], bytes[6]);
          Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[7]);
        });

    assertCollationOfCompositeKeyString(
        types,
        getCompositeKey("u"),
        (byte[] bytes) -> {
          Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
          Assert.assertEquals((new byte[] {(byte) 0x52})[0], bytes[1]);
          Assert.assertEquals((new byte[] {(byte) 0x1})[0], bytes[2]);
          Assert.assertEquals((new byte[] {(byte) 0x5})[0], bytes[3]);
          Assert.assertEquals((new byte[] {(byte) 0x1})[0], bytes[4]);
          Assert.assertEquals((new byte[] {(byte) 0x5})[0], bytes[5]);
          Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[6]);
        });
  }

  @Test
  @Ignore
  public void normalizeCompositeTwoStrings() {
    final OCompositeKey compositeKey = new OCompositeKey();
    final String key = "abcd";
    compositeKey.addKey(key);
    final String secondKey = "test";
    compositeKey.addKey(secondKey);
    Assert.assertEquals(2, compositeKey.getKeys().size());

    final OType[] types = new OType[2];
    types[0] = OType.STRING;
    types[1] = OType.STRING;

    assertCollationOfCompositeKeyString(
        types,
        compositeKey,
        (byte[] bytes) -> {
          // check 'not null' and beginning of first entry
          Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
          Assert.assertEquals((new byte[] {(byte) 0x2a})[0], bytes[1]);

          // finally assert 'not null' for second entry ..
          Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[10]);
          Assert.assertEquals((new byte[] {(byte) 0x50})[0], bytes[11]);
        });
  }

  @Test
  public void normalizeCompositeDate() {
    final GregorianCalendar calendar = getGregorianCalendarUTC(2013, Calendar.NOVEMBER, 5);
    final Date key = calendar.getTime();
    final byte[] bytes = getNormalizedKeySingle(key, OType.DATE);

    // 1383606000000 := Tue Nov 05 2013 00:00:00
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[1]);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[2]);
    Assert.assertEquals((new byte[] {(byte) 0x1})[0], bytes[3]);
    Assert.assertEquals((new byte[] {(byte) 0x42})[0], bytes[4]);
    Assert.assertEquals((new byte[] {(byte) 0x25})[0], bytes[5]);
    Assert.assertEquals((new byte[] {(byte) 0x8f})[0], bytes[6]);
    Assert.assertEquals((new byte[] {(byte) 0x8})[0], bytes[7]);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[8]);
  }

  private GregorianCalendar getGregorianCalendarUTC(
      final int year, final int month, final int dayOfMonth) {
    final GregorianCalendar calendar = new GregorianCalendar(year, month, dayOfMonth);
    calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
    return calendar;
  }

  @Test
  public void normalizeCompositeDateCompare() {
    GregorianCalendar calendar = getGregorianCalendarUTC(2013, Calendar.AUGUST, 5);
    Date key = calendar.getTime();
    final byte[] smallest = getNormalizedKeySingle(key, OType.DATE);

    calendar = getGregorianCalendarUTC(2013, Calendar.NOVEMBER, 5);
    key = calendar.getTime();
    final byte[] middle = getNormalizedKeySingle(key, OType.DATETIME);

    calendar = getGregorianCalendarUTC(2013, Calendar.NOVEMBER, 6);
    key = calendar.getTime();
    final byte[] largest = getNormalizedKeySingle(key, OType.DATETIME);
    compareWithUnsafeByteArrayComparator(smallest, middle, largest);
    compareWithByteArrayComparator(smallest, middle, largest);
  }

  @Ignore
  @Test
  public void normalizeCompositeDateTime() {
    final ZonedDateTime zdt =
        LocalDateTime.of(2013, 11, 5, 3, 3, 3)
            .atZone(ZoneId.systemDefault())
            .withZoneSameInstant(ZoneId.of("UTC"));
    final Date key = Date.from(zdt.toInstant());
    System.out.println("Date-key: " + key);
    final byte[] bytes = getNormalizedKeySingle(key, OType.DATETIME);
    print(bytes);

    // 1383616983000 := Tue Nov 05 2013 03:03:03
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[1]);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[2]);
    Assert.assertEquals((new byte[] {(byte) 0x1})[0], bytes[3]);
    Assert.assertEquals((new byte[] {(byte) 0x42})[0], bytes[4]);
    Assert.assertEquals((new byte[] {(byte) 0x25})[0], bytes[5]);
    Assert.assertEquals((new byte[] {(byte) 0xff})[0], bytes[6]);
    Assert.assertEquals((new byte[] {(byte) 0xaf})[0], bytes[7]);
    Assert.assertEquals((new byte[] {(byte) 0xd8})[0], bytes[8]);
  }

  @Test
  public void normalizeCompositeDateTimeCompare() {
    ZonedDateTime zdt =
        LocalDateTime.of(2013, 11, 5, 3, 3, 3)
            .atZone(ZoneId.systemDefault())
            .withZoneSameInstant(ZoneId.of("UTC"));
    Date key = Date.from(zdt.toInstant());
    final byte[] smallest = getNormalizedKeySingle(key, OType.DATETIME);

    zdt =
        LocalDateTime.of(2013, 11, 5, 5, 3, 3)
            .atZone(ZoneId.systemDefault())
            .withZoneSameInstant(ZoneId.of("UTC"));
    key = Date.from(zdt.toInstant());
    final byte[] middle = getNormalizedKeySingle(key, OType.DATETIME);

    zdt =
        LocalDateTime.of(2013, 11, 5, 5, 5, 5)
            .atZone(ZoneId.systemDefault())
            .withZoneSameInstant(ZoneId.of("UTC"));
    key = Date.from(zdt.toInstant());
    final byte[] largest = getNormalizedKeySingle(key, OType.DATETIME);
    compareWithUnsafeByteArrayComparator(smallest, middle, largest);
    compareWithByteArrayComparator(smallest, middle, largest);
  }

  @Test
  public void normalizeCompositeBinary() {
    final byte[] key = new byte[] {1, 2, 3, 4, 5, 6};

    final OCompositeKey compositeKey = new OCompositeKey();
    compositeKey.addKey(key);
    Assert.assertEquals(1, compositeKey.getKeys().size());

    final OType[] types = new OType[1];
    types[0] = OType.BINARY;

    final byte[] bytes = keyNormalizer.normalize(compositeKey, types, Collator.NO_DECOMPOSITION);
    Assert.assertEquals((new byte[] {(byte) 0x0})[0], bytes[0]);
    Assert.assertEquals((new byte[] {(byte) 0x1})[0], bytes[1]);
    Assert.assertEquals((new byte[] {(byte) 0x6})[0], bytes[6]);
  }

  @Test
  public void normalizeCompositeBinaryCompare() {
    final byte[] smallest = getNormalizedKeySingle(new byte[] {1, 2, 3, 4, 5, 6}, OType.BINARY);
    final byte[] middle = getNormalizedKeySingle(new byte[] {2, 2, 3, 4, 5, 6}, OType.BINARY);
    final byte[] biggest = getNormalizedKeySingle(new byte[] {3, 2, 3, 4, 5, 6}, OType.BINARY);
    compareWithUnsafeByteArrayComparator(smallest, middle, biggest);
    compareWithByteArrayComparator(smallest, middle, biggest);
  }

  private byte[] getNormalizedKeySingle(final Object keyValue, final OType type) {
    final OCompositeKey compositeKey = new OCompositeKey();
    compositeKey.addKey(keyValue);
    Assert.assertEquals(1, compositeKey.getKeys().size());

    final OType[] types = new OType[1];
    types[0] = type;
    return keyNormalizer.normalize(compositeKey, types, Collator.NO_DECOMPOSITION);
  }

  private void assertCollationOfCompositeKeyString(
      final OType[] types, final OCompositeKey compositeKey, final Consumer<byte[]> func) {
    // System.out.println("actual string: " + compositeKey.getKeys().get(0));
    final byte[] bytes = keyNormalizer.normalize(compositeKey, types, Collator.NO_DECOMPOSITION);
    // print(bytes);
    func.accept(bytes);
  }

  private OCompositeKey getCompositeKey(final String text) {
    final OCompositeKey compositeKey = new OCompositeKey();
    final String key = text;
    compositeKey.addKey(key);
    Assert.assertEquals(1, compositeKey.getKeys().size());
    return compositeKey;
  }

  private void compareWithByteArrayComparator(byte[] negative, byte[] zero, byte[] positive) {
    final OByteArrayComparator arrayComparator = new OByteArrayComparator();
    Assert.assertTrue("negative < zero", 0 > arrayComparator.compare(negative, zero));
    Assert.assertTrue("positive > zero", 0 < arrayComparator.compare(positive, zero));
    Assert.assertTrue("zero == zero", 0 == arrayComparator.compare(zero, zero));
    Assert.assertTrue("negative < positive", 0 > arrayComparator.compare(negative, positive));
  }

  private void compareWithUnsafeByteArrayComparator(byte[] negative, byte[] zero, byte[] positive) {
    final OUnsafeByteArrayComparatorV2 byteArrayComparator = new OUnsafeByteArrayComparatorV2();
    Assert.assertTrue("[unsafe] negative < zero", 0 > byteArrayComparator.compare(negative, zero));
    Assert.assertTrue("[unsafe] positive > zero", 0 < byteArrayComparator.compare(positive, zero));
    Assert.assertTrue("[unsafe] zero == zero", 0 == byteArrayComparator.compare(zero, zero));
    Assert.assertTrue(
        "{unsafe] negative < positive", 0 > byteArrayComparator.compare(negative, positive));
  }

  private void compareWithUnsafeByteArrayComparatorIntertype(byte[] first, byte[] second) {
    final OUnsafeByteArrayComparator byteArrayComparator = new OUnsafeByteArrayComparator();
    Assert.assertTrue("[unsafe] first == second", 0 == byteArrayComparator.compare(first, second));
  }

  private void print(final byte[] bytes) {
    for (final byte b : bytes) {
      System.out.format("0x%x ", b);
    }
    System.out.println();
  }
}


text:
int main(int argc, char** argv)
{
    QApplication app(argc, argv);
    QQmlApplicationEngine engine(QUrl(QStringLiteral("qrc:/main.qml")));
    return app.exec();
}


text:
"""
Copyright 2017 Peter Urda

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

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

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

from enum import Enum

class EnvironmentType(Enum):
    """
    Enum for describing environment types
    """

    DEV = 'dev'
    PROD = 'prod'

    @staticmethod
    def get_type(env_input: str=''):
        """
        Determine the environment enum based on a string input

        :param env_input: The string describing the environment
        :return: The 'EnvironmentType' or 'EnvironmentType.PROD' on ValueError
        """
        if not isinstance(env_input, str):
            return EnvironmentType.PROD

        env_input = env_input.lower()

        try:
            result = EnvironmentType(env_input)
        except ValueError:
            result = EnvironmentType.PROD

        return result


text:
use models::*;
use shmem::*;

use futures::prelude::*;
use std;
use std::{collections::HashMap, hash::Hash, io};

pub fn flush_connection<T>(
    outgoing_slots: &mut HashMap<T, Vec<u8>>,
    app_channel: &SharedAppChannel,
) -> Poll<(), io::Error>
where
    T: Copy + Into<MsgChannel> + Eq + Hash,
{
    let mut tmp = HashMap::new();
    std::mem::swap(&mut tmp, outgoing_slots);

    for (c, m) in tmp {
        if let AsyncSink::NotReady((_, m)) = unsafe { app_channel.push_unchecked((c.into(), m)) } {
            outgoing_slots.insert(c, m);
        }
    }

    if outgoing_slots.is_empty() {
        Ok(Async::Ready(()))
    } else {
        Ok(Async::NotReady)
    }
}


text:
// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

using System.Collections.Immutable;
using System.Linq;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.SolutionCrawler
{
    internal partial class SolutionCrawlerRegistrationService
    {
        private partial class WorkCoordinator
        {
            // this is internal only type
            private struct WorkItem
            {
                // project related workitem
                public readonly ProjectId ProjectId;

                // document related workitem
                public readonly DocumentId DocumentId;
                public readonly string Language;
                public readonly InvocationReasons InvocationReasons;
                public readonly bool IsLowPriority;

                // extra info
                public readonly SyntaxPath ActiveMember;
                public readonly ImmutableHashSet<IIncrementalAnalyzer> Analyzers;

                // retry
                public readonly bool IsRetry;

                // common
                public readonly IAsyncToken AsyncToken;

                public bool MustRefresh
                {
                    get
                    {
                        // in current design, we need to re-run all incremental analyzer on document open and close
                        // so that incremental analyzer who only cares about opened document can have a chance to clean up
                        // its state.
                        return InvocationReasons.Contains(PredefinedInvocationReasons.DocumentOpened) ||
                               InvocationReasons.Contains(PredefinedInvocationReasons.DocumentClosed);
                    }
                }

                private WorkItem(
                    DocumentId documentId,
                    ProjectId projectId,
                    string language,
                    InvocationReasons invocationReasons,
                    bool isLowPriority,
                    SyntaxPath activeMember,
                    ImmutableHashSet<IIncrementalAnalyzer> analyzers,
                    bool retry,
                    IAsyncToken asyncToken)
                {
                    this.DocumentId = documentId;
                    this.ProjectId = projectId;
                    this.Language = language;
                    this.InvocationReasons = invocationReasons;
                    this.IsLowPriority = isLowPriority;

                    this.ActiveMember = activeMember;
                    this.Analyzers = analyzers;

                    this.IsRetry = retry;

                    this.AsyncToken = asyncToken;
                }

                public WorkItem(DocumentId documentId, string language, InvocationReasons invocationReasons, bool isLowPriority, IAsyncToken asyncToken)
                    : this(documentId, documentId.ProjectId, language, invocationReasons, isLowPriority, null, ImmutableHashSet.Create<IIncrementalAnalyzer>(), false, asyncToken)
                {
                }

                public WorkItem(
                    DocumentId documentId, string language, InvocationReasons invocationReasons, bool isLowPriority,
                    SyntaxPath activeMember, IAsyncToken asyncToken)
                    : this(documentId, documentId.ProjectId, language, invocationReasons, isLowPriority,
                           activeMember, ImmutableHashSet.Create<IIncrementalAnalyzer>(),
                           false, asyncToken)
                {
                }

                public WorkItem(
                    DocumentId documentId, string language, InvocationReasons invocationReasons, bool isLowPriority,
                    IIncrementalAnalyzer analyzer, IAsyncToken asyncToken)
                    : this(documentId, documentId.ProjectId, language, invocationReasons, isLowPriority,
                           null, analyzer == null ? ImmutableHashSet.Create<IIncrementalAnalyzer>() : ImmutableHashSet.Create<IIncrementalAnalyzer>(analyzer),
                           false, asyncToken)
                {
                }

                public object Key
                {
                    get { return DocumentId ?? (object)ProjectId; }
                }

                private ImmutableHashSet<IIncrementalAnalyzer> Union(ImmutableHashSet<IIncrementalAnalyzer> analyzers)
                {
                    if (analyzers.IsEmpty)
                    {
                        return this.Analyzers;
                    }

                    if (this.Analyzers.IsEmpty)
                    {
                        return analyzers;
                    }

                    return this.Analyzers.Union(analyzers);
                }

                public WorkItem Retry(IAsyncToken asyncToken)
                {
                    return new WorkItem(
                        this.DocumentId, this.ProjectId, this.Language, this.InvocationReasons, this.IsLowPriority, this.ActiveMember, this.Analyzers,
                        retry: true, asyncToken: asyncToken);
                }

                public WorkItem With(
                    InvocationReasons invocationReasons, SyntaxPath currentMember,
                    ImmutableHashSet<IIncrementalAnalyzer> analyzers, bool retry, IAsyncToken asyncToken)
                {
                    // dispose old one
                    this.AsyncToken.Dispose();

                    // create new work item
                    return new WorkItem(
                        this.DocumentId, this.ProjectId, this.Language,
                        InvocationReasons.With(invocationReasons),
                        IsLowPriority,
                        this.ActiveMember == currentMember ? currentMember : null,
                        Union(analyzers), this.IsRetry || retry,
                        asyncToken);
                }

                public WorkItem With(IAsyncToken asyncToken)
                {
                    return new WorkItem(
                        this.DocumentId, this.ProjectId, this.Language, this.InvocationReasons, this.IsLowPriority, this.ActiveMember, this.Analyzers,
                        retry: false, asyncToken: asyncToken);
                }

                public WorkItem With(DocumentId documentId, ProjectId projectId, IAsyncToken asyncToken)
                {
                    // create new work item
                    return new WorkItem(
                        documentId,
                        projectId,
                        this.Language,
                        this.InvocationReasons,
                        this.IsLowPriority,
                        this.ActiveMember,
                        this.Analyzers,
                        this.IsRetry,
                        asyncToken);
                }

                public override string ToString()
                {
                    return $"{DocumentId?.ToString() ?? ProjectId.ToString()}, ({InvocationReasons.ToString()}), LowPriority:{IsLowPriority}, ActiveMember:{ActiveMember != null}, Retry:{IsRetry}, ({string.Join("|", Analyzers.Select(a => a.GetType().Name))})";
                }
            }
        }
    }
}


text:
package org.medipi.concentrator.dao;

import java.util.Date;
import java.util.List;
import org.medipi.concentrator.entities.RecordingDeviceData;
import org.medipi.concentrator.entities.Patient;
import org.medipi.concentrator.entities.RecordingDeviceAttribute;

/**
 * Data Access Object interface for RecordingDeviceData
 *
 * @author rick@robinsonhq.com
 */
public interface RecordingDeviceDataDAO extends GenericDAO<RecordingDeviceData> {

    /**
     * Method to check if a data point has already been persisted to the DB
     *
     * @param rda recordingDeviceAttribute
     * @param patient patient
     * @param data data value of the data point
     * @param dataPointTime time at which the measurement was taken
     * @return
     */
    public List<RecordingDeviceData> isAlreadyStored(RecordingDeviceAttribute rda, Patient patient, String data, Date dataPointTime);

    public List<RecordingDeviceData> findByPatientUuidAfterDate(String patientUuid, Date requestDate, String type);

    public RecordingDeviceData findByTypeAttributeAndData(String patientUuid, String type, String AttributeName, Date dataValueTime, String dataValue);

    public List<RecordingDeviceData> findByPatientAndDownloadedTime(String patientUuid, Date downloadedTime, Date endTime);
}


text:
package ru.atom.http;

import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import sun.util.resources.cldr.ms.CalendarData_ms_MY;

import java.io.IOException;

public class ChatClient {
    private static final OkHttpClient client = new OkHttpClient();
    private static final String PROTOCOL = "http://";
    private static final String HOST = "wtfis.ru";
    private static final String PORT = ":8080";

    //GET host:port/chat/online
    public static Response viewOnline() throws IOException {
        Request request = new Request.Builder()
                .get()
                .url(PROTOCOL + HOST + PORT + "/chat/online")
                .addHeader("host", HOST + PORT)
                .build();

        return client.newCall(request).execute();
    }

    //POST host:port/chat/login?name=my_name
    public static Response login(String name) throws IOException {
        MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
        Request request = new Request.Builder()
                .post(RequestBody.create(mediaType, ""))
                .url(PROTOCOL + HOST + PORT + "/chat/login?name=" + name)
                .build();

        return client.newCall(request).execute();
    }

    //POST host:port/chat/say?name=my_name
    //Body: "msg='my_message'"
    public static Response say(String name, String msg) throws IOException {
        throw new NotImplementedException();
    }

    //GET host:port/chat/chat
    public static Response viewChat() throws IOException {
        throw new NotImplementedException();
    }
}


text: __author__ = "Scott Nottingham"


text:
{% load daguerre %}
{% adjust banner 'fill' width=1200 height=300 as image %}
{% if image %}

{% endif %}


text:
package org.emonic.base.documentation;

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

class XMLDocumentation implements IDocumentation
{

	private List exceptions;
	private List parameters;

	private String name;
	private String remarks;
	private String returns;
	private String seeAlso;
	private String summary;
	private String value;

	XMLDocumentation(String name)
	{
		this.name = name;
	}

	@Override
	public IDocumentation[] getExceptions()
	{
		return exceptions == null ? new IDocumentation[0] : (IDocumentation[]) exceptions.toArray(new IDocumentation[exceptions.size()]);
	}

	@Override
	public String getName()
	{
		return name;
	}

	void addParameter(String name, String summary)
	{
		if(parameters == null)
		{
			parameters = new ArrayList();
		}
		parameters.add(new Parameter(name, summary));
	}

	@Override
	public IDocumentation[] getParams()
	{
		return parameters == null ? new IDocumentation[0] : (IDocumentation[]) parameters.toArray(new IDocumentation[parameters.size()]);
	}

	@Override
	public String getRemarks()
	{
		return remarks;
	}

	void setRemarks(String remarks)
	{
		this.remarks = remarks;
	}

	@Override
	public String getReturns()
	{
		return returns;
	}

	void setReturns(String returns)
	{
		this.returns = returns;
	}

	@Override
	public String getSeeAlso()
	{
		return seeAlso;
	}

	void setSeeAlso(String seeAlso)
	{
		this.seeAlso = seeAlso;
	}

	@Override
	public String getSummary()
	{
		return summary;
	}

	void setSummary(String summary)
	{
		this.summary = summary;
	}

	@Override
	public String getValue()
	{
		return value;
	}

	void setValue(String value)
	{
		this.value = value;
	}

	class Parameter extends AbstractDocumentation
	{

		private final String name;
		private final String summary;

		Parameter(String name, String summary)
		{
			this.name = name;
			this.summary = summary;
		}

		@Override
		public String getName()
		{
			return name;
		}

		@Override
		public String getSummary()
		{
			return summary;
		}

	}

}


text:
<md-toolbar color="primary">
    <md-toolbar-row fxLayout="row">
        <button md-button md-icon-button routerLink="/semester" mdTooltip="Semester">
            <md-icon>arrow_upward</md-icon>
        </button>

{{course.name}}

        <settings-button></settings-button>
    </md-toolbar-row>
</md-toolbar>

        <md-card *ngIf="course && course.deliverables.length !== 0" class="details-card">

                <div fxFlex class="tile" id="complete" [fxHide]="completionPercentage === 100 || completionPercentage <= 0">
                    {{ completionPercentage | number : '1.0-1' }}% Done

                    {{ currentGrade | number : '1.0-1' }}% Current Grade

{{deliverable.name}}

{{deliverable.due | date}}

Mark: {{getDisplayValue(deliverable.mark)}}

Weight: {{getDisplayValue(deliverable.weight)}}

Mark: {{getDisplayValue(deliverable.mark)}}

Weight: {{getDisplayValue(deliverable.weight)}}

{{getStatus(deliverable)}}

                            <button md-button md-icon-button [fxHide]="deliverable.isComplete" (click)="completeDeliverable(deliverable)" mdTooltip="Complete">
                                <md-icon>done</md-icon>
                            </button>
                            <button md-button md-icon-button [fxShow]="canInputMark(deliverable)" (click)="beginInputMark(deliverable)" mdTooltip="Input mark">
                                <md-icon>input</md-icon>
                            </button>
                            <button md-button md-icon-button [fxShow]="deliverable.isComplete" (click)="reset(deliverable)" mdTooltip="Reset">
                                <md-icon>undo</md-icon>
                            </button>

        </md-card>

            Add your first deliverable for {{course.name}}

                <md-icon>add</md-icon>


text:
package com.odiago.flumebase.util.concurrent;

import org.testng.annotations.Test;

public class TestArrayBoundedSelectableQueue extends QueueTestCase {
  @Test
  public void TestSimple() {
    // 1 producer, 1 consumer, bigger buffer than we need.
    runTest(new ArrayBoundedSelectableQueue<Long>(500), 1, 1, 100);

    // 1 producer, 1 consumer, smaller buffer than we need.
    runTest(new ArrayBoundedSelectableQueue<Long>(20), 1, 1, 100);
  }

  @Test
  public void testFanOut() {
    // 1 producer, 2 consumers
    runTest(new ArrayBoundedSelectableQueue<Long>(100), 1, 2, 10000);

    // 1 producer, 4 consumers
    runTest(new ArrayBoundedSelectableQueue<Long>(1500), 1, 4, 25000);
  }

  @Test
  public void testFanIn() {
    // 2 producers, 1 consumer
    runTest(new ArrayBoundedSelectableQueue<Long>(100), 2, 1, 10000);

    // 1 producer, 4 consumers
    runTest(new ArrayBoundedSelectableQueue<Long>(1500), 4, 1, 25000);
  }

  @Test
  public void testMultiMulti() {
    // 2 producers, 2 consumers
    runTest(new ArrayBoundedSelectableQueue<Long>(100), 2, 2, 10000);

    // 3 producers, 3 consumers
    runTest(new ArrayBoundedSelectableQueue<Long>(1500), 3, 3, 25000);
  }
}


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>Maintenance Mode Configuration — ownCloud Administrators Manual 7.0 documentation</title>

    <link rel="stylesheet" href="../_static/style.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="../_static/style.css" type="text/css" />
    <link rel="stylesheet" href="../_static/bootstrap-sphinx.css" type="text/css" />

    <link rel="top" title="ownCloud Administrators Manual 7.0 documentation" href="../index.html" />
    <link rel="up" title="Maintenance" href="index.html" />
    <link rel="next" title="Backing up ownCloud" href="backup.html" />
    <link rel="prev" title="Maintenance" href="index.html" />

ownCloud Administrators Manual

Overview

Introduction

Installation

Configuration

Maintenance

Maintenance Mode Configuration

Parameters

Backing up ownCloud

Updating ownCloud

Restoring ownCloud

Migrating ownCloud Installations

Issues

Maintenance Mode Configuration¶

If you want to prevent users to login to ownCloud before you start doing
some maintenance work, you need to set the value of the maintenance
parameter to true. Please keep in mind that users who are already logged-in
are kicked out of ownCloud instantly.

Parameters¶

<?php

  "maintenance" => false,

This parameters can be set in the <tt class="file docutils literal">config/config.php</tt>


text:
package org.glowroot.agent.live;

import java.lang.instrument.Instrumentation;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.ImmutableList;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import org.glowroot.agent.live.ClasspathCache.UiAnalyzedMethod;
import org.glowroot.agent.weaving.AnalyzedWorld;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class ClasspathCacheTest {

    private static ClasspathCache classpathCache;

    @BeforeAll
    public static void setUp() throws Exception {
        ClassLoader badUrlsClassLoader =
                new URLClassLoader(new URL[] {new URL("file://a/b c"), new URL("http://a/b/c")});
        AnalyzedWorld analyzedWorld = mock(AnalyzedWorld.class);
        when(analyzedWorld.getClassLoaders()).thenReturn(
                ImmutableList.of(badUrlsClassLoader, ClassLoader.getSystemClassLoader()));
        Instrumentation instrumentation = mock(Instrumentation.class);
        when(instrumentation.getAllLoadedClasses()).thenReturn(new Class[] {A.class});
        classpathCache = new ClasspathCache(analyzedWorld, instrumentation);
    }

    @Test
    public void shouldRead() {
        // when
        List<String> classNames = classpathCache.getMatchingClassNames("google.common.base.str", 5);
        // then
        assertThat(classNames).contains("com.google.common.base.Strings");
    }

    @Test
    public void shouldReadFullClass() {
        // when
        List<String> classNames = classpathCache.getMatchingClassNames("ImmutableMap", 5);
        // then
        assertThat(classNames).contains("com.google.common.collect.ImmutableMap");
    }

    @Test
    public void shouldReadFullFullClass() {
        // when
        List<String> classNames =
                classpathCache.getMatchingClassNames("com.google.common.collect.ImmutableMap", 5);
        // then
        assertThat(classNames).contains("com.google.common.collect.ImmutableMap");
    }

    @Test
    public void shouldReadFullInnerClass() {
        // when
        List<String> classNames = classpathCache.getMatchingClassNames("OnePlusArrayList", 5);
        // then
        assertThat(classNames).contains("com.google.common.collect.Lists$OnePlusArrayList");
    }

    @Test
    public void shouldReadFullFullInnerClass() {
        // when
        List<String> classNames = classpathCache
                .getMatchingClassNames("com.google.common.collect.Lists$OnePlusArrayList", 5);
        // then
        assertThat(classNames).contains("com.google.common.collect.Lists$OnePlusArrayList");
    }

    @Test
    public void shouldHitFullMatchLimit() {
        // when
        List<String> classNames = classpathCache.getMatchingClassNames("Builder", 5);
        // then
        assertThat(classNames).hasSize(5);
        for (String className : classNames) {
            if (!className.endsWith("$Builder") && !className.endsWith(".Builder")) {
                throw new AssertionError();
            }
        }
    }

    @Test
    public void shouldAnalyzedMethods() {
        List<UiAnalyzedMethod> methods = classpathCache.getAnalyzedMethods(A.class.getName());
        assertThat(methods).hasSize(1);
    }

    @Test
    public void shouldAnalyzedMethodsB() {
        List<UiAnalyzedMethod> methods = classpathCache.getAnalyzedMethods(B.class.getName());
        assertThat(methods).hasSize(1);
    }

    @SuppressWarnings("serial")
    private static class A extends ArrayList<String> {
        @Override
        public boolean add(String str) {
            return true;
        }
    }

    @SuppressWarnings("serial")
    private static class B extends ArrayList<String> {
        @Override
        public boolean add(String str) {
            return true;
        }
    }
}


text:
/**
 * @requires OpenLayers/Control/DragPan.js
 * @requires OpenLayers/Control/PinchZoom.js
 * @requires OpenLayers/Handler/Click.js
 */

/**
 * Class: OpenLayers.Control.TouchNavigation
 * The navigation control handles map browsing with touch events (dragging,
 *     double-tapping, tap with two fingers, and pinch zoom).  Create a new
 *     control with the <OpenLayers.Control.TouchNavigation> constructor.
 *
 * If you're only targeting touch enabled devices with your mapping application,
 *     you can create a map with only a TouchNavigation control. The
 *     <OpenLayers.Control.Navigation> control is mobile ready by default, but
 *     you can generate a smaller build of the library by only including this
 *     touch navigation control if you aren't concerned about mouse interaction.
 *
 * Inherits:
 *  - <OpenLayers.Control>
 */
OpenLayers.Control.TouchNavigation = OpenLayers.Class(OpenLayers.Control, {

    /**
     * Property: dragPan
     * {<OpenLayers.Control.DragPan>}
     */
    dragPan: null,

    /**
     * APIProperty: dragPanOptions
     * {Object} Options passed to the DragPan control.
     */
    dragPanOptions: null,

    /**
     * Property: pinchZoom
     * {<OpenLayers.Control.PinchZoom>}
     */
    pinchZoom: null,

    /**
     * APIProperty: pinchZoomOptions
     * {Object} Options passed to the PinchZoom control.
     */
    pinchZoomOptions: null,

    /**
     * APIProperty: clickHandlerOptions
     * {Object} Options passed to the Click handler.
     */
    clickHandlerOptions: null,

    /**
     * APIProperty: documentDrag
     * {Boolean} Allow panning of the map by dragging outside map viewport.
     *     Default is false.
     */
    documentDrag: false,

    /**
     * APIProperty: autoActivate
     * {Boolean} Activate the control when it is added to a map.  Default is
     *     true.
     */
    autoActivate: true,

    /**
     * Constructor: OpenLayers.Control.TouchNavigation
     * Create a new navigation control
     *
     * Parameters:
     * options - {Object} An optional object whose properties will be set on
     *                    the control
     */
    initialize: function (options) {
        this.handlers = {};
        OpenLayers.Control.prototype.initialize.apply(this, arguments);
    },

    /**
     * Method: destroy
     * The destroy method is used to perform any clean up before the control
     * is dereferenced.  Typically this is where event listeners are removed
     * to prevent memory leaks.
     */
    destroy: function () {
        this.deactivate();
        if (this.dragPan) {
            this.dragPan.destroy();
        }
        this.dragPan = null;
        if (this.pinchZoom) {
            this.pinchZoom.destroy();
            delete this.pinchZoom;
        }
        OpenLayers.Control.prototype.destroy.apply(this, arguments);
    },

    /**
     * Method: activate
     */
    activate: function () {
        if (OpenLayers.Control.prototype.activate.apply(this, arguments)) {
            this.dragPan.activate();
            this.handlers.click.activate();
            this.pinchZoom.activate();
            return true;
        }
        return false;
    },

    /**
     * Method: deactivate
     */
    deactivate: function () {
        if (OpenLayers.Control.prototype.deactivate.apply(this, arguments)) {
            this.dragPan.deactivate();
            this.handlers.click.deactivate();
            this.pinchZoom.deactivate();
            return true;
        }
        return false;
    },

    /**
     * Method: draw
     */
    draw: function () {
        var clickCallbacks = {
            click: this.defaultClick,
            dblclick: this.defaultDblClick
        };
        var clickOptions = OpenLayers.Util.extend({
            "double": true,
            stopDouble: true,
            pixelTolerance: 2
        }, this.clickHandlerOptions);
        this.handlers.click = new OpenLayers.Handler.Click(
            this, clickCallbacks, clickOptions
        );
        this.dragPan = new OpenLayers.Control.DragPan(
            OpenLayers.Util.extend({
                map: this.map,
                documentDrag: this.documentDrag
            }, this.dragPanOptions)
        );
        this.dragPan.draw();
        this.pinchZoom = new OpenLayers.Control.PinchZoom(
            OpenLayers.Util.extend({map: this.map}, this.pinchZoomOptions)
        );
    },

    /**
     * Method: defaultClick
     *
     * Parameters:
     * evt - {Event}
     */
    defaultClick: function (evt) {
        if (evt.lastTouches && evt.lastTouches.length == 2) {
            this.map.zoomOut();
        }
    },

    /**
     * Method: defaultDblClick
     *
     * Parameters:
     * evt - {Event}
     */
    defaultDblClick: function (evt) {
        this.map.zoomTo(this.map.zoom + 1, evt.xy);
    },

    CLASS_NAME: "OpenLayers.Control.TouchNavigation"
});


text:
package org.apache.spark.groupon.metrics

import java.util.concurrent.TimeUnit

import org.apache.spark.groupon.metrics.util.{TestMetricsRpcEndpoint, SparkContextSetup}
import org.apache.spark.rpc.RpcEndpointRef
import org.scalatest.concurrent.Eventually
import org.scalatest.{Matchers, BeforeAndAfter, FlatSpec}

import scala.util.Random

class SparkMetricTest extends FlatSpec with Matchers with BeforeAndAfter with Eventually with SparkContextSetup {
  var metricsEndpoint: TestMetricsRpcEndpoint = _
  var metricsEndpointRef: RpcEndpointRef = _

  before {
    metricsEndpoint = new TestMetricsRpcEndpoint(sc.env.rpcEnv)
    metricsEndpointRef = sc.env.rpcEnv.setupEndpoint(Random.alphanumeric.take(32).mkString(""), metricsEndpoint)
  }

  after {
    metricsEndpoint.stop()
    metricsEndpoint = null
    metricsEndpointRef = null
  }

  "Counter" should "increment correctly" in {
    val counterName = "counter"
    val counter = new SparkCounter(metricsEndpointRef, counterName)
    val incrementVals = Seq(1, 2, 3, -1, -2, -3)
    incrementVals.foreach(i => counter.inc(i))

    eventually {
      metricsEndpoint.getMetricNames shouldBe Seq.fill(incrementVals.length)(counterName)
      metricsEndpoint.getMetricValues shouldBe incrementVals
    }
  }

  it should "decrement correctly" in {
    val counterName = "counter"
    val counter = new SparkCounter(metricsEndpointRef, counterName)
    val decrementVals = Seq(1, 2, 3, -1, -2, -3)
    decrementVals.foreach(i => counter.dec(i))

    eventually {
      metricsEndpoint.getMetricNames shouldBe Seq.fill(decrementVals.length)(counterName)
      metricsEndpoint.getMetricValues shouldBe decrementVals.map(i => -i)
    }
  }

  "Gauge" should "set its value correctly" in {
    val gaugeName = "gauge"
    val gauge = new SparkGauge(metricsEndpointRef, gaugeName)
    val gaugeVal = 1
    gauge.set(gaugeVal)

    eventually {
      metricsEndpoint.getMetricNames shouldBe Seq(gaugeName)
      metricsEndpoint.getMetricValues shouldBe Seq(gaugeVal)
    }
  }

  "Histogram" should "set its value correctly" in {
    val histogramName = "histogram"
    val histogram = new SparkHistogram(metricsEndpointRef, histogramName, ReservoirClass.ExponentiallyDecaying)
    val histogramVals = Seq(1, 2, 3, -1, -2, -3)
    histogramVals.foreach(i => histogram.update(i))

    eventually {
      metricsEndpoint.getMetricNames shouldBe Seq.fill(histogramVals.length)(histogramName)
      metricsEndpoint.getMetricValues shouldBe histogramVals
    }
  }

  it should "use the correct Reservoir class" in {
    val reservoirClasses = Seq(
      ReservoirClass.ExponentiallyDecaying,
      ReservoirClass.SlidingTimeWindow,
      ReservoirClass.SlidingWindow,
      ReservoirClass.Uniform
    )
    reservoirClasses.foreach(reservoirClass => {
      new SparkHistogram(metricsEndpointRef, "histogram", reservoirClass).update(0)
    })

    eventually {
      metricsEndpoint.metricStore.map(metricMessage => {
        metricMessage.asInstanceOf[HistogramMessage].reservoirClass
      }) shouldBe reservoirClasses
    }
  }

  "Meter" should "set its value correctly" in {
    val meterName = "meter"
    val meter = new SparkMeter(metricsEndpointRef, meterName)
    val meterVals = Seq(1, 2, 3, -1, -2, -3)
    meterVals.foreach(i => meter.mark(i))

    eventually {
      metricsEndpoint.getMetricNames shouldBe Seq.fill(meterVals.length)(meterName)
      metricsEndpoint.getMetricValues shouldBe meterVals
    }
  }

  "Timer" should "set its value correctly with 'update'" in {
    val timerName = "timer"
    val timer = new SparkTimer(metricsEndpointRef, timerName, ReservoirClass.ExponentiallyDecaying, ClockClass.UserTime)
    val timerVal = 1000
    timer.update(timerVal, TimeUnit.NANOSECONDS)

    eventually {
      metricsEndpoint.getMetricNames shouldBe Seq(timerName)
      metricsEndpoint.getMetricValues shouldBe Seq(timerVal)
    }
  }

  it should "convert time units correctly with 'update'" in {
    val timer = new SparkTimer(metricsEndpointRef, "timer", ReservoirClass.ExponentiallyDecaying, ClockClass.UserTime)
    val timeUnits = Seq(
      TimeUnit.DAYS,
      TimeUnit.HOURS,
      TimeUnit.MICROSECONDS,
      TimeUnit.MILLISECONDS,
      TimeUnit.MINUTES,
      TimeUnit.NANOSECONDS,
      TimeUnit.SECONDS
    )
    val timerVal = 1
    timeUnits.foreach(timeUnit => timer.update(timerVal, timeUnit))

    eventually {
      metricsEndpoint.getMetricValues shouldBe timeUnits.map(timeUnit => timeUnit.toNanos(timerVal))
    }
  }

  it should "time a function correctly" in {
    val timer = new SparkTimer(metricsEndpointRef, "timer", ReservoirClass.ExponentiallyDecaying, ClockClass.UserTime)
    // Function should take about 500 milliseconds
    val (duration, timeUnit) = (500, TimeUnit.MILLISECONDS)
    val toleranceRange = timeUnit.toNanos(duration) +- timeUnit.toNanos(100)
    timer.time({
      timeUnit.sleep(duration)
    })

    eventually {
      metricsEndpoint.getMetricValues.head.asInstanceOf[Long] shouldBe toleranceRange
    }
  }

  it should "time using a Context correctly" in {
    val timer = new SparkTimer(metricsEndpointRef, "timer", ReservoirClass.ExponentiallyDecaying, ClockClass.UserTime)
    // Timer should measure about 500 milliseconds
    val (duration, timeUnit) = (500, TimeUnit.MILLISECONDS)
    val toleranceRange = timeUnit.toNanos(duration) +- timeUnit.toNanos(100)
    val timerContext = timer.time()
    timeUnit.sleep(duration)
    timerContext.stop()

    eventually {
      metricsEndpoint.getMetricValues.head.asInstanceOf[Long] shouldBe toleranceRange
    }
  }

  it should "use the correct Reservoir class" in {
    val reservoirClasses = Seq(
      ReservoirClass.ExponentiallyDecaying,
      ReservoirClass.SlidingTimeWindow,
      ReservoirClass.SlidingWindow,
      ReservoirClass.Uniform
    )
    reservoirClasses.foreach(reservoirClass => {
      new SparkTimer(metricsEndpointRef, "timer", reservoirClass, ClockClass.UserTime).update(0, TimeUnit.SECONDS)
    })

    eventually {
      metricsEndpoint.metricStore.map(metricMessage => {
        metricMessage.asInstanceOf[TimerMessage].reservoirClass
      }) shouldBe reservoirClasses
    }
  }

  it should "use the correct Clock class" in {
    val clockClasses = Seq(
      ClockClass.UserTime,
      ClockClass.CpuTime
    )
    clockClasses.foreach(clockClass => {
      new SparkTimer(metricsEndpointRef, "timer", ReservoirClass.ExponentiallyDecaying, clockClass)
        .update(0, TimeUnit.SECONDS)
    })

    eventually {
      metricsEndpoint.metricStore.map(metricMessage => {
        metricMessage.asInstanceOf[TimerMessage].clockClass
      }) shouldBe clockClasses
    }
  }
}


text:
/**
 * Provides classes used to manage {@link javafx.scene.text.Font} with JRebirth Resource Engine.
 */
package org.jrebirth.af.core.resource.font;