text:
<?php

namespace kalibao\common\components\helpers;

use Yii;
use kalibao\common\components\i18n\I18N;
use yii\data\Sort;
use yii\helpers\Inflector;

/**
 * Class Html overload the default Html component in order to add new features
 *
 * @package kalibao\common\components\helpers
 * @version 1.0
 * @author Kévin Walter <walkev13@gmail.com>
 */
class Html extends \yii\helpers\Html
{
    /**
     * Generates a summary of the validation errors.
     * If there is no validation error, an empty error summary markup will still be generated, but it will be hidden.
     * @param Model|Model[] $models the model(s) whose validation errors are to be displayed
     * @param array $options the tag options in terms of name-value pairs. The following options are specially handled:
     *
     * - header: string, the header HTML for the error summary. If not set, a default prompt string will be used.
     * - footer: string, the footer HTML for the error summary.
     * - encode: boolean, if set to false then value won't be encoded.
     *
     * The rest of the options will be rendered as the attributes of the container tag. The values will
     * be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered.
     * @return string the generated error summary
     */
    public static function errorSummary($models, $options = [])
    {
        $header = isset($options['header']) ? $options['header'] : '
' . Yii::t('yii', 'Please fix the following errors:') . '
';
        $footer = isset($options['footer']) ? $options['footer'] : '';
        $encode = !isset($options['encode']) || $options['encode'] !== false;
        unset($options['header'], $options['footer'], $options['encode']);

        $lines = [];
        if (!is_array($models)) {
            $models = [$models];
        }
        self::getErrorLines($models, $lines, $encode);

        if (empty($lines)) {
            // still render the placeholder for client-side validation use
            $content = "

";
            $options['style'] = isset($options['style']) ? rtrim($options['style'], ';') . '; display:none' : 'display:none';
        } else {
            $content = "

" . implode("
\n
", $lines) . "

";
        }
        return Html::tag('div', $header . $content . $footer, $options);
    }

    /**
     * Get error lines
     * @param array $models
     * @param array $lines
     * @param boolean $encode if set to false then value won't be encoded.
     */
    protected static function getErrorLines(array $models, array &$lines, $encode)
    {
        foreach ($models as $model) {
            if (is_array($model)) {
                self::getErrorLines($model, $lines, $encode);
            } else {
                /* @var $model Model */
                foreach ($model->getFirstErrors() as $error) {
                    $lines[] = $encode ? Html::encode($error) : $error;
                }
            }
        }
    }

    /**
     * Get data used to generate an advanced drop down list
     * @param string $modelName Model name
     * @param array $select Attributes to select
     * @param array $where Condition
     * @param int $limit Limit
     * @return array
     */
    public static function findAdvancedDropDownListData($modelName, $select, $where, $limit)
    {
        $activeQuery = (new \yii\db\Query())
            ->select($select)
            ->from((new $modelName())->tableName());

        $first = true;
        foreach ($where as $condition) {
            if ($first) {
                $activeQuery->where($condition);
                $first = false;
            } else {
                $activeQuery->andWhere($condition);
            }
        }
        $models = $activeQuery->limit($limit)->all();

        $attributeId = '';
        $attributeValue = '';

        if (!empty($models)) {
            $keys = array_keys($models[0]);
            $attributeId = $keys[0];
            $attributeValue = isset($keys[1]) ? $keys[1] : $keys[0];
        }

        return self::activeAdvancedDropDownListData($models, $attributeId, $attributeValue);
    }

    /**
     * Get data used to generate a drop down list
     * @param string $modelName Model name
     * @param array $select Attributes to select
     * @param array $where Condition
     * @return array
     */
    public static function findDropDownListData($modelName, $select, $where)
    {
        $activeQuery = (new \yii\db\Query())
            ->select($select)
            ->from((new $modelName())->tableName());

        $first = true;
        foreach ($where as $condition) {
            if ($first) {
                $activeQuery->where($condition);
                $first = false;
            } else {
                $activeQuery->andWhere($condition);
            }
        }
        $models = $activeQuery->all();

        $attributeId = '';
        $attributeValue = '';

        if (!empty($models)) {
            $keys = array_keys($models[0]);
            $attributeId = $keys[0];
            $attributeValue = isset($keys[1]) ? $keys[1] : $keys[0];
        }

        return self::activeDropDownListData($models, $attributeId, $attributeValue);
    }

    /**
     * Get data used to generate an advanced drop down list from array of \yii\base\Model
     * @param \yii\base\Model[] $models List of models
     * @param string $attributeId Name of attribute id
     * @param string $attributeValue Name of attribute value
     * @return array
     */
    public static function activeAdvancedDropDownListData($models, $attributeId, $attributeValue)
    {
        $results = [];
        foreach ($models as $model) {
            $results[] = ['id' => $model[$attributeId], 'text' => $model[$attributeValue]];
        }
        return $results;
    }

    /**
     * Get data used to generate a drop down list from array of \yii\base\Model
     * @param \yii\base\Model[] $models List of models
     * @param string $attributeId Name of attribute id
     * @param string $attributeValue Name of attribute value
     * @return array
     */
    public static function activeDropDownListData($models, $attributeId, $attributeValue)
    {
        $results[''] = Yii::t('kalibao', 'input_select');
        foreach ($models as $model) {
            $results[$model[$attributeId]] = $model[$attributeValue];
        }
        return $results;
    }

    /**
     * Generates a hyperlink that can be clicked to cause sorting.
     * @param Sort $sort the current Sort instance
     * @param string $attribute the attribute name
     * @param array $options additional HTML attributes for the hyperlink tag.
     * There is one special attribute `label` which will be used as the label of the hyperlink.
     * If this is not set, the label defined in [[attributes]] will be used.
     * If no label is defined, [[\yii\helpers\Inflector::camel2words()]] will be called to get a label.
     * Note that it will not be HTML-encoded.
     * @return string
     */
    public static function sortLink(Sort $sort, $attribute, $options = [])
    {
        if (($direction = $sort->getAttributeOrder($attribute)) !== null) {
            $class = ($direction === SORT_DESC) ? 'current-sort desc' : 'current-sort asc';
            $icon = ($direction === SORT_DESC) ?  'glyphicon-sort-by-alphabet-alt' : 'glyphicon-sort-by-alphabet';
            if (isset($options['class'])) {
                $options['class'] .= ' ' . $class;
            } else {
                $options['class'] = $class;
            }
        } else {
            $icon = 'glyphicon-sort-by-alphabet';
            if (isset($options['class'])) {
                $options['class'] .= ' asc';
            } else {
                $options['class'] = 'asc';
            }
        }

        $url = $sort->createUrl($attribute);
        $options['data-sort'] = $sort->createSortParam($attribute);
        if (isset($options['label'])) {
            $label = $options['label'];
            unset($options['label']);
        } else {
            if (isset($sort->attributes[$attribute]['label'])) {
                $label = $sort->attributes[$attribute]['label'];
            } else {
                $label = Inflector::camel2words($attribute);
            }
        }
        $label .= ' ';
        return Html::a($label, $url, $options);
    }

