text:
//
//  GTLCivicInfoPollingLocation.h
//

// ----------------------------------------------------------------------------
// NOTE: This file is generated from Google APIs Discovery Service.
// Service:
//   Google Civic Information API (civicinfo/v2)
// Description:
//   An API for accessing civic information.
// Documentation:
//   https://developers.google.com/civic-information
// Classes:
//   GTLCivicInfoPollingLocation (0 custom class methods, 9 custom properties)

#if GTL_BUILT_AS_FRAMEWORK
  #import "GTL/GTLObject.h"
#else
  #import "GTLObject.h"
#endif

@class GTLCivicInfoSimpleAddressType;
@class GTLCivicInfoSource;

// ----------------------------------------------------------------------------
//
//   GTLCivicInfoPollingLocation
//

// A location where a voter can vote. This may be an early vote site, an
// election day voting location, or a drop off location for a completed ballot.

@interface GTLCivicInfoPollingLocation : GTLObject

// The address of the location.
@property (nonatomic, retain) GTLCivicInfoSimpleAddressType *address;

// The last date that this early vote site or drop off location may be used.
// This field is not populated for polling locations.
@property (nonatomic, copy) NSString *endDate;

// An ID for this object. IDs may change in future requests and should not be
// cached. Access to this field requires special access that can be requested
// from the Request more link on the Quotas page.
// identifier property maps to 'id' in JSON (to avoid Objective C's 'id').
@property (nonatomic, copy) NSString *identifier;

// The name of the early vote site or drop off location. This field is not
// populated for polling locations.
@property (nonatomic, copy) NSString *name;

// Notes about this location (e.g. accessibility ramp or entrance to use).
@property (nonatomic, copy) NSString *notes;

// A description of when this location is open.
@property (nonatomic, copy) NSString *pollingHours;

// A list of sources for this location. If multiple sources are listed the data
// has been aggregated from those sources.
@property (nonatomic, retain) NSArray *sources;  // of GTLCivicInfoSource

// The first date that this early vote site or drop off location may be used.
// This field is not populated for polling locations.
@property (nonatomic, copy) NSString *startDate;

// The services provided by this early vote site or drop off location. This
// field is not populated for polling locations.
@property (nonatomic, copy) NSString *voterServices;

@end


text:
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.vcs.actions;

import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.colors.ColorKey;
import com.intellij.openapi.util.Couple;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.openapi.vcs.annotate.AnnotationSource;
import com.intellij.openapi.vcs.annotate.FileAnnotation;
import com.intellij.openapi.vcs.annotate.LineAnnotationAspect;
import com.intellij.openapi.vcs.annotate.TextAnnotationPresentation;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;

import java.awt.*;
import java.util.Map;
import java.util.function.Consumer;

/**
 * shown additionally only when merge
 *
 * @author Konstantin Bulenkov
 */
final class CurrentRevisionAnnotationFieldGutter extends AspectAnnotationFieldGutter implements Consumer<AnnotationSource> {
  // merge source showing is turned on
  private boolean myTurnedOn;

  CurrentRevisionAnnotationFieldGutter(FileAnnotation annotation,
                                       LineAnnotationAspect aspect,
                                       TextAnnotationPresentation highlighting,
                                       Couple<Map<VcsRevisionNumber, Color>> colorScheme) {
    super(annotation, aspect, highlighting, colorScheme);
  }

  @Override
  public ColorKey getColor(int line, Editor editor) {
    return AnnotationSource.LOCAL.getColor();
  }

  @Override
  public String getLineText(int line, Editor editor) {
    final String value = myAspect.getValue(line);
    if (String.valueOf(myAnnotation.getLineRevisionNumber(line)).equals(value)) {
      return "";
    }
    // shown in merge sources mode
    return myTurnedOn ? value : "";
  }

  @Override
  public String getToolTip(int line, Editor editor) {
    final String aspectTooltip = myAspect.getTooltipText(line);
    if (aspectTooltip != null) {
      return aspectTooltip;
    }
    final String text = getLineText(line, editor);
    return ((text == null) || (text.length() == 0)) ? "" : VcsBundle.message("annotation.original.revision.text", text);
  }

  @Override
  public void accept(AnnotationSource annotationSource) {
    myTurnedOn = annotationSource.showMerged();
  }
}

redpajama_set_name: RedPajamaGithub


