text:
<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Booking is confirmed
 *
 * An email sent to the user when a booking is confirmed.
 *
 * @class 		WC_Email_Booking_Confirmed
 * @extends 	WC_Email
 */
class WC_Email_Booking_Confirmed extends WC_Email {

	/**
	 * Constructor
	 */
	public function __construct() {

		$this->id 				= 'booking_confirmed';
		$this->title 			= __( 'Booking Confirmed', 'woocommerce-bookings' );
		$this->description		= __( 'Booking confirmed emails are sent when the status of a booking goes to confirmed.', 'woocommerce-bookings' );
		$this->heading 			= __( 'Booking Confirmed', 'woocommerce-bookings' );
		$this->subject      	= __( '[{blogname}] Your booking of "{product_title}" has been confirmed (Order {order_number}) - {order_date}', 'woocommerce-bookings' );
		$this->customer_email   = true;
		$this->template_html 	= 'emails/customer-booking-confirmed.php';
		$this->template_plain 	= 'emails/plain/customer-booking-confirmed.php';

		// Triggers for this email
		add_action( 'woocommerce_booking_confirmed_notification', array( $this, 'trigger' ) );

		// `schedule_trigger` function must run after `trigger` as we must ensure that when trigger runs the next time
		// it will find the value set in the schedule `trigger` function. This is to allow for cases
		// where the dates are change and emails are sent before the new data is saved.
		add_action( 'woocommerce_booking_confirmed_notification', array( $this, 'schedule_trigger' ), 80 );

		// Call parent constructor
		parent::__construct();

		// Other settings
		$this->template_base = WC_BOOKINGS_TEMPLATE_PATH;
	}

	/**
	 * @param    $booking_id
	 * @since    1.9.13 introduced
	 * @version  1.10.7
	 */
	public function schedule_trigger( $booking_id ) {
		$ids_pending_confirmation_email = get_transient( 'wc_booking_confirmation_email_send_ids' );
		$ids_pending_confirmation_email = is_array( $ids_pending_confirmation_email ) ? $ids_pending_confirmation_email : array();
		// if id is in array it means were currently processing it in WC_Booking_Email_Manager::trigger_confirmation_email
		if ( ! in_array( $booking_id, $ids_pending_confirmation_email ) ) {
			$ids_pending_confirmation_email[] = $booking_id;
			set_transient( 'wc_booking_confirmation_email_send_ids', $ids_pending_confirmation_email, 0 );
		}
	}

	/**
	 * trigger function.
	 *
	 * @access public
	 * @return void
	 */
	public function trigger( $booking_id ) {

		$booking_ids = get_transient( 'wc_booking_confirmation_email_send_ids' );
		if ( ! in_array( $booking_id, (array) $booking_ids ) ) {
			return;
		}

		if ( $booking_id ) {
			$this->object = get_wc_booking( $booking_id );

			if ( ! is_object( $this->object ) ) {
				return;
			}

			foreach ( array( '{product_title}', '{order_date}', '{order_number}' ) as $key ) {
				$key = array_search( $key, $this->find );
				if ( false !== $key ) {
					unset( $this->find[ $key ] );
					unset( $this->replace[ $key ] );
				}
			}

			$this->find[]    = '{product_title}';
			$this->replace[] = $this->object->get_product()->get_title();

			if ( $this->object->get_order() ) {
				if ( version_compare( WC_VERSION, '3.0', '<' ) ) {
					$billing_email = $this->object->get_order()->billing_email;
					$order_date = $this->object->get_order()->order_date;
				} else {
					$billing_email = $this->object->get_order()->get_billing_email();
					$order_date = $this->object->get_order()->get_date_created() ? $this->object->get_order()->get_date_created()->date( 'Y-m-d H:i:s' ) : '';
				}

				$this->find[]    = '{order_date}';
				$this->replace[] = date_i18n( wc_date_format(), strtotime( $order_date ) );

				$this->find[]    = '{order_number}';
				$this->replace[] = $this->object->get_order()->get_order_number();

				$this->recipient = $billing_email;
			} else {
				$this->find[]    = '{order_date}';
				$this->replace[] = date_i18n( wc_date_format(), strtotime( $this->object->booking_date ) );

				$this->find[]    = '{order_number}';
				$this->replace[] = __( 'N/A', 'woocommerce-bookings' );

				if ( $this->object->customer_id && ( $customer = get_user_by( 'id', $this->object->customer_id ) ) ) {
					$this->recipient = $customer->user_email;
				}
			}
		}

		if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
			return;
		}

		$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
	}

	/**
	 * get_content_html function.
	 *
	 * @access public
	 * @return string
	 */
	public function get_content_html() {
		ob_start();
		wc_get_template( $this->template_html, array(
			'booking' 		=> $this->object,
			'email_heading' => $this->get_heading(),
			'sent_to_admin' => false,
			'plain_text'    => false
		), 'woocommerce-bookings/', $this->template_base );
		return ob_get_clean();
	}

	/**
	 * get_content_plain function.
	 *
	 * @access public
	 * @return string
	 */
	public function get_content_plain() {
		ob_start();
		wc_get_template( $this->template_plain, array(
			'booking' 		=> $this->object,
			'email_heading' => $this->get_heading(),
			'sent_to_admin' => false,
			'plain_text'    => true
		), 'woocommerce-bookings/', $this->template_base );
		return ob_get_clean();
	}

    /**
     * Initialise Settings Form Fields
     *
     * @access public
     * @return void
     */
    public function init_form_fields() {
    	$this->form_fields = array(
			'enabled' => array(
				'title' 		=> __( 'Enable/Disable', 'woocommerce-bookings' ),
				'type' 			=> 'checkbox',
				'label' 		=> __( 'Enable this email notification', 'woocommerce-bookings' ),
				'default' 		=> 'yes'
			),
			'subject' => array(
				'title' 		=> __( 'Subject', 'woocommerce-bookings' ),
				'type' 			=> 'text',
				'description' 	=> sprintf( __( 'This controls the email subject line. Leave blank to use the default subject: %s.', 'woocommerce-bookings' ), $this->subject ),
				'placeholder' 	=> '',
				'default' 		=> ''
			),
			'heading' => array(
				'title' 		=> __( 'Email Heading', 'woocommerce-bookings' ),
				'type' 			=> 'text',
				'description' 	=> sprintf( __( 'This controls the main heading contained within the email notification. Leave blank to use the default heading: %s.', 'woocommerce-bookings' ), $this->heading ),
				'placeholder' 	=> '',
				'default' 		=> ''
			),
			'email_type' => array(
				'title' 		=> __( 'Email type', 'woocommerce-bookings' ),
				'type' 			=> 'select',
				'description' 	=> __( 'Choose which format of email to send.', 'woocommerce-bookings' ),
				'default' 		=> 'html',
				'class'			=> 'email_type',
				'options'		=> array(
					'plain'		 	=> __( 'Plain text', 'woocommerce-bookings' ),
					'html' 			=> __( 'HTML', 'woocommerce-bookings' ),
					'multipart' 	=> __( 'Multipart', 'woocommerce-bookings' ),
				)
			)
		);
    }
}

return new WC_Email_Booking_Confirmed();

redpajama_set_name: RedPajamaGithub


text:
//
//  RCUploadMediaStatusListener.h
//  RongIMLib
//
//  Created by litao on 15/8/28.
//  Copyright (c) 2015年 RongCloud. All rights reserved.
//

#import "RCMessage.h"
#import <Foundation/Foundation.h>

/*!
 媒体文件上传进度更新的 IMKit 监听

 @discussion 此监听用于 IMKit 发送媒体文件消息(上传到指定服务器)。
 App 在上传媒体文件时,需要在监听中调用 updateBlock、successBlock 与 errorBlock,通知 IMKit
 SDK 当前上传媒体文件的进度和状态,SDK 会更新 UI。
 */
@interface RCUploadMediaStatusListener : NSObject

/*!
 上传的媒体文件消息的消息实体
 */
@property (nonatomic, strong) RCMessage *currentMessage;

/*!
 更新上传进度需要调用的 block [progress:当前上传的进度,0 <= progress < 100]
 */
@property (nonatomic, strong) void (^updateBlock)(int progress);

/*!
 上传成功需要调用的 block。
 content:上传成功之后,需要发送的消息内容。
 您可以使用 currentMessage,把其中content属性对应的 url 字段设置成您上传成功的网络 URL。
 请参考下面代码。

 升级说明:如果您之前使用了此接口,请参考下面代码把参数从 url 替换成 message。
 if ([currentMessage.content isKindOfClass:[RCImageMessage class]]) {
    RCImageMessage *content = (RCImageMessage *)currentMessage.content;
    content.imageUrl = remoteUrl;
    successBlock(content);
 } else if ([currentMessage.content isKindOfClass:[RCFileMessage class]]) {
    RCFileMessage *content = (RCFilemessage *)currentMessage.content;
    content.fileUrl = remoteUrl;
    successBlock(content);
 }
 */
@property (nonatomic, strong) void (^successBlock)(RCMessageContent *content);

/*!
 上传成功需要调用的 block [errorCode:上传失败的错误码,非 0 整数]
 */
@property (nonatomic, strong) void (^errorBlock)(RCErrorCode errorCode);

/*!
 上传取消需要调用的 block
 */
@property (nonatomic, strong) void (^cancelBlock)(void);

/*!
 初始化媒体文件上传进度更新的 IMKit 监听

 @param message             媒体文件消息的消息实体
 @param progressBlock       更新上传进度需要调用的 block
 @param successBlock        上传成功需要调用的 block
 @param errorBlock          上传失败需要调用的 block
 @param cancelBlock         上传取消需要调用的 block( 如果未实现,传 nil 即可)

 @return                    媒体文件上传进度更新的 IMKit 监听对象
 */
- (instancetype)initWithMessage:(RCMessage *)message
                 uploadProgress:(void (^)(int progress))progressBlock
                  uploadSuccess:(void (^)(RCMessageContent *content))successBlock
                    uploadError:(void (^)(RCErrorCode errorCode))errorBlock
                   uploadCancel:(void (^)(void))cancelBlock;

/*!
 取消当前上传

 @discussion 如果您实现取消正在上传的媒体消息功能,则必须实现此回调。
 您需要在取消成功之后,调用 cancelBlock 通知 SDK,SDK 会自动更新 UI。
 */
