text:
package li.strolch.model.policy;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

/**
 * @author Robert von Burg <eitch@eitchnet.ch>
 */
public class PolicyDefTest {

	@Test
	public void shouldInstantiateJavaPolicyDef() {
		PolicyDef def = PolicyDef.valueOf("MyJavaType", JavaPolicyDef.XML_PREFIX + "java.lang.Object");
		assertEquals(JavaPolicyDef.class, def.getClass());
		assertEquals("MyJavaType", def.getType());
		assertEquals("java.lang.Object", def.getValue());
		assertEquals(JavaPolicyDef.XML_PREFIX + "java.lang.Object", def.getValueForXml());
	}

	@Test
	public void shouldInstantiateKeyPolicyDef() {
		PolicyDef def = PolicyDef.valueOf("MyKeyType", KeyPolicyDef.XML_PREFIX + "MyKey");
		assertEquals(KeyPolicyDef.class, def.getClass());
		assertEquals("MyKeyType", def.getType());
		assertEquals("MyKey", def.getValue());
		assertEquals(KeyPolicyDef.XML_PREFIX + "MyKey", def.getValueForXml());
	}

	@Test
	public void shouldClonePolicyDefs() {

		PolicyDef javaDef = PolicyDef.valueOf("MyJavaType", JavaPolicyDef.XML_PREFIX + "java.lang.Object");
		PolicyDef keyDef = PolicyDef.valueOf("MyKeyType", KeyPolicyDef.XML_PREFIX + "MyKey");

		PolicyDefs defs = new PolicyDefs();
		defs.addOrUpdate(javaDef);
		defs.addOrUpdate(keyDef);

		assertEquals(2, defs.getPolicyTypes().size());

		PolicyDefs clone = defs.getClone();
		assertEquals(2, clone.getPolicyTypes().size());

		PolicyDef javaClone = clone.getPolicyDef("MyJavaType");
		assertEquals(JavaPolicyDef.class, javaClone.getClass());
		assertEquals("MyJavaType", javaClone.getType());
		assertEquals("java.lang.Object", javaClone.getValue());
		assertEquals(JavaPolicyDef.XML_PREFIX + "java.lang.Object", javaClone.getValueForXml());

		PolicyDef keyClone = clone.getPolicyDef("MyKeyType");
		assertEquals(KeyPolicyDef.class, keyClone.getClass());
		assertEquals("MyKeyType", keyClone.getType());
		assertEquals("MyKey", keyClone.getValue());
		assertEquals(KeyPolicyDef.XML_PREFIX + "MyKey", keyClone.getValueForXml());
	}
}


text:
// Copyright 2016 Rolosoft Ltd
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// <copyright file="ActivityLoggingEventSource.cs" company="Rolosoft Ltd">
// Copyright (c) Rolosoft Ltd. All rights reserved.
// </copyright>

namespace Rsft.Identity3.CacheRedis.Diagnostics.EventSources
{
    using System;
    using System.Diagnostics.Tracing;

    using Common;

    /// <summary>
    ///     The activity logging event source.
    /// </summary>
    [EventSource(Name = SourceNames.ActivityLogging)]
    public partial class ActivityLoggingEventSource : EventSource
    {
        /// <summary>
        ///     The module name
        /// </summary>
        private const string ModuleName = @"ActivityLogging";

        /// <summary>
        ///     The instance.
        /// </summary>
        private static readonly Lazy<ActivityLoggingEventSource> Instance =
            new Lazy<ActivityLoggingEventSource>(() => new ActivityLoggingEventSource());

        /// <summary>
        ///     Prevents a default instance of the <see cref="ActivityLoggingEventSource" /> class from being created.
        /// </summary>
        private ActivityLoggingEventSource()
        {
        }

        /// <summary>
        ///     Gets the log.
        /// </summary>
        public static ActivityLoggingEventSource Log => Instance.Value;