text:
if [ $# -lt 1 ]; then
  echo "usage: $0 [deuscoin srcroot] build-test arguments..."
fi

killall -q deuscoin-cli
killall -q deuscoind

cd $1
shift

./autogen.sh
./configure
./qa/pull-tester/build-tests.sh "$@"


text:
from .views import send_message_all, send_message_to, send_message_location, send_message_event
from .views import get_activities, get_messages, get_messages_from, get_messages_from_all, get_notifications
from django.conf.urls import url

urlpatterns = [
    url(r'^send/message/all/$', send_message_all, name='send_message_all'),
    url(r'^send/message/to/(?P<employee_username>\w+)/$', send_message_to, name='send_message_to'),
    url(r'^send/message/location/(?P<location_id>\d+)/$', send_message_location, name='send_message_location'),
    url(r'^send/message/event/(?P<event_id>\d+)/$', send_message_event, name='send_message_event'),
    url(r'^get/activity/employee/(?P<employee_id>\d+)/all/$', get_activities, name='get_activities'),
    url(r'^get/message/employee/(?P<employee_id>\d+)/all/$', get_messages, name='get_messages'),
    url(r'^get/message/from/employee/all/$', get_messages_from_all, name='get_messages_from_all'),
    url(r'^get/message/from/employee/(?P<employee_id>\d+)/all/$', get_messages_from, name='get_messages_from'),
    url(r'^get/notification/employee/(?P<employee_id>\d+)/all/$', get_notifications, name='get_notifications'),
]


text:
package nl.sense_os.commonsense.main.client.states.edit;

import com.extjs.gxt.ui.client.event.EventType;

public class StateEditEvents {
    public static final EventType ShowEditor = new EventType();

    protected static final EventType InvokeMethodRequested = new EventType();
    protected static final EventType InvokeMethodComplete = new EventType();
    protected static final EventType InvokeMethodFailed = new EventType();
}


text:
package nif.tictactoe.model;

import java.util.Random;

import nif.tictactoe.BrainBase;

/**
 * @author: Fabrizio Niedda
 * @version: 1.0
 * @description: The brain for playing hard games versus the computer.
 */
public class HardBrain extends BrainBase {

	public HardBrain() {
		int random = new Random().nextInt(ImmitatorScheduler.getInstance().hasStrategies() ? 4 : 3);

		switch (random) {
		case 0:
			_strategy = new PokerBettingStrategy();
			break;
		case 1:
			_strategy = new ModerateBettingStrategy();
			break;
		case 2:
			_strategy = new AggressiveBettingStrategy();
			break;
		case 3:
			_strategy = ImmitatorScheduler.getInstance().getImmitatorBidStrategy();
			break;
		}
	}
}


text:
let path = require('path');
let webpack = require('webpack');
let production = process.env.NODE_ENV === 'production';
let CleanWebpackPlugin = require('clean-webpack-plugin');
let ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = function(env = {}) {
  const isProd = !!env.prod;
  const buildType = env.type;
  const devServer = !!env.devServer;

  console.log(isProd ? 'Production build' : 'Development build');
  console.log('Build type: ', buildType);

  const plugins = [
    new CleanWebpackPlugin(['dist/' + buildType], {
      root: path.resolve(__dirname, './'),
      verbose: true,
      dry: false
    })
  ];

  if (isProd && buildType !== 'server') {
    plugins.push(
      new webpack.optimize.UglifyJsPlugin({
        sourceMap: true,
        mangle: false,
        compress: {
          warnings: false, // Suppress uglification warnings
          sequences: true,
          dead_code: true,
          conditionals: true,
          booleans: true,
          unused: true,
          if_return: true,
          join_vars: true,
          drop_console: true
        }
      }));
  }

  let entry, target, rules = [];

  if (buildType === 'server') {
    entry = {server: ['./server/index.js']};
    target = 'node';

    rules = rules.concat([{
      test: /\.jsx?$/,
      exclude: /(node_modules)/,
      use: {
        loader: 'babel-loader',
      }
    }]);
  } else {
    entry = {client: ['babel-polyfill', './client/index.js']};
    target = 'web';

    rules = rules.concat([{
      test: /\.jsx?$/,
      exclude: /(pages|node_modules)/,
      use: {
        loader: 'babel-loader'
      }
    }, {
      test: /\.jsx?$/,
      include: /pages/,
      exclude: /node_modules/,
      use: [
        {loader: 'bundle-loader', options: {lazy: true}},
        {loader: 'babel-loader'}
      ]
    }]);
  }

  rules = rules.concat([{
    test: /.(png|jpe?g|woff(2)?|eot|ttf|svg|gif)$/,
    use: {loader: 'url-loader?limit=100000'}
  }, {
    test: /(\.s?css)$/,
    use: [
      {
        loader: 'style-loader',
      },
      {
        loader: 'css-loader',
        options: {
          modules: true,
          import: true,
          sourceMap: !isProd,
          getLocalIdent: (context, localIndentName, localName) => {
            return localName;
          },
          importLoaders: 1,
          localIdentName: '[hash:base64]-[name]-[local]'
        }
      },
      {
        loader: 'sass-loader',
        options: {
          import: true,
          sourceMap: !isProd,
          getLocalIdent: (context, localIndentName, localName) => {
            return localName;
          }
        }
      },
      {
        loader: 'postcss-loader'
      },
    ]
  }]);

  let config = {
    context: path.join(__dirname, '/src'),
    entry,
    output: {
      path: path.join(__dirname, '/dist/' + buildType),
      filename: 'index.js',
      chunkFilename: '[name]-[chunkhash].js',
      publicPath: devServer ? 'http://localhost:8080/static/' : '/static/',
    },
    devServer: {
      contentBase: path.resolve(__dirname, '/dist/' + buildType),
      inline: !isProd
    },
    stats: {
      colors: true,
      reasons: true,
      hash: false,
      modulesSort: 'name'
    },
    cache: true,
    module: {
      rules
    },
    resolve: {
      extensions: ['.js', '.jsx', '.json']
    },
    plugins: [
      new ExtractTextPlugin('/css/app.css')
    ],
    target
  };

  if (!isProd) {
    config.devtool = 'source-map';
  }

  return config;
};


text:
from django.forms.models import model_to_dict
from django.test.utils import override_settings

from cms.api import add_plugin
from cms.models import CMSPlugin, Placeholder, UserSettings
from cms.test_utils.project.placeholderapp.exceptions import PlaceholderHookException
from cms.test_utils.project.placeholderapp.models import Example1, CharPksExample
from cms.test_utils.testcases import CMSTestCase

class AppAdminTestCase(CMSTestCase):

    def setUp(self):
        self._obj = self._get_example_obj()

    def _add_plugin_to_placeholder(self, placeholder,
                                   plugin_type='LinkPlugin', language='en'):
        plugin_data = {
            'StylePlugin': {'tag_type': 'div'},
            'LinkPlugin': {'name': 'A Link', 'url': 'https://www.django-cms.org'},
            'PlaceholderPlugin': {'name': 'Content'},
        }
        plugin = add_plugin(
            placeholder,
            plugin_type,
            language,
            **plugin_data[plugin_type]
        )
        return plugin

    def _get_add_plugin_uri(self, plugin_type='LinkPlugin', language='en'):
        uri = self.get_add_plugin_uri(
            placeholder=self._obj.placeholder,
            plugin_type=plugin_type,
            language=language,
        )
        return uri

    def _get_example_obj(self):
        obj = Example1.objects.create(
            char_1='one',
            char_2='two',
            char_3='tree',
            char_4='four'
        )
        return obj

class AppAdminTest(AppAdminTestCase):
    placeholderconf = {'placeholder': {
        'limits': {
            'global': 2,
            'StylePlugin': 1,
        }
    }
    }

    def test_global_limit_on_plugin_add(self):
        """
        Ensures placeholder global plugin limit is respected
        when adding plugins to the placeholder.
        """
        superuser = self.get_superuser()
        endpoint = self._get_add_plugin_uri()

        with self.login_user_context(superuser):
            with override_settings(CMS_PLACEHOLDER_CONF=self.placeholderconf):
                data = {'name': 'A Link', 'url': 'https://www.django-cms.org'}
                response = self.client.post(endpoint, data)  # first
                self.assertEqual(response.status_code, 200)
                response = self.client.post(endpoint, data)  # second
                self.assertEqual(response.status_code, 200)
                response = self.client.post(endpoint, data)  # third
                self.assertEqual(response.status_code, 400)
                self.assertEqual(
                    response.content,
                    b"This placeholder already has the maximum number of plugins (2).",
                )

    def test_global_limit_on_plugin_move(self):
        """
        Ensures placeholder global plugin limit is respected
        when moving plugins to the placeholder.
        """
        superuser = self.get_superuser()
        source_placeholder = self._obj.placeholder
        target_placeholder = self._get_example_obj().placeholder
        endpoint = self.get_admin_url(Example1, 'move_plugin')

        plugin_1 = self._add_plugin_to_placeholder(source_placeholder)
        plugin_2 = self._add_plugin_to_placeholder(source_placeholder)
        plugin_3 = self._add_plugin_to_placeholder(source_placeholder)

        with self.login_user_context(superuser):
            with self.settings(CMS_PLACEHOLDER_CONF=self.placeholderconf):
                data = {
                    'plugin_id': plugin_1.pk,
                    'placeholder_id': target_placeholder.pk,
                    'plugin_parent': '',
                }
                response = self.client.post(endpoint, data)  # first
                self.assertEqual(response.status_code, 200)
                data = {
                    'plugin_id': plugin_2.pk,
                    'placeholder_id': target_placeholder.pk,
                    'plugin_parent': '',
                }
                response = self.client.post(endpoint, data)  # second
                self.assertEqual(response.status_code, 200)
                data = {
                    'plugin_id': plugin_3.pk,
                    'placeholder_id': target_placeholder.pk,
                    'plugin_parent': '',
                }
                response = self.client.post(endpoint, data)  # third
                self.assertEqual(response.status_code, 400)
                self.assertEqual(
                    response.content,
                    b"This placeholder already has the maximum number of plugins (2)."
                )

    def test_no_global_limit_check_same_placeholder_move(self):
        """
        Ensures no global limit exception is raised
        when moving plugins inside of a placeholder.
        """
        superuser = self.get_superuser()
        source_placeholder = self._obj.placeholder
        target_placeholder = source_placeholder
        endpoint = self.get_admin_url(Example1, 'move_plugin')

        plugin_1 = self._add_plugin_to_placeholder(source_placeholder)
        plugin_2 = self._add_plugin_to_placeholder(source_placeholder)

        with self.login_user_context(superuser):
            with self.settings(CMS_PLACEHOLDER_CONF=self.placeholderconf):
                data = {
                    'plugin_id': plugin_1.pk,
                    'placeholder_id': target_placeholder.pk,
                    'plugin_parent': '',
                    'plugin_order': 1,
                }
                response = self.client.post(endpoint, data)  # first
                self.assertEqual(response.status_code, 200)
                data = {
                    'plugin_id': plugin_2.pk,
                    'placeholder_id': target_placeholder.pk,
                    'plugin_parent': '',
                    'plugin_order': 1,
                }
                response = self.client.post(endpoint, data)  # second
                self.assertEqual(response.status_code, 200)

    def test_type_limit_on_plugin_add(self):
        """
        Ensures placeholder plugin type limit is respected
        when adding plugins to the placeholder.
        """
        superuser = self.get_superuser()
        endpoint = self._get_add_plugin_uri('StylePlugin')

        with self.login_user_context(superuser):
            with self.settings(CMS_PLACEHOLDER_CONF=self.placeholderconf):
                data = {'tag_type': 'div'}
                response = self.client.post(endpoint, data)  # first
                self.assertEqual(response.status_code, 200)
                response = self.client.post(endpoint, data)  # second
                self.assertEqual(response.status_code, 400)
                self.assertEqual(
                    response.content,
                    b"This placeholder already has the "
                    b"maximum number (1) of allowed Style plugins."
                )

    def test_type_limit_on_plugin_move(self):
        """
        Ensures placeholder plugin type limit is respected
        when moving plugins to the placeholder.
        """
        superuser = self.get_superuser()
        source_placeholder = self._obj.placeholder
        target_placeholder = self._get_example_obj().placeholder
        endpoint = self.get_admin_url(Example1, 'move_plugin')

        plugin_1 = self._add_plugin_to_placeholder(source_placeholder, 'StylePlugin')
        plugin_2 = self._add_plugin_to_placeholder(source_placeholder, 'StylePlugin')

        with self.login_user_context(superuser):
            with self.settings(CMS_PLACEHOLDER_CONF=self.placeholderconf):
                data = {
                    'plugin_id': plugin_1.pk,
                    'placeholder_id': target_placeholder.pk,
                    'plugin_parent': '',
                }
                response = self.client.post(endpoint, data)  # first
                self.assertEqual(response.status_code, 200)
                data = {
                    'plugin_id': plugin_2.pk,
                    'placeholder_id': target_placeholder.pk,
                    'plugin_parent': '',
                }
                response = self.client.post(endpoint, data)  # second
                self.assertEqual(response.status_code, 400)
                self.assertEqual(response.content,
                                 b"This placeholder already has the maximum number (1) of allowed Style plugins.")

    def test_no_type_limit_check_same_placeholder_move(self):
        """
        Ensures no plugin type limit exception is raised
        when moving plugins inside of a placeholder.
        """
        superuser = self.get_superuser()
        source_placeholder = self._obj.placeholder
        target_placeholder = source_placeholder
        endpoint = self.get_admin_url(Example1, 'move_plugin')

        plugin_1 = self._add_plugin_to_placeholder(source_placeholder, 'StylePlugin')

        with self.login_user_context(superuser):
            with self.settings(CMS_PLACEHOLDER_CONF=self.placeholderconf):
                data = {
                    'plugin_id': plugin_1.pk,
                    'placeholder_id': target_placeholder.pk,
                    'plugin_parent': '',
                    'plugin_order': 1,
                }
                response = self.client.post(endpoint, data)  # first
                self.assertEqual(response.status_code, 200)

    def test_placeholder_post_move_hook_resolve(self):
        """
        Ensure moving a plugin from placeholder A
        registered with admin A calls the move plugin hooks
        on the target placeholder's registered admin.
        """
        superuser = self.get_superuser()
        endpoint = self.get_admin_url(Example1, 'move_plugin')
        exception = PlaceholderHookException
        message = 'move plugin hook has been called.'

        example_1 = self._obj
        source_placeholder = example_1.placeholder
        plugin = self._add_plugin_to_placeholder(source_placeholder)

        example_2 = CharPksExample.objects.create(
            char_1='one',
            slug='two',
        )
        target_placeholder = example_2.placeholder_1

        with self.login_user_context(superuser):
            with self.assertRaisesMessage(exception, message):
                # move plugin to placeholder_2
                # this will cause the Example1 admin
                # to resolve the attached model/admin of the target placeholder
                # and call it's hook.
                data = {
                    'plugin_id': plugin.pk,
                    'placeholder_id': target_placeholder.pk,
                    'plugin_parent': '',
                }
                self.client.post(endpoint, data)

    def test_placeholder_post_copy_hook_resolve(self):
        """
        Ensure copying a plugin from placeholder A
        registered with admin A calls the copy plugin hooks
        on the target placeholder's registered admin.
        """
        superuser = self.get_superuser()
        endpoint = self.get_admin_url(Example1, 'copy_plugins')
        exception = PlaceholderHookException
        message = 'copy plugin hook has been called.'

        example_1 = self._obj
        source_placeholder = example_1.placeholder
        plugin = self._add_plugin_to_placeholder(source_placeholder)

        example_2 = CharPksExample.objects.create(
            char_1='one',
            slug='two',
        )
        target_placeholder = example_2.placeholder_1

        with self.login_user_context(superuser):
            with self.assertRaisesMessage(exception, message):
                # move plugin to placeholder_2
                # this will cause the Example1 admin
                # to resolve the attached model/admin of the target placeholder
                # and call it's hook.
                data = {
                    'source_language': plugin.language,
                    'source_placeholder_id': source_placeholder.pk,
                    'source_plugin_id': plugin.pk,
                    'target_language': plugin.language,
                    'target_placeholder_id': target_placeholder.pk,
                }
                self.client.post(endpoint, data)

class AppAdminPermissionsTest(AppAdminTestCase):

    def setUp(self):
        self._obj = self._get_example_obj()
        self._staff_user = self.get_staff_user_with_no_permissions()

    def test_user_can_add_plugin(self):
        """
        User can add a new plugin if he has change permissions
        on the model attached to the placeholder and he has
        add permissions on the plugin model.
        """
        staff_user = self._staff_user
        placeholder = self._obj.placeholder
        plugins = placeholder.get_plugins('en').filter(plugin_type='LinkPlugin')
        endpoint = self._get_add_plugin_uri()

        self.add_permission(staff_user, 'change_example1')
        self.add_permission(staff_user, 'add_link')

        with self.login_user_context(staff_user):
            data = {'name': 'A Link', 'url': 'https://www.django-cms.org'}
            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 200)
            self.assertEqual(plugins.count(), 1)

    def test_user_cant_add_plugin(self):
        """
        User can't add a new plugin if he does not have
        change permissions on the model attached to the placeholder
        and/or does not have add permissions on the plugin model.
        """
        staff_user = self._staff_user
        placeholder = self._obj.placeholder
        plugins = placeholder.get_plugins('en').filter(plugin_type='LinkPlugin')
        endpoint = self._get_add_plugin_uri()

        self.add_permission(staff_user, 'add_example1')
        self.add_permission(staff_user, 'delete_example1')
        self.add_permission(staff_user, 'add_link')

        with self.login_user_context(staff_user):
            data = {'name': 'A Link', 'url': 'https://www.django-cms.org'}
            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 403)
            self.assertEqual(plugins.count(), 0)

        self.add_permission(staff_user, 'change_example1')
        self.remove_permission(staff_user, 'add_link')

        with self.login_user_context(staff_user):
            data = {'name': 'A Link', 'url': 'https://www.django-cms.org'}
            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 403)
            self.assertEqual(plugins.count(), 0)

    def test_user_can_edit_plugin(self):
        """
        User can edit a plugin if he has change permissions
        on the model attached to the placeholder and he has
        change permissions on the plugin model.
        """
        staff_user = self._staff_user
        placeholder = self._obj.placeholder
        plugin = self._add_plugin_to_placeholder(placeholder)
        endpoint = self.get_admin_url(Example1, 'edit_plugin', plugin.pk)

        self.add_permission(staff_user, 'change_example1')
        self.add_permission(staff_user, 'change_link')

        with self.login_user_context(staff_user):
            data = model_to_dict(plugin, fields=['name', 'url'])
            data['name'] = 'A link 2'

            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 200)
            plugin.refresh_from_db()
            self.assertEqual(plugin.name, data['name'])

    def test_user_cant_edit_plugin(self):
        """
        User can't edit a plugin if he does not have
        change permissions on the model attached to the placeholder
        and/or does not have change permissions on the plugin model.
        """
        staff_user = self._staff_user
        placeholder = self._obj.placeholder
        plugin = self._add_plugin_to_placeholder(placeholder)
        endpoint = self.get_admin_url(Example1, 'edit_plugin', plugin.pk)

        self.add_permission(staff_user, 'add_example1')
        self.add_permission(staff_user, 'delete_example1')
        self.add_permission(staff_user, 'change_link')

        with self.login_user_context(staff_user):
            data = model_to_dict(plugin, fields=['name', 'url'])
            data['name'] = 'A link 2'

            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 403)
            plugin.refresh_from_db()
            self.assertNotEqual(plugin.name, data['name'])

        self.add_permission(staff_user, 'change_example1')
        self.remove_permission(staff_user, 'change_link')

        with self.login_user_context(staff_user):
            data = model_to_dict(plugin, fields=['name', 'url'])
            data['name'] = 'A link 2'

            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 403)
            plugin.refresh_from_db()
            self.assertNotEqual(plugin.name, data['name'])

    def test_user_can_delete_plugin(self):
        """
        User can delete a plugin if he has change permissions
        on the model attached to the placeholder and he has
        delete permissions on the plugin model.
        """
        staff_user = self._staff_user
        placeholder = self._obj.placeholder
        plugin = self._add_plugin_to_placeholder(placeholder)
        endpoint = self.get_admin_url(Example1, 'delete_plugin', plugin.pk)

        self.add_permission(staff_user, 'change_example1')
        self.add_permission(staff_user, 'delete_link')

        with self.login_user_context(staff_user):
            data = {'post': True}

            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 302)
            self.assertFalse(CMSPlugin.objects.filter(pk=plugin.pk).exists())

    def test_user_cant_delete_plugin(self):
        """
        User can't delete a plugin if he does not have
        change permissions on the model attached to the placeholder
        and/or does not have delete permissions on the plugin model.
        """
        staff_user = self._staff_user
        placeholder = self._obj.placeholder
        plugin = self._add_plugin_to_placeholder(placeholder)
        endpoint = self.get_admin_url(Example1, 'delete_plugin', plugin.pk)

        self.add_permission(staff_user, 'add_example1')
        self.add_permission(staff_user, 'delete_example1')
        self.add_permission(staff_user, 'delete_link')

        with self.login_user_context(staff_user):
            data = {'post': True}

            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 403)
            self.assertTrue(CMSPlugin.objects.filter(pk=plugin.pk).exists())

        self.add_permission(staff_user, 'change_example1')
        self.remove_permission(staff_user, 'delete_link')

        with self.login_user_context(staff_user):
            data = {'post': True}

            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 403)
            self.assertTrue(CMSPlugin.objects.filter(pk=plugin.pk).exists())

    def test_user_can_move_plugin(self):
        """
        User can move a plugin if he has change permissions
        on the model attached to the placeholder and he has
        change permissions on the plugin model.
        """
        staff_user = self._staff_user
        source_placeholder = self._obj.placeholder
        target_placeholder = self._get_example_obj().placeholder
        plugin = self._add_plugin_to_placeholder(source_placeholder)
        endpoint = self.get_admin_url(Example1, 'move_plugin')

        data = {
            'plugin_id': plugin.pk,
            'placeholder_id': target_placeholder.pk,
            'plugin_parent': '',
        }

        self.add_permission(staff_user, 'change_example1')
        self.add_permission(staff_user, 'change_link')

        with self.login_user_context(staff_user):
            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 200)
            self.assertTrue(target_placeholder.get_plugins('en').filter(pk=plugin.pk))
            self.assertFalse(source_placeholder.get_plugins('en').filter(pk=plugin.pk))

    def test_user_cant_move_plugin(self):
        """
        User can't move a plugin if he does not have
        change permissions on the model attached to the placeholder
        and/or does not have change permissions on the plugin model.
        """
        staff_user = self._staff_user
        source_placeholder = self._obj.placeholder
        target_placeholder = self._get_example_obj().placeholder
        plugin = self._add_plugin_to_placeholder(source_placeholder)
        endpoint = self.get_admin_url(Example1, 'move_plugin')

        data = {
            'plugin_id': plugin.pk,
            'placeholder_id': target_placeholder.pk,
            'plugin_parent': '',
        }

        self.add_permission(staff_user, 'add_example1')
        self.add_permission(staff_user, 'delete_example1')
        self.add_permission(staff_user, 'change_link')

        with self.login_user_context(staff_user):
            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 403)
            self.assertFalse(target_placeholder.get_plugins('en').filter(pk=plugin.pk))
            self.assertTrue(source_placeholder.get_plugins('en').filter(pk=plugin.pk))

        self.add_permission(staff_user, 'change_example1')
        self.remove_permission(staff_user, 'change_link')

        with self.login_user_context(staff_user):
            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 403)
            self.assertFalse(target_placeholder.get_plugins('en').filter(pk=plugin.pk))
            self.assertTrue(source_placeholder.get_plugins('en').filter(pk=plugin.pk))

    def test_user_can_copy_plugin(self):
        """
        User can copy a plugin if he has change permissions
        on the model attached to the placeholder and he has
        add permissions on the plugin model.
        """
        staff_user = self._staff_user
        placeholder = self._obj.placeholder
        plugin = self._add_plugin_to_placeholder(placeholder)
        endpoint = self.get_admin_url(Example1, 'copy_plugins')
        source_placeholder = plugin.placeholder
        target_placeholder = self._get_example_obj().placeholder

        data = {
            'source_plugin_id': plugin.pk,
            'source_placeholder_id': source_placeholder.pk,
            'source_language': plugin.language,
            'target_language': 'en',
            'target_placeholder_id': target_placeholder.pk,
        }

        self.add_permission(staff_user, 'change_example1')
        self.add_permission(staff_user, 'add_link')

        with self.login_user_context(staff_user):
            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 200)
            self.assertTrue(source_placeholder.get_plugins('en').filter(pk=plugin.pk).exists())
            self.assertTrue(
                target_placeholder
                .get_plugins('en')
                .filter(plugin_type=plugin.plugin_type)
                .exists()
            )

    def test_user_cant_copy_plugin(self):
        """
        User can't copy a plugin if he does not have
        change permissions on the model attached to the placeholder
        and/or does not have add permissions on the plugin model.
        """
        staff_user = self._staff_user
        placeholder = self._obj.placeholder
        plugin = self._add_plugin_to_placeholder(placeholder)
        endpoint = self.get_admin_url(Example1, 'copy_plugins')
        source_placeholder = plugin.placeholder
        target_placeholder = self._get_example_obj().placeholder

        data = {
            'source_plugin_id': plugin.pk,
            'source_placeholder_id': source_placeholder.pk,
            'source_language': plugin.language,
            'target_language': 'en',
            'target_placeholder_id': target_placeholder.pk,
        }

        self.add_permission(staff_user, 'add_example1')
        self.add_permission(staff_user, 'delete_example1')
        self.add_permission(staff_user, 'add_link')

        with self.login_user_context(staff_user):
            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 403)
            self.assertTrue(source_placeholder.get_plugins('en').filter(pk=plugin.pk).exists())
            self.assertFalse(
                target_placeholder
                .get_plugins('en')
                .filter(plugin_type=plugin.plugin_type)
                .exists()
            )

        self.add_permission(staff_user, 'change_example1')
        self.remove_permission(staff_user, 'add_link')

        with self.login_user_context(staff_user):
            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 403)
            self.assertTrue(source_placeholder.get_plugins('en').filter(pk=plugin.pk).exists())
            self.assertFalse(
                target_placeholder
                .get_plugins('en')
                .filter(plugin_type=plugin.plugin_type)
                .exists()
            )

    def test_user_can_clear_empty_placeholder(self):
        """
        User can clear a placeholder if he has change permissions
        on the model attached to the placeholder.
        """
        staff_user = self._staff_user
        placeholder = self._obj.placeholder
        endpoint = self.get_admin_url(Example1, 'clear_placeholder', placeholder.pk)

        self.add_permission(staff_user, 'change_example1')

        with self.login_user_context(staff_user):
            response = self.client.post(endpoint, {'test': 0})
            self.assertEqual(response.status_code, 302)

    def test_user_cant_clear_empty_placeholder(self):
        """
        User can't clear a placeholder if he does not have
        change permissions on the model attached to the placeholder.
        """
        staff_user = self._staff_user
        placeholder = self._obj.placeholder
        endpoint = self.get_admin_url(Example1, 'clear_placeholder', placeholder.pk)

        with self.login_user_context(staff_user):
            response = self.client.post(endpoint, {'test': 0})
            self.assertEqual(response.status_code, 403)

    def test_user_can_clear_non_empty_placeholder(self):
        """
        User can clear a placeholder with plugins if he has
        change permissions on the model attached to the placeholder
        and delete permissions on the plugin model.
        """
        staff_user = self._staff_user
        placeholder = self._obj.placeholder
        plugins = [
            self._add_plugin_to_placeholder(placeholder, 'StylePlugin'),
            self._add_plugin_to_placeholder(placeholder, 'LinkPlugin'),
        ]
        placeholder = plugins[0].placeholder
        endpoint = self.get_admin_url(Example1, 'clear_placeholder', placeholder.pk)

        self.add_permission(staff_user, 'delete_text')
        self.add_permission(staff_user, 'delete_link')
        self.add_permission(staff_user, 'change_example1')

        with self.login_user_context(staff_user):
            response = self.client.post(endpoint, {'test': 0})
            self.assertEqual(response.status_code, 302)
            self.assertEqual(placeholder.get_plugins('en').count(), 0)

    def test_user_cant_clear_non_empty_placeholder(self):
        """
        User can't clear a placeholder with plugins if he does not have
        change permissions on the model attached to the placeholder
        and/or does not have delete permissions on the plugin model.
        """
        staff_user = self._staff_user
        placeholder = self._obj.placeholder
        plugins = [
            self._add_plugin_to_placeholder(placeholder, 'StylePlugin'),
            self._add_plugin_to_placeholder(placeholder, 'LinkPlugin'),
        ]
        placeholder = plugins[0].placeholder
        endpoint = self.get_admin_url(Example1, 'clear_placeholder', placeholder.pk)

        self.add_permission(staff_user, 'delete_text')
        self.add_permission(staff_user, 'delete_link')

        with self.login_user_context(staff_user):
            response = self.client.post(endpoint, {'test': 0})
            self.assertEqual(response.status_code, 403)
            self.assertEqual(placeholder.get_plugins('en').count(), 2)

    def test_user_can_copy_placeholder_to_clipboard(self):
        """
        User can copy a placeholder to the clipboard
        if he has add permissions on the plugin models
        being copied.
        """
        staff_user = self._staff_user
        source_placeholder = self._obj.placeholder
        endpoint = self.get_admin_url(Example1, 'copy_plugins')

        self._add_plugin_to_placeholder(source_placeholder, 'StylePlugin')
        self._add_plugin_to_placeholder(source_placeholder, 'LinkPlugin')

        user_settings = UserSettings.objects.create(
            language="en",
            user=staff_user,
            clipboard=Placeholder.objects.create(),
        )

        self.add_permission(staff_user, 'add_link')
        self.add_permission(staff_user, 'add_style')

        # This is sadly required to copy the plugins into the clipboard
        # FIXME: https://github.com/divio/django-cms/issues/5488
        self.add_permission(staff_user, 'change_example1')

        # This are sadly required to alter the clipboard
        # FIXME: https://github.com/divio/django-cms/issues/5488
        self.add_permission(staff_user, 'change_usersettings')

        data = {
            'source_plugin_id': '',
            'source_placeholder_id': source_placeholder.pk,
            'source_language': 'en',
            'target_language': 'en',
            'target_placeholder_id': user_settings.clipboard.pk,
        }

        with self.login_user_context(staff_user):
            # Copy plugins into the clipboard
            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 200)

        clipboard_plugins = user_settings.clipboard.get_plugins()

        # assert the clipboard has a PlaceholderPlugin
        self.assertTrue(clipboard_plugins.filter(plugin_type='PlaceholderPlugin').exists())

        # assert three new plugins have been created
        # One for the PlaceholderPlugin and the other two
        # are the plugins being copied.
        self.assertEqual(len(clipboard_plugins), 1)

        placeholder_plugin = clipboard_plugins[0].get_plugin_instance()[0]
        ref_placeholder = placeholder_plugin.placeholder_ref

        # assert there's only two plugins in the clipboard
        self.assertEqual(ref_placeholder.get_plugins().count(), 2)

    def test_user_cant_copy_placeholder_to_clipboard(self):
        """
        User cant copy a placeholder to the clipboard if he does not
        have add permissions on the plugin models being copied.
        """
        staff_user = self._staff_user
        source_placeholder = self._obj.placeholder
        endpoint = self.get_admin_url(Example1, 'copy_plugins')

        self._add_plugin_to_placeholder(source_placeholder, 'StylePlugin')
        self._add_plugin_to_placeholder(source_placeholder, 'LinkPlugin')

        user_settings = UserSettings.objects.create(
            language="en",
            user=staff_user,
            clipboard=Placeholder.objects.create(),
        )

        self.add_permission(staff_user, 'change_link')
        self.add_permission(staff_user, 'delete_link')
        self.add_permission(staff_user, 'change_style')
        self.add_permission(staff_user, 'delete_style')

        # This is sadly required to copy the plugins
        # FIXME: https://github.com/divio/django-cms/issues/5488
        self.add_permission(staff_user, 'change_example1')

        # This are sadly required to alter the clipboard
        # FIXME: https://github.com/divio/django-cms/issues/5488
        self.add_permission(staff_user, 'change_usersettings')

        data = {
            'source_plugin_id': '',
            'source_placeholder_id': source_placeholder.pk,
            'source_language': 'en',
            'target_language': 'en',
            'target_placeholder_id': user_settings.clipboard.pk,
        }

        with self.login_user_context(staff_user):
            # Copy plugins into the clipboard
            response = self.client.post(endpoint, data)

        self.assertEqual(response.status_code, 403)

        clipboard_plugins = user_settings.clipboard.get_plugins()

        # assert three new plugins have been created
        # One for the PlaceholderPlugin and the other two
        # are the plugins being copied.
        self.assertEqual(len(clipboard_plugins), 0)

    def test_user_can_paste_from_clipboard(self):
        """
        User can paste plugins from the clipboard if he has
        change permissions on the model attached to the target
        placeholder and he has add permissions on the plugin models
        being copied.
        """
        staff_user = self._staff_user
        target_placeholder = self._obj.placeholder
        endpoint = self.get_admin_url(Example1, 'move_plugin')

        self.add_permission(staff_user, 'change_example1')
        self.add_permission(staff_user, 'add_link')

        # This is sadly required to paste from the clipboard
        # FIXME: https://github.com/divio/django-cms/issues/5432
        self.add_permission(staff_user, 'change_placeholderreference')

        user_settings = UserSettings.objects.create(
            language="en",
            user=staff_user,
            clipboard=Placeholder.objects.create(),
        )

        placeholder_plugin = self._add_plugin_to_placeholder(
            user_settings.clipboard,
            'PlaceholderPlugin',
        )
        ref_placeholder = placeholder_plugin.placeholder_ref

        self._add_plugin_to_placeholder(ref_placeholder)
        self._add_plugin_to_placeholder(ref_placeholder)

        with self.login_user_context(staff_user):
            # Paste plugins from clipboard into placeholder
            # under the french language.
            data = {
                'placeholder_id': target_placeholder.pk,
                'plugin_id': placeholder_plugin.pk,
                'plugin_parent': '',
                'plugin_language': 'fr',
                'plugin_order[]': '__COPY__',
                'move_a_copy': True,
            }
            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 200)
            self.assertEqual(target_placeholder.get_plugins('fr').count(), 2)

    def test_user_cant_paste_from_clipboard(self):
        """
        User cant paste plugins from the clipboard if he does not have
        change permissions on the model attached to the target placeholder
        and/or does not have add permissions on the plugin models
        being copied.
        """
        staff_user = self._staff_user
        target_placeholder = self._obj.placeholder
        endpoint = self.get_admin_url(Example1, 'move_plugin')

        self.add_permission(staff_user, 'add_example1')
        self.add_permission(staff_user, 'delete_example1')
        self.add_permission(staff_user, 'add_link')

        # This is sadly required to paste from the clipboard
        # FIXME: https://github.com/divio/django-cms/issues/5432
        self.add_permission(staff_user, 'change_placeholderreference')

        user_settings = UserSettings.objects.create(
            language="en",
            user=staff_user,
            clipboard=Placeholder.objects.create(),
        )

        placeholder_plugin = self._add_plugin_to_placeholder(
            user_settings.clipboard,
            'PlaceholderPlugin',
        )
        ref_placeholder = placeholder_plugin.placeholder_ref

        self._add_plugin_to_placeholder(ref_placeholder)
        self._add_plugin_to_placeholder(ref_placeholder)

        with self.login_user_context(staff_user):
            # Paste plugins from clipboard into placeholder
            # under the french language.
            data = {
                'placeholder_id': target_placeholder.pk,
                'plugin_id': placeholder_plugin.pk,
                'plugin_parent': '',
                'plugin_language': 'fr',
                'plugin_order[]': '__COPY__',
                'move_a_copy': True,
            }
            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 403)
            self.assertEqual(target_placeholder.get_plugins('fr').count(), 0)

        self.add_permission(staff_user, 'change_example1')
        self.remove_permission(staff_user, 'add_link')

        with self.login_user_context(staff_user):
            # Paste plugins from clipboard into placeholder
            # under the french language.
            data = {
                'placeholder_id': target_placeholder.pk,
                'plugin_id': placeholder_plugin.pk,
                'plugin_parent': '',
                'plugin_language': 'fr',
                'plugin_order[]': '__COPY__',
                'move_a_copy': True,
            }
            response = self.client.post(endpoint, data)
            self.assertEqual(response.status_code, 403)
            self.assertEqual(target_placeholder.get_plugins('fr').count(), 0)


