text:
sudo apt-get install -y maven openjdk-6-jdk build-essential \
            ruby-dev zlib1g-dev realpath python-setuptools

base_dir=`dirname $0`/../..

if [ -z `which vagrant` ]; then
    echo "Installing vagrant..."
    wget https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.2_x86_64.deb
    sudo dpkg -i vagrant_1.7.2_x86_64.deb
    rm -f vagrant_1.7.2_x86_64.deb
fi

# Install necessary vagrant plugins
# Note: Do NOT install vagrant-cachier since it doesn't work on AWS and only
# adds log noise
vagrant_plugins="vagrant-aws vagrant-hostmanager"
existing=`vagrant plugin list`
for plugin in $vagrant_plugins; do
    echo $existing | grep $plugin > /dev/null
    if [ $? != 0 ]; then
        vagrant plugin install $plugin
    fi
done

# Create Vagrantfile.local as a convenience
if [ ! -e "$base_dir/Vagrantfile.local" ]; then
    cp $base_dir/aws/aws-example-Vagrantfile.local $base_dir/Vagrantfile.local
fi

gradle="gradle-2.2.1"
if [ -z `which gradle` ] && [ ! -d $base_dir/$gradle ]; then
    if [ ! -e $gradle-bin.zip ]; then
        wget https://services.gradle.org/distributions/$gradle-bin.zip
    fi
    unzip $gradle-bin.zip
    rm -rf $gradle-bin.zip
    mv $gradle $base_dir/$gradle
fi

# Ensure aws access keys are in the environment when we use a EC2 driver machine
LOCAL_HOSTNAME=$(hostname -d)
if [[ ${LOCAL_HOSTNAME} =~ .*\.compute\.internal ]]; then
  grep "AWS ACCESS KEYS" ~/.bashrc > /dev/null
  if [ $? != 0 ]; then
    echo "# --- AWS ACCESS KEYS ---" >> ~/.bashrc
    echo ". `realpath $base_dir/aws/aws-access-keys-commands`" >> ~/.bashrc
    echo "# -----------------------" >> ~/.bashrc
    source ~/.bashrc
  fi
fi


text:
'use strict';

// Load dependencies
const request = require('request');
const baseUrl = require('./base-url');
const headers = require('./headers');

const sendRequest = function (parameters, callback) {

  request(parameters, (error, response, body) => {

      if (error) {
        return callback(error);
      }

      let data = null;

      try {
        data = JSON.parse(body);
      }
      catch (error) {
        return callback(error);
      }

      if (data.error) {
        return callback(data.error);
      }

      return callback(null, data);
  });
};

exports.getByName = (artistName, callback) => {

  const requestParams = {
    baseUrl,
    headers,
    qs: {
      query: artistName,
      fmt: 'json'
    },
    uri: "artist"
  };

  return sendRequest(requestParams, callback);
};

exports.getById = (id, callback) => {

  const requestParams = {
    baseUrl,
    headers,
    qs: {
      inc: 'recordings',
      fmt: 'json'
    },
    uri: `artist/${id}`
  };

  return sendRequest(requestParams, callback);
};

exports.getReleaseCardinalityById = (id, callback) => {

  // http://musicbrainz.org/ws/2/release?artist=0383dadf-2a4e-4d10-a46a-e9e041da8eb3&fmt=json

  const requestParams = {
    baseUrl,
    headers,
    qs: {
      artist: id,
      fmt: 'json'
    },
    uri: `release`
  };

  return sendRequest(requestParams, (error, data) => {
    if (error) {
      return callback(error);
    }

    return callback(null, data["release-count"]);
  });
};

exports.getArtistNameById = (id, callback) => {

  // http://musicbrainz.org/ws/2/artist/0383dadf-2a4e-4d10-a46a-e9e041da8eb3?fmt=json

  const requestParams = {
    baseUrl,
    headers,
    qs: {
      fmt: 'json'
    },
    uri: `artist/${id}`
  };

  return sendRequest(requestParams, (error, data) => {
    if (error) {
      return callback(error);
    }

    return callback(null, data.name);
  });
};

redpajama_set_name: RedPajamaGithub


text:
package com.creactiviti.piper.core.task;

/**
 *
 * @author Arik Cohen
 * @since Apr 11, 2017
 */
public interface ControlTask extends Task {

  static final String TYPE_CANCEL = "cancel";

}


text:
<?php

namespace NCMF\DefaultBundle\Repository;

