text:
//
// BodyPartCollection.cs
//
// Author: Jeffrey Stedfast <jeff@xamarin.com>
//
// Copyright (c) 2013-2015 Xamarin Inc. (www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

using MimeKit.Utils;

namespace MailKit {
	/// <summary>
	/// A <see cref="BodyPart"/> collection.
	/// </summary>
	/// <remarks>
	/// A <see cref="BodyPart"/> collection.
	/// </remarks>
	public class BodyPartCollection : ICollection<BodyPart>
	{
		readonly List<BodyPart> collection = new List<BodyPart> ();

		/// <summary>
		/// Initializes a new instance of the <see cref="MailKit.BodyPartCollection"/> class.
		/// </summary>
		/// <remarks>
		/// Creates a new <see cref="MailKit.BodyPartCollection"/>.
		/// </remarks>
		public BodyPartCollection ()
		{
		}

		/// <summary>
		/// Get the number of body parts in the collection.
		/// </summary>
		/// <remarks>
		/// Gets the number of body parts in the collection.
		/// </remarks>
		/// <value>The count.</value>
		public int Count {
			get { return collection.Count; }
		}

		/// <summary>
		/// Get whether or not this body part collection is read only.
		/// </summary>
		/// <remarks>
		/// Gets whether or not this body part collection is read only.
		/// </remarks>
		/// <value><c>true</c> if this collection is read only; otherwise, <c>false</c>.</value>
		public bool IsReadOnly {
			get { return false; }
		}

		/// <summary>
		/// Add the specified body part to the collection.
		/// </summary>
		/// <remarks>
		/// Adds the specified body part to the collection.
		/// </remarks>
		/// <param name="part">The body part.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <paramref name="part"/> is <c>null</c>.
		/// </exception>
		public void Add (BodyPart part)
		{
			if (part == null)
				throw new ArgumentNullException ("part");

			collection.Add (part);
		}

		/// <summary>
		/// Clears the body part collection.
		/// </summary>
		/// <remarks>
		/// Removes all of the body parts from the collection.
		/// </remarks>
		public void Clear ()
		{
			collection.Clear ();
		}

		/// <summary>
		/// Checks if the collection contains the specified body part.
		/// </summary>
		/// <remarks>
		/// Determines whether or not the collection contains the specified body part.
		/// </remarks>
		/// <returns><value>true</value> if the specified body part exists; otherwise <value>false</value>.</returns>
		/// <param name="part">The body part.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <paramref name="part"/> is <c>null</c>.
		/// </exception>
		public bool Contains (BodyPart part)
		{
			if (part == null)
				throw new ArgumentNullException ("part");

			return collection.Contains (part);
		}

		/// <summary>
		/// Copies all of the body parts in the collection to the specified array.
		/// </summary>
		/// <remarks>
		/// Copies all of the body parts within the collection into the array,
		/// starting at the specified array index.
		/// </remarks>
		/// <param name="array">The array.</param>
		/// <param name="arrayIndex">The array index.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <paramref name="array"/> is <c>null</c>.
		/// </exception>
		/// <exception cref="System.ArgumentOutOfRangeException">
		/// <paramref name="arrayIndex"/> is out of range.
		/// </exception>
		public void CopyTo (BodyPart[] array, int arrayIndex)
		{
			if (array == null)
				throw new ArgumentNullException ("array");

			if (arrayIndex < 0 || arrayIndex + Count > array.Length)
				throw new ArgumentOutOfRangeException ("arrayIndex");

			collection.CopyTo (array, arrayIndex);
		}

		/// <summary>
		/// Removes the specified body part.
		/// </summary>
		/// <remarks>
		/// Removes the specified body part.
		/// </remarks>
		/// <returns><value>true</value> if the body part was removed; otherwise <value>false</value>.</returns>
		/// <param name="part">The body part.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <paramref name="part"/> is <c>null</c>.
		/// </exception>
		public bool Remove (BodyPart part)
		{
			if (part == null)
				throw new ArgumentNullException ("part");

			return collection.Remove (part);
		}

		/// <summary>
		/// Get the body part at the specified index.
		/// </summary>
		/// <remarks>
		/// Gets the body part at the specified index.
		/// </remarks>
		/// <value>The body part at the specified index.</value>
		/// <param name="index">The index.</param>
		/// <exception cref="System.ArgumentOutOfRangeException">
		/// <paramref name="index"/> is out of range.
		/// </exception>
		public BodyPart this [int index] {
			get {
				if (index < 0 || index >= collection.Count)
					throw new ArgumentOutOfRangeException ("index");

				return collection[index];
			}
		}

