text:
Usage
=====

Use aioeventlet with trollius
-----------------------------

aioeventlet can be used with trollius, coroutines written with ``yield
From(...)``. Using aioeventlet with trollius is a good start to port project
written for eventlet to trollius.

To use aioeventlet with trollius, set the event loop policy before using an event
loop, example::

    import aioeventlet
    import trollius

    trollius.set_event_loop_policy(aioeventlet.EventLoopPolicy())
    # ....

Hello World::

    import aioeventlet
    import trollius as asyncio

    def hello_world():
        print("Hello World")
        loop.stop()

    asyncio.set_event_loop_policy(aioeventlet.EventLoopPolicy())
    loop = asyncio.get_event_loop()
    loop.call_soon(hello_world)
    loop.run_forever()
    loop.close()

.. seealso::
   `Trollius documentation <http://trollius.readthedocs.org/>`_.

Use aioeventlet with asyncio
----------------------------

aioeventlet can be used with asyncio, coroutines written with ``yield from ...``.
To use aioeventlet with asyncio, set the event loop policy before using an event
loop. Example::

    import aioeventlet
    import asyncio

    asyncio.set_event_loop_policy(aioeventlet.EventLoopPolicy())
    # ....

Setting the event loop policy should be enough to examples of the asyncio
documentation with the aioeventlet event loop.

.. warning::
   Since aioeventlet relies on eventlet, eventlet port to Python 3 is not complete
   and asyncio requires Python 3.3 or newer: using aioeventlet with asyncio is not
   recommended yet. *Using aioeventlet with trollius should be preferred right
   now*.  See the :ref:`status of the eventlet port to Python 3
   <eventlet-py3>`.

Hello World::

    import aioeventlet
    import asyncio

    def hello_world():
        print("Hello World")
        loop.stop()

    asyncio.set_event_loop_policy(aioeventlet.EventLoopPolicy())
    loop = asyncio.get_event_loop()
    loop.call_soon(hello_world)
    loop.run_forever()
    loop.close()

.. seealso::
   The `asyncio documentation
   <https://docs.python.org/dev/library/asyncio.html>`_.

Threads
-------

Running an event loop in a thread different than the main thread is currently
experimental.

An eventlet Event object is not thread-safe, it must only be used in the
same thread. Use threading.Event to signal events between threads,
and threading.Queue to pass data between threads.

Use ``threading = eventlet.patcher.original('threading')`` to get the original
threading instead of ``import threading``.

It is not possible to run two aioeventlet event loops in the same thread.

Debug mode
----------

To enable the debug mode globally when using trollius, set the environment
variable ``TROLLIUSDEBUG`` to ``1``. To see debug traces, set the log level of
the trollius logger to ``logging.DEBUG``.  The simplest configuration is::

   import logging
   # ...
   logging.basicConfig(level=logging.DEBUG)

If you use asyncio,  use the ``PYTHONASYNCIODEBUG`` environment variable
instead of the ``TROLLIUSDEBUG`` variable.

You can also call ``loop.set_debug(True)`` to enable the debug mode of the
event loop, but it enables less debug checks.

.. seealso::
   Read the `Develop with asyncio
   <https://docs.python.org/dev/library/asyncio-dev.html>`_ section of the
   asyncio documentation.

API
===

aioeventlet specific functions:

yield_future
------------

.. function:: yield_future(future, loop=None)

   Wait for a future, a task, or a coroutine object from a greenthread.

   Return the result or raise the exception of the future.

   The function must not be called from the greenthread running the aioeventlet
   event loop.

   .. versionchanged:: 0.4

      Rename the function from ``wrap_future()`` to :func:`yield_future`.

   .. versionchanged:: 0.3

      Coroutine objects are also accepted. Added the *loop* parameter.
      An exception is raised if it is called from the greenthread of the
      aioeventlet event loop.

   Example of greenthread waiting for a trollius task. The ``progress()``
   callback is called regulary to see that the event loop in not blocked::

        import aioeventlet
        import eventlet
        import trollius as asyncio
        from trollius import From, Return

        def progress():
            print("computation in progress...")
            loop.call_later(0.5, progress)

        @asyncio.coroutine
        def coro_slow_sum(x, y):
            yield From(asyncio.sleep(1.0))
            raise Return(x + y)

        def green_sum():
            loop.call_soon(progress)

            value = aioeventlet.yield_future(coro_slow_sum(1, 2))
            print("1 + 2 = %s" % value)

            loop.stop()

        asyncio.set_event_loop_policy(aioeventlet.EventLoopPolicy())
        eventlet.spawn(green_sum)
        loop = asyncio.get_event_loop()
        loop.run_forever()
        loop.close()

   Output::

        computation in progress...
        computation in progress...
        computation in progress...
        1 + 2 = 3

