text:
var Paintbrush = function($canvas, info) {
	var scope = this;

	scope.debug = true;
	scope.objects = {};
	scope.info = info;
	scope.images = [];
	$canvas[0].ondragstart = $canvas[0].onselectstart = function(e) {
		if (e && e.preventDefault) {
			e.preventDefault();
		}
		if (e && e.stopPropagation) {
			e.stopPropagation();
		}
		return false;
	}
	scope.ctx = $canvas[0].getContext('2d');

	// scope.loadFinish = function() {
	// 	scope.drawBackground();
	// 	if (scope.debug) {
	// 		scope.drawDebug();
	// 	}
	// }

	scope.setObjects = function(id, obj) {
		scope.objects[id] = obj;
	}

	scope.putImage = function(image_name, xpos, ypos, xsize, ysize, is_center) {
		if (is_center) {
			xpos -= xsize / 2;
			ypos -= ysize / 2;
		}
		var image_object = scope.images[image_name];
		scope.ctx.drawImage(image_object, xpos, ypos, xsize, ysize);
	}

	scope.drawBackground = function() {
		if (scope.debug) {
			scope.ctx.save();
			scope.ctx.fillStyle = 'white';
			scope.ctx.fillRect(0, 0, scope.info.width, scope.info.height);
			scope.ctx.restore();
		} else {
			scope.putImage('background', 0, 0, scope.info.width, scope.info.height, false);
		}
	}

	scope.drawPlayer = function(player) {
		var lfp = scope.info.toCanvasCoord(scope.info.left_front_point);
		var lbp = scope.info.toCanvasCoord(scope.info.left_back_point);

		// player.updateCanvasCoordinate();
		// var x = player.position_c.x;
		// var y = player.position_c.y;
		var p = scope.info.toCanvasCoord(player.position);
		var p_head = scope.info.toCanvasCoord(player.position_head);
		var x = p[0];
		var y = p[1];
		var y_head = p_head[1];
		// console.log(player.position,x,y);
		var h = player.human_height;
		if (scope.debug) {
			scope.ctx.save();
			scope.ctx.translate(0, -(lbp[1] + lfp[1]) / 2 + 1000);
			scope.ctx.strokeStyle = '#808';
			scope.ctx.lineWidth = 6;
			scope.ctx.beginPath();
			// scope.ctx.translate(x, y);
			// scope.ctx.rotate(-r);
			// scope.ctx.translate(-x, -y);

			// scope.ctx.moveTo(x - 20, y - 20);
			// scope.ctx.lineTo(x + 20, y + 20);
			// scope.ctx.moveTo(x - 20, y + 20);
			// scope.ctx.lineTo(x + 20, y - 20);
			scope.ctx.moveTo(x, y);
			scope.ctx.lineTo(x, y_head);
			scope.ctx.closePath();
			scope.ctx.stroke();

			var angle;
			if (player.hit_status.is_hitting) {
				angle = (player.hit_range[0] + (player.hit_range[1] - player.hit_range[0]) * (player.hit_time - player.hit_status.timer) / player.hit_time) / 180 * Math.PI;
			} else {
				angle = player.hit_range[0] / 180 * Math.PI;
			}

			var p1 = player.position_head.copy();
			var p2 = player.position_head.copy();
			var q1 = new Vector3(player.arm_range[0] * Math.cos(angle), player.arm_range[0] * Math.sin(angle), 0);
			var q2 = new Vector3(player.arm_range[1] * Math.cos(angle), player.arm_range[1] * Math.sin(angle), 0);
			p1.add(q1);
			p2.add(q2);
			var r1 = scope.info.toCanvasCoord(p1);
			var r2 = scope.info.toCanvasCoord(p2);
			scope.ctx.strokeStyle = '#880';

			scope.ctx.beginPath();
			scope.ctx.moveTo(r1[0], r1[1]);
			scope.ctx.lineTo(r2[0], r2[1]);
			// console.log(p1, p2);
			scope.ctx.closePath();
			scope.ctx.stroke();

			scope.ctx.restore();
		}
	}

	scope.drawBall = function(ball) {
		var lfp = scope.info.toCanvasCoord(scope.info.left_front_point);
		var lbp = scope.info.toCanvasCoord(scope.info.left_back_point);

		// ball.updateCanvasCoordinate();
		var p = scope.info.toCanvasCoord(ball.position);
		var x = p[0];
		var y = p[1];
		// console.log(ball.position,p,x,y);
		var r = ball.rotation;
		if (scope.debug) {
			scope.ctx.save();
			scope.ctx.translate(0, -(lbp[1] + lfp[1]) / 2 + 1000);
			scope.ctx.strokeStyle = '#8f8';
			scope.ctx.lineWidth = 6;
			scope.ctx.beginPath();
			scope.ctx.translate(x, y);
			scope.ctx.rotate(-r);
			scope.ctx.translate(-x, -y);
			scope.ctx.moveTo(x + 20, y+ 20);
			scope.ctx.lineTo(x , y );
			scope.ctx.moveTo(x , y );
			scope.ctx.lineTo(x - 20, y + 20);
			scope.ctx.moveTo(x, y);
			scope.ctx.lineTo(x, y + 60);
			scope.ctx.closePath();
			scope.ctx.stroke();
			scope.ctx.restore();
		}
	}

	scope.drawDebug = function() {
		var lfp = scope.info.toCanvasCoord(scope.info.left_front_point);
		var lbp = scope.info.toCanvasCoord(scope.info.left_back_point);
		var rfp = scope.info.toCanvasCoord(scope.info.right_front_point);
		var rbp = scope.info.toCanvasCoord(scope.info.right_back_point);
		var fn = scope.info.toCanvasCoord(scope.info.front_net);
		var bn = scope.info.toCanvasCoord(scope.info.back_net);
		var lfs = scope.info.toCanvasCoord(scope.info.left_front_service);
		var lbs = scope.info.toCanvasCoord(scope.info.left_back_service);
		var rfs = scope.info.toCanvasCoord(scope.info.right_front_service);
		var rbs = scope.info.toCanvasCoord(scope.info.right_back_service);

		scope.ctx.save();

		scope.ctx.translate(0, -(lbp[1] + lfp[1]) / 2 + 1000);

		scope.ctx.strokeStyle = '#88f';
		scope.ctx.beginPath();

		scope.ctx.moveTo(lfp[0], lfp[1]);
		scope.ctx.lineTo(lbp[0], lbp[1]);
		scope.ctx.lineTo(rbp[0], rbp[1]);
		scope.ctx.lineTo(rfp[0], rfp[1]);
		scope.ctx.lineTo(lfp[0], lfp[1]);

		scope.ctx.moveTo((lbp[0] + rbp[0]) / 2, (lbp[1] + rbp[1]) / 2);
		scope.ctx.lineTo((lfp[0] + rfp[0]) / 2, (lfp[1] + rfp[1]) / 2);

		scope.ctx.moveTo(lbp[0],lbp[1]);
		scope.ctx.lineTo(lbp[0],lbp[1]-1080);
		scope.ctx.moveTo(rbp[0],rbp[1]);
		scope.ctx.lineTo(rbp[0],rbp[1]-1080);
		scope.ctx.moveTo(lfp[0],lfp[1]);
		scope.ctx.lineTo(lfp[0],lfp[1]-1080);
		scope.ctx.moveTo(rfp[0],rfp[1]);
		scope.ctx.lineTo(rfp[0],rfp[1]-1080);

		scope.ctx.closePath();
		scope.ctx.stroke();

		scope.ctx.strokeStyle = '#f88';
		scope.ctx.beginPath();

		// 网
		scope.ctx.moveTo((lfp[0] + rfp[0]) / 2, (lfp[1] + rfp[1]) / 2);
		scope.ctx.lineTo(fn[0], fn[1]);
		scope.ctx.lineTo(bn[0], bn[1]);
		scope.ctx.lineTo((lbp[0] + rbp[0]) / 2, (lbp[1] + rbp[1]) / 2);

		// 中线
		scope.ctx.moveTo((lbp[0] + lfp[0]) / 2, (lbp[1] + lfp[1]) / 2);
		scope.ctx.lineTo((rbp[0] + rfp[0]) / 2, (rbp[1] + rfp[1]) / 2);
		// console.log((lbp[1] + lfp[1]) / 2);

		scope.ctx.moveTo((lbp[0] + lfp[0]) / 2, (lbp[1] + lfp[1]) / 2);
		scope.ctx.lineTo((lbp[0] + lfp[0]) / 2, (lbp[1] + lfp[1]) / 2-1080);
		scope.ctx.moveTo((rbp[0] + rfp[0]) / 2, (rbp[1] + rfp[1]) / 2);
		scope.ctx.lineTo((rbp[0] + rfp[0]) / 2, (rbp[1] + rfp[1]) / 2-1080);

		scope.ctx.moveTo(lbs[0], lbs[1]);
		scope.ctx.lineTo(lfs[0], lfs[1]);
		scope.ctx.moveTo(rbs[0], rbs[1]);
		scope.ctx.lineTo(rfs[0], rfs[1]);

		scope.ctx.closePath();
		scope.ctx.stroke();

		scope.ctx.restore();
	}

	scope.drawDebug2 = function() {
		scope.ctx.save();
		scope.ctx.strokeStyle = '#88f';
		scope.ctx.beginPath();
		// 球场上部边界
		scope.ctx.moveTo(scope.info.ground_edge, scope.info.height - scope.info.ground_edge);
		scope.ctx.lineTo(scope.info.width - scope.info.ground_edge, scope.info.height - scope.info.ground_edge);

		// 球场左右边界
		scope.ctx.moveTo(scope.info.ground_edge, scope.info.height - scope.info.ground_edge);
		scope.ctx.lineTo(0, scope.info.height);
		scope.ctx.moveTo(scope.info.width - scope.info.ground_edge, scope.info.height - scope.info.ground_edge);
		scope.ctx.lineTo(scope.info.width, scope.info.height);

		// 左右墙
		scope.ctx.moveTo(scope.info.ground_edge, scope.info.height - scope.info.ground_edge);
		scope.ctx.lineTo(scope.info.ground_edge, 0);
		scope.ctx.moveTo(scope.info.width - scope.info.ground_edge, scope.info.height - scope.info.ground_edge);
		scope.ctx.lineTo(scope.info.width - scope.info.ground_edge, 0);

		// 中线
		scope.ctx.moveTo(scope.info.width / 2, 0);
		scope.ctx.lineTo(scope.info.width / 2, scope.info.height - scope.info.net_height - 20);

		scope.ctx.closePath();
		scope.ctx.stroke();

		scope.ctx.strokeStyle = '#f88';
		scope.ctx.beginPath();
		// 地面
		scope.ctx.moveTo(scope.info.ground_edge / 2, scope.info.height - scope.info.ground_edge / 2);
		scope.ctx.lineTo(scope.info.width - scope.info.ground_edge / 2, scope.info.height - scope.info.ground_edge / 2);

		// 网
		scope.ctx.moveTo(scope.info.width / 2, scope.info.height - scope.info.net_height);
		scope.ctx.lineTo(scope.info.width / 2, scope.info.height - scope.info.ground_edge / 2);

		// 左右墙中线
		scope.ctx.moveTo(scope.info.ground_edge / 2, scope.info.height - scope.info.ground_edge / 2);
		scope.ctx.lineTo(scope.info.ground_edge / 2, 0);
		scope.ctx.moveTo(scope.info.width - scope.info.ground_edge / 2, scope.info.height - scope.info.ground_edge / 2);
		scope.ctx.lineTo(scope.info.width - scope.info.ground_edge / 2, 0);

		// 球网
		scope.ctx.moveTo(scope.info.width / 2, scope.info.height - scope.info.net_height);
		scope.ctx.lineTo(scope.info.width / 2 + 20, scope.info.height - scope.info.net_height + 20);
		scope.ctx.moveTo(scope.info.width / 2 - 20, scope.info.height - scope.info.net_height + 20);
		scope.ctx.lineTo(scope.info.width / 2, scope.info.height - scope.info.net_height);

		// 发球线
		scope.ctx.moveTo(scope.info.service_line - scope.info.service_line_offset, scope.info.height);
		scope.ctx.lineTo(scope.info.service_line + scope.info.service_line_offset, scope.info.height - scope.info.ground_edge);
		scope.ctx.moveTo(scope.info.width - scope.info.service_line + scope.info.service_line_offset, scope.info.height);
		scope.ctx.lineTo(scope.info.width - scope.info.service_line - scope.info.service_line_offset, scope.info.height - scope.info.ground_edge);

		scope.ctx.closePath();
		scope.ctx.stroke();

		scope.ctx.restore();
	}
}


