text:
<!DOCTYPE html>

    <meta content="en-us" http-equiv="Content-Language" />
    <meta content="text/html; charset=utf-16" http-equiv="Content-Type" />
    <title _locid="PortabilityAnalysis0">.NET Portability Report</title>

.NET Portability Report

                    Submission Id
                    b841e435-1284-4fed-b228-623e60fcc7d3

            Portability Summary

                        Assembly
                            ASP.NET 5,Version=v1.0
                            Windows,Version=v8.1
                            .NET Framework,Version=v4.6
                            Windows Phone,Version=v8.1

                            Hangfire.Core
                                96.20 %
                                89.48 %
                                100.00 %
                                89.48 %

Hangfire.Core

                                Target type
                                ASP.NET 5,Version=v1.0
                                Windows,Version=v8.1
                                .NET Framework,Version=v4.6
                                Windows Phone,Version=v8.1
                                Recommended changes

                                    System.Attribute

                                        GetCustomAttribute(System.Reflection.MemberInfo,System.Type,System.Boolean)

                                    System.Collections.Generic.List`1

                                        ForEach(System.Action{`0})

                                    System.ComponentModel.DisplayNameAttribute

                                        get_DisplayName

                                    System.ComponentModel.TypeConverter

                                        ConvertFromInvariantString(System.String)

                                    System.ComponentModel.TypeDescriptor

                                Currently there is no workaround, but we are working on it. Please check back.

                                        GetConverter(System.Type)

                                    Currently there is no workaround, but we are working on it. Please check back.

                                    System.Delegate

                                Use System.Reflection.RuntimeReflectionExtensions.GetMethodInfo

                                        CreateDelegate(System.Type,System.Object,System.Reflection.MethodInfo)

                                    Use MethodInfo.CreateDelegate

                                        get_Method

                                    Use System.Reflection.RuntimeReflectionExtensions.GetMethodInfo

                                    System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute

                                        #ctor

                                    System.Diagnostics.DefaultTraceListener

                                    System.Diagnostics.FileVersionInfo

                                Currently there is no workaround, but we are working on it. Please check back.

                                        get_ProductVersion

                                        GetVersionInfo(System.String)

                                    Currently there is no workaround, but we are working on it. Please check back.

                                    System.Diagnostics.Process

                                        get_Id

                                        GetCurrentProcess

                                    System.Diagnostics.SourceLevels

                                    System.Diagnostics.SourceSwitch

                                        #ctor(System.String)

                                        get_Level

                                        ShouldTrace(System.Diagnostics.TraceEventType)

                                    System.Diagnostics.Switch

                                        get_DisplayName

                                    System.Diagnostics.TraceEventType

                                    System.Diagnostics.TraceListener

                                    System.Diagnostics.TraceListenerCollection

                                        Add(System.Diagnostics.TraceListener)

                                        AddRange(System.Diagnostics.TraceListenerCollection)

                                        Clear

                                        get_Count

                                        get_Item(System.Int32)

                                    System.Diagnostics.TraceSource

                                        #ctor(System.String)

                                        get_Listeners

                                        get_Name

                                        get_Switch

                                        set_Switch(System.Diagnostics.SourceSwitch)

                                        TraceEvent(System.Diagnostics.TraceEventType,System.Int32,System.String)

                                    System.Environment

                                Remove, or use Environment.GetEnvironmentVariable("COMPUTERNAME")

                                        get_MachineName

                                    Remove, or use Environment.GetEnvironmentVariable("COMPUTERNAME")

                                    System.Exception

                                False positive (GetType() from Object is sufficient)

                                        #ctor(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)

                                    Remove.  Ctor overload taking SerializationInfo is not applicable in new surface area

                                        GetType

                                    False positive (GetType() from Object is sufficient)

                                    System.Globalization.CultureInfo

                                new CultureInfo(String)

                                        GetCultureInfo(System.String)

                                    new CultureInfo(String)

                                    System.Globalization.IdnMapping

                                        #ctor

                                        GetAscii(System.String)

                                        GetAscii(System.String,System.Int32,System.Int32)

                                        GetUnicode(System.String)

                                        GetUnicode(System.String,System.Int32,System.Int32)

                                    System.Globalization.TextInfo

                                        ToTitleCase(System.String)

                                    System.IO.Stream

                                Use Stream.WriteAsync

                                        BeginWrite(System.Byte[],System.Int32,System.Int32,System.AsyncCallback,System.Object)

                                    Use Stream.WriteAsync

                                        EndWrite(System.IAsyncResult)

                                    Use Stream.WriteAsync

                                    System.MissingFieldException

                                        #ctor(System.String,System.String)

                                    System.MissingMethodException

                                Use MissingMemberException instead.

                                        #ctor(System.String)

                                    Use MissingMemberException instead.

                                        #ctor(System.String,System.String)

                                    Use MissingMemberException instead.

                                    System.Net.WebUtility

                                        HtmlEncode(System.String,System.IO.TextWriter)

                                    System.Reflection.Assembly

                                Remove usage

                                        get_Location

                                    Remove usage

                                    System.Runtime.Serialization.IObjectReference

                                        GetRealObject(System.Runtime.Serialization.StreamingContext)

                                    System.Runtime.Serialization.SerializationInfo

                                Remove serialization constructors on custom Exception types

                                    System.Threading.Thread

                                        #ctor(System.Threading.ThreadStart)

                                        Abort

                                    This is only reliable in SQL Server.  Elsewhere, don't use it.

                                        get_CurrentCulture

                                    Use System.Globalization.CultureInfo.CurrentCulture

                                        get_CurrentThread

                                        get_CurrentUICulture

                                    Use System.Globalization.CultureInfo.CurrentUICulture

                                        get_ManagedThreadId

                                        Join(System.TimeSpan)

                                        set_CurrentCulture(System.Globalization.CultureInfo)

                                        set_CurrentUICulture(System.Globalization.CultureInfo)

                                        set_IsBackground(System.Boolean)

                                        set_Name(System.String)

                                        Start

                                    System.Threading.ThreadAbortException

                                Do not use: exception cannot be caught since it is not thrown by framework, never throw this type. Thread.Abort is only reliable in SQL Server.  Elsewhere, don't use it.

                                    System.Threading.ThreadStart

                                        #ctor(System.Object,System.IntPtr)

                                    System.Type

                                .GetTypeInfo().Assembly

                                        get_Assembly

                                    .GetTypeInfo().Assembly

                                        get_IsEnum

                                    .GetTypeInfo().IsEnum

                                        get_IsGenericType

                                    .GetTypeInfo().IsGenericType

                                        get_IsInterface

                                    .GetTypeInfo().IsInterface

                                        get_IsValueType

                                    .GetTypeInfo().IsValueType

                                        GetConstructors

                                        GetGenericArguments

                                        GetInterfaces

                                        GetMethod(System.String)

                                        GetMethod(System.String,System.Type[])

                                        GetMethods

                                        GetType(System.String,System.Boolean,System.Boolean)

                                        GetTypeCode(System.Type)

                                    Use Type or RuntimeTypeHandle instead.

                                        IsAssignableFrom(System.Type)

                                        IsInstanceOfType(System.Object)

                                    System.TypeCode

                                Use Type or RuntimeTypeHandle instead.

                                    System.Uri

                                        SchemeDelimiter

                    Back to Summary


text:
<?xml version="1.0"?>
<!--

-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_order_payment_place_end">
        <observer name="paypal" instance="Magento\Paypal\Observer\AddBillingAgreementToSessionObserver"/>
    </event>
    <event name="sales_order_payment_transaction_html_txn_id">
        <observer name="paypal_transaction_html" instance="Magento\Paypal\Observer\HtmlTransactionIdObserver"/>
    </event>
</config>

redpajama_set_name: RedPajamaGithub


text:
import java.util.function.Function;

public abstract class x {

  public enum E {
    A(n -> <caret>n.toString()),
    B(n -> { return n.toString();}),
    C(Number::toString);

    E(Function<Number, Object> iFunc) {}
  }

  public void dothis(Function<Number, Object> iFunc) { }

  public void trythis() {
    dothis(n -> n.toString());
  }

  public void trythis2() {
    dothis(n -> { return n.toString(); });
  }
}


text:
namespace testing {
template <typename TComparator = PixelByPixelImageComparator<>>
class DrawTest : public ::testing::Test {
private:
    woc::unique_cf<CGContextRef> _context;
    CGRect _bounds;
    void* _opaqueAutoreleasePool;

public:
    virtual CFStringRef CreateAdditionalTestDescription();
    virtual CFStringRef CreateOutputFilename();
    virtual CGSize CanvasSize();
    virtual void SetUpContext();

    virtual void SetUp();
    virtual void PreDraw();
    virtual void Draw();
    virtual void PostDraw();
    virtual void TearDown();

    virtual void TestBody();

    CGContextRef GetDrawingContext();
    void SetDrawingBounds(CGRect bounds);
    CGRect GetDrawingBounds();
};
}

inline CGPoint _CGRectGetCenter(CGRect rect) {
    return {
        rect.origin.x + (rect.size.width / 2.f), rect.origin.y + (rect.size.height / 2.f),
    };
}

inline CGRect _CGRectCenteredOnPoint(CGSize size, CGPoint point) {
    return {
        {
            point.x - (size.width / 2.f), point.y - (size.height / 2.f),
        },
        size,
    };
}

template <typename TComparator = PixelByPixelImageComparator<>>
class WhiteBackgroundTest : public ::testing::DrawTest<TComparator> {
protected:
    virtual void SetUpContext();
};

template <typename TComparator = PixelByPixelImageComparator<>>
class UIKitMimicTest : public WhiteBackgroundTest<TComparator> {
protected:
    virtual CGSize CanvasSize();
    virtual void SetUpContext();
};

#define _DRAW_TEST_INTERSTITIAL_CLASS_NAME(test_case_name, test_name) test_case_name##_##test_name##_Drawing
#define _DRAW_TEST_INTERSTITIAL_CLASS(test_case_name, test_name, test_fixture)                  \
    class _DRAW_TEST_INTERSTITIAL_CLASS_NAME(test_case_name, test_name) : public test_fixture { \
    public:                                                                                \
        virtual void Draw();                                                                    \
    };
#define _DRAW_TEST_INTERSTITIAL_BODY \
    {                                \
        PreDraw();                   \
        Draw();                      \
        PostDraw();                  \
    \
}

#define DRAW_TEST_F(test_case_name, test_name, test_fixture)                   \
    _DRAW_TEST_INTERSTITIAL_CLASS(test_case_name, test_name, test_fixture)     \
    GTEST_TEST_(test_case_name,                                                \
                test_name,                                                     \
                _DRAW_TEST_INTERSTITIAL_CLASS_NAME(test_case_name, test_name), \
                ::testing::internal::GetTestTypeId())                          \
    _DRAW_TEST_INTERSTITIAL_BODY                                               \
    void _DRAW_TEST_INTERSTITIAL_CLASS_NAME(test_case_name, test_name)::Draw()