		/// <summary>
		/// Gets the index of the body part matching the specified URI.
		/// </summary>
		/// <remarks>
		/// <para>Finds the index of the body part matching the specified URI, if it exists.</para>
		/// <para>If the URI scheme is <c>"cid"</c>, then matching is performed based on the Content-Id header
		/// values, otherwise the Content-Location headers are used. If the provided URI is absolute and a child
		/// part's Content-Location is relative, then then the child part's Content-Location URI will be combined
		/// with the value of its Content-Base header, if available, otherwise it will be combined with the
		/// multipart/related part's Content-Base header in order to produce an absolute URI that can be
		/// compared with the provided absolute URI.</para>
		/// </remarks>
		/// <returns>The index of the part matching the specified URI if found; otherwise <c>-1</c>.</returns>
		/// <param name="uri">The URI of the body part.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <paramref name="uri"/> is <c>null</c>.
		/// </exception>
		public int IndexOf (Uri uri)
		{
			if (uri == null)
				throw new ArgumentNullException ("uri");

			bool cid = uri.IsAbsoluteUri && uri.Scheme.ToLowerInvariant () == "cid";

			for (int index = 0; index < Count; index++) {
				var bodyPart = this[index] as BodyPartBasic;

				if (bodyPart == null)
					continue;

				if (uri.IsAbsoluteUri) {
					if (cid) {
						if (!string.IsNullOrEmpty (bodyPart.ContentId)) {
							var id = MimeUtils.EnumerateReferences (bodyPart.ContentId).FirstOrDefault ();

							if (id == uri.AbsolutePath)
								return index;
						}
					} else if (bodyPart.ContentLocation != null) {
						Uri absolute;

						if (!bodyPart.ContentLocation.IsAbsoluteUri)
							continue;

						absolute = bodyPart.ContentLocation;

						if (absolute == uri)
							return index;
					}
				} else if (bodyPart.ContentLocation == uri) {
					return index;
				}
			}

			return -1;
		}

		#region IEnumerable implementation

		/// <summary>
		/// Gets the body part enumerator.
		/// </summary>
		/// <remarks>
		/// Gets the body part enumerator.
		/// </remarks>
		/// <returns>The enumerator.</returns>
		public IEnumerator<BodyPart> GetEnumerator ()
		{
			return collection.GetEnumerator ();
		}

		#endregion

		#region IEnumerable implementation

		/// <summary>
		/// Gets the body part enumerator.
		/// </summary>
		/// <remarks>
		/// Gets the body part enumerator.
		/// </remarks>
		/// <returns>The enumerator.</returns>
		IEnumerator IEnumerable.GetEnumerator ()
		{
			return GetEnumerator ();
		}

		#endregion
	}
}


text:
package com.yutian.entity;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;

/**
 * Parter entity. @author MyEclipse Persistence Tools
 */

public class Parter extends EntityBase implements java.io.Serializable {

	private static final long serialVersionUID = 5979810534926655030L;
	// Fields
	private Integer id;
	private String name;
	private String department;
	private String password;
	private Timestamp createTime;
	private Set<?> terms = new HashSet<Object>(0);

	// Constructors

	/** default constructor */
	public Parter() {
	}

	/** full constructor */
	public Parter(String name, String department, String password,
			Timestamp createTime, Set<?> terms) {
		this.name = name;
		this.department = department;
		this.password = password;
		this.createTime = createTime;
		this.terms = terms;
	}

	// Property accessors

	public Integer getId() {
		return this.id;
	}

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

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDepartment() {
		return this.department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Timestamp getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}

	public Set<?> getTerms() {
		return this.terms;
	}

	public void setTerms(Set<?> terms) {
		this.terms = terms;
	}

}

redpajama_set_name: RedPajamaGithub


text:
require 'spec_helper'