text:
package gorethink

import (
	"sync"
	"sync/atomic"
	"time"

	p "github.com/brendanobrienesq/gorethink/ql2"
)

const (
	maxNodeHealth = 100
)

// Node represents a database server in the cluster
type Node struct {
	ID      string
	Host    Host
	aliases []Host

	cluster         *Cluster
	pool            *Pool
	refreshDoneChan chan struct{}

	mu     sync.RWMutex
	closed bool
	health int64
}

func newNode(id string, aliases []Host, cluster *Cluster, pool *Pool) *Node {
	node := &Node{
		ID:              id,
		Host:            aliases[0],
		aliases:         aliases,
		cluster:         cluster,
		pool:            pool,
		health:          maxNodeHealth,
		refreshDoneChan: make(chan struct{}),
	}
	// Start node refresh loop
	refreshInterval := cluster.opts.NodeRefreshInterval
	if refreshInterval <= 0 {
		// Default to refresh every 30 seconds
		refreshInterval = time.Second * 30
	}

	go func() {
		refreshTicker := time.NewTicker(refreshInterval)
		for {
			select {
			case <-refreshTicker.C:
				node.Refresh()
			case <-node.refreshDoneChan:
				return
			}
		}
	}()

	return node
}

// Closed returns true if the node is closed
func (n *Node) Closed() bool {
	n.mu.RLock()
	defer n.mu.RUnlock()

	return n.closed
}

// Close closes the session
func (n *Node) Close(optArgs ...CloseOpts) error {
	n.mu.Lock()
	defer n.mu.Unlock()

	if n.closed {
		return nil
	}

	if len(optArgs) >= 1 {
		if optArgs[0].NoReplyWait {
			n.NoReplyWait()
		}
	}

	n.refreshDoneChan <- struct{}{}
	if n.pool != nil {
		n.pool.Close()
	}
	n.pool = nil
	n.closed = true

	return nil
}

// SetMaxIdleConns sets the maximum number of connections in the idle
// connection pool.
func (n *Node) SetMaxIdleConns(idleConns int) {
	n.pool.SetMaxIdleConns(idleConns)
}

// SetMaxOpenConns sets the maximum number of open connections to the database.
func (n *Node) SetMaxOpenConns(openConns int) {
	n.pool.SetMaxOpenConns(openConns)
}

// NoReplyWait ensures that previous queries with the noreply flag have been
// processed by the server. Note that this guarantee only applies to queries
// run on the given connection
func (n *Node) NoReplyWait() error {
	return n.pool.Exec(Query{
		Type: p.Query_NOREPLY_WAIT,
	})
}

// Query executes a ReQL query using this nodes connection pool.
func (n *Node) Query(q Query) (cursor *Cursor, err error) {
	if n.Closed() {
		return nil, ErrInvalidNode
	}

	cursor, err = n.pool.Query(q)
	if err != nil {
		n.DecrementHealth()
	}

	return cursor, err
}

// Exec executes a ReQL query using this nodes connection pool.
func (n *Node) Exec(q Query) (err error) {
	if n.Closed() {
		return ErrInvalidNode
	}

	err = n.pool.Exec(q)
	if err != nil {
		n.DecrementHealth()
	}

	return err
}

