text:
#!/usr/bin/env bash

# Keep-alive: update existing `sudo` time stamp until the script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &

TITLECOLOR='\033[0;35m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color

cd "$(dirname "$BASH_SOURCE")" || {
  echo "Error getting current directory" >&2
  exit 1
}

# Installing homebrew
echo -e "${TITLECOLOR}"
echo "----------------------------------"
echo "Verifying Homebrew and dependencies"
echo "This might take a while to complete, as some formulae need to be installed from source"
echo "You'll need to provide administrator permission to install Brew"
echo "----------------------------------"
echo -e "${NC}"
if test ! "$(which brew)"; then
  # Ask for the administrator password upfront.
  echo "Installing homebrew..."
  xcode-select --install
  ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  export PATH="/usr/local/opt/python/libexec/bin:$PATH"
  export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
  sudo chown -R "$(whoami)" "$(brew --prefix)"/*
else
  echo -e "${GREEN}Homebrew already installed${NC}"
fi

sudo chown -R $(whoami) /usr/local/bin /usr/local/etc /usr/local/lib/pkgconfig /usr/local/sbin /usr/local/share /usr/local/share/doc /usr/local/share/man/man5 /usr/local/share/zsh /usr/local/lib/node_modules

chmod u+w /usr/local/bin /usr/local/etc /usr/local/lib/pkgconfig /usr/local/sbin /usr/local/share /usr/local/share/doc /usr/local/share/man/man5 /usr/local/share/zsh /usr/local/lib/node_modules

brew update

# Installing Git
echo -e "${TITLECOLOR}"
echo "----------------------------------"
echo "Installing Git"
echo "This might take a while to complete"
echo "----------------------------------"
echo -e "${NC}"
brew list git || brew install git

# Checking version/Installing Python
python3_installed() {
  local a b
  a=$(python3 --version 2>&1 | perl -pe 's/python *//i') ; b="3.7"
  [ "$( (echo "$a" ; echo "$b") | sort -V | head -1)" == "$b" ]
}
if python3_installed ; then
  echo "Detected Python >= 3.7"
else
  echo -e "${TITLECOLOR}"
  echo "----------------------------------"
  echo "Installing Python"
  echo "This might take a while to complete"
  echo "----------------------------------"
  echo -e "${NC}"
  # NOTE: this will actually installs the latest version (not the version we detected)
  # Potentially this can breaks things on the user machine.
  # Probably we should use pyenv to workaround this
	brew install python3
fi

# Installing NodeJS
# echo -e "${TITLECOLOR}"
# echo "----------------------------------"
# echo "Installing Node"
# echo "This might take a while to complete"
# echo "----------------------------------"
# echo -e "${NC}"
# brew list node || brew install node

# Cleaning up old versions
brew cleanup

# Downloading application
echo -e "${TITLECOLOR}"
echo "----------------------------------"
echo "Downloading updated application"
echo "----------------------------------"
echo -e "${NC}"
DIR="assetMG"
if [ -d "$DIR" ]; then
  ### Project exists, updating ###
  cd assetMG
  git pull
else
  ### Project didn't exist, cloning ###
  git clone https://github.com/google/assetMG.git
  cd assetMG
fi
# NOTE: we're now inside 'assetMG' folder

# Configurating virtual env
echo -e "${TITLECOLOR}"
echo "----------------------------------"
echo "Configuring Python environment"
echo "----------------------------------"
echo -e "${NC}"
python3 -m venv .venv
. .venv/bin/activate
# NOTE: after moving to python 3.8 these one line can be removed
export AC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

# Installing dependencies via pip
echo -e "${TITLECOLOR}"
echo "----------------------------------"
echo "Installing backend dependencies"
echo "----------------------------------"
echo -e "${NC}"
python3 -m pip install -r requirements.txt