wrap_greenthread
----------------

.. function:: wrap_greenthread(gt)

   Wrap an eventlet GreenThread, or a greenlet, into a Future object.

   The Future object waits for the completion of a greenthread. The result or
   the exception of the greenthread will be stored in the Future object.

   The greenthread must be wrapped before its execution starts.  If the
   greenthread is running or already finished, an exception is raised.

   For greenlets, the ``run`` attribute must be set.

   .. versionchanged:: 0.3

     An exception is now raised if the greenthread is running or already
     finished. In debug mode, the exception is not more logged to sys.stderr
     for greenthreads.

   Example of trollius coroutine waiting for a greenthread. The ``progress()``
   callback is called regulary to see that the event loop in not blocked::

        import aioeventlet
        import eventlet
        import trollius as asyncio
        from trollius import From, Return

        def progress():
            print("computation in progress...")
            loop.call_later(0.5, progress)

        def slow_sum(x, y):
            eventlet.sleep(1.0)
            return x + y

        @asyncio.coroutine
        def coro_sum():
            loop.call_soon(progress)

            gt = eventlet.spawn(slow_sum, 1, 2)
            fut = aioeventlet.wrap_greenthread(gt, loop=loop)

            result = yield From(fut)
            print("1 + 2 = %s" % result)

        asyncio.set_event_loop_policy(aioeventlet.EventLoopPolicy())
        loop = asyncio.get_event_loop()
        loop.run_until_complete(coro_sum())
        loop.close()

   Output::

        computation in progress...
        computation in progress...
        computation in progress...
        1 + 2 = 3

Installation
============

Install aioeventlet with pip
----------------------------

Type::

    pip install aioeventlet

Install aioeventlet on Windows with pip
---------------------------------------

Procedure for Python 2.7:

* If pip is not installed yet, `install pip
  <http://www.pip-installer.org/en/latest/installing.html>`_: download
  ``get-pip.py`` and type::

  \Python27\python.exe get-pip.py

* Install aioeventlet with pip::

  \Python27\python.exe -m pip install aioeventlet

* pip also installs dependencies: ``eventlet`` and ``trollius``

Manual installation of aioeventlet
----------------------------------

Requirements:

- eventlet 0.14 or newer
- asyncio or trollius:

  * Python 3.4 and newer: asyncio is now part of the stdlib (only eventlet is
    needed)
  * Python 3.3: need Tulip 0.4.1 or newer (``pip install asyncio``),
    but Tulip 3.4.1 or newer is recommended
  * Python 2.6-3.2: need Trollius 0.3 or newer (``pip install trollius``),
    but Trollius 1.0 or newer is recommended

Type::

    python setup.py install

Run tests
=========

Run tests with tox
------------------

The `tox project <http://testrun.org/tox/latest/>`_ can be used to build a
virtual environment with all runtime and test dependencies and run tests
against different Python versions (2.6, 2.7, 3.2, 3.3, 3.4).

To test all Python versions, just type::

    tox

To run tests with Python 2.7, type::

    tox -e py27

To run tests against other Python versions:

* ``py26``: Python 2.6
* ``py27``: Python 2.7
* ``py27_patch``: Python 2.7 with eventlet monkey patching
* ``py27_old``: Python 2.7 with the oldest supported versions of eventlet and
  trollius