/**
 * SectionRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class SectionRepository extends \Doctrine\ORM\EntityRepository
{
}


text:
define(function (require) {
  var _ = require('lodash');
  var angular = require('angular');
  var rison = require('ui/utils/rison');
  var registry = require('plugins/kibana/settings/saved_object_registry');
  var objectViewHTML = require('plugins/kibana/settings/sections/objects/_view.html');

  require('ui/routes')
  .when('/settings/objects/:service/:id', {
    template: objectViewHTML
  });

  require('ui/modules').get('apps/settings')
  .directive('kbnSettingsObjectsView', function (kbnIndex, Notifier) {
    return {
      restrict: 'E',
      controller: function ($scope, $injector, $routeParams, $location, $window, $rootScope, es, Private) {
        var notify = new Notifier({ location: 'SavedObject view' });
        var castMappingType = Private(require('ui/index_patterns/_cast_mapping_type'));
        var serviceObj = registry.get($routeParams.service);
        var service = $injector.get(serviceObj.service);

        /**
         * Creates a field definition and pushes it to the memo stack. This function
         * is designed to be used in conjunction with _.reduce(). If the
         * values is plain object it will recurse through all the keys till it hits
         * a string, number or an array.
         *
         * @param {array} memo The stack of fields
         * @param {mixed} value The value of the field
         * @param {string} key The key of the field
         * @param {object} collection This is a reference the collection being reduced
         * @param {array} parents The parent keys to the field
         * @returns {array}
         */
        var createField = function (memo, val, key, collection, parents) {
          if (_.isArray(parents)) {
            parents.push(key);
          } else {
            parents = [key];
          }

          var field = { type: 'text', name: parents.join('.'), value: val };

          if (_.isString(field.value)) {
            try {
              field.value = angular.toJson(JSON.parse(field.value), true);
              field.type = 'json';
            } catch (err) {
              field.value = field.value;
            }
          } else if (_.isNumeric(field.value)) {
            field.type = 'number';
          } else if (_.isArray(field.value)) {
            field.type = 'array';
            field.value = angular.toJson(field.value, true);
          } else if (_.isBoolean(field.value)) {
            field.type = 'boolean';
            field.value = field.value;
          } else if (_.isPlainObject(field.value)) {
            // do something recursive
            return _.reduce(field.value, _.partialRight(createField, parents), memo);
          }

          memo.push(field);

          // once the field is added to the object you need to pop the parents
          // to remove it since we've hit the end of the branch.
          parents.pop();
          return memo;
        };

        var readObjectClass = function (fields, Class) {
          var fieldMap = _.indexBy(fields, 'name');

          _.forOwn(Class.mapping, function (esType, name) {
            if (fieldMap[name]) return;

            fields.push({
              name: name,
              type: (function () {
                switch (castMappingType(esType)) {
                  case 'string': return 'text';
                  case 'number': return 'number';
                  case 'boolean': return 'boolean';
                  default: return 'json';
                }
              }())
            });
          });

          if (Class.searchSource && !fieldMap['kibanaSavedObjectMeta.searchSourceJSON']) {
            fields.push({
              name: 'kibanaSavedObjectMeta.searchSourceJSON',
              type: 'json',
              value: '{}'
            });
          }
        };

        $scope.notFound = $routeParams.notFound;

        $scope.title = service.type;

        es.get({
          index: kbnIndex,
          type: service.type,
          id: $routeParams.id
        })
        .then(function (obj) {
          $scope.obj = obj;
          $scope.link = service.urlFor(obj._id);

          var fields =  _.reduce(obj._source, createField, []);
          if (service.Class) readObjectClass(fields, service.Class);
          $scope.fields = _.sortBy(fields, 'name');
        })
        .catch(notify.fatal);

        // This handles the validation of the Ace Editor. Since we don't have any
        // other hooks into the editors to tell us if the content is valid or not
        // we need to use the annotations to see if they have any errors. If they
        // do then we push the field.name to aceInvalidEditor variable.
        // Otherwise we remove it.
        var loadedEditors = [];
        $scope.aceInvalidEditors = [];

        $scope.aceLoaded = function (editor) {
          if (_.contains(loadedEditors, editor)) return;
          loadedEditors.push(editor);

          editor.$blockScrolling = Infinity;

          var session = editor.getSession();
          var fieldName = editor.container.id;

          session.setTabSize(2);
          session.setUseSoftTabs(true);
          session.on('changeAnnotation', function () {
            var annotations = session.getAnnotations();
            if (_.some(annotations, { type: 'error'})) {
              if (!_.contains($scope.aceInvalidEditors, fieldName)) {
                $scope.aceInvalidEditors.push(fieldName);
              }
            } else {
              $scope.aceInvalidEditors = _.without($scope.aceInvalidEditors, fieldName);
            }

            if ($rootScope.$$phase) $scope.$apply();
          });
        };

        $scope.cancel = function () {
          $window.history.back();
          return false;
        };

        /**
         * Deletes an object and sets the notification
         * @param {type} name description
         * @returns {type} description
         */
        $scope.delete = function () {
          es.delete({
            index: kbnIndex,
            type: service.type,
            id: $routeParams.id
          })
          .then(function (resp) {
            return redirectHandler('deleted');
          })
          .catch(notify.fatal);
        };

        $scope.submit = function () {
          var source = _.cloneDeep($scope.obj._source);

          _.each($scope.fields, function (field) {
            var value = field.value;

            if (field.type === 'number') {
              value = Number(field.value);
            }

            if (field.type === 'array') {
              value = JSON.parse(field.value);
            }

            _.set(source, field.name, value);
          });

          es.index({
            index: kbnIndex,
            type: service.type,
            id: $routeParams.id,
            body: source
          })
          .then(function (resp) {
            return redirectHandler('updated');
          })
          .catch(notify.fatal);
        };

        function redirectHandler(action) {
          return es.indices.refresh({
            index: kbnIndex
          })
          .then(function (resp) {
            var msg = 'You successfully ' + action + ' the "' + $scope.obj._source.title + '" ' + $scope.title.toLowerCase() + ' object';

            $location.path('/settings/objects').search({
              _a: rison.encode({
                tab: serviceObj.title
              })
            });
            notify.info(msg);
          });
        }
      }
    };
  });
});