# Installing frontend dependencies
# echo -e "${TITLECOLOR}"
# echo "----------------------------------"
# echo "Installing frontend dependencies"
# echo "----------------------------------"
# echo -e "${NC}"
# cd app/asset_browser/frontend
# npm install
# node_modules/.bin/ng build
# cd ../../..
# NOTE: we're now inside 'assetMG' folder

# Prepare the run script
mv scripts/AssetMG.command ./
chmod 777 scripts/AssetMG.command

echo "-----------------------------------------------------------------------------------"
echo -e "${GREEN} All done, to start the app please run AssetMG.command or python main.py${TITLECOLOR}"
echo "-----------------------------------------------------------------------------------"


text:
   /**
    *  Gets URI that identifies the test.
    *  @return uri identifier of test
    */
function getTargetURI() {
      return "http://www.w3.org/2001/DOM-Test-Suite/level1/html/HTMLObjectElement04";
   }

var docsLoaded = -1000000;
var builder = null;

//
//   This function is called by the testing framework before
//      running the test suite.
//
//   If there are no configuration exceptions, asynchronous
//        document loading is started.  Otherwise, the status
//        is set to complete and the exception is immediately
//        raised when entering the body of the test.
//
function setUpPage() {
   setUpPageStatus = 'running';
   try {
     //
     //   creates test document builder, may throw exception
     //
     builder = createConfiguredBuilder();

      docsLoaded = 0;

      var docRef = null;
      if (typeof(this.doc) != 'undefined') {
        docRef = this.doc;
      }
      docsLoaded += preload(docRef, "doc", "object");

       if (docsLoaded == 1) {
          setUpPageStatus = 'complete';
       }
    } catch(ex) {
    	catchInitializationError(builder, ex);
        setUpPageStatus = 'complete';
    }
}

//
//   This method is called on the completion of
//      each asychronous load started in setUpTests.
//
//   When every synchronous loaded document has completed,
//      the page status is changed which allows the
//      body of the test to be executed.
function loadComplete() {
    if (++docsLoaded == 1) {
        setUpPageStatus = 'complete';
    }
}

/**
*
    The archive attribute specifies a space-separated list of archives.

    Retrieve the archive attribute of the first OBJECT element and examine
    its value.

* @author NIST
* @author Mary Brady
* @see http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-html#ID-47783837
*/
function HTMLObjectElement04() {
   var success;
    if(checkInitialization(builder, "HTMLObjectElement04") != null) return;
    var nodeList;
      var testNode;
      var varchive;
      var doc;

      var docRef = null;
      if (typeof(this.doc) != 'undefined') {
        docRef = this.doc;
      }
      doc = load(docRef, "doc", "object");
      nodeList = doc.getElementsByTagName("object");
      assertSize("Asize",2,nodeList);
testNode = nodeList.item(0);
      varchive = testNode.archive;

      assertEquals("archiveLink","",varchive);

}

function runTest() {
   HTMLObjectElement04();
}

redpajama_set_name: RedPajamaGithub


text:
package org.apache.kafka.copycat.runtime.standalone;

import org.apache.kafka.copycat.connector.Connector;
import org.apache.kafka.copycat.connector.Task;
import org.apache.kafka.copycat.runtime.ConnectorConfig;
import org.apache.kafka.copycat.runtime.HerderConnectorContext;
import org.apache.kafka.copycat.runtime.TaskConfig;
import org.apache.kafka.copycat.runtime.Worker;
import org.apache.kafka.copycat.sink.SinkConnector;
import org.apache.kafka.copycat.sink.SinkTask;
import org.apache.kafka.copycat.source.SourceConnector;
import org.apache.kafka.copycat.source.SourceTask;
import org.apache.kafka.copycat.util.Callback;
import org.apache.kafka.copycat.util.ConnectorTaskId;
import org.apache.kafka.copycat.util.FutureCallback;
import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.api.easymock.annotation.Mock;
import org.powermock.modules.junit4.PowerMockRunner;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