describe TestData::Address do

  it 'return unit number' do
    expect(TestData::Address.unit_no).to be_between(1,20)
  end

  it 'return building number' do
    expect(TestData::Address.building_no).to be_between(1,400)
  end

  it 'return street type' do
    expect(TestData::Address.street_type).to match(/[A-Z][a-z]+/)
  end

  it 'return street name' do
    expect(TestData::Address.street_name).to match(/[A-Z][a-z]+ [A-Z][a-z]+/)
  end

  it 'return street address' do
    expect(TestData::Address.street_address).to match(/\d{1,3} [A-Z][a-z]+ [A-Z][a-z]+/)
  end

  it 'return suburb' do
    expect(TestData::Address.suburb).to match(/[A-Z][a-z]+/)
  end

  it 'return state' do
    expect(TestData::Address.state).to match(/[A-Z][a-z]+/)
  end

  it 'return city' do
    expect(TestData::Address.city).to match(/[A-Z][a-z]+/)
  end

  it 'return country' do
    expect(TestData::Address.country).to match(/[A-Z][a-z]+/)
  end

  it 'return post code' do
    expect(TestData::Address.post_code).to be_between(3000,5000)
  end

  it 'return zip code' do
    expect(TestData::Address.zip_code).to be_between(3000,5000)
  end

  it 'return zip' do
    expect(TestData::Address.zip).to be_between(3000,5000)
  end

  it 'return full address' do
    expect(TestData::Address.full_address).to match(/\d{1,3} [A-Z][a-z]+ [A-Z][a-z]+, [A-Z][a-z]+, [A-Z][a-z]+, [A-Z][a-z]+ - \d{4}, [A-Z][a-z]+/)
  end

end


text:
template<typename T>
class threadsafe_queue
{
private:
  mutable std::mutex m;
  std::queue<T> data_queue;
  std::condition_variable data_cond;
public:
  threadsafe_queue() {}

  void push(T new_value)
  {
    std::lock_guard<std::mutex> lock(m);
    data_queue.push(std::move(new_value));
    data_cond.notify_one();
  }

  void wait_and_pop(T& value)
  {
    std::lock_guard<std::mutex> lock(m);
    data_cond.wait(lock, [this]{return !data_queue.empty();});
    value = std::move(data_queue.front());
    data_queue.pop();
  }

  std::shared_ptr<T> wait_and_pop()
  {
    std::lock_guard<std::mutex> lock(m);
    data_cond.wait(lock, [this]{return !data_queue.empty();});
    std::shared_ptr<T> const res =
      std::make_shared<T>(std::move(data_queue.front()));
    data_queue.pop();
    return res;
  }

  bool try_pop(T& value)
  {
    std::lock_guard<std::mutex> lock(m);
    if (data_queue.empty())
      return false;
    value = std::move(data_queue.front());
    data_queue.pop();
    return true;
  }

  std::shared_ptr<T> try_pop()
  {
    std::lock_guard<std::mutex> lock(m);
    if (data_queue.empty())
      return std::make_shared<T>();
    std::shared_ptr<T> const res =
      std::make_shared<T>(std::move(data_queue.front()));
    data_queue.pop();
    return res;
  }

  bool empty() const
  {
    std::lock_guard<std::mutex> lock(m);
    return data_queue.empty();
  }
};

template<typename T>
class threadsafe_queue_opt
{
private:
  mutable std::mutex m;
  std::queue<std::shared_ptr<T> > data_queue;
  std::condition_variable data_cond;
public:
  threadsafe_queue_opt() {}

  void push(T new_value)
  {
    std::shared_ptr<T> data(
        std::make_shared<T>(std::move(new_value)));
    std::lock_guard<std::mutex> lock(m);
    data_queue.push(data);
    data_cond.notify_one();
  }

  void wait_and_pop(T& value)
  {
    std::lock_guard<std::mutex> lock(m);
    data_cond.wait(lock, [this]{return !data_queue.empty();});
    value = std::move(*data_queue.front());
    data_queue.pop();
  }

  std::shared_ptr<T> wait_and_pop()
  {
    std::lock_guard<std::mutex> lock(m);
    data_cond.wait(lock, [this]{return !data_queue.empty();});
    std::shared_ptr<T> res = data_queue.front();
    data_queue.pop();
    return res;
  }

  bool try_pop(T& value)
  {
    std::lock_guard<std::mutex> lock(m);
    if (data_queue.empty())
      return false;
    value = std::move(*data_queue.front());
    data_queue.pop();
    return true;
  }

  std::shared_ptr<T> try_pop()
  {
    std::lock_guard<std::mutex> lock(m);
    if (data_queue.empty())
      return std::make_shared<T>();
    std::shared_ptr<T> res = data_queue.front();
    data_queue.pop();
    return res;
  }

  bool empty() const
  {
    std::lock_guard<std::mutex> lock(m);
    return data_queue.empty();
  }
};

int main()
{
  threadsafe_queue<int> q;
  assert(q.empty() == true);

  threadsafe_queue_opt<int> qt;
  assert(qt.empty() == true);

  return 0;
}


text:
<?php

namespace Kachkaev\AssetsVersionBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;