#define DRAW_TEST(test_case_name, test_name) DRAW_TEST_F(test_case_name, test_name, ::testing::DrawTest<>)

#define DISABLED_DRAW_TEST(test_case_name, test_name) DRAW_TEST(test_case_name, DISABLED_##test_name)
#define DISABLED_DRAW_TEST_F(test_case_name, test_name, test_fixture) DRAW_TEST_F(test_case_name, DISABLED_##test_name, test_fixture)

#define DRAW_TEST_P(test_case_name, test_name)                                                              \
    _DRAW_TEST_INTERSTITIAL_CLASS(test_case_name, test_name, test_case_name)                                \
    GTEST_TEST_P_(test_case_name, test_name, _DRAW_TEST_INTERSTITIAL_CLASS_NAME(test_case_name, test_name)) \
    _DRAW_TEST_INTERSTITIAL_BODY                                                                            \
    void _DRAW_TEST_INTERSTITIAL_CLASS_NAME(test_case_name, test_name)::Draw()
#define DISABLED_DRAW_TEST_P(test_case_name, test_name) DRAW_TEST_P(test_case_name, DISABLED_##test_name)

#define TEXT_DRAW_TEST(test_case_name, test_name) DRAW_TEST_F(test_case_name, test_name, ::testing::DrawTest<>)
#define TEXT_DRAW_TEST_F(test_case_name, test_name, test_fixture) DRAW_TEST_F(test_case_name, test_name, test_fixture)

