text:
#include "stcp.h"

#include "../../utils/err.h"
#include "../../utils/cont.h"
#include "../../utils/fast.h"
#include "../../utils/wire.h"
#include "../../utils/int.h"
#include "../../utils/attr.h"

/*  States of the object as a whole. */
#define NN_STCP_STATE_IDLE 1
#define NN_STCP_STATE_PROTOHDR 2
#define NN_STCP_STATE_STOPPING_STREAMHDR 3
#define NN_STCP_STATE_ACTIVE 4
#define NN_STCP_STATE_SHUTTING_DOWN 5
#define NN_STCP_STATE_DONE 6
#define NN_STCP_STATE_STOPPING 7

/*  Possible states of the inbound part of the object. */
#define NN_STCP_INSTATE_HDR 1
#define NN_STCP_INSTATE_BODY 2
#define NN_STCP_INSTATE_HASMSG 3

/*  Possible states of the outbound part of the object. */
#define NN_STCP_OUTSTATE_IDLE 1
#define NN_STCP_OUTSTATE_SENDING 2

/*  Subordinate srcptr objects. */
#define NN_STCP_SRC_USOCK 1
#define NN_STCP_SRC_STREAMHDR 2

/*  Stream is a special type of pipe. Implementation of the virtual pipe API. */
static int nn_stcp_send (struct nn_pipebase *self, struct nn_msg *msg);
static int nn_stcp_recv (struct nn_pipebase *self, struct nn_msg *msg);
const struct nn_pipebase_vfptr nn_stcp_pipebase_vfptr = {
    nn_stcp_send,
    nn_stcp_recv
};

/*  Private functions. */
static void nn_stcp_handler (struct nn_fsm *self, int src, int type,
    void *srcptr);
static void nn_stcp_shutdown (struct nn_fsm *self, int src, int type,
    void *srcptr);

void nn_stcp_init (struct nn_stcp *self, int src,
    struct nn_epbase *epbase, struct nn_fsm *owner)
{
    nn_fsm_init (&self->fsm, nn_stcp_handler, nn_stcp_shutdown,
        src, self, owner);
    self->state = NN_STCP_STATE_IDLE;
    nn_streamhdr_init (&self->streamhdr, NN_STCP_SRC_STREAMHDR, &self->fsm);
    self->usock = NULL;
    self->usock_owner.src = -1;
    self->usock_owner.fsm = NULL;
    nn_pipebase_init (&self->pipebase, &nn_stcp_pipebase_vfptr, epbase);
    self->instate = -1;
    nn_msg_init (&self->inmsg, 0);
    self->outstate = -1;
    nn_msg_init (&self->outmsg, 0);
    nn_fsm_event_init (&self->done);
}

void nn_stcp_term (struct nn_stcp *self)
{
    nn_assert_state (self, NN_STCP_STATE_IDLE);

    nn_fsm_event_term (&self->done);
    nn_msg_term (&self->outmsg);
    nn_msg_term (&self->inmsg);
    nn_pipebase_term (&self->pipebase);
    nn_streamhdr_term (&self->streamhdr);
    nn_fsm_term (&self->fsm);
}

int nn_stcp_isidle (struct nn_stcp *self)
{
    return nn_fsm_isidle (&self->fsm);
}

void nn_stcp_start (struct nn_stcp *self, struct nn_usock *usock)
{
    /*  Take ownership of the underlying socket. */
    nn_assert (self->usock == NULL && self->usock_owner.fsm == NULL);
    self->usock_owner.src = NN_STCP_SRC_USOCK;
    self->usock_owner.fsm = &self->fsm;
    nn_usock_swap_owner (usock, &self->usock_owner);
    self->usock = usock;

    /*  Launch the state machine. */
    nn_fsm_start (&self->fsm);
}

void nn_stcp_stop (struct nn_stcp *self)
{
    nn_fsm_stop (&self->fsm);
}

static int nn_stcp_send (struct nn_pipebase *self, struct nn_msg *msg)
{
    struct nn_stcp *stcp;
    struct nn_iovec iov [3];

    stcp = nn_cont (self, struct nn_stcp, pipebase);

    nn_assert_state (stcp, NN_STCP_STATE_ACTIVE);
    nn_assert (stcp->outstate == NN_STCP_OUTSTATE_IDLE);

    /*  Move the message to the local storage. */
    nn_msg_term (&stcp->outmsg);
    nn_msg_mv (&stcp->outmsg, msg);

    /*  Serialise the message header. */
    nn_putll (stcp->outhdr, nn_chunkref_size (&stcp->outmsg.sphdr) +
        nn_chunkref_size (&stcp->outmsg.body));

    /*  Start async sending. */
    iov [0].iov_base = stcp->outhdr;
    iov [0].iov_len = sizeof (stcp->outhdr);
    iov [1].iov_base = nn_chunkref_data (&stcp->outmsg.sphdr);
    iov [1].iov_len = nn_chunkref_size (&stcp->outmsg.sphdr);
    iov [2].iov_base = nn_chunkref_data (&stcp->outmsg.body);
    iov [2].iov_len = nn_chunkref_size (&stcp->outmsg.body);
    nn_usock_send (stcp->usock, iov, 3);

    stcp->outstate = NN_STCP_OUTSTATE_SENDING;

    return 0;
}

static int nn_stcp_recv (struct nn_pipebase *self, struct nn_msg *msg)
{
    struct nn_stcp *stcp;

    stcp = nn_cont (self, struct nn_stcp, pipebase);

    nn_assert_state (stcp, NN_STCP_STATE_ACTIVE);
    nn_assert (stcp->instate == NN_STCP_INSTATE_HASMSG);

    /*  Move received message to the user. */
    nn_msg_mv (msg, &stcp->inmsg);
    nn_msg_init (&stcp->inmsg, 0);

    /*  Start receiving new message. */
    stcp->instate = NN_STCP_INSTATE_HDR;
    nn_usock_recv (stcp->usock, stcp->inhdr, sizeof (stcp->inhdr), NULL);

    return 0;
}

static void nn_stcp_shutdown (struct nn_fsm *self, int src, int type,
    NN_UNUSED void *srcptr)
{
    struct nn_stcp *stcp;

    stcp = nn_cont (self, struct nn_stcp, fsm);

    if (nn_slow (src == NN_FSM_ACTION && type == NN_FSM_STOP)) {
        nn_pipebase_stop (&stcp->pipebase);
        nn_streamhdr_stop (&stcp->streamhdr);
        stcp->state = NN_STCP_STATE_STOPPING;
    }
    if (nn_slow (stcp->state == NN_STCP_STATE_STOPPING)) {
        if (nn_streamhdr_isidle (&stcp->streamhdr)) {
            nn_usock_swap_owner (stcp->usock, &stcp->usock_owner);
            stcp->usock = NULL;
            stcp->usock_owner.src = -1;
            stcp->usock_owner.fsm = NULL;
            stcp->state = NN_STCP_STATE_IDLE;
            nn_fsm_stopped (&stcp->fsm, NN_STCP_STOPPED);
            return;
        }
        return;
    }

    nn_fsm_bad_state(stcp->state, src, type);
}

static void nn_stcp_handler (struct nn_fsm *self, int src, int type,
    NN_UNUSED void *srcptr)
{
    int rc;
    struct nn_stcp *stcp;
    uint64_t size;

    stcp = nn_cont (self, struct nn_stcp, fsm);

    switch (stcp->state) {

/******************************************************************************/
/*  IDLE state.                                                               */
/******************************************************************************/
    case NN_STCP_STATE_IDLE:
        switch (src) {

        case NN_FSM_ACTION:
            switch (type) {
            case NN_FSM_START:
                nn_streamhdr_start (&stcp->streamhdr, stcp->usock,
                    &stcp->pipebase);
                stcp->state = NN_STCP_STATE_PROTOHDR;
                return;
            default:
                nn_fsm_bad_action (stcp->state, src, type);
            }

        default:
            nn_fsm_bad_source (stcp->state, src, type);
        }

/******************************************************************************/
/*  PROTOHDR state.                                                           */
/******************************************************************************/
    case NN_STCP_STATE_PROTOHDR:
        switch (src) {

        case NN_STCP_SRC_STREAMHDR:
            switch (type) {
            case NN_STREAMHDR_OK:

                /*  Before moving to the active state stop the streamhdr
                    state machine. */
                nn_streamhdr_stop (&stcp->streamhdr);
                stcp->state = NN_STCP_STATE_STOPPING_STREAMHDR;
                return;

            case NN_STREAMHDR_ERROR:

                /* Raise the error and move directly to the DONE state.
                   streamhdr object will be stopped later on. */
                stcp->state = NN_STCP_STATE_DONE;
                nn_fsm_raise (&stcp->fsm, &stcp->done, NN_STCP_ERROR);
                return;

            default:
                nn_fsm_bad_action (stcp->state, src, type);
            }

        default:
            nn_fsm_bad_source (stcp->state, src, type);
        }

/******************************************************************************/
/*  STOPPING_STREAMHDR state.                                                 */
/******************************************************************************/
    case NN_STCP_STATE_STOPPING_STREAMHDR:
        switch (src) {

        case NN_STCP_SRC_STREAMHDR:
            switch (type) {
            case NN_STREAMHDR_STOPPED:

                 /*  Start the pipe. */
                 rc = nn_pipebase_start (&stcp->pipebase);
                 if (nn_slow (rc < 0)) {
                    stcp->state = NN_STCP_STATE_DONE;
                    nn_fsm_raise (&stcp->fsm, &stcp->done, NN_STCP_ERROR);
                    return;
                 }

                 /*  Start receiving a message in asynchronous manner. */
                 stcp->instate = NN_STCP_INSTATE_HDR;
                 nn_usock_recv (stcp->usock, &stcp->inhdr,
                     sizeof (stcp->inhdr), NULL);

                 /*  Mark the pipe as available for sending. */
                 stcp->outstate = NN_STCP_OUTSTATE_IDLE;

                 stcp->state = NN_STCP_STATE_ACTIVE;
                 return;

            default:
                nn_fsm_bad_action (stcp->state, src, type);
            }

        default:
            nn_fsm_bad_source (stcp->state, src, type);
        }

/******************************************************************************/
/*  ACTIVE state.                                                             */
/******************************************************************************/
    case NN_STCP_STATE_ACTIVE:
        switch (src) {

        case NN_STCP_SRC_USOCK:
            switch (type) {
            case NN_USOCK_SENT:

                /*  The message is now fully sent. */
                nn_assert (stcp->outstate == NN_STCP_OUTSTATE_SENDING);
                stcp->outstate = NN_STCP_OUTSTATE_IDLE;
                nn_msg_term (&stcp->outmsg);
                nn_msg_init (&stcp->outmsg, 0);
                nn_pipebase_sent (&stcp->pipebase);
                return;

            case NN_USOCK_RECEIVED:

                switch (stcp->instate) {
                case NN_STCP_INSTATE_HDR:

                    /*  Message header was received. Allocate memory for the
                        message. */
                    size = nn_getll (stcp->inhdr);
                    nn_msg_term (&stcp->inmsg);
                    nn_msg_init (&stcp->inmsg, (size_t) size);

                    /*  Special case when size of the message body is 0. */
                    if (!size) {
                        stcp->instate = NN_STCP_INSTATE_HASMSG;
                        nn_pipebase_received (&stcp->pipebase);
                        return;
                    }

                    /*  Start receiving the message body. */
                    stcp->instate = NN_STCP_INSTATE_BODY;
                    nn_usock_recv (stcp->usock,
                        nn_chunkref_data (&stcp->inmsg.body),
                       (size_t) size, NULL);

                    return;

                case NN_STCP_INSTATE_BODY:

                    /*  Message body was received. Notify the owner that it
                        can receive it. */
                    stcp->instate = NN_STCP_INSTATE_HASMSG;
                    nn_pipebase_received (&stcp->pipebase);

                    return;

                default:
                    nn_fsm_error("Unexpected socket instate",
                        stcp->state, src, type);
                }

            case NN_USOCK_SHUTDOWN:
                nn_pipebase_stop (&stcp->pipebase);
                stcp->state = NN_STCP_STATE_SHUTTING_DOWN;
                return;

            case NN_USOCK_ERROR:
                nn_pipebase_stop (&stcp->pipebase);
                stcp->state = NN_STCP_STATE_DONE;
                nn_fsm_raise (&stcp->fsm, &stcp->done, NN_STCP_ERROR);
                return;

            default:
                nn_fsm_bad_action (stcp->state, src, type);
            }

        default:
            nn_fsm_bad_source (stcp->state, src, type);
        }

/******************************************************************************/
/*  SHUTTING_DOWN state.                                                      */
/*  The underlying connection is closed. We are just waiting that underlying  */
/*  usock being closed                                                        */
/******************************************************************************/
    case NN_STCP_STATE_SHUTTING_DOWN:
        switch (src) {

        case NN_STCP_SRC_USOCK:
            switch (type) {
            case NN_USOCK_ERROR:
                stcp->state = NN_STCP_STATE_DONE;
                nn_fsm_raise (&stcp->fsm, &stcp->done, NN_STCP_ERROR);
                return;
            default:
                nn_fsm_bad_action (stcp->state, src, type);
            }

        default:
            nn_fsm_bad_source (stcp->state, src, type);
        }

/******************************************************************************/
/*  DONE state.                                                               */
/*  The underlying connection is closed. There's nothing that can be done in  */
/*  this state except stopping the object.                                    */
/******************************************************************************/
    case NN_STCP_STATE_DONE:
        nn_fsm_bad_source (stcp->state, src, type);

/******************************************************************************/
/*  Invalid state.                                                            */
/******************************************************************************/
    default:
        nn_fsm_bad_state (stcp->state, src, type);
    }
}