@RunWith(PowerMockRunner.class)
public class StandaloneHerderTest {
    private static final String CONNECTOR_NAME = "test";
    private static final List<String> TOPICS_LIST = Arrays.asList("topic1", "topic2");
    private static final String TOPICS_LIST_STR = "topic1,topic2";
    private static final int DEFAULT_MAX_TASKS = 1;

    private StandaloneHerder herder;
    @Mock protected Worker worker;
    private Connector connector;
    @Mock protected Callback<String> createCallback;

    private Map<String, String> connectorProps;
    private Map<String, String> taskProps;

    @Before
    public void setup() {
        worker = PowerMock.createMock(Worker.class);
        herder = new StandaloneHerder(worker);

        connectorProps = new HashMap<>();
        connectorProps.put(ConnectorConfig.NAME_CONFIG, CONNECTOR_NAME);
        connectorProps.put(SinkConnector.TOPICS_CONFIG, TOPICS_LIST_STR);

        // These can be anything since connectors can pass along whatever they want.
        taskProps = new HashMap<>();
        taskProps.put("foo", "bar");
    }

    @Test
    public void testCreateSourceConnector() throws Exception {
        connector = PowerMock.createMock(BogusSourceConnector.class);
        expectAdd(BogusSourceConnector.class, BogusSourceTask.class, false);
        PowerMock.replayAll();

        herder.addConnector(connectorProps, createCallback);

        PowerMock.verifyAll();
    }

    @Test
    public void testCreateSinkConnector() throws Exception {
        connector = PowerMock.createMock(BogusSinkConnector.class);
        expectAdd(BogusSinkConnector.class, BogusSinkTask.class, true);

        PowerMock.replayAll();

        herder.addConnector(connectorProps, createCallback);

        PowerMock.verifyAll();
    }

    @Test
    public void testDestroyConnector() throws Exception {
        connector = PowerMock.createMock(BogusSourceConnector.class);
        expectAdd(BogusSourceConnector.class, BogusSourceTask.class, false);
        expectDestroy();
        PowerMock.replayAll();

        herder.addConnector(connectorProps, createCallback);
        FutureCallback<Void> futureCb = new FutureCallback<>(new Callback<Void>() {
            @Override
            public void onCompletion(Throwable error, Void result) {

            }
        });
        herder.deleteConnector(CONNECTOR_NAME, futureCb);
        futureCb.get(1000L, TimeUnit.MILLISECONDS);
        PowerMock.verifyAll();
    }

    @Test
    public void testCreateAndStop() throws Exception {
        connector = PowerMock.createMock(BogusSourceConnector.class);
        expectAdd(BogusSourceConnector.class, BogusSourceTask.class, false);
        // herder.stop() should stop any running connectors and tasks even if destroyConnector was not invoked
        expectStop();

        PowerMock.replayAll();

        herder.addConnector(connectorProps, createCallback);
        herder.stop();

        PowerMock.verifyAll();
    }

    private void expectAdd(Class<? extends Connector> connClass,
                           Class<? extends Task> taskClass,
                           boolean sink) throws Exception {
        connectorProps.put(ConnectorConfig.CONNECTOR_CLASS_CONFIG, connClass.getName());

        worker.addConnector(EasyMock.eq(new ConnectorConfig(connectorProps)), EasyMock.anyObject(HerderConnectorContext.class));
        PowerMock.expectLastCall();

        createCallback.onCompletion(null, CONNECTOR_NAME);
        PowerMock.expectLastCall();

        // And we should instantiate the tasks. For a sink task, we should see added properties for
        // the input topic partitions
        Map<String, String> generatedTaskProps = new HashMap<>();
        generatedTaskProps.putAll(taskProps);
        generatedTaskProps.put(TaskConfig.TASK_CLASS_CONFIG, taskClass.getName());
        if (sink)
            generatedTaskProps.put(SinkTask.TOPICS_CONFIG, TOPICS_LIST_STR);
        EasyMock.expect(worker.reconfigureConnectorTasks(CONNECTOR_NAME, DEFAULT_MAX_TASKS, TOPICS_LIST))
                .andReturn(Collections.singletonMap(new ConnectorTaskId(CONNECTOR_NAME, 0), generatedTaskProps));

        worker.addTask(new ConnectorTaskId(CONNECTOR_NAME, 0), new TaskConfig(generatedTaskProps));
        PowerMock.expectLastCall();
    }