* ``py32``: Python 3.2
* ``py33``: Python 3.3
* ``py3_patch``: Python 3 with eventlet monkey patching
* ``py3_old``: Python 3 with the oldest supported versions of eventlet and
  tulip
* ``py34``: Python 3.4

Run tests manually
------------------

To run unit tests, the ``mock`` module is need on Python older than 3.3.

Run the following command::

    python runtests.py -r


text:
module Fog
  module Storage
    class AWS
      class Real
        # Delete policy for a bucket
        #
        # @param bucket_name [String] name of bucket to delete policy from
        #
        # @return [Excon::Response] response:
        #   * status [Integer] - 204
        #
        # @see http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketDELETEpolicy.html

        def delete_bucket_policy(bucket_name)
          request({
            :expects  => 204,
            :headers  => {},
            :bucket_name => bucket_name,
            :method   => 'DELETE',
            :query    => {'policy' => nil}
          })
        end
      end
    end
  end
end

redpajama_set_name: RedPajamaGithub


text:
thisDir=$(dirname $0)
thisDir=$(readlink -f "$thisDir")

source $thisDir/load-storm-config.sh

stormDir=$1

if [ $# = "1" ]; then
    ssh -n $stormUser@$stormMaster '
        mkdir -p '$stormDir'/logs/counter;
        mkdir -p '$stormDir'/logs/all_tests/counter;
        for slave in '$stormSlaves'; do
            ssh $slave "mkdir -p '$stormDir'/logs/counter"
        done
        '
else
    echo "USAGE:"
	echo "run <storm dir>"
fi


text:
<ion-header>
  <ion-navbar>
    <button menuToggle>
      <ion-icon name="menu"></ion-icon>
    </button>
    <ion-title>Slides</ion-title>
  </ion-navbar>
</ion-header>

<ion-content class="slider">

  <ion-slides pager>
    <ion-slide *ngFor="let slide of slides">
      <ion-toolbar>
        <ion-buttons end>
          <button>Skip</button>
        </ion-buttons>
      </ion-toolbar>

    </ion-slide>
    <ion-slide>
      <ion-toolbar>
      </ion-toolbar>

Ready to Play?

      <button large clear>
        Continue
        <ion-icon name="arrow-forward"></ion-icon>
      </button>
    </ion-slide>
  </ion-slides>
</ion-content>


text:
package com.wavesplatform.transaction.smart.script.estimator

import com.wavesplatform.lang.v1.estimator.v2.ScriptEstimatorV2

class FunctionComplexityV2Test extends FunctionComplexityTest(ScriptEstimatorV2)


text:
<?php

/**
 * @file
 * Contains \Drupal\block\BlockAccessController.
 */

namespace Drupal\block;

use Drupal\Core\Entity\EntityAccessController;
use Drupal\Core\Entity\EntityControllerInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Path\AliasManagerInterface;
use Drupal\Component\Utility\Unicode;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Provides a Block access controller.
 */
class BlockAccessController extends EntityAccessController implements EntityControllerInterface {

  /**
   * The node grant storage.
   *
   * @var \Drupal\Core\Path\AliasManagerInterface
   */
  protected $aliasManager;

  /**
   * Constructs a BlockAccessController object.
   *
   * @param string $entity_type
   *   The entity type of the access controller instance.
   * @param \Drupal\Core\Path\AliasManagerInterface $alias_manager
   *   The alias manager.
   */
  public function __construct($entity_type, AliasManagerInterface $alias_manager) {
    parent::__construct($entity_type);
    $this->aliasManager = $alias_manager;
  }

  /**
   * {@inheritdoc}
   */
  public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info) {
    return new static(
      $entity_type,
      $container->get('path.alias_manager')
    );
  }

  /**
   * {@inheritdoc}
   */
  protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
    if ($operation != 'view') {
      return user_access('administer blocks', $account);
    }

    // Deny access to disabled blocks.
    if (!$entity->status()) {
      return FALSE;
    }

    // If the plugin denies access, then deny access.
    if (!$entity->getPlugin()->access()) {
      return FALSE;
    }

    // Otherwise, check for other access restrictions.

    // User role access handling.
    // If a block has no roles associated, it is displayed for every role.
    // For blocks with roles associated, if none of the user's roles matches
    // the settings from this block, access is denied.
    $visibility = $entity->get('visibility');
    if (!empty($visibility['role']['roles']) && !array_intersect(array_filter($visibility['role']['roles']), $account->getRoles())) {
      // No match.
      return FALSE;
    }

    // Page path handling.
    // Limited visibility blocks must list at least one page.
    if (!empty($visibility['path']['visibility']) && $visibility['path']['visibility'] == BLOCK_VISIBILITY_LISTED && empty($visibility['path']['pages'])) {
      return FALSE;
    }

    // Match path if necessary.
    if (!empty($visibility['path']['pages'])) {
      // Assume there are no matches until one is found.
      $page_match = FALSE;

      // Convert path to lowercase. This allows comparison of the same path
      // with different case. Ex: /Page, /page, /PAGE.
      $pages = drupal_strtolower($visibility['path']['pages']);
      if ($visibility['path']['visibility'] < BLOCK_VISIBILITY_PHP) {
        // Compare the lowercase path alias (if any) and internal path.
        $path = current_path();
        $path_alias = Unicode::strtolower($this->aliasManager->getPathAlias($path));
        $page_match = drupal_match_path($path_alias, $pages) || (($path != $path_alias) && drupal_match_path($path, $pages));
        // When $block->visibility has a value of 0
        // (BLOCK_VISIBILITY_NOTLISTED), the block is displayed on all pages
        // except those listed in $block->pages. When set to 1
        // (BLOCK_VISIBILITY_LISTED), it is displayed only on those pages
        // listed in $block->pages.
        $page_match = !($visibility['path']['visibility'] xor $page_match);
      }
      elseif (module_exists('php')) {
        $page_match = php_eval($visibility['path']['pages']);
      }

      // If there are page visibility restrictions and this page does not
      // match, deny access.
      if (!$page_match) {
        return FALSE;
      }
    }

    // Language visibility settings.
    if (!empty($visibility['language']['langcodes']) && array_filter($visibility['language']['langcodes'])) {
      if (empty($visibility['language']['langcodes'][language($visibility['language']['language_type'])->id])) {
        return FALSE;
      }
    }
    return TRUE;
  }

}


