text:
<?php
define('CHANNEL_DOTEY_SORT_LIVETIME_SUPER',1);	//按直播总时长排序
define('CHANNEL_DOTEY_SORT_RANK',2);			//按主播等级排序
define('CHANNEL_DOTEY_SORT_STARTTIME',3);		//按最新开播时间排序
define('CHANNEL_DOTEY_SORT_SONGS_YESTERDAY',4);	//按昨日点唱榜排序
define('CHANNEL_DOTEY_SORT_CHARMS_YESTERDAY',5);//按昨日魅力榜排序
define('CHANNEL_DOTEY_SORT_CHARMS_SUPER',6);	//按主播超级魅力值排序
define('CHANNEL_DOTEY_SORT_SORT',7);			//用户自定义排序
define('CHANNEL_DOTEY_SORT_USER_TOTAL',8);		//按直播在线人数排序
define('CHANNEL_DOTEY_SORT_WAIT_STARTTIME',9);	//待直播按直播预告的开始时间排序

/**
 * 主播频道排序
 *
 * the last known user to change this file in the repository  <$LastChangedBy: hexin $>
 * @author Su qian <suqian@pipi.cn>
 * @version $Id: ChannelDoteySortService.php 17803 2014-01-23 08:22:25Z hexin $
 * @package
 */
class ChannelDoteySortService extends PipiService {
	/**
	 *
	 * @var string 正在排序的字段
	 */
	private $sortingField = '';

	/**
	 * 暂存数据
	 * @var array
	 */
	private $localCache = array();
	/**
	 * 取得主播时段统计
	 *
	 * @param array $uids
	 * @param string $field
	 * @return array
	 */
	public function getDoteyPeriodCountByUids(array $uids,$field='*'){
		if(empty($uids)){
			return $this->setError(Yii::t('common','Parameter is empty'),array());
		}

		$doteyPeriodModel = new DoteyPeriodCountModel();
		$periods = $doteyPeriodModel->getDoteyPeriodCountByUids($uids,$field);
		$periods = $this->arToArray($periods);
		return $this->buildDataByIndex($periods,'uid');
	}

   /**
	 * 生成直播档期的时间
	 *
	 * @param array $liveArchives
	 * @param int $return 0表示返回所有 1表示返回正在直播的 2表示返回待直播的
	 * @author suqian
	 * @return array
	 */
	public function buildLiveArchives(array &$archives,$loginUid = 0,$return = 0,$ifHasDotey = false,$ifHasAttention = false){
		if(empty($archives)){
			return array();
		}
		$timeStamp  = time();
		$uids = array_keys($this->buildDataByIndex($archives,'uid'));
		$lives = $doteys = $attentions = array();
		if($ifHasDotey){
			$doteyService = new DoteyService();
			if(is_array($ifHasDotey)){
				$doteys = $ifHasDotey;
			}else{
				$doteys = $doteyService->getDoteyInfoByUids($uids);
			}
		}
		if($ifHasAttention && $loginUid){
			$weiboService = new WeiboService();
			$attentions = $weiboService->getDoteyAttentionsByUid($loginUid);
			$attentions = $this->buildDataByIndex($attentions,'uid');
		}
		$lives = array();
		foreach($archives as $key=>$archive){
			$lives[$key]['live_time'] = $archive['live_record']['live_time'];
			$lives[$key]['start_time'] = $archive['live_record']['start_time'];
			$lives[$key]['status'] = $archive['live_record']['status'];
			$lives[$key]['sub_title'] = $archive['live_record']['sub_title'];
			$lives[$key]['title'] = $archive['title'];
			$lives[$key]['uid'] = $archive['uid'];
			$lives[$key]['archives_id'] = $archive['archives_id'];
			if($ifHasDotey && isset($doteys[$archive['uid']])){
				$dotey = $doteys[$archive['uid']];
				$updateDesc = isset($dotey['update_desc']) && is_array($dotey['update_desc']) ? $dotey['update_desc'] : array();
				$lives[$key]['display_small'] = $doteyService->getDoteyUpload($archive['uid'],'small','display',$updateDesc);
				$lives[$key]['display_big'] = $doteyService->getDoteyUpload($archive['uid'],'big','display',$updateDesc);
				//是否唱区主播
				$lives[$key]['sing_area'] = $this->hasMoreBit((int)$dotey['sub_channel'],1);
				if(isset($archive['today_recommand']))
				{
					$lives[$key]['today_recommand']=$archive['today_recommand'];
				}
			}

			if($ifHasAttention){
				if(isset($attentions[$archive['uid']])){
					$lives[$key]['is_attention'] = 1;
				}else{
					$lives[$key]['is_attention'] = 0;
				}
			}

			$lives[$key]['live_desc'] = PipiDate::getLastDate((int)$archive['live_record']['live_time'],$timeStamp,'Y-m-d H:i');
			$lives[$key]['start_desc'] = PipiDate::getFurtureDate((int)$archive['live_record']['start_time'],$timeStamp,'Y-m-d H:i');
		}

		$archives = $lives;
		return $lives;
	}

	/**
	 * 排序值播的档期 包括正在直播的或者待直播的
	 *
	 * @param array $liveArchives 直播记录
	 * @param int $sortMethod 主播排序方法
	 * @return int $return 0表示返回所有 1表示返回正在直播的 2表示返回待直播的
	 * @return boolean $isSort 是否排序 true表示排序  false表示不排序
	 * @author suqian
	 * @return array
	 */
	public function sortLiveArchives(array $liveArchives,$sortMethod = CHANNEL_DOTEY_SORT_STARTTIME,$return = 0,$isSort = true){
		if(empty($liveArchives)){
			return array();
		}
		$newData = array('living' => array(), 'wait' => array());
		if(isset($liveArchives['living']) && isset($liveArchives['wait'])){
			$newData['living'] = $liveArchives['living'];
			$newData['wait'] = $liveArchives['wait'];
		}else{
			foreach($liveArchives as $key=>$archive){
				if($archive['status'] == 1){
					$newData['living'][$key] = $archive;
				}elseif($archive['status'] == 0){
					$newData['wait'][$key] = $archive;
				}
			}
		}

		if($isSort === false){
			return $newData;
		}

		$this->localCache = array();
		$newData['living'] = $this->sortArchives($newData['living'], $sortMethod);
		if($sortMethod == CHANNEL_DOTEY_SORT_STARTTIME) $sortMethod = CHANNEL_DOTEY_SORT_WAIT_STARTTIME;
		$newData['wait'] = $this->sortArchives($newData['wait'], $sortMethod);
		return $newData;
	}

	/**
	 * 排序档期,只负责排序,不改变数据的结构
	 *
	 * @param array $archives 直播记录
	 * @param int $sortMethod 主播排序方法
	 * @author hexin
	 * @return array
	 */
	private function sortArchives(array &$archives,$sortMethod = CHANNEL_DOTEY_SORT_STARTTIME){
		if(empty($archives)) return array();
		$periodDefines = array(
			CHANNEL_DOTEY_SORT_CHARMS_YESTERDAY,
			CHANNEL_DOTEY_SORT_LIVETIME_SUPER,
			CHANNEL_DOTEY_SORT_SONGS_YESTERDAY,
		);
		//需要取得主播区段统计数据的排序
		if(in_array($sortMethod,$periodDefines)){
			$this->sortingField = $this->sortMapDbPeiordFiled($sortMethod);
			if(isset($this->localCache['doteyPeriods'])) $doteyPeriods = $this->localCache['doteyPeriods'];
			else{
				$uids = array_keys($this->buildDataByIndex($archives,'uid'));
				$doteyPeriods = $this->getDoteyPeriodCountByUids($uids,$this->sortingField);
				$this->localCache['doteyPeriods'] = $doteyPeriods;
			}
			foreach($archives as $key=>$archive){
				$uid = $archive['uid'];
				if(isset($doteyPeriods[$uid])){
					$archive[$this->sortingField] = $doteyPeriods[$uid][$this->sortingField];
				}else{
					$archive[$this->sortingField] = 0;
				}
			}
		//需要取得主播等级数据的排序
		}elseif($sortMethod == CHANNEL_DOTEY_SORT_RANK){
			$this->sortingField = $this->sortMapDbPeiordFiled($sortMethod);
			if(isset($this->localCache['consumes'])) $consumes = $this->localCache['consumes'];
			else{
				$uids = array_keys($this->buildDataByIndex($archives,'uid'));
				$consumeService = new ConsumeService();
				$consumes = $consumeService->getConsumesByUids($uids);
				$this->localCache['consumes'] = $consumes;
			}
			foreach($archives as $key=>$archive){
				$uid = $archive['uid'];
				if(isset($consumes[$uid])){
					$archive[$this->sortingField] = $consumes[$uid][$this->sortingField];
				}else{
					$archive[$this->sortingField] = 0;
				}
			}
		}

		if($sortMethod == CHANNEL_DOTEY_SORT_STARTTIME)
			usort($archives,array($this,'sortLivingArchivesByTimes'));
		elseif($sortMethod == CHANNEL_DOTEY_SORT_WAIT_STARTTIME)
			usort($archives,array($this,'sortWaitArchivesByTimes'));
		elseif(in_array($sortMethod,$periodDefines))
			usort($archives,array($this,'sortLiveArchivesByPeriod'));
		elseif($sortMethod == CHANNEL_DOTEY_SORT_RANK)
			usort($archives,array($this,'sortLiveArchivesByPeriod'));
		elseif($sortMethod == CHANNEL_DOTEY_SORT_SORT)
			usort($archives,array($this,'sortLiveArchivesByPeriod'));
		elseif($sortMethod == CHANNEL_DOTEY_SORT_USER_TOTAL)
			usort($archives,array($this,'sortUserTotal'));

		return $archives;
	}