// Refresh attempts to connect to the node and check that it is still connected
// to the cluster.
//
// If an error occurred or the node is no longer connected then
// the nodes health is decrease, if there were no issues then the node is marked
// as being healthy.
func (n *Node) Refresh() {
	if n.cluster.opts.DiscoverHosts {
		// If host discovery is enabled then check the servers status
		q, err := newQuery(
			DB("rethinkdb").Table("server_status").Get(n.ID),
			map[string]interface{}{},
			n.cluster.opts,
		)
		if err != nil {
			return
		}

		cursor, err := n.pool.Query(q)
		if err != nil {
			n.DecrementHealth()
			return
		}
		defer cursor.Close()

		// Cant find node status so assuming node has been disconnected
		if cursor.IsNil() {
			n.DecrementHealth()
			return
		}

		// Below check is for RethinkDB 2.0
		var status nodeStatus
		err = cursor.One(&status)
		if err != nil {
			return
		}

		if status.Status != "" && status.Status != "connected" {
			n.DecrementHealth()
			return
		}
	} else {
		// If host discovery is disabled just execute a simple ping query
		q, err := newQuery(
			Expr("OK"),
			map[string]interface{}{},
			n.cluster.opts,
		)
		if err != nil {
			return
		}

		cursor, err := n.pool.Query(q)
		if err != nil {
			n.DecrementHealth()
			return
		}
		defer cursor.Close()

		var status string
		err = cursor.One(&status)
		if err != nil {
			return
		}

		if status != "OK" {
			n.DecrementHealth()
			return
		}
	}

	// If status check was successful reset health
	n.ResetHealth()
}

// DecrementHealth decreases the nodes health by 1 (the nodes health starts at maxNodeHealth)
func (n *Node) DecrementHealth() {
	atomic.AddInt64(&n.health, -1)
}

// ResetHealth sets the nodes health back to maxNodeHealth (fully healthy)
func (n *Node) ResetHealth() {
	atomic.StoreInt64(&n.health, maxNodeHealth)
}

// IsHealthy checks the nodes health by ensuring that the health counter is above 0.
func (n *Node) IsHealthy() bool {
	health := atomic.LoadInt64(&n.health)
	return health > 0
}

type nodeStatus struct {
	ID      string `gorethink:"id"`
	Name    string `gorethink:"name"`
	Status  string `gorethink:"status"`
	Network struct {
		Hostname           string `gorethink:"hostname"`
		ClusterPort        int64  `gorethink:"cluster_port"`
		ReqlPort           int64  `gorethink:"reql_port"`
		CanonicalAddresses []struct {
			Host string `gorethink:"host"`
			Port int64  `gorethink:"port"`
		} `gorethink:"canonical_addresses"`
	} `gorethink:"network"`
}

redpajama_set_name: RedPajamaGithub


text:
#include "implementation.hpp"
#include "common/example_utilities.h"

#include <iostream>
#include <string>
#include <sstream>

#include "DurabilityData_DCPS.hpp"

namespace examples {
#ifdef GENERATING_EXAMPLE_DOXYGEN
GENERATING_EXAMPLE_DOXYGEN /* workaround doxygen bug */
#endif
namespace dcps { namespace Durability {

/**
 * @addtogroup examplesdcpsDurabilityisocpp The ISO C++ DCPS API Durability example
 *
 * This example demonstrates the two kinds of durability, transient and persistent
 * and allows the user to specify which durability kind is used.
 * @ingroup examplesdcpsisocpp
 *
 * @see Example Description
 * @see @ref isocpp2_dcpsexamples "IsoC++2 Examples"
 */
/** @{*/
/** @dir */
/** @file */

namespace isocpp  {

void usagePub()
{
    std::cerr << "*** ERROR" << std::endl;
    std::cerr << "*** usage : publisher <durability_kind> <autodispose_flag>" << std::endl;
    std::cerr << "***         . durability_kind = transient | persistent" << std::endl;
    std::cerr << "***         . autodispose_flag = false | true" << std::endl;
    std::cerr << "***         . automatic_flag = false | true" << std::endl;
}

/**
 * This function performs the publisher role in this example.
 * @return 0 if a sample is successfully written, 1 otherwise.
 */
int publisher(int argc, char *argv[])
{
    int result = 0;

    if(argc < 4 || (strcmp(argv[1], "transient") && strcmp(argv[1], "persistent")) ||
        (strcmp(argv[2], "false") && strcmp(argv[2], "true")) ||
        (strcmp(argv[3], "false") && strcmp(argv[3], "true")))
    {
        usagePub();
        return -1;
    }
    std::string durability_kind(argv[1]);
    bool isPersistent = (strcmp(argv[1], "persistent") == 0);
    bool autodispose_unregistered_instances = (strcmp(argv[2], "true") == 0);
    bool automatic = (strcmp(argv[3], "true") == 0);
    std::string topic_name = "Isocpp2DurabilityData_Msg";

    // Wait for the Subscriber
    exampleSleepMilliseconds(2000);

    try
    {
        /** A dds::domain::DomainParticipant is created for the default domain. */
        dds::domain::DomainParticipant dp(org::opensplice::domain::default_id());

        /** The Durability is specified based on the users preference. The Reliability::Reliable
          * policy is also specified to guarantee delivery. */
        dds::topic::qos::TopicQos topicQos = dp.default_topic_qos() << dds::core::policy::Reliability::Reliable();
        if(durability_kind == "transient")
        {
            topicQos << dds::core::policy::Durability::Transient();
        }
        else if(durability_kind == "persistent")
        {
            topicQos << dds::core::policy::Durability::Persistent();
        }

        /** A dds::topic::Topic is created for our sample type on the domain participant. */
        if (isPersistent) {
            topic_name = "PersistentIsocpp2DurabilityData_Msg";
        }
        dds::topic::Topic<DurabilityData::Msg> topic(dp, topic_name.c_str(), topicQos);

        /** A dds::pub::Publisher is created on the domain participant. */
        std::string name = "Durability example";
        dds::pub::qos::PublisherQos pubQos
            = dp.default_publisher_qos()
                << dds::core::policy::Partition(name);
        dds::pub::Publisher pub(dp, pubQos);

        /** The dds::pub::qos::DataWriterQos is derived from the topic qos and autodispose is
         * set to either manual or automatic based on the users preference. This is so the publisher
         * can optionally be run (and exit) before the subscriber. It prevents or allows the middleware
         * default 'clean up' of the topic instance after the writer deletion, this deletion
         * implicitly performs DataWriter::unregister_instance */
        dds::pub::qos::DataWriterQos dwqos = topic.qos();
        dwqos << dds::core::policy::WriterDataLifecycle(autodispose_unregistered_instances);

        /** A dds::pub::DataWriter is created on the Publisher & Topic with the modififed Qos. */
        dds::pub::DataWriter<DurabilityData::Msg> dw(pub, topic, dwqos);

        /** Ten samples are created and registered as an instance before being written. */
        std::vector<DurabilityData::Msg> msgInstances;
        std::vector<dds::core::InstanceHandle> userHandle;

        for(int i = 0; i < 10; i++)
        {
            std::stringstream ss;
            ss << i;
            DurabilityData::Msg msg(i, ss.str());
            userHandle.push_back(dw.register_instance(msg));
            msgInstances.push_back(msg);
            std::cout << msg.content() << std::endl;
        }
        dw.write(msgInstances.begin(), msgInstances.end(), userHandle.begin(), userHandle.end());

        if(!automatic)
        {
            char c = 0;
            std::cout << "Enter E to exit" << std::endl;
            while(c != 'E')
            {
                std::cin >> c;
            }
        }
        else
        {
            /* A sleep ensures time is allowed for the sample to be written to the network.
               If the example is running in *Single Process Mode* exiting immediately might
               otherwise shutdown the domain services before this could occur
            std::cout << "=== sleeping 30s..." << std::endl; */
            exampleSleepMilliseconds(30000);
        }

        if(autodispose_unregistered_instances)
        {
            while(!userHandle.empty())
            {
                dw.unregister_instance(userHandle.back());
                userHandle.pop_back();
            }
        }
    }
    catch (const dds::core::Exception& e)
    {
        std::cerr << "ERROR: Exception: " << e.what() << std::endl;
        result = 1;
    }
    return result;
}

void usageSub()
{
    std::cerr << "*** ERROR" << std::endl;
    std::cerr << "*** usage : subscriber <durability_kind>" << std::endl;
    std::cerr << "***         . durability_kind = transient | persistent" << std::endl;
}

/**
 * Runs the subscriber role of this example.
 * @return 0 if a sample is successfully read, 1 otherwise.
 */
int subscriber(int argc, char *argv[])
{
    int result = 0;

    if(argc < 2 || (strcmp(argv[1], "transient") && strcmp(argv[1], "persistent")))
    {
        usageSub();
        return -1;
    }
    std::string durability_kind(argv[1]);
    bool isPersistent = (strcmp(argv[1], "persistent") == 0);
    std::string topic_name = "Isocpp2DurabilityData_Msg";

    try
    {
        /** A domain participant and topic are created identically as in
         the ::publisher */
        dds::domain::DomainParticipant dp(org::opensplice::domain::default_id());
        dds::topic::qos::TopicQos topicQos = dp.default_topic_qos() << dds::core::policy::Reliability::Reliable();
        if(durability_kind == "transient")
        {
            topicQos << dds::core::policy::Durability::Transient();
        }
        else if(durability_kind == "persistent")
        {
            topicQos << dds::core::policy::Durability::Persistent();
        }

        /** A dds::topic::Topic is created for our sample type on the domain participant. */
        if (isPersistent) {
             topic_name = "PersistentIsocpp2DurabilityData_Msg";
        }
        dds::topic::Topic<DurabilityData::Msg> topic(dp, topic_name.c_str(), topicQos);

        /** A dds::sub::Subscriber is created on the domain participant. */
        std::string name = "Durability example";
        dds::sub::qos::SubscriberQos subQos
            = dp.default_subscriber_qos()
                << dds::core::policy::Partition(name);
        dds::sub::Subscriber sub(dp, subQos);

        /** The dds::sub::qos::DataReaderQos are derived from the topic qos */
        dds::sub::qos::DataReaderQos drqos = topic.qos();

        /** A dds::sub::DataReader is created on the Subscriber & Topic with the DataReaderQos. */
        dds::sub::DataReader<DurabilityData::Msg> dr(sub, topic, drqos);
        dds::core::Duration timeout(40, 0);
        dr.wait_for_historical_data(timeout);

        std::cout << "=== [Subscriber] Ready ..." << std::endl;

        /** An attempt to take samples is made repeatedly until it succeeds,
         * or twenty seconds have elapsed. */
        bool closed = false;
        do
        {
            dds::sub::LoanedSamples<DurabilityData::Msg> samples = dr.take();
            for (dds::sub::LoanedSamples<DurabilityData::Msg>::const_iterator sample = samples.begin();
                 sample < samples.end();
                 ++sample)
            {
                if (sample->info().valid())
                {
                    std::cout << sample->data().content() << std::endl;

                    if (sample->data().content() == "9")
                    {
                        closed = true;
                    }
                }
            }
        }
        while (!closed);

        exampleSleepMilliseconds(2000);
    }
    catch (const dds::core::Exception& e)
    {
        std::cerr << "ERROR: Exception: " << e.what() << std::endl;
        result = 1;
    }
    return result;
}

}
}
}
}