text:
import React, {Fragment} from "react";
import {FormGroup, Label, Button, Row, Col} from "helpers/reactstrap";
import {capitalCase} from "change-case";
const Priority = ({update, team = {}}) => {
  const updatePriority = priority => {
    update(
      Object.assign({}, team, {
        priority,
      }),
    );
  };
  return (
    <Fragment>
      <FormGroup className="priority-label" row>
        <Label size="lg" style={{marginBottom: 0, paddingBottom: 0}}>
          Priority
        </Label>
      </FormGroup>
      <Row className="team-priority">
        <Col sm={5}>
          <PriorityButton
            update={updatePriority}
            color="info"
            type="low"
            team={team}
          />
        </Col>
        <Col sm={7}>
          <PriorityButton
            update={updatePriority}
            color="success"
            type="normal"
            team={team}
          />
        </Col>
      </Row>
      <Row>
        <Col sm={6}>
          <PriorityButton
            update={updatePriority}
            color="warning"
            type="critical"
            team={team}
          />
        </Col>
        <Col sm={6}>
          <PriorityButton
            update={updatePriority}
            color="danger"
            type="emergency"
            team={team}
          />
        </Col>
      </Row>
    </Fragment>
  );
};

const PriorityButton = ({update, color, type, team}) => {
  return (
    <Button
      onClick={() => update(type)}
      disabled={!team.id}
      active={team.priority === type}
      block
      color={color}
    >
      {capitalCase(type)}
    </Button>
  );
};
export default Priority;

redpajama_set_name: RedPajamaGithub


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

namespace core_tag\output;

use renderable;
use templatable;
use renderer_base;
use stdClass;
use moodle_url;
use core_tag_tag;

/**
 * Class to display items tagged with a specific tag
 *
 * @package   core_tag
 * @copyright 2015 Marina Glancy
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
class tagindex implements templatable {

    /** @var core_tag_tag|stdClass */
    protected $tag;

    /** @var stdClass */
    protected $tagarea;

    /** @var stdClass */
    protected $record;

    /**
     * Constructor
     *
     * @param core_tag_tag|stdClass $tag
     * @param string $component
     * @param string $itemtype
     * @param string $content
     * @param bool $exclusivemode
     * @param int $fromctx context id where the link was displayed, may be used by callbacks
     *            to display items in the same context first
     * @param int $ctx context id where we need to search for items
     * @param int $rec search items in sub contexts as well
     * @param int $page
     * @param bool $totalpages
     */
    public function __construct($tag, $component, $itemtype, $content,
            $exclusivemode = false, $fromctx = 0, $ctx = 0, $rec = 1, $page = 0, $totalpages = 1) {
        $this->record = new stdClass();
        $this->tag = $tag;

        $tagareas = \core_tag_area::get_areas();
        if (!isset($tagareas[$itemtype][$component])) {
            throw new \coding_exception('Tag area for component '.$component.' and itemtype '.$itemtype.' is not defined');
        }
        $this->tagarea = $tagareas[$itemtype][$component];
        $this->record->tagid = $tag->id;
        $this->record->ta = $this->tagarea->id;
        $this->record->itemtype = $itemtype;
        $this->record->component = $component;

        $a = (object)array(
            'tagarea' => \core_tag_area::display_name($component, $itemtype),
            'tag' => \core_tag_tag::make_display_name($tag)
        );
        if ($exclusivemode) {
            $this->record->title = get_string('itemstaggedwith', 'tag', $a);
        } else {
            $this->record->title = (string)$a->tagarea;
        }
        $this->record->content = $content;

        $this->record->nextpageurl = null;
        $this->record->prevpageurl = null;
        $this->record->exclusiveurl = null;

        $url = core_tag_tag::make_url($tag->tagcollid, $tag->rawname, $exclusivemode, $fromctx, $ctx, $rec);
        $urlparams = array('ta' => $this->tagarea->id);
        if ($totalpages > $page + 1) {
            $this->record->nextpageurl = new moodle_url($url, $urlparams + array('page' => $page + 1));
        }
        if ($page > 0) {
            $this->record->prevpageurl = new moodle_url($url, $urlparams + array('page' => $page - 1));
        }
        if (!$exclusivemode && ($totalpages > 1 || $page)) {
            $this->record->exclusiveurl = new moodle_url($url, $urlparams + array('excl' => 1));
        }
        $this->record->exclusivetext = get_string('exclusivemode', 'tag', $a);
        $this->record->hascontent = ($totalpages > 1 || $page || $content);
        $this->record->anchor = $component . '_' . $itemtype;
    }

    /**
     * Magic setter
     *
     * @param string $name
     * @param mixed $value
     */
    public function __set($name, $value) {
        $this->record->$name = $value;
    }

    /**
     * Magic getter
     *
     * @param string $name
     * @return mixed
     */
    public function __get($name) {
        return $this->record->$name;
    }

    /**
     * Magic isset
     *
     * @param string $name
     * @return bool
     */
    public function __isset($name) {
        return isset($this->record->$name);
    }

    /**
     * Export this data so it can be used as the context for a mustache template.
     *
     * @param renderer_base $output
     * @return stdClass
     */
    public function export_for_template(renderer_base $output) {
        if ($this->record->nextpageurl && $this->record->nextpageurl instanceof moodle_url) {
            $this->record->nextpageurl = $this->record->nextpageurl->out(false);
        }
        if ($this->record->prevpageurl && $this->record->prevpageurl instanceof moodle_url) {
            $this->record->prevpageurl = $this->record->prevpageurl->out(false);
        }
        if ($this->record->exclusiveurl && $this->record->exclusiveurl instanceof moodle_url) {
            $this->record->exclusiveurl = $this->record->exclusiveurl->out(false);
        }
        return $this->record;
    }
}


text:
package org.wso2.carbon.apimgt.rest.api.publisher.utils.mappings;

import org.wso2.carbon.apimgt.api.dto.CertificateInformationDTO;
import org.wso2.carbon.apimgt.rest.api.publisher.dto.CertificateInfoDTO;
import org.wso2.carbon.apimgt.rest.api.publisher.dto.CertificateValidityDTO;

/**
 * This class is responsible for comverting between certificate objects.
 */
public class CertificateMappingUtil {

    /**
     * To convert Instance of {@link CertificateInformationDTO} to {@link CertificateInfoDTO};
     *
     * @param certificateInformationDTO Instance of {@link CertificateInformationDTO}
     * @return converted instance of {@link CertificateInfoDTO}.
     */
    public static CertificateInfoDTO fromCertificateInformationToDTO(
            CertificateInformationDTO certificateInformationDTO) {
        CertificateValidityDTO certificateValidityDTO = new CertificateValidityDTO();
        certificateValidityDTO.setFrom(certificateInformationDTO.getFrom());
        certificateValidityDTO.setTo(certificateInformationDTO.getTo());

        CertificateInfoDTO certificateInfoDTO = new CertificateInfoDTO();
        certificateInfoDTO.setValidity(certificateValidityDTO);
        certificateInfoDTO.setStatus(certificateInformationDTO.getStatus());
        certificateInfoDTO.setSubject(certificateInformationDTO.getSubject());
        certificateInfoDTO.setVersion(certificateInformationDTO.getVersion());

        return certificateInfoDTO;
    }
}


text: Old files and notes, just for reference (to be deleted in the future)


text:
package com.ukefu.webim.util.server.message;