text:
package com.crawler.otomoto;

public class OtoMotoCrawlerException extends Exception {

	private static final long serialVersionUID = -4285532697713094539L;

	public OtoMotoCrawlerException(String message, Throwable cause) {
		super(message, cause);
	}

	public OtoMotoCrawlerException(String message) {
		super(message);
	}

}


text:
var browserSync = require("./index");
var connect = require("connect");
var sass = require("gulp-ruby-sass");
var _    = require("lodash");
var http = require("http");

console.time("init");

var files = ["test/fixtures/assets/*"];

var options = {
    server: {
        baseDir: "./test/fixtures"
    },
//    proxy: "swoon.static/store-home.php",
    files: "test/fixtures/*.html",
////    tunnel: true,
//    codeSync: false,
//    port: 8080,
//    online: false,
    open: false
//    logFileChanges: false
//    https: true,
//    tunnel: true,
//    logConnections: false,
//    minify: false,
////    logLevel: "silent",
//    notify: true,
//    browser: ["Safari"]
};

//var clientScript = require("/Users/shakyshane/Sites/browser-sync-modules/browser-sync-client/index");
//clientScript.name = "client:script";

//var cp = require("/Users/shakyshane/Sites/browser-sync-modules/browser-sync-cp/index");
//
////console.log(cp);
//
//var validUrls = [];
//
//browserSync.use({
//    name: "custom",
//    plugin: function (bs) {
//
//    }
//});

var instance = browserSync(options);

instance.events.on("file:changed", function (data) {

    console.log("CHANGED");
//    if (data.namespace === "core") {
//        console.log("FILE Chanegd");
//    } else {
//        console.log("File change, but not in the core namespace");
//    }
//    console.log(data.namespace);
});