    /**
     * Get drop down list filter for checkbox input
     * @return array
     */
    public static function checkboxInputFilterDropDownList()
    {
        return [
            '' => Yii::t('kalibao', 'input_drop_down_list_all'),
            '1' => Yii::t('kalibao', 'input_drop_down_list_checked'),
            '0' => Yii::t('kalibao', 'input_drop_down_list_unchecked'),
        ];
    }

    /**
     * Get language label from id
     * @param string $language Language ID
     * @param bool $flag Display flag
     * @param bool $text Display text
     * @return string HTML
     */
    public static function labelI18n($language, $flag = true, $text = true)
    {
        return ''.($flag ? '' : '') .($text ? ''.I18N::label($language).'' : ''). '';
    }

    public static function activeImageDropDown($model, $attribute, $data)
    {
        return '

';
    }
}


text:
button .vertical-align, li .vertical-align {
  display: flex;
  align-items: center;
}
button .grow, li .grow {
  flex-grow: 1;
}
button .glyph-checkbox, li .glyph-checkbox {
  display: inline-block;
  text-align: center;
  vertical-align: middle;
  width: 1.5rem;
  padding: 0 0.25rem 0 0.05rem;
}
button .glyph-checkbox input[type="checkbox"], li .glyph-checkbox input[type="checkbox"] {
  display: none;
}
button .glyph-checkbox label, li .glyph-checkbox label {
  margin: 0;
}
button .glyph-checkbox input[type="checkbox"] + .fa-check::before, li .glyph-checkbox input[type="checkbox"] + .fa-check::before {
  outline: none;
  color: rgba(40, 40, 40, 0.4);
  font-size: 1.25em;
  background-color: transparent;
  -moz-transition: all 0.1s;
  -o-transition: all 0.1s;
  -webkit-transition: all 0.1s;
  transition: all 0.1s;
  -moz-appearance: none;
  -webkit-appearance: none;
}
button .glyph-checkbox input[type="checkbox"]:checked + .fa-check::before, li .glyph-checkbox input[type="checkbox"]:checked + .fa-check::before {
  color: #282828;
  font-size: 1.5em;
}
button .glyph-checkbox input[type="checkbox"] + .fa-check::before:hover, li .glyph-checkbox input[type="checkbox"] + .fa-check::before:hover {
  cursor: pointer;
}
button .glyph-checkbox, li .glyph-checkbox {
  display: inline-block;
  text-align: center;
  vertical-align: middle;
  width: 1.5rem;
  padding: 0 0.25rem 0 0.05rem;
}
button .glyph-checkbox input[type="checkbox"], li .glyph-checkbox input[type="checkbox"] {
  display: none;
}
button .glyph-checkbox label, li .glyph-checkbox label {
  margin: 0;
}
button .glyph-checkbox input[type="checkbox"] + .fa-pencil::before, li .glyph-checkbox input[type="checkbox"] + .fa-pencil::before {
  outline: none;
  color: rgba(40, 40, 40, 0.4);
  font-size: 1.25em;
  background-color: transparent;
  -moz-transition: all 0.1s;
  -o-transition: all 0.1s;
  -webkit-transition: all 0.1s;
  transition: all 0.1s;
  -moz-appearance: none;
  -webkit-appearance: none;
}
button .glyph-checkbox input[type="checkbox"]:checked + .fa-pencil::before, li .glyph-checkbox input[type="checkbox"]:checked + .fa-pencil::before {
  color: #282828;
  font-size: 1.5em;
}
button .glyph-checkbox input[type="checkbox"] + .fa-pencil::before:hover, li .glyph-checkbox input[type="checkbox"] + .fa-pencil::before:hover {
  cursor: pointer;
}
button .glyph-checkbox, li .glyph-checkbox {
  display: inline-block;
  text-align: center;
  vertical-align: middle;
  width: 1.5rem;
  padding: 0 0.25rem 0 0.05rem;
}
button .glyph-checkbox input[type="checkbox"], li .glyph-checkbox input[type="checkbox"] {
  display: none;
}
button .glyph-checkbox label, li .glyph-checkbox label {
  margin: 0;
}
button .glyph-checkbox input[type="checkbox"] + .fa-trash-o::before, li .glyph-checkbox input[type="checkbox"] + .fa-trash-o::before {
  outline: none;
  color: rgba(40, 40, 40, 0.4);
  font-size: 1.25em;
  background-color: transparent;
  -moz-transition: all 0.1s;
  -o-transition: all 0.1s;
  -webkit-transition: all 0.1s;
  transition: all 0.1s;
  -moz-appearance: none;
  -webkit-appearance: none;
}
button .glyph-checkbox input[type="checkbox"]:checked + .fa-trash-o::before, li .glyph-checkbox input[type="checkbox"]:checked + .fa-trash-o::before {
  color: #282828;
  font-size: 1.5em;
}
button .glyph-checkbox input[type="checkbox"] + .fa-trash-o::before:hover, li .glyph-checkbox input[type="checkbox"] + .fa-trash-o::before:hover {
  cursor: pointer;
}
button .glyph-checkbox, li .glyph-checkbox {
  display: inline-block;
  text-align: center;
  vertical-align: middle;
  width: 1.5rem;
  padding: 0 0.25rem 0 0.05rem;
}
button .glyph-checkbox input[type="checkbox"], li .glyph-checkbox input[type="checkbox"] {
  display: none;
}
button .glyph-checkbox label, li .glyph-checkbox label {
  margin: 0;
}
button .glyph-checkbox input[type="checkbox"] + .fa-bomb::before, li .glyph-checkbox input[type="checkbox"] + .fa-bomb::before {
  outline: none;
  color: rgba(40, 40, 40, 0.4);
  font-size: 1.25em;
  background-color: transparent;
  -moz-transition: all 0.1s;
  -o-transition: all 0.1s;
  -webkit-transition: all 0.1s;
  transition: all 0.1s;
  -moz-appearance: none;
  -webkit-appearance: none;
}
button .glyph-checkbox input[type="checkbox"]:checked + .fa-bomb::before, li .glyph-checkbox input[type="checkbox"]:checked + .fa-bomb::before {
  color: #282828;
  font-size: 1.5em;
}
button .glyph-checkbox input[type="checkbox"] + .fa-bomb::before:hover, li .glyph-checkbox input[type="checkbox"] + .fa-bomb::before:hover {
  cursor: pointer;
}
button .glyph-checkbox, li .glyph-checkbox {
  display: inline-block;
  text-align: center;
  vertical-align: middle;
  width: 1.5rem;
  padding: 0 0.25rem 0 0.05rem;
}
button .glyph-checkbox input[type="checkbox"], li .glyph-checkbox input[type="checkbox"] {
  display: none;
}
button .glyph-checkbox label, li .glyph-checkbox label {
  margin: 0;
}
button .glyph-checkbox input[type="checkbox"] + .fa-close::before, li .glyph-checkbox input[type="checkbox"] + .fa-close::before {
  outline: none;
  color: rgba(40, 40, 40, 0.4);
  font-size: 1.25em;
  background-color: transparent;
  -moz-transition: all 0.1s;
  -o-transition: all 0.1s;
  -webkit-transition: all 0.1s;
  transition: all 0.1s;
  -moz-appearance: none;
  -webkit-appearance: none;
}
button .glyph-checkbox input[type="checkbox"]:checked + .fa-close::before, li .glyph-checkbox input[type="checkbox"]:checked + .fa-close::before {
  color: #282828;
  font-size: 1.5em;
}
button .glyph-checkbox input[type="checkbox"] + .fa-close::before:hover, li .glyph-checkbox input[type="checkbox"] + .fa-close::before:hover {
  cursor: pointer;
}
button .glyph-checkbox, li .glyph-checkbox {
  display: inline-block;
  text-align: center;
  vertical-align: middle;
  width: 1.5rem;
  padding: 0 0.25rem 0 0.05rem;
}
button .glyph-checkbox input[type="checkbox"], li .glyph-checkbox input[type="checkbox"] {
  display: none;
}
button .glyph-checkbox label, li .glyph-checkbox label {
  margin: 0;
}
button .glyph-checkbox input[type="checkbox"] + .fa-clock-o::before, li .glyph-checkbox input[type="checkbox"] + .fa-clock-o::before {
  outline: none;
  color: rgba(40, 40, 40, 0.4);
  font-size: 1.25em;
  background-color: transparent;
  -moz-transition: all 0.1s;
  -o-transition: all 0.1s;
  -webkit-transition: all 0.1s;
  transition: all 0.1s;
  -moz-appearance: none;
  -webkit-appearance: none;
}
button .glyph-checkbox input[type="checkbox"]:checked + .fa-clock-o::before, li .glyph-checkbox input[type="checkbox"]:checked + .fa-clock-o::before {
  color: #282828;
  font-size: 1.5em;
}
button .glyph-checkbox input[type="checkbox"] + .fa-clock-o::before:hover, li .glyph-checkbox input[type="checkbox"] + .fa-clock-o::before:hover {
  cursor: pointer;
}
button .glyph-checkbox, li .glyph-checkbox {
  display: inline-block;
  text-align: center;
  vertical-align: middle;
  width: 1.5rem;
  padding: 0 0.25rem 0 0.05rem;
}
button .glyph-checkbox input[type="checkbox"], li .glyph-checkbox input[type="checkbox"] {
  display: none;
}
button .glyph-checkbox label, li .glyph-checkbox label {
  margin: 0;
}
button .glyph-checkbox input[type="checkbox"] + .fa-save::before, li .glyph-checkbox input[type="checkbox"] + .fa-save::before {
  outline: none;
  color: rgba(40, 40, 40, 0.4);
  font-size: 1.25em;
  background-color: transparent;
  -moz-transition: all 0.1s;
  -o-transition: all 0.1s;
  -webkit-transition: all 0.1s;
  transition: all 0.1s;
  -moz-appearance: none;
  -webkit-appearance: none;
}
button .glyph-checkbox input[type="checkbox"]:checked + .fa-save::before, li .glyph-checkbox input[type="checkbox"]:checked + .fa-save::before {
  color: #282828;
  font-size: 1.5em;
}
button .glyph-checkbox input[type="checkbox"] + .fa-save::before:hover, li .glyph-checkbox input[type="checkbox"] + .fa-save::before:hover {
  cursor: pointer;
}