        /// <summary>
        /// Initializeds the specified module.
        /// </summary>
        /// <param name="module">The module.</param>
        /// <param name="source">The source.</param>
        [Event(
            (int)EventIds.Initialized,
            Message = Messages.Initialized,
            Level = EventLevel.Verbose,
            Keywords = Keywords.GeneralDiagnostic)]
        private void Initialized(string module, string source)
        {
            if (this.IsEnabled(EventLevel.Verbose, Keywords.GeneralDiagnostic))
            {
                this.WriteEvent((int)EventIds.Initialized, module, source);
            }
        }

        /// <summary>
        /// The initializing.
        /// </summary>
        /// <param name="module">
        /// The module.
        /// </param>
        /// <param name="source">
        /// The source.
        /// </param>
        [Event(
            (int)EventIds.Initializing,
            Message = Messages.Initializing,
            Level = EventLevel.Verbose,
            Keywords = Keywords.GeneralDiagnostic)]
        private void Initializing(string module, string source)
        {
            if (this.IsEnabled(EventLevel.Verbose, Keywords.GeneralDiagnostic))
            {
                this.WriteEvent((int)EventIds.Initializing, module, source);
            }
        }

        /// <summary>
        /// The method enter.
        /// </summary>
        /// <param name="module">
        /// The module.
        /// </param>
        /// <param name="source">
        /// The source.
        /// </param>
        [Event(
            (int)EventIds.MethodEnter,
            Message = Messages.MethodEnter,
            Level = EventLevel.Verbose,
            Keywords = Keywords.GeneralDiagnostic)]
        private void MethodEnter(string module, string source)
        {
            if (this.IsEnabled(EventLevel.Verbose, Keywords.GeneralDiagnostic))
            {
                this.WriteEvent((int)EventIds.MethodEnter, module, source);
            }
        }

        /// <summary>
        /// The method exit.
        /// </summary>
        /// <param name="module">
        /// The module.
        /// </param>
        /// <param name="source">
        /// The source.
        /// </param>
        [Event(
            (int)EventIds.MethodExit,
            Message = Messages.MethodExit,
            Level = EventLevel.Verbose,
            Keywords = Keywords.GeneralDiagnostic)]
        private void MethodExit(string module, string source)
        {
            if (this.IsEnabled(EventLevel.Verbose, Keywords.GeneralDiagnostic))
            {
                this.WriteEvent((int)EventIds.MethodExit, module, source);
            }
        }

        /// <summary>
        /// The timer logging.
        /// </summary>
        /// <param name="module">
        /// The module.
        /// </param>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="elapsed">
        /// The elapsed milliseconds.
        /// </param>
        [Event(
            (int)EventIds.TimerLogging,
            Message = Messages.TimerLogging,
            Level = EventLevel.Verbose,
            Keywords = Keywords.Perf)]
        private void TimerLogging(string module, string source, long elapsed)
        {
            if (this.IsEnabled(EventLevel.Verbose, Keywords.Perf))
            {
                this.WriteEvent((int)EventIds.TimerLogging, module, source, elapsed);
            }
        }

        /// <summary>
        /// The server response string.
        /// </summary>
        /// <param name="module">
        /// The module.
        /// </param>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="serverResponse">
        /// The server response.
        /// </param>
        [Event(
            (int)EventIds.ServerResponseString,
            Message = Messages.ServerResponseString,
            Level = EventLevel.Verbose,
            Keywords = Keywords.Io)]
        private void ServerResponseString(string module, string source, string serverResponse)
        {
            if (this.IsEnabled(EventLevel.Verbose, Keywords.Io))
            {
                this.WriteEvent((int)EventIds.ServerResponseString, module, source, serverResponse);
            }
        }

        /// <summary>
        /// Caches the hit.
        /// </summary>
        /// <param name="module">The module.</param>
        /// <param name="source">The source.</param>
        [Event(
            (int)EventIds.CacheHit,
            Message = Messages.CacheHit,
            Level = EventLevel.Informational,
            Keywords = Keywords.Cache)]
        private void CacheHit(string module, string source)
        {
            if (this.IsEnabled(EventLevel.Informational, Keywords.Cache))
            {
                this.WriteEvent((int)EventIds.CacheHit, module, source);
            }
        }