text:
#include "StdAfx.h"

#include "Common/TextConfig.h"

#include "Defs.h"
#include "Common/UTFConvert.h"

static bool IsDelimitChar(char c)
{
  return (c == ' ' || c == 0x0A || c == 0x0D ||
      c == '\0' || c == '\t');
}

static AString GetIDString(const char *string, int &finishPos)
{
  AString result;
  for (finishPos = 0; true; finishPos++)
  {
    char c = string[finishPos];
    if (IsDelimitChar(c) || c == '=')
      return result;
    result += c;
  }
}

static bool WaitNextLine(const AString &string, int &pos)
{
  for (;pos < string.Length(); pos++)
    if (string[pos] == 0x0A)
      return true;
  return false;
}

static bool SkipSpaces(const AString &string, int &pos)
{
  for (;pos < string.Length(); pos++)
  {
    char c = string[pos];
    if (!IsDelimitChar(c))
    {
      if (c != ';')
        return true;
      if (!WaitNextLine(string, pos))
        return false;
    }
  }
  return false;
}

bool GetTextConfig(const AString &string, CObjectVector<CTextConfigPair> &pairs)
{
  pairs.Clear();
  int pos = 0;

  /////////////////////
  // read strings

  while (true)
  {
    if (!SkipSpaces(string, pos))
      break;
    CTextConfigPair pair;
    int finishPos;
    AString temp = GetIDString(((const char *)string) + pos, finishPos);
    if (!ConvertUTF8ToUnicode(temp, pair.ID))
      return false;
    if (finishPos == 0)
      return false;
    pos += finishPos;
    if (!SkipSpaces(string, pos))
      return false;
    if (string[pos] != '=')
      return false;
    pos++;
    if (!SkipSpaces(string, pos))
      return false;
    if (string[pos] != '\"')
      return false;
    pos++;
    AString message;
    while(true)
    {
      if (pos >= string.Length())
        return false;
      char c = string[pos++];
      if (c == '\"')
        break;
      if (c == '\\')
      {
        char c = string[pos++];
        switch(c)
        {
          case 'n':
            message += '\n';
            break;
          case 't':
            message += '\t';
            break;
          case '\\':
            message += '\\';
            break;
          case '\"':
            message += '\"';
            break;
          default:
            message += '\\';
            message += c;
            break;
        }
      }
      else
        message += c;
    }
    if (!ConvertUTF8ToUnicode(message, pair.String))
      return false;
    pairs.Add(pair);
  }
  return true;
}

int FindTextConfigItem(const CObjectVector<CTextConfigPair> &pairs, const UString &id)
{
  for (int  i = 0; i < pairs.Size(); i++)
    if (pairs[i].ID.Compare(id) == 0)
      return i;
  return -1;
}

UString GetTextConfigValue(const CObjectVector<CTextConfigPair> &pairs, const UString &id)
{
  int index = FindTextConfigItem(pairs, id);
  if (index < 0)
    return UString();
  return pairs[index].String;
}


text:
<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>TethysUiAngular2</title>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <!-- service worker -->
  <link rel="manifest" href="./assets/manifest.json">
  <script src="./assets/companion.js" data-service-worker="./assets/todo-service-worker.js"></script>
</head>
<body>
  <app-root>Loading...</app-root>
</body>
</html>


text:
<?php

namespace Predis;

use Predis\Command\CommandInterface;

/**
 * Defines the interface of a basic client class or abstraction that can send
 * commands to Redis.
 *
 * @author Daniele Alessandri <suppakilla@gmail.com>
 */
interface BasicClientInterface
{
    /**
     * Executes the specified Redis command.
     *
     * @param  CommandInterface $command Command instance.
     * @return mixed
     */
    public function executeCommand(CommandInterface $command);
}