redpajama_set_name: RedPajamaGithub


text:
bool Actor::objectsCanMoveThrough() const {
  return corporeal_state_ == DEAD || corporeal_state_ == SPIRIT_FORM;
}

ActorController* Actor::getController() {
  return controller_;
}

bool Actor::block(Actor* attacker, const MeleeAttack* attack) {
    return controller_ ? controller_->block(attacker, attack) : false;
}

bool Actor::instantiateMagic(int source,
                             const Magic* magic,
                             int* times_to_generate,
                             double* motion_delay,
                             double* action_delay,
                             int* visualization_power_parameter,
                             MagicDescriptionStageParameters stage_parameters[MagicDescription::NUM_STAGES]) {
  if (controller_) {
  return controller_->instantiateMagic(source,
                                       magic,
                                       times_to_generate,
                                       motion_delay,
                                       action_delay,
                                       visualization_power_parameter,
                                       stage_parameters);
  } else {
    return false;
  }
}

void Actor::setCorporealState(CorporealState state) { update_mask_.state = state != corporeal_state_; corporeal_state_ = state; }
CorporealState Actor::getCorporealState() const { return corporeal_state_; }
void Actor::setPosition(float x, float y) { update_mask_.position = 1; x_ = x; y_ = y; }
void Actor::setDirection(float direction) { update_mask_.direction = 1; update_mask_.dxdy = 1; direction_ = direction; }
void Actor::setSpeed(float speed) { update_mask_.speed = 1; update_mask_.dxdy = 1; moving_ = true; speed_ = speed; }
void Actor::stopMoving() { update_mask_.speed = 1; update_mask_.dxdy = 1; moving_ = false; speed_ = 0.0f; }
void Actor::teleportTo(float x, float y) {
  update_mask_.position = 1;
  x_ = x;
  y_ = y;
  for (int i = 0; i < Evidyon::ClientConfig::SYNC_GROUPS+1; ++i) {
    sync_flags_[i].teleport = 1;
  }
}

inline void Actor::setCombatState(bool enable) {
  if (enable) {
    if (corporeal_state_ == NORMAL) corporeal_state_ = IN_COMBAT;
  } else {
    if (corporeal_state_ == IN_COMBAT) corporeal_state_ = NORMAL;
  }
}

inline void Actor::setMemberOfFaction(Faction faction) {
  faction_ = faction;
}

