text:
using PicoMVVM.PubSub;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace PicoMVVM.Tests
{

	///
	///This is a test class for MessageCenterTest and is intended
	///to contain all MessageCenterTest Unit Tests
	///
	[TestClass()]
	public class MessageCenterTest
	{

		private TestContext testContextInstance;

		///
		///Gets or sets the test context which provides
		///information about and functionality for the current test run.
		///
		public TestContext TestContext
		{
			get
			{
				return testContextInstance;
			}
			set
			{
				testContextInstance = value;
			}
		}

		#region Additional test attributes
		//
		//You can use the following additional attributes as you write your tests:
		//
		//Use ClassInitialize to run code before running the first test in the class
		//[ClassInitialize()]
		//public static void MyClassInitialize(TestContext testContext)
		//{
		//}
		//
		//Use ClassCleanup to run code after all tests in a class have run
		//[ClassCleanup()]
		//public static void MyClassCleanup()
		//{
		//}
		//
		//Use TestInitialize to run code before running each test
		//[TestInitialize()]
		//public void MyTestInitialize()
		//{
		//}
		//
		//Use TestCleanup to run code after each test has run
		//[TestCleanup()]
		//public void MyTestCleanup()
		//{
		//}
		//
		#endregion

		class message
		{
			public string txt { get; set; }
		}
		class message2
		{
			public string txt { get; set; }
		}

		///
		///A test for MessageCenter Constructor
		///
		[TestMethod()]
		public void MessageCenterConstructorTest()
		{
			MessageCenter target = new MessageCenter();
		}

		///
		///A test for ClearSubscriptions
		///
		[TestMethod()]
		public void ClearSubscriptionsTest()
		{
			MessageCenter target = new MessageCenter();
			target.ClearSubscriptions();
		}

		[TestMethod()]
		public void PublishTest()
		{
			MessageCenter target = new MessageCenter();
			var msg = new message();
			target.Publish(msg);
		}

		[TestMethod()]
		public void PublishTopicalTest()
		{
			MessageCenter target = new MessageCenter();
			var msg = new message();
			target.Publish(msg, "topic");
		}

		[TestMethod()]
		public void SubscribeTest()
		{
			MessageCenter target = new MessageCenter();
			target.Subscribe<message>(msg => { });
		}
		[TestMethod()]
		public void SubscribeTopicalTest()
		{
			MessageCenter target = new MessageCenter();
			target.Subscribe<message>(msg => { }, "topic");
		}

		[TestMethod]
		public void PublishToAltSubscribedTest()
		{
			//arrange
			MessageCenter target = new MessageCenter();
			string res = null;
			target.Subscribe<string>(a => { res = a; });

			var msg = new message() { txt = "hi" };

			//act
			target.Publish(msg);

			//assert
			Assert.AreNotEqual(res, "hi");
		}

		[TestMethod()]
		public void PublishToSubscribedTest()
		{
			//arrange
			MessageCenter target = new MessageCenter();
			string res = null;
			target.Subscribe<message>(a => { res = a.txt; });

			var msg = new message() { txt = "hi" };

			//act
			target.Publish(msg);

			//assert
			Assert.AreEqual(res, "hi");
		}

		[TestMethod()]
		public void PublishToSubscribedTopicalTest()
		{
			//arrange
			MessageCenter target = new MessageCenter();
			string res = null;
			target.Subscribe<message>(a => { res = a.txt; }, "topic");

			var msg = new message() { txt = "hi" };

			//act
			target.Publish(msg);

			//assert
			Assert.AreNotEqual(res, "hi");
		}

		[TestMethod()]
		public void PublishTopicalToSubscribedTest()
		{
			//arrange
			MessageCenter target = new MessageCenter();
			string res = null;
			target.Subscribe<message>(a => { res = a.txt; });

			var msg = new message() { txt = "hi" };

			//act
			target.Publish(msg, "topic");

			//assert
			Assert.AreEqual(res, "hi");
		}

		[TestMethod()]
		public void PublishTopicalToSubscribedTopicalTest()
		{
			//arrange
			MessageCenter target = new MessageCenter();
			string res = null;
			target.Subscribe<message>(a => { res = a.txt; }, "topic");

			var msg = new message { txt = "hi" };

			//act
			target.Publish(msg, "topic");

			//assert
			Assert.AreEqual(res, "hi");
		}

		[TestMethod()]
		public void PublishTopicalToSubscribedAltTopicalTest()
		{
			//arrange
			MessageCenter target = new MessageCenter();
			string res = null;
			target.Subscribe<message>(a => { res = a.txt; }, "topic");

			var msg = new message { txt = "hi" };

			//act
			target.Publish(msg, "topica");

			//assert
			Assert.AreNotEqual(res, "hi");
		}

	}
}


text:
import type {PerseusRenderer} from "../../perseus-types.js";

export const question1: PerseusRenderer = {
    content:
        "**Arrange the following measurements in order from smallest to largest.**\n\n[[\u2603 sorter 1]]",
    images: {},
    widgets: {
        "sorter 1": {
            version: {major: 0, minor: 0},
            type: "sorter",
            graded: true,
            options: {
                padding: true,
                layout: "horizontal",
                correct: ["$0.005$ kilograms", "$15$ grams", "$55$ grams"],
            },
        },
    },
};

redpajama_set_name: RedPajamaGithub


text:
#include <aws/codepipeline/model/ActionTypeId.h>
#include <aws/core/utils/json/JsonSerializer.h>

#include <utility>

using namespace Aws::Utils::Json;
using namespace Aws::Utils;