text:
<?php
/**
 * CreateWalletMessage.php
 *
 * @author   Ilya Sinyakin <sinyakin.ilya@gmail.com>
 */

namespace SunTechSoft\Blockchain;

final class CreateWalletMessage extends AbstractMessage
{
    private $publicKey;

    public function __construct($publicKey)
    {
        parent::__construct(1);
        $this->publicKey = $publicKey;
    }

    public function createMessageForSignature()
    {
        $this->payloadLength = 106;

        $msg = '';
        $msg .= pack('ccvv', $this->networkId, $this->protocolVersion, $this->messageId, $this->serviceId);
        $msg .= pack('V', $this->payloadLength);
        $msg .= \Sodium\hex2bin($this->publicKey);

        return $msg;
    }

    public function getBody()
    {
        return [
            'pub_key' => $this->publicKey,
        ];
    }

}


text:
package org.openspaces.remoting;

import java.util.concurrent.ExecutionException;

/**
 * An extension for {@link java.util.concurrent.ExecutionException} holding both the
 * {@link SpaceRemotingInvocation remoteInvocation} and the
 * {@link SpaceRemotingResult remoteResult} remote result.
 *
 * @author kimchy
 */
public class SpaceRemoteExecutionException extends ExecutionException {

    private static final long serialVersionUID = -8990362587695315894L;