EXAMPLE_ENTRYPOINT(DCPS_ISOCPP_Durability_publisher, examples::dcps::Durability::isocpp::publisher)
EXAMPLE_ENTRYPOINT(DCPS_ISOCPP_Durability_subscriber, examples::dcps::Durability::isocpp::subscriber)


text:
require("firecast.lua");
local __o_rrpgObjs = require("rrpgObjs.lua");
require("rrpgGUI.lua");
require("rrpgDialogs.lua");
require("rrpgLFM.lua");
require("ndb.lua");
require("locale.lua");
local __o_Utils = require("utils.lua");

local function constructNew_frmAMZ1_1()
    local obj = GUI.fromHandle(_obj_newObject("form"));
    local self = obj;
    local sheet = nil;

    rawset(obj, "_oldSetNodeObjectFunction", rawget(obj, "setNodeObject"));

    function obj:setNodeObject(nodeObject)
        sheet = nodeObject;
        self.sheet = nodeObject;
        self:_oldSetNodeObjectFunction(nodeObject);
    end;

    function obj:setNodeDatabase(nodeObject)
        self:setNodeObject(nodeObject);
    end;

    _gui_assignInitialParentForForm(obj.handle);
    obj:beginUpdate();
    obj:setName("frmAMZ1_1");
    obj:setAlign("client");
    obj:setTheme("dark");

    obj.scrollBox1 = GUI.fromHandle(_obj_newObject("scrollBox"));
    obj.scrollBox1:setParent(obj);
    obj.scrollBox1:setAlign("client");
    obj.scrollBox1:setName("scrollBox1");

    obj.layout1 = GUI.fromHandle(_obj_newObject("layout"));
    obj.layout1:setParent(obj.scrollBox1);
    obj.layout1:setLeft(0);
    obj.layout1:setTop(0);
    obj.layout1:setWidth(960);
    obj.layout1:setHeight(70);
    obj.layout1:setName("layout1");

    obj.rectangle1 = GUI.fromHandle(_obj_newObject("rectangle"));
    obj.rectangle1:setParent(obj.layout1);
    obj.rectangle1:setAlign("client");
    obj.rectangle1:setColor("black");
    obj.rectangle1:setXradius(5);
    obj.rectangle1:setYradius(5);
    obj.rectangle1:setCornerType("round");
    obj.rectangle1:setName("rectangle1");

    obj.layout2 = GUI.fromHandle(_obj_newObject("layout"));
    obj.layout2:setParent(obj.layout1);
    obj.layout2:setLeft(5);
    obj.layout2:setTop(5);
    obj.layout2:setWidth(310);
    obj.layout2:setHeight(25);
    obj.layout2:setName("layout2");

    obj.label1 = GUI.fromHandle(_obj_newObject("label"));
    obj.label1:setParent(obj.layout2);
    obj.label1:setLeft(0);
    obj.label1:setTop(5);
    obj.label1:setWidth(100);
    obj.label1:setHeight(20);
    obj.label1:setText("Nome");
    obj.label1:setHorzTextAlign("trailing");
    obj.label1:setName("label1");

    obj.edit1 = GUI.fromHandle(_obj_newObject("edit"));
    obj.edit1:setParent(obj.layout2);
    obj.edit1:setLeft(110);
    obj.edit1:setTop(0);
    obj.edit1:setWidth(200);
    obj.edit1:setHeight(25);
    obj.edit1:setField("desc_nome");
    obj.edit1:setName("edit1");

    obj.layout3 = GUI.fromHandle(_obj_newObject("layout"));
    obj.layout3:setParent(obj.layout1);
    obj.layout3:setLeft(5);
    obj.layout3:setTop(35);
    obj.layout3:setWidth(310);
    obj.layout3:setHeight(25);
    obj.layout3:setName("layout3");

    obj.label2 = GUI.fromHandle(_obj_newObject("label"));
    obj.label2:setParent(obj.layout3);
    obj.label2:setLeft(0);
    obj.label2:setTop(5);
    obj.label2:setWidth(100);
    obj.label2:setHeight(20);
    obj.label2:setText("Família");
    obj.label2:setHorzTextAlign("trailing");
    obj.label2:setName("label2");

    obj.edit2 = GUI.fromHandle(_obj_newObject("edit"));
    obj.edit2:setParent(obj.layout3);
    obj.edit2:setLeft(110);
    obj.edit2:setTop(0);
    obj.edit2:setWidth(200);
    obj.edit2:setHeight(25);
    obj.edit2:setField("desc_familia");
    obj.edit2:setName("edit2");

    obj.layout4 = GUI.fromHandle(_obj_newObject("layout"));
    obj.layout4:setParent(obj.layout1);
    obj.layout4:setLeft(320);
    obj.layout4:setTop(5);
    obj.layout4:setWidth(310);
    obj.layout4:setHeight(25);
    obj.layout4:setName("layout4");

    obj.label3 = GUI.fromHandle(_obj_newObject("label"));
    obj.label3:setParent(obj.layout4);
    obj.label3:setLeft(0);
    obj.label3:setTop(5);
    obj.label3:setWidth(100);
    obj.label3:setHeight(20);
    obj.label3:setText("Sexo");
    obj.label3:setHorzTextAlign("trailing");
    obj.label3:setName("label3");

    obj.edit3 = GUI.fromHandle(_obj_newObject("edit"));
    obj.edit3:setParent(obj.layout4);
    obj.edit3:setLeft(110);
    obj.edit3:setTop(0);
    obj.edit3:setWidth(200);
    obj.edit3:setHeight(25);
    obj.edit3:setField("desc_sexo");
    obj.edit3:setName("edit3");

    obj.layout5 = GUI.fromHandle(_obj_newObject("layout"));
    obj.layout5:setParent(obj.layout1);
    obj.layout5:setLeft(320);
    obj.layout5:setTop(35);
    obj.layout5:setWidth(310);
    obj.layout5:setHeight(25);
    obj.layout5:setName("layout5");

    obj.label4 = GUI.fromHandle(_obj_newObject("label"));
    obj.label4:setParent(obj.layout5);
    obj.label4:setLeft(0);
    obj.label4:setTop(5);
    obj.label4:setWidth(100);
    obj.label4:setHeight(20);
    obj.label4:setText("Idade");
    obj.label4:setHorzTextAlign("trailing");
    obj.label4:setName("label4");

    obj.edit4 = GUI.fromHandle(_obj_newObject("edit"));
    obj.edit4:setParent(obj.layout5);
    obj.edit4:setLeft(110);
    obj.edit4:setTop(0);
    obj.edit4:setWidth(200);
    obj.edit4:setHeight(25);
    obj.edit4:setField("desc_idade");
    obj.edit4:setName("edit4");

    obj.layout6 = GUI.fromHandle(_obj_newObject("layout"));
    obj.layout6:setParent(obj.layout1);
    obj.layout6:setLeft(585);
    obj.layout6:setTop(5);
    obj.layout6:setWidth(310);
    obj.layout6:setHeight(25);
    obj.layout6:setName("layout6");

    obj.label5 = GUI.fromHandle(_obj_newObject("label"));
    obj.label5:setParent(obj.layout6);
    obj.label5:setLeft(0);
    obj.label5:setTop(5);
    obj.label5:setWidth(100);
    obj.label5:setHeight(20);
    obj.label5:setText("Altura");
    obj.label5:setHorzTextAlign("trailing");
    obj.label5:setName("label5");

    obj.edit5 = GUI.fromHandle(_obj_newObject("edit"));
    obj.edit5:setParent(obj.layout6);
    obj.edit5:setLeft(110);
    obj.edit5:setTop(0);
    obj.edit5:setWidth(200);
    obj.edit5:setHeight(25);
    obj.edit5:setField("desc_altura");
    obj.edit5:setName("edit5");

    obj.layout7 = GUI.fromHandle(_obj_newObject("layout"));
    obj.layout7:setParent(obj.layout1);
    obj.layout7:setLeft(585);
    obj.layout7:setTop(35);
    obj.layout7:setWidth(310);
    obj.layout7:setHeight(25);
    obj.layout7:setName("layout7");

    obj.label6 = GUI.fromHandle(_obj_newObject("label"));
    obj.label6:setParent(obj.layout7);
    obj.label6:setLeft(0);
    obj.label6:setTop(5);
    obj.label6:setWidth(100);
    obj.label6:setHeight(20);
    obj.label6:setText("Peso");
    obj.label6:setHorzTextAlign("trailing");
    obj.label6:setName("label6");

    obj.edit6 = GUI.fromHandle(_obj_newObject("edit"));
    obj.edit6:setParent(obj.layout7);
    obj.edit6:setLeft(110);
    obj.edit6:setTop(0);
    obj.edit6:setWidth(200);
    obj.edit6:setHeight(25);
    obj.edit6:setField("desc_peso");
    obj.edit6:setName("edit6");

    obj.layout8 = GUI.fromHandle(_obj_newObject("layout"));
    obj.layout8:setParent(obj.scrollBox1);
    obj.layout8:setLeft(0);
    obj.layout8:setTop(80);
    obj.layout8:setWidth(400);
    obj.layout8:setHeight(400);
    obj.layout8:setName("layout8");

    obj.rectangle2 = GUI.fromHandle(_obj_newObject("rectangle"));
    obj.rectangle2:setParent(obj.layout8);
    obj.rectangle2:setAlign("client");
    obj.rectangle2:setColor("black");
    obj.rectangle2:setXradius(5);
    obj.rectangle2:setYradius(5);
    obj.rectangle2:setCornerType("round");
    obj.rectangle2:setName("rectangle2");

    obj.label7 = GUI.fromHandle(_obj_newObject("label"));
    obj.label7:setParent(obj.layout8);
    obj.label7:setLeft(0);
    obj.label7:setTop(0);
    obj.label7:setWidth(400);
    obj.label7:setHeight(20);
    obj.label7:setText("Aparencia");
    obj.label7:setHorzTextAlign("center");
    obj.label7:setName("label7");

    obj.textEditor1 = GUI.fromHandle(_obj_newObject("textEditor"));
    obj.textEditor1:setParent(obj.layout8);
    obj.textEditor1:setLeft(10);
    obj.textEditor1:setTop(25);
    obj.textEditor1:setWidth(380);
    obj.textEditor1:setHeight(360);
    obj.textEditor1:setField("aparencia");
    obj.textEditor1:setName("textEditor1");

    obj.layout9 = GUI.fromHandle(_obj_newObject("layout"));
    obj.layout9:setParent(obj.scrollBox1);
    obj.layout9:setLeft(410);
    obj.layout9:setTop(80);
    obj.layout9:setWidth(400);
    obj.layout9:setHeight(400);
    obj.layout9:setName("layout9");

    obj.rectangle3 = GUI.fromHandle(_obj_newObject("rectangle"));
    obj.rectangle3:setParent(obj.layout9);
    obj.rectangle3:setAlign("client");
    obj.rectangle3:setColor("black");
    obj.rectangle3:setXradius(5);
    obj.rectangle3:setYradius(5);
    obj.rectangle3:setCornerType("round");
    obj.rectangle3:setName("rectangle3");

    obj.label8 = GUI.fromHandle(_obj_newObject("label"));
    obj.label8:setParent(obj.layout9);
    obj.label8:setLeft(0);
    obj.label8:setTop(0);
    obj.label8:setWidth(400);
    obj.label8:setHeight(20);
    obj.label8:setText("Personalidade");
    obj.label8:setHorzTextAlign("center");
    obj.label8:setName("label8");

    obj.textEditor2 = GUI.fromHandle(_obj_newObject("textEditor"));
    obj.textEditor2:setParent(obj.layout9);
    obj.textEditor2:setLeft(10);
    obj.textEditor2:setTop(25);
    obj.textEditor2:setWidth(380);
    obj.textEditor2:setHeight(360);
    obj.textEditor2:setField("personalidade");
    obj.textEditor2:setName("textEditor2");

    obj.layout10 = GUI.fromHandle(_obj_newObject("layout"));
    obj.layout10:setParent(obj.scrollBox1);
    obj.layout10:setLeft(820);
    obj.layout10:setTop(80);
    obj.layout10:setWidth(400);
    obj.layout10:setHeight(400);
    obj.layout10:setName("layout10");

    obj.rectangle4 = GUI.fromHandle(_obj_newObject("rectangle"));
    obj.rectangle4:setParent(obj.layout10);
    obj.rectangle4:setAlign("client");
    obj.rectangle4:setColor("black");
    obj.rectangle4:setStrokeColor("white");
    obj.rectangle4:setStrokeSize(1);
    obj.rectangle4:setName("rectangle4");

    obj.image1 = GUI.fromHandle(_obj_newObject("image"));
    obj.image1:setParent(obj.layout10);
    obj.image1:setLeft(1);
    obj.image1:setTop(1);
    obj.image1:setWidth(398);
    obj.image1:setHeight(398);
    obj.image1:setField("avatar");
    obj.image1:setEditable(true);
    obj.image1:setStyle("autoFit");
    obj.image1:setName("image1");

    obj._e_event0 = obj.image1:addEventListener("onStartDrag",
        function (_, drag, x, y)
            drag:addData("imageURL", sheet.avatar);
        end, obj);

    function obj:_releaseEvents()
        __o_rrpgObjs.removeEventListenerById(self._e_event0);
    end;

    obj._oldLFMDestroy = obj.destroy;

    function obj:destroy()
        self:_releaseEvents();

        if (self.handle ~= 0) and (self.setNodeDatabase ~= nil) then
          self:setNodeDatabase(nil);
        end;

        if self.label1 ~= nil then self.label1:destroy(); self.label1 = nil; end;
        if self.layout4 ~= nil then self.layout4:destroy(); self.layout4 = nil; end;
        if self.edit4 ~= nil then self.edit4:destroy(); self.edit4 = nil; end;
        if self.label8 ~= nil then self.label8:destroy(); self.label8 = nil; end;
        if self.label3 ~= nil then self.label3:destroy(); self.label3 = nil; end;
        if self.label4 ~= nil then self.label4:destroy(); self.label4 = nil; end;
        if self.label6 ~= nil then self.label6:destroy(); self.label6 = nil; end;
        if self.textEditor1 ~= nil then self.textEditor1:destroy(); self.textEditor1 = nil; end;
        if self.layout9 ~= nil then self.layout9:destroy(); self.layout9 = nil; end;
        if self.layout10 ~= nil then self.layout10:destroy(); self.layout10 = nil; end;
        if self.image1 ~= nil then self.image1:destroy(); self.image1 = nil; end;
        if self.edit5 ~= nil then self.edit5:destroy(); self.edit5 = nil; end;
        if self.textEditor2 ~= nil then self.textEditor2:destroy(); self.textEditor2 = nil; end;
        if self.edit6 ~= nil then self.edit6:destroy(); self.edit6 = nil; end;
        if self.label7 ~= nil then self.label7:destroy(); self.label7 = nil; end;
        if self.layout5 ~= nil then self.layout5:destroy(); self.layout5 = nil; end;
        if self.label2 ~= nil then self.label2:destroy(); self.label2 = nil; end;
        if self.edit3 ~= nil then self.edit3:destroy(); self.edit3 = nil; end;
        if self.layout6 ~= nil then self.layout6:destroy(); self.layout6 = nil; end;
        if self.label5 ~= nil then self.label5:destroy(); self.label5 = nil; end;
        if self.rectangle4 ~= nil then self.rectangle4:destroy(); self.rectangle4 = nil; end;
        if self.rectangle2 ~= nil then self.rectangle2:destroy(); self.rectangle2 = nil; end;
        if self.rectangle3 ~= nil then self.rectangle3:destroy(); self.rectangle3 = nil; end;
        if self.layout3 ~= nil then self.layout3:destroy(); self.layout3 = nil; end;
        if self.edit2 ~= nil then self.edit2:destroy(); self.edit2 = nil; end;
        if self.layout8 ~= nil then self.layout8:destroy(); self.layout8 = nil; end;
        if self.layout1 ~= nil then self.layout1:destroy(); self.layout1 = nil; end;
        if self.scrollBox1 ~= nil then self.scrollBox1:destroy(); self.scrollBox1 = nil; end;
        if self.rectangle1 ~= nil then self.rectangle1:destroy(); self.rectangle1 = nil; end;
        if self.layout2 ~= nil then self.layout2:destroy(); self.layout2 = nil; end;
        if self.edit1 ~= nil then self.edit1:destroy(); self.edit1 = nil; end;
        if self.layout7 ~= nil then self.layout7:destroy(); self.layout7 = nil; end;
        self:_oldLFMDestroy();
    end;

    obj:endUpdate();

    return obj;