	/**
	 * 按主播区段统计排序直播
	 *
	 * @param $prev
	 * @param $next
	 * @author suqian
	 * @return int
	 */
	public function sortLiveArchivesByPeriod(array $prev,array $next){
		$sortField = $this->sortingField ? $this->sortingField : 'start_time';
		if($prev[$sortField] == $next[$sortField]){
			return 0;
		}
		return $prev[$sortField] > $next[$sortField] ? -1 : 1;
	}

	/**
	 * 按真实直播时间排序 正在直播的
	 *
	 * @param $prev
	 * @param $next
	 * @author suqian
	 * @return int
	 */
	public function sortLivingArchivesByTimes(array $prev,array $next){
		if($prev['live_time'] == $next['live_time']){
			return 0;
		}
		return $prev['live_time'] > $next['live_time'] ? -1 : 1;
	}

	/**
	 * 按今日推荐排序 档期信息
	 *
	 * @param $prev
	 * @param $next
	 * @author zzf
	 * @return int
	 */
	public function sortArchivesByTodayRecommand(array $prev,array $next){
		if($prev['today_recommand'] == $next['today_recommand']){
			return 0;
		}
		return $prev['today_recommand'] ==true ? -1 : 1;
	}

	/**
	 * 按待开播时间排序 待直播的
	 *
	 * @param $prev
	 * @param $next
	 * @author suqian
	 * @return int
	 */
	public function sortWaitArchivesByTimes(array $prev,array $next){
		if($prev['start_time'] == $next['start_time']){
			return 0;
		}
		return $prev['start_time'] < $next['start_time'] ? -1 : 1;
	}

	/**
	 * 按在线人数排序
	 *
	 * @param $prev
	 * @param $next
	 * @author suqian
	 * @return int
	 */
	public function sortUserTotal(array $prev,array $next){
		if(!isset($prev['user_total']) || !isset($next['user_total']))
			return 0;
		if($prev['user_total'] == $next['user_total']){
			return 0;
		}
		return $prev['user_total'] > $next['user_total'] ? -1 : 1;
	}

	/**
	 * 主播排序类型
	 *
	 * @param string $sort
	 * @return mixed
	 */
	public function getDoteySortList($sort = NULL){
		$list = array(
			CHANNEL_DOTEY_SORT_LIVETIME_SUPER => '按直播总时长排序',
			CHANNEL_DOTEY_SORT_RANK	=>'按主播等级排序',
			CHANNEL_DOTEY_SORT_STARTTIME => '按最新开播时间排序',
			CHANNEL_DOTEY_SORT_SONGS_YESTERDAY => '按昨日点唱榜排序',
			CHANNEL_DOTEY_SORT_CHARMS_YESTERDAY => '按昨日魅力榜排序',
			CHANNEL_DOTEY_SORT_CHARMS_SUPER=>'按主播超级魅力值排序',
			CHANNEL_DOTEY_SORT_SORT=>'用户自定义排序',
		);
		return isset($list[$sort]) ? $list[$sort] : $list;
	}

	/**
	 * 排序类型与数据库对应的字段
	 *
	 * @param $sort
	 * @return string
	 */
	public function sortMapDbPeiordFiled($sort){
		$map = array(
			CHANNEL_DOTEY_SORT_CHARMS_YESTERDAY=>'yesterday_charms',
			CHANNEL_DOTEY_SORT_SONGS_YESTERDAY=>'yesterday_songs',
			CHANNEL_DOTEY_SORT_LIVETIME_SUPER => 'super_livetime',
			CHANNEL_DOTEY_SORT_RANK => 'dotey_rank',
			CHANNEL_DOTEY_SORT_CHARMS_SUPER=>'charm',
			CHANNEL_DOTEY_SORT_SORT =>'sort',
		);
		return isset($map[$sort]) ? $map[$sort] : 'yesterday_charms';
	}

	/**
	 * 过滤档期的通用方法
	 *
	 * @param array $archives
	 * @return int $return 0表示返回所有 1表示返回正在直播的 2表示返回待直播的
 	 * @return int $removeDays 过滤掉超出指定天数范围的记录,参数值大于0生效
	 * @return array
	 */
	public function filterArchives(array &$archives ,$return = 0,$removeDays=0){
		foreach($archives as $key=>$archive){
			//过滤没有直播记录的
			if(!isset($archive['live_record']) || empty($archive['live_record'])){
				unset($archives[$key]);
				continue;
			}
			//过滤掉已经结束直播的
			if($archive['live_record']['status'] == 2 || $archive['live_record']['status'] == -1){
				unset($archives[$key]);
				continue;
			}
			//过滤掉后台隐藏的
			if(isset($archive['is_hide']) && $archive['is_hide']){
				unset($archives[$key]);
				continue;
			}
			//取得正在直揪或者待直播的
			if($return == 1 && $archive['live_record']['status'] == 0){
				unset($archives[$key]);
				continue;
			}elseif($return == 2 &&  $archive['live_record']['status'] == 1){
				unset($archives[$key]);
				continue;
			}

			if($archive['live_record']['status'] == 0){
				$startTime = $archive['live_record']['start_time'];
				if(time() - $startTime > 3600*3){
					unset($archives[$key]);
					continue;
				}
			}

			//过滤掉超出指定天数范围的记录
			if($archive['live_record']['status'] == 0 && $removeDays>0){
				$startTime = $archive['live_record']['start_time'];
				$testResult=PipiDate::checkTimeRange(time(),$startTime,true,$removeDays,true);
				if(!$testResult)
				{
					unset($archives[$key]);
					continue;
				}
			}
		}
		return $archives;
	}
}

?>

redpajama_set_name: RedPajamaGithub


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="generator" content="ExDoc v0.11.4">
    <title>Elixush.Globals.Agent – elixush v0.0.4</title>
    <link rel="stylesheet" href="dist/app-1e374caa3d.css" />

<button class="sidebar-toggle">

</button>

  <button class="sidebar-toggle">

  </button>

        elixush

        v0.0.4

    <input type="text" class="sidebar-searchInput" placeholder="search" autocomplete="off" />

Pages

Modules

        elixush v0.0.4
        Elixush.Globals.Agent

The values defined here tend to remain constant over all runs. The atoms not starting with "global_" are used in a variety of places and therefore it is easiest to keep them global. The atoms starting with "global_" may change depending on arguments to pushgp.

Most of the values and atoms in this file are those that are used by Push instructions; all others, with few exceptions, should be defined in push_argmap in pushgp.ex and should be passed to whatever functions use them as arguments.

            Summary

      Functions

    get_globals(key)

Get a key from the globals service

    start_link(name)

    update_globals(key, value)

Update a key in the globals service

            Functions

    get_globals(key)

Specs

get_globals(atom) :: any

Get a key from the globals service

    start_link(name)

    update_globals(key, value)

Specs

update_globals(atom, any) :: any

Update a key in the globals service

          Built using
          ExDoc (v0.11.4),

          designed by
          Friedel Ziegelmayer.

      <button class="night-mode-toggle" />


text:
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="TextualAnnotation.cs" company="OxyPlot">
//   The MIT License (MIT)
//
//   Copyright (c) 2012 Oystein Bjorke
//
//   Permission is hereby granted, free of charge, to any person obtaining a
//   copy of this software and associated documentation files (the
//   "Software"), to deal in the Software without restriction, including
//   without limitation the rights to use, copy, modify, merge, publish,
//   distribute, sublicense, and/or sell copies of the Software, and to
//   permit persons to whom the Software is furnished to do so, subject to
//   the following conditions:
//
//   The above copyright notice and this permission notice shall be included
//   in all copies or substantial portions of the Software.
//
//   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
//   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
//   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
//   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
//   CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
//   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
//   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
// <summary>
//   Provides an abstract base class for annotations that contains text.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace OxyPlot.Wpf
{
    using System.Windows;

    /// <summary>
    /// Provides an abstract base class for annotations that contains text.
    /// </summary>
    public abstract class TextualAnnotation : Annotation
    {
        /// <summary>
        /// The text property.
        /// </summary>
        public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
            "Text", typeof(string), typeof(TextualAnnotation), new PropertyMetadata(null, AppearanceChanged));

        /// <summary>
        /// Gets or sets the text.
        /// </summary>
        public string Text
        {
            get
            {
                return (string)this.GetValue(TextProperty);
            }

            set
            {
                this.SetValue(TextProperty, value);
            }
        }

        /// <summary>
        /// Synchronizes the properties.
        /// </summary>
        public override void SynchronizeProperties()
        {
            var a = (OxyPlot.Annotations.TextualAnnotation)this.InternalAnnotation;
            a.Text = this.Text;
        }
    }
}