    private SpaceRemotingInvocation remoteInvocation;

    private SpaceRemotingResult remoteResult;

    public SpaceRemoteExecutionException(SpaceRemotingInvocation remoteInvocation, String message, Throwable cause) {
        super(message, cause);
        this.remoteInvocation = remoteInvocation;
    }

    public SpaceRemoteExecutionException(SpaceRemotingInvocation remoteInvocation, SpaceRemotingResult remoteResult) {
        super("Remote Invocation failed with invocation [" + remoteInvocation + "]", remoteResult.getException());
        this.remoteInvocation = remoteInvocation;
        this.remoteResult = remoteResult;
    }

    /**
     * Returns the remote invocation that caused this execution exception.
     */
    public SpaceRemotingInvocation getRemoteInvocation() {
        return remoteInvocation;
    }

    /**
     * Returns the remote result that caused this execution exception.
     */
    public SpaceRemotingResult getRemoteResult() {
        return remoteResult;
    }
}


text:
package com.fasterxml.jackson.jr.ob.api;

import java.util.*;

import com.fasterxml.jackson.jr.ob.JSON;
import com.fasterxml.jackson.jr.ob.JSON.Feature;
import com.fasterxml.jackson.jr.ob.impl.DeferredMap;
import com.fasterxml.jackson.jr.ob.JSONObjectException;