import com.ukefu.util.UKTools;

public class NewRequestMessage extends Message{
	/**
	 *
	 */
	private static final long serialVersionUID = 3520656734252136303L;
	private String id = UKTools.getUUID();
	private String type ;

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
}


text:
'use strict';

var _expect = require('expect');

var _expect2 = _interopRequireDefault(_expect);

var _expectJsx = require('expect-jsx');

var _expectJsx2 = _interopRequireDefault(_expectJsx);

var _lodash = require('lodash.noop');

var _lodash2 = _interopRequireDefault(_lodash);

var _Slider = require('material-ui/Slider');

var _Slider2 = _interopRequireDefault(_Slider);

var _getMuiTheme = require('material-ui/styles/getMuiTheme');

var _getMuiTheme2 = _interopRequireDefault(_getMuiTheme);

var _MuiThemeProvider = require('material-ui/styles/MuiThemeProvider');

var _MuiThemeProvider2 = _interopRequireDefault(_MuiThemeProvider);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _testUtils = require('react-dom/test-utils');

var _testUtils2 = _interopRequireDefault(_testUtils);

var _Slider3 = require('../Slider');

var _Slider4 = _interopRequireDefault(_Slider3);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

_expect2.default.extend(_expectJsx2.default);

describe('Slider', function () {
  it('has a display name', function () {
    (0, _expect2.default)(_Slider4.default.displayName).toBe('ReduxFormMaterialUISlider');
  });

  it('renders a Slider', function () {
    (0, _expect2.default)(new _Slider4.default({
      input: {
        name: 'mySlider',
        value: 0.5,
        onDragStart: _lodash2.default
      }
    }).render()).toEqualJSX(_react2.default.createElement(_Slider2.default, { name: 'mySlider', value: 0.5, onChange: _lodash2.default, ref: 'component' }));
  });

  it('should ignore defaultValue', function () {
    (0, _expect2.default)(new _Slider4.default({
      input: {
        name: 'mySlider',
        value: 0.5,
        onDragStart: _lodash2.default
      },
      defaultValue: 0.8
    }).render()).toEqualJSX(_react2.default.createElement(_Slider2.default, { name: 'mySlider', value: 0.5, onChange: _lodash2.default, ref: 'component' }));
  });

  it('ignores errors', function () {
    (0, _expect2.default)(new _Slider4.default({
      input: {
        name: 'mySlider',
        value: 0.5,
        onDragStart: _lodash2.default
      },
      meta: {
        touched: true,
        error: 'FooError'
      }
    }).render()).toEqualJSX(_react2.default.createElement(_Slider2.default, { name: 'mySlider', value: 0.5, onChange: _lodash2.default, ref: 'component' }));
  });

  it('ignores warnings', function () {
    (0, _expect2.default)(new _Slider4.default({
      input: {
        name: 'mySlider',
        value: 0.5,
        onDragStart: _lodash2.default
      },
      meta: {
        touched: true,
        warning: 'FooWarning'
      }
    }).render()).toEqualJSX(_react2.default.createElement(_Slider2.default, { name: 'mySlider', value: 0.5, onChange: _lodash2.default, ref: 'component' }));
  });

  it('maps onChange properly', function () {
    var onChange = (0, _expect.createSpy)();
    var fieldOnChange = (0, _expect.createSpy)();

    var dom = _testUtils2.default.renderIntoDocument(_react2.default.createElement(
      _MuiThemeProvider2.default,
      { muiTheme: (0, _getMuiTheme2.default)() },
      _react2.default.createElement(_Slider4.default, {
        name: 'mySlider',
        input: { onChange: onChange, value: 0.5 },
        onChange: fieldOnChange
      })
    ));

    var slider = _testUtils2.default.findRenderedComponentWithType(dom, _Slider2.default);

    (0, _expect2.default)(onChange).toNotHaveBeenCalled();
    (0, _expect2.default)(fieldOnChange).toNotHaveBeenCalled();

    slider.props.onChange(undefined, 0.9);

    (0, _expect2.default)(onChange).toHaveBeenCalled().toHaveBeenCalledWith(0.9);

    (0, _expect2.default)(fieldOnChange).toHaveBeenCalled().toHaveBeenCalledWith(0.9);
  });

  it('provides getRenderedComponent', function () {
    var dom = _testUtils2.default.renderIntoDocument(_react2.default.createElement(
      _MuiThemeProvider2.default,
      { muiTheme: (0, _getMuiTheme2.default)() },
      _react2.default.createElement(_Slider4.default, { input: { name: 'mySlider' } })
    ));

    var element = _testUtils2.default.findRenderedComponentWithType(dom, _Slider4.default);
    (0, _expect2.default)(element.getRenderedComponent).toBeA('function');
    (0, _expect2.default)(element.getRenderedComponent()).toExist();
  });
});


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

  /**
   * @ngdoc overview
   * @name hz.dashboard.workflow
   * @description
   *
   * # hz.dashboard.workflow
   *
   * This module provides utility function factory `dashboardWorkflow` and
   * `dashboardWorkflowDecorator`.
   *
   * | Factories                                                                                |
   * |------------------------------------------------------------------------------------------------|
   * | {@link hz.dashboard.workflow.factory:dashboardWorkflowDecorator `dashboardWorkflowDecorator`}  |
   *
   */
  angular.module('hz.dashboard.workflow', []);

})();


text:
require 'spec_helper'

describe ApplicationHelper do
	# include ApplicationHelper

	def content_for(name)
		@template.instance_variable_get("@content_for_#{name}")
	end

  #Delete this example and add some real ones or delete this file
  it "should be included in the object returned by #helper" do
    included_modules = (class << helper; self; end).send :included_modules
    included_modules.should include(ApplicationHelper)
  end

	describe "#merge_classes" do
	  it "should merge two strings" do
	  	helper.merge_classes("abc", "def").should == "abc def"
	  end

	  it "should merge a string array and a string" do
	  	helper.merge_classes(%w{abc def}, "efg").should == "abc def efg"
	  end

	  it "should merge a string and a string array" do
	  	helper.merge_classes("abc", %w{def efg}).should == "abc def efg"
	  end

	  it "should merge two string arrays" do
	  	helper.merge_classes(%w{abc def}, %w{ghi jkl}).should == "abc def ghi jkl"
	  end

	end

	describe "#javascript" do
		it "adds a javascript file to the head" do
			helper.javascript('test')
			content_for(:head).should =~ /^<script.*src=\".*\/test\.js/
		end
	end

	describe "#jquery" do
		it "adds jquery javascript file to the head" do
			helper.jquery
			content_for(:head).should =~ /^<script.*src=\".*\/jquery\.js/
		end
	end

	describe "#stylesheet" do
	  it "should include a stylesheet link tag in content_for(:head)" do
	    helper.stylesheet("test")
			content_for(:head).should =~ /^<link.*href=\".*\/test\.css/
	  end
	end

	describe "#number_to_dollars" do
	  it "should format an integer as dollars" do
	    helper.number_to_dollars(10).should == "$10"
	  end

	  it "should round up and format a float as dollars" do
	    helper.number_to_dollars(10.01).should == "$11"
	  end
	end

	describe "#swap_banner_type_fields" do
	  it "should include a javascript statement" do
			helper.swap_banner_type_fields
			content_for(:head).should =~ /swap_banner_type_fields\(\);/
		end
	end
end


text:
<?xml version="1.0" encoding="UTF-8" ?>