        /// <summary>
        /// Caches the miss.
        /// </summary>
        /// <param name="module">The module.</param>
        /// <param name="source">The source.</param>
        [Event(
            (int)EventIds.CacheMiss,
            Message = Messages.CacheMiss,
            Level = EventLevel.Informational,
            Keywords = Keywords.Cache)]
        private void CacheMiss(string module, string source)
        {
            if (this.IsEnabled(EventLevel.Informational, Keywords.Cache))
            {
                this.WriteEvent((int)EventIds.CacheMiss, module, source);
            }
        }

        /// <summary>
        /// Caches the get object.
        /// </summary>
        /// <param name="module">The module.</param>
        /// <param name="source">The source.</param>
        /// <param name="myObject">My object.</param>
        [Event(
            (int)EventIds.CacheGetObject,
            Message = Messages.CacheGetObject,
            Level = EventLevel.Verbose,
            Keywords = Keywords.Cache)]
        private void CacheGetObject(string module, string source, string myObject)
        {
            if (this.IsEnabled(EventLevel.Verbose, Keywords.Cache))
            {
                this.WriteEvent((int)EventIds.CacheGetObject, module, source, myObject);
            }
        }

        /// <summary>
        /// Caches the set object.
        /// </summary>
        /// <param name="module">The module.</param>
        /// <param name="source">The source.</param>
        /// <param name="myObject">My object.</param>
        [Event(
            (int)EventIds.CacheSetObject,
            Message = Messages.CacheSetObject,
            Level = EventLevel.Verbose,
            Keywords = Keywords.Cache)]
        private void CacheSetObject(string module, string source, string myObject)
        {
            if (this.IsEnabled(EventLevel.Verbose, Keywords.Cache))
            {
                this.WriteEvent((int)EventIds.CacheSetObject, module, source, myObject);
            }
        }

        /// <summary>
        ///     The keywords.
        /// </summary>
        public sealed class Keywords
        {
            /// <summary>
            ///     The general diagnostic.
            /// </summary>
            public const EventKeywords GeneralDiagnostic = (EventKeywords)1;

            /// <summary>
            ///     The IO keyword.
            /// </summary>
            public const EventKeywords Io = (EventKeywords)2;

            /// <summary>
            ///     The performance keyword.
            /// </summary>
            public const EventKeywords Perf = (EventKeywords)4;

            /// <summary>
            /// The cache keyword
            /// </summary>
            public const EventKeywords Cache = (EventKeywords)8;
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
namespace Microsoft { namespace WindowsAPICodePack { namespace DirectX { namespace Direct3D10 {

using namespace System;

    /// <summary>
    /// A pixel-shader interface manages an executable program (a pixel shader) that controls the pixel-shader stage.
    /// <para>(Also see DirectX SDK: ID3D10PixelShader)</para>
    /// </summary>
    public ref class PixelShader :
        public DeviceChild
    {
    public:

    internal:
        PixelShader()
        { }

        PixelShader(ID3D10PixelShader* pNativeID3D10PixelShader) : DeviceChild(pNativeID3D10PixelShader)
        { }

        static property System::Guid Guid
        {
            System::Guid get() { return Utilities::Convert::SystemGuidFromGUID(__uuidof(ID3D10PixelShader)); }
        }
    };
} } } }


text:
layout: kanji
v4: 973
v6: 1047
kanji: 個
keyword: individual
elements: individual, person, harden, pent in, old, tombstone, gravestone, church, ten, needle, mouth
strokes: 10
image: E5808B
on-yomi: コ、カ
permalink: /rtk/個/
prev: 例
next: 健
---

1) [fuaburisu] 15-8-2006(120): This keyword gave me trouble, I could write the kanji from memory but could not remember the keyword the other way around. In such case the dictionary definition can be helpful : "Middle English, single, indivisible". Here we have Mr. T. who is so hardened (all the body workout he's had) that he became in-dividual, that is, in-divisible. "I pity da foo who can be divided into smaller units.".

2) [dihutenosa] 5-9-2007(86): Mr. T insists that people be individual. He appears on television, saying, "Being an individual is hard! But you gotta do it! Harden yourself, and be individual!".

3) [phauna] 11-2-2008(79): Mr. T is a hardened individual.

4) [tristanthorn] 18-3-2009(17): Mr T works out everyday until each individual muscle has hardened.