- (void)cancelUpload;

@end


text:
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.admin.monitoring;

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

import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
 * @author gjoranv
 */
public class MetricTest {

    @Test
    void this_metric_takes_precedence_when_combined_with_another_metric() {
        String COMMON_DIMENSION_KEY = "commonKey";

        Map<String, String> thisDimensions = ImmutableMap.<String, String>builder()
                .put(COMMON_DIMENSION_KEY, "thisCommonVal")
                .put("thisKey", "thisVal")
                .build();
        Metric thisMetric = new Metric("thisMetric", "this-output-name", "this-description", thisDimensions);

        Map<String, String> thatDimensions = ImmutableMap.<String, String>builder()
                .put(COMMON_DIMENSION_KEY, "thatCommonVal")
                .put("thatKey", "thatVal")
                .build();
        Metric thatMetric = new Metric("thatMetric", "that-output-name", "that-description", thatDimensions);

        Metric combinedMetric = thisMetric.addDimensionsFrom(thatMetric);
        assertEquals("this-output-name", combinedMetric.outputName);
        assertEquals("this-description", combinedMetric.description);
        assertEquals(3, combinedMetric.dimensions.size());
        assertEquals("thisCommonVal", combinedMetric.dimensions.get(COMMON_DIMENSION_KEY));
    }
}


text:
<?php
namespace Cheetahmail\Campaigns\Campaigns;

class GetSourceOfCampaign
{

    /**
     * @var int $campaignId
     */
    protected $campaignId = null;

    /**
     * @param int $campaignId
     */
    public function __construct($campaignId)
    {
        $this->campaignId = $campaignId;
    }

    /**
     * @return int
     */
    public function getCampaignId()
    {
        return $this->campaignId;
    }

    /**
     * @param int $campaignId
     * @return \Cheetahmail\Campaigns\Campaigns\GetSourceOfCampaign
     */
    public function setCampaignId($campaignId)
    {
        $this->campaignId = $campaignId;
        return $this;
    }
}


text:
#ifndef FillLayer_h
#define FillLayer_h

#include "core/style/ComputedStyleConstants.h"
#include "core/style/StyleImage.h"
#include "platform/Length.h"
#include "platform/LengthSize.h"
#include "platform/graphics/GraphicsTypes.h"
#include "wtf/RefPtr.h"

namespace blink {

struct FillSize {
    FillSize()
        : type(SizeLength)
    {
    }

    FillSize(EFillSizeType t, const LengthSize& l)
        : type(t)
        , size(l)
    {
    }

    bool operator==(const FillSize& o) const
    {
        return type == o.type && size == o.size;
    }
    bool operator!=(const FillSize& o) const
    {
        return !(*this == o);
    }

    EFillSizeType type;
    LengthSize size;
};

class FillLayer {
    WTF_MAKE_FAST_ALLOCATED(FillLayer);
public:
    FillLayer(EFillLayerType, bool useInitialValues = false);
    ~FillLayer();

    StyleImage* image() const { return m_image.get(); }
    const Length& xPosition() const { return m_xPosition; }
    const Length& yPosition() const { return m_yPosition; }
    BackgroundEdgeOrigin backgroundXOrigin() const { return static_cast<BackgroundEdgeOrigin>(m_backgroundXOrigin); }
    BackgroundEdgeOrigin backgroundYOrigin() const { return static_cast<BackgroundEdgeOrigin>(m_backgroundYOrigin); }
    EFillAttachment attachment() const { return static_cast<EFillAttachment>(m_attachment); }
    EFillBox clip() const { return static_cast<EFillBox>(m_clip); }
    EFillBox origin() const { return static_cast<EFillBox>(m_origin); }
    EFillRepeat repeatX() const { return static_cast<EFillRepeat>(m_repeatX); }
    EFillRepeat repeatY() const { return static_cast<EFillRepeat>(m_repeatY); }
    CompositeOperator composite() const { return static_cast<CompositeOperator>(m_composite); }
    WebBlendMode blendMode() const { return static_cast<WebBlendMode>(m_blendMode); }
    const LengthSize& sizeLength() const { return m_sizeLength; }
    EFillSizeType sizeType() const { return static_cast<EFillSizeType>(m_sizeType); }
    FillSize size() const { return FillSize(static_cast<EFillSizeType>(m_sizeType), m_sizeLength); }
    EMaskSourceType maskSourceType() const { return static_cast<EMaskSourceType>(m_maskSourceType); }

    const FillLayer* next() const { return m_next; }
    FillLayer* next() { return m_next; }
    FillLayer* ensureNext()
    {
        if (!m_next)
            m_next = new FillLayer(type());
        return m_next;
    }

    bool isImageSet() const { return m_imageSet; }
    bool isXPositionSet() const { return m_xPosSet; }
    bool isYPositionSet() const { return m_yPosSet; }
    bool isBackgroundXOriginSet() const { return m_backgroundXOriginSet; }
    bool isBackgroundYOriginSet() const { return m_backgroundYOriginSet; }
    bool isAttachmentSet() const { return m_attachmentSet; }
    bool isClipSet() const { return m_clipSet; }
    bool isOriginSet() const { return m_originSet; }
    bool isRepeatXSet() const { return m_repeatXSet; }
    bool isRepeatYSet() const { return m_repeatYSet; }
    bool isCompositeSet() const { return m_compositeSet; }
    bool isBlendModeSet() const { return m_blendModeSet; }
    bool isSizeSet() const { return m_sizeType != SizeNone; }
    bool isMaskSourceTypeSet() const { return m_maskSourceTypeSet; }

    void setImage(PassRefPtr<StyleImage> i) { m_image = i; m_imageSet = true; }
    void setXPosition(const Length& position) { m_xPosition = position; m_xPosSet = true; m_backgroundXOriginSet = false; m_backgroundXOrigin = LeftEdge; }
    void setYPosition(const Length& position) { m_yPosition = position; m_yPosSet = true; m_backgroundYOriginSet = false; m_backgroundYOrigin = TopEdge; }
    void setBackgroundXOrigin(BackgroundEdgeOrigin origin) { m_backgroundXOrigin = origin; m_backgroundXOriginSet = true; }
    void setBackgroundYOrigin(BackgroundEdgeOrigin origin) { m_backgroundYOrigin = origin; m_backgroundYOriginSet = true; }
    void setAttachment(EFillAttachment attachment) { m_attachment = attachment; m_attachmentSet = true; }
    void setClip(EFillBox b) { m_clip = b; m_clipSet = true; }
    void setOrigin(EFillBox b) { m_origin = b; m_originSet = true; }
    void setRepeatX(EFillRepeat r) { m_repeatX = r; m_repeatXSet = true; }
    void setRepeatY(EFillRepeat r) { m_repeatY = r; m_repeatYSet = true; }
    void setComposite(CompositeOperator c) { m_composite = c; m_compositeSet = true; }
    void setBlendMode(WebBlendMode b) { m_blendMode = b; m_blendModeSet = true; }
    void setSizeType(EFillSizeType b) { m_sizeType = b; }
    void setSizeLength(const LengthSize& length) { m_sizeLength = length; }
    void setSize(FillSize f) { m_sizeType = f.type; m_sizeLength = f.size; }
    void setMaskSourceType(EMaskSourceType m) { m_maskSourceType = m; m_maskSourceTypeSet = true; }

    void clearImage() { m_image.clear(); m_imageSet = false; }
    void clearXPosition()
    {
        m_xPosSet = false;
        m_backgroundXOriginSet = false;
    }
    void clearYPosition()
    {
        m_yPosSet = false;
        m_backgroundYOriginSet = false;
    }

    void clearAttachment() { m_attachmentSet = false; }
    void clearClip() { m_clipSet = false; }
    void clearOrigin() { m_originSet = false; }
    void clearRepeatX() { m_repeatXSet = false; }
    void clearRepeatY() { m_repeatYSet = false; }
    void clearComposite() { m_compositeSet = false; }
    void clearBlendMode() { m_blendModeSet = false; }
    void clearSize() { m_sizeType = SizeNone; }
    void clearMaskSourceType() { m_maskSourceTypeSet = false; }

    FillLayer& operator=(const FillLayer&);
    FillLayer(const FillLayer&);

    bool operator==(const FillLayer&) const;
    bool operator!=(const FillLayer& o) const
    {
        return !(*this == o);
    }

    bool containsImage(StyleImage*) const;
    bool imagesAreLoaded() const;

    bool hasImage() const
    {
        if (m_image)
            return true;
        return m_next ? m_next->hasImage() : false;
    }

    bool hasFixedImage() const
    {
        if (m_image && m_attachment == FixedBackgroundAttachment)
            return true;
        return m_next ? m_next->hasFixedImage() : false;
    }

    bool hasOpaqueImage(const LayoutObject*) const;
    bool hasRepeatXY() const;
    bool clipOccludesNextLayers(bool firstLayer) const;

    EFillLayerType type() const { return static_cast<EFillLayerType>(m_type); }

    void fillUnsetProperties();
    void cullEmptyLayers();

    static EFillAttachment initialFillAttachment(EFillLayerType) { return ScrollBackgroundAttachment; }
    static EFillBox initialFillClip(EFillLayerType) { return BorderFillBox; }
    static EFillBox initialFillOrigin(EFillLayerType type) { return type == BackgroundFillLayer ? PaddingFillBox : BorderFillBox; }
    static EFillRepeat initialFillRepeatX(EFillLayerType) { return RepeatFill; }
    static EFillRepeat initialFillRepeatY(EFillLayerType) { return RepeatFill; }
    static CompositeOperator initialFillComposite(EFillLayerType) { return CompositeSourceOver; }
    static WebBlendMode initialFillBlendMode(EFillLayerType) { return WebBlendModeNormal; }
    static EFillSizeType initialFillSizeType(EFillLayerType) { return SizeLength; }
    static LengthSize initialFillSizeLength(EFillLayerType) { return LengthSize(); }
    static FillSize initialFillSize(EFillLayerType type) { return FillSize(initialFillSizeType(type), initialFillSizeLength(type)); }
    static Length initialFillXPosition(EFillLayerType) { return Length(0.0, Percent); }
    static Length initialFillYPosition(EFillLayerType) { return Length(0.0, Percent); }
    static StyleImage* initialFillImage(EFillLayerType) { return 0; }
    static EMaskSourceType initialFillMaskSourceType(EFillLayerType) { return MaskAlpha; }

private:
    friend class ComputedStyle;