end;

function newfrmAMZ1_1()
    local retObj = nil;
    __o_rrpgObjs.beginObjectsLoading();

    __o_Utils.tryFinally(
      function()
        retObj = constructNew_frmAMZ1_1();
      end,
      function()
        __o_rrpgObjs.endObjectsLoading();
      end);

    assert(retObj ~= nil);
    return retObj;
end;

local _frmAMZ1_1 = {
    newEditor = newfrmAMZ1_1,
    new = newfrmAMZ1_1,
    name = "frmAMZ1_1",
    dataType = "",
    formType = "undefined",
    formComponentName = "form",
    title = "",
    description=""};

frmAMZ1_1 = _frmAMZ1_1;
Firecast.registrarForm(_frmAMZ1_1);

return _frmAMZ1_1;


text:
<?php

namespace JobsByMailTest\Factory\Controller;

use Interop\Container\ContainerInterface;
use Laminas\ServiceManager\ServiceLocatorInterface;
use JobsByMail\Factory\Controller\ConsoleControllerFactory;
use JobsByMail\Controller\ConsoleController;
use JobsByMail\Repository\SearchProfile as SearchProfileRepository;
use JobsByMail\Service\JobSeeker;
use JobsByMail\Service\Mailer;
use JobsByMail\Options\SubscribeOptions;
use Core\Console\ProgressBar;