5) [jezerey] 13-4-2008(15): Yoda says that to really be an individual you must harden your resolve against other people's opinions.


text:
package org.ovirt.engine.core.bll.storage;

import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.ovirt.engine.core.bll.RenamedEntityInfoProvider;
import org.ovirt.engine.core.bll.validator.storage.StoragePoolValidator;
import org.ovirt.engine.core.common.AuditLogType;
import org.ovirt.engine.core.common.VdcObjectType;
import org.ovirt.engine.core.common.action.StorageDomainManagementParameter;
import org.ovirt.engine.core.common.businessentities.StorageDomainStatic;
import org.ovirt.engine.core.common.businessentities.StorageDomainStatus;
import org.ovirt.engine.core.common.errors.EngineMessage;
import org.ovirt.engine.core.common.validation.group.UpdateEntity;
import org.ovirt.engine.core.common.vdscommands.SetStorageDomainDescriptionVDSCommandParameters;
import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase;
import org.ovirt.engine.core.utils.ObjectIdentityChecker;

public class UpdateStorageDomainCommand<T extends StorageDomainManagementParameter> extends
        StorageDomainManagementCommandBase<T>  implements RenamedEntityInfoProvider {
    public UpdateStorageDomainCommand(T parameters) {
        super(parameters);
    }

    private boolean storageDomainNameChanged;
    private StorageDomainStatic oldDomain;

    @Override
    protected boolean canDoAction() {
        if (!super.canDoAction() || !checkStorageDomain()) {
            return false;
        }

        // Only after validating the existence of the storage domain in DB, we set the field lastTimeUsedAsMaster in the
        // storage domain which is about to be updated.
        oldDomain = getStorageDomainStaticDao().get(getStorageDomain().getId());
        getStorageDomain().setLastTimeUsedAsMaster(oldDomain.getLastTimeUsedAsMaster());

        return validateStoragePropertiesUpdate();
    }

    private boolean validateStoragePropertiesUpdate() {
       if (!checkStorageDomainStatusNotEqual(StorageDomainStatus.Locked) || !validateStorageNameUpdate()) {
           return false;
       }

        // Collect changed fields to update in a list.
        List<String> props = ObjectIdentityChecker.GetChangedFields(oldDomain, getStorageDomain()
                .getStorageStaticData());

        // Allow changes to the following fields only:
        props.remove("storageName");
        props.remove("description");
        props.remove("comment");
        props.remove("wipeAfterDelete");
        props.remove("warningLowSpaceIndicator");
        props.remove("criticalSpaceActionBlocker");
        if (!props.isEmpty()) {
            log.warn("There was an attempt to update the following fields although they are not allowed to be updated: {}",
                    StringUtils.join(props, ","));
            return failCanDoAction(EngineMessage.ERROR_CANNOT_CHANGE_STORAGE_DOMAIN_FIELDS);
        }
        return true;
    }

    private boolean validateStorageNameUpdate() {
        storageDomainNameChanged =
                !StringUtils.equals(oldDomain.getStorageName(), getStorageDomain().getStorageName());

        if (!storageDomainNameChanged) {
            return true;
        }

        return checkStorageDomainStatus(StorageDomainStatus.Active)
                && checkStorageDomainNameLengthValid()
                && isPoolUp()
                && validateNotTheSameName();
    }

    private boolean isPoolUp() {
        // if domain is part of pool, and name changed, check that pool is up in
        // order to change description in spm
        return validate(new StoragePoolValidator(getStoragePool()).isUp());
    }

    private boolean validateNotTheSameName() {
        if (isStorageWithSameNameExists()) {
            return failCanDoAction(EngineMessage.ACTION_TYPE_FAILED_STORAGE_DOMAIN_NAME_ALREADY_EXIST);
        }
        return true;
    }

    @Override
    protected void setActionMessageParameters() {
        super.setActionMessageParameters();
        addCanDoActionMessage(EngineMessage.VAR__ACTION__UPDATE);
    }

    @Override
    public AuditLogType getAuditLogTypeValue() {
        return getSucceeded() ? AuditLogType.USER_UPDATE_STORAGE_DOMAIN
                : AuditLogType.USER_UPDATE_STORAGE_DOMAIN_FAILED;
    }

    @Override
    protected void executeCommand() {
        getStorageDomainStaticDao().update(getStorageDomain().getStorageStaticData());
        if (storageDomainNameChanged && getStoragePool() != null) {
            runVdsCommand(
                            VDSCommandType.SetStorageDomainDescription,
                            new SetStorageDomainDescriptionVDSCommandParameters(getStoragePool().getId(),
                                    getStorageDomain().getId(), getStorageDomain().getStorageName()));
        }
        setSucceeded(true);
    }

    @Override
    protected List<Class<?>> getValidationGroups() {
        addValidationGroup(UpdateEntity.class);
        return super.getValidationGroups();
    }

    @Override
    public String getEntityType() {
        return VdcObjectType.Storage.getVdcObjectTranslation();
    }

    @Override
    public String getEntityOldName() {
        return oldDomain.getStorageName();
    }

    @Override
    public String getEntityNewName() {
        return getStorageDomain().getStorageName();
    }

    @Override
    public void setEntityId(AuditLogableBase logable) {
        logable.setStorageDomainId(oldDomain.getId());
    }
}