#ifdef WINOBJC_DISABLE_TESTS
#define ARM_DISABLED_TEXT_DRAW_TEST_F(test_case_name, test_name, test_fixture) \
    DISABLED_DRAW_TEST_F(test_case_name, DISABLED_##test_name, test_fixture)
#else
#define ARM_DISABLED_TEXT_DRAW_TEST_F(test_case_name, test_name, test_fixture) TEXT_DRAW_TEST_F(test_case_name, test_name, test_fixture)
#endif

#define DISABLED_TEXT_DRAW_TEST(test_case_name, test_name) TEXT_DRAW_TEST(test_case_name, DISABLED_##test_name)
#define DISABLED_TEXT_DRAW_TEST_F(test_case_name, test_name, test_fixture) \
    TEXT_DRAW_TEST_F(test_case_name, DISABLED_##test_name, test_fixture)

#define TEXT_DRAW_TEST_P(test_case_name, test_name) DRAW_TEST_P(test_case_name, test_name)
#define DISABLED_TEXT_DRAW_TEST_P(test_case_name, test_name) TEXT_DRAW_TEST_P(test_case_name, DISABLED_##test_name)


text:
import os
import sys

from mock import patch, Mock
import pytest

from nameko.standalone.rpc import ClusterProxy
from nameko.cli.commands import Shell
from nameko.cli.main import setup_parser
from nameko.cli.shell import make_nameko_helper
from nameko.constants import (
    AMQP_URI_CONFIG_KEY, WEB_SERVER_CONFIG_KEY, SERIALIZER_CONFIG_KEY)

def test_helper_module(rabbit_config):
    helper = make_nameko_helper(rabbit_config)
    assert isinstance(helper.rpc, ClusterProxy)
    helper.disconnect()

@pytest.yield_fixture
def pystartup(tmpdir):
    startup = tmpdir.join('startup.py')
    startup.write('foo = 42')

    with patch.dict(os.environ, {'PYTHONSTARTUP': str(startup)}):
        yield

@pytest.yield_fixture(autouse=True)
def fake_alternative_interpreters():
    # Make sure these appear unavailable even if installed. We cheat slightly,
    # and have the call to `embed` raise the ImportError, rather than the
    # actual module import (this is easier to do and has the same effect in our
    # case).
    fake_module = Mock()
    fake_module.embed.side_effect = ImportError
    with patch.dict(sys.modules, {
        'IPython': fake_module,
        'bpython': fake_module,
    }):
        yield

def test_basic(pystartup, rabbit_config):
    parser = setup_parser()
    args = parser.parse_args([
        'shell', '--broker', rabbit_config[AMQP_URI_CONFIG_KEY]
    ])

    with patch('nameko.cli.shell.code') as code:
        Shell.main(args)

    _, kwargs = code.interact.call_args
    local = kwargs['local']
    assert 'n' in local.keys()
    assert local['foo'] == 42
    local['n'].disconnect()

def test_plain(pystartup, rabbit_config):
    parser = setup_parser()
    args = parser.parse_args([
        'shell', '--broker', rabbit_config[AMQP_URI_CONFIG_KEY],
        '--interface', 'plain'
    ])

    with patch('nameko.cli.shell.code') as code:
        Shell.main(args)

    _, kwargs = code.interact.call_args
    local = kwargs['local']
    assert 'n' in local.keys()
    assert local['foo'] == 42
    local['n'].disconnect()

def test_plain_fallback(pystartup, rabbit_config):
    parser = setup_parser()
    args = parser.parse_args([
        'shell', '--broker', rabbit_config[AMQP_URI_CONFIG_KEY],
        '--interface', 'bpython'
    ])

    with patch('nameko.cli.shell.code') as code:
        Shell.main(args)

    _, kwargs = code.interact.call_args
    local = kwargs['local']
    assert 'n' in local.keys()
    assert local['foo'] == 42
    local['n'].disconnect()

def test_bpython(pystartup, rabbit_config):
    parser = setup_parser()
    args = parser.parse_args([
        'shell', '--broker', rabbit_config[AMQP_URI_CONFIG_KEY],
        '--interface', 'bpython'
    ])

    with patch('bpython.embed') as embed:
        Shell.main(args)

    _, kwargs = embed.call_args
    local = kwargs['locals_']
    assert 'n' in local.keys()
    assert local['foo'] == 42
    local['n'].disconnect()

def test_ipython(pystartup, rabbit_config):
    parser = setup_parser()
    args = parser.parse_args([
        'shell', '--broker', rabbit_config[AMQP_URI_CONFIG_KEY],
        '--interface', 'ipython'
    ])

    with patch('IPython.embed') as embed:
        Shell.main(args)

    _, kwargs = embed.call_args
    local = kwargs['user_ns']
    assert 'n' in local.keys()
    assert local['foo'] == 42
    local['n'].disconnect()

def test_config(pystartup, rabbit_config, tmpdir):

    config = tmpdir.join('config.yaml')
    config.write("""
        WEB_SERVER_ADDRESS: '0.0.0.0:8001'
        AMQP_URI: '{}'
        serializer: 'json'
    """.format(rabbit_config[AMQP_URI_CONFIG_KEY]))

    parser = setup_parser()
    args = parser.parse_args(['shell', '--config', config.strpath])

    with patch('nameko.cli.shell.code') as code:
        Shell.main(args)

    _, kwargs = code.interact.call_args
    local = kwargs['local']
    assert 'n' in local.keys()
    assert local['n'].config == {
        WEB_SERVER_CONFIG_KEY: '0.0.0.0:8001',
        AMQP_URI_CONFIG_KEY: rabbit_config[AMQP_URI_CONFIG_KEY],
        SERIALIZER_CONFIG_KEY: 'json'
    }
    local['n'].disconnect()

class TestBanner(object):

    @pytest.yield_fixture(autouse=True)
    def patch_nameko_helper(self):
        with patch('nameko.cli.shell.make_nameko_helper'):
            yield

    def test_broker_as_param(self):

        amqp_uri = "amqp://broker/param"

        parser = setup_parser()
        args = parser.parse_args(['shell', '--broker', amqp_uri])

        with patch('nameko.cli.shell.ShellRunner') as shell_runner:
            Shell.main(args)

        expected_message = (
            "Broker: {}".format(amqp_uri)
        )
        (banner, _), _ = shell_runner.call_args
        assert expected_message in banner

    def test_broker_from_config(self, tmpdir):

        amqp_uri = "amqp://broker/config"

        config = tmpdir.join('config.yaml')
        config.write("""
            WEB_SERVER_ADDRESS: '0.0.0.0:8001'
            AMQP_URI: '{}'
            serializer: 'json'
        """.format(amqp_uri))

        parser = setup_parser()
        args = parser.parse_args(['shell', '--config', config.strpath])

        with patch('nameko.cli.shell.ShellRunner') as shell_runner:
            Shell.main(args)

        expected_message = (
            "Broker: {} (from --config)".format(amqp_uri)
        )
        (banner, _), _ = shell_runner.call_args
        assert expected_message in banner


text:
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.

Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.VisualStudio.GraphModel
Imports Microsoft.VisualStudio.GraphModel.Schemas
Imports Microsoft.VisualStudio.LanguageServices.Implementation.Progression
Imports Moq
Imports Roslyn.Test.Utilities

Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Progression

    Public Class GraphProviderTests
        <WorkItem(1078048, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1078048")>
        <Fact, Trait(Traits.Feature, Traits.Features.Progression)>
        Public Sub TestGetContainsGraphQueries()
            Dim context = CreateGraphContext(GraphContextDirection.Contains, Array.Empty(Of GraphCategory)())
            Dim queries = AbstractGraphProvider.GetGraphQueries(context, threadingContext:=Nothing, asyncListener:=Nothing)
            Assert.Equal(queries.Single().GetType(), GetType(ContainsGraphQuery))
        End Sub

        <WorkItem(1078048, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1078048")>
        <Fact, Trait(Traits.Feature, Traits.Features.Progression)>
        Public Sub TestGetContainsGraphQueriesWithTarget()
            Dim context = CreateGraphContext(GraphContextDirection.Target, {CodeLinkCategories.Contains})
            Dim queries = AbstractGraphProvider.GetGraphQueries(context, threadingContext:=Nothing, asyncListener:=Nothing)
            Assert.Equal(queries.Single().GetType(), GetType(ContainsGraphQuery))
        End Sub

        Private Shared Function CreateGraphContext(direction As GraphContextDirection, linkCategories As IEnumerable(Of GraphCategory)) As IGraphContext
            Dim context = New Mock(Of IGraphContext)(MockBehavior.Strict)
            context.Setup(Function(x) x.Direction).Returns(direction)
            context.Setup(Function(x) x.LinkCategories).Returns(linkCategories)
            Return context.Object
        End Function
    End Class

End Namespace


text:
package com.evolveum.midpoint.repo.sql;

import com.evolveum.midpoint.prism.query.ObjectPaging;

/**
 * @author Pavol
 */ // Temporary hack. Represents special paging object that means
// "give me objects with OID greater than specified one, sorted by OID ascending".
//
// TODO: replace by using cookie that is part of the standard ObjectPaging
// (but think out all consequences, e.g. conflicts with the other use of the cookie)
public class ObjectPagingAfterOid extends ObjectPaging {
    private String oidGreaterThan;

    public String getOidGreaterThan() {
        return oidGreaterThan;
    }

    public void setOidGreaterThan(String oidGreaterThan) {
        this.oidGreaterThan = oidGreaterThan;
    }

    @Override
    public String toString() {
        return super.toString() + ", after OID: " + oidGreaterThan;
    }

    @Override
    public ObjectPagingAfterOid clone() {
        ObjectPagingAfterOid clone = new ObjectPagingAfterOid();
        copyTo(clone);
        return clone;
    }

    protected void copyTo(ObjectPagingAfterOid clone) {
        super.copyTo(clone);
        clone.oidGreaterThan = this.oidGreaterThan;
    }

	public boolean equals(Object o, boolean exact) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;
		if (!super.equals(o, exact))
			return false;

		ObjectPagingAfterOid that = (ObjectPagingAfterOid) o;

		return oidGreaterThan != null ? oidGreaterThan.equals(that.oidGreaterThan) : that.oidGreaterThan == null;

	}

	@Override
	public int hashCode() {
		int result = super.hashCode();
		result = 31 * result + (oidGreaterThan != null ? oidGreaterThan.hashCode() : 0);
		return result;
	}
}


text:
"use strict";
var CliCommand = require("./command");
var MZ700KeyMatrix = require("../../js/MZ-700/mz700-key-matrix.js");
function CliCommandSendKey() {
    this._durationMake = 250;
    this._durationRelease = 250;
}
CliCommandSendKey.prototype = new CliCommand("key", function(mz700, args) {
    var inkey = [];
    var s = args.join(" ").toUpperCase();
    var i = 0;
    while(i < s.length) {
        var c = s.charAt(i);
        if(c == '\\') {
            i++;
            if(i < s.length) {
                inkey.push(s.charAt(i));
            }
        } else if(c == '[') {
            c = "";
            i++;
            while(i < s.length && s.charAt(i) != ']') {
                c += s.charAt(i);
                i++;
            }
            if(i < s.length && c != "") {
                inkey.push(c);
            }
            i++;
        } else {
            inkey.push(s.charAt(i));
        }
        i++;
    }
    const pushKeys = [];
    for(const strcode of inkey) {
        const key = MZ700KeyMatrix.Str2Key[strcode];
        if(key) {
            pushKeys.push(key);
        } else {
            return Promise.reject(`Not found ${strcode}`);
        }
    }
    var durationRelease = this._durationRelese;
    var durationMake = this._durationMake;
    var pushKey = function(key) {
        return new Promise(function(resolv, reject) {
            try {
                mz700.setKeyState(key.strobe, key.bit, true, null);
                setTimeout(function() {
                    mz700.setKeyState(key.strobe, key.bit, false, null);
                    setTimeout(function() { resolv(); },
                        durationRelease);
                }, durationMake);
            } catch(ex) {
                reject(ex);
            }
        });
    };
    return new Promise(function(resolv, reject) {
        var sendKeys = function(i) {
            try {
                var key = pushKeys[i];
                console.log("SEND KEY [" + i + "/" + pushKeys.length + "] " + key.face);
                pushKey(key).then(function() {
                    if(++i < pushKeys.length) {
                        sendKeys(i);
                    } else {
                        resolv();
                    }
                }).catch(function(err) {
                    console.log(err);
                });
            } catch(err) {
                reject(err);
            }
        };
        sendKeys(0);
    });
});
CliCommandSendKey.prototype.setMakeReleaseDurations = function(
        durationMake, durationRelease)
{
    this._durationMake = durationMake;
    this._durationRelease = durationRelease;
};
module.exports = new CliCommandSendKey();


text:
package org.apache.geode.management.internal.cli.commands;

import static org.apache.geode.cache.Region.SEPARATOR;
import static org.apache.geode.lang.Identifiable.find;
import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException;
import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.TemporaryFolder;
import org.junit.rules.TestName;

import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.cache.configuration.CacheConfig;
import org.apache.geode.cache.configuration.RegionConfig;
import org.apache.geode.distributed.internal.InternalLocator;
import org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException;
import org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException;
import org.apache.geode.internal.cache.wan.MyAsyncEventListener;
import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
import org.apache.geode.test.dunit.rules.ClusterStartupRule;
import org.apache.geode.test.dunit.rules.MemberVM;
import org.apache.geode.test.junit.categories.WanTest;
import org.apache.geode.test.junit.rules.GfshCommandRule;
import org.apache.geode.test.junit.rules.serializable.SerializableTestName;

@Category(WanTest.class)
public class AlterRegionCommandDUnitTest {
  private static MemberVM locator;

  @Rule
  public GfshCommandRule gfsh = new GfshCommandRule();

  @Rule
  public TestName testName = new SerializableTestName();

  @Rule
  public ClusterStartupRule lsRule = new ClusterStartupRule();

  @Rule
  public TemporaryFolder temporaryFolder = new TemporaryFolder();

  @Before
  public void before() throws Exception {
    locator = lsRule.startLocatorVM(0);
    lsRule.startServerVM(1, locator.getPort());

    gfsh.connectAndVerify(locator);
    gfsh.executeAndAssertThat(
        "create disk-store --name=diskStore --dir=" + temporaryFolder.getRoot())
        .statusIsSuccess()
        .doesNotContainOutput("Did not complete waiting");
  }

  @Test
  public void alterPartitionRegionWithParallelAsynchronousEventQueueShouldPersistTheChangesIntoTheClusterConfigurationService() {
    String regionName = testName.getMethodName();
    String asyncEventQueueName = "asyncEventQueue1";

    gfsh.executeAndAssertThat(
        "create async-event-queue --parallel=true --persistent=false --listener=org.apache.geode.internal.cache.wan.MyAsyncEventListener --id="
            + asyncEventQueueName)
        .statusIsSuccess();
    locator.waitUntilAsyncEventQueuesAreReadyOnExactlyThisManyServers(asyncEventQueueName, 1);

    gfsh.executeAndAssertThat("create region --type=PARTITION --name=" + regionName)
        .statusIsSuccess();
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + regionName, 1);

    // Associate the async-event-queue
    gfsh.executeAndAssertThat(
        "alter region --name=" + regionName + " --async-event-queue-id=" + asyncEventQueueName)
        .statusIsSuccess().containsOutput("server-1", "OK", "Region " + regionName + " altered");

    // Check the cluster configuration service.
    locator.invoke(() -> {
      InternalLocator internalLocator = ClusterStartupRule.getLocator();
      assertThat(internalLocator).isNotNull();
      CacheConfig config =
          internalLocator.getConfigurationPersistenceService().getCacheConfig("cluster");

      RegionConfig regionConfig = find(config.getRegions(), regionName);
      assertThat(regionConfig).isNotNull();
      assertThat(regionConfig.getRegionAttributes()).isNotNull();
      assertThat(regionConfig.getRegionAttributes().getAsyncEventQueueIds()).isNotEmpty()
          .isEqualTo(asyncEventQueueName);
    });
  }

  @Test
  public void alterNonColocatedPartitionRegionWithTheSameParallelAsynchronousEventQueueShouldThrowExceptionAndPreventTheClusterConfigurationServiceFromBeingUpdated() {
    addIgnoredException(
        "Non colocated regions (.*) cannot have the same parallel async event queue id (.*) configured.");

    String asyncEventQueue = "asyncEventQueue";
    String region1Name = testName.getMethodName() + "1";
    String region2Name = testName.getMethodName() + "2";

    gfsh.executeAndAssertThat(
        "create async-event-queue --parallel=true --persistent=false --listener=org.apache.geode.internal.cache.wan.MyAsyncEventListener --id="
            + asyncEventQueue)
        .statusIsSuccess();
    locator.waitUntilAsyncEventQueuesAreReadyOnExactlyThisManyServers(asyncEventQueue, 1);

    gfsh.executeAndAssertThat("create region --type=PARTITION --name=" + region1Name)
        .statusIsSuccess();
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + region1Name, 1);

    gfsh.executeAndAssertThat("create region --type=PARTITION --name=" + region2Name)
        .statusIsSuccess();
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + region2Name, 1);

    // Associate the async-event-queue to both regions (second one should fail because they are not
    // co-located)
    gfsh.executeAndAssertThat(
        "alter region --name=" + region1Name + " --async-event-queue-id=" + asyncEventQueue)
        .statusIsSuccess().containsOutput("server-1", "OK", "Region " + region1Name + " altered");
    gfsh.executeAndAssertThat(
        "alter region --name=" + region2Name + " --async-event-queue-id=" + asyncEventQueue)
        .statusIsError().containsOutput("server-1", "ERROR",
            "Non colocated regions " + SEPARATOR + region2Name + ", " + SEPARATOR + region1Name
                + " cannot have the same parallel async event queue id " + asyncEventQueue
                + " configured.");

    // The exception must be thrown early in the initialization, so the change shouldn't be
    // persisted to the cluster configuration service for the second region.
    locator.invoke(() -> {
      InternalLocator internalLocator = ClusterStartupRule.getLocator();
      assertThat(internalLocator).isNotNull();
      CacheConfig config =
          internalLocator.getConfigurationPersistenceService().getCacheConfig("cluster");

      RegionConfig regionConfig = find(config.getRegions(), region1Name);
      assertThat(regionConfig).isNotNull();
      assertThat(regionConfig.getRegionAttributes()).isNotNull();
      assertThat(regionConfig.getRegionAttributes().getAsyncEventQueueIds())
          .isEqualTo(asyncEventQueue);

      RegionConfig region2Config = find(config.getRegions(), region2Name);
      assertThat(region2Config).isNotNull();
      assertThat(region2Config.getRegionAttributes()).isNotNull();
      assertThat(region2Config.getRegionAttributes().getAsyncEventQueueIds()).isBlank();
    });
  }

  @Test
  public void alterPartitionPersistentRegionWithParallelNonPersistentAsynchronousEventQueueShouldThrowExceptionAndPreventTheClusterConfigurationServiceFromBeingUpdated() {
    addIgnoredException(
        "Non persistent asynchronous event queue (.*) can not be attached to persistent region (.*)");
    String regionName = testName.getMethodName();
    String asyncEventQueueName = "asyncEventQueue";

    gfsh.executeAndAssertThat(
        "create async-event-queue --parallel=true --persistent=false --listener=org.apache.geode.internal.cache.wan.MyAsyncEventListener --id="
            + asyncEventQueueName)
        .statusIsSuccess();
    locator.waitUntilAsyncEventQueuesAreReadyOnExactlyThisManyServers(asyncEventQueueName, 1);

    gfsh.executeAndAssertThat("create region --type=PARTITION_PERSISTENT --name=" + regionName
        + " --disk-store=diskStore").statusIsSuccess();
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + regionName, 1);

    // Make sure that the next invocations also fail and that the changes are not persisted to the
    // cluster configuration service. See GEODE-6551.
    gfsh.executeAndAssertThat(
        "alter region --name=" + regionName + " --async-event-queue-id=" + asyncEventQueueName)
        .statusIsError()
        .containsOutput("server-1", "ERROR", "Non persistent asynchronous event queue "
            + asyncEventQueueName + " can not be attached to persistent region " + SEPARATOR
            + regionName);
    gfsh.executeAndAssertThat(
        "alter region --name=" + regionName + " --async-event-queue-id=" + asyncEventQueueName)
        .statusIsError()
        .containsOutput("server-1", "ERROR", "Non persistent asynchronous event queue "
            + asyncEventQueueName + " can not be attached to persistent region " + SEPARATOR
            + regionName);
    gfsh.executeAndAssertThat(
        "alter region --name=" + regionName + " --async-event-queue-id=" + asyncEventQueueName)
        .statusIsError()
        .containsOutput("server-1", "ERROR", "Non persistent asynchronous event queue "
            + asyncEventQueueName + " can not be attached to persistent region " + SEPARATOR
            + regionName);

    // The exception must be thrown early in the initialization, so the change shouldn't be
    // persisted to the cluster configuration service.
    locator.invoke(() -> {
      InternalLocator internalLocator = ClusterStartupRule.getLocator();
      assertThat(internalLocator).isNotNull();
      CacheConfig config =
          internalLocator.getConfigurationPersistenceService().getCacheConfig("cluster");

      RegionConfig regionConfig = find(config.getRegions(), regionName);
      assertThat(regionConfig).isNotNull();
      assertThat(regionConfig.getRegionAttributes()).isNotNull();
      assertThat(regionConfig.getRegionAttributes().getAsyncEventQueueIds()).isBlank();
    });
  }

  @Test
  public void alterPartitionRegionWithParallelGatewaySenderShouldPersistTheChangesIntoTheClusterConfigurationService() {
    addIgnoredException("could not get remote locator information");
    String regionName = testName.getMethodName();
    String gatewaySenderName = "gatewaySender";

    gfsh.executeAndAssertThat(
        "create gateway-sender --parallel=true --enable-persistence=false --remote-distributed-system-id=2 --id="
            + gatewaySenderName)
        .statusIsSuccess()
        .doesNotContainOutput("Did not complete waiting");

    gfsh.executeAndAssertThat("create region --type=PARTITION --name=" + regionName)
        .statusIsSuccess();
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + regionName, 1);

    // Associate the gateway-sender
    gfsh.executeAndAssertThat(
        "alter region --name=" + regionName + " --gateway-sender-id=" + gatewaySenderName)
        .statusIsSuccess().containsOutput("server-1", "OK", "Region " + regionName + " altered");

    // Check the cluster configuration service.
    locator.invoke(() -> {
      InternalLocator internalLocator = ClusterStartupRule.getLocator();
      assertThat(internalLocator).isNotNull();
      CacheConfig config =
          internalLocator.getConfigurationPersistenceService().getCacheConfig("cluster");

      RegionConfig regionConfig = find(config.getRegions(), regionName);
      assertThat(regionConfig).isNotNull();
      assertThat(regionConfig.getRegionAttributes()).isNotNull();
      assertThat(regionConfig.getRegionAttributes().getGatewaySenderIds()).isNotEmpty()
          .isEqualTo(gatewaySenderName);
    });
  }

  @Test
  public void alterNonColocatedPartitionRegionWithTheSameParallelGatewaySenderShouldThrowExceptionAndPreventTheClusterConfigurationServiceFromBeingUpdated() {
    addIgnoredException("could not get remote locator information");
    addIgnoredException(
        "Non colocated regions (.*) cannot have the same parallel gateway sender id (.*) configured.");

    String gatewaySenderName = "gatewaySender";
    String region1Name = testName.getMethodName() + "1";
    String region2Name = testName.getMethodName() + "2";

    gfsh.executeAndAssertThat(
        "create gateway-sender --parallel=true --enable-persistence=false --remote-distributed-system-id=2 --id="
            + gatewaySenderName)
        .statusIsSuccess()
        .doesNotContainOutput("Did not complete waiting");

    gfsh.executeAndAssertThat("create region --type=PARTITION --name=" + region1Name)
        .statusIsSuccess();
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + region1Name, 1);

    gfsh.executeAndAssertThat("create region --type=PARTITION --name=" + region2Name)
        .statusIsSuccess();
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + region2Name, 1);

    // Associate the gateway-sender to both regions (second one should fail because they are not
    // co-located)
    gfsh.executeAndAssertThat(
        "alter region --name=" + region1Name + " --gateway-sender-id=" + gatewaySenderName)
        .statusIsSuccess().containsOutput("server-1", "OK", "Region " + region1Name + " altered");
    gfsh.executeAndAssertThat(
        "alter region --name=" + region2Name + " --gateway-sender-id=" + gatewaySenderName)
        .statusIsError().containsOutput("server-1", "ERROR",
            "Non colocated regions " + SEPARATOR + region2Name + ", " + SEPARATOR + region1Name
                + " cannot have the same parallel gateway sender id " + gatewaySenderName
                + " configured.");

    // The exception must be thrown early in the initialization, so the change shouldn't be
    // persisted to the cluster configuration service for the second region.
    locator.invoke(() -> {
      InternalLocator internalLocator = ClusterStartupRule.getLocator();
      assertThat(internalLocator).isNotNull();
      CacheConfig config =
          internalLocator.getConfigurationPersistenceService().getCacheConfig("cluster");

      RegionConfig regionConfig = find(config.getRegions(), region1Name);
      assertThat(regionConfig).isNotNull();
      assertThat(regionConfig.getRegionAttributes()).isNotNull();
      assertThat(regionConfig.getRegionAttributes().getGatewaySenderIds())
          .isEqualTo(gatewaySenderName);

      RegionConfig region2Config = find(config.getRegions(), region2Name);
      assertThat(region2Config).isNotNull();
      assertThat(region2Config.getRegionAttributes()).isNotNull();
      assertThat(region2Config.getRegionAttributes().getGatewaySenderIds()).isBlank();
    });
  }

  @Test
  public void alterPartitionPersistentRegionWithParallelNonPersistentGatewaySenderShouldThrowExceptionAndPreventTheClusterConfigurationServiceFromBeingUpdated() {
    addIgnoredException("could not get remote locator information");
    addIgnoredException(
        "Non persistent gateway sender (.*) can not be attached to persistent region (.*)");
    String regionName = testName.getMethodName();
    String gatewaySenderName = "gatewaySender";

    gfsh.executeAndAssertThat(
        "create gateway-sender --parallel=true --enable-persistence=false --remote-distributed-system-id=2 --id="
            + gatewaySenderName)
        .statusIsSuccess()
        .doesNotContainOutput("Did not complete waiting");

    gfsh.executeAndAssertThat("create region --type=PARTITION_PERSISTENT --name=" + regionName
        + " --disk-store=diskStore").statusIsSuccess();
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + regionName, 1);

    // Make sure that the next invocations also fail and that the changes are not persisted to the
    // cluster configuration service. See GEODE-6551.
    gfsh.executeAndAssertThat(
        "alter region --name=" + regionName + " --gateway-sender-id=" + gatewaySenderName)
        .statusIsError().containsOutput("server-1", "ERROR", "Non persistent gateway sender "
            + gatewaySenderName + " can not be attached to persistent region " + SEPARATOR
            + regionName);
    gfsh.executeAndAssertThat(
        "alter region --name=" + regionName + " --gateway-sender-id=" + gatewaySenderName)
        .statusIsError().containsOutput("server-1", "ERROR", "Non persistent gateway sender "
            + gatewaySenderName + " can not be attached to persistent region " + SEPARATOR
            + regionName);
    gfsh.executeAndAssertThat(
        "alter region --name=" + regionName + " --gateway-sender-id=" + gatewaySenderName)
        .statusIsError().containsOutput("server-1", "ERROR", "Non persistent gateway sender "
            + gatewaySenderName + " can not be attached to persistent region " + SEPARATOR
            + regionName);

    // The exception must be thrown early in the initialization, so the change shouldn't be
    // persisted to the cluster configuration service.
    locator.invoke(() -> {
      InternalLocator internalLocator = ClusterStartupRule.getLocator();
      assertThat(internalLocator).isNotNull();
      CacheConfig config =
          internalLocator.getConfigurationPersistenceService().getCacheConfig("cluster");

      RegionConfig regionConfig = find(config.getRegions(), regionName);
      assertThat(regionConfig).isNotNull();
      assertThat(regionConfig.getRegionAttributes()).isNotNull();
      assertThat(regionConfig.getRegionAttributes().getGatewaySenderIds()).isBlank();
    });
  }

  @Test
  public void alterReplicateRegionWithParallelGatewaySenderShouldFailAndDoNotPersistChangesIntoTheClusterConfigurationService() {
    addIgnoredException(GatewaySenderConfigurationException.class);
    addIgnoredException("could not get remote locator information");
    String regionName = testName.getMethodName();
    String gatewaySenderId = testName.getMethodName() + "_parallelGatewaySender";

    CommandStringBuilder createSenderBuilder = new CommandStringBuilder("create gateway-sender")
        .addOption("id", gatewaySenderId)
        .addOption("parallel", "true")
        .addOption("enable-persistence", "false")
        .addOption("remote-distributed-system-id", "2");
    gfsh.executeAndAssertThat(createSenderBuilder.getCommandString())
        .statusIsSuccess().doesNotContainOutput("Did not complete waiting");

    CommandStringBuilder createRegionBuilder = new CommandStringBuilder("create region")
        .addOption("name", regionName)
        .addOption("type", RegionShortcut.REPLICATE.toString());
    gfsh.executeAndAssertThat(createRegionBuilder.getCommandString()).statusIsSuccess();
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + regionName, 1);

    // Associate the gateway-sender
    CommandStringBuilder alterRegionBuilder = new CommandStringBuilder("alter region")
        .addOption("name", regionName)
        .addOption("gateway-sender-id", gatewaySenderId);
    gfsh.executeAndAssertThat(alterRegionBuilder.getCommandString())
        .statusIsError()
        .containsOutput("server-1", "Parallel Gateway Sender " + gatewaySenderId
            + " can not be used with replicated region " + SEPARATOR + regionName);

    // Check the cluster configuration service.
    locator.invoke(() -> {
      InternalLocator internalLocator = ClusterStartupRule.getLocator();
      assertThat(internalLocator).isNotNull();
      CacheConfig config =
          internalLocator.getConfigurationPersistenceService().getCacheConfig("cluster");

      RegionConfig regionConfig = find(config.getRegions(), regionName);
      assertThat(regionConfig).isNotNull();
      assertThat(regionConfig.getRegionAttributes()).isNotNull();
      assertThat(regionConfig.getRegionAttributes().getGatewaySenderIds()).isNull();
    });
  }

  @Test
  public void alterReplicateRegionWithParallelAsynchronousEventQueueShouldFailAndDoNotPersistChangesIntoTheClusterConfigurationService() {
    addIgnoredException(AsyncEventQueueConfigurationException.class);
    String regionName = testName.getMethodName();
    String asyncEventQueueName = testName.getMethodName() + "_asyncEventQueue";

    CommandStringBuilder createAsyncQueueBuilder =
        new CommandStringBuilder("create async-event-queue")
            .addOption("id", asyncEventQueueName)
            .addOption("parallel", "true")
            .addOption("persistent", "false")
            .addOption("listener", MyAsyncEventListener.class.getCanonicalName());
    gfsh.executeAndAssertThat(createAsyncQueueBuilder.getCommandString()).statusIsSuccess();
    locator.waitUntilAsyncEventQueuesAreReadyOnExactlyThisManyServers(asyncEventQueueName, 1);

    CommandStringBuilder createRegionBuilder = new CommandStringBuilder("create region")
        .addOption("name", regionName)
        .addOption("type", RegionShortcut.REPLICATE.toString());
    gfsh.executeAndAssertThat(createRegionBuilder.getCommandString()).statusIsSuccess();
    locator.waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + regionName, 1);

    // Associate the async-event-queue
    CommandStringBuilder alterRegionBuilder = new CommandStringBuilder("alter region")
        .addOption("name", regionName)
        .addOption("async-event-queue-id", asyncEventQueueName);
    gfsh.executeAndAssertThat(alterRegionBuilder.getCommandString())
        .statusIsError()
        .containsOutput("server-1", "Parallel Async Event Queue " + asyncEventQueueName
            + " can not be used with replicated region " + SEPARATOR + regionName);

    // Check the cluster configuration service.
    locator.invoke(() -> {
      InternalLocator internalLocator = ClusterStartupRule.getLocator();
      assertThat(internalLocator).isNotNull();
      CacheConfig config =
          internalLocator.getConfigurationPersistenceService().getCacheConfig("cluster");

      RegionConfig regionConfig = find(config.getRegions(), regionName);
      assertThat(regionConfig).isNotNull();
      assertThat(regionConfig.getRegionAttributes()).isNotNull();
      assertThat(regionConfig.getRegionAttributes().getAsyncEventQueueIds()).isNull();
    });
  }
}