class KachkaevAssetsVersionExtension extends Extension
{
    /**
     * {@inheritDoc}
     */
    public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration, $configs);

        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('config.yml');

        if (null !== $config['file_path']) {
            $container->setParameter('kachkaev_assets_version.file_path', $config['file_path']);
        }
        if (null !== $config['parameter_name']) {
            $container->setParameter('kachkaev_assets_version.parameter_name', $config['parameter_name']);
        }
        if (null !== $config['manager']) {
            $container->setParameter('kachkaev_assets_version.manager.class', $config['manager']);
        }
    }
}


text:
using System;
using System.Collections.Generic;
using System.Globalization;
using Content.Client.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Localization;
using Robust.Shared.Maths;

namespace Content.Client.Atmos.UI
{
    /// <summary>
    /// Client-side UI used to control a gas mixer.
    /// </summary>
    [GenerateTypedNameReferences]
    public sealed partial class GasMixerWindow : DefaultWindow
    {
        public bool MixerStatus = true;

        public event Action? ToggleStatusButtonPressed;
        public event Action<string>? MixerOutputPressureChanged;
        public event Action<string>? MixerNodePercentageChanged;

        public bool NodeOneLastEdited = true;

        public GasMixerWindow()
        {
            RobustXamlLoader.Load(this);

            ToggleStatusButton.OnPressed += _ => SetMixerStatus(!MixerStatus);
            ToggleStatusButton.OnPressed += _ => ToggleStatusButtonPressed?.Invoke();

            MixerPressureOutputInput.OnTextChanged += _ => SetOutputPressureButton.Disabled = false;
            SetOutputPressureButton.OnPressed += _ =>
            {
                MixerOutputPressureChanged?.Invoke(MixerPressureOutputInput.Text ??= "");
                SetOutputPressureButton.Disabled = true;
            };

            SetMaxPressureButton.OnPressed += _ =>
            {
                MixerPressureOutputInput.Text = Atmospherics.MaxOutputPressure.ToString(CultureInfo.InvariantCulture);
                SetOutputPressureButton.Disabled = false;
            };

            MixerNodeOneInput.OnTextChanged += _ =>
            {
                SetMixerPercentageButton.Disabled = false;
                NodeOneLastEdited = true;
            };
            MixerNodeTwoInput.OnTextChanged += _ =>
            {
                SetMixerPercentageButton.Disabled = false;
                NodeOneLastEdited = false;
            };

            SetMixerPercentageButton.OnPressed += _ =>
            {
                MixerNodePercentageChanged?.Invoke(NodeOneLastEdited ? MixerNodeOneInput.Text ??= "" : MixerNodeTwoInput.Text ??= "");
                SetMixerPercentageButton.Disabled = true;
            };
        }

        public void SetOutputPressure(float pressure)
        {
            MixerPressureOutputInput.Text = pressure.ToString(CultureInfo.InvariantCulture);
        }

        public void SetNodePercentages(float nodeOne)
        {
            nodeOne *= 100.0f;
            MixerNodeOneInput.Text = nodeOne.ToString(CultureInfo.InvariantCulture);

            float nodeTwo = 100.0f - nodeOne;
            MixerNodeTwoInput.Text = nodeTwo.ToString(CultureInfo.InvariantCulture);
        }

        public void SetMixerStatus(bool enabled)
        {
            MixerStatus = enabled;
            if (enabled)
            {
                ToggleStatusButton.Text = Loc.GetString("comp-gas-mixer-ui-status-enabled");
            }
            else
            {
                ToggleStatusButton.Text = Loc.GetString("comp-gas-mixer-ui-status-disabled");
            }
        }
    }
}


text:
package org.eclipse.bpmn2;

/**
 *
 * A representation of the model object 'Alfresco Script Task'.
 *
 *
 *

 * The following features are supported:
 *

 *
{@link org.eclipse.bpmn2.AlfrescoScriptTask#getScript Script}

 *

 *

 *
 * @see org.eclipse.bpmn2.Bpmn2Package#getAlfrescoScriptTask()
 * @model
 * @generated
 */
public interface AlfrescoScriptTask extends Task, AlfrescoScriptBase {
	/**
	 * Returns the value of the 'Script' attribute.
	 *
	 *

	 * If the meaning of the 'Script' attribute isn't clear,
	 * there really should be more of a description here...
	 *

	 *
	 * @return the value of the 'Script' attribute.
	 * @see #setScript(String)
	 * @see org.eclipse.bpmn2.Bpmn2Package#getAlfrescoScriptTask_Script()
	 * @model
	 * @generated
	 */
	String getScript();