text:
<?php

class BitHDTVAccount extends commonAccount
{
	public $url = "https://www.bit-hdtv.com";

	protected function isOK($client)
	{
		return(strpos($client->results, '>Password:<')===false);
	}
	protected function login($client,$login,$password,&$url,&$method,&$content_type,&$body,&$is_result_fetched)
        {
                $is_result_fetched = false;
                if($client->fetch( $this->url ))
                {
                        $client->setcookies();
                        $client->referer = $this->url;

                        if($client->fetch( $this->url."/takelogin.php","POST","application/x-www-form-urlencoded",
                                "username=".rawurlencode($login)."&password=".rawurlencode($password) ))
                        {
                                $client->setcookies();
                                return(true);
                        }
                }
                return(false);
        }
}


text:
'use strict';

var _ = require('lodash');
var async = require('async');
var checkProfiles = require('./lib/check_profiles');

module.exports = function (options) {
  var seneca = this;
  var plugin = 'cd-permissions';

  //  Required params
  var config = require(options.config)();
  var addValidator = function (lib) {
    seneca.add({role: lib, cmd: 'check_permissions'},
      require('./lib/check_permissions'));
  };

  _.each(_.keys(config), addValidator);

  return {
    name: plugin,
    exportmap: {
      config: config
    }
  };
};

module.exports.checkProfiles = checkProfiles;


text:
package com.sastix.cms.server.domain.entities;

import javax.persistence.*;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

@Entity
@Table(name = "resource")
@NamedQueries({
        @NamedQuery(name = "Resource.findAll", query = "SELECT resource FROM Resource resource")
        , @NamedQuery(name = "Resource.findByAuthor", query = "SELECT resource FROM Resource resource WHERE resource.author = :author")
        , @NamedQuery(name = "Resource.findByAuthorContaining", query = "SELECT resource FROM Resource resource WHERE resource.author like :author")
        , @NamedQuery(name = "Resource.findByName", query = "SELECT resource FROM Resource resource WHERE resource.name = :name")
        , @NamedQuery(name = "Resource.findByNameContaining", query = "SELECT resource FROM Resource resource WHERE resource.name like :name")
        , @NamedQuery(name = "Resource.findByMediaType", query = "SELECT resource FROM Resource resource WHERE resource.mediaType = :mediaType")
        , @NamedQuery(name = "Resource.findByMediaTypeContaining", query = "SELECT resource FROM Resource resource WHERE resource.mediaType like :mediaType")
        , @NamedQuery(name = "Resource.findByPath", query = "SELECT resource FROM Resource resource WHERE resource.path = :path")
        , @NamedQuery(name = "Resource.findByPathContaining", query = "SELECT resource FROM Resource resource WHERE resource.path like :path")
        , @NamedQuery(name = "Resource.findByUid", query = "SELECT resource FROM Resource resource WHERE resource.uid = :uid")
        , @NamedQuery(name = "Resource.findByUidContaining", query = "SELECT resource FROM Resource resource WHERE resource.uid like :uid")
})
@Getter @Setter @NoArgsConstructor
public class Resource implements Serializable {

