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

    <groupId>com.github.h908714124</groupId>
    <artifactId>zerobuilder-parent</artifactId>
    <version>0-SNAPSHOT</version>

    <packaging>pom</packaging>

    <modules>
        <module>api</module>
        <module>modules</module>
        <module>zerobuilder</module>
        <module>compiler</module>
        <module>examples</module>
    </modules>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

</project>


text:
////////////////////////////////////////////////////////////////////////////////
/// @brief memory mapped files in windows
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2014 ArangoDB GmbH, Cologne, Germany
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
///
/// 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.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Dr. Oreste Costa-Panaia
/// @author Copyright 2014, ArangoDB GmbH, Cologne, Germany
/// @author Copyright 2012-2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////

#ifndef ARANGODB_BASICS_C_MEMORY__MAP__WIN32_H
#define ARANGODB_BASICS_C_MEMORY__MAP__WIN32_H 1

#include "Basics/Common.h"

#ifdef TRI_HAVE_WIN32_MMAP

#include <Windows.h>

////////////////////////////////////////////////////////////////////////////////
/// @brief undefine this so anonymous memory mapping is disabled
///
/// anonymous memory mapping may or may not work on Windows
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// Flags used when we create a memory map -- dummy flags for windows for now
////////////////////////////////////////////////////////////////////////////////

#define MAP_SHARED      0x01            /* Share changes */
#define MAP_PRIVATE     0x02            /* Changes are private */
#define MAP_TYPE        0x0f            /* Mask for type of mapping */
#define MAP_FIXED       0x10            /* Interpret addr exactly */
#define MAP_ANONYMOUS   0x20            /* don't use a file */

#define TRI_MMAP_ANONYMOUS MAP_ANONYMOUS

////////////////////////////////////////////////////////////////////////////////
// Define some dummy flags which are ignored under windows.
// Under windows only the MS_SYNC flag makes sense, that is, all memory map
// file flushes are synchronous.
////////////////////////////////////////////////////////////////////////////////

#define MS_ASYNC        1             /* sync memory asynchronously */
#define MS_INVALIDATE   2             /* invalidate the caches */
#define MS_SYNC         4             /* synchronous memory sync */

#define PROT_READ       0x1             /* Page can be read.  */
#define PROT_WRITE      0x2             /* Page can be written.  */
#define PROT_EXEC       0x4             /* Page can be executed.  */
#define PROT_NONE       0x0             /* Page can not be accessed.  */
#define PROT_GROWSDOWN  0x01000000      /* Extend change to start of growsdown vma (mprotect only).  */
#define PROT_GROWSUP    0x02000000      /* Extend change to start of growsup vma (mprotect only).  */

#endif

#endif

// -----------------------------------------------------------------------------
// --SECTION--                                                       END-OF-FILE
// -----------------------------------------------------------------------------

// Local Variables:
// mode: outline-minor
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}"
// End:

redpajama_set_name: RedPajamaGithub


text:
package org.apache.camel.component.nsq;

import java.util.Map;

import org.apache.camel.Endpoint;
import org.apache.camel.SSLContextParametersAware;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.annotations.Component;
import org.apache.camel.support.DefaultComponent;

/**
 * Represents the component that manages {@link NsqEndpoint}.
 */
@Component("nsq")
public class NsqComponent extends DefaultComponent implements SSLContextParametersAware {

    @Metadata(label = "security", defaultValue = "false")
    private boolean useGlobalSslContextParameters;

    @Override
    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
        NsqConfiguration configuration = new NsqConfiguration();
        setProperties(configuration, parameters);
        configuration.setServers(remaining);

        if (configuration.getSslContextParameters() == null) {
            configuration.setSslContextParameters(retrieveGlobalSslContextParameters());
        }

        NsqEndpoint endpoint = new NsqEndpoint(uri, this, configuration);
        return endpoint;
    }

    @Override
    public boolean isUseGlobalSslContextParameters() {
        return this.useGlobalSslContextParameters;
    }

    /**
     * Enable usage of global SSL context parameters.
     */
    @Override
    public void setUseGlobalSslContextParameters(boolean useGlobalSslContextParameters) {
        this.useGlobalSslContextParameters = useGlobalSslContextParameters;
    }
}


text:
using System;

namespace Palwyn.Domain.Infrastructure
{
	public abstract class EntityBase<TEntityId> : DomainBase, IEntity<TEntityId>, IEquatable<EntityBase<TEntityId>>
	{
		public TEntityId Id { get; private set; }

		protected EntityBase() { }

		protected EntityBase(TEntityId id)
		{
			if (id != null)
			{
				Id = id;
			}
		}

		public override int GetHashCode()
		{
			// Call the base class GetHashCode
			int hashcode = base.GetHashCode();

			return hashcode;
		}

		public override bool Equals(object other)
		{
			if (other != null)
			{
				if (this.Equals((EntityBase<TEntityId>)other))
				{
					return true;
				}
			}

			return false;
		}

		public virtual bool Equals(EntityBase<TEntityId> other)
		{
			if ((object)other != null)
			{
				if (GetType() == other.GetType())
				{
					if (this.Id.Equals(other.Id))
					{
						if (this.CompareProperties(other))
						{
							return true;
						}
					}
				}
			}

			return false;
		}

		public static bool operator ==(EntityBase<TEntityId> leftEntity, EntityBase<TEntityId> rightEntity)
		{
			bool? nullChecks = Utilities.EqualityNullChecks(leftEntity, rightEntity);

			if (nullChecks.HasValue)
			{
				return (bool)nullChecks;
			}

			// Perform null checks on the Id's
			nullChecks = Utilities.EqualityNullChecks(leftEntity.Id, rightEntity.Id);

			if (nullChecks.HasValue)
			{
				return (bool)nullChecks;
			}

			// If the entities are equal, return true
			if (leftEntity.Equals(rightEntity))
			{
				return true;
			}

			return false;
		}

		public static bool operator !=(EntityBase<TEntityId> leftEntity, EntityBase<TEntityId> rightEntity)
		{
			return (!(leftEntity == rightEntity));
		}
	}
}


text:
#ifndef VOLUME_NODE_H
#define VOLUME_NODE_H

#include <vector>
#include <memory>
#include <string>
#include "linalg/transform.h"
#include "volume.h"

/*
 * A scene node that holds some volume instead of geometry
 * analogous to the geometry node but for volumes
 */
class VolumeNode : public Volume {
	std::vector<std::shared_ptr<VolumeNode>> children;
	const Volume *volume;
	Transform transform, inv_transform;
	std::string name;

public:
	/*
	 * Create a volume node in the scene, placing some volume in the scene
	 */
	VolumeNode(const Volume *volume, const Transform &t, const std::string &name);
	/*
	 * Get the object-space bounds for the volume region
	 */
	 BBox bound() const override;
	/*
	 * Test if the ray intersects the volume region, returning the min/max t
	 * values that the ray overlapped the region in
	 */
	 bool intersect(const Ray &ray, std::array<float, 2> &t) const override;
	/*
	 * Get the absorption coefficient of the volume at some point
	 * along the direction passed
	 */
	 Colorf absorption(const Point &p, const Vector &v) const override;
	/*
	 * Get the scattering coefficient of the volume at some point
	 * along the direction passed
	 */
	 Colorf scattering(const Point &p, const Vector &v) const override;
	/*
	 * Get the attenuation coefficient of the volume at some poiint
	 * along the direciton passed
	 */
	 Colorf attenuation(const Point &p, const Vector &v) const;
	/*
	 * Get the emission property of the volume region at some point
	 * along the direction passed
	 */
	 Colorf emission(const Point &p, const Vector &v) const override;
	/*
	 * Get the optical thickness of the region along the ray on the line
	 * segment from min_t to max_t
	 * For volumes that use Monte Carlo integration to compute this value step
	 * and offset are used to control how to step along the segment to estimate
	 * the integral
	 */
	 Colorf optical_thickness(const Ray &ray, float step = 1, float offset = 0.5) const override;
	/*
	 * Get the phase function value for the volume at the some point
	 * for a ray incident along w_i and exiting along w_o
	 */
	 float phase(const Point &p, const Vector &w_i, const Vector &w_o) const override;
	 /*
	  * Get the volume associated with the node, or nullptr if none is attached
	  */
	 const Volume* get_volume() const;
	 /*
	  * Get the transform or inverse of the nodes transform
	  */
	 const Transform& get_transform() const;
	 Transform& get_transform();
	 const Transform& get_inv_transform() const;
	 Transform& get_inv_transform();
	 /*
	  * Get the node's children
	  */
	 const std::vector<std::shared_ptr<VolumeNode>>& get_children() const;
	 std::vector<std::shared_ptr<VolumeNode>>& get_children();
};

#endif


text:
module.exports = function (guardian) {
  'use strict';

  var tests = [],
    guard = guardian({
      tests: tests
    }),
    test1 = Object.create(guard),
    firstFail = test1.assert(true).assert(false),
    test2 = Object.create(guard),
    secondFail = test2.assert(false);

  test1.name = "test1";
  test2.name = "test2";
  var failures = guard.failures();

  function hasFailure(fail) {
    var s = JSON.stringify;
    return failures.some(function (i) {
      return s(i) === s(fail);
    });
  }

  return {
    'guard has two failures': failures.length === 2,
    'failure has none of the methods': failures[0].assert === undefined,
    'failures has firstFail': hasFailure({
      "pass": false,
      "name": "test1"
    }),
    'failures has secondFail': hasFailure({
      "pass": false,
      "name": "test2"
    }),
  };
};


text:
"""This module is deprecated. Please use :mod:`airflow.sensors.base`."""

import warnings

# pylint: disable=unused-import
from airflow.sensors.base import BaseSensorOperator  # noqa

warnings.warn(
    "This module is deprecated. Please use `airflow.sensors.base`.", DeprecationWarning, stacklevel=2
)


text:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="GradleSettings">
    <option name="linkedExternalProjectsSettings">
      <GradleProjectSettings>
        <option name="distributionType" value="DEFAULT_WRAPPED" />
        <option name="externalProjectPath" value="$PROJECT_DIR$" />
        <option name="modules">
          <set>
            <option value="$PROJECT_DIR$/../LibCore" />
            <option value="$PROJECT_DIR$/../LibDataStore" />
            <option value="$PROJECT_DIR$/../LibDownload" />
            <option value="$PROJECT_DIR$/../LibImageLoader" />
            <option value="$PROJECT_DIR$/../LibNet" />
            <option value="$PROJECT_DIR$/../LibUtils" />
            <option value="$PROJECT_DIR$/../LibWidget" />
            <option value="$PROJECT_DIR$" />
            <option value="$PROJECT_DIR$/app" />
            <option value="$PROJECT_DIR$/libwidget" />
          </set>
        </option>
        <option name="myModules">
          <set>
            <option value="$PROJECT_DIR$/../LibCore" />
            <option value="$PROJECT_DIR$/../LibDataStore" />
            <option value="$PROJECT_DIR$/../LibDownload" />
            <option value="$PROJECT_DIR$/../LibImageLoader" />
            <option value="$PROJECT_DIR$/../LibNet" />
            <option value="$PROJECT_DIR$/../LibUtils" />
            <option value="$PROJECT_DIR$/../LibWidget" />
            <option value="$PROJECT_DIR$" />
            <option value="$PROJECT_DIR$/app" />
            <option value="$PROJECT_DIR$/libwidget" />
          </set>
        </option>
      </GradleProjectSettings>
    </option>
  </component>
</project>


text:
#include "nanoev_internal.h"

/*----------------------------------------------------------------------------*/

struct nanoev_timer {
    NANOEV_EVENT_FILEDS
    nanoev_timeval after;
    int repeat;
    unsigned int min_heap_idx;
    nanoev_timeval timeout;
    nanoev_timer_callback callback;
};
typedef struct nanoev_timer nanoev_timer;