	/**
	 * Sets the value of the '{@link org.eclipse.bpmn2.AlfrescoScriptTask#getScript Script}' attribute.
	 *
	 *
	 * @param value the new value of the 'Script' attribute.
	 * @see #getScript()
	 * @generated
	 */
	void setScript(String value);

} // AlfrescoScriptTask


text:
include FetcherUtils

class InstagramWorker < BaseWorker
  @queue = :instagram_job_queue
  def self.perform()
    FetcherUtils.update_grams
    logger.info('Instagrams updated')
  end
end


text:
/* jshint laxcomma:true, sub:true */

var path = require('path')
    , fs = require('fs')
    , common = require('./common')
    , events = require('../../events')
    , xml_helpers = require(path.join(__dirname, '..', '..', 'util', 'xml-helpers'))
    ;

module.exports = {
    www_dir: function(project_dir) {
        return path.join(project_dir, 'www');
    },
    package_name:function(project_dir) {
        // preferred location if cordova >= 3.4
        var preferred_path = path.join(project_dir, 'config.xml');
        var config_path;

        if (!fs.existsSync(preferred_path)) {
            // older location
            var old_config_path = path.join(module.exports.www_dir(project_dir), 'config.xml');
            if (!fs.existsSync(old_config_path)) {
                // output newer location and fail reading
                config_path = preferred_path;
                events.emit('verbose', 'unable to find '+config_path);
            } else {
                config_path = old_config_path;
            }
        } else {
            config_path = preferred_path;
        }
        var widget_doc = xml_helpers.parseElementtreeSync(config_path);
        return widget_doc._root.attrib['id'];
    },
    'source-file':{
        install:function(obj, plugin_dir, project_dir, plugin_id, options) {
            var dest = path.join(obj.targetDir, path.basename(obj.src));
            common.copyFile(plugin_dir, obj.src, project_dir, dest);
        },
        uninstall:function(obj, project_dir, plugin_id, options) {
            var dest = path.join(obj.targetDir, path.basename(obj.src));
            common.removeFile(project_dir, dest);
        }
    },
    'header-file': {
        install:function(obj, plugin_dir, project_dir, plugin_id, options) {
            events.emit('verbose', 'header-fileinstall is not supported for firefoxos');
        },
        uninstall:function(obj, project_dir, plugin_id, options) {
            events.emit('verbose', 'header-file.uninstall is not supported for firefoxos');
        }
    },
    'resource-file':{
        install:function(obj, plugin_dir, project_dir, plugin_id, options) {
            events.emit('verbose', 'resource-file.install is not supported for firefoxos');
        },
        uninstall:function(obj, project_dir, plugin_id, options) {
            events.emit('verbose', 'resource-file.uninstall is not supported for firefoxos');
        }
    },
    'framework': {
        install:function(obj, plugin_dir, project_dir, plugin_id, options) {
            events.emit('verbose', 'framework.install is not supported for firefoxos');
        },
        uninstall:function(obj, project_dir, plugin_id, options) {
            events.emit('verbose', 'framework.uninstall is not supported for firefoxos');
        }
    },
    'lib-file': {
        install:function(obj, plugin_dir, project_dir, plugin_id, options) {
            events.emit('verbose', 'lib-file.install is not supported for firefoxos');
        },
        uninstall:function(obj, project_dir, plugin_id, options) {
            events.emit('verbose', 'lib-file.uninstall is not supported for firefoxos');
        }
    }
};


text:
'use strict';

module.exports.main = function(event, context, callback) {
    console.log("Inside participation");
    if (event.test) {
        callback(null, {
            test: "success"
        });
        return;
    }
    var response = "",
        count = 0,
        total = 0,
        result = 0,
        userId = event.userId;
    event.messages.forEach(function(message) {
        if (message.user == userId) {
            count++;
        }
        total++;
    });

    result = ((count / total) * 100).toFixed(0);

    if (isNaN(result)) {
      result = 0;
    }

    response = {
        color: "#439FE0",
        pretext: "Participation",
        fields: [{
            title: "Score",
            value: result + "% of the posts in this channel were penned by you."
        }]
    };

    callback(null, response);
};


text:
using System.Numerics;

namespace Nethereum.GSN.Models
{
    public class GetAddrResponse
    {
        public string RelayServerAddress { get; set; }

        public BigInteger MinGasPrice { get; set; }

        public bool Ready { get; set; }

        public string Version { get; set; }
    }
}


text:
<?php

namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Loader;

use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator;
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;

/**
 * @group legacy
 */