    public static final String FIND_ALL = "Resource.findAll";
    public static final String FIND_BY_AUTHOR = "Resource.findByAuthor";
    public static final String FIND_BY_AUTHOR_CONTAINING = "Resource.findByAuthorContaining";
    public static final String FIND_BY_NAME = "Resource.findByName";
    public static final String FIND_BY_NAME_CONTAINING = "Resource.findByNameContaining";
    public static final String FIND_BY_MEDIATYPE = "Resource.findByMediaType";
    public static final String FIND_BY_MEDIATYPE_CONTAINING = "Resource.findByMediaTypeContaining";
    public static final String FIND_BY_PATH = "Resource.findByPath";
    public static final String FIND_BY_PATH_CONTAINING = "Resource.findByPathContaining";
    public static final String FIND_BY_UID = "Resource.findByUid";
    public static final String FIND_BY_UID_CONTAINING = "Resource.findByUidContaining";
    private static final long serialVersionUID = -7222707205353947820L;

    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;

    @Column(name = "author", nullable = false, unique = false)
    private String author;

    @Column(name = "name", nullable = false, unique = false)
    private String name;

    @Column(name = "media_type", nullable = false, unique = false)
    private String mediaType;

    @Column(name = "path", length = 512, nullable = false, unique = false)
    private String path;

    @Column(name = "uid", length = 255, nullable = false, unique = false)
    private String uid;

    @Column(name = "uri", length = 255, nullable = false, unique = false)
    private String uri;

    @Column(name = "resource_tenant_id", nullable = false)
    private String resourceTenantId;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "resource_id")
    private Resource resource;

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "resource")
    private Set<Resource> resources = new HashSet<Resource>(0);

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "resource")
    private Set<Revision> revisions = new HashSet<Revision>(0);

}


text:
package vgrechka;

public class BreakOnMeException_Java extends RuntimeException {
    BreakOnMeException_Java() {}
    BreakOnMeException_Java(String message) {super(message);}
    BreakOnMeException_Java(String message, Throwable cause) {super(message, cause);}
    BreakOnMeException_Java(Throwable cause) {super(cause);}
    BreakOnMeException_Java(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {super(message, cause, enableSuppression, writableStackTrace);}
}


text:
"""Hex file merger

This is a helper script for merging SS, DS and XS into a single hex file.

"""

import argparse
import os
import pathlib
import re
import sys
import zlib

import leb128
from collections import OrderedDict
from intelhex import IntelHex
from struct import pack, unpack

THREAD_FACTORY_KEY_BASE = 0x2000
MATTER_FACTORY_KEY_BASE = 0x2100

def main():
    args = parse_args()

    configs = gen_thread_factory_config()
    configs.update(gen_matter_factory_config(args.config_header))

    parse_config_args(configs, args.config)

    merged_hex = insert_config(IntelHex(str(args.ss_hex)), configs)
    merged_hex.merge(IntelHex(str(args.ds_hex)))
    merged_hex.merge(IntelHex(str(args.xs_hex)))
    merged_hex.write_hex_file(args.output)

def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument("--output", required=True, type=pathlib.Path)
    parser.add_argument("--ss_hex", required=True, type=pathlib.Path)
    parser.add_argument("--ds_hex", required=True, type=pathlib.Path)
    parser.add_argument("--xs_hex", required=True, type=pathlib.Path)
    parser.add_argument("--config_header", required=True, type=pathlib.Path)
    parser.add_argument("--config", action="append", type=str)
    return parser.parse_args()

def gen_thread_factory_config() -> OrderedDict:
    configs = OrderedDict()
    configs["ExtendedAddress"] = {"key": THREAD_FACTORY_KEY_BASE, "value": os.urandom(8)}
    return configs

def gen_matter_factory_config(path: pathlib.Path) -> OrderedDict:
    # compile the regex for extracting name and key of factory configurations.
    factory_config_re = re.compile(r"""
      .*                    # Prefix
      kConfigKey_(\w+)      # Parse the config name
      \s*=.*                # Allow spaces
      kChipFactory_KeyBase  # Only match factory configurations
      \s*,\s*               # Allow spaces
      (0x[0-9a-fA-F]+)      # Parse the config key
    """, re.VERBOSE)