static int min_heap_insert(timer_min_heap *heap, nanoev_timer *timer);
static void min_heap_erase(timer_min_heap *heap, nanoev_timer *timer);
static int min_heap_reserve(timer_min_heap *heap, unsigned int capacity_required);
static void min_heap_shift_up(timer_min_heap *heap, unsigned int hole_index, nanoev_timer *timer);
static void min_heap_shift_down(timer_min_heap *heap, unsigned int hole_index, nanoev_timer *timer);

#define NANOEV_TIMER_FLAG_INVOKING_CALLBACK  (0x00000001) /* during callback */
#define NANOEV_TIMER_FLAG_DELETED            (0x80000000) /* mark for delete */

/*----------------------------------------------------------------------------*/

nanoev_event* timer_new(nanoev_loop *loop, void *userdata)
{
    nanoev_timer *timer;

    timer = (nanoev_timer*)mem_alloc(sizeof(nanoev_timer));
    if (!timer)
        return NULL;

    memset(timer, 0, sizeof(nanoev_timer));

    timer->type = nanoev_event_timer;
    timer->loop = loop;
    timer->userdata = userdata;
    timer->min_heap_idx = (unsigned int)-1;

    return (nanoev_event*)timer;
}

void timer_free(nanoev_event *event)
{
    nanoev_timer *timer = (nanoev_timer*)event;
    ASSERT(!(timer->flags & NANOEV_TIMER_FLAG_DELETED));

    if (!(timer->flags & NANOEV_TIMER_FLAG_INVOKING_CALLBACK)) {
        timer_min_heap *heap = get_loop_timers(timer->loop);
        min_heap_erase(heap, timer);

        mem_free(timer);
    } else {
        timer->flags |= NANOEV_TIMER_FLAG_DELETED;
    }
}

int nanoev_timer_add(
    nanoev_event *event,
    nanoev_timeval after,
    int repeat,
    nanoev_timer_callback callback
    )
{
    nanoev_timer *timer = (nanoev_timer*)event;
    timer_min_heap *heap;

    ASSERT(timer);
    ASSERT(in_loop_thread(timer->loop));
    ASSERT(callback);

    if (timer->min_heap_idx != (unsigned int)-1)
        return NANOEV_ERROR_FAIL;

    timer->after = after;
    timer->repeat = repeat;
    nanoev_loop_now(timer->loop, &timer->timeout);
    time_add(&timer->timeout, &after);
    timer->callback = callback;

    heap = get_loop_timers(timer->loop);
    ASSERT(heap);
    return min_heap_insert(heap, timer);
}

int nanoev_timer_del(
    nanoev_event *event
    )
{
    nanoev_timer *timer = (nanoev_timer*)event;
    timer_min_heap *heap;

    ASSERT(timer);
    ASSERT(in_loop_thread(timer->loop));

    if (timer->min_heap_idx == (unsigned int)-1)
        return NANOEV_ERROR_FAIL;

    heap = get_loop_timers(timer->loop);
    ASSERT(heap);
    min_heap_erase(heap, timer);

    return NANOEV_SUCCESS;
}

/*----------------------------------------------------------------------------*/

void timers_init(timer_min_heap *heap)
{
    ASSERT(heap);
    heap->events = NULL;
    heap->capacity = 0;
    heap->size = 0;
}

void timers_term(timer_min_heap *heap)
{
    ASSERT(heap);
    mem_free(heap->events);
}

void timers_timeout(timer_min_heap *heap, const nanoev_timeval *now, nanoev_timeval *timeout)
{
    nanoev_timer *top;

    ASSERT(heap && now);

    if (!heap->size) {
        timeout->tv_sec = -1;
        return;
    }

    top = (nanoev_timer*)heap->events[0];
    *timeout = top->timeout;
    if (time_cmp(timeout, now) <= 0) {
        timeout->tv_sec = 0;
        timeout->tv_usec = 0;
    } else {
        time_sub(timeout, now);
    }
}

void timers_process(timer_min_heap *heap, const nanoev_timeval *now)
{
    nanoev_timer *top;

    ASSERT(heap && now);

    while (heap->size) {
        top = (nanoev_timer*)heap->events[0];
        if (time_cmp(&top->timeout, now) > 0)
            break;

        /* Erase from the heap */
        min_heap_erase(heap, top);

        /* Invoke callback */
        top->flags |= NANOEV_TIMER_FLAG_INVOKING_CALLBACK;
        top->callback((nanoev_event*)top);
        top->flags &= ~NANOEV_TIMER_FLAG_INVOKING_CALLBACK;

        if (top->flags & NANOEV_TIMER_FLAG_DELETED) {  /* freed during callback */
            mem_free(top);

        } else if (top->repeat) {  /* Add back if top is a repeating timer */
            top->timeout = *now;

            time_add(&top->timeout, &top->after);

            min_heap_shift_up(heap, heap->size, top);
            heap->size++;
        }
    }
}

void timers_adjust_backward(timer_min_heap *heap, const nanoev_timeval *off)
{
    unsigned int i;
    nanoev_timer *timer;

    ASSERT(heap && off);

    for (i = 0; i < heap->size; ++i) {
        timer = (nanoev_timer*)heap->events[i];
        time_sub(&timer->timeout, off);
    }
}

/*----------------------------------------------------------------------------*/

static int __time_greater(nanoev_timer *t0, nanoev_timer *t1)
{
    int ret_code = time_cmp(&t0->timeout, &t1->timeout);
    return ret_code > 0 ? 1 : 0;
}

static int min_heap_insert(timer_min_heap *heap, nanoev_timer *timer)
{
    int ret_code;

    ASSERT(timer->min_heap_idx == (unsigned int)-1);

    ret_code = min_heap_reserve(heap, heap->size + 1);
    if (ret_code != NANOEV_SUCCESS)
        return ret_code;

    min_heap_shift_up(heap, heap->size, timer);
    heap->size++;

    return NANOEV_SUCCESS;
}

static void min_heap_erase(timer_min_heap *heap, nanoev_timer *timer)
{
    nanoev_timer *last;
    unsigned int parent;

    if (timer->min_heap_idx != (unsigned int)-1) {
        heap->size--;

        last = (nanoev_timer*)heap->events[heap->size];
        parent = (timer->min_heap_idx - 1) / 2;
        if (timer->min_heap_idx > 0 && __time_greater((nanoev_timer*)heap->events[parent], last))
            min_heap_shift_up(heap, timer->min_heap_idx, last);
        else
            min_heap_shift_down(heap, timer->min_heap_idx, last);

        timer->min_heap_idx = (unsigned int)-1;
    }
}

static int min_heap_reserve(timer_min_heap *heap, unsigned int capacity_required)
{
    ASSERT(heap);
    ASSERT(capacity_required);

    if (heap->capacity < capacity_required) {
        unsigned int capacity_new;
        nanoev_event** events_new;

        capacity_new = heap->capacity;
        while (capacity_new < capacity_required)
            capacity_new += 64;

        events_new = (nanoev_event**)mem_realloc(
            heap->events, sizeof(nanoev_event*) * capacity_new);
        if (!events_new)
            return NANOEV_ERROR_OUT_OF_MEMORY;

        heap->events = events_new;
        heap->capacity = capacity_new;
    }

    return NANOEV_SUCCESS;
}

static void min_heap_shift_up(timer_min_heap *heap, unsigned int hole_index, nanoev_timer *timer)
{
    unsigned int parent = (hole_index - 1) / 2;
    while (hole_index) {
        if (!__time_greater((nanoev_timer*)heap->events[parent], timer)) {
            break;
        }

        heap->events[hole_index] = heap->events[parent];
        ((nanoev_timer*)heap->events[hole_index])->min_heap_idx = hole_index;
        hole_index = parent;

        parent = (hole_index - 1) / 2;
    }

    heap->events[hole_index] = (nanoev_event*)timer;
    timer->min_heap_idx = hole_index;
}

static void min_heap_shift_down(timer_min_heap *heap, unsigned int hole_index, nanoev_timer *timer)
{
    unsigned int min_child = 2 * hole_index + 2;
    while (min_child <= heap->size) {
        if (min_child == heap->size) {
            min_child--;
        } else if (__time_greater((nanoev_timer*)heap->events[min_child],
                    (nanoev_timer*)heap->events[min_child - 1])
                   ) {
            min_child--;
        }

        if (!__time_greater(timer, (nanoev_timer*)heap->events[min_child])) {
            break;
        }

        heap->events[hole_index] = heap->events[min_child];
        ((nanoev_timer*)heap->events[hole_index])->min_heap_idx = hole_index;
        hole_index = min_child;

        min_child = 2 * hole_index + 2;
    }

    heap->events[hole_index] = (nanoev_event*)timer;
    timer->min_heap_idx = hole_index;
}


text:
<?php

namespace Drupal\Component\Utility;

/**
 * Performs color conversions.
 */
class Color {

  /**
   * Validates whether a hexadecimal color value is syntactically correct.
   *
   * @param $hex
   *   The hexadecimal string to validate. May contain a leading '#'. May use
   *   the shorthand notation (e.g., '123' for '112233').
   *
   * @return bool
   *   TRUE if $hex is valid or FALSE if it is not.
   */
  public static function validateHex($hex) {
    if (!is_string($hex)) {
      return FALSE;
    }
    return preg_match('/^[#]?([0-9a-fA-F]{3}){1,2}$/', $hex) === 1;
  }

  /**
   * Parses a hexadecimal color string like '#abc' or '#aabbcc'.
   *
   * @param string $hex
   *   The hexadecimal color string to parse.
   *
   * @return array
   *   An array containing the values for 'red', 'green', 'blue'.
   *
   * @throws \InvalidArgumentException
   */
  public static function hexToRgb($hex) {
    if (!self::validateHex($hex)) {
      throw new \InvalidArgumentException("'$hex' is not a valid hex value.");
    }

    // Ignore '#' prefixes.
    $hex = ltrim($hex, '#');

    // Convert shorthands like '#abc' to '#aabbcc'.
    if (strlen($hex) == 3) {
      $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
    }

    $c = hexdec($hex);

    return [
      'red' => $c >> 16 & 0xFF,
      'green' => $c >> 8 & 0xFF,
      'blue' => $c & 0xFF,
    ];
  }

  /**
   * Converts RGB color arrays and RGB strings in CSS notation to lowercase
   * simple colors like '#aabbcc'.
   *
   * @param array|string $input
   *   The value to convert. If the value is an array the first three elements
   *   will be used as the red, green and blue components. String values in CSS
   *   notation like '10, 20, 30' are also supported.
   *
   * @return string
   *   The lowercase simple color representation of the given color.
   */
  public static function rgbToHex($input) {
    // Remove named array keys if input comes from Color::hex2rgb().
    if (is_array($input)) {
      $rgb = array_values($input);
    }
    // Parse string input in CSS notation ('10, 20, 30').
    elseif (is_string($input)) {
      preg_match('/(\d+), ?(\d+), ?(\d+)/', $input, $rgb);
      array_shift($rgb);
    }

    $out = 0;
    foreach ($rgb as $k => $v) {
      $out |= $v << (16 - $k * 8);
    }

    return '#' . str_pad(dechex($out), 6, 0, STR_PAD_LEFT);
  }

  /**
   * Normalize the hex color length to 6 characters for comparison.
   *
   * @param string $hex
   *   The hex color to normalize.
   *
   * @return string
   *   The 6 character hex color.
   */
  public static function normalizeHexLength($hex) {
    // Ignore '#' prefixes.
    $hex = ltrim($hex, '#');

    if (strlen($hex) === 3) {
      $hex[5] = $hex[2];
      $hex[4] = $hex[2];
      $hex[3] = $hex[1];
      $hex[2] = $hex[1];
      $hex[1] = $hex[0];
    }

    return '#' . $hex;
  }

}