<!--
  ~ 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.
  -->

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="org.camunda.bpm.engine.impl.persistence.entity.HistoricTaskInstanceEntity">

  <!-- HISTORIC TASK INSTANCE INSERT -->

  <insert id="insertHistoricTaskInstance" parameterType="org.camunda.bpm.engine.impl.persistence.entity.HistoricTaskInstanceEntity">
      insert into ${prefix}ACT_HI_TASKINST (
        ID_,
        PROC_DEF_ID_,
        PROC_INST_ID_,
        EXECUTION_ID_,
        NAME_,
        PARENT_TASK_ID_,
        DESCRIPTION_,
        OWNER_,
        ASSIGNEE_,
        START_TIME_,
        END_TIME_,
        DURATION_,
        DELETE_REASON_,
        TASK_DEF_KEY_,
        PRIORITY_,
        DUE_DATE_
      ) values (
        #{id ,jdbcType=VARCHAR},
        #{processDefinitionId, jdbcType=VARCHAR},
        #{processInstanceId, jdbcType=VARCHAR},
        #{executionId, jdbcType=VARCHAR},
        #{name ,jdbcType=VARCHAR},
        #{parentTaskId ,jdbcType=VARCHAR},
        #{description ,jdbcType=VARCHAR},
        #{owner ,jdbcType=VARCHAR},
        #{assignee ,jdbcType=VARCHAR},
        #{startTime, jdbcType=TIMESTAMP},
        #{endTime, jdbcType=TIMESTAMP},
        #{durationInMillis ,jdbcType=BIGINT},
        #{deleteReason ,jdbcType=VARCHAR},
        #{taskDefinitionKey ,jdbcType=VARCHAR},
        #{priority, jdbcType=INTEGER},
        #{dueDate, jdbcType=TIMESTAMP}
      )
  </insert>

  <!-- HISTORIC TASK INSTANCE UPDATE -->

  <update id="updateHistoricTaskInstance" parameterType="org.camunda.bpm.engine.impl.persistence.entity.HistoricTaskInstanceEntity">
    update ${prefix}ACT_HI_TASKINST set
      EXECUTION_ID_ = #{executionId, jdbcType=VARCHAR},
      NAME_ = #{name, jdbcType=VARCHAR},
      PARENT_TASK_ID_ = #{parentTaskId, jdbcType=VARCHAR},
      DESCRIPTION_ = #{description, jdbcType=VARCHAR},
      OWNER_ = #{owner, jdbcType=VARCHAR},
      ASSIGNEE_ = #{assignee, jdbcType=VARCHAR},
      END_TIME_ = #{endTime, jdbcType=TIMESTAMP},
      DURATION_ = #{durationInMillis ,jdbcType=BIGINT},
      DELETE_REASON_ = #{deleteReason ,jdbcType=VARCHAR},
      TASK_DEF_KEY_ = #{taskDefinitionKey ,jdbcType=VARCHAR},
      PRIORITY_ = #{priority, jdbcType=INTEGER},
      DUE_DATE_ = #{dueDate, jdbcType=TIMESTAMP}
    where ID_ = #{id}
  </update>

  <!-- HISTORIC TASK INSTANCE DELETE -->

  <delete id="deleteHistoricTaskInstance" parameterType="org.camunda.bpm.engine.impl.persistence.entity.HistoricTaskInstanceEntity">
    delete from ${prefix}ACT_HI_TASKINST where ID_ = #{id}
  </delete>

  <!-- HISTORIC TASK INSTANCE RESULT MAP -->

  <resultMap id="historicTaskInstanceResultMap" type="org.camunda.bpm.engine.impl.persistence.entity.HistoricTaskInstanceEntity">
    <id property="id" column="ID_" jdbcType="VARCHAR" />
    <result property="processDefinitionId" column="PROC_DEF_ID_" jdbcType="VARCHAR" />
    <result property="processInstanceId" column="PROC_INST_ID_" jdbcType="VARCHAR" />
    <result property="executionId" column="EXECUTION_ID_" jdbcType="VARCHAR" />
    <result property="name" column="NAME_" jdbcType="VARCHAR" />
    <result property="parentTaskId" column="PARENT_TASK_ID_" jdbcType="VARCHAR" />
    <result property="description" column="DESCRIPTION_" jdbcType="VARCHAR" />
    <result property="owner" column="OWNER_" jdbcType="VARCHAR" />
    <result property="assignee" column="ASSIGNEE_" jdbcType="VARCHAR" />
    <result property="startTime" column="START_TIME_" jdbcType="TIMESTAMP" />
    <result property="endTime" column="END_TIME_" jdbcType="TIMESTAMP" />
    <result property="durationInMillis" column="DURATION_" jdbcType="BIGINT" />
    <result property="deleteReason" column="DELETE_REASON_" jdbcType="VARCHAR" />
    <result property="taskDefinitionKey" column="TASK_DEF_KEY_" jdbcType="VARCHAR" />
    <result property="priority" column="PRIORITY_" jdbcType="INTEGER" />
    <result property="dueDate" column="DUE_DATE_" jdbcType="TIMESTAMP" />
  </resultMap>

  <!-- HISTORIC TASK INSTANCE SELECT -->

  <select id="selectHistoricTaskInstance" resultMap="historicTaskInstanceResultMap">
    select * from ${prefix}ACT_HI_TASKINST where ID_ = #{historicTaskInstanceId}
  </select>

  <select id="selectHistoricTaskInstanceIdsByProcessInstanceId" resultType="string" parameterType="org.camunda.bpm.engine.impl.db.ListQueryParameterObject" >
    select ID_
    from ${prefix}ACT_HI_TASKINST
    where PROC_INST_ID_ = #{parameter}
  </select>

  <select id="selectHistoricTaskInstancesByQueryCriteria" parameterType="org.camunda.bpm.engine.impl.HistoricTaskInstanceQueryImpl" resultMap="historicTaskInstanceResultMap">
  	${limitBefore}
    select RES.* ${limitBetween}
    <include refid="selectHistoricTaskInstancesByQueryCriteriaSql"/>
    ${orderBy}
    ${limitAfter}
  </select>

  <select id="selectHistoricTaskInstanceCountByQueryCriteria" parameterType="org.camunda.bpm.engine.impl.HistoricTaskInstanceQueryImpl" resultType="long">
    select count(*)
    <include refid="selectHistoricTaskInstancesByQueryCriteriaSql"/>
  </select>

  <sql id="selectHistoricTaskInstancesByQueryCriteriaSql">
    from ${prefix}ACT_HI_TASKINST RES
    <if test="processFinished || processUnfinished">
      inner join ${prefix}ACT_HI_PROCINST HPI ON RES.PROC_INST_ID_ = HPI.ID_
    </if>
    <if test="processDefinitionKey != null || processDefinitionName != null">
      inner join ${prefix}ACT_RE_PROCDEF D on RES.PROC_DEF_ID_ = D.ID_
    </if>
    <where>
      <if test="taskId != null">
        RES.ID_ = #{taskId}
      </if>
      <if test="processDefinitionId != null">
        and RES.PROC_DEF_ID_ = #{processDefinitionId}
      </if>
      <if test="processDefinitionKey != null">
        and D.KEY_ = #{processDefinitionKey}
      </if>
      <if test="processDefinitionName != null">
        and D.NAME_ = #{processDefinitionName}
      </if>
      <if test="processInstanceId != null">
        and RES.PROC_INST_ID_ = #{processInstanceId}
      </if>
      <if test="taskDefinitionKey != null">
        and RES.TASK_DEF_KEY_ = #{taskDefinitionKey}
      </if>
      <if test="executionId != null">
        and RES.EXECUTION_ID_ = #{executionId}
      </if>
      <if test="taskName != null">
        and RES.NAME_ = #{taskName}
      </if>
      <if test="taskNameLike != null">
        and RES.NAME_ like #{taskNameLike}
      </if>
      <if test="taskParentTaskId != null">
        and RES.PARENT_TASK_ID_ = #{taskParentTaskId}
      </if>
      <if test="taskDescription != null">
        and RES.DESCRIPTION_ = #{taskDescription}
      </if>
      <if test="taskDescriptionLike != null">
        and RES.DESCRIPTION_ like #{taskDescriptionLike}
      </if>
      <if test="taskDeleteReason != null">
        and RES.DELETE_REASON_ = #{taskDeleteReason}
      </if>
      <if test="taskDeleteReasonLike != null">
        and RES.DELETE_REASON_ like #{taskDeleteReasonLike}
      </if>
      <if test="taskOwner != null">
        and RES.OWNER_ = #{taskOwner}
      </if>
      <if test="taskOwnerLike != null">
        and RES.OWNER_ like #{taskOwnerLike}
      </if>
      <if test="taskAssignee != null">
        and RES.ASSIGNEE_ = #{taskAssignee}
      </if>
      <if test="taskAssigneeLike != null">
        and RES.ASSIGNEE_ like #{taskAssigneeLike}
      </if>
      <if test="taskPriority != null">
        and RES.PRIORITY_ = #{taskPriority}
      </if>
      <if test="unfinished">
        and RES.END_TIME_ is null
      </if>
      <if test="finished">
        and RES.END_TIME_ is not null
      </if>
      <if test="processFinished">
        and HPI.END_TIME_ is not null
      </if>
      <if test="processUnfinished">
        and HPI.END_TIME_ is null
      </if>
      <if test="dueDate != null">
        and RES.DUE_DATE_ = #{dueDate}
      </if>
      <if test="dueBefore != null">
        and RES.DUE_DATE_ < #{dueBefore}
      </if>
      <if test="dueAfter != null">
        and RES.DUE_DATE_ > #{dueAfter}
      </if>
      <foreach collection="variables" index="index" item="var">
        and exists (
          select HD.ID_
          from ${prefix}ACT_HI_DETAIL HD
          where
            HD.TYPE_ = 'VariableUpdate'
            and HD.NAME_ =  #{var.name}
            <choose>
              <when test="var.local">
                and HD.TASK_ID_ = RES.ID_
                and HD.REV_ = (select max(HDM.REV_) from ${prefix}ACT_HI_DETAIL HDM where HDM.TASK_ID_ = RES.ID_ and HDM.VAR_TYPE_ = #{var.type} and HDM.NAME_ = #{var.name} and HDM.TYPE_ = 'VariableUpdate')
                and HD.TIME_ = (select max(HDM.TIME_) from ${prefix}ACT_HI_DETAIL HDM where HDM.TASK_ID_ = RES.ID_ and HDM.VAR_TYPE_ = #{var.type} and HDM.NAME_ = #{var.name} and HDM.TYPE_ = 'VariableUpdate')
              </when>
              <otherwise>
                and HD.PROC_INST_ID_ = RES.PROC_INST_ID_ and HD.TASK_ID_ is null
                and HD.REV_ = (select max(HDM.REV_) from ${prefix}ACT_HI_DETAIL HDM where HDM.PROC_INST_ID_ = RES.PROC_INST_ID_ and HDM.TASK_ID_ is null and HDM.VAR_TYPE_ = #{var.type} and HDM.NAME_ = #{var.name} and HDM.TYPE_ = 'VariableUpdate')
                and HD.TIME_ = (select max(HDM.TIME_) from ${prefix}ACT_HI_DETAIL HDM where HDM.PROC_INST_ID_ = RES.PROC_INST_ID_ and HDM.TASK_ID_ is null and HDM.VAR_TYPE_ = #{var.type} and HDM.NAME_ = #{var.name} and HDM.TYPE_ = 'VariableUpdate')
              </otherwise>
            </choose>
            <if test="!var.type.equals('null')">
              and HD.VAR_TYPE_ = #{var.type}
            </if>
            <!-- Variable value -->
            <if test="var.textValue != null && var.longValue == null && var.doubleValue == null">
              and HD.TEXT_ =  #{var.textValue}
            </if>
            <if test="var.textValue2 != null">
              and HD.TEXT2_ = #{var.textValue2}
            </if>
            <if test="var.longValue != null">
              and HD.LONG_ = #{var.longValue}
            </if>
            <if test="var.doubleValue != null">
              and HD.DOUBLE_ = #{var.doubleValue}
            </if>
            <!-- Null variable type -->
            <if test="var.textValue == null && var.textValue2 == null && var.longValue == null && var.doubleValue == null">
              and HD.TEXT_ is null and HD.TEXT2_ is null and HD.LONG_ is null and HD.DOUBLE_ is null and HD.BYTEARRAY_ID_ is null
            </if>
        )
      </foreach>
    </where>
  </sql>

  <select id="selectHistoricTaskInstanceByNativeQuery" parameterType="java.util.Map" resultMap="historicTaskInstanceResultMap">
    <if test="resultType == 'LIST_PAGE'">
      ${limitBefore}
    </if>
    ${sql}
    <if test="resultType == 'LIST_PAGE'">
      ${limitAfter}
    </if>
  </select>

  <select id="selectHistoricTaskInstanceByNativeQuery_mssql_or_db2" parameterType="java.util.Map" resultMap="historicTaskInstanceResultMap">
    <if test="resultType == 'LIST_PAGE'">
        ${limitBeforeNativeQuery}
    </if>
    ${sql}
    <if test="resultType == 'LIST_PAGE'">
      ${limitAfter}
    </if>
  </select>

  <select id="selectHistoricTaskInstanceCountByNativeQuery" parameterType="java.util.Map" resultType="long">
    ${sql}
  </select>
</mapper>


text:
/**********************************************************************
* $Id$		lpc18xx_rgu.h		2011-06-02
*//**
* @file		lpc18xx_rgu.h
* @brief	Contains all macro definitions and function prototypes
* 			support for RGU firmware library on LPC18xx
* @version	1.0
* @date		02. June. 2011
* @author	NXP MCU SW Application Team
*
* Copyright(C) 2011, NXP Semiconductor
* All rights reserved.
*
***********************************************************************
* Software that is described herein is for illustrative purposes only
* which provides customers with programming information regarding the
* products. This software is supplied "AS IS" without any warranties.
* NXP Semiconductors assumes no responsibility or liability for the
* use of the software, conveys no license or title under any patent,
* copyright, or mask work right to the product. NXP Semiconductors
* reserves the right to make changes in the software without
* notification. NXP Semiconductors also make no representation or
* warranty that such application will be suitable for the specified
* use without further testing or modification.
* Permission to use, copy, modify, and distribute this software and its
* documentation is hereby granted, under NXP Semiconductors'
* relevant copyright in the software, without fee, provided that it
* is used in conjunction with NXP Semiconductors microcontrollers.  This
* copyright, permission, and disclaimer notice must appear in all copies of
* this code.
**********************************************************************/

/* Peripheral group ----------------------------------------------------------- */
/** @defgroup RGU RGU (Reset Generation Unit)
 * @ingroup LPC1800CMSIS_FwLib_Drivers
 * @{
 */

#ifndef LPC18XX_RGU_H_
#define LPC18XX_RGU_H_

/* Includes ------------------------------------------------------------------- */
#include "LPC18xx.h"
#include "lpc_types.h"

#ifdef __cplusplus
extern "C"
{
#endif
/* Public Types --------------------------------------------------------------- */
/** @defgroup RGU_Public_Types RGU Public Types
 * @{
 */

/*********************************************************************//**
 * @brief RGU enumeration
 **********************************************************************/
/** @brief Out Reset Signal Generated by RGU */
typedef enum
{
	RGU_SIG_CORE  = 0,					/**< Core reset signal 			*/
	RGU_SIG_PERIPH,						/**< Peripheral reset signal	*/
	RGU_SIG_MASTER,						/**< Master reset signal		*/
	RGU_SIG_WWDT = 4,					/**< WWDT reset signal			*/
	RGU_SIG_CREG,						/**< CREG reset signal			*/
	RGU_SIG_BUS = 8,					/**< Bus reset signal			*/
	RGU_SIG_SCU,						/**< SCU reset signal			*/
	RGU_SIG_PINMUX,						/**< Pin mux reset signal		*/
	RGU_SIG_M3 = 13,					/**< Cortex-M3 reset signal		*/
	RGU_SIG_LCD = 16,					/**< LCD reset signal			*/
	RGU_SIG_USB0,						/**< USB0 reset signal			*/
	RGU_SIG_USB1,						/**< USB1 reset signal			*/
	RGU_SIG_DMA,						/**< DMA reset signal			*/
	RGU_SIG_SDIO,						/**< SDIO reset signal			*/
	RGU_SIG_EMC,						/**< EMC reset signal			*/
	RGU_SIG_ETHERNET,					/**< Ethernet reset signal		*/
	RGU_SIG_AES,						/**< AES reset signal			*/
	RGU_SIG_GPIO = 28,					/**< GPIO reset signal			*/
	RGU_SIG_TIMER0 = 32,				/**< TIMER 0 reset signal		*/
	RGU_SIG_TIMER1,						/**< TIMER 1 reset signal		*/
	RGU_SIG_TIMER2,						/**< TIMER 2 reset signal		*/
	RGU_SIG_TIMER3,						/**< TIMER 3 reset signal		*/
	RGU_SIG_RITIMER,					/**< RIT timer reset signal		*/
	RGU_SIG_SCT,						/**< SCT reset signal			*/
	RGU_SIG_MOTOCONPWM,					/**< Motor control reset signal	*/
	RGU_SIG_QEI,						/**< QEI reset signal			*/
	RGU_SIG_ADC0,						/**< ADC0 reset signal			*/
	RGU_SIG_ADC1,						/**< ADC1 reset signal			*/
	RGU_SIG_DAC,						/**< DAC reset signal			*/
	RGU_SIG_UART0 = 44,					/**< UART0 reset signal			*/
	RGU_SIG_UART1,						/**< UART1 reset signal			*/
	RGU_SIG_UART2,						/**< UART2 reset signal			*/
	RGU_SIG_UART3,						/**< UART3 reset signal			*/
	RGU_SIG_I2C0,						/**< I2C0 reset signal			*/
	RGU_SIG_I2C1,						/**< I2C1 reset signal			*/
	RGU_SIG_SSP0,						/**< SSP0 reset signal			*/
	RGU_SIG_SSP1,						/**< SSP1 reset signal			*/
	RGU_SIG_I2S,						/**< I2S reset signal			*/
	RGU_SIG_SPIFI,						/**< SPIFI reset signal			*/
	RGU_SIG_CAN = 55					/**< CAN reset signal			*/
}RGU_SIG;

/** @brief Reset Cause Source */
typedef enum {
	RGU_SRC_NONE,						/**< No source				*/
	RGU_SRC_SOFT,						/**< Software reset source	*/
	RGU_SRC_EXT,						/**< External reset source	*/
	RGU_SRC_CORE,						/**< Core reset source		*/
	RGU_SRC_PERIPH,						/**< Peripheral reset source*/
	RGU_SRC_MASTER,						/**< Master reset source	*/
	RGU_SRC_BOD,						/**< BOD reset source		*/
	RGU_SRC_WWDT						/**< WWDT reset source		*/
}RGU_SRC;
/**
 * @}
 */

/* Public Functions ----------------------------------------------------------- */
/** @defgroup RGU_Public_Functions RGU Public Functions
 * @{
 */
/* RGU peripheral control function ----------------*/
void RGU_SoftReset(RGU_SIG ResetSignal);
RGU_SRC RGU_GetSource(RGU_SIG ResetSignal);
Bool RGU_GetSignalStatus(RGU_SIG ResetSignal);

/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif /* LPC18XX_RGU_H_ */

/**
 * @}
 */

/* --------------------------------- End Of File ------------------------------ */


text:
var express = require('express') // hey we want to use express, our web host / routing system
var app = express(); // starts express running
var server = require('http').Server( app ) // start a server instance on a port
var io = require('socket.io')(server) // use socket.io for real time connections a.k.a websockets

var port = process.env.PORT || 8000

server.listen(port, function(){
  console.log("App is running on port" + port);
}) //server, set up a server on port 3001, do a call back when it srated successfully

app.use( express.static('public') ) //server out everything that is in the public folder

var storedPositions = []; //array of all stored postion element

io.on('connection', function(socket){ // if socket.io sees a new connection, do something with them...
  console.log(socket.id) // this prints out the socket that connected (ie: all users + the projection)

  io.emit('storedPositionsMessage', storedPositions);

  // socket.on('addRectangle', function(data){ // look for any messages with the 'addRectangle'
  //   console.log("addRectangle" + data); // log out the 'data' in this case you get true, but you could use this to get any arbitray data you want, think postion, color, ect.
  //   io.emit('projectionRectangle', data); // this sends out a message to the porjection to add a rectangle to the screen
  socket.on('addRectangle', function(buttons){ // look for any messages with the 'addRectangle'
    console.log("addRectangle" + buttons); // log out the 'data' in this case you get true, but you could use this to get any arbitray data you want, think postion, color, ect.
    io.emit('projectionRectangle', buttons); // this sends out a message to the porjection to add a rectangle to the screen

    storedPositions.push(buttons);

  })

})


text:
package banba.com.exceptionexample;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ApplicationErrorReport;
import android.app.ListActivity;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;

public class E extends ListActivity {
    public static void showPopUp(final Context context) {
        final ExceptionDatabase db = new ExceptionDatabase(context);
        final List<ExceptionItem> items = db.getAll();
        ExceptionItemAdapter adapter = new ExceptionItemAdapter(context, items);
        ListView listViewItems = new ListView(context);
        listViewItems.setAdapter(adapter);
        listViewItems.setFastScrollEnabled(true);
        AlertDialog dialog = new AlertDialog.Builder(context)
                .setView(listViewItems)
                .setTitle("Exceptions")
                .setPositiveButton("Share", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        Intent sendIntent = new Intent();
                        sendIntent.setAction(Intent.ACTION_SEND);
                        StringBuilder b = new StringBuilder();
                        for (ExceptionItem i : items) {
                            b.append(i.toString()).append("\n");
                        }
                        sendIntent.putExtra(Intent.EXTRA_TEXT, b.toString());
                        sendIntent.setType("text/plain");
                        context.startActivity(sendIntent);
                    }
                })
                .setNegativeButton("Clear Exceptions", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        db.deleteAll();
                        Toast.makeText(context, "All exceptions cleared", Toast.LENGTH_SHORT).show();
                    }
                }).create();
        dialog.show();
    }

    public static void LogError(Throwable ex, Context context) {
        ApplicationErrorReport report = new ApplicationErrorReport();
        report.time = System.currentTimeMillis();
        report.type = ApplicationErrorReport.TYPE_CRASH;
        report.systemApp = false;

        ApplicationErrorReport.CrashInfo crash = new ApplicationErrorReport.CrashInfo();
        crash.exceptionClassName = ex.getClass().getSimpleName();
        crash.exceptionMessage = ex.getMessage();

        StringWriter writer = new StringWriter();
        PrintWriter printer = new PrintWriter(writer);
        ex.printStackTrace(printer);

        crash.stackTrace = writer.toString();

        StackTraceElement stack = ex.getStackTrace()[0];
        crash.throwClassName = stack.getClassName();
        crash.throwFileName = stack.getFileName();
        crash.throwLineNumber = stack.getLineNumber();
        crash.throwMethodName = stack.getMethodName();

        report.crashInfo = crash;

        ExceptionItem item = new ExceptionItem();
        item.packageName = report.packageName;
        item.exceptionTime = report.time;
        item.exceptionType = Long.valueOf(report.type);
        item.exceptionMessage = crash.exceptionMessage;
        item.stackTrace = crash.stackTrace;
        item.throwClassName = crash.throwClassName;
        item.throwFileName = crash.throwFileName;
        item.throwLineNumber = crash.throwLineNumber;
        item.throwMethodName = crash.throwMethodName;

        Log.e("EXCEPTION", item.toString());

        ExceptionDatabase db = new ExceptionDatabase(context);
        db.add(item);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setTitle("Exceptions");
        super.onCreate(savedInstanceState);
        setContentView(android.R.layout.list_content);
        ExceptionDatabase db = new ExceptionDatabase(this);
        final List<ExceptionItem> items = db.getAll();
        ExceptionItemAdapter adapter = new ExceptionItemAdapter(this, items);
        getListView().setAdapter(adapter);
    }

    public static class ExHandler implements Thread.UncaughtExceptionHandler {
        Context mContext;

        public ExHandler(Context context) {
            mContext = context;
        }

        @Override
        public void uncaughtException(Thread thread, Throwable ex) {
            LogError(ex, mContext);
        }
    }

    static class ExceptionItem {
        long id;
        String packageName;
        Long exceptionTime;
        Long exceptionType;
        String exceptionClassName;
        String exceptionMessage;
        String stackTrace;
        String throwClassName;
        String throwFileName;
        int throwLineNumber;
        String throwMethodName;

        @Override
        public String toString() {
            return "Exception:" +
                    "\nTime = " + exceptionTime +
                    "\nPackage Name = " + packageName +
                    "\nType = " + exceptionType +
                    "\nClass Name = " + exceptionClassName +
                    "\nMessage = " + exceptionMessage +
                    "\nthrow Class Name = " + throwClassName +
                    "\nthrow File Name = " + throwFileName +
                    "\nthrow Line Number = " + throwLineNumber +
                    "\nthrow Method Name = " + throwMethodName +
                    "\nStack Trace = [\n" + stackTrace + "\n]";
        }
    }

    static class ExceptionItemHolder {
        TextView className;
        TextView message;
    }

    static class ExceptionItemAdapter extends ArrayAdapter<ExceptionItem> {
        Context context;

        public ExceptionItemAdapter(Context context, List items) {
            super(context, android.R.layout.simple_list_item_2, items);
            this.context = context;
        }

        public View getView(int position, View convertView, ViewGroup parent) {
            ExceptionItemHolder holder = null;
            final ExceptionItem item = getItem(position);
            if (convertView == null) {
                LayoutInflater inflater = ((Activity) context).getLayoutInflater();
                convertView = inflater.inflate(android.R.layout.simple_list_item_2, parent, false);
                holder = new ExceptionItemHolder();
                holder.className = (TextView) convertView.findViewById(android.R.id.text1);
                holder.message = (TextView) convertView.findViewById(android.R.id.text2);
                convertView.setTag(holder);
                convertView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Toast.makeText(context, item.toString(), Toast.LENGTH_LONG).show();
                    }
                });
            } else {
                holder = (ExceptionItemHolder) convertView.getTag();
            }

            holder.className.setText(item.exceptionMessage);
            holder.message.setText(item.stackTrace.substring(0, 200));
            return convertView;
        }
    }

    static class ExceptionDatabase extends SQLiteOpenHelper {
        private static final int DATABASE_VERSION = 1;
        private static final String DATABASE_NAME = "exceptions.db";
        private static final String TABLE_EXCEPTIONS = "exceptions";

        private static final String KEY_ID = "ID";
        private static final String PACKAGE_NAME = "PACKAGE_NAME";
        private static final String EXCEPTION_TIME = "EXCEPTION_TIME";
        private static final String EXCEPTION_TYPE = "EXCEPTION_TYPE";
        private static final String EXCEPTION_CLASS_NAME = "EXCEPTION_CLASS_NAME";
        private static final String EXCEPTION_MESSAGE = "EXCEPTION_MESSAGE";
        private static final String STACKTRACE = "STACKTRACE";
        private static final String THROW_CLASS_NAME = "THROW_CLASS_NAME";
        private static final String THROW_FILE_NAME = "THROW_FILE_NAME";
        private static final String THROW_LINE_NUMBER = "THROW_LINE_NUMBER";
        private static final String KEY_METHOD_NAME = "THROW_METHOD_NAME";

        public ExceptionDatabase(Context context) {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            String CREATE_ARTICLES_TABLE = "CREATE TABLE "
                    + TABLE_EXCEPTIONS + " ( "
                    + PACKAGE_NAME + " TEXT , "
                    + EXCEPTION_TIME + " LONG , "
                    + EXCEPTION_TYPE + " TEXT ,"
                    + EXCEPTION_CLASS_NAME + " TEXT ,"
                    + EXCEPTION_MESSAGE + " TEXT , "
                    + STACKTRACE + " TEXT , "
                    + THROW_CLASS_NAME + " TEXT , "
                    + THROW_FILE_NAME + " TEXT , "
                    + THROW_LINE_NUMBER + " INTEGER , "
                    + KEY_METHOD_NAME + " TEXT , "
                    + KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT)";
            db.execSQL(CREATE_ARTICLES_TABLE);

//            String trigger = "CREATE TRIGGER delete_tail AFTER INSERT ON "
//                    + TABLE_EXCEPTIONS +
//                    "BEGIN DELETE FROM "
//                    + TABLE_EXCEPTIONS +
//                    " WHERE id%10=NEW.id%10 AND id!=NEW.id; END;";
//            db.execSQL(trigger);
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            db.execSQL("DROP TABLE IF EXISTS " + TABLE_EXCEPTIONS);
            onCreate(db);
        }

        public void add(ExceptionItem ex) {
            SQLiteDatabase db = getWritableDatabase();
            ContentValues values = new ContentValues();
            values.put(PACKAGE_NAME, ex.packageName);
            values.put(EXCEPTION_TIME, ex.exceptionTime);
            values.put(EXCEPTION_TYPE, ex.exceptionType);
            values.put(EXCEPTION_CLASS_NAME, ex.exceptionClassName);
            values.put(EXCEPTION_MESSAGE, ex.exceptionMessage);
            values.put(STACKTRACE, ex.stackTrace);
            values.put(THROW_CLASS_NAME, ex.throwClassName);
            values.put(THROW_FILE_NAME, ex.throwFileName);
            values.put(THROW_LINE_NUMBER, ex.throwLineNumber);
            db.insert(TABLE_EXCEPTIONS, null, values);
            db.close();
        }

        public List<ExceptionItem> getAll() {
            List<ExceptionItem> articleList = new ArrayList<>();
            String selectQuery = "SELECT  * FROM " + TABLE_EXCEPTIONS + " ORDER BY " + EXCEPTION_TIME;
            SQLiteDatabase db = getWritableDatabase();
            Cursor cursor = db.rawQuery(selectQuery, null);
            if (cursor.moveToLast()) {
                do {
                    ExceptionItem item = new ExceptionItem();
                    item.id = cursor.getLong(0);
                    item.packageName = cursor.getString(0);
                    item.exceptionTime = cursor.getLong(1);
                    item.exceptionType = cursor.getLong(2);
                    item.exceptionClassName = cursor.getString(3);
                    item.exceptionMessage = cursor.getString(4);
                    item.stackTrace = cursor.getString(5);
                    item.throwClassName = cursor.getString(6);
                    item.throwFileName = cursor.getString(7);
                    item.throwLineNumber = cursor.getInt(8);
                    item.throwMethodName = cursor.getString(9);
                    articleList.add(item);
                } while (cursor.moveToPrevious());
            }
            db.close();
            return articleList;
        }

        public void deleteAll() {
            SQLiteDatabase db = getWritableDatabase();
            db.delete(TABLE_EXCEPTIONS, null, null);
            db.close();
        }
    }
}