    void computeClipMax() const;

    FillLayer() { }

    FillLayer* m_next;

    RefPtr<StyleImage> m_image;

    Length m_xPosition;
    Length m_yPosition;

    LengthSize m_sizeLength;

    unsigned m_attachment : 2; // EFillAttachment
    unsigned m_clip : 2; // EFillBox
    unsigned m_origin : 2; // EFillBox
    unsigned m_repeatX : 3; // EFillRepeat
    unsigned m_repeatY : 3; // EFillRepeat
    unsigned m_composite : 4; // CompositeOperator
    unsigned m_sizeType : 2; // EFillSizeType
    unsigned m_blendMode : 5; // WebBlendMode
    unsigned m_maskSourceType : 1; // EMaskSourceType
    unsigned m_backgroundXOrigin : 2; // BackgroundEdgeOrigin
    unsigned m_backgroundYOrigin : 2; // BackgroundEdgeOrigin

    unsigned m_imageSet : 1;
    unsigned m_attachmentSet : 1;
    unsigned m_clipSet : 1;
    unsigned m_originSet : 1;
    unsigned m_repeatXSet : 1;
    unsigned m_repeatYSet : 1;
    unsigned m_xPosSet : 1;
    unsigned m_yPosSet : 1;
    unsigned m_backgroundXOriginSet : 1;
    unsigned m_backgroundYOriginSet : 1;
    unsigned m_compositeSet : 1;
    unsigned m_blendModeSet : 1;
    unsigned m_maskSourceTypeSet : 1;

    unsigned m_type : 1; // EFillLayerType

    mutable unsigned m_clipMax : 2; // EFillBox, maximum m_clip value from this to bottom layer
};

} // namespace blink

#endif // FillLayer_h


text:
package com.merakianalytics.orianna.examples;

import com.merakianalytics.orianna.types.common.Region;
import com.merakianalytics.orianna.types.core.staticdata.Item;
import com.merakianalytics.orianna.types.core.staticdata.Items;

public class GetItems {
    public static void main(final String[] args) {
        final Items items = Items.withRegion(Region.NORTH_AMERICA).get();
        for(final Item item : items) {
            System.out.println(item.getName() + " " + item.getId());
        }

        final Item dagger = Item.named("Dagger").withRegion(Region.NORTH_AMERICA).get();
        System.out.println(dagger.getName() + " " + dagger.getId());
    }
}


text:
package org.apache.accumulo.core.util.format;

import java.util.Iterator;
import java.util.Map.Entry;

import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.security.ColumnVisibility;
import org.apache.hadoop.io.Text;

public class BinaryFormatter implements Formatter {
  private Iterator<Entry<Key,Value>> si;
  private boolean doTimestamps;
  private static int showLength;

  @Override
  public void initialize(Iterable<Entry<Key,Value>> scanner, boolean printTimestamps) {
    checkState(si, false);
    si = scanner.iterator();
    doTimestamps = printTimestamps;
  }

  @Override
  public boolean hasNext() {
    checkState(si, true);
    return si.hasNext();
  }

  @Override
  public String next() {
    checkState(si, true);
    return formatEntry(si.next(), doTimestamps);
  }

  @Override
  public void remove() {
    checkState(si, true);
    si.remove();
  }

  static void checkState(Iterator<Entry<Key,Value>> si, boolean expectInitialized) {
    if (expectInitialized && si == null)
      throw new IllegalStateException("Not initialized");
    if (!expectInitialized && si != null)
      throw new IllegalStateException("Already initialized");
  }

  // this should be replaced with something like Record.toString();
  public static String formatEntry(Entry<Key,Value> entry, boolean showTimestamps) {
    StringBuilder sb = new StringBuilder();

    // append row
    appendText(sb, entry.getKey().getRow()).append(" ");

    // append column family
    appendText(sb, entry.getKey().getColumnFamily()).append(":");

    // append column qualifier
    appendText(sb, entry.getKey().getColumnQualifier()).append(" ");

    // append visibility expression
    sb.append(new ColumnVisibility(entry.getKey().getColumnVisibility()));

    // append timestamp
    if (showTimestamps)
      sb.append(" ").append(entry.getKey().getTimestamp());

    // append value
    if (entry.getValue() != null && entry.getValue().getSize() > 0) {
      sb.append("\t");
      appendValue(sb, entry.getValue());
    }

    return sb.toString();
  }

  public static StringBuilder appendText(StringBuilder sb, Text t) {
    return appendBytes(sb, t.getBytes(), 0, t.getLength());
  }

  static StringBuilder appendValue(StringBuilder sb, Value value) {

    return appendBytes(sb, value.get(), 0, value.get().length);
  }

  static StringBuilder appendBytes(StringBuilder sb, byte ba[], int offset, int len) {
    if (len > showLength) {
      for (int i = 0; i < showLength; i++) {
        int c = 0xff & ba[offset + i];
        if (c == '\\')
          sb.append("\\\\");
        else if (c >= 32 && c <= 126)
          sb.append((char) c);
        else
          sb.append("\\x").append(String.format("%02X", c));
      }
      return sb;
    } else {
      for (int i = 0; i < len; i++) {

        int c = 0xff & ba[offset + i];
        if (c == '\\')
          sb.append("\\\\");
        else if (c >= 32 && c <= 126)
          sb.append((char) c);
        else
          sb.append("\\x").append(String.format("%02X", c));
      }
      return sb;
    }
  }

  public Iterator<Entry<Key,Value>> getScannerIterator() {
    return si;
  }

  public static void getlength(int length) {
    showLength = length;
  }
}


text:
'use strict';

import GL from "gl-react";
import React, { Component }  from "react";

import {
    GPUImageFragShaderPredefineString,
    GPUImageFilter
} from '../GPUImageFilter';
import {
    GPUImage3x3TextureSamplingFragShaderPredefine,
    GPUImage3x3TextureSamplingFilter
} from '../GPUImage3x3TextureSamplingFilter';

const GPUImageToonFragShaderString = GPUImageFragShaderPredefineString +
GPUImage3x3TextureSamplingFragShaderPredefine + `
uniform float u_threshold;
uniform float u_quantizationLevels;
void main() {
    float bottomLeftIntensity  = texture2D(u_texture_0, v_texCoord_lb).r;
    float topRightIntensity    = texture2D(u_texture_0, v_texCoord_rt).r;
    float topLeftIntensity     = texture2D(u_texture_0, v_texCoord_lt).r;
    float bottomRightIntensity = texture2D(u_texture_0, v_texCoord_rb).r;
    float leftIntensity        = texture2D(u_texture_0, v_texCoord_l).r;
    float rightIntensity       = texture2D(u_texture_0, v_texCoord_r).r;
    float bottomIntensity      = texture2D(u_texture_0, v_texCoord_b).r;
    float topIntensity         = texture2D(u_texture_0, v_texCoord_t).r;

    vec4 texColor = texture2D(u_texture_0, v_texCoord);

    float x = -bottomLeftIntensity - 2.0 * leftIntensity - topLeftIntensity + bottomRightIntensity + 2.0 * rightIntensity + topRightIntensity;
    float y = -topLeftIntensity - 2.0 * topIntensity - topRightIntensity + bottomLeftIntensity + 2.0 * bottomIntensity + bottomRightIntensity;
    float magnitude = length(vec2(x, y));
    vec3 posterizedImageColor = floor((texColor.rgb * u_quantizationLevels) + 0.5) / u_quantizationLevels;
    float test = 1.0 - step(u_threshold, magnitude);

    gl_FragColor = vec4(posterizedImageColor * test, texColor.z);
}
`;

export const GPUImageToonFilter = GL.createComponent(
    ({children, texelWidth, texelHeight, levels, threshold})=>{
        return (
            <GPUImage3x3TextureSamplingFilter
                frag={GPUImageToonFragShaderString}
                texelWidth={texelWidth}
                texelHeight={texelHeight}
                uniforms={{
                    u_threshold: threshold,
                    u_quantizationLevels: levels,
                }}>
                {children}
            </GPUImage3x3TextureSamplingFilter>
        );
    },
    {
        defaultProps: {
            threshold: 0.2,
            levels: 10.0,
        }
    }
);


text:
<?php
# MantisBT - A PHP based bugtracking system

# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.

require_once( 'core.php' );
require_api( 'access_api.php' );
require_api( 'authentication_api.php' );
require_api( 'config_api.php' );
require_api( 'custom_field_api.php' );
require_api( 'form_api.php' );
require_api( 'gpc_api.php' );
require_api( 'helper_api.php' );
require_api( 'html_api.php' );
require_api( 'lang_api.php' );
require_api( 'print_api.php' );
require_api( 'string_api.php' );

auth_reauthenticate();

access_ensure_global_level( config_get( 'manage_custom_fields_threshold' ) );

$f_field_id	= gpc_get_int( 'field_id' );
$f_return	= strip_tags( gpc_get_string( 'return', 'manage_custom_field_page.php' ) );

custom_field_ensure_exists( $f_field_id );

require_js( 'manage_custom_field_edit_page.js' );

layout_page_header();

layout_page_begin( 'manage_overview_page.php' );

print_manage_menu( 'manage_custom_field_page.php' );

$t_definition = custom_field_get_definition( $f_field_id );
?>

<form id="manage-custom-field-update-form" method="post" action="manage_custom_field_update.php">

		<?php echo lang_get( 'edit_custom_field_title' ) ?>