/**
 * @coversDefaultClass \JobsByMail\Factory\Controller\ConsoleControllerFactory
 */
class ConsoleControllerFactoryTest extends \PHPUnit_Framework_TestCase
{

    /**
     * @covers ::__invoke
     */
    public function testInvoke()
    {
        $searchProfileRepository = $this->getMockBuilder(SearchProfileRepository::class)
            ->disableOriginalConstructor()
            ->getMock();

        $repositories = $this->getMockBuilder(ContainerInterface::class)
            ->getMock();
        $repositories->expects($this->once())
            ->method('get')
            ->with($this->equalTo('JobsByMail/SearchProfile'))
            ->willReturn($searchProfileRepository);

        $mailer = $this->getMockBuilder(Mailer::class)
            ->disableOriginalConstructor()
            ->getMock();

        $jobSeeker = $this->getMockBuilder(JobSeeker::class)
            ->disableOriginalConstructor()
            ->getMock();

        $options = $this->getMockBuilder(SubscribeOptions::class)
            ->getMock();

        $container = $this->getMockBuilder(ContainerInterface::class)
            ->getMock();
        $container->expects($this->exactly(4))
            ->method('get')
            ->will($this->returnValueMap([
                ['repositories', $repositories],
                [JobSeeker::class, $jobSeeker],
                [Mailer::class, $mailer],
                ['JobsByMail/SubscribeOptions', $options]
            ]));

        $controllerFactory = new ConsoleControllerFactory();
        $controller = $controllerFactory->__invoke($container, ConsoleController::class);
        $this->assertInstanceOf(ConsoleController::class, $controller);
        $this->assertInstanceOf(ProgressBar::class, $controller->getProgressBarFactory()->__invoke(0, 'preventOutput'));
    }

    /**
     * @covers ::createService
     */
    public function testCreateService()
    {
        $controller = $this->getMockBuilder(ConsoleController::class)
            ->disableOriginalConstructor()
            ->getMock();

        $container = $this->getMockBuilder(ServiceLocatorInterface::class)
            ->setMethods(['getServiceLocator', 'get', 'has', 'build'])
            ->getMock();
        $container->expects($this->once())
            ->method('getServiceLocator')
            ->willReturnSelf();

        $controllerFactory = $this->getMockBuilder(ConsoleControllerFactory::class)
            ->setMethods(['__invoke'])
            ->getMock();
        $controllerFactory->expects($this->once())
            ->method('__invoke')
            ->with($this->identicalTo($container), $this->identicalTo(ConsoleController::class))
            ->willReturn($controller);

        $this->assertSame($controller, $controllerFactory->createService($container));
    }
}


text:
package com.fasterxml.jackson.databind.node;

import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;

import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.core.io.NumberOutput;
import com.fasterxml.jackson.databind.SerializerProvider;

/**
 * Numeric node that contains 64-bit ("double precision")
 * floating point values simple 32-bit integer values.
 */
public final class DoubleNode
    extends NumericNode
{
    protected final double _value;

    /*
    /**********************************************************
    /* Construction
    /**********************************************************
     */

    public DoubleNode(double v) { _value = v; }

    public static DoubleNode valueOf(double v) { return new DoubleNode(v); }

    /*
    /**********************************************************
    /* BaseJsonNode extended API
    /**********************************************************
     */

    @Override public JsonToken asToken() { return JsonToken.VALUE_NUMBER_FLOAT; }

    @Override
    public JsonParser.NumberType numberType() { return JsonParser.NumberType.DOUBLE; }

    /*
    /**********************************************************
    /* Overrridden JsonNode methods
    /**********************************************************
     */

    @Override
    public boolean isFloatingPointNumber() { return true; }

    @Override
    public boolean isDouble() { return true; }

    @Override public boolean canConvertToInt() {
        return (_value >= Integer.MIN_VALUE && _value <= Integer.MAX_VALUE);
    }
    @Override public boolean canConvertToLong() {
        return (_value >= Long.MIN_VALUE && _value <= Long.MAX_VALUE);
    }

    @Override
    public Number numberValue() {
        return Double.valueOf(_value);
    }

    @Override
        public int intValue() { return (int) _value; }

    @Override
        public long longValue() { return (long) _value; }

    @Override
        public double doubleValue() { return _value; }

    @Override
        public BigDecimal decimalValue() { return BigDecimal.valueOf(_value); }

    @Override
    public BigInteger bigIntegerValue() {
        return decimalValue().toBigInteger();
    }

    @Override
    public String asText() {
        return NumberOutput.toString(_value);
    }

    @Override
    public final void serialize(JsonGenerator jg, SerializerProvider provider)
        throws IOException, JsonProcessingException
    {
        jg.writeNumber(_value);
    }

    @Override
    public boolean equals(Object o)
    {
        if (o == this) return true;
        if (o == null) return false;
        if (o.getClass() != getClass()) { // final class, can do this
            return false;
        }

        // We must account for NaNs: NaN does not equal NaN, therefore we have
        // to use Double.compare().
        final double otherValue = ((DoubleNode) o)._value;
        return Double.compare(_value, otherValue) == 0;
    }

    @Override
    public int hashCode()
    {
        // same as hashCode Double.class uses
        long l = Double.doubleToLongBits(_value);
        return ((int) l) ^ (int) (l >> 32);

    }
}