text:
<?php

$path = __DIR__ . '/../../yiisoft/yii2';

require($path . '/BaseYii.php');

class Yii extends \yii\BaseYii {
	public static function t($category, $message, $params = [], $language = null) {
		if($category === 'yii') {
			return static::p('cii', $message, $params, $language);
		}

		return parent::t($category, $message, $params, $language);
	}

	public static function p($category, $message, $params = [], $language = null) {
		return parent::t(['package', $category], $message, $params, $language);
	}

	public static function l($category, $message, $params = [], $language = null) {
		return parent::t(['layout', $category], $message, $params, $language);
	}
}

spl_autoload_register(['Yii', 'autoload'], true, true);
Yii::$classMap = require($path . '/classes.php');
Yii::$container = new yii\di\Container();


text:
BasicAuthenticatable = Ember.Mixin.create({
  basicAuthorize: function(email, password, successCallback) {
    $.post("api/v1/authorizations", {
      email: email, password: password, source: "basic"
    }, successCallback);
  }
});


text:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Xunit;

namespace System.Composition.Runtime.Tests
{
    public class ExportFactoryTests
    {
        [Fact]
        public void CreateExport_ValidCreator_ReturnsExpected()
        {
            var factory = new ExportFactory<int>(ExportCreator);
            Assert.Equal(0, ExportCreatorCalled);
            Assert.Equal(0, ExportActionCalled);

            Export<int> export = factory.CreateExport();
            Assert.Equal(1, export.Value);
            Assert.Equal(1, ExportCreatorCalled);
            Assert.Equal(0, ExportActionCalled);

            export.Dispose();
            Assert.Equal(1, ExportCreatorCalled);
            Assert.Equal(1, ExportActionCalled);
        }

        [Fact]
        public void CreateExport_MultipleTimes_ReturnsDifferentExports()
        {
            var factory = new ExportFactory<int>(ExportCreator);
            Export<int> export1 = factory.CreateExport();
            Export<int> export2 = factory.CreateExport();
            Assert.Equal(2, ExportCreatorCalled);
            Assert.NotSame(export1, export2);
        }

        [Fact]
        public void Ctor_NullExport_ThrowsArgumentNullException()
        {
            AssertExtensions.Throws<ArgumentNullException>("exportCreator", () => new ExportFactory<int>(null));
        }

        private int ExportCreatorCalled { get; set; }
        private int ExportActionCalled { get; set; }

        private Tuple<int, Action> ExportCreator()
        {
            ExportCreatorCalled++;
            return Tuple.Create<int, Action>(1, () => ExportActionCalled++);
        }
    }
}


text:
package de.lessvoid.nifty.layout;

import de.lessvoid.nifty.tools.SizeValue;

import javax.annotation.Nonnull;
import java.util.List;

/**
 * LayoutPart is a composition of Box and BoxConstraints.
 *
 * @author void
 */
public class LayoutPart {
  /**
   * the box.
   */
  @Nonnull
  private final Box box;

  /**
   * the box constraints.
   */
  @Nonnull
  private final BoxConstraints boxConstraints;

  /**
   * Create a new instance.
   */
  public LayoutPart() {
    this.box = new Box();
    this.boxConstraints = new BoxConstraints();
  }

  /**
   * Create a new LayoutPart instance.
   *
   * @param newBox            the new box
   * @param newBoxConstraints the new box constraints
   */
  public LayoutPart(@Nonnull final Box newBox, @Nonnull final BoxConstraints newBoxConstraints) {
    this.box = newBox;
    this.boxConstraints = newBoxConstraints;
  }

  /**
   * copy constructor.
   *
   * @param src source
   */
  public LayoutPart(@Nonnull final LayoutPart src) {
    this.box = new Box(src.getBox());
    this.boxConstraints = new BoxConstraints(src.getBoxConstraints());
  }

  /**
   * Get the box of this LayoutPart.
   *
   * @return the box
   */
  @Nonnull
  public final Box getBox() {
    return box;
  }

  /**
   * Get the box constraints for this LayoutPart.
   *
   * @return the box Constraints
   */
  @Nonnull
  public final BoxConstraints getBoxConstraints() {
    return boxConstraints;
  }

  @Override
  @Nonnull
  public String toString() {
    return "box [" + box.getX() + ", " + box.getY() + ", " +
        "" + box.getWidth() + ", " + box.getHeight() + "] with constraints [" + boxConstraints.getX() + ", " +
        "" + boxConstraints.getY() + ", " +
        "" + boxConstraints.getWidth() + ", " + boxConstraints.getHeight() + "]";
  }

  /**
   * Calculates the maximum width of the given child elements. This takes padding of this LayoutPart
   * as well as the margin values of the child elements into account.
   *
   * @param children List<LayoutPart> to calculate max width
   * @return max width
   */
  @Nonnull
  public SizeValue getMaxWidth(@Nonnull final List<LayoutPart> children) {
    int newWidth = 0;
    for (LayoutPart e : children) {
      int partWidth = e.getBoxConstraints().getWidth().getValueAsInt(0);
      partWidth += e.getBoxConstraints().getMarginLeft().getValueAsInt(0);
      partWidth += e.getBoxConstraints().getMarginRight().getValueAsInt(0);
      if (partWidth > newWidth) {
        newWidth = partWidth;
      }
    }
    return SizeValue.px(newWidth);
  }

  /**
   * Calculates the maximum height of the given child elements. This takes padding of this LayoutPart
   * as well as the margin values of the child elements into account.
   *
   * @param children List<LayoutPart> to calculate max height
   * @return max height
   */
  @Nonnull
  public SizeValue getMaxHeight(@Nonnull final List<LayoutPart> children) {
    int newHeight = 0;
    for (LayoutPart e : children) {
      int partHeight = e.getBoxConstraints().getHeight().getValueAsInt(0);
      partHeight += e.getBoxConstraints().getMarginTop().getValueAsInt(0);
      partHeight += e.getBoxConstraints().getMarginBottom().getValueAsInt(0);
      if (partHeight > newHeight) {
        newHeight = partHeight;
      }
    }
    return SizeValue.px(newHeight);
  }

  /**
   * Calculates the sum of the width of all children. Taking padding of this and margin of child
   * elements into account.
   *
   * @param children List<LayoutPart> to calculate width sum
   * @return width sum
   */
  @Nonnull
  public SizeValue getSumWidth(@Nonnull final List<LayoutPart> children) {
    int newWidth = 0;
    for (LayoutPart e : children) {
      newWidth += e.getBoxConstraints().getMarginLeft().getValueAsInt(0);
      newWidth += e.getBoxConstraints().getWidth().getValueAsInt(0);
      newWidth += e.getBoxConstraints().getMarginRight().getValueAsInt(0);
    }
    return SizeValue.px(newWidth);
  }

  /**
   * Calculates the sum of the height of all children. Taking padding of this and margin of child
   * elements into account.
   *
   * @param children List<LayoutPart> to calculate height sum
   * @return width sum
   */
  @Nonnull
  public SizeValue getSumHeight(@Nonnull final List<LayoutPart> children) {
    int newHeight = 0;
    for (LayoutPart e : children) {
      newHeight += e.getBoxConstraints().getHeight().getValueAsInt(0);
      newHeight += e.getBoxConstraints().getMarginTop().getValueAsInt(0);
      newHeight += e.getBoxConstraints().getMarginBottom().getValueAsInt(0);
    }
    return SizeValue.px(newHeight);
  }
}


text:
import os
import sys

import django
from django.conf import settings
from django.test.utils import get_runner

os.environ['DJANGO_SETTINGS_MODULE'] = 'fallballapp.tests.settings'
django.setup()

TestRunner = get_runner(settings)
test_runner = TestRunner()
failures = test_runner.run_tests(['fallballapp.tests'])
sys.exit(bool(failures))


text:
package org.ovirt.engine.ui.userportal.widget.tab;

import org.ovirt.engine.ui.common.widget.Align;
import org.ovirt.engine.ui.common.widget.tab.AbstractTab;
import org.ovirt.engine.ui.common.widget.tab.AbstractTabPanel;
import org.ovirt.engine.ui.common.widget.tab.TabDefinition;

import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
import com.gwtplatform.mvp.client.TabData;

public class UserPortalMainTab extends AbstractTab implements TabDefinition {

    public Anchor hyperlink;
    protected HTMLPanel root;