namespace Aws
{
namespace CodePipeline
{
namespace Model
{

ActionTypeId::ActionTypeId() :
    m_category(ActionCategory::NOT_SET),
    m_categoryHasBeenSet(false),
    m_owner(ActionOwner::NOT_SET),
    m_ownerHasBeenSet(false),
    m_providerHasBeenSet(false),
    m_versionHasBeenSet(false)
{
}

ActionTypeId::ActionTypeId(const JsonValue& jsonValue) :
    m_category(ActionCategory::NOT_SET),
    m_categoryHasBeenSet(false),
    m_owner(ActionOwner::NOT_SET),
    m_ownerHasBeenSet(false),
    m_providerHasBeenSet(false),
    m_versionHasBeenSet(false)
{
  *this = jsonValue;
}

ActionTypeId& ActionTypeId::operator =(const JsonValue& jsonValue)
{
  if(jsonValue.ValueExists("category"))
  {
    m_category = ActionCategoryMapper::GetActionCategoryForName(jsonValue.GetString("category"));

    m_categoryHasBeenSet = true;
  }

  if(jsonValue.ValueExists("owner"))
  {
    m_owner = ActionOwnerMapper::GetActionOwnerForName(jsonValue.GetString("owner"));

    m_ownerHasBeenSet = true;
  }

  if(jsonValue.ValueExists("provider"))
  {
    m_provider = jsonValue.GetString("provider");

    m_providerHasBeenSet = true;
  }

  if(jsonValue.ValueExists("version"))
  {
    m_version = jsonValue.GetString("version");

    m_versionHasBeenSet = true;
  }

  return *this;
}

JsonValue ActionTypeId::Jsonize() const
{
  JsonValue payload;

  if(m_categoryHasBeenSet)
  {
   payload.WithString("category", ActionCategoryMapper::GetNameForActionCategory(m_category));
  }

  if(m_ownerHasBeenSet)
  {
   payload.WithString("owner", ActionOwnerMapper::GetNameForActionOwner(m_owner));
  }

  if(m_providerHasBeenSet)
  {
   payload.WithString("provider", m_provider);

  }

  if(m_versionHasBeenSet)
  {
   payload.WithString("version", m_version);

  }

  return payload;
}

} // namespace Model
} // namespace CodePipeline
} // namespace Aws


text:
$TEMPLATE[gbsvx.all.TRANS.trait_of]
AB
$TEMPLATE[gbsvx.all.KU.trait]
num_super_sub,AB
$TEMPLATE[gbsvx.real.min_size_iwork.args]
N
$TEMPLATE[gbsvx.real.min_size_iwork]
return n;
$TEMPLATE[gbsvx.real.min_size_work.args]
N
$TEMPLATE[gbsvx.real.min_size_work]
return 3*n;
$TEMPLATE[gbsvx.complex.min_size_rwork.args]
N
$TEMPLATE[gbsvx.complex.min_size_rwork]
return n;
$TEMPLATE[end]


text:
<?php
/**
 * Created by PhpStorm.
 * User: Petrica
 * Date: 3/26/2016
 * Time: 1:23
 */
namespace Petrica\StatsdSystem\Config;

use Petrica\StatsdSystem\Config\Definition\ConfigDefinition;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Yaml\Parser;

class ConfigLoader
{
    /**
     * Filepath to Yaml configuration file
     * @var String
     */
    private $filepath;

    /**
     * ConfigLoader constructor.
     * @param $filepath
     */
    public function __construct($filepath)
    {
        $this->filepath = $filepath;
    }

    /**
     * Process configuration and make sure the configuration format is as expected
     *
     * @return array
     */
    public function load()
    {
        if (file_exists($this->filepath) && ($contents = file_get_contents($this->filepath))) {
            $yaml = new Parser();
            $config = $yaml->parse($contents);

            if (null === $config) {
                $config = array();
            }

            $processor = new Processor();
            $configDefinition = new ConfigDefinition();
            $processedConfiguration = $processor->processConfiguration(
                $configDefinition,
                $config
            );

            if (empty($processedConfiguration)) {
                throw new Exception(
                    'You need to specify at least one gaguge in the configuration file'
                );
            }

            return $processedConfiguration;
        }
        else {
            throw new \RuntimeException(sprintf('Configuration file does not exist or is not accessible %s',
                $this->filepath));
        }

    }
}


text:
<?php

/**
 */
require_once 'Opus11/Example.php';
require_once 'Opus11/Timer.php';

/**
 * Program that measures the running times of both
 * a recursive and a non-recursive method that computes
 * the Fibonacci numbers.
 *
 * @package Opus11
 */
class Experiment1
{
    /**
     * Main program.
     *
     * @param array $args Command-line arguments.
     * @return integer Zero on success; non-zero on failure.
     */
    public static function main($args)
    {
        $status = 0;
        printf("3\n");
        printf("n\n");
        printf("fib1 s\n");
        printf("fib2 s\n");
        for ($i = 0; $i < 48; ++$i)
        {
            $timer = new Timer();
            $timer->start();
            $result = fibonacci($i);
            $timer->stop();
            $time1 = $timer->getElapsedTime();

            $timer->start();
            $result = fibonacci2($i);
            $timer->stop();
            $time2 = $timer->getElapsedTime();

            printf("%d\t%f\t%f\n", $i, $time1, $time2);
        }
        return $status;
    }
}

if (realpath($argv[0]) == realpath(__FILE__))
{
    exit(Experiment1::main(array_slice($argv, 1)));
}
?>


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

namespace OpenQA.Selenium
{
    /// <summary>
    /// Represents the speed with which actions are executed in the browser.
    /// </summary>
    public class Speed
    {
        /// <summary>
        /// Gets a slow speed.
        /// </summary>
        public static readonly Speed Slow = new Speed("Slow", 1000);

        /// <summary>
        /// Gets a medium speed.
        /// </summary>
        public static readonly Speed Medium = new Speed("Medium", 500);