text:
/*
 * Copyright 1999-2004 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 * $Id: ObjectStack.java,v 1.2.4.1 2005/09/15 08:15:51 suresh_emailid Exp $
 */
package com.sun.org.apache.xml.internal.utils;

import java.util.EmptyStackException;

/**
 * Implement a stack of simple integers.
 *
 * %OPT%
 * This is currently based on ObjectVector, which permits fast acess but pays a
 * heavy recopying penalty if/when its size is increased. If we expect deep
 * stacks, we should consider a version based on ChunkedObjectVector.
 * @xsl.usage internal
 */
public class ObjectStack extends ObjectVector
{

  /**
   * Default constructor.  Note that the default
   * block size is very small, for small lists.
   */
  public ObjectStack()
  {
    super();
  }

  /**
   * Construct a ObjectVector, using the given block size.
   *
   * @param blocksize Size of block to allocate
   */
  public ObjectStack(int blocksize)
  {
    super(blocksize);
  }

  /**
   * Copy constructor for ObjectStack
   *
   * @param v ObjectStack to copy
   */
  public ObjectStack (ObjectStack v)
  {
        super(v);
  }

  /**
   * Pushes an item onto the top of this stack.
   *
   * @param   i   the int to be pushed onto this stack.
   * @return  the item argument.
   */
  public Object push(Object i)
  {

    if ((m_firstFree + 1) >= m_mapSize)
    {
      m_mapSize += m_blocksize;

      Object newMap[] = new Object[m_mapSize];

      System.arraycopy(m_map, 0, newMap, 0, m_firstFree + 1);

      m_map = newMap;
    }

    m_map[m_firstFree] = i;

    m_firstFree++;

    return i;
  }

  /**
   * Removes the object at the top of this stack and returns that
   * object as the value of this function.
   *
   * @return     The object at the top of this stack.
   */
  public Object pop()
  {
    Object val = m_map[--m_firstFree];
    m_map[m_firstFree] = null;

    return val;
  }

  /**
   * Quickly pops a number of items from the stack.
   */

  public void quickPop(int n)
  {
    m_firstFree -= n;
  }

  /**
   * Looks at the object at the top of this stack without removing it
   * from the stack.
   *
   * @return     the object at the top of this stack.
   * @throws  EmptyStackException  if this stack is empty.
   */
  public Object peek()
  {
    try {
      return m_map[m_firstFree - 1];
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      throw new EmptyStackException();
    }
  }

  /**
   * Looks at the object at the position the stack counting down n items.
   *
   * @param n The number of items down, indexed from zero.
   * @return     the object at n items down.
   * @throws  EmptyStackException  if this stack is empty.
   */
  public Object peek(int n)
  {
    try {
      return m_map[m_firstFree-(1+n)];
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      throw new EmptyStackException();
    }
  }

  /**
   * Sets an object at a the top of the statck
   *
   *
   * @param val object to set at the top
   * @throws  EmptyStackException  if this stack is empty.
   */
  public void setTop(Object val)
  {
    try {
      m_map[m_firstFree - 1] = val;
    }
    catch (ArrayIndexOutOfBoundsException e)
    {
      throw new EmptyStackException();
    }
  }

  /**
   * Tests if this stack is empty.
   *
   * @return  true if this stack is empty;
   *          false otherwise.
   * @since   JDK1.0
   */
  public boolean empty()
  {
    return m_firstFree == 0;
  }

  /**
   * Returns where an object is on this stack.
   *
   * @param   o   the desired object.
   * @return  the distance from the top of the stack where the object is]
   *          located; the return value -1 indicates that the
   *          object is not on the stack.
   * @since   JDK1.0
   */
  public int search(Object o)
  {

    int i = lastIndexOf(o);

    if (i >= 0)
    {
      return size() - i;
    }

    return -1;
  }

  /**
   * Returns clone of current ObjectStack
   *
   * @return clone of current ObjectStack
   */
  public Object clone()
    throws CloneNotSupportedException
  {
        return (ObjectStack) super.clone();
  }

}