text:
%% USAGE: add lines below on the top of a script or inside of a function.
%% %% Configure the default parameters
%% configure;

%% Default Parameters
SECOND_UNIT = 1000;
UNIT = 30; VERBOSE = true; FRAME_PER_SEC = 10;

TRAIN_DATA_SIZE = 1000;
INTERVAL = 4;
WINDOW_SIZE = 2;
SKIP = 1;

%% Video Inforamtion
if ispc
    PATH_TO_PORORO3_VIDEO = 'd:\Movies\pororo_1.avi';
    PATH_TO_PORORO2_VIDEO = 'd:\Movies\Pororo_ENGLISH2_1.avi';
else
    PATH_TO_PORORO3_VIDEO = '/Users/Calvin/Documents/Projects/Pororo/Movies/pororo_3_1.avi';
    PATH_TO_PORORO2_VIDEO = '/Users/Calvin/Documents/Projects/Pororo/Movies/Pororo_2_1.avi';
end

%% Reading the whole video is very slow.
if ~exist('M', 'var')
    disp('Reading a video..');
    M = VideoReader(PATH_TO_PORORO3_VIDEO);
    disp('done.');
else
    disp('Reuse movie variable.');
end


text:
print "first"

print "second"<caret>


text:
FROM python:3.8-slim-buster
WORKDIR /home
COPY . .
RUN pip install -r requirements.txt