        /// <summary>
        /// Gets a fast speed.
        /// </summary>
        public static readonly Speed Fast = new Speed("Fast", 0);

        private int speedTimeout = 0;
        private string speedDescription = string.Empty;

        private Speed(string description, int timeout)
        {
            speedDescription = description;
            speedTimeout = timeout;
        }

        /// <summary>
        /// Gets the timeout for the speed.
        /// </summary>
        public int Timeout
        {
            get { return speedTimeout; }
        }

        /// <summary>
        /// Gets the description of the speed.
        /// </summary>
        public string Description
        {
            get { return speedDescription; }
        }

        /// <summary>
        /// Creates a <see cref="Speed"/> object from its string description.
        /// </summary>
        /// <param name="speedName">The description of the speed to create.</param>
        /// <returns>The <see cref="Speed"/> object.</returns>
        public static Speed FromString(string speedName)
        {
            Speed toReturn = Fast;
            if (string.Compare(speedName, "medium", StringComparison.OrdinalIgnoreCase) == 0)
            {
                toReturn = Medium;
            }

            if (string.Compare(speedName, "slow", StringComparison.OrdinalIgnoreCase) == 0)
            {
                toReturn = Slow;
            }

            return toReturn;
        }

        /// <summary>
        /// Serves as a hash function for a particular type.
        /// </summary>
        /// <returns>A hash code for the current <see cref="System.Object">Object</see>.</returns>
        public override int GetHashCode()
        {
            return speedDescription.GetHashCode();
        }

        /// <summary>
        /// Determines whether the specified <see cref="System.Object">Object</see> is equal
        /// to the current <see cref="System.Object">Object</see>.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object">Object</see> to compare with the
        /// current <see cref="System.Object">Object</see>.</param>
        /// <returns><see langword="true"/> if the specified <see cref="System.Object">Object</see>
        /// is equal to the current <see cref="System.Object">Object</see>; otherwise,
        /// <see langword="false"/>.</returns>
        public override bool Equals(object obj)
        {
            bool isEqual = false;
            Speed otherObject = obj as Speed;
            if (otherObject != null)
            {
                isEqual = string.Compare(otherObject.Description, speedDescription, StringComparison.OrdinalIgnoreCase) == 0;
            }

            return base.Equals(obj);
        }
    }
}


text:
Slob
====

Slob is a set of simple RequireJS modules made to abstract librairies such as Lo-Dash, jQuery, Backbone, Handlebars... and assemble them into a framework and other components to ensure modularity of application code.

Installation
------------

Using Bower: `bower install slob`

Previous work
-------------

Slob is based on best-practices articles and presentations, most notably:

* [Scalable JavaScript Application Architecture](http://www.slideshare.net/nzakas/scalable-javascript-application-architecture) by Nicholas Zakas
* [Large-scale JavaScript Application Architecture](https://speakerdeck.com/addyosmani/large-scale-javascript-application-architecture) by Addy Osmani
* [Learning JavaScript Design Patterns](http://addyosmani.com/resources/essentialjsdesignpatterns/book/) by Addy Osmani
* [Building The Next SoundCloud](http://backstage.soundcloud.com/2012/06/building-the-next-soundcloud/) by Nick Fisher

Work in progress
----------------

This code is still in very early development, it requires lots of testing and is not appropriate for production applications.
Future developments will focus on adding tests and examples.

Architecture
------------

Slob architecture is made of 3 parts, defining 3 layers of abstraction:

* The **core** is made to abstract librairies and eventually split or assemble them into different functionalities. It also offers basic implementations of different design patterns and general-purpose utilities.
* The **extensions** purpose is to augment the core functionalities and provide new ones to match the needs of the application, assembled in a simple framework and a mediator.
* The **sandboxes** purpose is to provide a limited API of the core and framework functionalities to the actual application modules depending on their role, such as services and widgets.

License
-------

MIT - See LICENSE file


text:
import json

from openstackclient.tests.functional.network.v2 import common

class L3NDPProxyTests(common.NetworkTests):

    def setUp(self):
        super().setUp()
        # Nothing in this class works with Nova Network
        if not self.haz_network:
            self.skipTest("No Network service present")
        if not self.is_extension_enabled('l3-ndp-proxy'):
            self.skipTest("No l3-ndp-proxy extension present")

        self.ROT_NAME = self.getUniqueString()
        self.EXT_NET_NAME = self.getUniqueString()
        self.EXT_SUB_NAME = self.getUniqueString()
        self.INT_NET_NAME = self.getUniqueString()
        self.INT_SUB_NAME = self.getUniqueString()
        self.INT_PORT_NAME = self.getUniqueString()
        self.ADDR_SCOPE_NAME = self.getUniqueString()
        self.SUBNET_P_NAME = self.getUniqueString()
        self.created_ndp_proxies = []

        json_output = json.loads(
            self.openstack(
                'address scope create -f json --ip-version 6 '
                '%(address_s_name)s' % {
                    'address_s_name': self.ADDR_SCOPE_NAME}))
        self.assertIsNotNone(json_output['id'])
        self.ADDRESS_SCOPE_ID = json_output['id']
        json_output = json.loads(
            self.openstack(
                'subnet pool create -f json %(subnet_p_name)s '
                '--address-scope %(address_scope)s '
                '--pool-prefix 2001:db8::/96 --default-prefix-length 112' % {
                    'subnet_p_name': self.SUBNET_P_NAME,
                    'address_scope': self.ADDRESS_SCOPE_ID}))
        self.assertIsNotNone(json_output['id'])
        self.SUBNET_POOL_ID = json_output['id']
        json_output = json.loads(
            self.openstack('network create -f json '
                           '--external ' + self.EXT_NET_NAME))
        self.assertIsNotNone(json_output['id'])
        self.EXT_NET_ID = json_output['id']
        json_output = json.loads(
            self.openstack(
                'subnet create -f json --ip-version 6 --subnet-pool '
                '%(subnet_pool)s --network %(net_id)s %(sub_name)s' % {
                    'subnet_pool': self.SUBNET_POOL_ID,
                    'net_id': self.EXT_NET_ID,
                    'sub_name': self.EXT_SUB_NAME}))
        self.assertIsNotNone(json_output['id'])
        self.EXT_SUB_ID = json_output['id']
        json_output = json.loads(
            self.openstack('router create -f json ' + self.ROT_NAME))
        self.assertIsNotNone(json_output['id'])
        self.ROT_ID = json_output['id']
        output = self.openstack(
            'router set %(router_id)s --external-gateway %(net_id)s' % {
                'router_id': self.ROT_ID,
                'net_id': self.EXT_NET_ID})
        self.assertEqual('', output)
        output = self.openstack('router set --enable-ndp-proxy ' + self.ROT_ID)
        self.assertEqual('', output)
        json_output = json.loads(
            self.openstack(
                'router show -f json -c enable_ndp_proxy ' + self.ROT_ID))
        self.assertTrue(json_output['enable_ndp_proxy'])
        json_output = json.loads(
            self.openstack('network create -f json ' + self.INT_NET_NAME))
        self.assertIsNotNone(json_output['id'])
        self.INT_NET_ID = json_output['id']
        json_output = json.loads(
            self.openstack(
                'subnet create -f json --ip-version 6 --subnet-pool '
                '%(subnet_pool)s --network %(net_id)s %(sub_name)s' % {
                    'subnet_pool': self.SUBNET_POOL_ID,
                    'net_id': self.INT_NET_ID,
                    'sub_name': self.INT_SUB_NAME}))
        self.assertIsNotNone(json_output['id'])
        self.INT_SUB_ID = json_output['id']
        json_output = json.loads(
            self.openstack(
                'port create -f json --network %(net_id)s '
                '%(port_name)s' % {
                    'net_id': self.INT_NET_ID,
                    'port_name': self.INT_PORT_NAME}))
        self.assertIsNotNone(json_output['id'])
        self.INT_PORT_ID = json_output['id']
        self.INT_PORT_ADDRESS = json_output['fixed_ips'][0]['ip_address']
        output = self.openstack(
            'router add subnet ' + self.ROT_ID + ' ' + self.INT_SUB_ID)
        self.assertEqual('', output)

    def tearDown(self):
        for ndp_proxy in self.created_ndp_proxies:
            output = self.openstack(
                'router ndp proxy delete ' + ndp_proxy['id'])
            self.assertEqual('', output)
        output = self.openstack('port delete ' + self.INT_PORT_ID)
        self.assertEqual('', output)
        output = self.openstack(
            'router set --disable-ndp-proxy ' + self.ROT_ID)
        self.assertEqual('', output)
        output = self.openstack(
            'router remove subnet ' + self.ROT_ID + ' ' + self.INT_SUB_ID)
        self.assertEqual('', output)
        output = self.openstack('subnet delete ' + self.INT_SUB_ID)
        self.assertEqual('', output)
        output = self.openstack('network delete ' + self.INT_NET_ID)
        self.assertEqual('', output)
        output = self.openstack(
            'router unset ' + self.ROT_ID + ' ' + '--external-gateway')
        self.assertEqual('', output)
        output = self.openstack('router delete ' + self.ROT_ID)
        self.assertEqual('', output)
        output = self.openstack('subnet delete ' + self.EXT_SUB_ID)
        self.assertEqual('', output)
        output = self.openstack('network delete ' + self.EXT_NET_ID)
        self.assertEqual('', output)
        output = self.openstack('subnet pool delete ' + self.SUBNET_POOL_ID)
        self.assertEqual('', output)
        output = self.openstack('address scope delete ' +
                                self.ADDRESS_SCOPE_ID)
        self.assertEqual('', output)
        super().tearDown()

    def _create_ndp_proxies(self, ndp_proxies):
        for ndp_proxy in ndp_proxies:
            output = json.loads(
                self.openstack(
                    'router ndp proxy create %(router)s --name %(name)s '
                    '--port %(port)s --ip-address %(address)s -f json' % {
                        'router': ndp_proxy['router_id'],
                        'name': ndp_proxy['name'],
                        'port': ndp_proxy['port_id'],
                        'address': ndp_proxy['address']}))
            self.assertEqual(ndp_proxy['router_id'], output['router_id'])
            self.assertEqual(ndp_proxy['port_id'], output['port_id'])
            self.assertEqual(ndp_proxy['address'], output['ip_address'])
            self.created_ndp_proxies.append(output)

    def test_create_ndp_proxy(self):
        ndp_proxies = [
            {
                'name': self.getUniqueString(),
                'router_id': self.ROT_ID,
                'port_id': self.INT_PORT_ID,
                'address': self.INT_PORT_ADDRESS
            }
        ]
        self._create_ndp_proxies(ndp_proxies)

    def test_ndp_proxy_list(self):
        ndp_proxies = {
            'name': self.getUniqueString(),
            'router_id': self.ROT_ID,
            'port_id': self.INT_PORT_ID,
            'address': self.INT_PORT_ADDRESS}
        self._create_ndp_proxies([ndp_proxies])
        ndp_proxy = json.loads(self.openstack(
            'router ndp proxy list -f json'))[0]
        self.assertEqual(ndp_proxies['name'], ndp_proxy['Name'])
        self.assertEqual(ndp_proxies['router_id'], ndp_proxy['Router ID'])
        self.assertEqual(ndp_proxies['address'], ndp_proxy['IP Address'])

    def test_ndp_proxy_set_and_show(self):
        ndp_proxies = {
            'name': self.getUniqueString(),
            'router_id': self.ROT_ID,
            'port_id': self.INT_PORT_ID,
            'address': self.INT_PORT_ADDRESS}
        description = 'balala'
        self._create_ndp_proxies([ndp_proxies])
        ndp_proxy_id = self.created_ndp_proxies[0]['id']
        output = self.openstack(
            'router ndp proxy set --description %s %s' % (
                description, ndp_proxy_id))
        self.assertEqual('', output)
        json_output = json.loads(
            self.openstack('router ndp proxy show -f json ' + ndp_proxy_id))
        self.assertEqual(ndp_proxies['name'], json_output['name'])
        self.assertEqual(ndp_proxies['router_id'], json_output['router_id'])
        self.assertEqual(ndp_proxies['port_id'], json_output['port_id'])
        self.assertEqual(ndp_proxies['address'], json_output['ip_address'])
        self.assertEqual(description, json_output['description'])


text:
#include <stdinc.hpp>
#include "../data_traits.hpp"
using namespace modloader;
using std::set;
using std::string;

enum class PedRelationship : uint8_t
{
    None,
    Hate, Dislike, Like, Respect,  // SA
    Threat, Avoid,                 // III/VC
};

template<>
struct enum_map<PedRelationship>
{
    static std::map<string, PedRelationship>& map()
    {
        static std::map<string, PedRelationship> xmap = {
            { "Hate", PedRelationship::Hate },
            { "Like", PedRelationship::Like },
            { "Dislike", PedRelationship::Dislike },
            { "Respect", PedRelationship::Respect },
            { "Threat", PedRelationship::Threat },
            { "Avoid", PedRelationship::Avoid },
        };
        return xmap;
    }
};

//
struct ped_traits : public data_traits
{
    static const bool has_sections      = false;
    static const bool per_line_section  = false;

    struct dtraits : modloader::dtraits::SaOpenOr3VcLoadFileDetour
    {
        static const char* what() { return "ped relationship data"; }
    };

    using detour_type = modloader::SaOpenOr3VcLoadFileDetour<0x608B45, dtraits>;

    using key_type      = std::pair<size_t, PedRelationship>;
    using value_type    = data_slice<either< std::tuple<PedRelationship, set<string>>, std::tuple<string, VC3Only<pack<real_t, 5>>> >>;

    // key_from_value
    struct key_from_value_visitor : gta3::data_section_visitor<key_type>
    {
        ped_traits& traits;
        key_from_value_visitor(ped_traits& traits) : traits(traits) {}

        key_type operator()(const std::tuple<PedRelationship, set<string>>& tuple) const
        {
            return key_type(traits.pedtype, get<0>(tuple));
        }

        key_type operator()(const std::tuple<string, VC3Only<pack<real_t, 5>>>& tuple) const
        {
            traits.pedtype = modloader::hash(get<0>(tuple));
            return key_type(traits.pedtype, PedRelationship::None);
        }

        key_type operator()(const either_blank& slice) const
        { throw std::invalid_argument("blank type"); }
    };

    key_type key_from_value(const value_type& value)
    {
        return get<0>(value).apply_visitor(key_from_value_visitor(*this));
    }

    public:

        size_t pedtype = 0;   // Working ped type hash

        template<class Archive>
        void serialize(Archive& archive)
        { archive(this->pedtype); }
};

using ped_store = gta3::data_store<ped_traits, std::map<
                        ped_traits::key_type, ped_traits::value_type
                        >>;

static auto xinit = initializer([](DataPlugin* plugin_ptr)
{
    auto ReloadPedRelationship = [] {}; // refreshing ped relationship during gameplay might break save game, don't do it at all
    plugin_ptr->AddMerger<ped_store>("ped.dat", true, false, false, reinstall_since_load, gdir_refresh(ReloadPedRelationship));
});


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ObservableCollectionExample.Models
{
    public class Icon
    {
        public string IconPath { get; set; }
    }
}


text:
ACCEPTED

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
null

#### Original name
Angelica citriodora Hance

### Remarks
null


text:
import Vue from 'vue'

export type MouseHandler = (e: MouseEvent | TouchEvent) => any

export type MouseEvents = {
  [event: string]: {
    event: string
    passive?: boolean
    capture?: boolean
    once?: boolean
    stop?: boolean
    prevent?: boolean
    button?: number
    result?: any
  }
}

export type MouseEventsMap = {
  [event: string]: MouseHandler | MouseHandler[]
}

export default Vue.extend({
  name: 'mouse',

  methods: {
    getDefaultMouseEventHandlers (suffix: string, getEvent: MouseHandler): MouseEventsMap {
      return this.getMouseEventHandlers({
        ['click' + suffix]: { event: 'click' },
        ['contextmenu' + suffix]: { event: 'contextmenu', prevent: true, result: false },
        ['mousedown' + suffix]: { event: 'mousedown' },
        ['mousemove' + suffix]: { event: 'mousemove' },
        ['mouseup' + suffix]: { event: 'mouseup' },
        ['mouseenter' + suffix]: { event: 'mouseenter' },
        ['mouseleave' + suffix]: { event: 'mouseleave' },
        ['touchstart' + suffix]: { event: 'touchstart' },
        ['touchmove' + suffix]: { event: 'touchmove' },
        ['touchend' + suffix]: { event: 'touchend' }
      }, getEvent)
    },
    getMouseEventHandlers (events: MouseEvents, getEvent: MouseHandler): MouseEventsMap {
      const on: MouseEventsMap = {}

      for (const event in events) {
        const eventOptions = events[event]

        if (!this.$listeners[event]) continue

        // TODO somehow pull in modifiers

        const prefix = eventOptions.passive ? '&' : ((eventOptions.once ? '~' : '') + (eventOptions.capture ? '!' : ''))
        const key = prefix + eventOptions.event

        const handler: MouseHandler = e => {
          const mouseEvent: MouseEvent = e as MouseEvent
          if (eventOptions.button === undefined || (mouseEvent.buttons > 0 && mouseEvent.button === eventOptions.button)) {
            if (eventOptions.prevent) {
              e.preventDefault()
            }
            if (eventOptions.stop) {
              e.stopPropagation()
            }
            this.$emit(event, getEvent(e))
          }

          return eventOptions.result
        }

        if (key in on) {
          if (Array.isArray(on[key])) {
            (on[key] as MouseHandler[]).push(handler)
          } else {
            on[key] = [on[key], handler] as MouseHandler[]
          }
        } else {
          on[key] = handler
        }
      }

      return on
    }
  }
})


text:
package joshie.enchiridion.gui.book;

import joshie.enchiridion.api.gui.IDrawHelper;
import joshie.enchiridion.api.recipe.IItemStack;
import joshie.enchiridion.helpers.ClientStackHelper;
import joshie.enchiridion.util.PenguinFont;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Mouse;

import javax.annotation.Nonnull;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class GuiBase extends GuiScreen implements IDrawHelper {
    public static final GuiBase INSTANCE = new GuiBase();
    protected final int xSize = 430;
    protected final int ySize = 217;
    protected ScaledResolution res;

    public final List<String> TOOLTIP = new ArrayList<>();
    public int mouseX = 0;
    public int mouseY = 0;
    public int x;
    public int y;
    private int renderX;
    private int renderY;
    private double renderWidth;
    private double renderHeight;
    private float renderSize;

    protected GuiBase() {
    }

    @Override
    public void drawScreen(int x2, int y2, float partialTicks) {
        x = (width - xSize) / 2;
        y = (height - ySize) / 2;
        res = new ScaledResolution(mc);
        TOOLTIP.clear();
    }

    public ScaledResolution getRes() {
        return res;
    }

    @Override
    public void handleMouseInput() throws IOException {
        int x = Mouse.getEventX() * width / mc.displayWidth;
        int y = height - Mouse.getEventY() * height / mc.displayHeight - 1;

        mouseX = x - (width - xSize) / 2;
        mouseY = y - (height - ySize) / 2;
        super.handleMouseInput(); //Call the super
    }

    @Override
    public void setRenderData(int xPos, int yPos, double width, double height, float size) {
        renderX = xPos;
        renderY = yPos;
        renderWidth = width;
        renderHeight = height;
        renderSize = size;
    }

    private int getLeft(double x) {
        return (int) (renderX + ((x / 150D) * renderWidth));
    }

    private int getTop(double y) {
        return (int) (renderY + ((y / 100D) * renderHeight));
    }

    @Override
    public boolean isMouseOverIItemStack(IItemStack stack) {
        if (stack == null || stack.getItemStack().isEmpty()) return false;
        int left = getLeft(stack.getX());
        int top = getTop(stack.getY());
        int scaled = (int) (16 * stack.getScale() * renderSize);
        int right = left + scaled;
        int bottom = top + scaled;
        return mouseX >= left && mouseX <= right && mouseY >= top && mouseY <= bottom;
    }

    @Override
    public boolean isMouseOverArea(double x2, double y2, int width, int height, float scale) {
        int left = getLeft(x2);
        int top = getTop(y2);
        int scaledX = (int) (width * scale * renderSize);
        int scaledY = (int) (height * scale * renderSize);
        int right = left + scaledX;
        int bottom = top + scaledY;
        return mouseX >= left && mouseX <= right && mouseY >= top && mouseY <= bottom;
    }

    @Override
    public void drawIItemStack(IItemStack stack) {
        stack.onDisplayTick(); //Update the display ticker
        drawStack(stack.getItemStack(), getLeft(stack.getX()), getTop(stack.getY()), renderSize * stack.getScale());
    }

    @Override
    public void drawTexturedRectangle(double left, double top, int u, int v, int w, int h, float scale) {
        float size = renderSize * scale;
        int x2 = (int) Math.floor(((x + getLeft(left)) / size));
        int y2 = (int) Math.floor(((y + getTop(top)) / size));

        GlStateManager.pushMatrix();
        GlStateManager.enableBlend();
        GlStateManager.color(1F, 1F, 1F, 1F);
        GlStateManager.enableAlpha();
        GlStateManager.scale(size, size, 1.0F);
        drawTexturedModalRect(x2, y2, u, v, w, h);
        GlStateManager.disableBlend();
        GlStateManager.popMatrix();
    }

    @Override
    public void drawTexturedReversedRectangle(double left, double top, int u, int v, int w, int h, float scale) {
        float size = renderSize * scale;
        int x2 = (int) Math.floor(((x + getLeft(left)) / size)) - w;
        int y2 = (int) Math.floor(((y + getTop(top)) / size)) - h;

        GlStateManager.pushMatrix();
        GlStateManager.enableBlend();
        GlStateManager.color(1F, 1F, 1F, 1F);
        GlStateManager.enableAlpha();
        GlStateManager.scale(size, size, 1.0F);
        drawTexturedModalRect(x2, y2, u, v, w, h);
        GlStateManager.disableBlend();
        GlStateManager.popMatrix();
    }

    @Override
    public void drawSplitScaledString(String text, int xPos, int yPos, int wrap, int color, float scale) {
        GlStateManager.pushMatrix();
        GlStateManager.scale(scale, scale, scale);
        PenguinFont.INSTANCE.drawSplitString(text, (int) ((x + xPos) / scale), (int) ((y + yPos) / scale), wrap, color);
        GlStateManager.popMatrix();
    }

    @Override
    public void drawRectangle(int left, int top, int right, int bottom, int colorI) {
        drawRect(x + left, y + top, x + right, y + bottom, colorI);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    }

    @Override
    public void drawLine(int left, int top, int right, int bottom, int thickness, int color) {
        //Fix these numbers
        left += x;
        top += y;
        right += x;
        bottom += y;

        float f3 = (float) (color >> 24 & 255) / 255.0F;
        float f = (float) (color >> 16 & 255) / 255.0F;
        float f1 = (float) (color >> 8 & 255) / 255.0F;
        float f2 = (float) (color & 255) / 255.0F;
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder buffer = tessellator.getBuffer();
        GlStateManager.enableBlend();
        GlStateManager.disableTexture2D();
        GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
        GlStateManager.color(f, f1, f2, f3);

        int posX;
        if (right > left) {
            posX = thickness;
        } else {
            posX = -thickness;
        }

        int posY;
        if (bottom > top) {
            posY = thickness;
        } else {
            posY = -thickness;
        }

        buffer.begin(7, DefaultVertexFormats.POSITION);
        buffer.pos((double) left, (double) top + posX, 0.0D).endVertex();
        buffer.pos((double) right, (double) bottom + posX, 0.0D).endVertex();
        buffer.pos((double) right + posY, (double) bottom, 0.0D).endVertex();
        buffer.pos((double) left + posY, (double) top, 0.0D).endVertex();
        tessellator.draw();

        buffer.begin(7, DefaultVertexFormats.POSITION_COLOR);
        buffer.pos((double) left, (double) top, 0.0D).color(f, f1, f2, f3).endVertex();
        buffer.pos((double) left + 5, (double) top, 0.0D).color(f, f1, f2, f3).endVertex();
        buffer.pos((double) left + 5, (double) top + 5, 0.0D).color(f, f1, f2, f3).endVertex();
        buffer.pos((double) left, (double) top + 5, 0.0D).color(f, f1, f2, f3).endVertex();
        tessellator.draw();

        GlStateManager.enableTexture2D();
        GlStateManager.disableBlend();
    }

    @Override
    public void drawBorderedRectangle(int left, int top, int right, int bottom, int colorI, int colorB) {
        drawRect(x + left, y + top, x + right, y + bottom, colorI);
        drawRect(x + left, y + top, x + right, y + top + 1, colorB);
        drawRect(x + left, y + bottom - 1, x + right, y + bottom, colorB);
        drawRect(x + left, y + top, x + left + 1, y + bottom, colorB);
        drawRect(x + right - 1, y + top, x + right, y + bottom, colorB);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    }

    @Override
    public void drawStack(@Nonnull ItemStack stack, int left, int top, float size) {
        if (stack.isEmpty()) return; //Don't draw stacks that don't exist
        int x2 = (int) Math.floor(((x + left) / size));
        int y2 = (int) Math.floor(((y + top) / size));
        ClientStackHelper.drawStack(stack, x2, y2, size);
    }

    @Override
    public void drawResource(ResourceLocation resource, int left, int top, int width, int height, float scaleX, float scaleY) {
        GlStateManager.pushMatrix();
        GlStateManager.enableBlend();
        GlStateManager.color(1F, 1F, 1F);
        mc.getTextureManager().bindTexture(resource);
        GlStateManager.scale(scaleX, scaleY, 1.0F);
        drawTexturedModalRect((int) ((x + left) / scaleX), (int) ((y + top) / scaleY), 0, 0, width, height);
        GlStateManager.disableBlend();
        GlStateManager.popMatrix();
    }

    @Override
    public void drawImage(ResourceLocation resource, int left, int top, int right, int bottom) {
        if (resource == null) {
            return; //DON'T YOU DARE RENDER BROKEN STUFF!!!
        }

        GlStateManager.pushMatrix();
        GlStateManager.enableBlend();
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder buffer = tessellator.getBuffer();
        Minecraft.getMinecraft().getTextureManager().bindTexture(resource);
        buffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        buffer.pos((double) (x + left), (double) (y + bottom), (double) zLevel).tex(0, 1).color(1F, 1F, 1F, 1F).endVertex();
        buffer.pos((double) (x + right), (double) (y + bottom), (double) zLevel).tex(1, 1).color(1F, 1F, 1F, 1F).endVertex();
        buffer.pos((double) (x + right), (double) (y + top), (double) zLevel).tex(1, 0).color(1F, 1F, 1F, 1F).endVertex();
        buffer.pos((double) (x + left), (double) (y + top), (double) zLevel).tex(0, 0).color(1F, 1F, 1F, 1F).endVertex();
        tessellator.draw();
        GlStateManager.disableBlend();
        GlStateManager.popMatrix();
    }

    @Override //From vanilla, switching to my font renderer though
    protected void drawHoveringText(List<String> textLines, int x, int y, @Nonnull FontRenderer font) {
        if (!textLines.isEmpty()) {
            GlStateManager.disableRescaleNormal();
            RenderHelper.disableStandardItemLighting();
            GlStateManager.disableLighting();
            GlStateManager.disableDepth();
            int i = 0;

            for (String s : textLines) {
                int j = PenguinFont.INSTANCE.getStringWidth(s);

                if (j > i) {
                    i = j;
                }
            }

            int l1 = x + 12;
            int i2 = y - 12;
            int k = 8;

            if (textLines.size() > 1) {
                k += 2 + (textLines.size() - 1) * 10;
            }

            if (l1 + i > this.width) {
                l1 -= 28 + i;
            }

            if (i2 + k + 6 > this.height) {
                i2 = this.height - k - 6;
            }

            this.zLevel = 300.0F;
            this.itemRender.zLevel = 300.0F;
            int l = 0xCC312921;
            this.drawGradientRect(l1 - 3, i2 - 4, l1 + i + 3, i2 - 3, l, l);
            this.drawGradientRect(l1 - 3, i2 + k + 3, l1 + i + 3, i2 + k + 4, l, l);
            this.drawGradientRect(l1 - 3, i2 - 3, l1 + i + 3, i2 + k + 3, l, l);
            this.drawGradientRect(l1 - 4, i2 - 3, l1 - 3, i2 + k + 3, l, l);
            this.drawGradientRect(l1 + i + 3, i2 - 3, l1 + i + 4, i2 + k + 3, l, l);
            int i1 = 0xFF191511;
            int j1 = (i1 & 16711422) >> 1 | i1 & -16777216;
            this.drawGradientRect(l1 - 3, i2 - 3 + 1, l1 - 3 + 1, i2 + k + 3 - 1, i1, j1);
            this.drawGradientRect(l1 + i + 2, i2 - 3 + 1, l1 + i + 3, i2 + k + 3 - 1, i1, j1);
            this.drawGradientRect(l1 - 3, i2 - 3, l1 + i + 3, i2 - 3 + 1, i1, i1);
            this.drawGradientRect(l1 - 3, i2 + k + 2, l1 + i + 3, i2 + k + 3, j1, j1);

            for (int k1 = 0; k1 < textLines.size(); ++k1) {
                String s1 = textLines.get(k1);
                PenguinFont.INSTANCE.drawStringWithShadow(s1, (float) l1, (float) i2, -1);

                if (k1 == 0) {
                    i2 += 2;
                }

                i2 += 10;
            }

            this.zLevel = 0.0F;
            this.itemRender.zLevel = 0.0F;
            GlStateManager.enableLighting();
            GlStateManager.enableDepth();
            RenderHelper.enableStandardItemLighting();
            GlStateManager.enableRescaleNormal();
        }
    }
}


text:
module OpenFlashChart

  class Line < LineBase
    def initialize args={}
      @type = "line"
      super
    end
  end

end


text:
// This file is part of Indico.
// Copyright (C) 2002 - 2022 CERN
//
// Indico is free software; you can redistribute it and/or
// modify it under the terms of the MIT License; see the
// LICENSE file for more details.

/**
 * Creates a watch value and binds it to the source.
 * @param {Object} source
 * @param {Function} template
 * @return {WatchValue}
 */
function $V(source, template) {
  return bind.toAccessor(new WatchValue(), source, template);
}

/**
 * Observable value.
 */
type(
  'WatchValue',
  ['WatchAccessor'],
  {},
  /**
   * Initializes a new watch value with the given value.
   * @param {Object} value
   */
  function(value) {
    var valueObservers = commands();
    this.WatchAccessor(
      function() {
        return value;
      },
      function(newValue) {
        if (!equals(value, newValue)) {
          var oldValue = value;
          value = newValue;
          valueObservers(newValue, oldValue);
        }
      },
      valueObservers.attach,
      function(observer) {
        return observer(value, value);
      }
    );
  }
);

type(
  'WatchPair',
  ['WatchValue'],
  {
    key: null,
  },
  function(key, value) {
    this.key = key;
    this.WatchValue(value);
  }
);


text:
{-# LANGUAGE GADTs               #-}
{-# LANGUAGE ImpredicativeTypes  #-}
{-# LANGUAGE PatternGuards       #-}
{-# LANGUAGE QuasiQuotes         #-}
{-# LANGUAGE ScopedTypeVariables #-}
-- |
-- Module      : Data.Array.Accelerate.CUDA.CodeGen.Mapping
-- Copyright   : [2008..2014] Manuel M T Chakravarty, Gabriele Keller
--               [2009..2014] Trevor L. McDonell
-- License     : BSD3
--
-- Maintainer  : Trevor L. McDonell <tmcdonell@cse.unsw.edu.au>
-- Stability   : experimental
-- Portability : non-portable (GHC extensions)
--

module Data.Array.Accelerate.CUDA.CodeGen.Mapping (

  mkMap,

) where

import Language.C.Quote.CUDA
import Foreign.CUDA.Analysis.Device

import Data.Array.Accelerate.Array.Sugar                ( Array, Shape, Elt )
import Data.Array.Accelerate.CUDA.AST
import Data.Array.Accelerate.CUDA.CodeGen.Base

-- Apply the given unary function to each element of an array. Each thread
-- processes multiple elements, striding the array by the grid size.
--
-- map :: (Shape sh, Elt a, Elt b)
--     => (Exp a -> Exp b)
--     -> Acc (Array sh a)
--     -> Acc (Array sh b)
--
mkMap :: forall aenv sh a b. (Shape sh, Elt a, Elt b)
      => DeviceProperties
      -> Gamma aenv
      -> CUFun1 aenv (a -> b)
      -> CUDelayedAcc aenv sh a
      -> [CUTranslSkel aenv (Array sh b)]
mkMap dev aenv fun arr
  | CUFun1 dce f                 <- fun
  , CUDelayed _ _ (CUFun1 _ get) <- arr
  = return
  $ CUTranslSkel "map" [cunit|

    $esc:("#include <accelerate_cuda.h>")
    $edecls:texIn

    extern "C" __global__ void
    map
    (
        $params:argIn,
        $params:argOut
    )
    {
        const int shapeSize     = $exp:(csize shOut);
        const int gridSize      = $exp:(gridSize dev);
              int ix;

        for ( ix =  $exp:(threadIdx dev)
            ; ix <  shapeSize
            ; ix += gridSize )
        {
            $items:(dce x       .=. get ix)
            $items:(setOut "ix" .=. f x)
        }
    }
  |]
  where
    (texIn, argIn)              = environment dev aenv
    (argOut, shOut, setOut)     = writeArray "Out" (undefined :: Array sh b)
    (x, _, _)                   = locals "x" (undefined :: a)
    ix                          = [cvar "ix"]