<fieldset>
			<?php echo form_security_field( 'manage_custom_field_update' ); ?>
			<input type="hidden" name="field_id" value="<?php echo $f_field_id ?>" />
			<input type="hidden" name="return" value="<?php echo $f_return ?>" />

			<?php echo lang_get( 'custom_field_name' ) ?>

			<input type="text" id="custom-field-name" name="name" class="input-sm" size="32" maxlength="64" value="<?php echo string_attribute( $t_definition['name'] ) ?>" />

			<?php echo lang_get( 'custom_field_type' ) ?>

			<select id="custom-field-type" name="type" class="input-sm">
				<?php print_enum_string_option_list( 'custom_field_type', (int)$t_definition['type'] ) ?>
			</select>

			<?php echo lang_get( 'custom_field_possible_values' ) ?>

			<input type="text" id="custom-field-possible-values" name="possible_values" class="input-sm" size="80%" value="<?php echo string_attribute( $t_definition['possible_values'] ) ?>" />
            <?php echo sprintf( lang_get( 'separate_list_items_by' ), '|' ) ?>

			<?php echo lang_get( 'custom_field_default_value' ) ?>

				<input type="text" id="custom-field-default-value" name="default_value" class="input-sm" size="32" maxlength="255" value="<?php echo string_attribute( $t_definition['default_value'] ) ?>" />

				<textarea disabled="disabled" id="custom-field-default-value-textarea" name="default_value" class="form-control" cols="80" rows="10"><?php echo string_attribute( $t_definition['default_value'] ) ?></textarea>

			<?php echo lang_get( 'custom_field_valid_regexp' ) ?>

			<input type="text" id="custom-field-valid-regexp" name="valid_regexp" class="input-sm" size="32" maxlength="255" value="<?php echo string_attribute( $t_definition['valid_regexp'] ) ?>" />

			<?php echo lang_get( 'custom_field_access_level_r' ) ?>

			<select id="custom-field-access-level-r" name="access_level_r" class="input-sm">
				<?php print_enum_string_option_list( 'access_levels', (int)$t_definition['access_level_r'] ) ?>
			</select>

			<?php echo lang_get( 'custom_field_access_level_rw' ) ?>

			<select id="custom-field-access-level-rw" name="access_level_rw" class="input-sm">
				<?php print_enum_string_option_list( 'access_levels', (int)$t_definition['access_level_rw'] ) ?>
			</select>

            <?php echo lang_get( 'custom_field_length_min' ) ?>

            <input type="text" id="custom-field-length-min" name="length_min" class="input-sm" size="32" maxlength="64" value="<?php echo $t_definition['length_min'] ?>" />

            <?php echo lang_get( 'custom_field_length_max' ) ?>

            <input type="text" id="custom-field-length-max" name="length_max" class="input-sm" size="32" maxlength="64" value="<?php echo $t_definition['length_max'] ?>" />

            <?php echo lang_get( 'custom_field_filter_by' ) ?>

                <input type="checkbox" class="ace" id="custom-field-filter-by" name="filter_by" value="1"
                    <?php
                    if( $t_definition['filter_by'] ) {
                        echo 'checked="checked"';
                    }
                    ?> />

			<?php echo lang_get( 'custom_field_display_report' ) ?>

				<input type="checkbox" class="ace" id="custom-field-display-report" name="display_report" value="1" <?php check_checked( (bool)$t_definition['display_report'] ) ?> />

			<?php echo lang_get( 'custom_field_display_update' ) ?>

				<input type="checkbox" class="ace" id="custom-field-display-update" name="display_update" value="1" <?php check_checked( (bool)$t_definition['display_update'] ) ?> />

			<?php echo lang_get( 'custom_field_display_resolved' ) ?>

				<input type="checkbox" class="ace" id="custom-field-display-resolved" name="display_resolved" value="1" <?php check_checked( (bool)$t_definition['display_resolved'] ) ?> />

			<?php echo lang_get( 'custom_field_display_closed' ) ?>

				<input type="checkbox" class="ace" id="custom-field-display-closed" name="display_closed" value="1" <?php check_checked( (bool)$t_definition['display_closed'] ) ?> />

			<?php echo lang_get( 'custom_field_require_report' ) ?>

				<input type="checkbox" class="ace" id="custom-field-require-report" name="require_report" value="1" <?php check_checked( (bool)$t_definition['require_report'] ) ?> />

			<?php echo lang_get( 'custom_field_require_update' ) ?>

				<input type="checkbox" class="ace" id="custom-field-require-update" name="require_update" value="1" <?php check_checked( (bool)$t_definition['require_update'] ) ?> />

			<?php echo lang_get( 'custom_field_require_resolved' ) ?>

				<input type="checkbox" class="ace" id="custom-field-require-resolved" name="require_resolved" value="1" <?php check_checked( (bool)$t_definition['require_resolved'] ) ?> />

			<?php echo lang_get( 'custom_field_require_closed' ) ?>

				<input type="checkbox" class="ace" id="custom-field-require-closed" name="require_closed" value="1" <?php check_checked( (bool)$t_definition['require_closed'] ) ?> />

</fieldset>

	<input type="submit" class="btn btn-primary btn-white btn-round" value="<?php echo lang_get( 'update_custom_field_button' ) ?>" />

</form>

	<form method="post" action="manage_custom_field_delete.php" class="pull-right">
		<fieldset>
			<?php echo form_security_field( 'manage_custom_field_delete' ); ?>
			<input type="hidden" name="field_id" value="<?php echo $f_field_id ?>" />
			<input type="hidden" name="return" value="<?php echo string_attribute( $f_return ) ?>" />
			<input type="submit" class="btn btn-primary btn-sm btn-white btn-round" value="<?php echo lang_get( 'delete_custom_field_button' ) ?>" />
		</fieldset>
	</form>

<?php /** @todo There is access checking in the ADD action page and at the top of this file.
           * We may need to add extra checks to exclude projects from the list that the user
		   * can't link/unlink fields from/to. */
?>

			<?php echo lang_get( 'link_custom_field_to_project_title' ) ?>

			<form id="manage-custom-field-link-form" method="post" action="manage_custom_field_proj_add.php">

					<?php echo lang_get( 'linked_projects_label' ) ?>

					<?php print_custom_field_projects_list( $f_field_id ); ?>

				<input type="hidden" name="field_id" value="<?php echo $f_field_id ?>" />
				<?php echo form_security_field( 'manage_custom_field_proj_add' ); ?>

						<?php echo lang_get( 'projects_title_label' ) ?>

						<select id="custom-field-project-id" name="project_id[]" class="input-sm" multiple="multiple" size="5">
							<?php print_project_option_list( null, false ); ?>
						</select>

						<?php echo lang_get( 'custom_field_sequence_label' ) ?>

						<input type="text" id="custom-field-sequence" name="sequence" class="input-sm" value="0" />

						<input type="submit" class="btn btn-primary btn-white btn-round" value="<?php echo lang_get( 'link_custom_field_to_project_button' ) ?>" />

				</form>

<?php

layout_page_end();


text:
package oru.aass.CS;

import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import oru.aass.CS.utils.MathFunc;
import oru.aass.CS.utils.Pair;

/**
 *
 * @author Hadi Banaee <Örebro University, AASS>
 */
public class Reasoner {

//    ??????
    public static final int SIMILARITY_EXPONENTIAL = 0;
    public static final int SIMILARITY_GAUSSIAN = 1;
    public static final int SIMILARITY_LINEAR = 2;

    private Model model;
    private double c = 1.0; // similarity sensitivity parameter

//    ??????
    private String qHullPath = "/opt/local/bin/qhull";
    private String tempDir = "temp/";
    private long qHullTimeout = 30000; // 30 sec
//    private double roundPrecision = Globals.roundPrecision; // rounding error buffer for identifying if values are equal after qhull, qhalf, etc.
    private double roundPrecision = 0.00000001;

//    ????????
    private String glpsolPath = "/usr/local/bin/glpsol";
    private long glpsolTimeout = 30000; // 30 sec

    public Reasoner() {
    }

    public Reasoner(Model model) {
        this.model = model;
    }

    // set the default similarity sensitivity parameter
    public void setC(double c) {
        this.c = c;
    }

    // get the default similarity sensitivity parameter
    public double getC() {
        return c;
    }

    // returns a list of all domains shared by the given list of instances
    public ArrayList<Domain> sharedDomains(ArrayList<Instance> instances) {
        ArrayList<Domain> domains = new ArrayList<Domain>();
        if (instances == null || instances.size() == 0) return domains;

        ArrayList<String> domainIds = new ArrayList<String>(Arrays.asList(instances.get(0).getDomainIds()));
        for (int i = domainIds.size()-1; i >= 0; i--) {
            String dId = domainIds.get(i);
            for (int j = 1; j < instances.size(); j++) {
                Instance curI = instances.get(j);
                String[] dIds = curI.getDomainIds();
                if (!Arrays.asList(dIds).contains(dId)) {
                    domainIds.remove(i);
                    break;
                }
            }
        }

        for (String domainId : domainIds) {
            Domain d = model.getDomain(domainId);
            if (d != null)
                domains.add(d);
        }

        return domains;
    }

    public ArrayList<Domain> sharedDomains(Instance i1, Instance i2) {
        ArrayList<Instance> iList = new ArrayList<Instance>();
        iList.add(i1);
        iList.add(i2);
        return sharedDomains(iList);
    }

    public ArrayList<Domain> sharedDomains(Concept concept, Instance instance) {
        ArrayList<Domain> domains = new ArrayList<Domain>();
        String[] domainIds = concept.getDomainIds();
        for (int i = 0; i < domainIds.length; i++) {
            Domain d = model.getDomain(domainIds[i]);
            if ((instance.getPoint(domainIds[i]) != null) && (d != null))
                domains.add(d);
        }

        return domains;
    }

    public ArrayList<Domain> sharedDomains(Instance instance, Concept concept) {
        return sharedDomains(concept, instance);
    }

    public ArrayList<Domain> sharedDomains(Concept c1, Concept c2) {
        ArrayList<Domain> domains = new ArrayList<Domain>();
        String[] domainIds = c1.getDomainIds();
        for (int i = 0; i < domainIds.length; i++) {
            Domain d = model.getDomain(domainIds[i]);
            if ((c2.getRegion(domainIds[i]) != null) && (d != null))
                domains.add(d);
        }
        return domains;
    }

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