CMD ["python", "populate_script.py"]


text:
<?php

namespace Google\AdsApi\Dfp\v201705;

/**
 * This file was generated from WSDL. DO NOT EDIT.
 */
class MobileCarrierTargeting
{

    /**
     * @var boolean $isTargeted
     */
    protected $isTargeted = null;

    /**
     * @var \Google\AdsApi\Dfp\v201705\Technology[] $mobileCarriers
     */
    protected $mobileCarriers = null;

    /**
     * @param boolean $isTargeted
     * @param \Google\AdsApi\Dfp\v201705\Technology[] $mobileCarriers
     */
    public function __construct($isTargeted = null, array $mobileCarriers = null)
    {
      $this->isTargeted = $isTargeted;
      $this->mobileCarriers = $mobileCarriers;
    }

    /**
     * @return boolean
     */
    public function getIsTargeted()
    {
      return $this->isTargeted;
    }

    /**
     * @param boolean $isTargeted
     * @return \Google\AdsApi\Dfp\v201705\MobileCarrierTargeting
     */
    public function setIsTargeted($isTargeted)
    {
      $this->isTargeted = $isTargeted;
      return $this;
    }

    /**
     * @return \Google\AdsApi\Dfp\v201705\Technology[]
     */
    public function getMobileCarriers()
    {
      return $this->mobileCarriers;
    }

    /**
     * @param \Google\AdsApi\Dfp\v201705\Technology[] $mobileCarriers
     * @return \Google\AdsApi\Dfp\v201705\MobileCarrierTargeting
     */
    public function setMobileCarriers(array $mobileCarriers)
    {
      $this->mobileCarriers = $mobileCarriers;
      return $this;
    }

}


text:
require 'fileutils'
require 'timeout'

module LanguageHandler
  class BaseHandler
    DEFAULT_PLACEHOLDER_REPLACEMENT = 'SIDXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'.freeze
    LANG_CNAME = 'cname'.freeze
    PROCESS_TIMEOUT_EXIT_CODE = 120
# To set up environmental variables, see http://twil.io/secure
    TEST_TIMEOUT = Integer(ENV['TEST_TIMEOUT'] || 20)
    UNHANDLED_LANGUAGE_MESSAGE = 'File name does not specify a Twilio library' \
                                 ' version. Rename snippet as ' \
                                 '\'snippet.rb\' => \'snippet.5.x.rb\'' \
                                 ' to use v5 of ruby\'s Twilio ' \
                                 'library for example'.freeze

    ROOT_FOLDER = "#{__dir__}/../../../".freeze

    attr_reader :dependencies_directory, :dependencies

    def initialize(dependencies_directory = Dir.pwd, dependencies = [])
      @dependencies_directory = dependencies_directory
      @dependencies = dependencies
    end

    def replace_and_relocate(snippet, lang)
      input_file = snippet.get_input_file(lang)
      output_file = snippet.get_output_file(lang)
      content = text_with_replacements(File.open(input_file).read)
      write_content(content, output_file)
    end

    def test_snippet(snippet_model)
      @input_file = snippet_model.get_input_file(lang_cname)
      @test_output = snippet_model.test_output
      path = snippet_model.get_output_file(lang_cname)
      execute(path)
    end

    def self.run_before_test(_directory); end

    private

    def execute(file)
      ErrorLogger.instance.add_error(
        file,
        UNHANDLED_LANGUAGE_MESSAGE,
        ErrorLogger::WARNING
      )
      puts "warning [#{lang_cname}]".yellow
    end

    def execute_command
      raise 'This method must me implemented in sub classes'
    end

    def excluded_twiml_nodes
      []
    end

    def execute_with_suppressed_output(command, file)
      rout, wout = IO.pipe
      rerr, werr = IO.pipe
      pid = Process.spawn(command, out: wout, err: werr)
      exit_code = check_process_success(pid, command)
      wout.close
      werr.close
      output = rout.read
      success = exit_code.zero? && assert_output(output) && language_conditional(output)

      if success
        puts "success [#{lang_cname}]".green
      else
        puts "failure [#{lang_cname}]".red
        error_message = rerr.read

        error_message += test_output_report(output) if @test_output

        ErrorLogger.instance.add_error(file, error_message, ErrorLogger::ERROR)
      end

      rout.close
      rerr.close
      success
    end

    def test_output_report(output)
      [
        '',
        'diff:'.red,
        "  sample: #{@current_sample}",
        "  output: #{output.chomp}"
      ].join("\n")
    end

    def assert_output(output)
      return true unless @test_output
      File.open(xml_output_file, 'r') do |xml|
        XmlMatcher.match(@current_sample = xml.read, output, excluded_twiml_nodes)
      end
    rescue => err
      puts err.message
    end

    def xml_output_file
      "#{File.dirname(@input_file)}/output/" \
      "#{File.basename(@input_file).split('.').first}.twiml"
    end

    def check_process_success(pid, command)
      Timeout.timeout(TEST_TIMEOUT) do
        _id, status = Process.wait2(pid)
        return status.exitstatus
      end
    rescue Timeout::Error
      puts 'process not finished in time, killing it'
      puts(command)
      Process.kill('KILL', pid)
      return PROCESS_TIMEOUT_EXIT_CODE
    end

    def language_conditional(_output)
      true
    end

    def output_folder
      Model::TestSession::OUTPUT_FOLDER
    end

    def text_with_replacements(file_content)
      text_with_specific_replacements(file_content)
    end

    def text_with_specific_replacements(file_content)
      file_content
    end

    def write_content(content, output_file)
      dir_name  = File.dirname(output_file)
      file_name = File.basename(output_file)
      FileUtils.mkdir_p(dir_name) unless Dir.exist?(dir_name)
      new_file = File.new(output_file, 'w+')
      new_file.write(content)
      new_file.close
    end

    def bash_string_command(command)
      "bash -c '#{command}'"
    end

    def lang_cname
      self.class::LANG_CNAME
    end
  end
end


text:
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You 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.
-->

NOAA GHCN-Daily Benchmark
=====================

# Introduction

The NOAA has hosted DAILY GLOBAL HISTORICAL CLIMATOLOGY NETWORK (GHCN-DAILY)
.dat files. Weather.gov has an RSS/XML feed that gives current weather sensor
readings. Using the RSS feed as a template, the GHCN-DAILY historical
information is used to generate past RSS feed XML documents. The process allows
testing on a large set of information with out having to continually monitor
the weather.gov site for all the weather details for years.

# Detailed Description

Detailed GHDN-DAILY information:
<http://www1.ncdc.noaa.gov/pub/data/ghcn/daily/readme.txt>

# Folders

 * conf
 * other_systems
 * queries
 * scripts