inline void Actor::fleshHit() {
  for (int i = 0; i < Evidyon::ClientConfig::SYNC_GROUPS+1; ++i) {
    sync_flags_[i].blood = 1;
  }
}

inline void Actor::setAction(ActorAction action) {
  for (int i = 0; i < Evidyon::ClientConfig::SYNC_GROUPS+1; ++i) {
    sync_flags_[i].action = (unsigned)action;
  }
}

inline void Actor::changeMap(Map* map, float x, float y) {
  map_ = map;
  update_mask_.position = 1;
  x_ = x;
  y_ = y;
  for (int i = 0; i < Evidyon::ClientConfig::SYNC_GROUPS+1; ++i) {
    sync_flags_[i].teleport = 1;
  }
  update_mask_.speed = 1; // stop moving
  update_mask_.dxdy = 1;
  moving_ = false;
  speed_ = 0.0f;
}

bool Actor::isAlive() const { return corporeal_state_ != DEAD; }
bool Actor::isDead() const { return corporeal_state_ == DEAD; }
bool Actor::isInvisible() const { return corporeal_state_ == SPIRIT_FORM; }

WorldRegion* Actor::getRegion() { return local_region_; }
ActorGroup* Actor::getGroup() { return group_; }
void Actor::getPosition(float* x, float* y) const { *x = x_; *y = y_; }
float Actor::getDirection() const { return direction_; }
void Actor::applyMagicEffect(Actor* source, double time, const Magic* magic,
               const MagicDescriptionStageEffect* effect,
               const MagicDescriptionStageEffect::Parameters* effect_parameters) {
  if (controller_) controller_->applyMagicEffect(source, time, magic, effect, effect_parameters);
}
float Actor::distanceToSq(const Actor* other) const {
  float dx = other->x_-x_, dy = other->y_-y_;
  return dx*dx+dy*dy;
}

float Actor::distanceToSq(float x, float y) const {
  float dx = x-x_, dy = y-y_;
  return dx*dx+dy*dy;
}
int Actor::getIDNumber() const { return sync_data_.id; }
bool Actor::isMoving() const { return moving_; }

Evidyon::Network::Packet::ActorSyncData* Actor::getSyncData() {
  return &sync_data_;
}

void Actor::setSyncGroup(int sync_group) {
  initSyncFlags(sync_group);
  sync_data_.flags = sync_flags_[sync_group];
  packPositionIntoSyncData();
  resetSyncFlags(sync_group);
}

bool Actor::withinViewOf(const Actor* client_actor) const {
  static const int SHIFT_SIGN = sizeof(int) * 8 - 1; // 31
  static const int VIEW_RANGE = 10 << 5;//<< Evidyon::Network::FLOAT_PACK_DECIMAL_BITS;
  // todo: subtract off for this actor's size
  {
    const int delta = sync_data_.x_packed - client_actor->sync_data_.x_packed;
    int abs_diff = delta - (((delta) & (delta >> SHIFT_SIGN)) << 1);
    // abs_diff -= actor_size_in_squares_;
    if (abs_diff > VIEW_RANGE) return false;
  }
  {
    const int delta = sync_data_.y_packed - client_actor->sync_data_.y_packed;
    int abs_diff = delta - (((delta) & (delta >> SHIFT_SIGN)) << 1);
    // abs_diff -= actor_size_in_squares_;
    if (abs_diff > VIEW_RANGE) return false;
  }

  return true;
}

Evidyon::Network::Packet::ActorSyncData::Flags Actor::getFastSyncFlags() {
  initSyncFlags(Evidyon::ClientConfig::SYNC_GROUPS);
  Evidyon::Network::Packet::ActorSyncData::Flags return_value =
    sync_flags_[Evidyon::ClientConfig::SYNC_GROUPS];
  resetSyncFlags(Evidyon::ClientConfig::SYNC_GROUPS);
  return return_value;
}

inline const char* Actor::getName() const { return  controller_ ? controller_->getName() : ""; }

inline bool Actor::inSameGroupAs(Actor* actor) const {
  return (group_ != 0) && (group_ == actor->getGroup());
}

inline float Actor::getSize() const {
  return size_;
}

inline void Actor::setSize(float size) {
  size_ = size;
}

inline float Actor::checkContactWith(float x, float y, float radius) {
  float rhs = radius + size_;
  return distanceToSq(x, y) - rhs*rhs;
}

inline float Actor::checkContactWith(const Actor* other_actor) {
  float rhs = (size_ + other_actor->size_);
  return distanceToSq(other_actor) - rhs*rhs;
}

inline float Actor::scaleWithinRangeOf(float x, float y, float radius, float range) {
  float rhs = radius + size_ + range;
  return distanceToSq(x, y) - rhs*rhs;
}

float Actor::separationDistanceTo(float x, float y, float radius) {
// the distance approximation is:
//  dx - x coordinate difference
//  dy - y coordinate difference
//  a, b - radii
//  t - the separation distance
// dx*dx + dy*dy = (a+b+t)*(a+b+t)
// dx*dx + dy*dy = (a+b)*(a+b) + 2*(a+b)*t + t*t
// (dx*dx + dy*dy - (a+b)*(a+b)) / (2*(a+b)) <=> t
// (dx*dx + dy*dy) / (a+b) - (a+b) / (2) <=> t
// t*t should be small relative to 2*(a+b)*t for best results

// the actual distance is:
// (-2*(a+b) +- sqrt(4*(a+b)*(a+b)-4*((a+b)*(a+b)-(dx*dx+dy*dy)))) / 2
// -(a+b) +- sqrt((a+b)*(a+b)-((a+b)*(a+b)-(dx*dx+dy*dy)))
// -(a+b) +- (a+b)*sqrt(1-(1-(dx*dx+dy*dy)/((a+b)*(a+b))))
// -(a+b) +- sqrt( dx*dx+dy*dy )
  float dd = distanceToSq(x, y) / 2.0f;
  float combined_radii = size_ + radius;
  return dd / combined_radii - combined_radii / 2.0f;
}

float Actor::separationDistanceTo(const Actor* other_actor) {
  float dd = distanceToSq(other_actor) / 2.0f;
  float combined_radii = size_ + other_actor->size_;
  return dd / combined_radii - combined_radii / 2.0f;
}