   // returns weighted distance between two points in a domain
//    public double distance(Point p1, Point p2, QualityDimensionTypeContext context) {
      public double distance(Point p1, Point p2, Context context) {
        if (p1 == null || p2 == null) return -1.0;
        if (context == null) {
//            context = new QualityDimensionTypeContext("__TEMP", p1.getDomainId());
            context = new Context("__TEMP", p1.getDomainId());
            Domain dd = model.getDomain(context.getDomainId());
            String[] qdIds = dd.getQualityDimensionIds();
            for (int i = 0; i < qdIds.length; i++) {
                double value = 1.0 / qdIds.length;
                context.addWeight(qdIds[i], value);
            }
        }
        if (!p1.getDomainId().equals(context.getDomainId())) return -1.0;
        if (!p2.getDomainId().equals(context.getDomainId())) return -1.0;

        Domain d = model.getDomain(context.getDomainId());
        if (d == null) return -1.0;

        double dist = 0.0;

        String[] qdIds = d.getQualityDimensionIds();

        for (int i = 0; i < qdIds.length; i++) {
            QualityDimension qDim = d.getQualityDimension(qdIds[i]);
            double weight = context.getWeight(qdIds[i]);
            double diff = Math.abs(p2.getValue(qdIds[i]) - p1.getValue(qdIds[i]));
            // modify difference if the dimension is circular
            if (qDim.isCircular()) {
                Range r = qDim.getRange();
                double maxDelta = r.getMagnitude() / 2.0;
                if (diff > maxDelta) {
                    diff -= r.getMagnitude();
                }
            }
            dist += weight * diff * diff;
        }

        return Math.sqrt(dist);
    }

    // returns semantic similarity of two instances given domain type and quality dimension type contexts
    // simFunction is one of exponential, gaussian, or linear:
    // 		SIMILARITY_EXPONENTIAL, SIMILARITY_GAUSSIAN, SIMILARITY_LINEAR
    public double semanticSimilarity(String instanceId1, String instanceId2, String domainTypeContextId,
                    String[] qualityDimensionTypeContextIds, int simFunction) //throws InvalidContextTypeException,InvalidInstanceException, InvalidContextException
    {
        Instance i1 = model.getInstance(instanceId1);
        if (i1 == null) throw null;//new InvalidInstanceException();
        Instance i2 = model.getInstance(instanceId2);
        if (i2 == null) throw null;//new InvalidInstanceException();
        Context dContext;
        try {
            dContext = model.getContext(domainTypeContextId);
        } catch (Exception e) {
            dContext = null;
        }
        //if (dContext == null) throw new InvalidContextException();
        if (dContext == null) {
//            dContext = new DomainTypeContext("__TEMP_DC");
            dContext = new Context("__TEMP_DC");
            ArrayList<Domain> domains = sharedDomains(i1, i2);
            for (Domain dd : domains) {
                dContext.addWeight(dd.getId(), 1.0 / domains.size());
            }
        }
        if (dContext.getType() != Context.DOMAIN_TYPE) throw null;//new InvalidContextTypeException();
        ArrayList<Context> qdContexts = new ArrayList<Context>();
        if (qualityDimensionTypeContextIds != null) {
            for (int i = 0; i < qualityDimensionTypeContextIds.length; i++) {
               Context qdContext = model.getContext(qualityDimensionTypeContextIds[i]);
    //           if (qdContext == null) throw new InvalidContextException();
    //           if (qdContext.getType() != Context.QUALITY_DIMENSION_TYPE) throw new InvalidContextTypeException();
                if (qdContext == null) qdContexts.add(null);
                 if (qdContext.getType() != Context.QUALITY_DIMENSION_TYPE) qdContexts.add(null);
                qdContexts.add(qdContext);
             }
        }

        if (i1.equals(i2)) return 0.0;
        ArrayList<Domain> domains = sharedDomains(i1, i2);

        double dist = 0.0;
        for (int i = 0; i < domains.size(); i++) {
            Domain d = domains.get(i);
            double dWeight = dContext.getWeight(d.getId());
            if (dWeight <= 0.0) break;  // don't bother calculating distance if zero, negative weights are invalid
            Point p1 = i1.getPoint(d.getId());
            Point p2 = i2.getPoint(d.getId());
//            QualityDimensionTypeContext qdC = null;
            Context qdC = null;
            for (int q = 0; q < qdContexts.size(); q++) {
//                QualityDimensionTypeContext qdCTest = (QualityDimensionTypeContext) qdContexts.get(q);
                Context qdCTest = (Context) qdContexts.get(q);
                if (qdCTest.getDomainId().equals(d.getId())) {
                    qdC = qdCTest;
                    break;
                }
            }
            if (qdC != null) {
                //double qdNNorm = Math.sqrt(d.numberOfDimensions());
                //double qdDist = distance(p1, p2, qdC);
                //System.out.println("dWeight: "+dWeight);
                //System.out.println("qdNNorm: "+qdNNorm);
                //System.out.println("qdDist : "+qdDist);
                //System.out.println("qdNNorm*qdDist = "+(qdNNorm*qdDist));

                dist += dWeight * Math.sqrt(d.numberOfDimensions()) * distance(p1, p2, qdC);
            } else {
                dist += dWeight * Math.sqrt(d.numberOfDimensions()) * distance(p1, p2, null);
            }
        }

        double similarity = 0.0;
        if (simFunction == SIMILARITY_GAUSSIAN) {
            similarity = Math.exp(-c*dist*dist);
        } else if (simFunction == SIMILARITY_EXPONENTIAL) {
            similarity = Math.exp(-c*dist);
        } else if (simFunction == SIMILARITY_LINEAR) {
            if (dist == 0)
                similarity = Double.POSITIVE_INFINITY;
            else
                similarity = 1.0 / (c * dist);
        }
        return similarity;
    }

    public double semanticSimilarity(String instanceId1, String instanceId2, String domainTypeContextId, String[] qualityDimensionTypeContextIds)
            //throws InvalidContextTypeException, InvalidInstanceException, InvalidContextException
    {
        return semanticSimilarity(instanceId1, instanceId2, domainTypeContextId, qualityDimensionTypeContextIds,
                        SIMILARITY_EXPONENTIAL);
    }

     public Concept learnConceptFromExemplars(String conceptId, ArrayList<Instance> exemplars, ArrayList<Domain> domains) {
        if (domains == null)
            domains = sharedDomains(exemplars);
        Concept concept = new Concept(conceptId);
        for (int i = 0; i < domains.size(); i++) {
            Domain d = domains.get(i);
            ArrayList<Point> points = new ArrayList<Point>();
            for (int j = 0; j < exemplars.size(); j++) {
                Instance ex = exemplars.get(j);
                Point p = ex.getPoint(d.getId());
                if (p != null)
                    points.add(p);
            }
            Region newRegion = convexHull(points, conceptId+"."+d.getId()+"_REGION");
            if (newRegion != null)
                concept.addRegion(newRegion);
        }
        return concept;
    }

    public Concept learnConceptFromExemplars(String conceptId, ArrayList<Instance> exemplars) {
            return learnConceptFromExemplars(conceptId, exemplars, null);
    }

    // use Voronoi tessellation to get regions based on prototype instances for the given domains.
    // If domains is null, the domains are the intersecting domains for all prototypes
    public ArrayList<Concept> conceptsFromPrototypeVoronoi(String baseConceptId, ArrayList<Instance> prototypes,
                    ArrayList<Domain> domains) {
            ArrayList<Concept> concepts = new ArrayList<Concept>();
            if (prototypes == null || prototypes.size() < 2)
                    return concepts;

            // find domains that are specified for every prototype instance
            if (domains == null) {
                    domains = sharedDomains(prototypes);
            }
            // TODO
            return concepts;
    }

    // use Voronoi tessellation to get regions based on prototype instances
    public ArrayList<Concept> conceptsFromPrototypeVoronoi(String baseConceptId, ArrayList<Instance> prototypes) {
            return conceptsFromPrototypeVoronoi(baseConceptId, prototypes, null);
    }

    // returns a region that fills the entire domain
    public Region domainRegion(String domainId) {
        Domain d = model.getDomain(domainId);
        if (d == null) return null;

        Region dRegion = new Region(new String(domainId + ".REGION"), new String(domainId));

        int qdNum = d.numberOfDimensions();
        String[] qdOrder = d.getQualityDimensionIds();
        double[][] newA = new double[qdNum*2][qdNum];
        for (int i = 0; i < newA.length; i++) {
            Arrays.fill(newA[i], 0.0);
        }
        double[] newb = new double[qdNum*2];

        for (int i = 0; i < qdNum; i++) {
            QualityDimension qd = d.getQualityDimension(qdOrder[i]);
            double min = qd.getRange().getMin();
            double max = qd.getRange().getMax();
            newA[i*2][i] = -1.0;
            newA[i*2+1][i] = 1.0;
            newb[i*2] = -min;
            newb[i*2+1] = max;
        }
        dRegion.setRegion(newA, qdOrder, newb);

        return dRegion;
    }

    public Region domainRegion(Domain d) {
        return domainRegion(d.getId());
    }