text:
;(function () {
    var $ = window.jQuery,
        $win = $(window),
        $doc = $(document);

    // Can I use inline svg ?
    var svgNS = 'http://www.w3.org/2000/svg',
        svgSupported = 'SVGAngle' in window && (function () {
                var supported,
                    el = document.createElement('div');
                el.innerHTML = '<svg/>';
                supported = (el.firstChild && el.firstChild.namespaceURI) === svgNS;
                el.innerHTML = '';
                return supported;
            })();

    // Can I use transition ?
    var transitionSupported = (function () {
        var style = document.createElement('div').style;
        return 'transition' in style ||
            'WebkitTransition' in style ||
            'MozTransition' in style ||
            'msTransition' in style ||
            'OTransition' in style;
    })();

    // Listen touch events in touch screen device, instead of mouse events in desktop.
    var touchSupported = 'ontouchstart' in window,
        mousedownEvent = 'mousedown' + ( touchSupported ? ' touchstart' : ''),
        mousemoveEvent = 'mousemove.clockpicker' + ( touchSupported ? ' touchmove.clockpicker' : ''),
        mouseupEvent = 'mouseup.clockpicker' + ( touchSupported ? ' touchend.clockpicker' : '');

    // Vibrate the device if supported
    var vibrate = navigator.vibrate ? 'vibrate' : navigator.hasOwnProperty('webkitVibrate') ? 'webkitVibrate' : null;

    function createSvgElement(name) {
        return document.createElementNS(svgNS, name);
    }

    function leadingZero(num) {
        return (num < 10 ? '0' : '') + num;
    }

    // Mousedown or touchstart
    function mousedown(e, space) {
        var self = this,
            options = this.options,
            plate = this.plate,
            offset = plate.offset(),
            isTouch = /^touch/.test(e.type),
            x0 = offset.left + dialRadius,
            y0 = offset.top + dialRadius,
            dx = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0,
            dy = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0,
            z = Math.sqrt(dx * dx + dy * dy),
            moved = false;

        // When clicking on minutes view space, check the mouse position
        if (space && (z < outerRadius - tickRadius || z > outerRadius + tickRadius))
            return;
        e.preventDefault();

        // Set cursor style of body after 200ms
        var movingTimer = setTimeout(function () {
            self.popover.addClass('clockpicker-moving');
        }, 200);

        // Place the canvas to top
        if (svgSupported)
            plate.append(self.canvas);

        var setHand = true;

        // Clock
        setHand = self.setHand(dx, dy, !space, true);

        // Mousemove on document
        $doc.off(mousemoveEvent).on(mousemoveEvent, function (e) {
            e.preventDefault();
            var isTouch = /^touch/.test(e.type),
                x = (isTouch ? e.originalEvent.touches[0] : e).pageX - x0,
                y = (isTouch ? e.originalEvent.touches[0] : e).pageY - y0;
            if (!moved && x === dx && y === dy)
            // Clicking in chrome on windows will trigger a mousemove event
                return;
            moved = true;
            setHand = self.setHand(x, y, false, true);
        });

        // Mouseup on document
        $doc.off(mouseupEvent).on(mouseupEvent, function (e) {
            $doc.off(mouseupEvent);
            e.preventDefault();
            var isTouch = /^touch/.test(e.type),
                x = (isTouch ? e.originalEvent.changedTouches[0] : e).pageX - x0,
                y = (isTouch ? e.originalEvent.changedTouches[0] : e).pageY - y0;
            if ((space || moved) && x === dx && y === dy) {
                setHand = self.setHand(x, y);
            }
            if (self.currentView === 'hours') {
                if (setHand) {
                    if (options.interval !== 60) { // skip
                        self.toggleView('minutes', duration / 2);
                    } else {
                        self.done();
                    }
                } else {
                    raiseCallback(self, 'invalidHour');
                }
            } else {
                if (options.autoclose && setHand) {
                    self.minutesView.addClass('clockpicker-dial-out');
                    setTimeout(function () {
                        self.done();
                    }, duration / 2);
                } else {
                    if (!setHand) {
                        raiseCallback(self, 'invalidMinute');
                    }
                }
            }
            plate.prepend(self.canvas);

            // Reset cursor style of body
            clearTimeout(movingTimer);
            self.popover.removeClass('clockpicker-moving');

            // Unbind mousemove event
            $doc.off(mousemoveEvent);
        });
    }
    // Get a unique id
    var idCounter = 0;

    function uniqueId(prefix) {
        var id = ++idCounter + '';
        return prefix ? prefix + id : id;
    }

    function raiseCallback(context, eventName) {
        var callbackFunction = context.options[eventName];
        if (callbackFunction && typeof callbackFunction === "function" && !context.attachedCallBack[eventName]) {
            callbackFunction.call(context.input,
                $.Event(eventName, {
                    currentTarget: context.input[0],
                    delegateTarget: context.input[0],
                    namespace: "clockpicker",
                    target: context.input[0]
                }),
                context);
        }
        context.input.trigger(eventName + '.clockpicker', context);
    }

    // Clock size
    var dialRadius = 135,
        outerRadius = 110,
        // innerRadius = 80 on 12 hour clock
        innerRadius = 80,
        tickRadius = 20,
        diameter = (dialRadius * 2),
        duration = transitionSupported ? 350 : 1;

    // Popover template
    var tpl = [
        '
',
            '
',
                '
',
                    '
',
                        '
',
                            '
',
                                '
',
                                    '
',
                                        '',
                                        ':',
                                        '',
                                    '
',
                                    '
',
                                    '

',
                                    '
',
                                '
',
                            '
',
                            '
',
                                '
',
                                '

',
                                '

',
                                '

',
                            '
',
                                '
',
                                '
',
                            '
',
                            '
',
                            '
',
                        '
',
                    '
',
                '
',
            '
',
        '
'
    ].join('');

    // Time prototype
    window.Time = function Time(time) {
        this.time = Time.parse(time || 'now');
    };
    Time.parse = function (time) {

        if (time instanceof Date) {
            return [time.getHours(), time.getMinutes()];
        }
        if (Array.isArray(time)) {
            return time;
        }
        if ($.isNumeric(time)) {
            var now = new Date();
            var h = now.getHours() + (+time);
            if (h > 23) {
                h = h % 24;
            }
            if (h < -23) {
                h = (h % 24);
            }
            if (h < 0) {
                h = 24 + h;
            }
            return [h, now.getMinutes()];
        }
        if (typeof time === 'string') {
            if (time === 'now') {
                return Time.now();
            }
            var a = /(\d{1,2}):(\d{1,2})(\s*)(AM|PM)?/gi.exec(time);
            if (a) {
                if (a[4]) {
                    if (a[4] === 'PM') {
                        a[1] = +a[1] + 12;
                    }
                }
                return [+a[1], +a[2]];
            }
            return [0, 0];
        }
        return 'Parse error';
    };
    Time.now = function() {
        var now = new Date();
        return [now.getHours(), now.getMinutes()];
    };
    Time.prototype.getHours = function () {
        return this.time[0];
    };
    Time.prototype.setHours = function (h) {
        this.time[0] = h;
        return this;
    };
    Time.prototype.isPm = function() {
        return this.time[0] > 11;
    };
    Time.prototype.getTwelveHours = function() {
        var value = this.time[0];
        if (this.twelvehour) {
            if (value > 12)
                value -= 12;
            if (value === 0)
                value = 12;
        }
        return value;
    };

    Time.prototype.getMinutes = function() {
        return this.time[1];
    };
    Time.prototype.setMinutes = function (m) {
        this.time[1] = m;
        return this;
    };
    Time.prototype.toString = function() {
        var time = this.time;
        if (this.twelvehour) {
            if (time[0] < 13) {
                return leadingZero(time[0]) +':'+ leadingZero(time[1]) +' AM';
            } else {
                return leadingZero((time[0] - 12)) +':'+ leadingZero(time[1]) +' PM';
            }
        } else {
            return leadingZero(time[0]) +':'+ leadingZero(time[1]);
        }
    };

    // ClockPicker
    function ClockPicker(element, options) {
        var popover = $(tpl),
            plate = popover.find('.clockpicker-plate'),
            hoursView = popover.find('.clockpicker-hours'),
            minutesView = popover.find('.clockpicker-minutes'),
            amPmBlock = popover.find('.clockpicker-am-pm-block'),
            isInput = element.prop('tagName') === 'INPUT',
            input = isInput ? element : element.find('input'),
            label = $("label[for=" + input.attr("id") + "]"),
            self = this;
        this.id = uniqueId('cp');
        this.element = element;
        this.options = options;
        this.isAppended = false;
        this.isShown = false;
        this.currentView = 'hours';
        this.isInput = isInput;
        this.input = input;
        this.label = label;
        this.popover = popover;
        this.plate = plate;
        this.hoursView = hoursView;
        this.minutesView = minutesView;
        this.$aHours = [];
        this.$aMinutes = [];
        this.amPmBlock = amPmBlock;
        this.spanHours = popover.find('.clockpicker-span-hours');
        this.spanMinutes = popover.find('.clockpicker-span-minutes');
        this.spanAmPm = popover.find('.clockpicker-span-am-pm');
        this.footer = popover.find('.picker__footer');
        this.amOrPm = "PM";
        this.attachedCallBack = [];

        this._parseTimeRestrictions();

        //force input to type ( disable type=time )
        input.attr('type', 'text');

        this.spanHours.click($.proxy(this.toggleView, this, 'hours'));
        this.spanMinutes.click($.proxy(this.toggleView, this, 'minutes'));

        var time = this.time = new Time(input.val());
        if (this.isValidTime(time.getHours(), time.getMinutes()) !== true) {
            this.input.val('');
        }

        // Show or toggle
        input.on('focus.clockpicker click.clockpicker', $.proxy(this.show, this));

        this.render('amPm');

        this.doneBtn = $('<button type="button" class="btn-flat clockpicker-button" tabindex="' + (options.twelvehour ? '3' : '1') + '">' + options.donetext + '</button>').click($.proxy(this.done, this)).appendTo(this.footer);

        if (options.darktheme) {
            popover.addClass('darktheme');
        }

        this.render('hours');

        this.render('minutes');

        // Clicking on minutes view space
        plate.on(mousedownEvent, function (e) {
            if ($(e.target).closest('.clockpicker-tick').length === 0)
                mousedown.call(self, e, true);
        });

        if (svgSupported) {
            // Draw clock hands and others
            var canvas = popover.find('.clockpicker-canvas').empty(),
                svg = createSvgElement('svg');
            svg.setAttribute('class', 'clockpicker-svg');
            svg.setAttribute('width', diameter);
            svg.setAttribute('height', diameter);
            var g = createSvgElement('g');
            g.setAttribute('transform', 'translate(' + dialRadius + ',' + dialRadius + ')');
            var bearing = createSvgElement('circle');
            bearing.setAttribute('class', 'clockpicker-canvas-bearing');
            bearing.setAttribute('cx', 0);
            bearing.setAttribute('cy', 0);
            bearing.setAttribute('r', 2);
            var hand = createSvgElement('line');
            hand.setAttribute('x1', 0);
            hand.setAttribute('y1', 0);
            var bg = createSvgElement('circle');
            bg.setAttribute('class', 'clockpicker-canvas-bg');
            bg.setAttribute('r', tickRadius);
            var fg = createSvgElement('circle');
            fg.setAttribute('class', 'clockpicker-canvas-fg');
            fg.setAttribute('r', 5);
            g.appendChild(hand);
            g.appendChild(bg);
            g.appendChild(fg);
            g.appendChild(bearing);
            svg.appendChild(g);
            canvas.append(svg);

            this.hand = hand;
            this.bg = bg;
            this.fg = fg;
            this.bearing = bearing;
            this.g = g;
            this.canvas = canvas;
        }

        raiseCallback(this, 'init');
    }

    // Default options
    ClockPicker.DEFAULTS = {
        'default': '',         // default time, 'now' or '13:14' e.g.
        fromnow: 0,            // set default time to * milliseconds from now (using with default = 'now')
        donetext: 'Done',      // done button text
        autoclose: false,      // auto close when minute is selected
        ampmclickable: false,  // set am/pm button on itself
        darktheme: false,			 // set to dark theme
        twelvehour: true,      // change to 12 hour AM/PM clock from 24 hour
        vibrate: true,          // vibrate the device when dragging clock hand
        dismissible: true,		// dismissable
        interval: false,		// set a time interval in minute / if 60, skip minute picker
        min: false,				// set the min time. ex: [13, 30] for 13:30
        max: false,				// set the max time. ex: [18, 30] for 18:30
        disable: false			// disable time value. ex: [[8,30],[12],[14,0],[null,15]] for 8:30, 12:**, 14:30 and **:15
    };

    ClockPicker.prototype.render = function(view) {
        var options = this.options,
            self = this,
            hoursView = this.hoursView,
            minutesView = this.minutesView;
        // Build ticks
        var tickTpl = $('

'),
            i, t, tick, radian, radius;

        if (view === 'hours') {
            hoursView.empty();
            this.$aHours = [];
            // Hours view
            for (i = 0; i < 24; i += 1) {
                tick = tickTpl.clone();
                t = i;

                this.$aHours.push(tick);

                if (this.isValidTime(i) !== true) {
                    tick.addClass('disabled');
                }

                radian = i / 6 * Math.PI;
                var inner = i > 0 && i < 13;
                if (options.twelvehour) {
                    radius = outerRadius;
                    if (i >= 12) {
                        t = i - 12;
                        tick.addClass('pm');
                    } else {
                        tick.addClass('am');
                    }
                    if (t === 0) {
                        t = 12;
                    }
                } else {
                    radius = inner ? innerRadius : outerRadius;
                    if (inner)
                        tick.css('font-size', '120%');
                }
                tick.css({
                    left: dialRadius + Math.sin(radian) * radius - tickRadius,
                    top: dialRadius - Math.cos(radian) * radius - tickRadius
                });
                tick.html(t === 0 ? '00' : t);
                hoursView.append(tick);
                tick.on(mousedownEvent, $.proxy(mousedown, this));
            }
        }
        if (view === 'minutes') {
            minutesView.empty();
            this.$aMinutes = [];
            // Minutes view
            for (i = 0; i < 60; i += 5) {
                tick = tickTpl.clone();

                this.$aMinutes.push(tick);

                if (this.isValidTime(null, i) !== true) {
                    tick.addClass('disabled interval');
                }
                // if (!options.)
                radian = i / 30 * Math.PI;
                tick.css({
                    left: dialRadius + Math.sin(radian) * outerRadius - tickRadius,
                    top: dialRadius - Math.cos(radian) * outerRadius - tickRadius
                });
                tick.css('font-size', '140%');
                tick.html(leadingZero(i));
                minutesView.append(tick);
                tick.on(mousedownEvent, $.proxy(mousedown, this));
            }
        }
        if (view === 'amPm') {
            this.amPmBlock.empty();
            this.spanAmPm.empty();
            // Setup for for 12 hour clock if option is selected
            if (options.twelvehour) {
                this.hoursView.addClass('twelvehour');
                if (!options.ampmclickable) {
                    $('<button type="button" class="btn-floating btn-flat clockpicker-button am-button" tabindex="1">' + "AM" + '</button>').on("click", function () {
                        self.setAMorPM("am");
                        self.amPmBlock.children('.pm-button').removeClass('active');
                        self.amPmBlock.children('.am-button').addClass('active');
                        self.spanAmPm.empty().append('AM');
                    }).appendTo(this.amPmBlock);
                    $('<button type="button" class="btn-floating btn-flat clockpicker-button pm-button" tabindex="2">' + "PM" + '</button>').on("click", function () {
                        self.setAMorPM("pm");
                        self.amPmBlock.children('.am-button').removeClass('active');
                        self.amPmBlock.children('.pm-button').addClass('active');
                        self.spanAmPm.empty().append('PM');
                    }).appendTo(this.amPmBlock);
                } else {
                    $('
AM
').on("click", function () {
                        self.spanAmPm.children('#click-am').addClass("text-primary");
                        self.spanAmPm.children('#click-pm').removeClass("text-primary");
                        self.amOrPm = "AM";
                    }).appendTo(this.spanAmPm);
                    $('
PM
').on("click", function () {
                        self.spanAmPm.children('#click-pm').addClass("text-primary");
                        self.spanAmPm.children('#click-am').removeClass("text-primary");
                        self.amOrPm = 'PM';
                    }).appendTo(this.spanAmPm);
                }
            } else {
                this.hoursView.removeClass('twelvehour');
            }
        }
    };

    ClockPicker.prototype._refreshAvailable = function(view) {
        var self = this;
        if (view === 'hours') {
            this.$aHours.forEach(function ($hour, index) {
                if (self.isValidTime(index) !== true) {
                    $hour.addClass('disabled');
                } else {
                    $hour.removeClass('disabled');
                }
            });
        }
        if (view === 'minutes') {
            this.$aMinutes.forEach(function ($minute, index) {
                if ($minute.hasClass('disabled interval')) {
                    return;
                }
                if (self.isValidTime(self.time.getHours(), (index * 5)) !== true) {
                    $minute.addClass('disabled');
                } else {
                    $minute.removeClass('disabled');
                }
            });
        }
    };
    // Show or hide popover
    ClockPicker.prototype.toggle = function () {
        this[this.isShown ? 'hide' : 'show']();
    };

    ClockPicker.prototype._parseTimeRestrictions = function() {
        if (this.options.min && !Array.isArray(this.options.min)) {
            this.options.min = Time.parse(this.options.min);
        }
        if (this.options.max&& !Array.isArray(this.options.max)) {
            this.options.max = Time.parse(this.options.max);
        }
        if (this.options.disable && Array.isArray(this.options.max)) {
            this.options.disable = this.options.disable.map(Time.parse);
        }
    };

    ClockPicker.prototype._optionRefresh = function(optName) {
        var optVal = this.options[optName];
        if (optName === 'donetext') {
            this.doneBtn.text(optVal);
        }
        if (optName === 'ampmclickable') {
            this.render('amPm');
            this.setAMorPM(this.time.isPm() ? 'pm' : 'am');
        }
        if (optName === 'darktheme') {
            if (optVal) {
                this.popover.addClass('darktheme');
            } else {
                this.popover.removeClass('darktheme');
            }
        }
        if (optName === 'twelvehour') {
            this.render('amPm');
            this.render('hours');
            this.setAMorPM(this.time.isPm() ? 'pm' : 'am');
        }
        var aRestrinction = ['min','max','disable','interval'];
        if (aRestrinction.indexOf(optName) !== -1) {
            this._parseTimeRestrictions();
            this._refreshAvailable('hours');
            if (this.currentView === 'minutes') {
                this._refreshAvailable('minutes');
            }
        }
        return this;
    };

    ClockPicker.prototype.set = function (optName, value) {
        var self = this;
        if ($.isPlainObject(optName)) {
            $.each(optName, function(k, v) {
                self.set(k, v);
            });
        } else {
            this.options[optName] = value;
            this._optionRefresh(optName);
        }
    };

    ClockPicker.prototype.options = function (oOptions) {
        var self = this;
        $.extend(this.options, oOptions);
        $.each(oOptions, function(optName) {
            self._optionRefresh(optName);
        });
    };

    // Set popover position
    ClockPicker.prototype.locate = function () {
        this.popover.show();
    };

    ClockPicker.prototype.isValidTime = function (h, m) {
        var self = this,
            min = this.options.min,
            max = this.options.max,
            disable = this.options.disable;
        function handleError(error) {
            self.error = error;
            return error;
        }
        // h only
        if (h !== null && m === undefined) {
            if (min && min[0] > h) {
                return handleError('Mimimum');
            }
            if (max && max[0] < h) {
                return handleError('Maximum');
            }
            if (disable && disable.some(function (v) {
                    return v[0] === h && v[1] === undefined;
                })) {
                return handleError('Disabled time');
            }
        }
        // m only
        if (m !== undefined) {
            if (this.options.interval && m % this.options.interval !== 0) {
                return handleError('Out of interval');
            }
            if (this.options.interval && m % this.options.interval !== 0) {
                return handleError('Out of interval');
            }
            if (disable && disable.some(function (v) {
                    return v[0] === null && v[1] === m;
                })) {
                return handleError('Disabled time');
            }
        }
        // h & m
        if (h !== null && m !== undefined) {
            if (min && (min[0] > h || min[0] === h&& min[1] > m)) {
                return handleError('Minimum');
            }
            if (max && (max[0] < h  || max[0] === h && max[1] < m)) {
                return handleError('Maximum');
            }
            if (disable && disable.some(function (v) {
                    return (v[0] === h && v[1] === m ||
                    v[0] === h && v[1] === undefined ||
                    v[0] === null && v[1] === m);
                })) {
                return handleError('Disabled time');
            }
        }

        return true;
    };

    ClockPicker.prototype.setAMorPM = function (option) {
        var active = option;
        if (option.toUpperCase() !== this.amOrPm) {
            var hours = 0;
            if (active === 'pm') {
                hours = this.time.getHours() + 12;
            } else {
                hours = this.time.getHours() - 12;
            }
            this.time.setHours(hours);
        }
        var inactive = (option === "pm" ? "am" : "pm");
        this.hoursView.addClass(active).removeClass(inactive);
        if (this.options.twelvehour) {
            if (this.currentView === 'minutes') {
                this._refreshAvailable(this.currentView);
            }
            this.amOrPm = active.toUpperCase();
            if (!this.options.ampmclickable) {
                this.amPmBlock.children('.' + inactive + '-button').removeClass('active');
                this.amPmBlock.children('.' + active + '-button').addClass('active');
                this.spanAmPm.empty().append(this.amOrPm);
            } else {
                this.spanAmPm.children('#click-' + active + '').addClass("text-primary");
                this.spanAmPm.children('#click-' + inactive + '').removeClass("text-primary");
            }
        }
    };

    // Show popover
    ClockPicker.prototype.show = function () {
        // Not show again
        if (this.isShown) {
            return;
        }
        raiseCallback(this, 'beforeShow');
        $(':input').each(function () {
            $(this).attr('tabindex', -1);
        });
        var self = this;
        // Initialize
        this.input.blur();
        this.popover.addClass('picker--opened');
        this.input.addClass('picker__input picker__input--active');
        $(document.body).css('overflow', 'hidden');
        if (!this.isAppended) {
            // Append popover to options.container
            if (this.options.hasOwnProperty('container'))
                this.popover.appendTo(this.options.container);
            else
                this.popover.insertAfter(this.input);
            this.setAMorPM("pm");
            // Reset position when resize
            $win.on('resize.clockpicker' + this.id, function () {
                if (self.isShown) {
                    self.locate();
                }
            });
            this.isAppended = true;
        }
        // Get the time
        var time = this.time = new Time(this.input.val() || this.options['default'] || 'now');

        if (this.isValidTime(null, time.getMinutes()) !== true) {
            time.setMinutes(0);
        }
        if (this.isValidTime(time.getHours(), time.getMinutes()) !== true) {
            this.input.val('');
            time.time = Time.now();
        }
        if (this.options.twelvehour) {
            time.twelvehour = true;
            if (time.isPm())
                this.setAMorPM("pm");
            else
                this.setAMorPM("am");
        }

        this.spanHours.html(leadingZero(time.getTwelveHours()));
        this.spanMinutes.html(leadingZero(time.getMinutes()));

        // Toggle to hours view
        this.toggleView('hours');
        // Set position
        this.locate();
        this.isShown = true;
        // Hide when clicking or tabbing on any element except the clock and input
        $doc.on('click.clockpicker.' + this.id + ' focusin.clockpicker.' + this.id, function (e) {
            var target = $(e.target);
            if (target.closest(self.popover.find('.picker__wrap')).length === 0 && target.closest(self.input).length === 0 && self.options.dismissible) {
                self.hide();
            }
        });
        // Hide when ESC is pressed
        $doc.on('keyup.clockpicker.' + this.id, function (e) {
            if (e.keyCode === 27)
                self.hide();
        });
        raiseCallback(this, 'afterShow');
    };
    // Hide popover
    ClockPicker.prototype.hide = function () {
        raiseCallback(this, 'beforeHide');
        this.input.removeClass('picker__input picker__input--active');
        this.popover.removeClass('picker--opened');
        $(document.body).css('overflow', 'visible');
        this.isShown = false;
        $(':input').each(function (index) {
            $(this).attr('tabindex', index + 1);
        });
        // Unbinding events on document
        $doc.off('click.clockpicker.' + this.id + ' focusin.clockpicker.' + this.id);
        $doc.off('keyup.clockpicker.' + this.id);
        this.popover.hide();
        raiseCallback(this, 'afterHide');
    };
    // Toggle to hours or minutes view
    ClockPicker.prototype.toggleView = function (view, delay) {
        var self = this;
        var raiseAfterHourSelect = false;
        if (view === 'minutes' && $(this.hoursView).css("visibility") === "visible") {
            raiseCallback(this, 'beforeHourSelect');
            self._refreshAvailable(view);
            raiseAfterHourSelect = true;
        }
        var isHours = view === 'hours',
            nextView = isHours ? this.hoursView : this.minutesView,
            hideView = isHours ? this.minutesView : this.hoursView;
        this.currentView = view;

        this.spanHours.toggleClass('text-primary', isHours);
        this.spanMinutes.toggleClass('text-primary', !isHours);

        // Let's make transitions
        hideView.addClass('clockpicker-dial-out');
        nextView.css('visibility', 'visible').removeClass('clockpicker-dial-out');

        // Reset clock hand
        this.resetClock(delay);
        // After transitions ended
        clearTimeout(this.toggleViewTimer);
        this.toggleViewTimer = setTimeout(function () {
            hideView.css('visibility', 'hidden');
        }, duration);

        if (raiseAfterHourSelect)
            raiseCallback(this, 'afterHourSelect');
    };

    // Reset clock hand
    ClockPicker.prototype.resetClock = function (delay) {
        var view = this.currentView,
            isHours = view === 'hours',
            value = (isHours ? this.time.getHours() : this.time.getMinutes()),
            unit = Math.PI / (isHours ? 6 : 30),
            radian = value * unit,
            radius = isHours && value > 0 && value < 13 ? innerRadius : outerRadius,
            x = Math.sin(radian) * radius,
            y = -Math.cos(radian) * radius,
            self = this;

        if (svgSupported && delay) {
            self.canvas.addClass('clockpicker-canvas-out');
            setTimeout(function () {
                self.canvas.removeClass('clockpicker-canvas-out');
                if (!self.setHand(x, y)) {
                    self.resetHand();
                }
            }, delay);
        } else {
            if (!this.setHand(x, y)) {
                this.resetHand();
            }
        }
    };

    ClockPicker.prototype.resetHand = function () {
        this.hand.setAttribute('x2', 0);
        this.hand.setAttribute('y2', 0);
        this.bg.setAttribute('cx', 0);
        this.bg.setAttribute('cy', 0);
        this.fg.setAttribute('cx', 0);
        this.fg.setAttribute('cy', 0);
    };

    // Set clock hand to (x, y)
    ClockPicker.prototype.setHand = function (x, y, roundBy5, dragging) {
        var radian = Math.atan2(x, -y),
            isHours = this.currentView === 'hours',
            unit = Math.PI / (isHours || roundBy5 ? 6 : 30),
            z = Math.sqrt(x * x + y * y),
            options = this.options,
            inner = isHours && z < (outerRadius + innerRadius) / 2,
            radius = inner ? innerRadius : outerRadius,
            vText = '',
            value;

        if (options.twelvehour)
            radius = outerRadius;

        // Radian should in range [0, 2PI]
        if (radian < 0)
            radian = Math.PI * 2 + radian;

        // Get the round value
        value = Math.round(radian / unit);

        // Get the round radian
        radian = value * unit;

        // Correct the hours or minutes
        // if (options.twelvehour) {
        //     if (isHours) {
        //         if (value === 0)
        //             value = 12;
        //     } else {
        //         if (roundBy5)
        //             value *= 5;
        //         if (value === 60)
        //             value = 0;
        //     }
        // } else {
        if (isHours) {
            if (options.twelvehour) {
                if (this.amOrPm === "PM") {
                    value += 12;
                }
                if (value === 12 && this.amOrPm === "AM") {
                    value = 0;
                }
                if (value === 24)
                    value = 12;
            } else {
                if (value === 12)
                    value = 0;
                value = inner ? (value === 0 ? 12 : value) : value === 0 ? 0 : value + 12;
            }

            if (this.isValidTime(value) !== true) {
                return false;
            }
            this.time.setHours(value);
            vText = this.time.getTwelveHours();
        } else {
            if (roundBy5)
                value *= 5;
            if (value === 60)
                value = 0;

            if (this.isValidTime(this.time.getHours(), value) !== true) {
                return false;
            }
            this.time.setMinutes(value);
            vText = value;
        }
        // }
        if (isHours)
            this.fg.setAttribute('class', 'clockpicker-canvas-fg');
        else {
            if (value % 5 === 0)
                this.fg.setAttribute('class', 'clockpicker-canvas-fg');
            else
                this.fg.setAttribute('class', 'clockpicker-canvas-fg active');
        }

        // Once hours or minutes changed, vibrate the device
        if (this[this.currentView] !== value)
            if (vibrate && this.options.vibrate)
            // Do not vibrate too frequently
                if (!this.vibrateTimer) {
                    navigator[vibrate](10);
                    this.vibrateTimer = setTimeout($.proxy(function () {
                        this.vibrateTimer = null;
                    }, this), 100);
                }

        this[this.currentView] = value;
        this[isHours ? 'spanHours' : 'spanMinutes'].html(leadingZero(vText));

        // If svg is not supported, just add an active class to the tick
        if (!svgSupported) {
            this[isHours ? 'hoursView' : 'minutesView'].find('.clockpicker-tick').each(function () {
                var tick = $(this);
                tick.toggleClass('active', value === +tick.html());
            });
            return true;
        }

        // Place clock hand at the top when dragging
        if (dragging || (!isHours && value % 5)) {
            this.g.insertBefore(this.hand, this.bearing);
            this.g.insertBefore(this.bg, this.fg);
            this.bg.setAttribute('class', 'clockpicker-canvas-bg clockpicker-canvas-bg-trans');
        } else {
            // Or place it at the bottom
            this.g.insertBefore(this.hand, this.bg);
            this.g.insertBefore(this.fg, this.bg);
            this.bg.setAttribute('class', 'clockpicker-canvas-bg');
        }

        // Set clock hand and others' position
        var cx1 = Math.sin(radian) * (radius - tickRadius),
            cy1 = -Math.cos(radian) * (radius - tickRadius),
            cx2 = Math.sin(radian) * radius,
            cy2 = -Math.cos(radian) * radius;
        this.hand.setAttribute('x2', cx1);
        this.hand.setAttribute('y2', cy1);
        this.bg.setAttribute('cx', cx2);
        this.bg.setAttribute('cy', cy2);
        this.fg.setAttribute('cx', cx2);
        this.fg.setAttribute('cy', cy2);
        return true;
    };

    // Hours and minutes are selected
    ClockPicker.prototype.done = function () {
        var time = this.time;
        raiseCallback(this, 'beforeDone');
        if (this.isValidTime(time.getHours(), time.getMinutes()) !== true) {
            raiseCallback(this,'invalidTime');
            return;
        }
        this.hide();
        this.label.addClass('active');

        var last = this.input.val(),
            value = time.toString();

        this.input.val(value);
        if (value !== last) {
            this.input.triggerHandler('change');
            if (!this.isInput)
                this.element.trigger('change');
        }

        if (this.options.autoclose)
            this.input.trigger('blur');

        raiseCallback(this, 'afterDone');
    };

    // Remove clockpicker from input
    ClockPicker.prototype.remove = function () {
        this.element.removeData('clockpicker');
        this.input.off('focus.clockpicker click.clockpicker');
        if (this.isShown)
            this.hide();
        if (this.isAppended) {
            $win.off('resize.clockpicker' + this.id);
            this.popover.remove();
        }
    };

    // Extends $.fn.clockpicker
    $.fn.pickatime = function (option) {
        var args = Array.prototype.slice.call(arguments, 1);

        var componentData = this.data( 'clockpicker' );

        if ( componentData && (option === 'picker' || option === undefined)) {
            return componentData
        }

        var options;
        return this.each(function () {
            var $this = $(this),
                data = $this.data('clockpicker');
            if (!data) {
                options = $.extend({}, ClockPicker.DEFAULTS, $this.data(), typeof option === 'object' && option);
                $this.data('clockpicker', new ClockPicker($this, options));
            } else {
                if ($.isPlainObject(option)) { // case recall with new parameters
                    data.set(option);
                }
                // Manual operatsions. show, hide, remove, e.g.
                if (typeof data[option] === 'function')
                    data[option].apply(data, args);
            }
        });
    };
    $.fn.pickatime.defaults = ClockPicker.DEFAULTS;
}());