text:
require 'test_helper'

class PaypalReturnTest < Test::Unit::TestCase
  include OffsitePayments::Integrations

  def test_return
    r = Paypal::Return.new('')
    assert r.success?
  end
end


text:
<resources>
    <string name="app_name">A8</string>

    <string name="hello_world">Hello world!</string>
    <string name="action_settings">Settings</string>
    <string name="Brand_String">Brand</string>
    <string name="StockAmount_String">N/A</string>
    <string name="title_activity_edit">EditActivity</string>
    <string name="title_activity_change_stock">ChangeStock</string>
</resources>


text:
module Mongoid
  module Errors

    # This error is raised when a bad global executor concurrency option is attempted
    # to be set.
    class InvalidGlobalExecutorConcurrency < MongoidError

      # Create the new error.
      #
      # @api private
      def initialize
        super(
          compose_message(
            "invalid_global_executor_concurrency"
          )
        )
      end
    end
  end
end


text:
package de.zib.scalaris.examples.wikipedia;

import java.util.List;

import de.zib.scalaris.RequestList;
import de.zib.scalaris.operations.AddDelOnListOp;
import de.zib.scalaris.operations.AddOnNrOp;

/**
 * Implements a list append operation using the append operation of Scalaris.
 *
 * For a correct counter in the <tt>countKey</tt>, this class assumes that every
 * element from the <tt>toRemove</tt> list existed in the list (at least after
 * adding the elements from <tt>toAdd</tt>).
 *
 * @param <T>
 *            the type of objects in the list
 *
 * @author Nico Kruber, kruber@zib.de
 */