/**
 * Helper class that is used for constructing {@link java.util.Map}s
 * to map JSON Object values in.
 *

 * Objects server both as "factories" for creating new builders (blueprint
 * style), and as actual builders. For each distinct read operation,
 * {@link #newBuilder} will be called at least once; this instance
 * may be used and reused multiple times, as calling {@link #start}
 * will reset the state so that more {@link List}s may be built.
 */
public abstract class MapBuilder
{
    protected final int _features;
    protected final boolean _checkDups;

    /**
     * Optional {@link Map} implementation class, used when specific
     * implementation is desired.
     */
    protected final Class<?> _mapType;

    protected MapBuilder(int features, Class<?> type) {
        _features = features;
        _checkDups = JSON.Feature.FAIL_ON_DUPLICATE_MAP_KEYS.isEnabled(features);
        _mapType = type;
    }

    /**
     * Factory method for getting a blueprint instance of the default
     * {@link MapBuilder} implementation.
     */
    public static MapBuilder defaultImpl() {
        return new Default(0, null);
    }

    public abstract MapBuilder newBuilder(int features);

    public abstract MapBuilder newBuilder(Class<?> mapImpl);

    public MapBuilder newBuilder() {
        return newBuilder(_features);
    }

    public final boolean isEnabled(JSON.Feature f) {
        return f.isEnabled(_features);
    }

    public abstract MapBuilder start();

    public abstract MapBuilder put(String key, Object value);

    public abstract Map<String, Object> build();

    /**
     * Specialized method that is called when an empty list needs to
     * be constructed; this may be a new list, or an immutable shared
     * List, depending on implementation.
     *

     * Default implementation simply calls:
     *

     *  start().build();
     *

     * which assumes that a builder has been constructed with {@link #newBuilder}
     */
    public Map<String, Object> emptyMap() throws JSONObjectException {
        return start().build();
    }

    /**
     * Specialized method that is called when an empty list needs to
     * be constructed; this may be a new list, or an immutable shared
     * List, depending on implementation.
     *

     * Default implementation simply calls:
     *

     *  start().put(key, value).build();
     *

     */
    public Map<String, Object> singletonMap(String key, Object value) throws JSONObjectException {
        return start().put(key, value).build();
    }

    /*
    /**********************************************************
    /* Default implementation
    /**********************************************************
     */

    /**
     * Default {@link MapBuilder} implementation which builds
     * either {@link HashMap} or {@link LinkedHashMap} instances
     * (depending on {@link Feature#PRESERVE_FIELD_ORDERING}).
     * It may also, with alternate configuration,
     * use {@link Collections#emptyMap()} for empty Maps,
     * if allowed with {@link Feature#READ_ONLY}.
     */
    public static class Default extends MapBuilder
    {
        protected Map<String, Object> _current;

        protected Default(int features, Class<?> type) {
            super(features, type);
        }

        @Override
        public MapBuilder newBuilder(int features) {
            return new Default(features, _mapType);
        }

        @Override
        public MapBuilder newBuilder(Class<?> mapImpl) {
            return new Default(_features, mapImpl);
        }

        @Override
        public MapBuilder start() {
            // If this builder is "busy", create a new one...
            if (_current != null) {
                return newBuilder().start();
            }
            _current = _map(12);
            return this;
        }

        @Override
        public Map<String, Object> build() {
            Map<String, Object> result = _current;
            _current = null;
            return result;
        }

        @Override
        public MapBuilder put(String key, Object value) {
            if (_checkDups) {
                if (_current.containsKey(key)) {
                    // 14-Apr-2017, tatu: Note that choice of `IllegalArgumentException` is arbitrary
                    //   but not random: caller catches and re-packages it to give context
                    throw new IllegalArgumentException("Duplicate key (key '"+key+"')");
                }
            }
            _current.put(key, value);
            return this;
        }

        @Override
        public Map<String, Object> emptyMap() {
            if ((_mapType == null) && isEnabled(Feature.READ_ONLY)) {
                return Collections.emptyMap();
            }
            return _map(4);
        }

        private final Map<String, Object> _map(int initialSize) {
            if (_mapType != null) {
                try {
                    @SuppressWarnings("unchecked")
                    Map<String,Object> m = (Map<String,Object>)
                        _mapType.getDeclaredConstructor().newInstance((Object[]) null);
                    return m;
                } catch (Exception e) {
                    Throwable t = e;
                    while (t.getCause() != null) {
                        t = t.getCause();
                    }
                    throw new IllegalArgumentException("Failed to create an instance of "
                            +_mapType.getName()+" ("+t.getClass().getName()+"): "+t.getMessage());

                }
            }
            final boolean sort = isEnabled(Feature.PRESERVE_FIELD_ORDERING);
            if (isEnabled(Feature.USE_DEFERRED_MAPS)) {
                return new DeferredMap(sort, initialSize);
            }
            return sort ? new LinkedHashMap<String, Object>(initialSize)
                    : new HashMap<String, Object>(initialSize);
        }
    }
}


text:
/**
 * Initialize a new `PropertySet`.
 *
 * @api public
 */

var PropertySet = exports = module.exports = function PropertySet(){
    this.props = {};
    this.vals = {};
};

/**
 * Set prop `name`.
 *
 * @param {String} name
 * @param {Object} prop
 * @return {Object}
 * @api public
 */

PropertySet.prototype.set = function(name, prop){
    return this.props[prop.name = name] = prop;
};

/**
 * Get prop `name`.
 *
 * @param {String} name
 * @return {Object}
 * @api public
 */

PropertySet.prototype.get = function(name){
    return this.props[name];
};

/**
 * Check if the prop `name` exists.
 *
 * @param {String} name
 * @return {Boolean}
 * @api public
 */

PropertySet.prototype.has = function(name){
    return this.get(name) !== undefined;
};

/**
 * Iterate properties with the given callback `fn` and optional `scope`.
 *
 * @param {Function} fn
 * @param {Mixed} scope
 * @api public
 */

PropertySet.prototype.each = function(fn, scope){
    var keys = Object.keys(this.props);
    for (var i = 0, len = keys.length; i < len; ++i) {
        var key = keys[i];
        fn.call(scope, this.props[key]);
    }
};


text:
FROM grempe/ruby:latest

ENV RAILS_VERSION="4.2.5.1"

RUN bundle config --global build.nokogiri '--use-system-libraries' && \
   gem install --no-document nokogiri -- --use-system-libraries && \
   gem install --no-document rails --version "$RAILS_VERSION" && \
   rm -rf /usr/lib/ruby/gems/*/cache/* && \
   rm -rf ~/.gem


text:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Collections.Generic;
using Azure.Core;

namespace Azure.Search.Documents.Indexes.Models
{
    public partial class StemmerOverrideTokenFilter
    {
        /// <summary> A list of stemming rules in the following format: "word => stem", for example: "ran => run". </summary>
        public IList<string> Rules { get; }
    }
}


text:
import Ember from 'ember';
import RippleMixin from '../mixins/components/ripple';

export default Ember.Component.extend(RippleMixin, {
  classNames: ['md-ripple-container'],

  createRipple() {
    return this.$('.md-ripple');
  },

  getRippleElement() {
    let $parent = this.$().parent();
    while(window.getComputedStyle($parent[0])['pointer-events'] === 'none') {
      $parent = $parent.parent();
    }

    return $parent;
  }
});


text:
package org.vaadin.spring.navigator.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import org.vaadin.spring.annotation.VaadinComponent;
import org.vaadin.spring.annotation.VaadinUIScope;
import org.vaadin.spring.navigator.SpringViewProvider;

/**
 * Annotation to be placed on {@link org.vaadin.spring.navigator.Presenter}-classes that employ a
 * {@link SpringViewProvider} and an {@link org.vaadin.spring.events.EventBus}.
 *

 * This annotation is also a stereotype annotation, so Spring will automatically detect the annotated classes.
 *

 * This is an example of a presenter that is mapped to a view name:
 *

 *
 *     @VaadinPresenter(viewName = "myView")
 *     public class MyPresenter extends Presenter {
 *         // ...
 *     }
 *
 *

 *
 * The viewName must match the name attribute of a {@link org.vaadin.spring.navigator.annotation.VaadinView} annotated {@link com.vaadin.navigator.View}.
 *
 * @author Chris Phillipson (fastnsilver@gmail.com)
 */
@Target({java.lang.annotation.ElementType.TYPE})
@Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@Documented
@VaadinUIScope
@VaadinComponent
public @interface VaadinPresenter {

    /**
     * A presenter will always be matched with a view in an application.
     */
    String viewName();
}


text:
import React from 'react';
import {expect} from 'chai';
import containsRow from '../containsRow';
import Row from '../../components/Row';

describe('containsRow()', () => {
  it('returns false if there are no rows', () => {
    expect(containsRow([
])).to.be.false();
  });

  it('returns true if there is a row', () => {
    expect(containsRow([<Row key={0}/>,
])).to.be.true();
  });
});


text:
package org.apache.poi.hssf.record.formula.functions;

import junit.framework.TestCase;

import org.apache.poi.hssf.record.formula.eval.AreaEval;
import org.apache.poi.hssf.record.formula.eval.BoolEval;
import org.apache.poi.hssf.record.formula.eval.ErrorEval;
import org.apache.poi.hssf.record.formula.eval.NumberEval;
import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
import org.apache.poi.hssf.record.formula.eval.StringEval;
import org.apache.poi.hssf.record.formula.eval.ValueEval;

/**
 * Test cases for MATCH()
 *
 * @author Josh Micich
 */
public final class TestMatch extends TestCase {
	/** less than or equal to */
	private static final NumberEval MATCH_LARGEST_LTE = new NumberEval(1);
	private static final NumberEval MATCH_EXACT = new NumberEval(0);
	/** greater than or equal to */
	private static final NumberEval MATCH_SMALLEST_GTE = new NumberEval(-1);