    public UserPortalMainTab(TabData tabData, AbstractTabPanel tabPanel) {
        super(tabData, tabPanel);

        root = new HTMLPanel("li",  ""); //$NON-NLS-1$ //$NON-NLS-2$
        hyperlink = new Anchor();
        hyperlink.getElement().getStyle().setProperty("fontFamily", "'Open Sans', Helvetica, Arial, sans-serif !important"); //$NON-NLS-1$ //$NON-NLS-2$
        root.add(hyperlink);
        root.setVisible(true);
        accessible = true;
    }
    @Override
    public void activate() {
        root.addStyleName("active"); //$NON-NLS-1$
    }

    @Override
    public Widget asWidget() {
        return root.asWidget();
    }

    @Override
    public void deactivate() {
        root.removeStyleName("active"); //$NON-NLS-1$
    }

    @Override
    public void setAlign(Align align) {
        // no-op, these can only be LEFT
    }

    @Override
    public String getText() {
        return hyperlink.getText();
    }

    @Override
    public void setText(String text) {
        hyperlink.setText(text);
    }

    @Override
    public void setTargetHistoryToken(String historyToken) {
        hyperlink.setHref("#" + historyToken); //$NON-NLS-1$
    }

}


text:
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

	// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)footerDidPress:(id)sender {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://twitter.com/mystcolor"]];
}

@end


text:
import common = require("ui/gestures/gestures-common");
import definition = require("ui/gestures");
import view = require("ui/core/view");
import observable = require("data/observable");
import trace = require("trace");

global.moduleMerge(common, exports);

class UIGestureRecognizerImpl extends NSObject {
    static new(): UIGestureRecognizerImpl {
        return <UIGestureRecognizerImpl>super.new();
    }

    private _owner: GesturesObserver;
    private _type: any;
    private _callback: Function;
    private _context: any;

    public initWithOwnerTypeCallback(owner: GesturesObserver, type: any, callback?: Function, thisArg?: any): UIGestureRecognizerImpl {
        this._owner = owner;
        this._type = type;

        if (callback) {
            this._callback = callback;
        }

        if (thisArg) {
            this._context = thisArg;
        }

        return this;
    }

    public static ObjCExposedMethods = {
        "recognize": { returns: interop.types.void, params: [UIGestureRecognizer] }
    };

    public recognize(recognizer: UIGestureRecognizer): void {
        var callback = this._callback ? this._callback : this._owner.callback;
        var type = this._type;
        var target = this._owner.target;

        var args = {
            type: type,
            view: target,
            ios: recognizer,
            android: undefined
        };

        if (callback) {
            callback.call(this._context, args);
        }
    }
}

export class GesturesObserver extends common.GesturesObserver {
    private _recognizers: {};

    private _onTargetLoaded: (data: observable.EventData) => void;
    private _onTargetUnloaded: (data: observable.EventData) => void;

    constructor(target: view.View, callback: (args: definition.GestureEventData) => void, context: any) {
        super(target, callback, context);
        this._recognizers = {};
    }

    public observe(type: definition.GestureTypes) {
        if (this.target) {
            this.type = type;
            this._onTargetLoaded = args => {
                trace.write(this.target + ".target loaded. _nativeView:" + this.target._nativeView, "gestures");
                this._attach(this.target, type);
            };
            this._onTargetUnloaded = args => {
                trace.write(this.target + ".target unloaded. _nativeView:" + this.target._nativeView, "gestures");
                this._dettach();
            };

            this.target.on(view.View.loadedEvent, this._onTargetLoaded);
            this.target.on(view.View.unloadedEvent, this._onTargetUnloaded);

            if (this.target.isLoaded) {
                this._attach(this.target, type);
            }
        }
    }

    private _attach(target: view.View, type: definition.GestureTypes) {
        trace.write(target + "._attach() _nativeView:" + target._nativeView, "gestures");
        this._dettach();

        if (target && target._nativeView && target._nativeView.addGestureRecognizer) {
            var nativeView = <UIView>target._nativeView;

            if (type & definition.GestureTypes.tap) {
                nativeView.addGestureRecognizer(this._createRecognizer(definition.GestureTypes.tap));
            }

            if (type & definition.GestureTypes.doubleTap) {
                var r = <UITapGestureRecognizer>this._createRecognizer(definition.GestureTypes.doubleTap);
                r.numberOfTapsRequired = 2;

                nativeView.addGestureRecognizer(r);
            }

            if (type & definition.GestureTypes.pinch) {
                nativeView.addGestureRecognizer(this._createRecognizer(definition.GestureTypes.pinch, args => {
                    this._executeCallback(_getPinchData(args));
                }));
            }

            if (type & definition.GestureTypes.pan) {
                nativeView.addGestureRecognizer(this._createRecognizer(definition.GestureTypes.pan, args => {
                    this._executeCallback(_getPanData(args, target._nativeView));
                }));
            }

            if (type & definition.GestureTypes.swipe) {
                nativeView.addGestureRecognizer(this._createRecognizer(definition.GestureTypes.swipe, args => {
                    this._executeCallback(_getSwipeData(args));
                }, UISwipeGestureRecognizerDirection.UISwipeGestureRecognizerDirectionDown));

                nativeView.addGestureRecognizer(this._createRecognizer(definition.GestureTypes.swipe, args => {
                    this._executeCallback(_getSwipeData(args));
                }, UISwipeGestureRecognizerDirection.UISwipeGestureRecognizerDirectionLeft));

                nativeView.addGestureRecognizer(this._createRecognizer(definition.GestureTypes.swipe, args => {
                    this._executeCallback(_getSwipeData(args));
                }, UISwipeGestureRecognizerDirection.UISwipeGestureRecognizerDirectionRight));

                nativeView.addGestureRecognizer(this._createRecognizer(definition.GestureTypes.swipe, args => {
                    this._executeCallback(_getSwipeData(args));
                }, UISwipeGestureRecognizerDirection.UISwipeGestureRecognizerDirectionUp));
            }

            if (type & definition.GestureTypes.rotation) {
                nativeView.addGestureRecognizer(this._createRecognizer(definition.GestureTypes.rotation, args => {
                    this._executeCallback(_getRotationData(args));
                }));
            }

            if (type & definition.GestureTypes.longPress) {
                nativeView.addGestureRecognizer(this._createRecognizer(definition.GestureTypes.longPress));
            }
        }
    }

    private _dettach() {
        trace.write(this.target + "._dettach() _nativeView:" + this.target._nativeView, "gestures");
        if (this.target && this.target._nativeView) {
            for (var name in this._recognizers) {
                if (this._recognizers.hasOwnProperty(name)) {
                    var item = <RecognizerCache>this._recognizers[name];
                    this.target._nativeView.removeGestureRecognizer(item.recognizer);

                    item.recognizer = null;
                    item.target = null;
                }
            }
            this._recognizers = {};
        }
    }

    public disconnect() {
        this._dettach();

        if (this.target) {
            this.target.off(view.View.loadedEvent, this._onTargetLoaded);
            this.target.off(view.View.unloadedEvent, this._onTargetUnloaded);

            this._onTargetLoaded = null;
            this._onTargetUnloaded = null;
        }
        // clears target, context and callback references
        super.disconnect();
    }

    private _executeCallback(args: definition.GestureEventData) {
        if (this.callback) {
            this.callback.call(this.context, args);
        }
    }

    private _createRecognizer(type: definition.GestureTypes, callback?: (args: definition.GestureEventData) => void, swipeDirection?: UISwipeGestureRecognizerDirection): UIGestureRecognizer {
        var recognizer: UIGestureRecognizer;
        var name = definition.toString(type);
        var target = _createUIGestureRecognizerTarget(this, type, callback, this.context);
        var recognizerType = _getUIGestureRecognizerType(type);

        if (recognizerType) {
            if (type === definition.GestureTypes.swipe && swipeDirection) {
                name = name + swipeDirection.toString();
                recognizer = recognizerType.alloc().initWithTargetAction(target, "recognize");
                (<UISwipeGestureRecognizer>recognizer).direction = swipeDirection;
            }
            else {
                recognizer = recognizerType.alloc().initWithTargetAction(target, "recognize");
            }

            if (recognizer) {
                this._recognizers[name] = <RecognizerCache>{ recognizer: recognizer, target: target };
            }
        }

        return recognizer;
    }
}

function _createUIGestureRecognizerTarget(owner: GesturesObserver, type: definition.GestureTypes, callback?: (args: definition.GestureEventData) => void, thisArg?: any): any {
    return UIGestureRecognizerImpl.new().initWithOwnerTypeCallback(owner, type, callback, thisArg);
}

interface RecognizerCache {
    recognizer: UIGestureRecognizer;
    target: any;
}

function _getUIGestureRecognizerType(type: definition.GestureTypes): any {
    var nativeType = null;

    if (type === definition.GestureTypes.tap) {
        nativeType = UITapGestureRecognizer;
    } else if (type === definition.GestureTypes.doubleTap) {
        nativeType = UITapGestureRecognizer;
    } else if (type === definition.GestureTypes.pinch) {
        nativeType = UIPinchGestureRecognizer;
    } else if (type === definition.GestureTypes.pan) {
        nativeType = UIPanGestureRecognizer;
    } else if (type === definition.GestureTypes.swipe) {
        nativeType = UISwipeGestureRecognizer;
    } else if (type === definition.GestureTypes.rotation) {
        nativeType = UIRotationGestureRecognizer;
    } else if (type === definition.GestureTypes.longPress) {
        nativeType = UILongPressGestureRecognizer;
    }

    return nativeType;
}