text:
class RedList
  attr_reader :key

  def self.redis
    @redis ||= Red.new
  end

  def self.get(key)
    redis.execute_with_uncertainty([]) do
      redis.lrange(key, 0, -1).map(&:to_i)
    end
  end

  def self.get_strings(key)
    redis.execute_with_uncertainty([]) do
      redis.lrange(key, 0, -1)
    end
  end

  def self.add(key, value)
    redis.execute_with_uncertainty(false) do
      redis.lpush(key, value)
    end
  end

  def self.remove(key, value, occurrences = 0)
    redis.execute_with_uncertainty(false) do
      redis.lrem(key, occurrences, value)
    end
  end

  def self.count(key, value)
    get(key).count(value)
  end

  def self.total_size(key)
    get(key).count
  end

  def self.trim_to(key, amount)
    redis.execute_with_uncertainty(false) do
      redis.ltrim(key, 0, (amount - 1))
    end
  end

  def self.pop(key)
    redis.execute_with_uncertainty(false) do
      redis.rpop(key)
    end
  end

  def initialize(key)
    @key = key
  end

  def add(value)
    self.class.add(@key, value)
  end

  def remove(value)
    self.class.remove(@key, value)
  end

  def value
    self.class.get(@key)
  end
end


text:
<?php

declare(strict_types=1);

namespace Lisachenko\Protocol\FCGI\Record;

use Lisachenko\Protocol\FCGI;
use Lisachenko\Protocol\FCGI\Record;

/**
 * The Web server sends a FCGI_ABORT_REQUEST record to abort a request
 */
class AbortRequest extends Record
{
    public function __construct(int $requestId)
    {
        $this->type = FCGI::ABORT_REQUEST;
        $this->setRequestId($requestId);
    }
}


text:
import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {

  serverElements = [{type: 'server', name: 'TestServer', content: 'Just a test!'}];

  onServerAdded(serverData: {serverName: string, serverContent: string}) {
    this.serverElements.push({
      type: 'server',
      name: serverData.serverName,
      content: serverData.serverContent
    });
  }

  onBlueprintAdded(blueprintData: {serverName: string, serverContent: string}) {
    this.serverElements.push({
      type: 'blueprint',
      name: blueprintData.serverName,
      content: blueprintData.serverContent
    });
  }
}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using Moq;
using NUnit.Framework;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Infrastructure.PublishedCache;
using Umbraco.Cms.Infrastructure.PublishedCache.DataSource;
using Umbraco.Cms.Tests.Common.Builders;
using Umbraco.Cms.Tests.Common.Builders.Extensions;
using Umbraco.Cms.Tests.UnitTests.TestHelpers;
using Umbraco.Extensions;

namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Infrastructure.PublishedCache
{
    /// <summary>
    /// Unit tests for IPublishedContent and extensions
    /// </summary>
    [TestFixture]
    public class PublishedContentDataTableTests : PublishedSnapshotServiceTestBase
    {
        private readonly DataType[] _dataTypes = GetDefaultDataTypes();

        private static ContentType CreateContentType(string name, IDataType dataType, IReadOnlyDictionary<string, string> propertyAliasesAndNames)
        {
            var contentType = new ContentType(TestHelper.ShortStringHelper, -1)
            {
                Alias = name,
                Name = name,
                Key = Guid.NewGuid(),
                Id = name.GetHashCode()
            };
            foreach(var prop in propertyAliasesAndNames)
            {
                contentType.AddPropertyType(new PropertyType(TestHelper.ShortStringHelper, dataType, prop.Key)
                {
                    Name = prop.Value
                });
            }

            return contentType;
        }

        private IEnumerable<ContentNodeKit> CreateCache(
            bool createChildren,
            IDataType dataType,
            out ContentType[] contentTypes)
        {
            var result = new List<ContentNodeKit>();
            var valueCounter = 1;
            var parentId = 3;

            var properties = new Dictionary<string, string>
            {
                ["property1"] = "Property 1",
                ["property2"] = "Property 2",
            };

            ContentType parentContentType = CreateContentType("Parent", dataType, new Dictionary<string, string>(properties)
                {
                    ["property3"] = "Property 3"
                });
            ContentType childContentType = CreateContentType("Child", dataType, new Dictionary<string, string>(properties)
            {
                ["property4"] = "Property 4"
            });
            ContentType child2ContentType = CreateContentType("Child2", dataType, new Dictionary<string, string>(properties)
            {
                ["property4"] = "Property 4"
            });

            contentTypes = new[] { parentContentType, childContentType, child2ContentType };

            ContentData parentData = new ContentDataBuilder()
                .WithName("Page" + Guid.NewGuid())
                .WithProperties(new PropertyDataBuilder()
                    .WithPropertyData("property1", "value" + valueCounter)
                    .WithPropertyData("property2", "value" + (valueCounter + 1))
                    .WithPropertyData("property3", "value" + (valueCounter + 2))
                    .Build())
                .Build();

            ContentNodeKit parent = ContentNodeKitBuilder.CreateWithContent(
                parentContentType.Id,
                parentId, $"-1,{parentId}",
                draftData: parentData,
                publishedData: parentData);

            result.Add(parent);

            if (createChildren)
            {
                for (int i = 0; i < 3; i++)
                {
                    valueCounter += 3;
                    var childId = parentId + i + 1;

                    ContentData childData = new ContentDataBuilder()
                        .WithName("Page" + Guid.NewGuid())
                        .WithProperties(new PropertyDataBuilder()
                            .WithPropertyData("property1", "value" + valueCounter)
                            .WithPropertyData("property2", "value" + (valueCounter + 1))
                            .WithPropertyData("property4", "value" + (valueCounter + 2))
                            .Build())
                        .Build();

                    ContentNodeKit child = ContentNodeKitBuilder.CreateWithContent(
                        i > 0 ? childContentType.Id : child2ContentType.Id,
                        childId, $"-1,{parentId},{childId}", i,
                        draftData: childData,
                        publishedData: childData);

                    result.Add(child);
                }
            }

            return result;
        }

        [Test]
        public void To_DataTable()
        {
            var cache = CreateCache(true, _dataTypes[0], out ContentType[] contentTypes);
            InitializedCache(cache, contentTypes, dataTypes: _dataTypes);

            var snapshot = GetPublishedSnapshot();
            var root = snapshot.Content.GetAtRoot().First();

            var dt = root.ChildrenAsTable(
                VariationContextAccessor,
                ContentTypeService,
                MediaTypeService,
                Mock.Of<IMemberTypeService>(),
                Mock.Of<IPublishedUrlProvider>());

            Assert.AreEqual(11, dt.Columns.Count);
            Assert.AreEqual(3, dt.Rows.Count);
            Assert.AreEqual("value4", dt.Rows[0]["Property 1"]);
            Assert.AreEqual("value5", dt.Rows[0]["Property 2"]);
            Assert.AreEqual("value6", dt.Rows[0]["Property 4"]);
            Assert.AreEqual("value7", dt.Rows[1]["Property 1"]);
            Assert.AreEqual("value8", dt.Rows[1]["Property 2"]);
            Assert.AreEqual("value9", dt.Rows[1]["Property 4"]);
            Assert.AreEqual("value10", dt.Rows[2]["Property 1"]);
            Assert.AreEqual("value11", dt.Rows[2]["Property 2"]);
            Assert.AreEqual("value12", dt.Rows[2]["Property 4"]);
        }

        [Test]
        public void To_DataTable_With_Filter()
        {
            var cache = CreateCache(true, _dataTypes[0], out ContentType[] contentTypes);
            InitializedCache(cache, contentTypes, dataTypes: _dataTypes);

            var snapshot = GetPublishedSnapshot();
            var root = snapshot.Content.GetAtRoot().First();

            var dt = root.ChildrenAsTable(
                VariationContextAccessor,
                ContentTypeService,
                MediaTypeService,
                Mock.Of<IMemberTypeService>(),
                Mock.Of<IPublishedUrlProvider>(),
                "Child");

            Assert.AreEqual(11, dt.Columns.Count);
            Assert.AreEqual(2, dt.Rows.Count);
            Assert.AreEqual("value7", dt.Rows[0]["Property 1"]);
            Assert.AreEqual("value8", dt.Rows[0]["Property 2"]);
            Assert.AreEqual("value9", dt.Rows[0]["Property 4"]);
            Assert.AreEqual("value10", dt.Rows[1]["Property 1"]);
            Assert.AreEqual("value11", dt.Rows[1]["Property 2"]);
            Assert.AreEqual("value12", dt.Rows[1]["Property 4"]);
        }

        [Test]
        public void To_DataTable_No_Rows()
        {
            var cache = CreateCache(false, _dataTypes[0], out ContentType[] contentTypes);
            InitializedCache(cache, contentTypes, dataTypes: _dataTypes);

            var snapshot = GetPublishedSnapshot();
            var root = snapshot.Content.GetAtRoot().First();

            var dt = root.ChildrenAsTable(
                VariationContextAccessor,
                ContentTypeService,
                MediaTypeService,
                Mock.Of<IMemberTypeService>(),
                Mock.Of<IPublishedUrlProvider>());

            //will return an empty data table
            Assert.AreEqual(0, dt.Columns.Count);
            Assert.AreEqual(0, dt.Rows.Count);
        }

    }
}


text:
exports.baseController = "demo_base";
$.main.add($.content);
var navigation = Alloy.Globals.navigation;

// Bind the button
$.button.addEventListener("click", function() {
	navigation.open("demo_subview", {title: "Subview"});
});


text:
import $ from 'jquery';
import RSVP from 'RSVP';
import _ from 'underscore';
import Events from '../Events';
import filter from '../Filter';
import Test from './Test';
import eachSeries from '../utils/each-series';

export default Scenario;

function Scenario(feature, options) {
  _.extend(this, options);

  this.feature        = feature;
  this.World          = feature.World;
  this.steps          = [];
  this.given          = [];
  this.when           = [];
  this.then           = [];
  this.tests          = [];
  this.examples       = [];
  this.elapsedTime    = 0;

  this.result = {
    status: 'passed',
    elapsedTime: 0,
    assertions: 0,
    passed: 0,
    failed: 0,
    total: 0
  };
}

var fn = Scenario.prototype;

fn.applyFilters = function() {
  this.exclude = this.feature.exclude || filter.shouldFilterOut('scenario', this);
};

// fn.run = function runScenario() {
//   Events.trigger('beforeScenario', this);

//   var promise = new $.Deferred();

//   if ( ! this.examples.length) {
//     this.tests.push( new Test(this) );
//   } else {
//     this.examples.forEach( example => {
//       this.tests.push( new Test(this, example) );
//     });
//   }

//   eachSeries(this.tests, (test, callback) => {
//     test.run().always(callback);
//   }).then( () => {

//     this.tests.forEach( test => {