public class ScalarisListAppendRemoveOp2<T> extends ScalarisChangeListOp2 {
    final protected List<T> toAdd;
    final protected List<T> toRemove;

    /**
     * Creates a new append+remove operation.
     *
     * @param key       the key to append/remove the values to/from
     * @param toAdd     the values to add
     * @param toRemove  the values to remove
     * @param countKey  the key for the counter of the entries in the list
     *                  (may be <tt>null</tt>)
     */
    public ScalarisListAppendRemoveOp2(final String key, final List<T> toAdd,
            final List<T> toRemove, final String countKey) {
        super(key, countKey);
        this.toAdd = toAdd;
        this.toRemove = toRemove;
    }

    /**
     * Adds {@link #toAdd} to the list at {@link ScalarisListOp2#key}.
     *
     * @param requests
     *            the request list
     *
     * @return <tt>0</tt> (number of processed operations)
     */
    @Override
    protected int changeList(final RequestList requests) {
        requests.addOp(new AddDelOnListOp(key, toAdd, toRemove));
        if (countKey != null) {
            requests.addOp(new AddOnNrOp(countKey, toAdd.size() - toRemove.size()));
        }
        return 0;
    }

    @Override
    public String toString() {
        return "Scalaris.append_remove(" + key + ", " + toAdd.toString() + ", "
                + toRemove.toString() + ", " + countKey + ")";
    }
}


text:
// GENERATED CODE: DO NOT EDIT BY HAND
// GENERATED FROM: components/Snackbar/src/MaterialSnackbar.bundle/Resources/en.lproj/MaterialSnackbar.strings
// GENERATED BY: generate_string_tables.py