    private void expectStop() {
        worker.stopTask(new ConnectorTaskId(CONNECTOR_NAME, 0));
        EasyMock.expectLastCall();
        worker.stopConnector(CONNECTOR_NAME);
        EasyMock.expectLastCall();
    }

    private void expectDestroy() {
        expectStop();
    }

    // We need to use a real class here due to some issue with mocking java.lang.Class
    private abstract class BogusSourceConnector extends SourceConnector {
    }

    private abstract class BogusSourceTask extends SourceTask {
    }

    private abstract class BogusSinkConnector extends SinkConnector {
    }

    private abstract class BogusSinkTask extends SourceTask {
    }

}


text:
declare function packageExport(x: number): string;
export = packageExport;

// @filename: index.ts
import("package").then(({default: foo}) => foo(42));


text: var a = new Array(10);


text:
import React, { useEffect } from "react";
import { useInView } from "react-intersection-observer";
import { motion, useAnimation } from "framer-motion";

interface FadeInWhenVisibleInterface {
  children: React.ReactNode;
  className?: string;
}

function FadeAndGrowInWhenVisible({ children, className } : FadeInWhenVisibleInterface) {
  const controls = useAnimation();
  const [ref, inView] = useInView();

  useEffect(() => {
    if (inView) {
      controls.start("visible");
    }
  }, [controls, inView]);

  return (
    <motion.div
      ref={ref}
      animate={controls}
      className={className}
      initial="hidden"
      transition={{ duration: 2.0,  type: "spring", bounce: 0.20 }}
      variants={{
        visible: { opacity: 1, scale: 1 },
        hidden: { opacity: 0, scale: 0,},
      }}
    >
      {children}
    </motion.div>
  );
}

export default FadeAndGrowInWhenVisible;


text:
#include <aws/autoscaling/model/DescribeScheduledActionsResult.h>
#include <aws/core/utils/xml/XmlSerializer.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/logging/LogMacros.h>

#include <utility>

using namespace Aws::AutoScaling::Model;
using namespace Aws::Utils::Xml;
using namespace Aws::Utils::Logging;
using namespace Aws::Utils;
using namespace Aws;

DescribeScheduledActionsResult::DescribeScheduledActionsResult()
{
}

DescribeScheduledActionsResult::DescribeScheduledActionsResult(const AmazonWebServiceResult<XmlDocument>& result)
{
  *this = result;
}

DescribeScheduledActionsResult& DescribeScheduledActionsResult::operator =(const AmazonWebServiceResult<XmlDocument>& result)
{
  const XmlDocument& xmlDocument = result.GetPayload();
  XmlNode rootNode = xmlDocument.GetRootElement();
  XmlNode resultNode = rootNode;
  if (rootNode.GetName() != "DescribeScheduledActionsResult")
  {
    resultNode = rootNode.FirstChild("DescribeScheduledActionsResult");
  }

  if(!resultNode.IsNull())
  {
    XmlNode scheduledUpdateGroupActionsNode = resultNode.FirstChild("ScheduledUpdateGroupActions");
    if(!scheduledUpdateGroupActionsNode.IsNull())
    {
      XmlNode scheduledUpdateGroupActionsMember = scheduledUpdateGroupActionsNode.FirstChild("member");
      while(!scheduledUpdateGroupActionsMember.IsNull())
      {
        m_scheduledUpdateGroupActions.push_back(scheduledUpdateGroupActionsMember);
        scheduledUpdateGroupActionsMember = scheduledUpdateGroupActionsMember.NextNode("member");
      }

    }
    XmlNode nextTokenNode = resultNode.FirstChild("NextToken");
    if(!nextTokenNode.IsNull())
    {
      m_nextToken = StringUtils::Trim(nextTokenNode.GetText().c_str());
    }
  }

  XmlNode responseMetadataNode = rootNode.FirstChild("ResponseMetadata");
  m_responseMetadata = responseMetadataNode;
  AWS_LOGSTREAM_DEBUG("Aws::AutoScaling::Model::DescribeScheduledActionsResult", "x-amzn-request-id: " << m_responseMetadata.GetRequestId() );

  return *this;
}