inline float Actor::scaleWithinRangeOf(const Actor* other_actor, float range) {
  // a = actor 1 radius
  // b = actor 2 radius
  // d = distance between actors
  // t = threashold distance
  // d - (a + b) < t
  // d < t + a + b
  // d*d < (t + a + b)^2
  // d*d = t*t + 2*t*(a+b) + (a+b)*(a+b)
  // 0 = t*t + 2*t*(a+b) * (a+b)*(a+b) - d*d
  // t1,t2 = (-2*(a+b) +- sqrt(4*(a+b)*(a+b) - 4*1*((a+b)*(a+b) - d*d)))/2
  // t1,t2 = (-2*(a+b) +- sqrt(4*(a+b)*(a+b)*(1 - 1) + 4*1*d*d))/2
  // t1,t2 = (-2*(a+b) +- sqrt(4*d*d))/2
  // t1,t2 = (-(a+b) +- d)
  // t1 = d - (a+b)
  float rhs = (range + size_ + other_actor->size_);
  return distanceToSq(other_actor) - rhs*rhs;
}

inline void Actor::initSyncFlags(int sync_group) {
  sync_flags_[sync_group].moving = moving_ ? 1 : 0;
  sync_flags_[sync_group].angle = (unsigned __int8)(direction_/(2*3.1415f)*(1<<Evidyon::ACTORSYNC_ANGLE_BITS));
  sync_flags_[sync_group].mesh_state = (unsigned)corporeal_state_;
}

inline void Actor::resetSyncFlags(int sync_group) {
  sync_flags_[sync_group].teleport = 0;
  sync_flags_[sync_group].action = ACTORACTION_NONE;
  sync_flags_[sync_group].blood = 0;
}

#endif


text:
namespace Decoder
{
	std::pair<std::string, int> decode(const std::string& msg);
}

#endif


text:
<Alloy>
	<Window id="dataView">
	<View class="container" id="container">
		<ScrollView id="scrollView1">

			</ScrollView>
	</View>
	</Window>
</Alloy>


text:
import React from 'react';
import { TouchableOpacity, Text, StyleSheet } from 'react-native';

interface ButtonProps {
  title: string;
  onPress?(): void;
}

export const Button: React.FC<ButtonProps> = ({ title, onPress }) => (
  <TouchableOpacity
    style={styles.wrapper}
    activeOpacity={0.5}
    onPress={onPress}>
    <Text style={styles.title}>{title}</Text>
  </TouchableOpacity>
);

const styles = StyleSheet.create({
  wrapper: {
    backgroundColor: '#4A4A4A',
    padding: 10,
    borderRadius: 5,
    marginBottom: 10,
    alignItems: 'center'
  },
  title: {
    color: '#FFF',
  },
});


text:
#include "main.h"

/* Standard includes. */
#include <string.h>

/* Scheduler includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"

/* Library includes. */
#include "stm32f10x_it.h"

/* Driver includes. */
#include "STM32_USART.h"
#include "epd.h"
#include "rtclock.h"
#include "btm.h"
#include "battery.h"
#include "leds.h"
#include "buttons.h"
#include "motor.h"
#include "gui.h"
#include "utils.h"

/* The time between cycles of the 'check' task - which depends on whether the
check task has detected an error or not. */
#define mainCHECK_DELAY_NO_ERROR			( ( TickType_t ) 5000 / portTICK_PERIOD_MS )
#define mainCHECK_DELAY_ERROR				( ( TickType_t ) 500 / portTICK_PERIOD_MS )

/* The LED controlled by the 'check' task. */
#define mainCHECK_LED						( 3 )

/* Task priorities. */
#if 0
#define mainSEM_TEST_PRIORITY				( tskIDLE_PRIORITY + 1 )
#define mainBLOCK_Q_PRIORITY				( tskIDLE_PRIORITY + 2 )
#define mainCHECK_TASK_PRIORITY				( tskIDLE_PRIORITY + 3 )
#define mainFLASH_TASK_PRIORITY				( tskIDLE_PRIORITY + 2 )
#define mainINTEGER_TASK_PRIORITY           ( tskIDLE_PRIORITY )
#define mainGEN_QUEUE_TASK_PRIORITY			( tskIDLE_PRIORITY )
#endif
#define mainECHO_TASK_PRIORITY              ( tskIDLE_PRIORITY + 1 )

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

/*
 * Configure the hardware for the demo.
 */
static void prvSetupHardware( void );

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

void assert_failed( char *pucFile, unsigned long ulLine );

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

int main( void )
{
#ifdef DEBUG
    debug();
#endif

	/* Set up the clocks and memory interface. */
	prvSetupHardware();

    toGuiQueue = xQueueCreate(32, sizeof(struct guievent));

    current_rtime.sec = 0;
    current_rtime.min = 39;
    current_rtime.hour = 21;

    LEDs_Init();
    LEDs_Set(LED0, LED_INTENS_50, LED_INTENS_0, LED_INTENS_0);

	/* Create the 'echo' task, which is also defined within this file. */
    xTaskCreate( BluetoothModemTask, "BTM", 2*configMINIMAL_STACK_SIZE, NULL, mainECHO_TASK_PRIORITY, NULL );

	xTaskCreate( GuiDrawTask, "GuiDraw", 2*configMINIMAL_STACK_SIZE, NULL, mainECHO_TASK_PRIORITY, NULL );

    xTaskCreate( BatteryTask, "Battery", 2*configMINIMAL_STACK_SIZE, NULL, mainECHO_TASK_PRIORITY, NULL );

    xTaskCreate( LEDsTask, "LEDs", 2*configMINIMAL_STACK_SIZE, NULL, mainECHO_TASK_PRIORITY, NULL );

    xTaskCreate( ButtonsTask, "Buttons", 2*configMINIMAL_STACK_SIZE, NULL, mainECHO_TASK_PRIORITY, NULL );

    xTaskCreate( MotorTask, "Motor", 2*configMINIMAL_STACK_SIZE, NULL, mainECHO_TASK_PRIORITY, NULL );

	/* Create the 'check' task, which is also defined within this file. */
	// xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );

    /* Start the scheduler. */
	vTaskStartScheduler();

    /* Will only get here if there was insufficient memory to create the idle
    task.  The idle task is created within vTaskStartScheduler(). */
	for( ;; );
}

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

/* FreeRTOS: User defined function executed from within the idle task. */
void vApplicationIdleHook( void )
{
#if 1
    /* Activate the sleep mode - wait for next interrupt. */
    /* Power modes must be configured first!! */
    __WFI();
#endif
}

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

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