text:
\begin{problema}{Software Allocation}{Standard}{Standard}{UVa}

A computing center has ten different computers (numbered 0 to 9) on which applications can run. The computers are not multi-tasking, so each machine can run only one application at any time. There are 26 applications, named $A$ to $Z$. Whether an application can run on a particular computer can be found in a job description (see below).

Every morning, the users bring in their applications for that day. It is possible that two users bring in the same application; in that case two different, independent computers will be allocated for that application.

A clerk collects the applications, and for each different application he makes a list of computers on which the application could run. Then, he assigns each application to a computer. Remember: the computers are \emph{not} multi-tasking, so each computer must handle at most one application in total. (An application takes a day to complete, so that sequencing i.e. one application after another on the same machine is not possible).

A job description consists of

\begin{enumerate}
\item one upper case letter $A\dots Z$, indicating the application.
\item one digit $0\dots 9$, indicating the number of users who brought in the application.
\item a blank (space character.)
\item one or more different digits $0\dots 9$, indicating the computers on which the application can run.
\item a terminating semicolon ``;''.
\item an end-of-line.
\end{enumerate}

\InputFile

The input for your program is a textfile. For each day it contains one or more job descriptions, separated by a line containing only the end-of-line marker. The input file ends with the standard end-of-file marker. For each day your program determines whether an allocation of applications to computers can be done, and if so, generates a possible allocation.

\OutputFile

The output is also a textfile. For each day it consists of one of the following:

\begin{itemize}
\item ten characters from the set $A \dots Z , \_ $, indicating the applications allocated to computers 0 to 9 respectively if an allocation was possible. An underscore ``\_'' means that no application is allocated to the corresponding computer.

\item a single character ``!'', if no allocation was possible.
\end{itemize}

\Example

\input ejemplos/software.txt

URL:\\
http://uva.onlinejudge.org/index.php? \\
option=onlinejudge\&page=show\_problem\&problem=195

\end{problema}


text:
/**
 * Generalized Abbreviation
 *
 * Write a function to generate the generalized abbreviations of a word.
 *
 * Note: The order of the output does not matter.
 *
 * Example:
 *
 * Input: "word"
 * Output:
 * ["word", "1ord", "w1rd", "wo1d", "wor1", "2rd", "w2d", "wo2", "1o1d", "1or1", "w1r1", "1o2", "2r1", "3d", "w3", "4"]
 */

/**
 * @param {string} word
 * @return {string[]}
 */
const generateAbbreviations = word => {
  const result = [];
  backtracking(word, 0, 0, '', result);
  return result;
};

const backtracking = (word, index, count, solution, result) => {
  if (index === word.length) {
    if (count > 0) {
      solution += count;
    }
    result.push(solution);
    return;
  }

  // solution | count | word[index]
  // -------- |  10   | I

  // Case 1. Continue to use number to replace the character
  backtracking(word, index + 1, count + 1, solution, result);
  // Case 2. Stop using number to replace the character
  backtracking(word, index + 1, 0, solution + (count > 0 ? count : '') + word[index], result);
};

export { generateAbbreviations };


text:
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInspection;

import com.intellij.codeInspection.deprecation.DeprecationInspectionBase;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.psi.util.PsiUtil;
import org.jetbrains.annotations.NotNull;

/**
 * @author cdr
 */
public class DeprecatedIsStillUsedInspection extends LocalInspectionTool {
  @NotNull
  @Override
  public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder,
                                        final boolean isOnTheFly,
                                        @NotNull final LocalInspectionToolSession session) {
    return new JavaElementVisitor() {
      @Override
      public void visitIdentifier(PsiIdentifier identifier) {
        PsiElement parent = identifier.getParent();
        if (parent instanceof PsiMember && parent instanceof PsiNameIdentifierOwner && ((PsiNameIdentifierOwner)parent).getNameIdentifier() == identifier) {
          checkMember((PsiMember)parent, identifier, holder);
        }
        super.visitIdentifier(identifier);
      }
    };
  }

  private static void checkMember(@NotNull PsiMember member, @NotNull PsiIdentifier identifier, @NotNull ProblemsHolder holder) {
    if (!(member instanceof PsiDocCommentOwner) || !isDeprecated((PsiDocCommentOwner)member)) {
      return;
    }

    PsiSearchHelper searchHelper = PsiSearchHelper.getInstance(member.getProject());
    String name = member.getName();
    if (name != null && hasUsages(member, name, searchHelper, member.getResolveScope())) {
      holder.registerProblem(identifier, "Deprecated member '" + name + "' is still used");
    }
  }

  private static boolean isDeprecated(PsiDocCommentOwner element) {
    return element.isDeprecated();
  }

  private static boolean hasUsages(@NotNull PsiElement element,
                                       @NotNull String name,
                                       @NotNull PsiSearchHelper psiSearchHelper,
                                       @NotNull GlobalSearchScope searchScope) {
    PsiSearchHelper.SearchCostResult cheapEnough = psiSearchHelper.isCheapEnoughToSearch(name, searchScope, null, null);
    if (cheapEnough == PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES ||
        cheapEnough == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES) {
      return false;
    }

    return ReferencesSearch.search(element, searchScope, false)
      .anyMatch(reference -> {
        PsiElement referenceElement = reference.getElement();
        return !DeprecationInspectionBase.isElementInsideDeprecated(referenceElement) &&
               !PsiUtil.isInsideJavadocComment(referenceElement);
      });
  }
}


text:
import pandas as pd
import grizzly.grizzly as gr
import time

# Make display smaller
pd.options.display.max_rows = 10

unames = ['user_id', 'gender', 'age', 'occupation', 'zip']
users = pd.read_table('data/ml-1m/users.dat', sep='::', header=None,
                      names=unames)

rnames = ['user_id', 'movie_id', 'rating', 'timestamp']
ratings = pd.read_table('data/ml-1m/ratings.dat', sep='::', header=None,
                        names=rnames)

mnames = ['movie_id', 'title', 'genres']
movies = pd.read_table('data/ml-1m/movies.dat', sep='::', header=None,
                       names=mnames)

start = time.time()
ratings = gr.DataFrameWeld(ratings)
users = gr.DataFrameWeld(users)
movies = gr.DataFrameWeld(movies)

data = gr.merge(gr.merge(ratings, users), movies).evaluate(True).to_pandas()
end = time.time()

start1 = time.time()
print data
data = gr.DataFrameWeld(data)
mean_ratings = data.pivot_table('rating', index='title', columns='gender',
                                aggfunc='mean')

ratings_by_title = data.groupby('title').size()
active_titles = ratings_by_title.index[ratings_by_title >= 250]
mean_ratings = mean_ratings.loc[active_titles]
mean_ratings['diff'] = mean_ratings['M'] - mean_ratings['F']
sorted_by_diff = mean_ratings.sort_values(by='diff')
rating_std_by_title = data.groupby('title')['rating'].std()
rating_std_by_title = rating_std_by_title.loc[active_titles]
rating_std_by_title = rating_std_by_title.sort_values(ascending=False)[0:10]
sorted_by_diff, rating_std_by_title = gr.group_eval([sorted_by_diff, rating_std_by_title])
end1 = time.time()

print sorted_by_diff
print rating_std_by_title
print "Time to merge:", (end - start)
print "Time for analysis:", (end1 - start1)


text:
/**
 * Autogenerated by Thrift Compiler (0.9.3)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */

#import <Foundation/Foundation.h>

@import ThriftLib;

#import "Aroma.h"
#import "Authentication.h"

typedef Aroma_int AromaEmail_int;

typedef Aroma_long AromaEmail_long;

typedef Aroma_timestamp AromaEmail_timestamp;

typedef Aroma_Application * AromaEmail_Application;