class TemplateLocatorTest extends TestCase
{
    public function testLocateATemplate()
    {
        $template = new TemplateReference('bundle', 'controller', 'name', 'format', 'engine');

        $fileLocator = $this->getFileLocator();

        $fileLocator
            ->expects($this->once())
            ->method('locate')
            ->with($template->getPath())
            ->willReturn('/path/to/template')
        ;

        $locator = new TemplateLocator($fileLocator);

        $this->assertEquals('/path/to/template', $locator->locate($template));

        // Assert cache is used as $fileLocator->locate should be called only once
        $this->assertEquals('/path/to/template', $locator->locate($template));
    }

    public function testLocateATemplateFromCacheDir()
    {
        $template = new TemplateReference('bundle', 'controller', 'name', 'format', 'engine');

        $fileLocator = $this->getFileLocator();

        $locator = new TemplateLocator($fileLocator, __DIR__.'/../../Fixtures');

        $this->assertEquals(realpath(__DIR__.'/../../Fixtures/Resources/views/this.is.a.template.format.engine'), $locator->locate($template));
    }

    public function testThrowsExceptionWhenTemplateNotFound()
    {
        $template = new TemplateReference('bundle', 'controller', 'name', 'format', 'engine');

        $fileLocator = $this->getFileLocator();

        $errorMessage = 'FileLocator exception message';

        $fileLocator
            ->expects($this->once())
            ->method('locate')
            ->willThrowException(new \InvalidArgumentException($errorMessage))
        ;

        $locator = new TemplateLocator($fileLocator);

        try {
            $locator->locate($template);
            $this->fail('->locate() should throw an exception when the file is not found.');
        } catch (\InvalidArgumentException $e) {
            $this->assertStringContainsString(
                $errorMessage,
                $e->getMessage(),
                'TemplateLocator exception should propagate the FileLocator exception message'
            );
        }
    }

    public function testThrowsAnExceptionWhenTemplateIsNotATemplateReferenceInterface()
    {
        $this->expectException('InvalidArgumentException');
        $locator = new TemplateLocator($this->getFileLocator());
        $locator->locate('template');
    }

    protected function getFileLocator()
    {
        return $this
            ->getMockBuilder('Symfony\Component\Config\FileLocator')
            ->setMethods(['locate'])
            ->setConstructorArgs(['/path/to/fallback'])
            ->getMock()
        ;
    }
}


text:
/* Captive Portal Example

    This example code is in the Public Domain (or CC0 licensed, at your option.)

    Unless required by applicable law or agreed to in writing, this
    software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
    CONDITIONS OF ANY KIND, either express or implied.
*/

#include <sys/param.h>

#include "esp_event.h"
#include "esp_log.h"
#include "esp_mac.h"

#include "nvs_flash.h"
#include "esp_wifi.h"
#include "esp_netif.h"
#include "lwip/inet.h"

#include "esp_http_server.h"
#include "dns_server.h"

#define EXAMPLE_ESP_WIFI_SSID CONFIG_ESP_WIFI_SSID
#define EXAMPLE_ESP_WIFI_PASS CONFIG_ESP_WIFI_PASSWORD
#define EXAMPLE_MAX_STA_CONN CONFIG_ESP_MAX_STA_CONN

extern const char root_start[] asm("_binary_root_html_start");
extern const char root_end[] asm("_binary_root_html_end");

static const char *TAG = "example";

static void wifi_event_handler(void *arg, esp_event_base_t event_base,
                               int32_t event_id, void *event_data)
{
    if (event_id == WIFI_EVENT_AP_STACONNECTED) {
        wifi_event_ap_staconnected_t *event = (wifi_event_ap_staconnected_t *)event_data;
        ESP_LOGI(TAG, "station " MACSTR " join, AID=%d",
                 MAC2STR(event->mac), event->aid);
    } else if (event_id == WIFI_EVENT_AP_STADISCONNECTED) {
        wifi_event_ap_stadisconnected_t *event = (wifi_event_ap_stadisconnected_t *)event_data;
        ESP_LOGI(TAG, "station " MACSTR " leave, AID=%d",
                 MAC2STR(event->mac), event->aid);
    }
}