	private static ValueEval invokeMatch(ValueEval lookup_value, ValueEval lookup_array, ValueEval match_type) {
		ValueEval[] args = { lookup_value, lookup_array, match_type, };
		return new Match().evaluate(args, -1, (short)-1);
	}
	private static void confirmInt(int expected, ValueEval actualEval) {
		if(!(actualEval instanceof NumericValueEval)) {
			fail("Expected numeric result");
		}
		NumericValueEval nve = (NumericValueEval)actualEval;
		assertEquals(expected, nve.getNumberValue(), 0);
	}

	public void testSimpleNumber() {

		ValueEval[] values = {
			new NumberEval(4),
			new NumberEval(5),
			new NumberEval(10),
			new NumberEval(10),
			new NumberEval(25),
		};

		AreaEval ae = EvalFactory.createAreaEval("A1:A5", values);

		confirmInt(2, invokeMatch(new NumberEval(5), ae, MATCH_LARGEST_LTE));
		confirmInt(2, invokeMatch(new NumberEval(5), ae, MATCH_EXACT));
		confirmInt(4, invokeMatch(new NumberEval(10), ae, MATCH_LARGEST_LTE));
		confirmInt(3, invokeMatch(new NumberEval(10), ae, MATCH_EXACT));
		confirmInt(4, invokeMatch(new NumberEval(20), ae, MATCH_LARGEST_LTE));
		assertEquals(ErrorEval.NA, invokeMatch(new NumberEval(20), ae, MATCH_EXACT));
	}

	public void testReversedNumber() {

		ValueEval[] values = {
			new NumberEval(25),
			new NumberEval(10),
			new NumberEval(10),
			new NumberEval(10),
			new NumberEval(4),
		};

		AreaEval ae = EvalFactory.createAreaEval("A1:A5", values);

		confirmInt(2, invokeMatch(new NumberEval(10), ae, MATCH_SMALLEST_GTE));
		confirmInt(2, invokeMatch(new NumberEval(10), ae, MATCH_EXACT));
		confirmInt(4, invokeMatch(new NumberEval(9), ae, MATCH_SMALLEST_GTE));
		confirmInt(1, invokeMatch(new NumberEval(20), ae, MATCH_SMALLEST_GTE));
		assertEquals(ErrorEval.NA, invokeMatch(new NumberEval(20), ae, MATCH_EXACT));
		assertEquals(ErrorEval.NA, invokeMatch(new NumberEval(26), ae, MATCH_SMALLEST_GTE));
	}

	public void testSimpleString() {

		ValueEval[] values = {
			new StringEval("Albert"),
			new StringEval("Charles"),
			new StringEval("Ed"),
			new StringEval("Greg"),
			new StringEval("Ian"),
		};

		AreaEval ae = EvalFactory.createAreaEval("A1:A5", values);

		// Note String comparisons are case insensitive
		confirmInt(3, invokeMatch(new StringEval("Ed"), ae, MATCH_LARGEST_LTE));
		confirmInt(3, invokeMatch(new StringEval("eD"), ae, MATCH_LARGEST_LTE));
		confirmInt(3, invokeMatch(new StringEval("Ed"), ae, MATCH_EXACT));
		confirmInt(3, invokeMatch(new StringEval("ed"), ae, MATCH_EXACT));
		confirmInt(4, invokeMatch(new StringEval("Hugh"), ae, MATCH_LARGEST_LTE));
		assertEquals(ErrorEval.NA, invokeMatch(new StringEval("Hugh"), ae, MATCH_EXACT));
	}

	public void testSimpleBoolean() {

		ValueEval[] values = {
				BoolEval.FALSE,
				BoolEval.FALSE,
				BoolEval.TRUE,
				BoolEval.TRUE,
		};

		AreaEval ae = EvalFactory.createAreaEval("A1:A4", values);

		// Note String comparisons are case insensitive
		confirmInt(2, invokeMatch(BoolEval.FALSE, ae, MATCH_LARGEST_LTE));
		confirmInt(1, invokeMatch(BoolEval.FALSE, ae, MATCH_EXACT));
		confirmInt(4, invokeMatch(BoolEval.TRUE, ae, MATCH_LARGEST_LTE));
		confirmInt(3, invokeMatch(BoolEval.TRUE, ae, MATCH_EXACT));
	}

	public void testHeterogeneous() {

		ValueEval[] values = {
				new NumberEval(4),
				BoolEval.FALSE,
				new NumberEval(5),
				new StringEval("Albert"),
				BoolEval.FALSE,
				BoolEval.TRUE,
				new NumberEval(10),
				new StringEval("Charles"),
				new StringEval("Ed"),
				new NumberEval(10),
				new NumberEval(25),
				BoolEval.TRUE,
				new StringEval("Ed"),
		};

		AreaEval ae = EvalFactory.createAreaEval("A1:A13", values);

		assertEquals(ErrorEval.NA, invokeMatch(new StringEval("Aaron"), ae, MATCH_LARGEST_LTE));

		confirmInt(5, invokeMatch(BoolEval.FALSE, ae, MATCH_LARGEST_LTE));
		confirmInt(2, invokeMatch(BoolEval.FALSE, ae, MATCH_EXACT));
		confirmInt(3, invokeMatch(new NumberEval(5), ae, MATCH_LARGEST_LTE));
		confirmInt(3, invokeMatch(new NumberEval(5), ae, MATCH_EXACT));

		confirmInt(8, invokeMatch(new StringEval("CHARLES"), ae, MATCH_EXACT));

		confirmInt(4, invokeMatch(new StringEval("Ben"), ae, MATCH_LARGEST_LTE));

		confirmInt(13, invokeMatch(new StringEval("ED"), ae, MATCH_LARGEST_LTE));
		confirmInt(9, invokeMatch(new StringEval("ED"), ae, MATCH_EXACT));

		confirmInt(13, invokeMatch(new StringEval("Hugh"), ae, MATCH_LARGEST_LTE));
		assertEquals(ErrorEval.NA, invokeMatch(new StringEval("Hugh"), ae, MATCH_EXACT));

		confirmInt(11, invokeMatch(new NumberEval(30), ae, MATCH_LARGEST_LTE));
		confirmInt(12, invokeMatch(BoolEval.TRUE, ae, MATCH_LARGEST_LTE));
	}

	/**
	 * Ensures that the match_type argument can be an <tt>AreaEval</tt>.<br/>
	 * Bugzilla 44421
	 */
	public void testMatchArgTypeArea() {

		ValueEval[] values = {
			new NumberEval(4),
			new NumberEval(5),
			new NumberEval(10),
			new NumberEval(10),
			new NumberEval(25),
		};

		AreaEval ae = EvalFactory.createAreaEval("A1:A5", values);

		AreaEval matchAE = EvalFactory.createAreaEval("C1:C1", new ValueEval[] { MATCH_LARGEST_LTE, });

		try {
			confirmInt(4, invokeMatch(new NumberEval(10), ae, matchAE));
		} catch (RuntimeException e) {
			if(e.getMessage().startsWith("Unexpected match_type type")) {
				// identified bug 44421
				fail(e.getMessage());
			}
			// some other error ??
			throw e;
		}
	}
}


text:
package com.github.illfaku.korro.internal.common

private[internal] case object TimedOut


text:
pub use self::unref::unref;
pub use self::default_gen::generate;
pub use self::generators::{
    generate_trimesh_around_origin
};

mod unref;
mod default_gen;
mod generators;


text:
namespace {

float GetDeviceScaleForNativeView(views::Widget* widget) {
  float device_scale = 1.0f;
  if (widget && widget->GetNativeView()) {
    gfx::NativeView view = widget->GetNativeView();
    display::Display display =
        display::Screen::GetScreen()->GetDisplayNearestWindow(view);
    device_scale = display.device_scale_factor();
  }
  return device_scale;
}

}  // namespace

namespace views {

gfx::Canvas* GetCanvasForDragImage(views::Widget* widget,
                                   const gfx::Size& canvas_size) {
  float device_scale = GetDeviceScaleForNativeView(widget);
  return new gfx::Canvas(canvas_size, device_scale, false);
}

}  // namespace views


text:
package org.dasein.cloud.joyent.storage;

import org.dasein.cloud.CloudProvider;
import org.dasein.cloud.joyent.storage.util.MantaStorageTestUtils;
import org.dasein.cloud.storage.Blob;
import org.dasein.cloud.storage.BlobStoreSupport;
import org.dasein.cloud.storage.FileTransfer;
import org.dasein.cloud.test.DaseinTestManager;
import org.dasein.util.uom.storage.Byte;
import org.dasein.util.uom.storage.Storage;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import java.io.File;
import java.util.Date;

import static org.junit.Assert.*;

/**
 * Manta storage smoke test. Provides basic tests for Manta Storage.
 *
 * @author ilya.drabenia
 * @author anton.karavaev
 */
public class MantaStorageSmokeTest {
    private static final String SRC_FILE_PATH = "src/test/resources/data/master-yoda.txt";
    private static final String MANTA_DIR_PATH = "smokeAK/";
    private static final String MANTA_FILE_NAME = "smokeAK/master-yoda.txt";

    private static BlobStoreSupport storage;

    @BeforeClass
    public static void prepareMantaStore() throws Exception {
        CloudProvider provider = DaseinTestManager.constructProvider();
        storage = provider.getStorageServices().getOnlineStorageSupport();
    }

    @AfterClass
    public static void tearDown() throws Exception {
        storage.removeBucket(MANTA_DIR_PATH);
    }

    @Test
    public void testFileUpload() throws Exception {
        Blob result = MantaStorageTestUtils.uploadTestFile(SRC_FILE_PATH, storage, MANTA_DIR_PATH, MANTA_FILE_NAME);

        assertNotNull(result);
    }

    @Test
    public void testFileDownload() throws Exception {
        MantaStorageTestUtils.uploadTestFile(SRC_FILE_PATH, storage, MANTA_DIR_PATH, MANTA_FILE_NAME);
        File toFile = File.createTempFile(String.valueOf(new Date().getTime()), "");

        FileTransfer fileTransfer = storage.download(MANTA_DIR_PATH, MANTA_FILE_NAME, toFile);
        waitUntilFileDownloaded(fileTransfer);

        assertThatFileSuccessfullyDownloaded(fileTransfer);
        assertEquals(toFile.length(), 16);
    }

    private void assertThatFileSuccessfullyDownloaded(FileTransfer fileTransfer) {
        Throwable error = fileTransfer.getTransferError();

        assertNull("After file download Task object must not contains errors", error);
    }

    private void waitUntilFileDownloaded(FileTransfer fileTransfer) throws InterruptedException {
        while (!fileTransfer.isComplete()) {
            synchronized (fileTransfer) {
                fileTransfer.wait(10000L);
            }
        }
    }

    @Test
    public void testFileRemove() throws Exception {
        MantaStorageTestUtils.uploadTestFile(SRC_FILE_PATH, storage, MANTA_DIR_PATH, MANTA_FILE_NAME);

        storage.removeObject(MANTA_DIR_PATH, MANTA_FILE_NAME);
    }