typedef enum {
  kStr_MaterialSnackbarMessageViewTitleA11yHint = 0,
} MaterialSnackbarStringId;


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

    <groupId>leblebi</groupId>
    <artifactId>leblebi</artifactId>
    <version>0.9.0-SNAPSHOT</version>

    <repositories>
        <repository>
            <id>ahmetaa-repo</id>
            <name>ahmetaa Maven Repo on Github</name>
            <url>https://raw.github.com/ahmetaa/maven-repo/master</url>
        </repository>
    </repositories>

    <distributionManagement>
        <repository>
            <id>local-repo-clone</id>
            <url>file:///home/afsina/projects/maven-repo</url>
        </repository>
    </distributionManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
                <version>3.0</version>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
                <version>2.0.4</version>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit-dep</artifactId>
            <version>4.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>


text:
require 'test_helper'

class EnrollmentStatusTest < ActiveSupport::TestCase
  # test "the truth" do
  #   assert true
  # end
end


text:
define(function(){
	(function($) {

		// jQuery plugin definition
		$.fn.timePicker = function(params) {

			// merge default and user parameters
			params = $.extend( {defaultTime: 0, mouseoverClass: 'jquery-timepicker-mouseover'}, params);

			// some default cars
			var newHTML = '';
			var $t = $(this);

			// calculate the offsets
			var height = this.height()+1;
			var width = this.outerWidth();

			// generate our html dropdown
			var timeMargins = ['00', '15','30','45'];
			newHTML += ' <select data-native-menu = "false" style="position: absolute; left:0;top:' + height + 'px; width: ' + width + 'px;" size="7">'
			for(var h = 0; h <= 23; h++)
			{
				for(var i = 0; i < timeMargins.length; i++)
				{
					var newhour = "" + h;
					var v = (newhour.length == 1 ? '0' : '') + h + ':' + timeMargins[i];
					newHTML += '<option>' + v + '</option>';
				}
			}
			newHTML += '</select>';

			var id = this.attr('id');
			var newid = id + '-container';

			// wrap the target in the div
			$t.wrap('

');
			$t.after(newHTML);
			//$("#" + newid + " select").selectmenu();
			// hide the dropdown now we've injected it
			$("#" + newid + " select").hide();

			// 1) Show the dropdown if we focus on the input
			$t.focus(function () {
				$("#" + newid + " select").show();
			});

			// 2) Hide the dropdown if we've clicked it
			/*$("#" + newid + " select").click(function (e) {
				$(this).hide();
			});*/

			// 3) Hide the dropdown if we lose focus
			/*$t.blur(function (e) {
					//$(this).val($("#" + newid + " select").val()); // put the value in the input
					//$("#" + newid + " select").hide(); // hide the select
				$("#" + newid + " select").change();
			});*/
			$("#" + newid + " select").change(function () {
				$t.val($t.val() +" " + $(this).val());
				$(this).hide();
			});

			// 4) Assign mouseover/mouseout to the options
			$("#" + newid + " select option").mouseover(function () {
				$(this).addClass(params.mouseoverClass);
			});
			$("#" + newid + " select option").mouseout(function () {
				$(this).removeClass(params.mouseoverClass);
			});

			// allow jQuery chaining
			return this;
		};

	})(jQuery);
});


text:
package archimulator.core.bpred;

import archimulator.core.Thread;
import archimulator.isa.Mnemonic;
import archimulator.isa.StaticInstructionType;
import archimulator.util.Reference;

/**
 * The "Always not taken" branch predictor.
 *
 * @author Min Cai
 */
public class NotTakenBranchPredictor extends BranchPredictor {
    /**
     * Create an "always not taken" branch predictor.
     *
     * @param thread the thread
     * @param name   the name of the branch predictor
     */
    public NotTakenBranchPredictor(Thread thread, String name) {
        super(thread, name, BranchPredictorType.NOT_TAKEN);
    }

    @Override
    public int predict(int branchAddress, int branchTarget, Mnemonic mnemonic, BranchPredictorUpdate branchPredictorUpdate, Reference<Integer> returnAddressStackRecoverIndex) {
        return mnemonic.getType() != StaticInstructionType.CONDITIONAL ? branchTarget : branchAddress + 4;
    }

    @Override
    public boolean isDynamic() {
        return false;
    }
}


text:
package com.cloud.common.storageprocessor.resource;

import com.cloud.legacymodel.communication.answer.Answer;
import com.cloud.legacymodel.communication.command.StorageSubSystemCommand;

public interface StorageSubsystemCommandHandler {
    public Answer handleStorageCommands(StorageSubSystemCommand command);
}


text:
<?php

namespace Aes3xs\Tasker\Connection;

/**
 * Connection interface to different connection types.
 */
interface ConnectionInterface
{
    /**
     * Execute command.
     *
     * Returns command output or throws exception on error.
     *
     * @param $command
     *
     * @return string
     */
    public function exec($command);

    /**
     * Upload file.
     *
     * @param $local
     * @param $remote
     */
    public function send($local, $remote);

    /**
     * Download file.
     *
     * @param $remote
     * @param $local
     */
    public function recv($remote, $local);
}


text:
package WWW::Wookie::User;    # -*- cperl; cperl-indent-level: 4 -*-
use strict;
use warnings;

# $Id: User.pm 360 2010-11-22 13:03:01Z roland $
# $Revision: 360 $
# $HeadURL: svn+ssh://ipenburg.xs4all.nl/srv/svnroot/barclay/trunk/lib/WWW/Wookie/User.pm $
# $Date: 2010-11-22 14:03:01 +0100 (Mon, 22 Nov 2010) $

use utf8;
use 5.006000;

our $VERSION = '0.03';

use Moose qw/around has/;
use Moose::Util::TypeConstraints qw/as coerce from where subtype via/;

use Readonly;
## no critic qw(ProhibitCallsToUnexportedSubs)
Readonly::Scalar my $EMPTY     => q{};
Readonly::Scalar my $UNKNOWN   => q{UNKNOWN};
Readonly::Scalar my $MORE_ARGS => 3;
## use critic

subtype 'Trimmed' => as 'Str' => where { m{(^$|(^\S|\S$))}gsmx };

coerce 'Trimmed' => from 'Str' => via { $_ =~ s{^\s+(.*)\s+$}{$1}gsmx; $_ };

has 'loginName' => (
    is      => 'rw',
    isa     => 'Trimmed',
    coerce  => 1,
    default => $UNKNOWN,
    reader  => 'getLoginName',
    writer  => 'setLoginName',
);

has 'screenName' => (
    is      => 'rw',
    isa     => 'Trimmed',
    coerce  => 1,
    default => $UNKNOWN,
    reader  => 'getScreenName',
    writer  => 'setScreenName',
);

has 'thumbnailUrl' => (
    is      => 'ro',
    isa     => 'Str',
    default => $EMPTY,
    reader  => 'getThumbnailUrl',
    writer  => 'setThumbnailUrl',
);

around BUILDARGS => sub {
    my $orig  = shift;
    my $class = shift;

    if ( @_ == 2 && !ref $_[0] ) {
        push @_, $EMPTY;
    }
    if ( @_ == $MORE_ARGS && !ref $_[0] ) {
        return $class->$orig(
            loginName    => $_[0],
            screenName   => $_[1],
            thumbnailUrl => $_[2],
        );
    }
    return $class->$orig(@_);
};

no Moose;

## no critic qw(RequireExplicitInclusion)
__PACKAGE__->meta->make_immutable;
## use critic

1;

__END__

=encoding utf8

=for stopwords Roland van Ipenburg plugins login url Readonly

=head1 NAME

WWW::Wookie::User - represent a possible user of a widget

=head1 VERSION

This document describes WWW::Wookie::User version 0.03

=head1 SYNOPSIS

    use WWW::Wookie::User;
    $u = WWW::Wookie::User->new($login, $nick);

=head1 DESCRIPTION

A user represents a possible user of a widget. This class provides a standard
way of representing users in plugins for host environments.

=head1 SUBROUTINES/METHODS

=head2 C<new>

Create a new user.

=over

=item 1. User login name as string

=item 2. User display name as string

=item 3. Optional thumbnail URL as string

=back

=head2 C<getLoginName>

Get the login name for this user. Returns the user login name as string.

=head2 C<getScreenName>

Get the screen name for this user. This is the name that is intended to be
displayed on screen. In many cases it will be the same as the login name.
Returns the user display name as a string.

=head2 C<setLoginName>

Set the login name for this user. this is the value that is used by the user
to register on the system, it is guaranteed to be unique.

=over

=item 1. New login name as string

=back

=head2 C<setScreenName>

Set the screen name for this user. This is the value that should be displayed
on screen. In many cases it will be the same as the login name.

=over

=item 1. New screen name as string

=back

=head2 C<getThumbnailUrl>

Get the URL for a thumbnail representing this user. Returns the user thumbnail
icon url as string.

=head2 C<setThumbnailUrl>

Set the URL for a thumbnail representing this user.

=over

=item 1. New thumbnail URL as string

=back

=head1 CONFIGURATION AND ENVIRONMENT

=head1 DEPENDENCIES

L<Moose|Moose>
L<Moose::Util::TypeConstraints|Moose::Util::TypeConstraints>
L<Readonly|Readonly>

=head1 INCOMPATIBILITIES

=head1 DIAGNOSTICS

=head1 BUGS AND LIMITATIONS

Please report any bugs or feature requests at L<RT for
rt.cpan.org|https://rt.cpan.org/Dist/Display.html?Queue=WWW-Wookie>.

=head1 AUTHOR

Roland van Ipenburg  C<< <ipenburg@xs4all.nl> >>

=head1 LICENSE AND COPYRIGHT

    Copyright 2010 Roland van Ipenburg

    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

=head1 DISCLAIMER OF WARRANTY

    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.

=cut


text:
use 5.008;
use strict;
use warnings;
use Getopt::Long;

MAIN: {
    my %options;
    GetOptions(\%options, 'help!', 'parrot-config=s',
               'gen-parrot!', 'gen-parrot-option=s@');

    # Print help if it's requested
    if ($options{'help'}) {
        print_help();
        exit(0);
    }

    # Update/generate parrot build if needed
    if ($options{'gen-parrot'}) {
        my @opts    = @{ $options{'gen-parrot-option'} || [] };
        my @command = ($^X, "build/gen_parrot.pl", @opts);

        print "Generating Parrot ...\n";
        print "@command\n\n";
        system @command;
    }

    # Get a list of parrot-configs to invoke.
    my @parrot_config_exe = qw(
        parrot/parrot_config
        ../../parrot_config
        parrot_config
    );

    if ($options{'parrot-config'} && $options{'parrot-config'} ne '1') {
        @parrot_config_exe = ($options{'parrot-config'});
    }

    #  Get configuration information from parrot_config
    my %config = read_parrot_config(@parrot_config_exe);
    unless (%config) {
        die <<'END';
Unable to locate parrot_config.
To automatically checkout (svn) and build a copy of parrot,
try re-running Configure.pl with the '--gen-parrot' option.
Or, use the '--parrot-config' option to explicitly specify
the location of parrot_config.
END
    }

#  Create the Makefile using the information we just got
    create_makefile(%config);

    my $make = $config{'make'};
    print <<"END";

You can now use '$make' to build Reason.
After that, you can use '$make test' to run some local tests.

END
    exit 0;

}

sub read_parrot_config {
    my @parrot_config_exe = @_;
    my %config = ();
    for my $exe (@parrot_config_exe) {
        no warnings;
        if (open my $PARROT_CONFIG, '-|', "$exe --dump") {
            print "\nReading configuration information from $exe ...\n";
            while (<$PARROT_CONFIG>) {
                if (/(\w+) => '(.*)'/) { $config{$1} = $2 }
            }
            close $PARROT_CONFIG or die $!;
            last if %config;
        }
    }
    return %config;
}

#  Generate a Makefile from a configuration
sub create_makefile {
    my %config = @_;

    my $maketext = slurp( 'build/Makefile.in' );

    $config{'win32_libparrot_copy'} = $^O eq 'MSWin32' ? 'copy $(BUILD_DIR)\libparrot.dll .' : '';
    $maketext =~ s/@(\w+)@/$config{$1}/g;
    if ($^O eq 'MSWin32') {
        # use backslashes.
        $maketext =~ s{/}{\\}g;
        # wildcards (for clean rules) need an additional backslash, see Rakudo RT #65006
        $maketext =~ s{\\\*}{\\\\*}g;
        # use forward slashes again for HTTP URLs
        $maketext =~ s{http:\S+}{ do {my $t = $&; $t =~ s'\\'/'g; $t} }eg;
    }

    my $outfile = 'Makefile';
    print "\nCreating $outfile ...\n";
    open(my $MAKEOUT, '>', $outfile) ||
        die "Unable to write $outfile\n";
    print {$MAKEOUT} $maketext;
    close $MAKEOUT or die $!;

    return;
}

sub slurp {
    my $filename = shift;

    open my $fh, '<', $filename or die "Unable to read $filename\n";
    local $/ = undef;
    my $maketext = <$fh>;
    close $fh or die $!;

    return $maketext;
}

#  Print some help text.
sub print_help {
    print <<'END';
Configure.pl - Reason Configure

General Options:
    --help             Show this text
    --parrot-config=(config)
                       Use configuration information from config
    --gen-parrot       Download and build a copy of Parrot to use
    --gen-parrot-option='--option=value'
                       Set parrot config option when using --gen-parrot
END

    return;
}

# Local Variables:
#   mode: cperl
#   cperl-indent-level: 4
#   fill-column: 100
# End:
# vim: expandtab shiftwidth=4:


text:
#pragma once

#include "kmdefs.h"
#include "kmbuffer.h"
#include "WSExtension.h"

#include <functional>
#include <string>
#include <vector>

WS_NS_BEGIN

class ExtensionHandler
{
public:
    using FrameCallback = WSExtension::FrameCallback;

    virtual ~ExtensionHandler() {}

    virtual KMError handleIncomingFrame(FrameHeader hdr, KMBuffer &payload);
    virtual KMError handleOutgoingFrame(FrameHeader hdr, KMBuffer &payload);

    void setIncomingCallback(FrameCallback cb) { incoming_cb_ = std::move(cb); }
    void setOutgoingCallback(FrameCallback cb) { outgoing_cb_ = std::move(cb); }

    KMError negotiateExtensions(const std::string &extensions, bool is_answer);
    std::string getExtensionAnswer() const { return extension_answer_; }

    bool hasExtension() const { return !ws_extensions_.empty(); }

    static std::string getExtensionOffer();

protected:
    virtual KMError onIncomingFrame(FrameHeader hdr, KMBuffer &payload)
    {
        if (incoming_cb_) {
            return incoming_cb_(hdr, payload);
        }

        return KMError::INVALID_STATE;
    }
    virtual KMError onOutgoingFrame(FrameHeader hdr, KMBuffer &payload)
    {
        if (outgoing_cb_) {
            return outgoing_cb_(hdr, payload);
        }

        return KMError::INVALID_STATE;
    }

protected:
    FrameCallback incoming_cb_;
    FrameCallback outgoing_cb_;

    std::string extension_answer_;
    std::vector<WSExtension::Ptr> ws_extensions_;
};

WS_NS_END


text:
package sqlest.ast

import org.joda.time.LocalDate
import org.scalatest._
import org.scalatest.matchers._

class MappedColumnTypeSpec extends FlatSpec with Matchers with MappedColumnTypes {
  "MappedBooleanColumnType" should "convert database values to booleans" in {
    val BooleanIntColumnType = MappedBooleanColumnType(1, 0)

    BooleanIntColumnType.write(true) should be(1)
    BooleanIntColumnType.write(false) should be(0)
    BooleanIntColumnType.read(Some(1)) should be(Some(true))
    BooleanIntColumnType.read(Some(0)) should be(Some(false))

    val BooleanStringColumnType = MappedBooleanColumnType("Y", "Z")

    BooleanStringColumnType.write(true) should be("Y")
    BooleanStringColumnType.write(false) should be("Z")
    BooleanStringColumnType.read(Some("Y")) should be(Some(true))
    BooleanStringColumnType.read(Some("Z")) should be(Some(false))
  }

  sealed trait Animal
  case object Snake extends Animal
  case object Gigantosaurus extends Animal
  case object Troglodyte extends Animal

  "EnumerationColumnType" should "convert database values to the enumeration" in {
    val AnimalColumnType = EnumerationColumnType(
      Snake -> "S",
      Gigantosaurus -> "G"
    )

    AnimalColumnType.write(Snake) should be("S")
    AnimalColumnType.write(Gigantosaurus) should be("G")

    intercept[NoSuchElementException] {
      AnimalColumnType.write(Troglodyte) should be("G")
    }
    AnimalColumnType.read(Some("S")) should be(Some(Snake))
    AnimalColumnType.read(Some("G")) should be(Some(Gigantosaurus))

    intercept[NoSuchElementException] {
      AnimalColumnType.read(Some("X")) should be(Some(Gigantosaurus))
    }
  }

  "EnumerationColumnType" should "accept a fallback value for reads using withDefault" in {
    val AnimalColumnType = EnumerationColumnType(
      Snake -> "S",
      Gigantosaurus -> "G"
    ).withDefault(Gigantosaurus)

    AnimalColumnType.write(Snake) should be("S")
    AnimalColumnType.write(Gigantosaurus) should be("G")

    intercept[NoSuchElementException] {
      AnimalColumnType.write(Troglodyte) should be("G")
    }

    AnimalColumnType.read(Some("S")) should be(Some(Snake))
    AnimalColumnType.read(Some("G")) should be(Some(Gigantosaurus))

    AnimalColumnType.read(Some("X")) should be(Some(Gigantosaurus))
  }

  it should "use a globally specified implicit value for its base column type" in {
    implicit val stringColumnType = TrimmedStringColumnType
    val AnimalColumnType = EnumerationColumnType(
      Snake -> "S",
      Gigantosaurus -> "G"
    )
    AnimalColumnType.read(Some("S   ")) shouldBe Some(Snake)
  }

  "OptionColumnType" should "convert zeroes in database to None" in {
    val zeroIsNoneIntColumnType = OptionColumnType[Int, Int](0)
    zeroIsNoneIntColumnType.write(Some(10)) should be(10)
    zeroIsNoneIntColumnType.write(None) should be(0)
    zeroIsNoneIntColumnType.read(Some(10)) should be(Some(Some(10)))
    zeroIsNoneIntColumnType.read(Some(0)) should be(Some(None))

    val zeroIsNoneBigDecimalColumnType = ZeroIsNoneColumnType[BigDecimal, BigDecimal]
    zeroIsNoneBigDecimalColumnType.write(Some(BigDecimal("3.1415"))) should be(BigDecimal("3.1415"))
    zeroIsNoneBigDecimalColumnType.write(None) should be(BigDecimal(0))
    zeroIsNoneBigDecimalColumnType.read(Some(BigDecimal("3.1415"))) should be(Some(Some(BigDecimal("3.1415"))))
    zeroIsNoneBigDecimalColumnType.read(Some(BigDecimal(0))) should be(Some(None))
  }

  "YyyyMmDdColumnType" should "convert integers to date times" in {
    YyyyMmDdColumnType.write(new LocalDate(1999, 12, 31)) should be(19991231)
    YyyyMmDdColumnType.write(new LocalDate(2000, 1, 1)) should be(20000101)
    YyyyMmDdColumnType.read(Some(19991231)) should be(Some(new LocalDate(1999, 12, 31)))
    YyyyMmDdColumnType.read(Some(20000101)) should be(Some(new LocalDate(2000, 1, 1)))
  }

  "MappedColumnType.compose" should "compose read and write operations" in {
    val zeroIsNoneStringColumn = OptionColumnType("0")(MappedColumnType[Int, String](_.toInt, _.toString))
    zeroIsNoneStringColumn.write(Some(1)) should be("1")
    zeroIsNoneStringColumn.write(None) should be("0")
    zeroIsNoneStringColumn.read(Some("0")) should be(Some(None))
    zeroIsNoneStringColumn.read(Some("1")) should be(Some(Some(1)))

    val blankIsNoneTrimmedColumn = OptionColumnType("")(TrimmedStringColumnType)
    blankIsNoneTrimmedColumn.read(Some("")) should be(Some(None))
    blankIsNoneTrimmedColumn.read(Some("  Test   ")) should be(Some(Some("  Test")))
    blankIsNoneTrimmedColumn.write(Some("Test")) should be("Test")
    blankIsNoneTrimmedColumn.write(None) should be("")

    val chainedComposedMappedColumn =
      YyyyMmDdColumnType.compose(
        MappedBooleanColumnType(
          new LocalDate(1999, 12, 31),
          new LocalDate(2000, 1, 1)
        ).compose(
            MappedColumnType[Option[Int], Boolean](
              db => if (db) Some(1) else None,
              v => if (v.getOrElse(0) == 0) false else true
            )
          )
      )

    chainedComposedMappedColumn.read(Some(19991231)) should be(Some(Some(1)))
    chainedComposedMappedColumn.read(Some(19900408)) should be(Some(None))
    chainedComposedMappedColumn.write(Some(5)) should be(19991231)
    chainedComposedMappedColumn.write(None) should be(20000101)
  }
}