static void wifi_init_softap(void)
{
    wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
    ESP_ERROR_CHECK(esp_wifi_init(&cfg));

    ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL));

    wifi_config_t wifi_config = {
        .ap = {
            .ssid = EXAMPLE_ESP_WIFI_SSID,
            .ssid_len = strlen(EXAMPLE_ESP_WIFI_SSID),
            .password = EXAMPLE_ESP_WIFI_PASS,
            .max_connection = EXAMPLE_MAX_STA_CONN,
            .authmode = WIFI_AUTH_WPA_WPA2_PSK
        },
    };
    if (strlen(EXAMPLE_ESP_WIFI_PASS) == 0) {
        wifi_config.ap.authmode = WIFI_AUTH_OPEN;
    }

    ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
    ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &wifi_config));
    ESP_ERROR_CHECK(esp_wifi_start());

    esp_netif_ip_info_t ip_info;
    esp_netif_get_ip_info(esp_netif_get_handle_from_ifkey("WIFI_AP_DEF"), &ip_info);

    char ip_addr[16];
    inet_ntoa_r(ip_info.ip.addr, ip_addr, 16);
    ESP_LOGI(TAG, "Set up softAP with IP: %s", ip_addr);

    ESP_LOGI(TAG, "wifi_init_softap finished. SSID:'%s' password:'%s'",
             EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS);
}

// HTTP GET Handler
static esp_err_t root_get_handler(httpd_req_t *req)
{
    const uint32_t root_len = root_end - root_start;

    ESP_LOGI(TAG, "Serve root");
    httpd_resp_set_type(req, "text/html");
    httpd_resp_send(req, root_start, root_len);

    return ESP_OK;
}

static const httpd_uri_t root = {
    .uri = "/",
    .method = HTTP_GET,
    .handler = root_get_handler
};

// HTTP Error (404) Handler - Redirects all requests to the root page
esp_err_t http_404_error_handler(httpd_req_t *req, httpd_err_code_t err)
{
    // Set status
    httpd_resp_set_status(req, "302 Temporary Redirect");
    // Redirect to the "/" root directory
    httpd_resp_set_hdr(req, "Location", "/");
    // iOS requires content in the response to detect a captive portal, simply redirecting is not sufficient.
    httpd_resp_send(req, "Redirect to the captive portal", HTTPD_RESP_USE_STRLEN);

    ESP_LOGI(TAG, "Redirecting to root");
    return ESP_OK;
}

static httpd_handle_t start_webserver(void)
{
    httpd_handle_t server = NULL;
    httpd_config_t config = HTTPD_DEFAULT_CONFIG();
    config.max_open_sockets = 13;
    config.lru_purge_enable = true;

    // Start the httpd server
    ESP_LOGI(TAG, "Starting server on port: '%d'", config.server_port);
    if (httpd_start(&server, &config) == ESP_OK) {
        // Set URI handlers
        ESP_LOGI(TAG, "Registering URI handlers");
        httpd_register_uri_handler(server, &root);
        httpd_register_err_handler(server, HTTPD_404_NOT_FOUND, http_404_error_handler);
    }
    return server;
}

void app_main(void)
{
    /*
        Turn of warnings from HTTP server as redirecting traffic will yield
        lots of invalid requests
    */
    esp_log_level_set("httpd_uri", ESP_LOG_ERROR);
    esp_log_level_set("httpd_txrx", ESP_LOG_ERROR);
    esp_log_level_set("httpd_parse", ESP_LOG_ERROR);

    // Initialize networking stack
    ESP_ERROR_CHECK(esp_netif_init());

    // Create default event loop needed by the  main app
    ESP_ERROR_CHECK(esp_event_loop_create_default());

    // Initialize NVS needed by Wi-Fi
    ESP_ERROR_CHECK(nvs_flash_init());

    // Initialize Wi-Fi including netif with default config
    esp_netif_create_default_wifi_ap();

    // Initialise ESP32 in SoftAP mode
    wifi_init_softap();

    // Start the server for the first time
    start_webserver();

    // Start the DNS server that will redirect all queries to the softAP IP
    start_dns_server();
}


text:
package dataforms.devtool.field.common;

import dataforms.devtool.validator.ClassNameValidator;
import dataforms.field.base.Field;

/**
 * フィールドクラス名フィールドクラス。
 *
 */
public class FieldClassNameField extends SimpleClassNameField {
	/**
	 * autocompleteの例外文字列。
	 */
	private static final String EXCEPTION_PATTERN = "dataforms\\.field\\.sqlfunc";
	/**
	 * フィールドコメント。
	 */
	private static final String COMMENT = "フィールドクラス名";
	/**
	 * コンストラクタ。
	 */
	public FieldClassNameField() {
		this.setBaseClass(Field.class);
		this.setComment(COMMENT);
		this.addExceptionPattern(EXCEPTION_PATTERN);
	}
	/**
	 * コンストラクタ。
	 * @param id フィールドID。
	 */
	public FieldClassNameField(final String id) {
		super(id);
		this.setBaseClass(Field.class);
		this.setComment(COMMENT);
		this.addExceptionPattern(EXCEPTION_PATTERN);
	}