    @Test
    public void testFileRename() throws Exception {
        MantaStorageTestUtils.uploadTestFile(SRC_FILE_PATH, storage, MANTA_DIR_PATH, MANTA_FILE_NAME);

        storage.renameObject(MANTA_DIR_PATH, MANTA_FILE_NAME, "Master-Yoda-1.jpg");
    }

    @Test
    public void testIsPublicForPublicFile() throws Exception {
        final String PUBLIC_FILE_PATH = "/altoros2/public/1/";

        boolean isPublic = storage.isPublic(PUBLIC_FILE_PATH, MANTA_FILE_NAME);

        assertTrue("Public files must be stored in /{login}/public folder", isPublic);
    }

    @Test
    public void testIsPublicForNotPublicFiles() throws Exception {
        final String PRIVATE_FILE_PATH = "/altoros2/stor/1/master-yoda.txt";

        boolean isPublic = storage.isPublic(null, PRIVATE_FILE_PATH);

        assertFalse(isPublic);
    }

    @Test
    public void testGetMaxObjectSize() throws Exception {
        double size = storage.getMaxObjectSize().doubleValue();

        assertTrue("Files in Manta has unlimited size", size > 1000000);
    }

    @Test
    public void testIsSubscribed() throws Exception {
        boolean isSubscribed = storage.isSubscribed();

        assertTrue("For make tests on real cloud client must be subscribed", isSubscribed);
    }

    /**
     * Note that current Manta Java API does not support recursive directory creation (i.e. mmkdir -p command in Node.js SDK)
     *
     * @throws Exception
     */
    @Test
    public void testDirectoryCreate() throws Exception {
        Blob bucket = MantaStorageTestUtils.createBucket(storage, MANTA_DIR_PATH);

        assertNotNull(bucket);
        assertNull("Manta directory must not have an object name", bucket.getObjectName());
        assertNotNull("Bucket name must be presented for Manta directories", bucket.getBucketName());
        assertEquals(bucket.getBucketName(), MANTA_DIR_PATH);
        assertTrue("Manta directory must be a container", bucket.isContainer());
    }

    @Test
    public void testDirectoryList() throws Exception {
        MantaStorageTestUtils.createBucket(storage, MANTA_DIR_PATH);
        MantaStorageTestUtils.createBucket(storage, MANTA_DIR_PATH + "foo/");
        MantaStorageTestUtils.uploadTestFile(SRC_FILE_PATH, storage, MANTA_DIR_PATH, MANTA_FILE_NAME);
        Iterable<Blob> blobs = storage.list(MANTA_DIR_PATH);

        assertTrue(blobs.iterator().hasNext());
    }

    @Test
    public void testDirectoryClear() throws Exception {
        String path = MantaStorageTestUtils.createBucket(storage, MANTA_DIR_PATH).getBucketName();
        storage.clearBucket(path);

        assertNull(storage.getBucket(path));
    }

    @Test
    public void testDirectoryExists() throws Exception {
        MantaStorageTestUtils.createBucket(storage, MANTA_DIR_PATH);

        assertTrue(storage.exists(MANTA_DIR_PATH));
    }

    @Test
    public void testDirectoryRemove() throws Exception {
        String path = MANTA_DIR_PATH + "2/";
        MantaStorageTestUtils.createBucket(storage, MANTA_DIR_PATH);
        MantaStorageTestUtils.createBucket(storage, path);
        storage.removeBucket(path);
        assertNull(storage.getBucket(path));
    }

    @Test
    public void testGetBucket() throws Exception {
        MantaStorageTestUtils.createBucket(storage, MANTA_DIR_PATH);
        Blob bucket = storage.getBucket(MANTA_DIR_PATH);

        assertNotNull(bucket);
    }

    @Test
    public void testGetObject() throws Exception {
        MantaStorageTestUtils.uploadTestFile(SRC_FILE_PATH, storage, MANTA_DIR_PATH, MANTA_FILE_NAME);
        Blob blob = storage.getObject(MANTA_DIR_PATH, MANTA_FILE_NAME);

        assertNotNull(blob);
    }

    @Test
    public void testGetObjectSize() throws Exception {
        Blob blob = MantaStorageTestUtils.uploadTestFile(SRC_FILE_PATH, storage, MANTA_DIR_PATH, MANTA_FILE_NAME);
        Storage<org.dasein.util.uom.storage.Byte> size = blob.getSize();
        Storage<Byte> storageObjectSize = storage.getObjectSize(MANTA_DIR_PATH, MANTA_FILE_NAME);
        if (size != null && storageObjectSize != null) {
            assertTrue(size.getQuantity().equals(storageObjectSize.getQuantity()));
        }
    }

}


text:
title: "Art world school艺术世界学校"
location: "4062 NW Saltzman Rd Suite 206  Portland, OR, 97229"
sidebar:
  - title: "Address"
    text: "4062 NW Saltzman Rd Suite 206  Portland, OR, 97229"
    image: "/assets/images/activities/artworld.png"
  - title: "Contact"
    text: "严咪咪"
  - title: "Phone"
    text: "503-590-5518"
  - title: "Email"
    text: "schooldirector@artworldschool.com"
  - title: "Website"
    text: "[https://artworldschool.com/](https://artworldschool.com/)"
---

Professional Art School Established in 1997 to teach students in person or online a variety of Fine Art, Clay, Arts & Crafts, 3D Art, Calligraphy, Yoga, Mixed Media, Homework Tutoring, Chinese Mandarin Classes and other classes. Different art classes to suite different student needs, Day, Evening, Weekend, Summer Camp, Spring Camp, Winter Camp, and After School program classes.

![]({{ site.url }}/assets/images/activities/151-1-scaled.jpg)


text:
(function () {

var CouchDBSession = Karel.Models.CouchDBSession
var CouchDBSessionView = Karel.Views.CouchDBSession

describe("CouchDB Session (View)", function () {

  var session, sessionView

  beforeEach(function () {
    session = new CouchDBSession({})
    sessionView = new CouchDBSessionView({ model: session })
    sessionView.appendTo(testEl)
  })

  afterEach(function () {
    sessionView.remove()
  })

  it("should try to log in using the entered username and password when the user clicks 'Login'", function () {
    var loginSpy = spyOn(session, 'login')
    sessionView.$('.username').val('admin')
    sessionView.$('.password').val('1234')
    sessionView.$('.login').click()
    expect(session.get('name')).toBe('admin')
    expect(session.get('password')).toBe('1234')
    expect(loginSpy).toHaveBeenCalled()

    expect($(sessionView.el).html()).not.toMatch(/Welcome/)
    session.set({ loggedIn: true })
    expect($(sessionView.el).html()).toMatch(/Welcome/)
  })

  it("should try to sign up using the entered username and password when the user clicks 'Signup'", function () {
    var signupSpy = spyOn(session, 'signup')
    sessionView.$('.username').val('admin')
    sessionView.$('.password').val('1234')
    sessionView.$('.signup').click()
    expect(session.get('name')).toBe('admin')
    expect(session.get('password')).toBe('1234')
    expect(signupSpy).toHaveBeenCalled()

    expect($(sessionView.el).html()).not.toMatch(/Welcome/)
    session.set({ loggedIn: true })
    expect($(sessionView.el).html()).toMatch(/Welcome/)
  })

  it("should try to log out if the user clicks the 'Logout' button", function () {
    expect(sessionView.$('.logout').length).toBe(0)
    expect(sessionView.$('.login').length).toBe(1)

    // Log in
    session.login = function (options) {
      if (options && options.success) options.success(null)
      this.trigger('login')
      this.set({ loggedIn: true })
    }
    sessionView.$('.username').val('admin')
    sessionView.$('.password').val('1234')
    sessionView.$('.login').click()

    expect(sessionView.$('.logout').length).toBe(1)
    expect(sessionView.$('.login').length).toBe(0)

    var logoutSpy = spyOn(session, 'logout')
    sessionView.$('.logout').click()
    expect(logoutSpy).toHaveBeenCalled()

    session.set({ loggedIn: false })
    expect(sessionView.$('.logout').length).toBe(0)
    expect(sessionView.$('.login').length).toBe(1)
  })

})

})()


text:
<?php
namespace TYPO3\ClassAliasLoader;

use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Plugin\PluginInterface;
use Composer\EventDispatcher\EventSubscriberInterface;

/**
 * Class Plugin
 */
class Plugin implements PluginInterface, EventSubscriberInterface
{
    /**
     * @var Composer
     */
    protected $composer;

    /**
     * @var IOInterface
     */
    protected $io;

    /**
     * Apply plugin modifications to composer
     *
     * @param Composer $composer
     * @param IOInterface $io
     */
    public function activate(Composer $composer, IOInterface $io)
    {
        $this->composer = $composer;
        $this->io = $io;
    }

    /**
     * Returns an array of event names this subscriber wants to listen to.
     *
     * The array keys are event names and the value can be:
     *
     * * The method name to call (priority defaults to 0)
     * * An array composed of the method name to call and the priority
     * * An array of arrays composed of the method names to call and respective
     *   priorities, or 0 if unset
     *
     * For instance:
     *
     * * array('eventName' => 'methodName')
     * * array('eventName' => array('methodName', $priority))
     * * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
     *
     * @return array The event names to listen to
     */
    public static function getSubscribedEvents()
    {
        return array(
            'post-autoload-dump' => array('onPostAutoloadDump')
        );
    }

    /**
     * Plugin callback for this script event, which calls the previously implemented static method
     *
     * @param \Composer\Script\Event $event
     * @return bool
     */
    public function onPostAutoloadDump(\Composer\Script\Event $event)
    {
        $flags = $event->getFlags();
        $config = $event->getComposer()->getConfig();
        $optimizeAutoloadFiles = !empty($flags['optimize']) || $config->get('optimize-autoloader') || $config->get('classmap-authoritative');

        $aliasMapGenerator = new ClassAliasMapGenerator(
            $event->getComposer(),
            $event->getIO(),
            $optimizeAutoloadFiles
        );

        return $aliasMapGenerator->generateAliasMap();
    }

}


text:
/*
 * drmaa_blast_tool.cpp
 *
 *  Created on: 22 Apr 2015
 *      Author: tyrrells
 */

#include <new>
#include <cstring>
#include <stdexcept>

#include "drmaa_blast_tool.hpp"
#include "streams.h"
#include "string_utils.h"
#include "jobs_manager.h"
#include "alloc_failure.hpp"
#include "blast_service_job.h"
#include "drmaa_tool_args_processor.hpp"

#ifdef _DEBUG
	#define DRMAA_BLAST_TOOL_DEBUG	(STM_LEVEL_FINEST)
#else
	#define DRMAA_BLAST_TOOL_DEBUG (STM_LEVEL_NONE)