//      if (test.result.passed) {
//         this.result.passed++;
//       } else {
//         this.result.status = test.result.status;
//         this.result.failed++;
//       }
//       this.result.error = test.result.error;
//       this.elapsedTime += test.result.elapsedTime;
//       this.result.elapsedTime += test.result.elapsedTime;
//       this.result.assertions += test.result.assertions;
//       this.result.total++;
//     });
//     Events.trigger('afterScenario', this);
//     promise.resolve();
//   });

//   return promise;
// };

fn._x_run = function runScenario() {
  Events.trigger('beforeScenario', this);

  var deferred = RSVP.defer();

  if ( ! this.examples.length) {
    this.tests.push( new Test(this) );
  } else {
    this.examples.forEach( example => {
      this.tests.push( new Test(this, example) );
    });
  }

  eachSeries(this.tests, (test, callback) => {
    test.run().always(callback);
  }).then( () => {

    this.tests.forEach( test => {

     if (test.result.passed) {
        this.result.passed++;
      } else {
        this.result.status = test.result.status;
        this.result.failed++;
      }
      this.result.error = test.result.error;
      this.elapsedTime += test.result.elapsedTime;
      this.result.elapsedTime += test.result.elapsedTime;
      this.result.assertions += test.result.assertions;
      this.result.total++;
    });
    Events.trigger('afterScenario', this);
    deferred.resolve();
  });

  return deferred.promise;
};

fn.run = function runScenario() {
  Events.trigger('beforeScenario', this);

  if ( ! this.examples.length) {
    this.tests.push( new Test(this) );
  } else {
    this.examples.forEach( example => {
      this.tests.push( new Test(this, example) );
    });
  }

  return new RSVP.Promise(resolve => {
    eachSeries(this.tests, (test, callback) => {
      test.run().always(callback);
    }).then(this.afterTests.bind(this)).then(resolve);
  });
};

fn.afterTests = function() {
  this.tests.forEach( test => {

   if (test.result.passed) {
      this.result.passed++;
    } else {
      this.result.status = test.result.status;
      this.result.failed++;
    }
    this.result.error = test.result.error;
    this.elapsedTime += test.result.elapsedTime;
    this.result.elapsedTime += test.result.elapsedTime;
    this.result.assertions += test.result.assertions;
    this.result.total++;
  });

  Events.trigger('afterScenario', this);
};

fn.generateMissingStepDefinitions = function generateMissingStepDefinitions() {
  var definitions = [];

  this.steps.forEach(function(step) {
    if (step.result.status === 'missing') {
      definitions.push(step.generateDefinition());
    }
  });

  return definitions.join('\n');
};


text:
package com.adamroughton.concentus.util;

import java.util.concurrent.TimeUnit;

public interface Mutex<TObject> {

	/**
	 * Executes the provided runnable object with exclusive
	 * access to the object, releasing access when the runnable
	 * completes.
	 *
	 * @param delegate the delegate to execute
	 * @throws IllegalStateException if the Mutex is already owned by another
	 * thread
	 */
	void runAsOwner(OwnerDelegate<TObject> delegate);

	boolean isOwned();

	void waitForRelease() throws InterruptedException;

	void waitForRelease(long timeout, TimeUnit unit) throws InterruptedException;

	public interface OwnerDelegate<TObject> {
		void asOwner(TObject item);
	}
}


text:
"""Main Fabric deployment file for CloudBioLinux distribution.

This installs a standard set of useful biological applications on a remote
server. It is designed for bootstrapping a machine from scratch, as with new
Amazon EC2 instances.

Usage:

    fab -H hostname -i private_key_file install_biolinux

which will call into the 'install_biolinux' method below. See the README for
more examples. hostname can be a named host in ~/.ssh/config

Requires:
    Fabric http://docs.fabfile.org
    PyYAML http://pyyaml.org/wiki/PyYAMLDocumentation
"""
import os
import sys
from datetime import datetime

from fabric.api import *
from fabric.contrib.files import *
import yaml

# use local cloudbio directory
for to_remove in [p for p in sys.path if p.find("cloudbiolinux-") > 0]:
    sys.path.remove(to_remove)
sys.path.append(os.path.dirname(__file__))
import cloudbio

from cloudbio import libraries
from cloudbio.utils import _setup_logging, _configure_fabric_environment
from cloudbio.cloudman import _cleanup_ec2, _configure_cloudman
from cloudbio.cloudbiolinux import _cleanup_space, _freenx_scripts
from cloudbio.custom import shared
from cloudbio.package.shared import _yaml_to_packages
from cloudbio.package import brew, conda
from cloudbio.package import (_configure_and_install_native_packages,
                              _connect_native_packages, _print_shell_exports)
from cloudbio.package.nix import _setup_nix_sources, _nix_packages
from cloudbio.flavor.config import get_config_file
from cloudbio.config_management.puppet import _puppet_provision
from cloudbio.config_management.chef import _chef_provision, chef, _configure_chef

# ### Shared installation targets for all platforms

def install_biolinux(target=None, flavor=None):
    """Main entry point for installing BioLinux on a remote server.

    `flavor` allows customization of CloudBioLinux behavior. It can either
    be a flavor name that maps to a corresponding directory in contrib/flavor
    or the path to a custom directory. This can contain:

      - alternative package lists (main.yaml, packages.yaml, custom.yaml)
      - custom python code (nameflavor.py) that hooks into the build machinery

    `target` allows running only particular parts of the build process. Valid choices are:

      - packages     Install distro packages
      - custom       Install custom packages
      - chef_recipes Provision chef recipes
      - libraries    Install programming language libraries
      - post_install Setup CloudMan, FreeNX and other system services
      - cleanup      Remove downloaded files and prepare images for AMI builds
    """
    _setup_logging(env)
    time_start = _print_time_stats("Config", "start")
    _check_fabric_version()
    if env.ssh_config_path and os.path.isfile(os.path.expanduser(env.ssh_config_path)):
        env.use_ssh_config = True
    _configure_fabric_environment(env, flavor,
                                  ignore_distcheck=(target is not None
                                                    and target in ["libraries", "custom"]))
    env.logger.debug("Target is '%s'" % target)
    env.logger.debug("Flavor is '%s'" % flavor)
    _perform_install(target, flavor)
    _print_time_stats("Config", "end", time_start)
    if hasattr(env, "keep_isolated") and env.keep_isolated:
        _print_shell_exports(env)

def _perform_install(target=None, flavor=None, more_custom_add=None):
    """
    Once CBL/fabric environment is setup, this method actually
    runs the required installation procedures.

    See `install_biolinux` for full details on arguments
    `target` and `flavor`.
    """
    pkg_install, lib_install, custom_ignore, custom_add = _read_main_config()
    if more_custom_add:
        if custom_add is None:
            custom_add = {}
        for k, vs in more_custom_add.iteritems():
            if k in custom_add:
                custom_add[k].extend(vs)
            else:
                custom_add[k] = vs
    if target is None or target == "packages":
        env.keep_isolated = getattr(env, "keep_isolated", "false").lower() in ["true", "yes"]
        # Only touch system information if we're not an isolated installation
        if not env.keep_isolated:
            # can only install native packages if we have sudo access or are root
            if env.use_sudo or env.safe_run_output("whoami").strip() == "root":
                _configure_and_install_native_packages(env, pkg_install)
            else:
                _connect_native_packages(env, pkg_install, lib_install)
        if env.nixpkgs:  # ./doc/nixpkgs.md
            _setup_nix_sources()
            _nix_packages(pkg_install)
    if target is None or target == "custom":
        _custom_installs(pkg_install, custom_ignore, custom_add)
    if target is None or target == "chef_recipes":
        _provision_chef_recipes(pkg_install, custom_ignore)
    if target is None or target == "puppet_classes":
        _provision_puppet_classes(pkg_install, custom_ignore)
    if target is None or target == "brew":
        install_brew(flavor=flavor, automated=True)
    if target is None or target == "conda":
        install_conda(flavor=flavor, automated=True)
    if target is None or target == "libraries":
        _do_library_installs(lib_install)
    if target is None or target == "post_install":
        env.flavor.post_install()
        if "is_ec2_image" in env and env.is_ec2_image.upper() in ["TRUE", "YES"]:
            _freenx_scripts(env)
            if pkg_install is not None and 'cloudman' in pkg_install:
                _configure_cloudman(env)
    if target is None or target == "cleanup":
        if env.use_sudo:
            _cleanup_space(env)
        if "is_ec2_image" in env and env.is_ec2_image.upper() in ["TRUE", "YES"]:
            _cleanup_ec2(env)

def _print_time_stats(action, event, prev_time=None):
    """ A convenience method for displaying time event during configuration.

    :type action: string
    :param action: Indicates type of action (eg, Config, Lib install, Pkg install)

    :type event: string
    :param event: The monitoring event (eg, start, stop)

    :type prev_time: datetime
    :param prev_time: A timeststamp of a previous event. If provided, duration between
                      the time the method is called and the time stamp is included in
                      the printout

    :rtype: datetime
    :return: A datetime timestamp of when the method was called
    """
    time = datetime.utcnow()
    s = "{0} {1} time: {2}".format(action, event, time)
    if prev_time: s += "; duration: {0}".format(str(time-prev_time))
    env.logger.info(s)
    return time

def _check_fabric_version():
    """Checks for fabric version installed
    """
    version = env.version
    if int(version.split(".")[0]) < 1:
        raise NotImplementedError("Please install fabric version 1 or higher")

def _custom_installs(to_install, ignore=None, add=None):
    if not env.safe_exists(env.local_install) and env.local_install:
        env.safe_run("mkdir -p %s" % env.local_install)
    pkg_config = get_config_file(env, "custom.yaml").base
    packages, pkg_to_group = _yaml_to_packages(pkg_config, to_install)
    packages = [p for p in packages if ignore is None or p not in ignore]
    if add is not None:
        for key, vals in add.iteritems():
            for v in vals:
                pkg_to_group[v] = key
                packages.append(v)
    for p in env.flavor.rewrite_config_items("custom", packages):
        install_custom(p, True, pkg_to_group)

def _provision_chef_recipes(to_install, ignore=None):
    """
    Much like _custom_installs, read config file, determine what to install,
    and install it.
    """
    pkg_config = get_config_file(env, "chef_recipes.yaml").base
    packages, _ = _yaml_to_packages(pkg_config, to_install)
    packages = [p for p in packages if ignore is None or p not in ignore]
    recipes = [recipe for recipe in env.flavor.rewrite_config_items("chef_recipes", packages)]
    if recipes:  # Don't bother running chef if nothing to configure
        install_chef_recipe(recipes, True)