	@Override
	protected void onBind() {
		super.onBind();
		this.addValidator(new ClassNameValidator("Field"));
		this.setAutocomplete(true);
		this.setRelationDataAcquisition(true);
	}
}


text:
title: Object isFrozen
localeTitle: Объект заморожен
---
## Объект заморожен

Вы можете использовать **`Object.isFrozen()`** чтобы выяснить, был ли объект заморожен или нет. Он возвращает **`true`** или **`false`** логическое значение.

#### **СИНТАКСИС**

```javascript
Object.isFrozen(obj)
```

**Например:**

```javascript
var foods = {
    grain : "wheat",
    dairy  : "milk",
    vegetable : "carrot",
    fruit  : "grape"
 };

 var frozenFoods = Object.freeze(foods);

 var areMyFoodsFrozen = Object.isFrozen(frozenFoods);

 \\ returns true
```

Помните, что замороженный объект **не может изменить** свои свойства.

Если вы попытаетесь использовать **`Object.isFrozen()`** для аргумента, отличного от объекта, он вернет `true` .

#### Дополнительная информация:

[MDN Object.isFrozen ()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen)
[MDN Object.freeze ()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)


text:
<?php
namespace Workflow\Controller\Admin;

use Workflow\Controller\AppController;

/**
 * TriggerTypes Controller
 *
 * @property \Workflow\Model\Table\TriggerTypesTable $TriggerTypes
 */
class TriggerTypesController extends AppController
{

    /**
     * Index method
     *
     * @return void
     */
    public function index()
    {
        $this->set('triggerTypes', $this->paginate($this->TriggerTypes));
        $this->set('_serialize', ['triggerTypes']);
    }

    /**
     * View method
     *
     * @param string|null $id Trigger Type id.
     * @return void
     * @throws \Cake\Network\Exception\NotFoundException When record not found.
     */
    public function view($id = null)
    {
        $triggerType = $this->TriggerTypes->get($id, [
            'contain' => []
        ]);
        $this->set('triggerType', $triggerType);
        $this->set('_serialize', ['triggerType']);
    }

    /**
     * Add method
     *
     * @return void Redirects on successful add, renders view otherwise.
     */
    public function add()
    {
        $triggerType = $this->TriggerTypes->newEntity();
        if ($this->request->is('post')) {
            $triggerType = $this->TriggerTypes->patchEntity($triggerType, $this->request->data);
            if ($this->TriggerTypes->save($triggerType)) {
                $this->Flash->success(__('The trigger type has been saved.'));
                return $this->redirect(['action' => 'index']);
            } else {
                $this->Flash->error(__('The trigger type could not be saved. Please, try again.'));
            }
        }
        $this->set(compact('triggerType'));
        $this->set('_serialize', ['triggerType']);
    }

    /**
     * Edit method
     *
     * @param string|null $id Trigger Type id.
     * @return void Redirects on successful edit, renders view otherwise.
     * @throws \Cake\Network\Exception\NotFoundException When record not found.
     */
    public function edit($id = null)
    {
        $triggerType = $this->TriggerTypes->get($id, [
            'contain' => []
        ]);
        if ($this->request->is(['patch', 'post', 'put'])) {
            $triggerType = $this->TriggerTypes->patchEntity($triggerType, $this->request->data);
            if ($this->TriggerTypes->save($triggerType)) {
                $this->Flash->success(__('The trigger type has been saved.'));
                return $this->redirect(['action' => 'index']);
            } else {
                $this->Flash->error(__('The trigger type could not be saved. Please, try again.'));
            }
        }
        $this->set(compact('triggerType'));
        $this->set('_serialize', ['triggerType']);
    }

    /**
     * Delete method
     *
     * @param string|null $id Trigger Type id.
     * @return void Redirects to index.
     * @throws \Cake\Network\Exception\NotFoundException When record not found.
     */
    public function delete($id = null)
    {
        $this->request->allowMethod(['post', 'delete']);
        $triggerType = $this->TriggerTypes->get($id);
        if ($this->TriggerTypes->delete($triggerType)) {
            $this->Flash->success(__('The trigger type has been deleted.'));
        } else {
            $this->Flash->error(__('The trigger type could not be deleted. Please, try again.'));
        }
        return $this->redirect(['action' => 'index']);
    }
}