    public ArrayList<Region> voronoiTessellation(ArrayList<Point> prototypes) {
        if (prototypes == null) return null;
        ArrayList<Region> newRegions = new ArrayList<Region>();
        if (prototypes.size() == 0) return newRegions;

        String domainId = prototypes.get(0).getDomainId();
        Domain domain = model.getDomain(domainId);
        if (domain == null) return null;
        // check that prototype points are consistent with domain
        for (int i = 1; i < prototypes.size(); i++) {
            Point p = prototypes.get(i);
            if (!p.getDomainId().equals(domainId))
                return null;
            else if (!p.domainOK(domain))
                return null;
        }

        String[] qOrder = domain.getQualityDimensionIds();

        if (prototypes.size() == 1) {
            newRegions.add(domainRegion(domainId));
            return newRegions;
        }

        // generate input for qvoronoi
        String qVoronoiInput = "";
        qVoronoiInput += domain.numberOfDimensions() + "\n";
        qVoronoiInput += prototypes.size() + "\n";
        for (int i = 0; i < prototypes.size(); i++) {
            Point p = prototypes.get(i);
            for (int j = 0; j < domain.numberOfDimensions(); j++) {
                double val = p.getValue(qOrder[j]);
                qVoronoiInput += "  " + val;
            }
            qVoronoiInput += "\n";
        }

        String rand;
        String qVoronoiOutputFN;
        File f;

        do {  // find unique random filename
            rand = Long.toHexString(new Random().nextLong());
            qVoronoiOutputFN = new String(tempDir + rand + ".tmp");
            f = new File(qVoronoiOutputFN);
        } while (f.exists());

        try {
            // run qhull
            String[] qVoronoiCmd = {qHullPath, "v", "Qbb", "Qx", "Fs", "Fi", "Fo", "Fv", "TO", qVoronoiOutputFN};
            Process p = Runtime.getRuntime().exec(qVoronoiCmd);

            PrintStream ps = new PrintStream(new BufferedOutputStream(p.getOutputStream()));
            // write H-polytope to qvoronoi
            //System.out.println(qVoronoiInput);
            ps.print(qVoronoiInput);
            ps.close();

            // Set a timer to interrupt the process if it does not return within the timeout period
            Timer timer = new Timer();
            timer.schedule(new InterruptScheduler(Thread.currentThread()), qHullTimeout);
            try {
                    p.waitFor();
            } catch (InterruptedException e) {
                    // Stop the process from running
                    p.destroy();
                    return null;
            }
            finally {
                    // Stop the timer
                    timer.cancel();
            }

            BufferedReader qVoronoiResultFile = new BufferedReader(new FileReader(qVoronoiOutputFN));
            ArrayList<String> qHullResult = new ArrayList<String>();
            String inString;
            while ((inString = qVoronoiResultFile.readLine()) != null) {
                    qHullResult.add(inString);
                    //System.out.println(inString);
            }
            qVoronoiResultFile.close();

            if (qHullResult.size() < 3) return null;

            int numRegions = Integer.parseInt(qHullResult.get(0).trim().split("\\s+")[5]);
            if (numRegions != prototypes.size()) {
                    // TODO
            }
            int numClosedHalfplanes = Integer.parseInt(qHullResult.get(2));
            //System.out.println("numClosed:  "+numClosedHalfplanes);
            int numOpenHalfplanes = Integer.parseInt(qHullResult.get(numClosedHalfplanes+3));
            //System.out.println("numOpen: "+ numOpenHalfplanes);

            String[] newQ = new String[qOrder.length];
            for (int i = 0; i < qOrder.length; i++) {
                    newQ[i] = new String(qOrder[i]);
            }

            for (int i = 0; i < numRegions; i++) {
                // number of regions should equal number of prototypes
                Region newRegion = new Region(prototypes.get(i).getId()+".VORONOI_REGION", domainId);

                ArrayList<double[]> tempA = new ArrayList<double[]>();
                ArrayList<Double> tempb = new ArrayList<Double>();

                for (int j = 3; j < numClosedHalfplanes + 3; j++) {
                    String[] resultLine = qHullResult.get(j).trim().split("\\s+");
                    if (Integer.parseInt(resultLine[1]) == i) {
                        double[] aRow = new double[newQ.length];
                        double bVal;
                        for (int n = 3; n < resultLine.length-1; n++) {
                            aRow[n-3] = Double.parseDouble(resultLine[n]);
                        }
                        bVal = -Double.parseDouble(resultLine[resultLine.length-1]);
                        tempA.add(aRow);
                        tempb.add(bVal);
                    } else if (Integer.parseInt(resultLine[2]) == i) {
                        double[] aRow = new double[newQ.length];
                        double bVal;
                        for (int n = 3; n < resultLine.length-1; n++) {
                            aRow[n-3] = -Double.parseDouble(resultLine[n]);
                        }
                        bVal = Double.parseDouble(resultLine[resultLine.length-1]);
                        tempA.add(aRow);
                        tempb.add(bVal);
                    }
                }

                for (int j = 4 + numClosedHalfplanes; j < numClosedHalfplanes + 4 + numOpenHalfplanes; j++) {
                    String[] resultLine = qHullResult.get(j).trim().split("\\s+");
                    if (Integer.parseInt(resultLine[1]) == i) {
                        double[] aRow = new double[newQ.length];
                        double bVal;
                        for (int n = 3; n < resultLine.length-1; n++) {
                            aRow[n-3] = Double.parseDouble(resultLine[n]);
                        }
                        bVal = -Double.parseDouble(resultLine[resultLine.length-1]);
                        tempA.add(aRow);
                        tempb.add(bVal);
                    } else if (Integer.parseInt(resultLine[2]) == i) {
                        double[] aRow = new double[newQ.length];
                        double bVal;
                        for (int n = 3; n < resultLine.length-1; n++) {
                            aRow[n-3] = -Double.parseDouble(resultLine[n]);
                        }
                        bVal = Double.parseDouble(resultLine[resultLine.length-1]);
                        tempA.add(aRow);
                        tempb.add(bVal);
                    }
                }

                double[][] newA = new double[tempA.size()][newQ.length];
                double[] newB = new double[tempb.size()];
                for (int j = 0; j < newA.length; j++) {
                    newA[j] = tempA.get(j);
                    newB[j] = tempb.get(j);
                }

                newRegion.setq(newQ);
                newRegion.setA(newA);
                newRegion.setb(newB);

                newRegions.add(newRegion);
            }
        } catch (IOException e) {
            // TODO
            return null;
        }

        // delete qvoronoi temp file
        if (f.exists())
            f.delete();

        return newRegions;
    }

    // return convex region from convex hull of input points
    public Region convexHull(ArrayList<Point> points, String newRegionId) {
        Region newRegion = null;
        if (points == null || points.size() == 0) return null;

        // test that all points are from same domain
        String domainId = new String(points.get(0).getDomainId());
        for (int i = 0; i < points.size(); i++) {
            Point p = points.get(i);
            if (!p.getDomainId().equals(domainId)) return null;
        }

        Domain domain = model.getDomain(domainId);

        // number of points must be at least # of dimensions in domain + 1
        if (points.size() < domain.numberOfDimensions() + 1) return null;

        String[] qDims = domain.getQualityDimensionIds();
        double[][] pointValues = new double[points.size()][qDims.length];
        double[] midpoint = new double[qDims.length];

        for (int i = 0; i < points.size(); i++) {
            for (int j = 0; j < qDims.length; j++) {
                pointValues[i][j] = points.get(i).getValue(qDims[j]);
            }
        }

        // if # dimensions == 1
        if (qDims.length == 1) {
            double[] sorted = new double[pointValues.length];
            for (int i = 0; i < pointValues.length; i++)
                    sorted[i] = pointValues[i][0];
            Arrays.sort(sorted);
            double min = sorted[0];
            double max = sorted[sorted.length-1];
            double sum = 0.0;
            for (int i = 0; i < sorted.length; i++) {
                sum += sorted[i];
            }
            midpoint[0] = sum / sorted.length;

            newRegion = new Region(newRegionId, domainId);
            newRegion.setq(qDims);
            double[][] aMatrix = { { 1.0 }, { -1.0 } };
            newRegion.setA(aMatrix);
            double[] bVector = { max, -min };
            newRegion.setb(bVector);
            newRegion.setCentroid(midpoint);
        } else {  // if # dimensions > 1 call qhull program
            String rand;
            String qHullOutput;
            File f;

            do {  // find unique random filename
                    rand = Long.toHexString(new Random().nextLong());
                    qHullOutput = new String(tempDir + rand + ".tmp");
                    f = new File(qHullOutput);
            } while (f.exists());

            try {
                // run qhull
                String[] qHull = {qHullPath, "FV", "n", "TO", qHullOutput};
                Process p = Runtime.getRuntime().exec(qHull);

                PrintStream ps = new PrintStream(new BufferedOutputStream(p.getOutputStream()));
                ps.println(qDims.length);
                ps.println(points.size());
                for (int i = 0; i < points.size(); i++) {
                    for (int j = 0; j < qDims.length; j++) {
                        ps.print(pointValues[i][j]);
                        if (j < qDims.length - 1)
                            ps.print(" ");
                    }
                    ps.println();
                }
                ps.close();

                // Set a timer to interrupt the process if it does not return within the timeout period
                Timer timer = new Timer();
                timer.schedule(new InterruptScheduler(Thread.currentThread()), qHullTimeout);
                try {
                    p.waitFor();
                } catch (InterruptedException e) {
                    // Stop the process from running
                    p.destroy();
                    return null;
                }
                finally {
                    // Stop the timer
                    timer.cancel();
                }

                BufferedReader qHullResultFile = new BufferedReader(new FileReader(qHullOutput));
                String inString;
                ArrayList<String> qHullResult = new ArrayList<String>();
                while ((inString = qHullResultFile.readLine()) != null) {
                    qHullResult.add(inString);
                }
                qHullResultFile.close();

                if (qHullResult.size() < 5) return null;
                String[] midpointStrs = qHullResult.get(1).trim().split("\\s+");
                for (int i = 0; i < midpoint.length; i++) {
                    midpoint[i] = Double.parseDouble(midpointStrs[i]);
                }
                int cols = Integer.parseInt(qHullResult.get(2).trim());
                int halfplaneNum = Integer.parseInt(qHullResult.get(3).trim());
                double[][] aMatrix = new double[halfplaneNum][cols-1];
                double[] bVector = new double[halfplaneNum];
                for (int i = 4; i < halfplaneNum + 4; i++) {
                    String[] rowVals = qHullResult.get(i).trim().split("\\s+");
                    for (int j = 0; j < rowVals.length - 1; j++) {
                        aMatrix[i-4][j] = Double.parseDouble(rowVals[j]);
                    }
                    bVector[i-4] = -Double.parseDouble(rowVals[rowVals.length - 1]);
                }
                newRegion = new Region(newRegionId, domainId);
                newRegion.setq(qDims);
                newRegion.setA(aMatrix);
                newRegion.setb(bVector);
                newRegion.setCentroid(midpoint);
            } catch (IOException e) {
                return null;
            }

            // delete the qhull temp file
            if (f.exists())
                f.delete();
        }

        return newRegion;
    }

     public boolean samePoint(Point p1, Point p2) {
        if (p1 == p2) return true;
        if (p1 == null || p2 == null) return false;
        if (p1.equals(p2)) return true;
        String domainId = p1.getDomainId();
        if (domainId == null) return false;
        Domain d = model.getDomain(domainId);
        if (d == null) return false;
        if (!p1.getDomainId().equals(p2.getDomainId())) return false;

        String[] qdIds = d.getQualityDimensionIds();
        for (int i = 0; i < qdIds.length; i++) {
            if (!equalWithinPrecision(p1.getValue(qdIds[i]), p2.getValue(qdIds[i])))
                return false;
        }
        return true;
    }