typedef Aroma_User * AromaEmail_User;

typedef AromaAuthentication_ApplicationToken * AromaEmail_ApplicationToken;

@interface AromaEmail_EmailNewApplication : NSObject <TBase, NSCoding> {
  AromaEmail_User __creator;
  AromaEmail_Application __app;
  AromaEmail_ApplicationToken __appToken;

  BOOL __creator_isset;
  BOOL __app_isset;
  BOOL __appToken_isset;
}

#if TARGET_OS_IPHONE || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
@property (nonatomic, retain, getter=creator, setter=setCreator:) AromaEmail_User creator;
@property (nonatomic, retain, getter=app, setter=setApp:) AromaEmail_Application app;
@property (nonatomic, retain, getter=appToken, setter=setAppToken:) AromaEmail_ApplicationToken appToken;
#endif

- (id) init;
- (id) initWithCreator: (AromaEmail_User) creator app: (AromaEmail_Application) app appToken: (AromaEmail_ApplicationToken) appToken;

- (void) read: (id <TProtocol>) inProtocol;
- (void) write: (id <TProtocol>) outProtocol;

- (void) validate;

#if !__has_feature(objc_arc)
- (AromaEmail_User) creator;
- (void) setCreator: (AromaEmail_User) creator;
#endif
- (BOOL) creatorIsSet;

#if !__has_feature(objc_arc)
- (AromaEmail_Application) app;
- (void) setApp: (AromaEmail_Application) app;
#endif
- (BOOL) appIsSet;

#if !__has_feature(objc_arc)
- (AromaEmail_ApplicationToken) appToken;
- (void) setAppToken: (AromaEmail_ApplicationToken) appToken;
#endif
- (BOOL) appTokenIsSet;

@end

@interface AromaEmail_EmailNewUserRegistration : NSObject <TBase, NSCoding> {
  AromaEmail_User __infoOfNewUser;

  BOOL __infoOfNewUser_isset;
}

#if TARGET_OS_IPHONE || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
@property (nonatomic, retain, getter=infoOfNewUser, setter=setInfoOfNewUser:) AromaEmail_User infoOfNewUser;
#endif

- (id) init;
- (id) initWithInfoOfNewUser: (AromaEmail_User) infoOfNewUser;

- (void) read: (id <TProtocol>) inProtocol;
- (void) write: (id <TProtocol>) outProtocol;

- (void) validate;

#if !__has_feature(objc_arc)
- (AromaEmail_User) infoOfNewUser;
- (void) setInfoOfNewUser: (AromaEmail_User) infoOfNewUser;
#endif
- (BOOL) infoOfNewUserIsSet;

@end

@interface AromaEmail_EmailMessage : NSObject <TBase, NSCoding> {
  AromaEmail_EmailNewApplication * __newApp;
  AromaEmail_EmailNewUserRegistration * __newUser;

  BOOL __newApp_isset;
  BOOL __newUser_isset;
}

#if TARGET_OS_IPHONE || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
@property (nonatomic, retain, getter=newApp, setter=setNewApp:) AromaEmail_EmailNewApplication * newApp;
@property (nonatomic, retain, getter=newUser, setter=setNewUser:) AromaEmail_EmailNewUserRegistration * newUser;
#endif

- (id) init;
- (id) initWithNewApp: (AromaEmail_EmailNewApplication *) newApp newUser: (AromaEmail_EmailNewUserRegistration *) newUser;

- (void) read: (id <TProtocol>) inProtocol;
- (void) write: (id <TProtocol>) outProtocol;

- (void) validate;

#if !__has_feature(objc_arc)
- (AromaEmail_EmailNewApplication *) newApp;
- (void) setNewApp: (AromaEmail_EmailNewApplication *) newApp;
#endif
- (BOOL) newAppIsSet;

#if !__has_feature(objc_arc)
- (AromaEmail_EmailNewUserRegistration *) newUser;
- (void) setNewUser: (AromaEmail_EmailNewUserRegistration *) newUser;
#endif
- (BOOL) newUserIsSet;

@end

@interface AromaEmail_EmailConstants : NSObject {
}
@end


text:
<?php

namespace ListOnce\Entity;

class AlertCollection extends EntityCollection
{

    /**
     * Does this collection use pagination?
     *
     * @var bool
     */
    protected $hasPagination = true;

    /**
     * The property containing entities
     *
     * @var string
     */
    protected $entityProperty = 'alerts';

    /**
     * The property containing total entities
     *
     * @var string
     */
    protected $totalEntitiesProperty = 'total_alerts';

    /**
     * The data type of entities within this collection
     *
     * @var string
     */
    protected $dataType = 'Alert';
}


text:
<?php

use ActiveRecord\ConnectionInfo;

class ConnectionInfoTest extends SnakeCase_PHPUnit_Framework_TestCase
{
	/**
	 * @expectedException ActiveRecord\DatabaseException
	 */
	public function test_connection_info_from_should_throw_exception_when_no_host()
	{
		ConnectionInfo::from_connection_url('mysql://user:pass@');
	}

	public function test_connection_info()
	{
		$info = ConnectionInfo::from_connection_url('mysql://user:pass@127.0.0.1:3306/dbname');
		$this->assert_equals('mysql', $info->adapter);
		$this->assert_equals('user', $info->username);
		$this->assert_equals('pass', $info->password);
		$this->assert_equals('127.0.0.1', $info->host);
		$this->assert_equals(3306, $info->port);
		$this->assert_equals('dbname', $info->database);
	}

	public function test_gh_103_sqlite_connection_string_relative()
	{
		$info = ConnectionInfo::from_connection_url('sqlite://../some/path/to/file.db');
		$this->assert_equals('../some/path/to/file.db', $info->host);
	}

	/**
	 * @expectedException ActiveRecord\DatabaseException
	 */
	public function test_gh_103_sqlite_connection_string_absolute()
	{
		$info = ConnectionInfo::from_connection_url('sqlite:///some/path/to/file.db');
	}

	public function test_gh_103_sqlite_connection_string_unix()
	{
		$info = ConnectionInfo::from_connection_url('sqlite://unix(/some/path/to/file.db)');
		$this->assert_equals('/some/path/to/file.db', $info->host);

		$info = ConnectionInfo::from_connection_url('sqlite://unix(/some/path/to/file.db)/');
		$this->assert_equals('/some/path/to/file.db', $info->host);

		$info = ConnectionInfo::from_connection_url('sqlite://unix(/some/path/to/file.db)/dummy');
		$this->assert_equals('/some/path/to/file.db', $info->host);
	}

	public function test_gh_103_sqlite_connection_string_windows()
	{
		$info = ConnectionInfo::from_connection_url('sqlite://windows(c%3A/some/path/to/file.db)');
		$this->assert_equals('c:/some/path/to/file.db', $info->host);
	}

	public function test_parse_connection_url_with_unix_sockets()
	{
		$info = ConnectionInfo::from_connection_url('mysql://user:password@unix(/tmp/mysql.sock)/database');
		$this->assert_equals('/tmp/mysql.sock', $info->host);
		$this->assert_equals('database', $info->database);
	}

	public function test_parse_connection_url_with_decode_option()
	{
		$info = ConnectionInfo::from_connection_url('mysql://h%20az:h%40i@127.0.0.1/test?decode=true');
		$this->assert_equals('h az', $info->username);
		$this->assert_equals('h@i', $info->password);
	}

	public function test_encoding()
	{
		$info = ConnectionInfo::from_connection_url('mysql://test:test@127.0.0.1/test?charset=utf8');
		$this->assert_equals('utf8', $info->charset);
	}

	public function test_connection_info_from_array(){
		$info = new ConnectionInfo(array(
			'adapter' => 'mysql',
			'host' => '127.0.0.1',
			'port' => 3306,
			'database' => 'dbname',
			'username' => 'user',
			'password' => 'pass'
		));
		$this->assert_equals('mysql', $info->adapter);
		$this->assert_equals('user', $info->username);
		$this->assert_equals('pass', $info->password);
		$this->assert_equals('127.0.0.1', $info->host);
		$this->assert_equals(3306, $info->port);
		$this->assert_equals('dbname', $info->database);
	}

}


text: require "cielo"


text:
module.exports = require('../lib/')
  .extend('faker', function() {
    try {
      return require('faker/locale/en_CA');
    } catch (e) {
      return null;
    }
  });