function _getSwipeDirection(direction: UISwipeGestureRecognizerDirection): definition.SwipeDirection {
    if (direction === UISwipeGestureRecognizerDirection.UISwipeGestureRecognizerDirectionDown) {
        return definition.SwipeDirection.down;
    } else if (direction === UISwipeGestureRecognizerDirection.UISwipeGestureRecognizerDirectionLeft) {
        return definition.SwipeDirection.left;
    } else if (direction === UISwipeGestureRecognizerDirection.UISwipeGestureRecognizerDirectionRight) {
        return definition.SwipeDirection.right;
    } else if (direction === UISwipeGestureRecognizerDirection.UISwipeGestureRecognizerDirectionUp) {
        return definition.SwipeDirection.up;
    }
}

function _getPinchData(args: definition.GestureEventData): definition.PinchGestureEventData {
    var recognizer = <UIPinchGestureRecognizer>args.ios;
    return <definition.PinchGestureEventData>{
        type: args.type,
        view: args.view,
        ios: args.ios,
        android: undefined,
        scale: recognizer.scale,
    };
}

function _getSwipeData(args: definition.GestureEventData): definition.SwipeGestureEventData {
    var recognizer = <UISwipeGestureRecognizer>args.ios;
    return <definition.SwipeGestureEventData>{
        type: args.type,
        view: args.view,
        ios: args.ios,
        android: undefined,
        direction: _getSwipeDirection(recognizer.direction),
    };
}

function _getPanData(args: definition.GestureEventData, view: UIView): definition.PanGestureEventData {
    var recognizer = <UIPanGestureRecognizer>args.ios;
    return <definition.PanGestureEventData>{
        type: args.type,
        view: args.view,
        ios: args.ios,
        android: undefined,
        deltaX: recognizer.translationInView(view).x,
        deltaY: recognizer.translationInView(view).y
    };
}

function _getRotationData(args: definition.GestureEventData): definition.RotationGestureEventData {
    var recognizer = <UIRotationGestureRecognizer>args.ios;
    return <definition.RotationGestureEventData>{
        type: args.type,
        view: args.view,
        ios: args.ios,
        android: undefined,
        rotation: recognizer.rotation * (180.0 / Math.PI),
    };
}