static void prvSetupHardware( void )
{
    NVIC_InitTypeDef NVIC_InitStructure;
    GPIO_InitTypeDef GPIO_InitStruct;

#if 1
	/* RCC system reset(for debug purpose). */
	RCC_DeInit ();

#if 1
    /* Enable HSE. */
	RCC_HSEConfig( RCC_HSE_ON );

	/* Wait till HSE is ready. */
	while (RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET)
        ;
#else
    /* Disable HSE */
    RCC_HSEConfig( RCC_HSE_OFF );
#endif

    /* HCLK = SYSCLK. */
    RCC_HCLKConfig( RCC_SYSCLK_Div1 );          // HCLK=8MHz
	// RCC_HCLKConfig( RCC_SYSCLK_Div2 );

    /* NOTE: update the constant configCPU_CLOCK_HZ to the correct SysTick (HCLK) operating frequency! */

    /* APB2 max 72MHz. PCLK2  = HCLK. */
    // RCC_PCLK2Config( RCC_HCLK_Div1 );
	RCC_PCLK2Config( RCC_HCLK_Div2 );      // PCLK2=4MHz

    /* APB1 max 36MHz. PCLK1  = HCLK/2. */
    // RCC_PCLK1Config( RCC_HCLK_Div2 );
    RCC_PCLK1Config( RCC_HCLK_Div4 );    // PCLK1=2MHz

	/* ADCCLK = PCLK2/2. */
	RCC_ADCCLKConfig( RCC_PCLK2_Div2 );    // PCLK2/2 = 2MHz

    /* Flash 2 wait state. */
	*( volatile unsigned long  * )0x40022000 = 0x01;

#if 1
    /* PLLCLK = 8MHz * 9 = 72 MHz */
    // RCC_PLLConfig( RCC_PLLSource_HSE_Div1, RCC_PLLMul_9 );   // 8 * 9 = 72MHz
    // RCC_PLLConfig( RCC_PLLSource_HSI_Div2, RCC_PLLMul_9 );     // 8/2 * 9 = 36 MHz
    // RCC_PLLConfig( RCC_PLLSource_PREDIV1, RCC_PLLMul_9 );     // 8 * 9 = 72 MHz (ok)
    // RCC_PLLConfig( RCC_PLLSource_PREDIV1, RCC_PLLMul_2 );     // 8 * 2 = 16 MHz (ok) - MD_VL
    // RCC_PLLConfig( RCC_PLLSource_HSE_Div1, RCC_PLLMul_2 );      // 8 * 2 = 16 MHz
    // RCC_PLLConfig( RCC_PLLSource_HSI_Div2, RCC_PLLMul_4 );      // 8/2 * 4 = 16 MHz
    RCC_PLLConfig( RCC_PLLSource_HSE_Div2, RCC_PLLMul_2 );      // 8 / 2 * 2 = 8 MHz

    // do { } while (1);
    /* Enable PLL. */
	RCC_PLLCmd( ENABLE );          /* BUG: SysReset here, irrespective if HSI or HSE is used!!! */

	/* Wait till PLL is ready. */
	while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
        ;

    /* Select PLL as system clock source. */
    RCC_SYSCLKConfig (RCC_SYSCLKSource_PLLCLK);

    /* Wait till PLL is used as system clock source. */
    while (RCC_GetSYSCLKSource() != 0x08)
        ;
#endif
#if 0
    /* Select HSI as system clock source. */
    RCC_SYSCLKConfig (RCC_SYSCLKSource_HSI);

    /* Wait till PLL is used as system clock source. */
    while (RCC_GetSYSCLKSource() != 0x00)
        ;
#endif
#if 0
    /* Select HSE-direct as system clock source. */
    RCC_SYSCLKConfig (RCC_SYSCLKSource_HSE);

    /* Wait till PLL is used as system clock source. */
    while (RCC_GetSYSCLKSource() != 0x04)
        ;
#endif

	/* Enable GPIOA, GPIOB, GPIOC, GPIOD, GPIOE and AFIO clocks */
	RCC_APB2PeriphClockCmd(	RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |RCC_APB2Periph_GPIOC
							| RCC_APB2Periph_GPIOD | RCC_APB2Periph_AFIO, ENABLE );

	/* Set the Vector Table base address at 0x08000000. */
	NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x0 );

	NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 );

	/* Configure HCLK clock as SysTick clock source. */
	SysTick_CLKSourceConfig( SysTick_CLKSource_HCLK );
#endif

    /* Update the SystemCoreClock variable based on current register settings */
    SystemCoreClockUpdate();

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

    /* Unused pins - pull up */
    /* GPIOA: PA10 */
    GPIO_InitStruct.GPIO_Pin = GPIO_Pin_10;
    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
    GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(GPIOA, &GPIO_InitStruct);
    /* GPIOB: PB12 PB14 PB15 */
    GPIO_InitStruct.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_14 | GPIO_Pin_15;
    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
    GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(GPIOB, &GPIO_InitStruct);
    /* GPIOC: PC0 PC5 PC6 PC7 PC8 PC9 */
    GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9;
    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
    GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(GPIOC, &GPIO_InitStruct);

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

    /* Init SPI and GPIO for EPD */
    epdInitInterface();

	/* APB1 Periph clock enable */
	RCC_APB1PeriphClockCmd( RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE );

    /* --------------------------------------------------------------------------- */
    /* RTC */
    /* Enable access to backup registers and RTC */
    PWR_BackupAccessCmd(ENABLE);

    /* Reset backup domain; this allows one-time configuration of RTC clock below. */
    BKP_DeInit();

    /* Enable LSE extenal xtal osci */
    RCC_LSEConfig(RCC_LSE_ON);

    /* FIXME: LSE SOMETIMES STOPS WORKING !! - TEMPERATURE ?? */
#if 0
    /* wait until LSE xtal osci is stable */
    while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) { }
    /* Set RTC clock source = external 32.768kHz xtal */
    RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
#else

    RCC_RTCCLKConfig(RCC_RTCCLKSource_HSE_Div128);

#endif

    /* Enable RTC clock after it has been selected */
    RCC_RTCCLKCmd(ENABLE);

    RTC_ExitConfigMode();
    RTC_WaitForSynchro();
    RTC_WaitForLastTask();

#if 0
    /* set prescaler: divide 32.768kHz LSE XTAL clock by 32768 -> generate 1Hz irq */
    RTC_SetPrescaler(32768);
#else
    /* set prescaler: divide 8MHz/128 HSE clock by 62500 -> generate 1Hz irq */
    RTC_SetPrescaler(62500);
#endif

    RTC_WaitForLastTask();

    /* enable RTC irq */
    RTC_ITConfig(RTC_IT_SEC, ENABLE);

    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = configLIBRARY_KERNEL_INTERRUPT_PRIORITY;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQn;
    NVIC_Init( &NVIC_InitStructure );

    RTC_WaitForLastTask();

    /* ------------------------------------------------------------------------ */
    /* ADC */