    // returns true if the two instances have the same points for each of the given domains
    public boolean sameInstance(Instance i1, Instance i2, ArrayList<String> domainIds) {
        for (int i = 0; i < domainIds.size(); i++) {
            Point p1 = i1.getPoint(domainIds.get(i));
            Point p2 = i2.getPoint(domainIds.get(i));
            if (!samePoint(p1, p2))
                return false;
        }
        return true;
    }

    // returns true if the two instances have the same points for all shared domains
    public boolean sameInstance(Instance i1, Instance i2) {
        ArrayList<Domain> domains = sharedDomains(i1, i2);
        ArrayList<String> domainIds = new ArrayList<String>();
        for (int i = 0; i < domains.size(); i++) {
            domainIds.add(domains.get(i).getId());
        }
        return sameInstance(i1, i2, domainIds);
    }

    // returns true if region r contains point p
    public boolean contains(Region r, Point p) {
        if (r == null || p == null) return false;
        String domainId = r.getDomainId();
        // point and region must be in same domain
        if (domainId == null || !r.getDomainId().equals(p.getDomainId())) return false;
        Domain d = model.getDomain(domainId);
        // domain must exist in model
        if (d == null) return false;
        // region and point must be consistent with domain
        if (!r.domainOK(d) || !p.domainOK(d)) return false;

        return r.contains(p, d, roundPrecision);
    }

    // returns true if region r1 contains region r2 (i.e. r2's convex hull points) completely
    public boolean contains(Region r1, Region r2) {
        Point[] hullPoints = r2.getVPolytope();
        if (hullPoints == null) hullPoints = vPolytope(r2);
        if (hullPoints == null) return false;
        for (int i = 0; i < hullPoints.length; i++) {
            if (!contains(r1, hullPoints[i])) return false;
        }
        return true;
    }

    // returns true if concept c contains instance i for the given domains
    public boolean contains(Concept concept, Instance instance, ArrayList<Domain> domains) {
        return concept.contains(instance, domains.toArray(new Domain[0]));
    }

    // returns true if concept c contains instance i for all shared domains
    public boolean contains(Concept concept, Instance instance) {
        return contains(concept, instance, sharedDomains(concept, instance));
    }

    // gets the V-polytope representation of a region as a set of points
    // also sets the vPolytope in the region data structure, so that it does not need to be calculated again
    public Point[] vPolytope(Region r) {
        Point[] points = null;

        if (r.getCentroidAsPoint() != null) {
            String qHullInput = r.qHullFormat();

            String rand;
            String qHullOutputFN;
            File f;

            do {  // find unique random filename
                rand = Long.toHexString(new Random().nextLong());
                qHullOutputFN = new String(tempDir + rand + ".tmp");
                f = new File(qHullOutputFN);
            } while (f.exists());

            try {
                // run qhull
                String[] qHull = {qHullPath, "H", "Fp", "TO", qHullOutputFN};
                Process p = Runtime.getRuntime().exec(qHull);

                PrintStream ps = new PrintStream(new BufferedOutputStream(p.getOutputStream()));
                // write H-polytope to qhull
                ps.print(qHullInput);
                ps.close();

                // Set a timer to interrupt the process if it does not return within the timeout period
                Timer timer = new Timer();
                timer.schedule(new InterruptScheduler(Thread.currentThread()), qHullTimeout);
                try {
                    p.waitFor();
                } catch (InterruptedException e) {
                    // Stop the process from running
                    p.destroy();
                    return null;
                }
                finally {
                    // Stop the timer
                    timer.cancel();
                }

                BufferedReader qHullResultFile = new BufferedReader(new FileReader(qHullOutputFN));
                ArrayList<String> qHullResult = new ArrayList<String>();
                String inString;
                while ((inString = qHullResultFile.readLine()) != null) {
                    qHullResult.add(inString);
                }
                qHullResultFile.close();

                if (qHullResult.size() < 3) return null;
                int qLength = Integer.parseInt(qHullResult.get(0));
                if (qLength != r.getq().length) return null;

                int numPoints = Integer.parseInt(qHullResult.get(1));
                points = new Point[numPoints];
                for (int i = 0; i < numPoints; i++) {
                    String row = qHullResult.get(i+2);
                    String[] rowVals = row.trim().split("\\s+");
                    points[i] = new Point(new String(r.getId()+".VPOLYTOPE_"+i), new String(r.getDomainId()));
                    String[] pointQ = new String[qLength];
                    for (int j = 0; j < qLength; j++) {
                        pointQ[j] = new String(r.getq()[j]);
                    }
                    double[] pointV = new double[qLength];
                    for (int j = 0; j < rowVals.length; j++) {
                        pointV[j] = Double.parseDouble(rowVals[j]);
                    }
                    points[i].setPoint(pointQ, pointV);
                }
            } catch (IOException e) {
                // TODO
                return null;
            }

            // delete qhull temp file
            if (f.exists())
                f.delete();
        }

        r.setVPolytope(points);
        return points;
    }

    // calculates v polytope for region r and stores the result in the r object
    // returns true if successful
    public boolean setVPolytope(Region r) {
        Point[] pts = vPolytope(r);
        if (pts == null) return false;
        else return true;
    }

    public boolean standardizeInstancesInDomain(String domainId){
        Domain d = model.getDomain(domainId);
        String[] qIds = d.getQualityDimensionIds();
        Instance[] instances = model.getInstances();

        ArrayList<ArrayList<Pair<String,Double>>> pointValues = new ArrayList<ArrayList<Pair<String,Double>>>();

        // create a table column for each quality dimension
        for (String qId : qIds) {
            pointValues.add(new ArrayList<Pair<String,Double>>());
        }

        for (Instance i : instances) {
            if (i.hasPointInDomain(domainId)) {
                for (int q = 0; q < qIds.length; q++) {
                    // add the quality dimension value for the point
                    pointValues.get(q).add(new Pair<String,Double>(i.getId(),i.getPoint(domainId).getValue(qIds[q])));
                }
            }
        }
        for (int q = 0; q < qIds.length; q++) {
            ArrayList<Pair<String,Double>> row = pointValues.get(q);
            ArrayList<Double> rowVals = new ArrayList<Double>();
            for (int i = 0; i < row.size(); i++) {
                rowVals.add(row.get(i).getSecond());
            }
            Pair<Double,Double> meanSD = MathFunc.meanStddev(rowVals);
            for (int i = 0; i < row.size(); i++) {
                double score = MathFunc.standardScore(rowVals, i, meanSD);
                Instance inst = model.getInstance(row.get(i).getFirst());
                Point p = inst.getPoint(domainId);
                // update the value of the point with the standard score value
                p.updateValue(qIds[q], score);
            }
        }

        return true;
    }

    public boolean standardizeInstancesInAllDomains() {
        Domain[] domains = model.getDomains();
        for (Domain d : domains) {
            standardizeInstancesInDomain(d.getId());
        }
        return true;
    }

    private boolean equalWithinPrecision(double x, double y) {
        if (Math.abs(x - y) < roundPrecision)
            return true;
        else
            return false;
    }

    private class InterruptScheduler extends TimerTask
    {
        Thread target = null;
        public InterruptScheduler(Thread target) {
            this.target = target;
        }

        @Override
        public void run()
        {
            target.interrupt();
        }
    }

}


text:
<?php
namespace codeception\Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

class Acceptance extends \Codeception\Module
{

}


text:
package net.tortuga.level.program.tiles.stones;

import net.tortuga.level.TurtleController;
import net.tortuga.level.TurtleRuntimeEnvironment;
import net.tortuga.level.program.tiles.*;

import com.porcupine.color.RGB;
import com.porcupine.coord.CoordI;

public class StoneMathSet extends ProgTileStone {

	@Override
	public boolean acceptsGrainTop(EGrainType grainType)
	{
		return grainType == EGrainType.NUMBER || grainType == EGrainType.VAR;
	}

	@Override
	public boolean acceptsGrainBottom(EGrainType grainType)
	{
		return grainType == EGrainType.VAR;
	}

	@Override
	public EGrainSlotMode getGrainModeTop()
	{
		return EGrainSlotMode.REQUIRED;
	}

	@Override
	public EGrainSlotMode getGrainModeBottom()
	{
		return EGrainSlotMode.REQUIRED;
	}

	@Override
	public CoordI getOverlayIndex()
	{
		return StoneTx.MATH_SET;
	}

	@Override
	public RGB getStoneColor()
	{
		return StoneColors.MATH;
	}

	@Override
	public void execute(ProgTileGrain topGrain, ProgTileGrain bottomGrain, TurtleRuntimeEnvironment tre, TurtleController tc)
	{
		int valIn;

		int outVar = bottomGrain.getVariant();

		if (topGrain.getGrainType() == EGrainType.VAR) {
			valIn = tre.getVariable(topGrain.getVariant());
		} else {
			valIn = topGrain.getExtraNumber();
		}

		outVar = bottomGrain.getVariant();

		tre.setVariable(outVar, valIn);

	}
}