text:
package org.opensextant.xtext.collectors;

public interface Collector {

    public final static char PATH_SEP = '/';

    /**
     *
     * @return name of the collector
     */
    public String getName();

    /**
     * Invokes collection.
     */
    public void collect() throws Exception;
}


text:
package ANNFileDetect;

/**
 *
 * @author ragnar0k@fabytes.com
 */
import java.io.File;
import javax.swing.filechooser.FileFilter;

class FilterClass extends FileFilter {
    String[] ext;
    String description;
    public FilterClass(String description, String ext) {
        this(description, new String[] { ext });
    }

    public FilterClass(String description, String[] ext) {
        this.ext = (String[]) ext.clone();
        this.description = description;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public boolean accept(File file) {
        if (file.isDirectory())
                return true;
        else {
            String path = file.getAbsolutePath().toLowerCase();
              for (int i = 0, n = ext.length; i < n; i++) {
                     String extension = ext[i];
                     if ((path.endsWith(extension) && (path.charAt(path.length() - extension.length() - 1)) == '.'))
                          return true;
              }
        }
        return false;
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.AppCompatTextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/text_view"
    android:layout_width="wrap_content"
    android:layout_height="36dp"
    android:textColor="@android:color/white"
    android:background="#7B68EE"
    android:gravity="center"
    android:layout_gravity="center"
    android:paddingLeft="@dimen/margin_three_quarters"
    android:paddingRight="@dimen/margin_three_quarters"/>


text:
/**
 * This class is generated by jOOQ
 */
package org.ng200.openolympus.jooq.routines;

import java.math.BigDecimal;

import javax.annotation.Generated;

import org.jooq.Field;
import org.jooq.Parameter;
import org.jooq.impl.AbstractRoutine;
import org.ng200.openolympus.jooq.Public;

/**
 * This class is generated by jOOQ.
 */
@Generated(
	value = {
		"http://www.jooq.org",
		"jOOQ version:3.7.3"
	},
	comments = "This class is generated by jOOQ"
)
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class GetUserTotalScoreInContest extends AbstractRoutine<BigDecimal> {

	private static final long serialVersionUID = 910745155;

	/**
	 * The parameter public.get_user_total_score_in_contest.RETURN_VALUE.
	 */
	public static final Parameter<BigDecimal> RETURN_VALUE = createParameter("RETURN_VALUE", org.jooq.impl.SQLDataType.NUMERIC, false);

	/**
	 * The parameter public.get_user_total_score_in_contest.contest_id_p.
	 */
	public static final Parameter<Integer> CONTEST_ID_P = createParameter("contest_id_p", org.jooq.impl.SQLDataType.INTEGER, false);

	/**
	 * The parameter public.get_user_total_score_in_contest.user_id_p.
	 */
	public static final Parameter<Long> USER_ID_P = createParameter("user_id_p", org.jooq.impl.SQLDataType.BIGINT, false);

	/**
	 * Create a new routine call instance
	 */
	public GetUserTotalScoreInContest() {
		super("get_user_total_score_in_contest", Public.PUBLIC, org.jooq.impl.SQLDataType.NUMERIC);

		setReturnParameter(RETURN_VALUE);
		addInParameter(CONTEST_ID_P);
		addInParameter(USER_ID_P);
	}

	/**
	 * Set the contest_id_p parameter IN value to the routine
	 */
	public void setContestIdP(Integer value) {
		setValue(CONTEST_ID_P, value);
	}

	/**
	 * Set the contest_id_p parameter to the function to be used with a {@link org.jooq.Select} statement
	 */
	public GetUserTotalScoreInContest setContestIdP(Field<Integer> field) {
		setField(CONTEST_ID_P, field);
		return this;
	}

	/**
	 * Set the user_id_p parameter IN value to the routine
	 */
	public void setUserIdP(Long value) {
		setValue(USER_ID_P, value);
	}

	/**
	 * Set the user_id_p parameter to the function to be used with a {@link org.jooq.Select} statement
	 */
	public GetUserTotalScoreInContest setUserIdP(Field<Long> field) {
		setField(USER_ID_P, field);
		return this;
	}
}


text:
define([
    'jquery',
    'underscore'
], function($, _) {
    'use strict';

    return function() {
        $(function() {
            function prepareTinymce(textareas) {
                if (textareas.length > 0) {
                    $(textareas).each(function(i, el) {
                        if ($(el).tinymce) {
                            var settings;
                            var tinymceInstance = $(el).tinymce();
                            if (tinymceInstance) {
                                if ($(el).prop('disabled')) {
                                    settings = tinymceInstance.editorManager.activeEditor.settings;
                                    settings.readonly = true;
                                    tinymceInstance.editorManager.activeEditor.remove();
                                    $(el).tinymce(settings);
                                } else {
                                    settings = tinymceInstance.editorManager.activeEditor.settings;
                                    settings.readonly = false;
                                    tinymceInstance.editorManager.activeEditor.remove();
                                    $(el).tinymce(settings);
                                }
                            }
                        }
                    });
                }
            }
            prepareTinymce($.find('textarea'));
            var value;
            var valueEls;
            var checkboxEls = $('.parent-scope-checkbox input');
            checkboxEls.on('change', function() {
                value = $(this).is(':checked');
                valueEls = $(this).parents('.controls').find(':input').not(checkboxEls);
                valueEls.each(function(i, el) {
                    $(el)
                        .prop('disabled', value)
                        .data('disabled', value)
                        .trigger(value ? 'disable' : 'enable');

                    if (!_.isUndefined($.uniform) && _.contains($.uniform.elements, el)) {
                        $(el).uniform('update');
                    }
                });

                prepareTinymce($(this).parents('.controls').find('textarea'));
            });
        });
    };
});


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <title>XUnit2Params - FAKE - F# Make</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Steffen Forkmann, Mauricio Scheffer, Colin Bull">

    <link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap-combined.min.css" rel="stylesheet">

    <link type="text/css" rel="stylesheet" href="http://fsharp.github.io/FAKE/content/style.css" />

fsharp.org

github page

FAKE - F# Make

XUnit2Params

The xUnit2 parameter type.

Record Fields

Record Field	Description

            ErrorLevel

            Signature: TestRunnerErrorLevel

Test runner error level.

            ExcludeTraits

            Signature: (string * string) list

List of traits to exclude.

            ForceAppVeyor

            Signature: bool

Forces AppVeyor CI mode (normally auto-detected).

            ForceTeamCity

            Signature: bool

Forces TeamCity mode (normally auto-detected).

            HtmlOutputPath

            Signature: string option

The output path of the xUnit HTML report.

            IncludeTraits

            Signature: (string * string) list

List of traits to include.

            MaxThreads

            Signature: CollectionConcurrencyMode

The xUnit thread limiting strategy.

            Parallel

            Signature: ParallelMode

The xUnit parallelization mode.

            ShadowCopy

            Signature: bool

Run xUnit with shadow copy enabled.

            Silent

            Signature: bool

Run xUnit without reporting test progress.

            TimeOut

            Signature: TimeSpan

Maximum time to allow xUnit to run before being killed.

            ToolPath

            Signature: string

The path to the xUnit console runner: xunit.console.exe

            Wait

            Signature: bool

Waits for input after completion.

            WorkingDir

            Signature: string option

The working directory for running the xunit console runner.

            XmlOutputPath

            Signature: string option

The output path of the xUnit XML report.

            XmlV1OutputPath

            Signature: string option

The output path of the xUnit XML report (in the xUnit v1 style).

FAKE - F# Make

Home page

Get FAKE - F# Make via NuGet

Source Code on GitHub

License (Apache 2)

Release Notes

Contributing to FAKE - F# Make

Who is using FAKE?

Ask a question

Tutorials

Getting started

NuGet package restore

Using FxCop in a build

Generating AssemblyInfo

Create NuGet packages

Running specific targets

Running FAKE from command line

Running targets in parallel

Using the F# compiler from FAKE

Creating custom tasks

TeamCity integration

Running canopy tests

Octopus Deploy

TypeScript support

Azure WebJobs support

Azure Cloud Services support

Android publisher

File Watcher

Fake.Deploy

Reference

API Reference


text:
source $(npm root -g)/pr-bumper/.travis/is-bump-commit.sh

if isBumpCommit
then
  echo "Skipping pr-bumper coverage publish step for version bump commit"
  exit 0
fi

if [[ ! "${PUBLISH_NODE_VERSION:-8.1.2}" =~ ^$TRAVIS_NODE_VERSION ]]
then
  echo "Skipping pr-bumper coverage publish step for TRAVIS_NODE_VERSION [${TRAVIS_NODE_VERSION}]"
  exit 0
fi

if [ "$EMBER_TRY_SCENARIO" != "ember-default" ]
then
  echo "Skipping pr-bumper coverage publish step for EMBER_TRY_SCENARIO [${EMBER_TRY_SCENARIO}]"
  exit 0
fi

cat coverage/lcov.info | coveralls


text:
import { importAll } from '~/utils'
import { version } from '~/../package.json'

const componentsContext = require.context('~/../src/components/', true, /package.json/)
export const components = importAll(componentsContext)

const directivesContext = require.context('~/../src/directives/', true, /package.json/)
export const directives = importAll(directivesContext)

const referenceContext = require.context('~/markdown/reference', true, /meta.json/)
export const reference = importAll(referenceContext)

const miscContext = require.context('~/markdown/misc', true, /meta.json/)
export const misc = importAll(miscContext)

export const nav = [
  {
    title: 'Getting started',
    base: ''
  },
  {
    title: 'Components',
    base: 'components/',
    pages: components
  },
  {
    title: 'Directives',
    base: 'directives/',
    pages: directives
  },
  {
    title: 'Reference',
    base: 'reference/',
    pages: reference
  },
  {
    title: 'Misc',
    base: 'misc/',
    pages: misc
  }
]

export {
  version
}


text:
sap.ui.define([
	"./library",
	"sap/ui/core/Control",
	"sap/ui/core/IconPool",
	"sap/ui/core/ResizeHandler",
	"sap/m/Image",
	"./NumericContentRenderer",
	"sap/ui/events/KeyCodes",
	"sap/base/util/deepEqual",
	"sap/ui/core/Configuration"
], function (library, Control, IconPool, ResizeHandler, Image, NumericContentRenderer, KeyCodes, deepEqual, Configuration) {
	"use strict";

	var LANG_MAP = { // keys are compared in lowercase
		"ar": 4,
		"ar_eg": 4,
		"ar_sa": 4,
		"bg": 4,
		"ca": 6,
		"cs": 4,
		"da": 4,
		"de": 8,
		"de-de": 8,
		"de_at": 8,
		"de_ch": 8,
		"el": 4,
		"el_cy": 4,
		"en": 4,
		"en_au": 4,
		"en_gb": 4,
		"en_hk": 4,
		"en_ie": 4,
		"en_in": 4,
		"en_nz": 4,
		"en_pg": 4,
		"en_sg": 4,
		"en_us": 4,
		"en_za": 4,
		"es": 6,
		"es_ar": 4,
		"es_bo": 4,
		"es_cl": 4,
		"es_co": 4,
		"es_mx": 6,
		"es_pe": 4,
		"es_uy": 4,
		"es_ve": 4,
		"et": 4,
		"fa": 4,
		"fi": 4,
		"fr": 4,
		"fr_be": 4,
		"fr_ca": 4,
		"fr_ch": 4,
		"fr_lu": 4,
		"he": 4,
		"hi": 4,
		"hr": 4,
		"hu": 4,
		"id": 4,
		"it": 8,
		"it_ch": 8,
		"ja": 6,
		"kk": 4,
		"ko": 6,
		"lt": 4,
		"lv": 4,
		"ms": 4,
		"nb": 4,
		"nl": 4,
		"nl_be": 4,
		"pl": 4,
		"pt": 4,
		"pt_pt": 4,
		"ro": 4,
		"ru": 4,
		"ru_ua": 4,
		"sk": 4,
		"sl": 4,
		"sr": 4,
		"sv": 4,
		"th": 4,
		"tr": 4,
		"uk": 4,
		"vi": 4,
		"zh_cn": 6,
		"zh_hk": 6,
		"zh_sg": 6,
		"zh_tw": 6
	};

	var DeviationIndicator = library.DeviationIndicator,
		ValueColor = library.ValueColor;

	/**
	 * Constructor for a new sap.m.GenericTile control.
	 *
	 * @param {string} [sId] id for the new control, generated automatically if no id is given
	 * @param {object} [mSettings] initial settings for the new control
	 *
	 * @class Shows numeric values used for example in tiles colored according to their meaning and displays deviations.
	 * @extends sap.ui.core.Control
	 *
	 * @author SAP SE
	 * @version ${version}
	 * @since 1.34
	 *
	 * @public
	 * @alias sap.m.NumericContent
	 */
	var NumericContent = Control.extend("sap.m.NumericContent", /** @lends sap.m.NumericContent.prototype */ {
		metadata: {

			library: "sap.m",
			properties: {

				/**
				 * If set to true, the change of the value will be animated.
				 */
				"animateTextChange": { type: "boolean", group: "Behavior", defaultValue: true },

				/**
				 * If set to true, the value parameter contains a numeric value and scale. If set to false (default), the value parameter contains a numeric value only.
				 */
				"formatterValue": { type: "boolean", group: "Data", defaultValue: false },

				/**
				 * The icon to be displayed as a graphical element within the control. This can be an image or an icon from the icon font.
				 */
				"icon": { type: "sap.ui.core.URI", group: "Appearance", defaultValue: null },

				/**
				 * Description of an icon that is used in the tooltip.
				 */
				"iconDescription": { type: "string", group: "Accessibility", defaultValue: null },

				/**
				 * The indicator arrow that shows value deviation.
				 */
				"indicator": { type: "sap.m.DeviationIndicator", group: "Appearance", defaultValue: "None" },

				/**
				 * If set to true, the omitted value property is set to 0.
				 */
				"nullifyValue": { type: "boolean", group: "Behavior", defaultValue: true },

				/**
				 * The scaling prefix. Financial characters can be used for currencies and counters. The SI prefixes can be used for units. If the scaling prefix contains more than three characters, only the first three characters are displayed.
				 */
				"scale": { type: "string", group: "Appearance", defaultValue: null },

				/**
				 * Updates the size of the control. If not set, then the default size is applied based on the device tile.
				 * @deprecated Since version 1.38.0. The NumericContent control has now a fixed size, depending on the used media (desktop, tablet or phone).
				 */
				"size": { type: "sap.m.Size", group: "Appearance", defaultValue: "Auto", deprecated: true },

				/**
				 * The number of characters of the value property to display.
				 *
				 * Note If adaptiveFontSize is set to true the default value of this property will vary between languages.
				 * If adaptiveFontSize is set to false the default value of this property is 4.
				 */
				"truncateValueTo": { type: "int", group: "Appearance" },

				/**
				 * The actual value.
				 */
				"value": { type: "string", group: "Data", defaultValue: null },

				/**
				 * The semantic color of the value.
				 */
				"valueColor": { type: "sap.m.ValueColor", group: "Appearance", defaultValue: "Neutral" },

				/**
				 * The width of the control. If it is not set, the size of the control is defined by the 'size' property.
				 */
				"width": { type: "sap.ui.core.CSSSize", group: "Appearance", defaultValue: null },

				/**
				 * If the value is set to false, the content is adjusted to the whole size of the control.
				 */
				"withMargin": { type: "boolean", group: "Appearance", defaultValue: true },

				/**
				 * Indicates the load status.
				 */
				"state": { type: "sap.m.LoadState", group: "Behavior", defaultValue: "Loaded" },

				/**
				 * If set to its default value true this property applies the appropriate font style class based on the language. When set to false the font size will always be large
				 *
				 * @experimental As of version 1.73 Disclaimer: this property is in a beta state - incompatible API changes may be done before its official public release. Use at your own discretion.
				 * @since 1.73
				 */
				"adaptiveFontSize": { type: "boolean", group: "Appearance", defaultValue: true }

			},
			events: {
				/**
				 * The event is fired when the user chooses the numeric content.
				 */
				"press": {}
			}
		},

		renderer: NumericContentRenderer
	});

	/* --- Lifecycle methods --- */

	NumericContent.prototype.init = function () {
		this._rb = sap.ui.getCore().getLibraryResourceBundle("sap.m");
		this.setTooltip("{AltText}");
		sap.ui.getCore().attachInit(this._registerResizeHandler.bind(this));
	};

	NumericContent.prototype._getParentTile = function () {
		var oParent = this.getParent();
		while (oParent) {
			if (oParent.isA("sap.m.GenericTile")) {
				return oParent;
			}

			oParent = oParent.getParent();
		}

		return null;
	};

	NumericContent.prototype._getMaxDigitsData = function () {
		var sFontClass = null,
			sLang = Configuration.getLanguage().toLowerCase(),
			iMaxLength = LANG_MAP[sLang] || 4;

		if (this.getAdaptiveFontSize()) {
			switch (iMaxLength) {
				case 6:
					sFontClass = "sapMNCMediumFontSize";
					break;
				case 8:
					sFontClass = "sapMNCSmallFontSize";
					break;
				default:
					sFontClass = "sapMNCLargeFontSize";
					break;
			}
		} else {
			sFontClass = "sapMNCLargeFontSize";
			iMaxLength = 4; // the default value if size is not adaptive
		}

		return {
			fontClass: sFontClass,
			maxLength: iMaxLength
		};
	};

	/**
	 * Registers resize handler.
	 * @private
	 */
	NumericContent.prototype._registerResizeHandler = function () {
		ResizeHandler.register(this, this.invalidate.bind(this));
	};

	NumericContent.prototype.onBeforeRendering = function () {
		this.$().off("mouseenter");
		this.$().off("mouseleave");

		this._iMaxLength = null;
	};

	NumericContent.prototype.onAfterRendering = function () {
		this.$().on("mouseenter", this._addTooltip.bind(this));
		this.$().on("mouseleave", this._removeTooltip.bind(this));

		if (!sap.ui.getCore().isThemeApplied()) {
			sap.ui.getCore().attachThemeChanged(this._checkIfIconFits, this);
		} else {
			this._checkIfIconFits();
		}
	};

	/**
	 * Sets the control's title attribute in order to show the tooltip.
	 * @private
	 */
	NumericContent.prototype._addTooltip = function () {
		this.$().attr("title", this.getTooltip_AsString());
	};

	/**
	 * Shows/hides icon depending if it fits or not.
	 * @private
	 */
	NumericContent.prototype._checkIfIconFits = function () {
		//first check if parent tile is going to resize in the future so resize it now for our calculation
		var oParentTile = this._getParentTile();
		if (oParentTile && (oParentTile.isA("sap.m.GenericTile") || oParentTile.isA("sap.m.SlideTile"))) {
			oParentTile._setupResizeClassHandler();
		}

		var oIcon = this.getDomRef("icon-image");
		if (oIcon) {
			var oValue = this.getDomRef("value-inner"),
				oIndScale = this.getDomRef("indicator"),
				oWrapper = this.getDomRef("value");

			var fIconWidth = oIcon ? oIcon.getBoundingClientRect().width : 0,
				fValueWidth = oValue ? oValue.getBoundingClientRect().width : 0,
				fIndScaleWidth = oIndScale ? oIndScale.getBoundingClientRect().width : 0,
				fWrapperWidth = oWrapper.getBoundingClientRect().width;

			oIcon.style.display = (fIconWidth + fValueWidth + fIndScaleWidth) > fWrapperWidth ? "none" : "";
		}
	};

	/**
	 * Removes the control's tooltip in order to prevent screen readers from reading it.
	 * @private
	 */
	NumericContent.prototype._removeTooltip = function () {
		this.$().attr("title", null);
	};

	NumericContent.prototype.exit = function () {
		if (this._oIcon) {
			this._oIcon.destroy();
		}
		if (this._oIndicatorIcon) {
			this._oIndicatorIcon.destroy();
		}
	};

	/* --- Getters and Setters --- */

	/**
	 * Returns the AltText
	 *
	 * @returns {string} The alternative text
	 */
	NumericContent.prototype.getAltText = function () {
		var sValue = this.getValue();
		var sScale = this.getScale();
		var sEmptyValue;
		var sAltText = "";
		if (this.getNullifyValue()) {
			sEmptyValue = "0";
		} else {
			sEmptyValue = "";
		}
		if (this.getIconDescription()) {
			sAltText = sAltText.concat(this.getIconDescription());
			sAltText = sAltText.concat("\n");
		}
		if (sValue) {
			sAltText = sAltText.concat(sValue + sScale);
		} else {
			sAltText = sAltText.concat(sEmptyValue);
		}
		if (this.getIndicator() && this.getIndicator() !== DeviationIndicator.None) {
			sAltText = sAltText.concat("\n");
			sAltText = sAltText.concat(this._rb.getText(("NUMERICCONTENT_DEVIATION_" + this.getIndicator()).toUpperCase()));
		}
		if (this.getValueColor() !== ValueColor.None) {
			var sMeaning = this._rb.getText(("SEMANTIC_COLOR_" + this.getValueColor()).toUpperCase());
			sAltText = sAltText.concat("\n");
			sAltText = sAltText.concat(sMeaning);
		}
		return sAltText;
	};

	NumericContent.prototype.getTooltip_AsString = function () { //eslint-disable-line
		var oTooltip = this.getTooltip();
		var sTooltip = this.getAltText();
		if (typeof oTooltip === "string" || oTooltip instanceof String) {
			// TODO Nov. 2015: needs to be checked with ACC. Issue will be addresses via BLI.
			sTooltip = oTooltip.split("{AltText}").join(sTooltip).split("((AltText))").join(sTooltip);
			return sTooltip;
		}
		if (oTooltip) {
			return oTooltip;
		} else {
			return "";
		}
	};

	NumericContent.prototype.setIcon = function (uri) {
		var bValueChanged = !deepEqual(this.getIcon(), uri);
		if (bValueChanged) {
			if (this._oIcon) {
				this._oIcon.destroy();
				this._oIcon = undefined;
			}
			if (uri) {
				this._oIcon = IconPool.createControlByURI({
					id: this.getId() + "-icon-image",
					src: uri
				}, Image);
			}
		}
		this._setPointerOnIcon();
		return this.setProperty("icon", uri);
	};

	NumericContent.prototype.setIndicator = function (sDeviationIndicator) {
		var sSrc = "sap-icon://" + (sDeviationIndicator ? sDeviationIndicator.toLowerCase() : "none");
		if (this._oIndicatorIcon) {
			this._oIndicatorIcon.setSrc(sSrc);
		} else {
			this._oIndicatorIcon = IconPool.createControlByURI({
				id: this.getId() + "-icon-indicator",
				size: "0.875rem",
				src: sSrc
			}, Image);
			this._oIndicatorIcon.addStyleClass("sapMNCIndIcon");
		}
		return this.setProperty("indicator", sDeviationIndicator);
	};

	/**
	 * Sets CSS class 'sapMPointer' for the internal Icon if needed.
	 * @private
	 */
	NumericContent.prototype._setPointerOnIcon = function () {
		if (this._oIcon && this.hasListeners("press")) {
			this._oIcon.addStyleClass("sapMPointer");
		} else if (this._oIcon && this._oIcon.hasStyleClass("sapMPointer")) {
			this._oIcon.removeStyleClass("sapMPointer");
		}
	};

	/* --- Event Handling --- */

	/**
	 * Handler for tap event
	 *
	 * @param {sap.ui.base.Event} oEvent which was fired
	 */
	NumericContent.prototype.ontap = function (oEvent) {
		this.$().trigger("focus");
		this.firePress();
		oEvent.preventDefault();
	};

	/**
	 * Handler for keyup event
	 *
	 * @param {sap.ui.base.Event} oEvent which was fired
	 */
	NumericContent.prototype.onkeyup = function (oEvent) {
		if (oEvent.which === KeyCodes.ENTER || oEvent.which === KeyCodes.SPACE) {
			this.firePress();
			oEvent.preventDefault();
		}
	};

	/**
	 * Handler for keydown event
	 *
	 * @param {sap.ui.base.Event} oEvent which was fired
	 */
	NumericContent.prototype.onkeydown = function (oEvent) {
		if (oEvent.which === KeyCodes.SPACE) {
			oEvent.preventDefault();
		}
	};

	NumericContent.prototype.attachEvent = function (eventId, data, functionToCall, listener) {
		Control.prototype.attachEvent.call(this, eventId, data, functionToCall, listener);
		if (this.hasListeners("press")) {
			this.$().attr("tabindex", 0).addClass("sapMPointer");
			this._setPointerOnIcon();
		}
		return this;
	};

	NumericContent.prototype.detachEvent = function (eventId, functionToCall, listener) {
		Control.prototype.detachEvent.call(this, eventId, functionToCall, listener);
		if (!this.hasListeners("press")) {
			this.$().removeAttr("tabindex").removeClass("sapMPointer");
			this._setPointerOnIcon();
		}
		return this;
	};

	/* --- Helpers --- */

	/**
	 * Parses the formatted value
	 *
	 * @private
	 * @param {string} sValue - With scale and value
	 * @returns {Object} The scale and formatted value
	 */
	NumericContent.prototype._parseFormattedValue = function (sValue) {

		// remove the invisible unicode character LTR and RTL mark before processing the regular expression.
		var sTrimmedValue = sValue.replace(String.fromCharCode(8206), "").replace(String.fromCharCode(8207), "");

		// extract value and scale information from string using regex.
		var aValueMatches = sTrimmedValue.match(/([+-., \d]*)/g) || [];
		var aScaleMatches = sTrimmedValue.match(/[^+-., \d]/g) || [];

		return {
			value: aValueMatches.reduce(function (acc, curVal){
						return acc + curVal;
					}, '').trim(),
			scale: aScaleMatches.reduce(function (acc, curVal){
						return acc + curVal;
					}, '').trim()
		};
	};

	return NumericContent;
});


text:
// $Id: TurnOffMoteCommand.java,v 1.2 2003/10/07 21:46:04 idgay Exp $

package net.tinyos.sim.event;
import net.tinyos.sim.*;
import net.tinyos.message.*;
import java.util.*;

public class TurnOffMoteCommand extends net.tinyos.sim.msg.TurnOffMoteCommand
  implements TossimCommand {
  private short moteID;
  private long time;

  public TurnOffMoteCommand(short moteID, long time) {
    super();
    this.moteID = moteID;
    this.time = time;
  }

  public String toString() {
    return "TurnOffMoteCommand [mote "+moteID+"]";
  }

  public short getMoteID() {
    return moteID;
  }
  public long getTime() {
    return time;
  }
}


text:
package cola.machine.game.myblocks.input;

import cola.machine.game.myblocks.model.ui.bag.Bag;
import cola.machine.game.myblocks.model.ui.html.HtmlObject;
import cola.machine.game.myblocks.model.ui.html.Tr;
import cola.machine.game.myblocks.registry.CoreRegistry;
import cola.machine.game.myblocks.rendering.world.WorldRendererLwjgl;
import glapp.GLApp;

/**
 * Created by luying on 14-9-19.
 */
public class PauseMouseEventReceiver implements MouseEventReceiver{
	public Bag bag;
    public boolean mouseMoveListen=false;
    public boolean mouseRClickListen=false;
    public boolean mouseLClickListen=false;
    public void mouseMove(int x,int y ){
        //TODO
        if(mouseMoveListen){
            mouseMoveHandle(x,y);

        }

    }
    public void mouseClick(float x,float y,HtmlObject htmlObject){
        if(htmlObject.isVisible()){//Keyboard.isKeyDown(0)
        	//if this has item  and mouse hasn't then current choose this item
            Tr tr = (Tr)htmlObject.parentNode;
            if(tr.rowIndex==1){
                //means exit
                GLApp.finished=true;
            }else if(tr.rowIndex==0){
                //means save
                CoreRegistry.get(WorldRendererLwjgl.class).save();
            }

        }
    }
    public void mouseMoveHandle(int x,int y){

    }
    public void mouseRCLickHandle(int x,int y){//receive the mouse key up

    }

    public void mouseLCLickHandle(int x,int y){

    }
}


text:
@implementation BackspaceReportingTextField
- (void)insertText:(NSString *)text
{
    [super insertText:text];
}

- (BOOL)keyboardInputShouldDelete:(UITextField *)textField
{
    if (self.text.length == 0) {
        if ([self.delegate respondsToSelector:@selector(textField:shouldChangeCharactersInRange:replacementString:)]) {
            [self.delegate textField:self shouldChangeCharactersInRange:NSMakeRange(0, 0) replacementString:@""];
        }
    }

    return YES;
}

@end


text:
            <button type="button" class="navbar-toggle" ng-click="toggleNavCollapse()">
                Toggle navigation

            </button>

                {{appName}}

                    <button type="button" ng-controller="StatusCtrl" class="btn btn-link navbar-btn btn-status"
                            ng-class="{ 'btn-status-online': status.status, 'btn-status-offline': !status.status }"
                            ng-click="showStatus()">

                        {{status.message}}
                    </button>

                            <pretty-duration from="timefilter.from" to="timefilter.to"></pretty-duration>

                            per {{timefilter.aggInterval.shortDescription}}

                     0">

                            {{timefilter.refreshInterval.display}}

                    <button class="btn btn-success navbar-btn btn-refresh" ng-click="refresh()">

                    </button>

                        {{authData.username}}

Change Password

Logout

<kbn-timepicker class="kbn-timepicker-wrap"
                ng-class="{ 'open': timepicker.show, 'closed': !timepicker.show }"
                active-tab="timepicker.tab"
                from="timefilter.from"
                to="timefilter.to"
                mode="timefilter.mode"
                interval="timefilter.refreshInterval"
                agg-interval="timefilter.aggInterval"
                show="timepicker.show">
</kbn-timepicker>


text:
from microscopes.irm import model, runner
from microscopes.irm.definition import model_definition
from microscopes.models import (
    bb,
    bbnc,
    nich,
)
from microscopes.common.rng import rng
from microscopes.common.relation.dataview import numpy_dataview
from microscopes.kernels import parallel
from microscopes.irm.testutil import toy_dataset, data_with_posterior
from microscopes.common.testutil import (
    assert_discrete_dist_approx,
    permutation_iter,
    permutation_canonical,
)

import itertools as it
import multiprocessing as mp

from nose.plugins.attrib import attr

def _test_runner_simple(defn, kc_fn):
    views = map(numpy_dataview, toy_dataset(defn))
    kc = kc_fn(defn)
    prng = rng()
    latent = model.initialize(defn, views, prng)
    r = runner.runner(defn, views, latent, kc)
    r.run(prng, 10)

def test_runner_default_kernel_config():
    defn = model_definition([10, 10], [((0, 0), bb), ((0, 1), nich)])
    kc_fn = runner.default_kernel_config
    _test_runner_simple(defn, kc_fn)

def test_runner_default_kernel_config_nonconj():
    defn = model_definition([10, 10], [((0, 0), bbnc), ((0, 1), nich)])
    kc_fn = runner.default_kernel_config
    _test_runner_simple(defn, kc_fn)

def test_runner_default_kernel_config_with_cluster():
    defn = model_definition([10, 10], [((0, 0), bb), ((0, 1), nich)])

    def kc_fn(defn):
        return list(it.chain(
            runner.default_assign_kernel_config(defn),
            runner.default_relation_hp_kernel_config(defn),
            runner.default_cluster_hp_kernel_config(defn)))
    _test_runner_simple(defn, kc_fn)

def test_runner_default_kernel_config_grid():
    defn = model_definition([10, 10], [((0, 0), bb), ((0, 1), nich)])

    def kc_fn(defn):
        return list(it.chain(
            runner.default_assign_kernel_config(defn),
            runner.default_relation_hp_kernel_config(defn)))
    _test_runner_simple(defn, kc_fn)

@attr('slow')
def test_runner_default_kernel_config_convergence():
    domains = [4]
    defn = model_definition(domains, [((0, 0), bb)])
    prng = rng()
    relations, posterior = data_with_posterior(defn, prng)
    views = map(numpy_dataview, relations)
    latent = model.initialize(defn, views, prng)
    r = runner.runner(defn, views, latent, [('assign', range(len(domains)))])

    r.run(r=prng, niters=1000)  # burnin
    product_assignments = tuple(map(list, map(permutation_iter, domains)))
    idmap = {C: i for i, C in enumerate(it.product(*product_assignments))}

    def sample_fn():
        r.run(r=prng, niters=10)
        new_latent = r.get_latent()
        key = tuple(tuple(permutation_canonical(new_latent.assignments(i)))
                    for i in xrange(len(domains)))
        return idmap[key]

    assert_discrete_dist_approx(sample_fn, posterior, ntries=100)

@attr('uses_mp')
def test_runner_multiprocessing():
    defn = model_definition([10, 10], [((0, 0), bb), ((0, 1), nich)])
    views = map(numpy_dataview, toy_dataset(defn))
    kc = runner.default_kernel_config(defn)
    prng = rng()
    latents = [model.initialize(defn, views, prng)
               for _ in xrange(mp.cpu_count())]
    runners = [runner.runner(defn, views, latent, kc) for latent in latents]
    r = parallel.runner(runners)
    # check it is restartable
    r.run(r=prng, niters=10)
    r.run(r=prng, niters=10)

@attr('uses_mp')
@attr('slow')
def test_runner_multiprocessing_convergence():
    domains = [4]
    defn = model_definition(domains, [((0, 0), bb)])
    prng = rng()
    relations, posterior = data_with_posterior(defn, prng)
    views = map(numpy_dataview, relations)
    latents = [model.initialize(defn, views, prng)
               for _ in xrange(mp.cpu_count())]
    kc = [('assign', range(len(domains)))]
    runners = [runner.runner(defn, views, latent, kc) for latent in latents]
    r = parallel.runner(runners)
    r.run(r=prng, niters=10000)  # burnin
    product_assignments = tuple(map(list, map(permutation_iter, domains)))
    idmap = {C: i for i, C in enumerate(it.product(*product_assignments))}

    def sample_iter():
        r.run(r=prng, niters=10)
        for latent in r.get_latents():
            key = tuple(tuple(permutation_canonical(latent.assignments(i)))
                        for i in xrange(len(domains)))
            yield idmap[key]

    ref = [None]

    def sample_fn():
        if ref[0] is None:
            ref[0] = sample_iter()
        try:
            return next(ref[0])
        except StopIteration:
            ref[0] = None
        return sample_fn()

    assert_discrete_dist_approx(sample_fn, posterior, ntries=100, kl_places=2)


text:
module Algebra.Optimum
( llo1
, rlo1
, llo2
, rlo2
, lloStd
, rloStd
, lloMem
, rloMem
, lloStdDepth
, rloStdDepth
, lloMemDepth
, rloMemDepth
) where

import Algebra.Semiring
import Algebra.Matrix

data LatticeStep = Lt | Gt | Eq | Pa

instance Show LatticeStep where
  show Lt = "<"
  show Gt = ">"
  show Eq = "≈"
  show Pa = "|"

norChar :: (Semiring s) => s -> s -> LatticeStep
norChar a b | (nor a b) && (nor b a) = Eq
norChar a b | (nor a b) = Lt
norChar a b | (nor b a) = Gt
norChar a b | otherwise = Pa

-- Iterated solving of X = AX + B
llo1 :: (Semiring s) => s -> s -> s -> s
llo1 a b x = if (x == updated) then x else llo1 a b updated
  where updated = add (mul a x) b
-- Iterated solving of X = XA + B
rlo1 :: (Semiring s) => s -> s -> s -> s
rlo1 a b x = if (x == updated) then x else rlo1 a b updated
  where updated = add (mul x a) b

lloDepth1 :: (Semiring s) => s -> s -> s -> [LatticeStep]
lloDepth1 a b x = if (x == updated) then [] else (norChar updated x) : lloDepth1 a b updated
  where updated = add (mul a x) b
rloDepth1 :: (Semiring s) => s -> s -> s -> [LatticeStep]
rloDepth1 a b x = if (x == updated) then [] else (norChar updated x) : rloDepth1 a b updated
  where updated = add (mul x a) b

llo2 :: (Semiring s) => s -> s -> s
llo2 a x = if (x == updated) then x else llo2 a updated
  where updated = add (mul a x) x
rlo2 :: (Semiring s) => s -> s -> s
rlo2 a x =  if (x == updated) then x else rlo2 a updated
  where updated = add (mul x a) x

lloDepth2 :: (Semiring s) => s -> s -> [LatticeStep]
lloDepth2 a x = if (x == updated) then [] else (norChar updated x) : lloDepth2 a updated
  where updated = add (mul a x) x
rloDepth2 :: (Semiring s) => s -> s -> [LatticeStep]
rloDepth2 a x = if (x == updated) then [] else (norChar updated x) : rloDepth2 a updated
  where updated = add (mul x a) x

lloStd :: (Semiring s) => s -> s
lloStd a = llo1 a unit unit

rloStd :: (Semiring s) => s -> s
rloStd a = rlo1 a unit unit

lloMem :: (Semiring s) => s -> s
lloMem a = llo2 a unit

rloMem :: (Semiring s) => s -> s
rloMem a = rlo2 a unit

lloStdDepth :: (Semiring s) => s -> [LatticeStep]
lloStdDepth a = lloDepth1 a unit unit
rloStdDepth :: (Semiring s) => s -> [LatticeStep]
rloStdDepth a = rloDepth1 a unit unit

lloMemDepth :: (Semiring s) => s -> [LatticeStep]
lloMemDepth a = lloDepth2 a unit
rloMemDepth :: (Semiring s) => s -> [LatticeStep]
rloMemDepth a = rloDepth2 a unit