text:
package org.apache.ecs.storage;

public class NoSuchObjectException extends Exception
{

    public NoSuchObjectException()
    {
        super("No such object found.");
    }
}


text:
import {ChildComponent} from "./child.component";
import {AfterViewInit, Component, QueryList, ViewChild, ViewChildren} from "@angular/core";
@Component({
  selector: 'app-root',
  template: `

Parent

    <child name= "John" #child1></child>

    <child name= "Mary" #child2></child>

    <button (click) = "child2.greet()">Invoke greet() on child 2</button>

    <button (click)="greetAllChildren()">Invoke greet() on both children</button>
  `
})
export class AppComponent implements AfterViewInit {
  @ViewChild('child1', { static: true })
  firstChild: ChildComponent;  // reference to one child

  @ViewChildren(ChildComponent)
  allChildren: QueryList<ChildComponent>; // reference to all instances of ChildComponent

  ngAfterViewInit() {
    this.firstChild.greet();
  }

  greetAllChildren(){
     this.allChildren.forEach(child => child.greet());
  }
}


text:
import { NgModule } from '@angular/core';
import { IonicModule } from 'ionic-angular';
import { ComponentsModule } from '../components';
import { ErrorComponentModule } from '../components/error/error.module';
import { FooterComponentModule } from '../components/footer/footer.module';
import { HeadNavComponentModule } from '../components/head-nav/head-nav.module';
import { LatestBlocksComponentModule } from '../components/latest-blocks/latest-blocks.module';
import { BlocksPageModule } from '../pages/blocks/blocks.module';
import { BroadcastTxPageModule } from './broadcast-tx/broadcast-tx.module';
import { HomePageModule } from './home/home.module';

@NgModule({
  declarations: [],
  imports: [
    IonicModule,
    ComponentsModule,
    BlocksPageModule,
    BroadcastTxPageModule,
    HomePageModule,
    FooterComponentModule,
    HeadNavComponentModule,
    LatestBlocksComponentModule,
    ErrorComponentModule
  ],
  entryComponents: [],
  providers: []
})
export class PagesModule {}


text:
package com.bq.corbel.oauth.service;

import static org.fest.assertions.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;

import org.junit.Before;
import org.junit.Test;

import com.bq.corbel.oauth.model.Client;
import com.bq.corbel.oauth.repository.ClientRepository;

/**
 * @author Rubén Carrasco
 *
 */
public class DefaultClientServiceTest {

    private static final String TEST_REDIRECT_URI = "http://example.org?a=b#frag";
    private static final String TEST_REDIRECT_URI2 = "http://example.org/user?a=b#frag";
    private static final String TEST_REDIRECT_URI_REGEX = "http://example.org/*.*";
    private static final String TEST_CLIENT_ID = "TEST_CLIENT";
    private static Client TEST_CLIENT;

    private ClientRepository clientRepository;
    private ClientService clientService;

    @Before
    public void setup() {
        clientRepository = mock(ClientRepository.class);
        TEST_CLIENT = new Client();
        TEST_CLIENT.setRedirectRegexp(TEST_REDIRECT_URI_REGEX);
        clientService = new DefaultClientService(clientRepository);
    }

    @Test
    public void testRegexp() {
        assertThat(clientService.verifyRedirectUri(TEST_REDIRECT_URI, TEST_CLIENT)).isTrue();
        assertThat(clientService.verifyRedirectUri(TEST_REDIRECT_URI2, TEST_CLIENT)).isTrue();
    }
}