text:
(function(module) {
  'use strict';

  var user = module.parent.require('./user'),
      meta = module.parent.require('./meta'),
      db = module.parent.require('../src/database'),
      passport = module.parent.require('passport'),
      passportClientCert = require('passport-client-cert').Strategy,
      nconf = module.parent.require('nconf'),
      async = module.parent.require('async'),
      winston = module.parent.require('winston'),
      changeCase = require('change-case'),
      fs = require('fs'),
      openssl = require('openssl-wrapper');

  var constants = Object.freeze({
    'name': 'client-cert',
    'icon': 'icon-client-cert-auth'
  });

  // TODO: make a settings page in the Admin CP to configure these
  // and success/failure URLs.
  const CA_CNS = ['ESTEID-SK 2007', 'ESTEID-SK 2011'];
  const CERTS_TEMP_FOLDER = 'certs/temp/';
  const OCSP_URL = 'http://ocsp.sk.ee';
  const OCSP_INFO = {
    'ESTEID-SK 2007': {
      CA_CERT_FILE: 'certs/ESTEID-SK_2007.crt',
      OCSP_SERVER_CERT_FILE: 'certs/ESTEID-SK_2007_OCSP_RESPONDER_2010.crt'
    },
    'ESTEID-SK 2011': {
      CA_CERT_FILE: 'certs/ESTEID-SK_2011.crt',
      OCSP_SERVER_CERT_FILE: 'certs/SK_OCSP_RESPONDER_2011.crt'
    }
  };

  var ClientCert = {};

  function verify(req, cert, done) {
    var subject = cert.subject ? cert.subject : {CN: undefined, GN: undefined, SN: undefined};
    var subjectCommonName = subject.CN ? subject.CN : req.headers.ssl_client_s_dn_cn;

    var issuer = cert.issuer ? cert.issuer : {CN: undefined};
    var issuerCommonName = issuer.CN ? issuer.CN : req.headers.ssl_client_i_dn_cn;

    if (!subject) {
      winston.error('[sso-client-cert] Client Certificate Subject missing!');
      return done(null, false);
    } else if (!subjectCommonName) {
      winston.error('[sso-client-cert] Client Certificate Subject CN missing!');
      return done(null, false);
    }

    if (CA_CNS.indexOf(issuerCommonName) === -1) {
      winston.error('[sso-client-cert] Client Certificate Issuer CN invalid: ' + issuerCommonName +
          '. Subject CN: ' + subjectCommonName);

      return done(null, false);
    }

    OCSPCheck(cert, subjectCommonName, issuerCommonName, done, function() {
      if (req.hasOwnProperty('user') && req.user.hasOwnProperty('uid') && req.user.uid > 0) {
        // Save cert CN to the user
        user.setUserField(req.user.uid, 'certcn', subjectCommonName);
        db.setObjectField('certcn:uid', subjectCommonName, req.user.uid);
        return done(null, req.user);
      }

      var subjectGivenName = subject.GN ? subject.GN : req.headers.ssl_client_s_dn_g;
      var subjectSurname = subject.SN ? subject.SN : req.headers.ssl_client_s_dn_s;
      var firstName = changeCase.titleCase(subjectGivenName);
      var lastName = changeCase.titleCase(subjectSurname);
      var userName = firstName + ' ' + lastName;
      var email = "";

      if (cert.subjectaltname) {
        email = cert.subjectaltname.split('email:')[1];
      }

      ClientCert.login(subjectCommonName, userName, email, function(err, user) {
        if (err) {
          return done(err);
        }

        done(null, user);
      });
    });
  }

  function OCSPCheck(cert, subjectCommonName, issuerCommonName, done, callback) {
    var certFile = CERTS_TEMP_FOLDER + subjectCommonName + '.crt';

    fs.writeFile(certFile, cert, function(err) {
      if (err) return done(err);

      openssl.exec('ocsp', {
        url: OCSP_URL,
        issuer: OCSP_INFO[issuerCommonName].CA_CERT_FILE,
        VAfile: OCSP_INFO[issuerCommonName].OCSP_SERVER_CERT_FILE,
        cert: certFile
      }, function(err, buffer) {
        fs.unlink(certFile);

        if (err.indexOf & err.indexOf('Response verify OK') === -1) {
          return done(err);
        }

        var response = buffer.toString();

        if (response.indexOf('good') === -1) {
          winston.error('[sso-client-cert] Client Certificate OCSP check failed! CN: ' + subjectCommonName);
          return done(null, false);
        } else {
          return callback();
        }
      });
    });
  }

  ClientCert.getStrategy = function(strategies, callback) {
    passport.use(constants.name, new passportClientCert({
      passReqToCallback: true,
      successReturnToOrRedirect: '/',
      failureRedirect: '/client-cert-auth-error'
    }, verify));

    strategies.push({
      name: 'client-cert',
      url: '/auth/client-cert',
      callbackURL: '/',
      icon: constants.icon
    });

    callback(null, strategies);
  };

  ClientCert.getAssociation = function(data, callback) {
    user.getUserField(data.uid, 'certcn', function(err, CN) {
      if (err) {
        return callback(err, data);
      }

      if (CN) {
        data.associations.push({
          associated: true,
          name: constants.name,
          icon: constants.icon
        });
      } else {
        data.associations.push({
          associated: false,
          url: nconf.get('url') + '/auth/client-cert',
          name: constants.name,
          icon: constants.icon
        });
      }

      callback(null, data);
    })
  };

  ClientCert.login = function(CN, userName, email, callback) {
    ClientCert.getUidByCertCN(CN, function(err, uid) {
      if(err) {
        return callback(err);
      }

      if (uid !== null) {
        // Existing User
        callback(null, {
          uid: uid
        });
      } else {
        // New User
        var success = function(uid) {
          // Save cert CN to the user
          user.setUserField(uid, 'certcn', CN);
          db.setObjectField('certcn:uid', CN, uid);
          user.setUserField(uid, 'email:confirmed', 0); // TODO: Add option to configure in Admin CP

          callback(null, {
            uid: uid
          });
        };

        user.getUidByEmail(email, function(err, uid) {
          if(err) {
            return callback(err);
          }

          if (!uid) {
            user.create({username: userName, email: email}, function(err, uid) {
              if(err) {
                return callback(err);
              }

              success(uid);
            });
          } else {
            success(uid); // Existing account -- merge
          }
        });
      }
    });
  };

  ClientCert.getUidByCertCN = function(CN, callback) {
    db.getObjectField('certcn:uid', CN, function(err, uid) {
      if (err) {
        return callback(err);
      }
      callback(null, uid);
    });
  };

  ClientCert.deleteUserData = function(data, callback) {
    var uid = data.uid;

    async.waterfall([
      async.apply(user.getUserField, uid, 'certcn'),
      function(CNToDelete, next) {
        db.deleteObjectField('certcn:uid', CNToDelete, next);
      }
    ], function(err) {
      if (err) {
        winston.error('[sso-client-cert] Could not remove cert CN for uid ' + uid + '. Error: ' + err);
        return callback(err);
      }
      callback(null, uid);
    });
  };

  module.exports = ClientCert;
}(module));


text:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Suite1" verbose="1" >
    <test name="Groups" >
        <classes>
            <class name="test.addressbook.pack.tests.AddGroupTest" />
            <class name="test.addressbook.pack.tests.EditGroupTest" />
            <class name="test.addressbook.pack.tests.DeleteGroupTest" />
        </classes>
    </test>
</suite>


text:
struct quadratic_params
  {
    double a, b, c;
  };

double quadratic (double x, void *params);
double quadratic_deriv (double x, void *params);
void quadratic_fdf (double x, void *params,
                    double *y, double *dy);


text:
using ManagedDns.Internal.Extensions;
using Xunit;

namespace ManagedDns.Tests.Internals.ExtensionTests
{
    public class ToLittleEndianExtensions
    {
        [Fact]
        public void BeUShortToLeUShort()
        {
            Assert.Equal((ushort)24, new byte[] { 0, 24 }.ToLeUShort());
            Assert.Equal((ushort)12015, new byte[] { 46, 239 }.ToLeUShort());
        }

        [Fact]
        public void BeUIntToLeUInt()
        {
            Assert.Equal((uint)24, new byte[] { 0, 0, 0, 24 }.ToLeUInt());
            Assert.Equal((uint)12015, new byte[] { 0, 0, 46, 239 }.ToLeUInt());
        }
    }
}


text:
{% extends "templates/layout.html" %}

{% block page_title %}
  NHS Medicines alpha
{% endblock %}

{% block content %}

Paracetamol

Interactions

What to avoid with paracetamol

Beware of paracetamol contained within other medicines.

      You should not exceed the total recommended dose.

Warfarin

Avoid regular use of paracetamol and discuss your options with your doctor if you are taking warfarin.
      Occasional use of paracetamol should not significantly affect its performance.

Epilepsy and tuberculosis medication

Talk to your doctor if you are taking medicines for epilepsy or tuberculosis, as this may mean that you should take lower doses of paracetamol.

St John's wort

You should check with your doctor or pharmacist if you are taking St John's wort as it may be necessary to reduce your paracetamol dose.

Alcohol

If you regularly drink more than the recommended amount of alcohol you should speak to your GP before taking paracetamol.

            Previous page:
            Interactions

{% endblock %}


text:
[![Circle CI](https://circleci.com/gh/afolson/pastewin/tree/master.svg?style=svg)](https://circleci.com/gh/afolson/lolbin/tree/master)

It's Yet Another Pastebin that does SUPER AWESOME THINGS like:

- Allow you to use cURL to create pastes (WOW!)
- Allow you to view pastes (HOLY STEAKNUGGETS!)
- Allow you to delete pastes (SWEET MOTHER OF CRAP!)
- Use UUIDs so HACKERS can't guess your pastes (because security through obscurity is best security!)

I'm not sure what you expected, but if it wasn't sarcasm I don't even know you right now.

## Install This

You know what to do (but in case you don't):

- Check this thing out from over yonder -->
- `composer selfupdate` because you know you haven't in a while
- `composer install`
- `npm install`
- Create your .env file
- `php artisan migrate`
- `php -S 127.0.0.1:9090 -t public/`

### License

The Lumen framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

To make stuff easy, Pastewin is also licensed under said. [TL;DR Legal](https://tldrlegal.com/license/mit-license)


text:
<?php
namespace Concrete\Core\Attribute;

use Concrete\Core\Entity\Attribute\Key\Key;
use Concrete\Core\Database\Schema\BuilderInterface;
use Doctrine\ORM\Mapping\Builder\AssociationBuilder;
use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder;

class AttributeKeyMappingFieldBuilder implements BuilderInterface
{
    protected $key;
    public function __construct(Key $key)
    {
        $this->key = $key;
    }

    public function build(ClassMetadataBuilder $builder)
    {
        $class = $this->key->getAttributeKeyType()->getAttributeValue();
        $namingStrategy = \Core::make('Concrete\Core\Express\NamingStrategy');
        $associationBuilder = new AssociationBuilder($builder,
            array(
                'fieldName' => $this->key->getAttributeKeyHandle(),
                'targetEntity' => get_class($class),
            ),
            \Doctrine\ORM\Mapping\ClassMetadata::ONE_TO_ONE
        );
        $associationBuilder->cascadeAll();
        $associationBuilder->addJoinColumn(
            $namingStrategy->joinColumnName($this->key->getAttributeKeyHandle()),
            'avID'
        );

        return $associationBuilder->build();
    }
}