text:
[Commits](https://github.com/wycats/handlebars.js/compare/v1.1.2...master)

## v1.1.2 - November 5th, 2013

- [#645](https://github.com/wycats/handlebars.js/issues/645) - 1.1.1 fails under IE8 ([@kpdecker](https://api.github.com/users/kpdecker))
- [#644](https://github.com/wycats/handlebars.js/issues/644) - Using precompiled templates (AMD mode) with handlebars.runtime 1.1.1 ([@fddima](https://api.github.com/users/fddima))

- Add simple binary utility tests - 96a45a4
- Fix empty string compilation - eea708a

[Commits](https://github.com/wycats/handlebars.js/compare/v1.1.1...v1.1.2)

## v1.1.1 - November 4th, 2013

- [#642](https://github.com/wycats/handlebars.js/issues/642) - handlebars 1.1.0 are broken with nodejs

- Fix release notes link - 17ba258

[Commits](https://github.com/wycats/handlebars.js/compare/v1.1.0...v1.1.1)

## v1.1.0 - November 3rd, 2013

- [#628](https://github.com/wycats/handlebars.js/pull/628) - Convert code to ES6 modules ([@kpdecker](https://api.github.com/users/kpdecker))
- [#336](https://github.com/wycats/handlebars.js/pull/336) - Add whitespace control syntax ([@kpdecker](https://api.github.com/users/kpdecker))
- [#535](https://github.com/wycats/handlebars.js/pull/535) - Fix for probable JIT error under Safari ([@sorentwo](https://api.github.com/users/sorentwo))
- [#483](https://github.com/wycats/handlebars.js/issues/483) - Add first and last @ vars to each helper ([@denniskuczynski](https://api.github.com/users/denniskuczynski))
- [#557](https://github.com/wycats/handlebars.js/pull/557) - `\\{{foo}}` escaping only works in some situations ([@dmarcotte](https://api.github.com/users/dmarcotte))
- [#552](https://github.com/wycats/handlebars.js/pull/552) - Added BOM removal flag. ([@blessenm](https://api.github.com/users/blessenm))
- [#543](https://github.com/wycats/handlebars.js/pull/543) - publish passing master builds to s3 ([@fivetanley](https://api.github.com/users/fivetanley))

- [#608](https://github.com/wycats/handlebars.js/issues/608) - Add `includeZero` flag to `if` conditional
- [#498](https://github.com/wycats/handlebars.js/issues/498) - `Handlebars.compile` fails on empty string although a single blank works fine
- [#599](https://github.com/wycats/handlebars.js/issues/599) - lambda helpers only receive options if used with arguments
- [#592](https://github.com/wycats/handlebars.js/issues/592) - Optimize array and subprogram performance
- [#571](https://github.com/wycats/handlebars.js/issues/571) - uglify upgrade breaks compatibility with older versions of node
- [#587](https://github.com/wycats/handlebars.js/issues/587) - Partial inside partial breaks?

Compatibility notes:
- The project now includes separate artifacts for AMD, CommonJS, and global objects.
  - AMD: Users may load the bundled `handlebars.amd.js` or `handlebars.runtime.amd.js` files or load individual modules directly. AMD users should also note that the handlebars object is exposed via the `default` field on the imported object. This [gist](https://gist.github.com/wycats/7417be0dc361a69d5916) provides some discussion of possible compatibility shims.
  - CommonJS/Node: Node loading occurs as normal via `require`
  - Globals: The `handlebars.js` and `handlebars.runtime.js` files should behave in the same manner as the v1.0.12 / 1.0.0 release.
- Build artifacts have been removed from the repository. [npm][npm], [components/handlebars.js][components], [cdnjs][cdnjs], or the [builds page][builds-page] should now be used as the source of built artifacts.
- Context-stored helpers are now always passed the `options` hash. Previously no-argument helpers did not have this argument.

[Commits](https://github.com/wycats/handlebars.js/compare/v1.0.12...v1.1.0)

## v1.0.12 / 1.0.0 - May 31 2013

- [#515](https://github.com/wycats/handlebars.js/issues/515) - Add node require extensions support ([@jjclark1982](https://github.com/jjclark1982))
- [#517](https://github.com/wycats/handlebars.js/issues/517) - Fix amd precompiler output with directories ([@blessenm](https://github.com/blessenm))
- [#433](https://github.com/wycats/handlebars.js/issues/433) - Add support for unicode ids
- [#469](https://github.com/wycats/handlebars.js/issues/469) - Add support for `?` in ids
- [#534](https://github.com/wycats/handlebars.js/issues/534) - Protect from object prototype modifications
- [#519](https://github.com/wycats/handlebars.js/issues/519) - Fix partials with . name ([@jamesgorrie](https://github.com/jamesgorrie))
- [#519](https://github.com/wycats/handlebars.js/issues/519) - Allow ID or strings in partial names
- [#437](https://github.com/wycats/handlebars.js/issues/437) - Require matching brace counts in escaped expressions
- Merge passed partials and helpers with global namespace values
- Add support for complex ids in @data references
- Docs updates

Compatibility notes:
- The parser is now stricter on `{{{`, requiring that the end token be `}}}`. Templates that do not
  follow this convention should add the additional brace value.
- Code that relies on global the namespace being muted when custom helpers or partials are passed will need to explicitly pass an `undefined` value for any helpers that should not be available.
- The compiler version has changed. Precompiled templates with 1.0.12 or higher must use the 1.0.0 or higher runtime.

[Commits](https://github.com/wycats/handlebars.js/compare/v1.0.11...v1.0.12)

## v1.0.11 / 1.0.0-rc4 - May 13 2013

- [#458](https://github.com/wycats/handlebars.js/issues/458) - Fix `./foo` syntax ([@jpfiset](https://github.com/jpfiset))
- [#460](https://github.com/wycats/handlebars.js/issues/460) - Allow `:` in unescaped identifers ([@jpfiset](https://github.com/jpfiset))
- [#471](https://github.com/wycats/handlebars.js/issues/471) - Create release notes (These!)
- [#456](https://github.com/wycats/handlebars.js/issues/456) - Allow escaping of `\\`
- [#211](https://github.com/wycats/handlebars.js/issues/211) - Fix exception in `escapeExpression`
- [#375](https://github.com/wycats/handlebars.js/issues/375) - Escape unicode newlines
- [#461](https://github.com/wycats/handlebars.js/issues/461) - Do not fail when compiling `""`
- [#302](https://github.com/wycats/handlebars.js/issues/302) - Fix sanity check in knownHelpersOnly mode
- [#369](https://github.com/wycats/handlebars.js/issues/369) - Allow registration of multiple helpers and partial by passing definition object
- Add bower package declaration ([@DevinClark](https://github.com/DevinClark))
- Add NuSpec package declaration ([@MikeMayer](https://github.com/MikeMayer))
- Handle empty context in `with` ([@thejohnfreeman](https://github.com/thejohnfreeman))
- Support custom template extensions in CLI ([@matteoagosti](https://github.com/matteoagosti))
- Fix Rhino support ([@broady](https://github.com/broady))
- Include contexts in string mode ([@leshill](https://github.com/leshill))
- Return precompiled scripts when compiling to AMD ([@JamesMaroney](https://github.com/JamesMaroney))
- Docs updates ([@iangreenleaf](https://github.com/iangreenleaf), [@gilesbowkett](https://github.com/gilesbowkett), [@utkarsh2012](https://github.com/utkarsh2012))
- Fix `toString` handling under IE and browserify ([@tommydudebreaux](https://github.com/tommydudebreaux))
- Add program metadata

[Commits](https://github.com/wycats/handlebars.js/compare/v1.0.10...v1.0.11)

## v1.0.10 - Node - Feb 27 2013

- [#428](https://github.com/wycats/handlebars.js/issues/428) - Fix incorrect rendering of nested programs
- Fix exception message ([@tricknotes](https://github.com/tricknotes))
- Added negative number literal support
- Concert library to single IIFE
- Add handlebars-source gemspec ([@machty](https://github.com/machty))

[Commits](https://github.com/wycats/handlebars.js/compare/v1.0.9...v1.0.10)

## v1.0.9 - Node - Feb 15 2013

- Added `Handlebars.create` API in node module for sandboxed instances ([@tommydudebreaux](https://github.com/tommydudebreaux))

[Commits](https://github.com/wycats/handlebars.js/compare/1.0.0-rc.3...v1.0.9)

## 1.0.0-rc3 - Browser - Feb 14 2013

- Prevent use of `this` or `..` in illogical place ([@leshill](https://github.com/leshill))
- Allow AST passing for `parse`/`compile`/`precompile` ([@machty](https://github.com/machty))
- Optimize generated output by inlining statements where possible
- Check compiler version when evaluating templates
- Package browser dist in npm package

[Commits](https://github.com/wycats/handlebars.js/compare/v1.0.8...1.0.0-rc.3)

## Prior Versions

When upgrading from the Handlebars 0.9 series, be aware that the
signature for passing custom helpers or partials to templates has
changed.

Instead of:

```js
template(context, helpers, partials, [data])
```

Use:

```js
template(context, {helpers: helpers, partials: partials, data: data})
```

[builds-page]: http://builds.handlebarsjs.com.s3.amazonaws.com/index.html
[cdnjs]: http://cdnjs.com/libraries/handlebars.js/
[components]: https://github.com/components/handlebars.js
[npm]: https://npmjs.org/package/handlebars


text:
package org.consumersunion.stories.dashboard.client.application.administration.account;

import java.util.List;

import org.consumersunion.stories.common.client.ui.form.Form;
import org.consumersunion.stories.common.client.ui.form.controls.CheckBoxInput;
import org.consumersunion.stories.common.client.ui.form.controls.PasswordInput;
import org.consumersunion.stories.common.client.ui.form.controls.RadioInput;
import org.consumersunion.stories.common.client.ui.form.controls.TextInput;
import org.consumersunion.stories.common.client.util.MessageDispatcher;
import org.consumersunion.stories.common.client.widget.MessageStyle;
import org.consumersunion.stories.common.shared.i18n.CommonI18nLabels;
import org.consumersunion.stories.common.shared.model.User;
import org.consumersunion.stories.common.shared.service.datatransferobject.OrganizationSummary;
import org.consumersunion.stories.dashboard.client.application.administration.AdminManagerUiHandlers;

import com.google.common.base.Strings;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import com.gwtplatform.mvp.client.ViewWithUiHandlers;

import static org.consumersunion.stories.common.client.ui.form.Form.OPTIONAL;
import static org.consumersunion.stories.common.client.ui.form.Form.REQUIRED;

public class CreateAccountView extends ViewWithUiHandlers<AdminManagerUiHandlers>
        implements CreateAccountPresenter.MyView {
    interface Binder extends UiBinder<Widget, CreateAccountView> {
    }

    @UiField
    Label createAccountLbl;
    @UiField
    Form form;
    @UiField
    Button buttonSave;

    public final String USER_NAME_FIELD_NAME = "userNameTxt";
    public final String FIRST_NAME_FIELD_NAME = "firstNameTxt";
    public final String LAST_NAME_FIELD_NAME = "lastNameTxt";
    public final String PASSWORD_FIELD_NAME = "passwordTxt";
    public final String PASSWORD_CONFIRM_FIELD_NAME = "passwordConfirmationTxt";
    public final String RESET_QUESTION_FIELD_NAME = "resetQuestionTxt";
    public final String RESET_ANSWER_FIELD_NAME = "resetAnswerTxt";
    public final String ORGANIZATIONS_FIELD_NAME = "organizationsSelect";
    public final String DEFAULT_ORGANIZATION_FIELD_NAME = "organizationSelect";

    private final CommonI18nLabels labels;
    private final MessageDispatcher messageDispatcher;

    private CheckBoxInput organizationInput;
    private RadioInput defaultOrgInput;
    private TextInput username;
    private boolean usernameAvailable;

    @Inject
    CreateAccountView(
            Binder uiBinder,
            CommonI18nLabels labels,
            MessageDispatcher messageDispatcher) {
        this.labels = labels;
        this.messageDispatcher = messageDispatcher;

        initWidget(uiBinder.createAndBindUi(this));
        setupForm();
        setupEvent();
    }

    @Override
    public void setUsernameDisponibility(boolean available) {
        this.usernameAvailable = available;

        if (usernameAvailable) {
            username.removeStyleName("cu-error-text-field");
            username.addStyleName("cu-success-availability-text-field");
        } else {
            username.removeStyleName("cu-success-availability-text-field");
            username.addStyleName("cu-error-text-field");
        }
    }

    @Override
    public void displayOrganizations(List<OrganizationSummary> organizationSummaries) {
        final String[] labels = new String[organizationSummaries.size()];
        final String[] options = new String[organizationSummaries.size()];

        int i = 0;
        for (final OrganizationSummary os : organizationSummaries) {
            labels[i] = os.getOrganization().getName();
            options[i] = Integer.toString(os.getOrganization().getId());
            i++;
        }
        organizationInput.setLabelsAndOptions(labels, options);
        defaultOrgInput.setLabelsAndOptions(labels, options);
        removeUsernameStyles();
    }

    @Override
    public void resetForm() {
        form.clear();
        setupForm();
        setupEvent();
    }

    @UiHandler("buttonSave")
    void onClick(final ClickEvent e) {
        if (validate()) {
            if (usernameAvailable) {
                createAccount();
                removeUsernameStyles();
            }
        } else {
            // TODO Display global errors messages
        }
    }

    private void createAccount() {
        User user = new User();
        user.setActive(true);
        user.setHandle(form.getValue(USER_NAME_FIELD_NAME));
        List<String> organizations = form.getMultiValue(ORGANIZATIONS_FIELD_NAME);
        String defaultOrg = form.getValue(DEFAULT_ORGANIZATION_FIELD_NAME);

        if (organizations.contains(defaultOrg)) {
            getUiHandlers().saveNewAccount(user, form.getValue(PASSWORD_FIELD_NAME),
                    form.getValue(RESET_QUESTION_FIELD_NAME), form.getValue(RESET_ANSWER_FIELD_NAME),
                    form.getValue(FIRST_NAME_FIELD_NAME), form.getValue(LAST_NAME_FIELD_NAME), organizations,
                    defaultOrg);
        } else {
            Window.alert("The default organization is not in the selected organizations");
        }
    }

    private boolean validate() {
        boolean validationResult = form.validate();

        if (validationResult && !form.getValue(PASSWORD_FIELD_NAME).equals(
                form.getValue(PASSWORD_CONFIRM_FIELD_NAME))) {
            messageDispatcher.displayMessage(MessageStyle.ERROR, "Confirmation password doesn't match");
            validationResult = false;
        }

        return validationResult;
    }

    private void setupForm() {
        buttonSave.setText(labels.createAccount());
        createAccountLbl.setText(labels.createAccount());

        username = form.add(new TextInput(labels.userName(), USER_NAME_FIELD_NAME, REQUIRED));
        form.add(new TextInput(labels.firstName(), FIRST_NAME_FIELD_NAME, OPTIONAL));
        form.add(new TextInput(labels.lastName(), LAST_NAME_FIELD_NAME, OPTIONAL));
        form.add(new PasswordInput(labels.password(), PASSWORD_FIELD_NAME, REQUIRED));
        form.add(new PasswordInput(labels.passwordConfirmation(), PASSWORD_CONFIRM_FIELD_NAME, REQUIRED));
        form.add(new TextInput(labels.resetQuestion(), RESET_QUESTION_FIELD_NAME, REQUIRED));
        form.add(new TextInput(labels.resetAnswer(), RESET_ANSWER_FIELD_NAME, REQUIRED));

        form.setMinLength(PASSWORD_FIELD_NAME, 6);
        form.setMinLength(PASSWORD_CONFIRM_FIELD_NAME, 6);

        organizationInput = new CheckBoxInput(labels.organizations(), ORGANIZATIONS_FIELD_NAME, OPTIONAL);
        defaultOrgInput = new RadioInput(labels.defaultOrganization(), DEFAULT_ORGANIZATION_FIELD_NAME,
                DEFAULT_ORGANIZATION_FIELD_NAME, OPTIONAL);
        form.add(organizationInput);
        form.add(defaultOrgInput);
    }

    private void setupEvent() {
        username.addKeyUpHandler(new KeyUpHandler() {
            @Override
            public void onKeyUp(KeyUpEvent event) {
                removeUsernameStyles();
                if (!Strings.isNullOrEmpty(form.getValue(USER_NAME_FIELD_NAME).trim())) {
                    getUiHandlers().checkUsernameExists(form.getValue(USER_NAME_FIELD_NAME));
                }
            }
        });
    }

    private void removeUsernameStyles() {
        usernameAvailable = true;
        username.removeStyleName("cu-success-availability-text-field");
        username.removeStyleName("cu-error-text-field");
    }
}


text: <ssh xmlns="urn:cesnet:mod3"/>


text:
<?php
namespace SmoothPhp\Domain;

use SmoothPhp\Contracts\Serialization\Serializable;

/**
 * Class Metadata
 * @package SmoothPhp\Domain
 * @author Simon Bennett <simon@bennett.im>
 */
final class Metadata implements Serializable
{
    /** @var array */
    private $meta;

    /**
     * Metadata constructor.
     * @param array $meta
     */
    public function __construct(array $meta = [])
    {
        $this->meta = $meta;
    }

    /**
     * @return array
     */
    public function getMeta()
    {
        return $this->meta;
    }

    /**
     * @return array
     */
    public function serialize()
    {
        return $this->meta;
    }

    /**
     * @param array $data
     * @return static
     */
    public static function deserialize(array $data)
    {
        return new static($data);
    }
}


text:
#include "avmshell.h"
#ifdef AVMPLUS_SELFTEST
namespace avmplus {
class ST_mmgc_basics : public Selftest {
public:
ST_mmgc_basics(AvmCore* core);
virtual void run(int n);
virtual void prologue();
private:
static const char* ST_names[];
void test0();
void test1();
void test2();
void test3();
void test4();
void test5();
void test6();
void test7();
void test8();
void test9();
void test10();
private:
    MMgc::GC *gc;
    MMgc::FixedAlloc *fa;
    MMgc::FixedMalloc *fm;

};
ST_mmgc_basics::ST_mmgc_basics(AvmCore* core)
    : Selftest(core, "mmgc", "basics", ST_mmgc_basics::ST_names)
{}
const char* ST_mmgc_basics::ST_names[] = {"create_gc_instance","create_gc_object","is_gc_memory","get_bytesinuse","collect","getgcheap","fixedAlloc","fixedMalloc","gcheap","gcmethods","gcLargeAlloc", NULL };
void ST_mmgc_basics::run(int n) {
switch(n) {
case 0: test0(); return;
case 1: test1(); return;
case 2: test2(); return;
case 3: test3(); return;
case 4: test4(); return;
case 5: test5(); return;
case 6: test6(); return;
case 7: test7(); return;
case 8: test8(); return;
case 9: test9(); return;
case 10: test10(); return;
}
}
void ST_mmgc_basics::prologue() {
	gc=new MMgc::GC(MMgc::GCHeap::GetGCHeap());
	if (gc==NULL) {
	    MMgc::GCHeap::Init();
	    MMgc::FixedMalloc::Init();
	    gc=new MMgc::GC(MMgc::GCHeap::GetGCHeap());
	}

}
void ST_mmgc_basics::test0() {
verifyPass(gc != NULL, "gc != NULL", __FILE__, __LINE__);

}
void ST_mmgc_basics::test1() {
    MyGCObject *mygcobject;
    mygcobject = (MyGCObject *)new (gc) MyGCObject();
verifyPass(mygcobject!=NULL, "mygcobject!=NULL", __FILE__, __LINE__);
    mygcobject->i=10;
verifyPass(mygcobject->i==10, "mygcobject->i==10", __FILE__, __LINE__);

}
void ST_mmgc_basics::test2() {
    MyGCObject *mygcobject;
    MyObject *myobject;
    mygcobject = (MyGCObject *)new (gc) MyGCObject();
    myobject = (MyObject *)new(MyObject);
verifyPass(gc->IsGCMemory(mygcobject) == true, "gc->IsGCMemory(mygcobject) == true", __FILE__, __LINE__);
verifyPass(gc->IsGCMemory(myobject) == false, "gc->IsGCMemory(myobject) == false", __FILE__, __LINE__);
    delete myobject;
    delete mygcobject;

}
void ST_mmgc_basics::test3() {
    MyGCObject *mygcobject;
    int inuse=(int)gc->GetBytesInUse();
    mygcobject = (MyGCObject *)new (gc) MyGCObject();
//    AvmLog("bytes in use before %d after %d\n",inuse,(int)gc->GetBytesInUse());
verifyPass((int)gc->GetBytesInUse()==inuse+8, "(int)gc->GetBytesInUse()==inuse+8", __FILE__, __LINE__);
    delete mygcobject;

}
void ST_mmgc_basics::test4() {
    MyGCObject *mygcobject;
    int inuse=(int)gc->GetBytesInUse();
    mygcobject = (MyGCObject *)new (gc) MyGCObject();
verifyPass((int)gc->GetBytesInUse()>inuse, "(int)gc->GetBytesInUse()>inuse", __FILE__, __LINE__);
    delete mygcobject;
//    AvmLog("collect: inuse=%d current=%d\n",inuse,(int)gc->GetBytesInUse());
    gc->Collect();
//    AvmLog("collect: inuse=%d current=%d\n",inuse,(int)gc->GetBytesInUse());
verifyPass((int)gc->GetBytesInUse()<=inuse, "(int)gc->GetBytesInUse()<=inuse", __FILE__, __LINE__);

}
void ST_mmgc_basics::test5() {
verifyPass(gc->GetGCHeap()!=NULL, "gc->GetGCHeap()!=NULL", __FILE__, __LINE__);

}
void ST_mmgc_basics::test6() {
    MMgc::FixedAlloc *fa;
    fa=new MMgc::FixedAlloc(2048,MMgc::GCHeap::GetGCHeap());
verifyPass((int)fa->GetMaxAlloc()==0, "(int)fa->GetMaxAlloc()==0", __FILE__, __LINE__);
verifyPass((int)fa->GetNumChunks()==0, "(int)fa->GetNumChunks()==0", __FILE__, __LINE__);
    void *data1=fa->Alloc(4096);
verifyPass(MMgc::FixedAlloc::GetFixedAlloc(data1)==fa, "MMgc::FixedAlloc::GetFixedAlloc(data1)==fa", __FILE__, __LINE__);
verifyPass((int)fa->GetBytesInUse()==2048, "(int)fa->GetBytesInUse()==2048", __FILE__, __LINE__);
verifyPass((int)fa->GetItemSize()==2048, "(int)fa->GetItemSize()==2048", __FILE__, __LINE__);
    void *data2=fa->Alloc(4096);
verifyPass(MMgc::FixedAlloc::GetFixedAlloc(data2)==fa, "MMgc::FixedAlloc::GetFixedAlloc(data2)==fa", __FILE__, __LINE__);
//    AvmLog("fa->GetItemSize=%d\n",(int)fa->GetItemSize());
verifyPass((int)fa->GetItemSize()==2048, "(int)fa->GetItemSize()==2048", __FILE__, __LINE__);
    fa->Free(data1);
verifyPass((int)fa->GetItemSize()==2048, "(int)fa->GetItemSize()==2048", __FILE__, __LINE__);
verifyPass((int)fa->GetMaxAlloc()==2, "(int)fa->GetMaxAlloc()==2", __FILE__, __LINE__);
verifyPass((int)fa->GetNumChunks()==2, "(int)fa->GetNumChunks()==2", __FILE__, __LINE__);
    gc->Collect();

}
void ST_mmgc_basics::test7() {
    fm=MMgc::FixedMalloc::GetInstance();
    int start=(int)fm->GetBytesInUse();
    int starttotal=(int)fm->GetTotalSize();
//    AvmLog("fm->GetBytesInUse()=%d\n",(int)fm->GetBytesInUse());
verifyPass((int)fm->GetBytesInUse()==start, "(int)fm->GetBytesInUse()==start", __FILE__, __LINE__);
//    AvmLog("fm->GetTotalSize()=%d\n",(int)fm->GetTotalSize());
verifyPass((int)fm->GetTotalSize()==starttotal, "(int)fm->GetTotalSize()==starttotal", __FILE__, __LINE__);
    void *obj=fm->Alloc(8192);
//    AvmLog("fm->GetBytesInUse()=%d\n",(int)fm->GetBytesInUse());
verifyPass((int)fm->GetBytesInUse()==start+8192, "(int)fm->GetBytesInUse()==start+8192", __FILE__, __LINE__);
//    AvmLog("fm->GetTotalSize()=%d\n",(int)fm->GetTotalSize());
verifyPass((int)fm->GetTotalSize()==starttotal+2, "(int)fm->GetTotalSize()==starttotal+2", __FILE__, __LINE__);
    fm->Free(obj);
//    AvmLog("fm->GetBytesInUse()=%d\n",(int)fm->GetBytesInUse());
verifyPass((int)fm->GetBytesInUse()==start, "(int)fm->GetBytesInUse()==start", __FILE__, __LINE__);
//    AvmLog("fm->GetTotalSize()=%d\n",(int)fm->GetTotalSize());
verifyPass((int)fm->GetTotalSize()==starttotal, "(int)fm->GetTotalSize()==starttotal", __FILE__, __LINE__);
    obj=fm->Calloc(1024,10);
//    AvmLog("fm->GetBytesInUse()=%d\n",(int)fm->GetBytesInUse());
verifyPass((int)fm->GetBytesInUse()==start+1024*12, "(int)fm->GetBytesInUse()==start+1024*12", __FILE__, __LINE__);
//    AvmLog("fm->GetTotalSize()=%d\n",(int)fm->GetTotalSize());
verifyPass((int)fm->GetTotalSize()==starttotal+3, "(int)fm->GetTotalSize()==starttotal+3", __FILE__, __LINE__);
    fm->Free(obj);
verifyPass((int)fm->GetBytesInUse()==start, "(int)fm->GetBytesInUse()==start", __FILE__, __LINE__);
verifyPass((int)fm->GetTotalSize()==starttotal, "(int)fm->GetTotalSize()==starttotal", __FILE__, __LINE__);
    gc->Collect();

}
void ST_mmgc_basics::test8() {
    MMgc::GCHeap *gh=MMgc::GCHeap::GetGCHeap();
    int startfreeheap=(int)gh->GetFreeHeapSize();
verifyPass((int)gh->GetTotalHeapSize()==128, "(int)gh->GetTotalHeapSize()==128", __FILE__, __LINE__);
//    AvmLog("gh->GetFreeHeapSize()=%d\n",(int)gh->GetFreeHeapSize());
verifyPass((int)gh->GetFreeHeapSize()==startfreeheap, "(int)gh->GetFreeHeapSize()==startfreeheap", __FILE__, __LINE__);
    gh->SetHeapLimit(1024);
verifyPass((int)gh->GetTotalHeapSize()==128, "(int)gh->GetTotalHeapSize()==128", __FILE__, __LINE__);
//    AvmLog("gh->GetFreeHeapSize()=%d\n",(int)gh->GetFreeHeapSize());
verifyPass((int)gh->GetFreeHeapSize()==startfreeheap, "(int)gh->GetFreeHeapSize()==startfreeheap", __FILE__, __LINE__);
    gh->Alloc(1024*10,true,true);
verifyPass((int)gh->GetTotalHeapSize()==10368, "(int)gh->GetTotalHeapSize()==10368", __FILE__, __LINE__);
//    AvmLog("gh->GetFreeHeapSize()=%d\n",(int)gh->GetFreeHeapSize());
verifyPass((int)gh->GetFreeHeapSize()==startfreeheap, "(int)gh->GetFreeHeapSize()==startfreeheap", __FILE__, __LINE__);

}
void ST_mmgc_basics::test9() {

    MyGCObject *mygcobject;
    mygcobject = (MyGCObject *)new (gc) MyGCObject();
verifyPass((MyGCObject *)gc->FindBeginning(mygcobject)==mygcobject, "(MyGCObject *)gc->FindBeginning(mygcobject)==mygcobject", __FILE__, __LINE__);

}
void ST_mmgc_basics::test10() {
    MyGCObject *mygcobject;
    mygcobject = (MyGCObject *)new (gc) MyGCObject();
    MMgc::GCLargeAlloc *gcl=new MMgc::GCLargeAlloc(gc);
    void *obj=gcl->Alloc(1024,0);
verifyPass(MMgc::GCLargeAlloc::IsLargeBlock(obj)==true, "MMgc::GCLargeAlloc::IsLargeBlock(obj)==true", __FILE__, __LINE__);
verifyPass(MMgc::GCLargeAlloc::FindBeginning(obj)==obj, "MMgc::GCLargeAlloc::FindBeginning(obj)==obj", __FILE__, __LINE__);
verifyPass(MMgc::GCLargeAlloc::IsFinalized(obj)==false, "MMgc::GCLargeAlloc::IsFinalized(obj)==false", __FILE__, __LINE__);
    MMgc::GCLargeAlloc::SetFinalize(obj);
verifyPass(MMgc::GCLargeAlloc::IsFinalized(obj)==true, "MMgc::GCLargeAlloc::IsFinalized(obj)==true", __FILE__, __LINE__);
    MMgc::GCLargeAlloc::ClearFinalized(obj);
    gcl->Free(obj);
verifyPass(MMgc::GCLargeAlloc::IsFinalized(obj)==false, "MMgc::GCLargeAlloc::IsFinalized(obj)==false", __FILE__, __LINE__);
verifyPass(MMgc::GCLargeAlloc::ContainsPointers(obj)==false, "MMgc::GCLargeAlloc::ContainsPointers(obj)==false", __FILE__, __LINE__);
verifyPass(MMgc::GCLargeAlloc::HasWeakRef(obj)==false, "MMgc::GCLargeAlloc::HasWeakRef(obj)==false", __FILE__, __LINE__);
    MMgc::GCLargeAlloc::SetHasWeakRef(obj,true);
verifyPass(MMgc::GCLargeAlloc::HasWeakRef(obj)==true, "MMgc::GCLargeAlloc::HasWeakRef(obj)==true", __FILE__, __LINE__);
    MMgc::GCLargeAlloc::SetHasWeakRef(obj,false);
verifyPass(MMgc::GCLargeAlloc::HasWeakRef(obj)==false, "MMgc::GCLargeAlloc::HasWeakRef(obj)==false", __FILE__, __LINE__);
verifyPass(MMgc::GCLargeAlloc::GetMark(obj)==false, "MMgc::GCLargeAlloc::GetMark(obj)==false", __FILE__, __LINE__);
    MMgc::GCLargeAlloc::SetMark(obj);
verifyPass(MMgc::GCLargeAlloc::GetMark(obj)==true, "MMgc::GCLargeAlloc::GetMark(obj)==true", __FILE__, __LINE__);
    MMgc::GCLargeAlloc::SetQueued(obj);
verifyPass(MMgc::GCLargeAlloc::IsRCObject(obj)==false, "MMgc::GCLargeAlloc::IsRCObject(obj)==false", __FILE__, __LINE__);
verifyPass(MMgc::GCLargeAlloc::IsWhite(obj)==false, "MMgc::GCLargeAlloc::IsWhite(obj)==false", __FILE__, __LINE__);
verifyPass(MMgc::GCLargeAlloc::IsWhite(mygcobject)==false, "MMgc::GCLargeAlloc::IsWhite(mygcobject)==false", __FILE__, __LINE__);

}
void create_mmgc_basics(AvmCore* core) { new ST_mmgc_basics(core); }
}
#endif


text:
<?php

namespace Course\Support\Traits;

use Course\Models\Course;
use Illuminate\Http\Request;

trait StudentResourceSoftDeleteTrait
{

    /**
     * Delete the specified resource from storage permanently.
     *
     * @param  Illuminate\Http\Request  $request
     * @param  int  $id
     * @return Illuminate\Http\Response
     */
    public function delete(Request $request, $id)
    {
        $students = Course::onlyTrashed()
                    ->whereIn('id', $request->has('id') ? $request->input('id') : [$id])
                    ->get();

        foreach ($students as $student) {
            $student->forceDelete();
        }

        return back();
    }
}


text:
<?php

namespace Meteor\Process;

class PHPMemoryLimitSetter
{
    const RE_PHP_SCRIPT = '/^\s*?(php)/';
    const RE_MEMORY_LIMIT = '/([-]{1,2}(?:define|d)\s*(memory_limit))/';

    /**
     * @param string $command
     *
     * @return bool
     */
    public static function isPHPScript($command)
    {
        return preg_match(self::RE_PHP_SCRIPT, $command);
    }

    /**
     * @param string $command
     *
     * @return bool
     */
    public static function hasMemoryLimit($command)
    {
        return preg_match(self::RE_MEMORY_LIMIT, $command);
    }

    /**
     * @param string $command
     *
     * @return string
     */
    public static function setMemoryLimit($command)
    {
        return preg_replace(
            self::RE_PHP_SCRIPT,
            sprintf('php --define memory_limit=%s', ini_get('memory_limit')),
            $command
        );
    }
}