#if 1
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);

    ADC_InitTypeDef ADC_InitStruct;
    ADC_StructInit(&ADC_InitStruct);
    ADC_InitStruct.ADC_Mode = ADC_Mode_Independent;
    ADC_InitStruct.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
    ADC_Init(ADC1, &ADC_InitStruct);

    ADC_Cmd(ADC1, ENABLE);
    ADC_TempSensorVrefintCmd(ENABLE);

    ADC_ITConfig(ADC1, ADC_IT_EOC, ENABLE);
    NVIC_InitStructure.NVIC_IRQChannel = ADC1_2_IRQn;
    NVIC_Init( &NVIC_InitStructure );
#endif

    /* ------------------------------------------------------------------------ */
    /* Buttons */
    /* Configure GPIO pins : PB5,6,7 = Buttons 0, 1, 2 */
    GPIO_InitStruct.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;
    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
    GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(GPIOB, &GPIO_InitStruct);

    /* USBPOW (PA9) input pull-down */
    GPIO_InitStruct.GPIO_Pin = USBPOW_Pin;
    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPD;
    GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(USBPOW_Port, &GPIO_InitStruct);

    /* CHARGESTAT (PB11) input pull-up */
    GPIO_InitStruct.GPIO_Pin = GPIO_Pin_11;
    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IPU;
    GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(GPIOB, &GPIO_InitStruct);

    /* configure interrupts from buttons: EXTI 5, 6, 7  */
    EXTI_InitTypeDef EXTI_InitStruct;
    EXTI_InitStruct.EXTI_Line = EXTI_Line5 | EXTI_Line6 | EXTI_Line7 /*| EXTI_Line9*/;
    EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
    EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
    EXTI_InitStruct.EXTI_LineCmd = ENABLE;
    EXTI_Init(&EXTI_InitStruct);

    /* set EXTI sources */
    GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource5); // BTN0
    GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource6); // BTN1
    GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource7); // BTN2
    // GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource9); // USBPOW

#if 1
    /* all the interrupts go to the EXTI9_5_IRQn IRQ-line */
    NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
    NVIC_Init( &NVIC_InitStructure );
#endif

    /* ------------------------------------------------------------------------ */
    /* LEDs */
    /* Configure GPIO pin : PC10=LEDRK, PC11=LEDGK, PC12=LEDBK Output */
    GPIO_InitStruct.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12;
    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(GPIOC, &GPIO_InitStruct);
    /* set cathodes HI */
    GPIO_SetBits(GPIOC, GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12);

    /* Configure GPIO pin : PD2=LED1A,  Output */
    GPIO_InitStruct.GPIO_Pin = GPIO_Pin_2;
    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(GPIOD, &GPIO_InitStruct);
    /* set anode LO */
    GPIO_ResetBits(GPIOD, GPIO_Pin_2);

    /* Configure GPIO pin : PB8=LED2A, PB9=LED3A, Output */
    GPIO_InitStruct.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;
    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(GPIOB, &GPIO_InitStruct);
    /* set anode LO */
    GPIO_ResetBits(GPIOB, GPIO_Pin_8 | GPIO_Pin_9);

    /* The CHARGEBLUE LED (PA8): Set high-impedence floating -> no current  */
    GPIO_InitStruct.GPIO_Pin = GPIO_Pin_8;
    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;
    GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(GPIOA, &GPIO_InitStruct);

    /* ------------------------------------------------------------------------ */
    /* Motors */
    /* Configure GPIO pin : PB13 Output */
    GPIO_InitStruct.GPIO_Pin = MOTOR_Pin;
    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(MOTOR_Port, &GPIO_InitStruct);
    /* set Motor_1 off */
    GPIO_ResetBits(MOTOR_Port, MOTOR_Pin);

    /* ------------------------------------------------------------------------ */
    /* BTM GPIO Signals */
#if 0
    /* Configure GPIO pin : PC4=BTM_RESET,  Output */
    GPIO_InitStruct.GPIO_Pin = BTM_Reset_Pin;
    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStruct.GPIO_Speed = GPIO_Speed_10MHz;
    GPIO_Init(BTM_Reset_Port, &GPIO_InitStruct);
    GPIO_SetBits(BTM_Reset_Port, BTM_Reset_Pin);
#endif

    /* ------------------------------------------------------------------------ */
    /* Debugging in low-power modes */
    DBGMCU_Config(DBGMCU_SLEEP | DBGMCU_STOP | DBGMCU_STANDBY, ENABLE);
}

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

void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
{
	/* This function will get called if a task overflows its stack.   If the
	parameters are corrupt then inspect pxCurrentTCB to find which was the
	offending task. */

	( void ) pxTask;
	( void ) pcTaskName;

	for( ;; );
}
/*-----------------------------------------------------------*/

void assert_failed( char *pucFile, unsigned long ulLine )
{
	( void ) pucFile;
	( void ) ulLine;

    char buf[64];

    strcpy(buf, "ASS-FAIL: ");
    strcat(buf, pucFile);
    strcat(buf, ":");
    itostr(buf+strlen(buf), 8, ulLine);
    strcat(buf, ";");

    printstr(buf);

	for( ;; );
}

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


text:
class Spree::Cms::Image < ActiveRecord::Base
  has_attached_file :upload,
                    styles: { thumb: '1200x800>' },
                    default_style: :thumb,
                    url: '/spree/cms/image/:id/:style/:basename.:extension',
                    path: ':rails_root/public/spree/cms/image/:id/:style/:basename.:extension'
                    # convert_options: { all: '-strip -auto-orient -colorspace sRGB' }

  validates_attachment :upload,
                       :presence => true,
                       :content_type => { :content_type => %w(image/jpeg image/jpg image/png image/gif) }
end


text:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;

namespace Core.ClipboardEnhance
{
    /// <summary>
    /// Holds clipboard data of a single data format.
    /// </summary>
    [Serializable]
    public class DataClip
    {
        private uint format;

        /// <summary>
        /// Get or Set the format code of the data
        /// </summary>
        public uint Format
        {
            get { return format; }
            set { format = value; }
        }

        private string formatName;
        /// <summary>
        /// Get or Set the format name of the data
        /// </summary>
        public string FormatName
        {
            get { return formatName; }
            set { formatName = value; }
        }
        private byte[] buffer;

        private int size;