def _provision_puppet_classes(to_install, ignore=None):
    """
    Much like _custom_installs, read config file, determine what to install,
    and install it.
    """
    pkg_config = get_config_file(env, "puppet_classes.yaml").base
    packages, _ = _yaml_to_packages(pkg_config, to_install)
    packages = [p for p in packages if ignore is None or p not in ignore]
    classes = [recipe for recipe in env.flavor.rewrite_config_items("puppet_classes", packages)]
    if classes:  # Don't bother running chef if nothing to configure
        install_puppet_class(classes, True)

def install_chef_recipe(recipe, automated=False, flavor=None):
    """Install one or more chef recipes by name.

    Usage: fab [-i key] [-u user] -H host install_chef_recipe:recipe

    :type recipe:  string or list
    :param recipe: TODO

    :type automated:  bool
    :param automated: If set to True, the environment is not loaded.
    """
    _setup_logging(env)
    if not automated:
        _configure_fabric_environment(env, flavor)

    time_start = _print_time_stats("Chef provision for recipe(s) '{0}'".format(recipe), "start")
    _configure_chef(env, chef)
    recipes = recipe if isinstance(recipe, list) else [recipe]
    for recipe_to_add in recipes:
        chef.add_recipe(recipe_to_add)
    _chef_provision(env, recipes)
    _print_time_stats("Chef provision for recipe(s) '%s'" % recipe, "end", time_start)

def install_puppet_class(classes, automated=False, flavor=None):
    """Install one or more puppet classes by name.

    Usage: fab [-i key] [-u user] -H host install_puppet_class:class

    :type classes:  string or list
    :param classes: TODO

    :type automated:  bool
    :param automated: If set to True, the environment is not loaded.
    """
    _setup_logging(env)
    if not automated:
        _configure_fabric_environment(env, flavor)

    time_start = _print_time_stats("Puppet provision for class(es) '{0}'".format(classes), "start")
    classes = classes if isinstance(classes, list) else [classes]
    _puppet_provision(env, classes)
    _print_time_stats("Puppet provision for classes(s) '%s'" % classes, "end", time_start)

def install_custom(p, automated=False, pkg_to_group=None, flavor=None):
    """
    Install a single custom program or package by name.

    This method fetches program name from ``config/custom.yaml`` and delegates
    to a method in ``custom/*name*.py`` to proceed with the installation.
    Alternatively, if a program install method is defined in the appropriate
    package, it will be called directly (see param ``p``).

    Usage: fab [-i key] [-u user] -H host install_custom:program_name

    :type p:  string
    :param p: A name of the custom program to install. This has to be either a name
              that is listed in ``custom.yaml`` as a subordinate to a group name or a
              program name whose install method is defined in either ``cloudbio`` or
              ``custom`` packages
              (e.g., ``cloudbio/custom/cloudman.py -> install_cloudman``).

    :type automated:  bool
    :param automated: If set to True, the environment is not loaded and reading of
                      the ``custom.yaml`` is skipped.
    """
    p = p.lower() # All packages listed in custom.yaml are in lower case
    if not automated:
        _setup_logging(env)
        _configure_fabric_environment(env, flavor, ignore_distcheck=True)
        pkg_config = get_config_file(env, "custom.yaml").base
        packages, pkg_to_group = _yaml_to_packages(pkg_config, None)
    time_start = _print_time_stats("Custom install for '{0}'".format(p), "start")
    fn = _custom_install_function(env, p, pkg_to_group)
    fn(env)
    ## TODO: Replace the previous 4 lines with the following one, barring
    ## objections. Slightly different behavior because pkg_to_group will be
    ## loaded regardless of automated if it is None, but IMO this shouldn't
    ## matter because the following steps look like they would fail if
    ## automated is True and pkg_to_group is None.
    # _install_custom(p, pkg_to_group)
    _print_time_stats("Custom install for '%s'" % p, "end", time_start)

def _install_custom(p, pkg_to_group=None):
    if pkg_to_group is None:
        pkg_config = get_config_file(env, "custom.yaml").base
        packages, pkg_to_group = _yaml_to_packages(pkg_config, None)
    fn = _custom_install_function(env, p, pkg_to_group)
    fn(env)

def install_brew(p=None, version=None, flavor=None, automated=False):
    """Top level access to homebrew/linuxbrew packages.
    p is a package name to install, or all configured packages if not specified.
    """
    if not automated:
        _setup_logging(env)
        _configure_fabric_environment(env, flavor, ignore_distcheck=True)
    if p is not None:
        if version:
            p = "%s==%s" % (p, version)
        brew.install_packages(env, packages=[p])
    else:
        pkg_install = _read_main_config()[0]
        brew.install_packages(env, to_install=pkg_install)

def install_conda(p=None, flavor=None, automated=False):
    if not automated:
        _setup_logging(env)
        _configure_fabric_environment(env, flavor, ignore_distcheck=True)
    if p is not None:
        conda.install_packages(env, packages=[p])
    else:
        pkg_install = _read_main_config()[0]
        conda.install_packages(env, to_install=pkg_install)

def _custom_install_function(env, p, pkg_to_group):
    """
    Find custom install function to execute based on package name to
    pkg_to_group dict.
    """
    try:
        # Allow direct calling of a program install method, even if the program
        # is not listed in the custom list (ie, not contained as a key value in
        # pkg_to_group). For an example, see 'install_cloudman' or use p=cloudman.
        mod_name = pkg_to_group[p] if p in pkg_to_group else p
        env.logger.debug("Importing module cloudbio.custom.%s" % mod_name)
        mod = __import__("cloudbio.custom.%s" % mod_name,
                         fromlist=["cloudbio", "custom"])
    except ImportError:
        raise ImportError("Need to write module cloudbio.custom.%s" %
                pkg_to_group[p])
    replace_chars = ["-"]
    try:
        for to_replace in replace_chars:
            p = p.replace(to_replace, "_")
        env.logger.debug("Looking for custom install function %s.install_%s"
            % (mod.__name__, p))
        fn = getattr(mod, "install_%s" % p)
    except AttributeError:
        raise ImportError("Need to write a install_%s function in custom.%s"
                % (p, pkg_to_group[p]))
    return fn

def _read_main_config():
    """Pull a list of groups to install based on our main configuration YAML.

    Reads 'main.yaml' and returns packages and libraries
    """
    yaml_file = get_config_file(env, "main.yaml").base
    with open(yaml_file) as in_handle:
        full_data = yaml.safe_load(in_handle)
    packages = full_data.get('packages', [])
    packages = env.flavor.rewrite_config_items("main_packages", packages)
    libraries = full_data.get('libraries', [])
    custom_ignore = full_data.get('custom_ignore', [])
    custom_add = full_data.get("custom_additional")
    if packages is None: packages = []
    if libraries is None: libraries = []
    if custom_ignore is None: custom_ignore = []
    env.logger.info("Meta-package information from {2}\n- Packages: {0}\n- Libraries: "
            "{1}".format(",".join(packages), ",".join(libraries), yaml_file))
    return packages, sorted(libraries), custom_ignore, custom_add

# ### Library specific installation code

def _python_library_installer(config):
    """Install python specific libraries using pip, conda and easy_install.
    Handles using isolated anaconda environments.
    """
    if shared._is_anaconda(env):
        conda_bin = shared._conda_cmd(env)
        for pname in env.flavor.rewrite_config_items("python", config.get("conda", [])):
            env.safe_run("{0} install --yes {1}".format(conda_bin, pname))
        cmd = env.safe_run
        with settings(warn_only=True):
            cmd("%s -U distribute" % os.path.join(os.path.dirname(conda_bin), "easy_install"))
    else:
        pip_bin = shared._pip_cmd(env)
        ei_bin = pip_bin.replace("pip", "easy_install")
        env.safe_sudo("%s -U pip" % ei_bin)
        with settings(warn_only=True):
            env.safe_sudo("%s -U distribute" % ei_bin)
        cmd = env.safe_sudo
    for pname in env.flavor.rewrite_config_items("python", config['pypi']):
        cmd("{0} install --upgrade {1} --allow-unverified {1} --allow-external {1}".format(shared._pip_cmd(env), pname)) # fixes problem with packages not being in pypi

def _ruby_library_installer(config):
    """Install ruby specific gems.
    """
    gem_ext = getattr(env, "ruby_version_ext", "")
    def _cur_gems():
        with settings(
                hide('warnings', 'running', 'stdout', 'stderr')):
            gem_info = env.safe_run_output("gem%s list --no-versions" % gem_ext)
        return [l.rstrip("\r") for l in gem_info.split("\n") if l.rstrip("\r")]
    installed = _cur_gems()
    for gem in env.flavor.rewrite_config_items("ruby", config['gems']):
        # update current gems only to check for new installs
        if gem not in installed:
            installed = _cur_gems()
        if gem in installed:
            env.safe_sudo("gem%s update %s" % (gem_ext, gem))
        else:
            env.safe_sudo("gem%s install %s" % (gem_ext, gem))

def _perl_library_installer(config):
    """Install perl libraries from CPAN with cpanminus.
    """
    with shared._make_tmp_dir() as tmp_dir:
        with cd(tmp_dir):
            env.safe_run("wget --no-check-certificate -O cpanm "
                         "https://raw.github.com/miyagawa/cpanminus/master/cpanm")
            env.safe_run("chmod a+rwx cpanm")
            env.safe_sudo("mv cpanm %s/bin" % env.system_install)
    sudo_str = "--sudo" if env.use_sudo else ""
    for lib in env.flavor.rewrite_config_items("perl", config['cpan']):
        # Need to hack stdin because of some problem with cpanminus script that
        # causes fabric to hang
        # http://agiletesting.blogspot.com/2010/03/getting-past-hung-remote-processes-in.html
        env.safe_run("cpanm %s --skip-installed --notest %s < /dev/null" % (sudo_str, lib))

def _haskell_library_installer(config):
    """Install haskell libraries using cabal.
    """
    run("cabal update")
    for lib in config["cabal"]:
        sudo_str = "--root-cmd=sudo" if env.use_sudo else ""
        env.safe_run("cabal install %s --global %s" % (sudo_str, lib))

lib_installers = {
    "r-libs" : libraries.r_library_installer,
    "python-libs" : _python_library_installer,
    "ruby-libs" : _ruby_library_installer,
    "perl-libs" : _perl_library_installer,
    "haskell-libs": _haskell_library_installer,
    }

def install_libraries(language):
    """High level target to install libraries for a specific language.
    """
    _setup_logging(env)
    _check_fabric_version()
    _configure_fabric_environment(env, ignore_distcheck=True)
    _do_library_installs(["%s-libs" % language])

def _do_library_installs(to_install):
    for iname in to_install:
        yaml_file = get_config_file(env, "%s.yaml" % iname).base
        with open(yaml_file) as in_handle:
            config = yaml.safe_load(in_handle)
        lib_installers[iname](config)