#endif

const char * const DrmaaBlastTool :: DBT_DRMAA_S = "drmaa";

const char * const DrmaaBlastTool :: DBT_ASYNC_S = "async";

static bool UpdateDrmaaBlastServiceJob (struct ServiceJob *job_p);

void DrmaaBlastTool :: SetDrmaaOptions (DrmaaTool *drmaa_p, bool async_flag)
{
	dbt_drmaa_tool_p = drmaa_p;
	dbt_async_flag = async_flag;
}

DrmaaBlastTool :: DrmaaBlastTool (BlastServiceJob *job_p, const char *name_s, const char *factory_s, const BlastServiceData *data_p, const char *blast_program_name_s, const char *queue_name_s, const char *const output_path_s, bool async_flag)
: ExternalBlastTool (job_p, name_s, factory_s, data_p, blast_program_name_s)
{
	const char *error_s = 0;
	DrmaaTool *drmaa_tool_p = AllocateDrmaaTool (blast_program_name_s, job_p -> bsj_job.sj_id);

	if (drmaa_tool_p)
		{
			if (SetDrmaaToolQueueName (drmaa_tool_p, queue_name_s))
				{
					if (SetDrmaaToolJobName (drmaa_tool_p, name_s))
						{
							if (SetDrmaaToolOutputFilename (drmaa_tool_p, output_path_s))
								{
									SetDrmaaOptions (drmaa_tool_p, async_flag);
									SetServiceJobUpdateFunction (& (job_p -> bsj_job), UpdateDrmaaBlastServiceJob);

									dbt_args_processor_p = new DrmaaToolArgsProcessor (drmaa_tool_p);

									return;
								}
							else
								{
									PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "SetDrmaaToolOutputFilename failed for \"%s\"", output_path_s);
									error_s = "SetDrmaaToolOutputFilename failed";
								}
						}
					else
						{
							PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "SetDrmaaToolJobName failed for \"%s\"", name_s);
							error_s = "SetDrmaaToolJobName failed";
						}
				}
			else
				{
					PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "SetDrmaaToolQueueName failed for \"%s\"", queue_name_s);
					error_s = "SetDrmaaToolQueueName failed";
				}

			FreeDrmaaTool (drmaa_tool_p);

		}
	else
		{
			PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to allocate drmaa tool");
			error_s = "Failed to allocate drmaa tool";
		}

	throw AllocFailure (error_s);
}

DrmaaBlastTool :: DrmaaBlastTool (BlastServiceJob *job_p, const BlastServiceData *data_p, const json_t *root_p)
	: ExternalBlastTool (job_p, data_p, root_p)
{
	dbt_async_flag = true;
	if (!GetJSONBoolean (root_p, DBT_ASYNC_S, &dbt_async_flag))
		{
			PrintJSONToErrors (STM_LEVEL_WARNING, __FILE__, __LINE__, root_p, "Failed to get aysnc flag from json");
		}

	json_t *drmaa_json_p = json_object_get (root_p, DBT_DRMAA_S);

	if (drmaa_json_p)
		{
			dbt_drmaa_tool_p = ConvertDrmaaToolFromJSON (drmaa_json_p);

			if (dbt_drmaa_tool_p)
				{
					dbt_args_processor_p = new DrmaaToolArgsProcessor (dbt_drmaa_tool_p);
				}
			else
				{
					PrintJSONToErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, drmaa_json_p, "Failed to get drmaa tool");
					throw std :: invalid_argument ("Failed to create drmaa tool");
				}
		}
	else
		{
			PrintJSONToErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, drmaa_json_p, "Failed to get drmaa json");
			throw std :: invalid_argument ("Failed to create drmaa tool");
		}

}

DrmaaBlastTool :: ~DrmaaBlastTool ()
{
	#if DRMAA_BLAST_TOOL_DEBUG >= STM_LEVEL_FINEST
	char uuid_s [UUID_STRING_BUFFER_SIZE];

	ConvertUUIDToString (bt_job_p -> bsj_job.sj_id, uuid_s);
	PrintLog (STM_LEVEL_FINEST, __FILE__, __LINE__, "Entering ~DrmaaBlastTool for %s with job id %s", uuid_s, dbt_drmaa_tool_p -> dt_id_s);
	#endif

	FreeDrmaaTool (dbt_drmaa_tool_p);

	delete dbt_args_processor_p;

	#if DRMAA_BLAST_TOOL_DEBUG >= STM_LEVEL_FINEST
	PrintLog (STM_LEVEL_FINEST, __FILE__, __LINE__, "Exiting ~DrmaaBlastTool for %s", uuid_s);
	#endif
}

void DrmaaBlastTool :: SetCoresPerSearch (uint32 cores)
{
	dbt_drmaa_tool_p -> dt_num_cores = cores;
}

bool DrmaaBlastTool :: SetEmailNotifications (const char **email_addresses_ss)
{
	return SetDrmaaToolEmailNotifications (dbt_drmaa_tool_p, email_addresses_ss);
}

OperationStatus DrmaaBlastTool :: Run ()
{
	char *job_id_filename_s = GetJobFilename (NULL, ".job");
	OperationStatus status = OS_IDLE;
	char uuid_s [UUID_STRING_BUFFER_SIZE];

	ConvertUUIDToString (bt_job_p -> bsj_job.sj_id, uuid_s);

	if (!job_id_filename_s)
		{
			PrintErrors (STM_LEVEL_WARNING, __FILE__, __LINE__, "Failed to create job filename for ", uuid_s);
		}

	if (RunDrmaaTool (dbt_drmaa_tool_p, dbt_async_flag, job_id_filename_s))
		{

			#if DRMAA_BLAST_TOOL_DEBUG >= STM_LEVEL_FINE
				{
					PrintLog (STM_LEVEL_FINE, __FILE__, __LINE__, "Added drmaa blast tool %s with job id %s", uuid_s, dbt_drmaa_tool_p -> dt_id_s);
				}
			#endif
		}
	else
		{
			AddErrorToBlastServiceJob (bt_job_p);

			SetServiceJobStatus (& (bt_job_p -> bsj_job), OS_FAILED);
		}

	if (job_id_filename_s)
		{
			FreeCopiedString (job_id_filename_s);
		}

	status = GetServiceJobStatus (& (bt_job_p -> bsj_job));

	if (status == OS_FAILED)
		{
			AddErrorToBlastServiceJob (bt_job_p);
		}

	return status;
}

bool DrmaaBlastTool :: AddBlastArg (const char * const arg_s, const bool hyphen_flag)
{
	bool success_flag = AddDrmaaToolArgument (dbt_drmaa_tool_p, arg_s);

	if (hyphen_flag)
		{
			char *value_s = ConcatenateStrings ("-", arg_s);

			if (value_s)
				{
					success_flag = AddDrmaaToolArgument (dbt_drmaa_tool_p, value_s);
					FreeCopiedString (value_s);
				}
			else
				{
					PrintErrors (STM_LEVEL_WARNING, __FILE__, __LINE__, "Failed to concatenate \"-\" and \"%s\"", arg_s);
				}
		}
	else
		{
			success_flag = AddDrmaaToolArgument (dbt_drmaa_tool_p, arg_s);
		}

	return success_flag;
}

OperationStatus DrmaaBlastTool :: GetStatus (bool update_flag)
{
	OperationStatus status = OS_ERROR;

	if (update_flag)
		{
			status = GetDrmaaToolStatus (dbt_drmaa_tool_p);

			SetServiceJobStatus (& (bt_job_p -> bsj_job), status);
		}
	else
		{
			status = GetCachedServiceJobStatus (& (bt_job_p -> bsj_job));
		}

	return status;
}

bool DrmaaBlastTool :: SetUpOutputFile ()
{
	bool success_flag = false;

	if (ExternalBlastTool :: SetUpOutputFile ())
		{
			char *logfile_s = GetJobFilename (":", BS_LOG_SUFFIX_S);

			if (logfile_s)
				{
					if (SetDrmaaToolOutputFilename (dbt_drmaa_tool_p, logfile_s))
						{
							success_flag = true;
						}
					else
						{
							PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to set drmaa logfile name to \"%s\"", logfile_s);
						}

					FreeCopiedString (logfile_s);
				}
			else
				{
					char *uuid_s = GetUUIDAsString (bt_job_p -> bsj_job.sj_id);

					if (uuid_s)
						{
							PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to get logfile name for \"%s\"", uuid_s);
							FreeUUIDString (uuid_s);
						}
					else
						{
							PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to get logfile name");
						}
				}
		}		/* if (ExternalBlastTool :: SetOutputFile ()) */

	return success_flag;
}

bool DrmaaBlastTool :: AddToJSON (json_t *root_p)
{
	bool success_flag = ExternalBlastTool :: AddToJSON (root_p);

	if (success_flag)
		{
			char uuid_s [UUID_STRING_BUFFER_SIZE];

			ConvertUUIDToString (bt_job_p -> bsj_job.sj_id, uuid_s);

			if (json_object_set_new (root_p, DBT_ASYNC_S, dbt_async_flag ? json_true () : json_false ()) == 0)
				{
					json_t *drmaa_json_p = ConvertDrmaaToolToJSON (dbt_drmaa_tool_p);

					if (drmaa_json_p)
						{
							if (json_object_set_new (root_p, DBT_DRMAA_S, drmaa_json_p) == 0)
								{
									success_flag = true;
								}		/* if (json_object_set_new (root_p, DBT_DRMAA_S, drmaa_json_p) == 0) */
							else
								{
									PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed add get drmaa json for %s", uuid_s);

									json_decref (drmaa_json_p);
								}		/* if (json_object_set_new (root_p, DBT_DRMAA_S, drmaa_json_p) == 0) else */

						}		/* if (drmaa_json_p) */
					else
						{
							PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed to create drmaa json for %s", uuid_s);
						}

				}		/* if (json_object_set_new (root_p, DBT_ASYNC_S, dbt_async_flag ? json_true () : json_false ()) == 0) */
			else
				{
					PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "Failed add async flag %d to drmaa json for %s", dbt_async_flag, uuid_s);
				}

		}		/* if (success_flag) */
	else
		{
			PrintErrors (STM_LEVEL_SEVERE, __FILE__, __LINE__, "DrmaaBlastTool :: AddToJSON failed");
		}

	return success_flag;
}

ArgsProcessor *DrmaaBlastTool :: GetArgsProcessor ()
{
	return dbt_args_processor_p;
}

static bool UpdateDrmaaBlastServiceJob (struct ServiceJob *job_p)
{
	BlastServiceJob *blast_job_p = reinterpret_cast <BlastServiceJob *> (job_p);
	DrmaaBlastTool *tool_p = static_cast <DrmaaBlastTool *> (blast_job_p -> bsj_tool_p);

	tool_p -> GetStatus (true);

	return true;
}