        /// <summary>
        /// Get or Set the buffer data
        /// </summary>
        public byte[] Buffer
        {
            get { return buffer; }
            set { buffer = value; }
        }
        /// <summary>
        /// Get the data buffer lenght
        /// </summary>
        public UIntPtr Size
        {
            get
            {
                if (buffer != null)
                {
                    //Read the correct size from buffer, if it is not null
                    return new UIntPtr(Convert.ToUInt32(buffer.GetLength(0)));
                }
                else
                {
                    //else return the optional set size
                    return new UIntPtr(Convert.ToUInt32(size));
                }
            }
        }
        /// <summary>
        /// Init a Clip Data object, containing one clipboard data and its format
        /// </summary>
        /// <param name="format"></param>
        /// <param name="formatName"></param>
        /// <param name="buffer"></param>
        public DataClip(uint format, string formatName, byte[] buffer)
        {
            this.format = format;
            this.formatName = formatName;
            this.buffer = buffer;
            this.size = 0;
        }
/// <summary>
/// Init an empty Clip Data object, used for serialize object
/// </summary>
        public DataClip() { }
    }

}


text:
// Copyright (c) 2017 VMware, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { Injectable } from '@angular/core';
import { HttpClient, HttpParams, HttpResponse } from '@angular/common/http';
import { map, catchError } from 'rxjs/operators';
import { Observable, throwError as observableThrowError } from 'rxjs';
import { User, LDAPUser } from './user';
import LDAPUsertoUser from './user';
import {
    buildHttpRequestOptionsWithObserveResponse,
    CURRENT_BASE_HREF,
    HTTP_GET_OPTIONS,
    HTTP_JSON_OPTIONS,
} from '../../../shared/units/utils';

const userMgmtEndpoint = CURRENT_BASE_HREF + '/users';
const userListSearch = CURRENT_BASE_HREF + '/users/search?';
const ldapUserEndpoint = CURRENT_BASE_HREF + '/ldap/users';

/**
 * Define related methods to handle account and session corresponding things
 *
 **
 * class SessionService
 */
@Injectable({
    providedIn: 'root',
})
export class UserService {
    constructor(private http: HttpClient) {}
    // Get paging user list
    getUserListByPaging(page: number, pageSize: number, username?: string) {
        let params = new HttpParams();
        if (page && pageSize) {
            params = params
                .set('page', page + '')
                .set('page_size', pageSize + '');
        }
        if (username) {
            params = params.set('username', username);
        }
        return this.http
            .get<HttpResponse<User[]>>(
                userMgmtEndpoint,
                buildHttpRequestOptionsWithObserveResponse(params)
            )
            .pipe(catchError(error => observableThrowError(error)));
    }
    // Handle the related exceptions
    handleError(error: any): Observable<any> {
        return observableThrowError(error);
    }

    // Get the user list
    getUsersNameList(name: string, page_size: number): Observable<User[]> {
        return this.http
            .get(
                `${userListSearch}page_size=${page_size}&username=${name}`,
                HTTP_GET_OPTIONS
            )
            .pipe(
                map(response => response as User[]),
                catchError(error => this.handleError(error))
            );
    }
    getUsers(): Observable<User[]> {
        return this.http.get(userMgmtEndpoint).pipe(
            map(
                (response: any) => {
                    return response as User[];
                },
                catchError(error => this.handleError(error))
            )
        );
    }

    // Add new user
    addUser(user: User): Observable<any> {
        return this.http
            .post(userMgmtEndpoint, JSON.stringify(user), HTTP_JSON_OPTIONS)
            .pipe(
                map(() => null),
                catchError(error => this.handleError(error))
            );
    }

    // Delete the specified user
    deleteUser(userId: number): Observable<any> {
        return this.http
            .delete(userMgmtEndpoint + '/' + userId, HTTP_JSON_OPTIONS)
            .pipe(
                map(() => null),
                catchError(error => this.handleError(error))
            );
    }

    // Update user to enable/disable the admin role
    updateUser(user: User): Observable<any> {
        return this.http
            .put(
                userMgmtEndpoint + '/' + user.user_id,
                JSON.stringify(user),
                HTTP_JSON_OPTIONS
            )
            .pipe(
                map(() => null),
                catchError(error => this.handleError(error))
            );
    }

    // Set user admin role
    updateUserRole(user: User): Observable<any> {
        return this.http
            .put(
                userMgmtEndpoint + '/' + user.user_id + '/sysadmin',
                JSON.stringify(user),
                HTTP_JSON_OPTIONS
            )
            .pipe(
                map(() => null),
                catchError(error => this.handleError(error))
            );
    }

    // admin change normal user pwd
    changePassword(
        uid: number,
        newPassword: string,
        confirmPwd: string
    ): Observable<any> {
        if (!uid || !newPassword) {
            return observableThrowError('Invalid change uid or password');
        }

        return this.http
            .put(
                userMgmtEndpoint + '/' + uid + '/password',
                {
                    old_password: newPassword,
                    new_password: confirmPwd,
                },
                HTTP_JSON_OPTIONS
            )
            .pipe(
                map(response => response),
                catchError(error => {
                    return observableThrowError(error);
                })
            );
    }

    // Get User from LDAP
    getLDAPUsers(username: string): Observable<User[]> {
        return this.http
            .get(
                `${ldapUserEndpoint}/search?username=${username}`,
                HTTP_GET_OPTIONS
            )
            .pipe(
                map(response => {
                    let ldapUser = (response as LDAPUser[]) || [];
                    return ldapUser.map(u => LDAPUsertoUser(u));
                }),
                catchError(error => this.handleError(error))
            );
    }

    importLDAPUsers(usernames: string[]): Observable<any> {
        return this.http
            .post(
                `${ldapUserEndpoint}/import`,
                JSON.stringify({ ldap_uid_list: usernames }),
                HTTP_JSON_OPTIONS
            )
            .pipe(
                map(() => null),
                catchError(err => this.handleError(err))
            );
    }
}


text:
<!doctype html>

    <title>Code coverage report for document-management-system/server/controllers/</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="../../../prettify.css" />
    <link rel="stylesheet" href="../../../base.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1">

      all files document-management-system/server/controllers/

        9.63%
        Statements
        13/135

        0%
        Branches
        0/50

        0%
        Functions
        0/64

        9.77%
        Lines
        13/133

   File

   Statements

   Branches

   Functions

   Lines

	DocumentController.js

	7.14%
	4/56
	0%
	0/28
	0%
	0/22
	7.27%
	4/55

	RoleController.js

	12.5%
	3/24
	0%
	0/6
	0%
	0/15
	12.5%
	3/24

	UserController.js

	10.91%
	6/55
	0%
	0/16
	0%
	0/27
	11.11%
	6/54

  Code coverage
  generated by istanbul at Fri Jun 16 2017 02:51:59 GMT+0100 (WAT)