    configs = OrderedDict()
    with open(str(path), mode="r") as config_file:
        for line in config_file:
            match = factory_config_re.match(line.strip())
            if match:
                name = match[1]
                key = MATTER_FACTORY_KEY_BASE + int(match[2], 0)
                configs[name] = {"key": key}
    return configs

def parse_config_args(configs: OrderedDict, args: list):
    for arg in args:
        name, category, value = arg.split(":")

        if name not in configs:
            print(f"[Warning] Ignored unknown config: {name}")
            continue

        if category == "address":
            addr = bytearray.fromhex(value)

            if len(addr) == 6:
                # RFC 4291 Appendix A
                addr[3:3] = b'\xff\xfe'
            elif len(addr) != 8:
                print(f"[Warning] Ignored config {name}: Invalid length: {len(addr)}")
                return

            configs[name]["value"] = addr[::-1]
        elif category == "file":
            with open(value, mode="rb") as file:
                configs[name]["value"] = file.read()
        else:
            print(f"[Warning] Ignored config {name}: Invalid category: {category}")

def insert_config(origin_hex: IntelHex, configs: OrderedDict):
    ss_segment = origin_hex.segments()[0]

    origin_ss_header = origin_hex.tobinarray(
        start=ss_segment[0], end=ss_segment[0] + 0x10 - 1)
    origin_ss_data = origin_hex.tobinarray(
        start=ss_segment[0] + 0x10, end=ss_segment[1] - 1)

    signature, _, _ = unpack("<8sLL", origin_ss_header)

    ss_data = bytearray()
    for config in configs.values():
        if "value" in config:
            ss_data += config["key"].to_bytes(2, byteorder="little")
            ss_data += leb128.u.encode(len(config["value"]))
            ss_data += config["value"]
    ss_data += origin_ss_data

    ss_header = pack("<8sLL", signature, zlib.crc32(ss_data), len(ss_data))

    ss_hex = IntelHex()
    ss_hex.puts(ss_segment[0], ss_header + ss_data)
    return ss_hex

if __name__ == "__main__":
    main()


text:
namespace Lissen
{
    public class Lambda : Function
    {
        public override Sexpr ApplyOn(List par, VariablesEnvironment env)
        {
            return new LambdaExpr(par.Car(), par.Cadr());
        }
    }
}


text:
<?php

namespace uuf6429\ElderBrother\Action;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\Process;

class ExecuteProgram extends ActionAbstract
{
    /**
     * @var string
     */
    protected $description;

    protected $command;
    protected $breakOnFailure;
    protected $environment;
    protected $currentDir;
    protected $timeout;

    /**
     * Executes an external program.
     *
     * @param string      $description    Description of the intention of the program
     * @param string      $command        Program command line (with parameters)
     * @param bool        $breakOnFailure (Optional, default is true) Stop execution if program returns non-0 exit code
     * @param array|null  $environment    (Optional, default is null / current vars) Environment variables to pass to program
     * @param string|null $currentDir     The current directory to use for program
     * @param int         $timeout        (Optional, default is 60) The time to wait for program to finish (in seconds)
     */
    public function __construct($description, $command, $breakOnFailure = true, $environment = null, $currentDir = null, $timeout = 60)
    {
        $this->description = $description;
        $this->command = $command;
        $this->breakOnFailure = $breakOnFailure;
        $this->environment = $environment;
        $this->currentDir = $currentDir;
        $this->timeout = $timeout;
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return ($this->description ?: 'Execute External Program') . ' (ExecuteProgram)';
    }

    /**
     * {@inheritdoc}
     */
    public function isSupported()
    {
        return true; // no special dependencies
    }

    /**
     * {@inheritdoc}
     */
    public function execute(InputInterface $input, OutputInterface $output)
    {
        $process = new Process(
            $this->command,
            $this->currentDir,
            $this->environment,
            null,
            $this->timeout
        );

        if ($this->breakOnFailure) {
            $process->mustRun();
        } else {
            $process->run();
        }
    }
}