text:
import { act, renderHook } from '@testing-library/react-hooks';

import { User } from '@proton/shared/lib/interfaces';
import { getDecryptedUserKeysHelper } from '@proton/shared/lib/keys';
import { getUserKey } from '@proton/shared/test/keys/keyDataHelper';

import { generateAddress, releaseCryptoProxy, setupCryptoProxyForTesting } from '../../../utils/test/crypto';
import { LockedVolumeForRestore } from '../interface';
import useSharesState from '../useSharesState';
import useLockedVolume, { useLockedVolumeInner } from './useLockedVolume';

const mockRequest = jest.fn();
jest.mock('../../_api/useDebouncedRequest', () => {
    const useDebouncedRequest = () => {
        return mockRequest;
    };
    return useDebouncedRequest;
});

jest.mock('../../_utils/useDebouncedFunction', () => {
    const useDebouncedFunction = () => {
        return (wrapper: any) => wrapper();
    };
    return useDebouncedFunction;
});

jest.mock('@proton/components/hooks/usePreventLeave', () => {
    const usePreventLeave = () => {
        return (wrapper: any) => wrapper();
    };
    return usePreventLeave;
});

const SHARE_MOCK_1 = {
    shareId: 'shareId1',
    lockedVolumeId: 'volumeId',
    decryptedPassphrase: 'passphrase',
};

const SHARE_MOCK_2 = {
    shareId: 'shareId2',
    lockedVolumeId: 'volumeId',
    decryptedPassphrase: 'passphrase',
};

const mockGetLockedShares = jest.fn();
const mockGetShareWithKey = jest.fn();
const sharesStateMock: ReturnType<typeof useSharesState> = {
    getLockedShares: mockGetLockedShares,
    removeShares: jest.fn(),
    setShares: jest.fn(),
    getShare: jest.fn(),
    getDefaultShareId: jest.fn(),
    setLockedVolumesForRestore: jest.fn(),
    lockedVolumesForRestore: [],
};

const generateAddressKeys = async () => {
    const keyPassword = 'password';
    const userKeysFull = await Promise.all([getUserKey('a', keyPassword, 2), getUserKey('b', keyPassword, 2)]);

    const UserKeys = userKeysFull.map(({ Key }) => Key);
    const User1 = {
        Keys: UserKeys.slice(0, 1),
    } as unknown as User;

    const decryptedUserKeys = await getDecryptedUserKeysHelper(User1, keyPassword);

    return [
        {
            address: await generateAddress(UserKeys, 'email@pm.me'),
            keys: decryptedUserKeys,
        },
    ];
};

const useHook = (props: any = {}) => {
    return useLockedVolumeInner({
        sharesState: sharesStateMock,
        getShareWithKey: jest.fn(),
        addressesKeys: [],
        getDefaultShare: jest.fn(),
        getPrimaryAddressKey: jest.fn(),
        prepareVolumeForRestore: jest.fn(),
        getLinkPrivateKey: jest.fn(),
        getLinkHashKey: jest.fn(),
        ...props,
    });
};

describe('useLockedVolume', () => {
    const abortSignal = new AbortController().signal;
    let hook: {
        current: ReturnType<typeof useLockedVolume>;
    };

    beforeAll(async () => {
        await setupCryptoProxyForTesting();
    });

    afterAll(async () => {
        await releaseCryptoProxy();
    });

    beforeEach(() => {
        jest.resetAllMocks();

        mockGetLockedShares.mockImplementation(() => {
            return [];
        });
    });

    describe('prepareVolumesForRestore', () => {
        it("should return locked volumes if there's no private keys associated with address", async () => {
            const { result } = renderHook(() => useHook());
            hook = result;

            sharesStateMock.lockedVolumesForRestore = [SHARE_MOCK_1, SHARE_MOCK_2];
            await act(async () => {
                const result = await hook.current.prepareVolumesForRestore(abortSignal);
                expect(result).toMatchObject([SHARE_MOCK_1, SHARE_MOCK_2]);
            });
        });
        it("should return locked volumes if there's no locked unprepared shares", async () => {
            const addressesKeys = await generateAddressKeys();
            const { result } = renderHook(() =>
                useHook({
                    addressesKeys,
                })
            );
            hook = result;

            sharesStateMock.lockedVolumesForRestore = [SHARE_MOCK_1, SHARE_MOCK_2];

            await act(async () => {
                const result = await hook.current.prepareVolumesForRestore(abortSignal);
                expect(result).toMatchObject([SHARE_MOCK_1, SHARE_MOCK_2]);
            });
        });

        it("should return locked volumes if there's no new prepared shares", async () => {
            mockGetLockedShares.mockImplementation(() => {
                return [{ shareId: 'shareId' }];
            });
            mockGetShareWithKey.mockImplementation(() => {
                return [{ shareId: 'shareId' }];
            });
            const addressesKeys = await generateAddressKeys();
            const { result } = renderHook(() =>
                useHook({
                    addressesKeys,
                    getShareWithKey: mockGetShareWithKey,
                })
            );
            hook = result;

            sharesStateMock.lockedVolumesForRestore = [SHARE_MOCK_1, SHARE_MOCK_2];

            await act(async () => {
                const result = await hook.current.prepareVolumesForRestore(abortSignal);
                expect(result).toMatchObject([SHARE_MOCK_1, SHARE_MOCK_2]);
            });
        });

        it('should return extended volume list with new prepared volumes', async () => {
            mockGetLockedShares.mockImplementation(() => {
                return [{ shareId: 'shareId' }];
            });
            mockGetShareWithKey.mockImplementation(() => {
                return [{ shareId: 'shareId' }];
            });

            const lockedVolumeForRestore = {
                shareId: 'shareId',
                lockedVolumeId: 'volumeId',
                decryptedPassphrase: 'passphrase',
            } as LockedVolumeForRestore;

            const addressesKeys = await generateAddressKeys();

            const { result } = renderHook(() =>
                useHook({
                    addressesKeys,
                    getShareWithKey: mockGetShareWithKey,
                    prepareVolumeForRestore: async () => lockedVolumeForRestore,
                })
            );
            hook = result;

            sharesStateMock.lockedVolumesForRestore = [SHARE_MOCK_1, SHARE_MOCK_2];

            await act(async () => {
                const result = await hook.current.prepareVolumesForRestore(abortSignal);
                expect(result).toMatchObject([SHARE_MOCK_1, SHARE_MOCK_2, lockedVolumeForRestore]);
            });
        });
    });
});


text:
<?php

namespace React\Stream;

use Evenement\EventEmitter;
use React\EventLoop\LoopInterface;

final class WritableResourceStream extends EventEmitter implements WritableStreamInterface
{
    private $stream;
    private $loop;

    /**
     * @var int
     */
    private $softLimit;

    /**
     * @var int
     */
    private $writeChunkSize;

    private $listening = false;
    private $writable = true;
    private $closed = false;
    private $data = '';

    public function __construct($stream, LoopInterface $loop, $writeBufferSoftLimit = null, $writeChunkSize = null)
    {
        if (!\is_resource($stream) || \get_resource_type($stream) !== "stream") {
            throw new \InvalidArgumentException('First parameter must be a valid stream resource');
        }

        // ensure resource is opened for writing (fopen mode must contain either of "waxc+")
        $meta = \stream_get_meta_data($stream);
        if (isset($meta['mode']) && $meta['mode'] !== '' && \strtr($meta['mode'], 'waxc+', '.....') === $meta['mode']) {
            throw new \InvalidArgumentException('Given stream resource is not opened in write mode');
        }

        // this class relies on non-blocking I/O in order to not interrupt the event loop
        // e.g. pipes on Windows do not support this: https://bugs.php.net/bug.php?id=47918
        if (\stream_set_blocking($stream, false) !== true) {
            throw new \RuntimeException('Unable to set stream resource to non-blocking mode');
        }

        $this->stream = $stream;
        $this->loop = $loop;
        $this->softLimit = ($writeBufferSoftLimit === null) ? 65536 : (int)$writeBufferSoftLimit;
        $this->writeChunkSize = ($writeChunkSize === null) ? -1 : (int)$writeChunkSize;
    }

    public function isWritable()
    {
        return $this->writable;
    }

    public function write($data)
    {
        if (!$this->writable) {
            return false;
        }

        $this->data .= $data;

        if (!$this->listening && $this->data !== '') {
            $this->listening = true;

            $this->loop->addWriteStream($this->stream, array($this, 'handleWrite'));
        }

        return !isset($this->data[$this->softLimit - 1]);
    }

    public function end($data = null)
    {
        if (null !== $data) {
            $this->write($data);
        }

        $this->writable = false;

        // close immediately if buffer is already empty
        // otherwise wait for buffer to flush first
        if ($this->data === '') {
            $this->close();
        }
    }

    public function close()
    {
        if ($this->closed) {
            return;
        }

        if ($this->listening) {
            $this->listening = false;
            $this->loop->removeWriteStream($this->stream);
        }

        $this->closed = true;
        $this->writable = false;
        $this->data = '';

        $this->emit('close');
        $this->removeAllListeners();

        if (\is_resource($this->stream)) {
            \fclose($this->stream);
        }
    }

    /** @internal */
    public function handleWrite()
    {
        $error = null;
        \set_error_handler(function ($_, $errstr) use (&$error) {
            $error = $errstr;
        });

        if ($this->writeChunkSize === -1) {
            $sent = \fwrite($this->stream, $this->data);
        } else {
            $sent = \fwrite($this->stream, $this->data, $this->writeChunkSize);
        }

        \restore_error_handler();

        // Only report errors if *nothing* could be sent and an error has been raised.
        // Ignore non-fatal warnings if *some* data could be sent.
        // Any hard (permanent) error will fail to send any data at all.
        // Sending excessive amounts of data will only flush *some* data and then
        // report a temporary error (EAGAIN) which we do not raise here in order
        // to keep the stream open for further tries to write.
        // Should this turn out to be a permanent error later, it will eventually
        // send *nothing* and we can detect this.
        if (($sent === 0 || $sent === false) && $error !== null) {
            $this->emit('error', array(new \RuntimeException('Unable to write to stream: ' . $error)));
            $this->close();

            return;
        }

        $exceeded = isset($this->data[$this->softLimit - 1]);
        $this->data = (string) \substr($this->data, $sent);

        // buffer has been above limit and is now below limit
        if ($exceeded && !isset($this->data[$this->softLimit - 1])) {
            $this->emit('drain');
        }

        // buffer is now completely empty => stop trying to write
        if ($this->data === '') {
            // stop waiting for resource to be writable
            if ($this->listening) {
                $this->loop->removeWriteStream($this->stream);
                $this->listening = false;
            }

            // buffer is end()ing and now completely empty => close buffer
            if (!$this->writable) {
                $this->close();
            }
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
<?php
/**
 * Automatically generated
 *
 * @author: Viskov Sergey
 * @date: 07.05.15
 */

namespace LTDBeget\apacheConfigurator\directives\available;

use LTDBeget\apacheConfigurator\ConfigurationFile;
use LTDBeget\apacheConfigurator\directives\Directive;

class ProxyAddHeaders extends Directive
{
    /**
     * Return link to full description of apache directive
     * @return String
     */
    public static function getApacheDocLink()
    {
        return Directive::$apacheSite."/docs/2.4/mod/mod_proxy.html#proxyaddheaders";
    }

    /**
     * the source module which defines the directive
     * @return String
     */
    public static function getModule()
    {
        return "mod_proxy";
    }

    /**
     * Return text description of apache directive
     * @return String
     */
    public static function getDescription()
    {
        return "Add proxy information in X-Forwarded-* headers";
    }

    /**
     * Return Apache directive Syntax
     * @return String
     */
    public static function getSyntax()
    {
        return 'ProxyAddHeaders Off|On';
    }

    /**
     * is this directive can include inner directives
     * @return boolean
     */
    public function isSection()
    {
        return false;
    }

    /**
     * Set allowed context of concrete directive
     */
    protected function setAllowedContext()
    {
        $this->allowedContext = [
            ConfigurationFile::SERVER_CONFIG,
            VirtualHost::getFullName(),
            Directory::getFullName(),
        ];
    }

}


text:
package org.cyclops.integrateddynamics.capability.variablefacade;

import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.common.capabilities.CapabilityToken;
import org.cyclops.commoncapabilities.CommonCapabilities;
import org.cyclops.cyclopscore.config.extendedconfig.CapabilityConfig;
import org.cyclops.integrateddynamics.api.item.IVariableFacadeHolder;

/**
 * Config for the variable facade holder capability.
 * @author rubensworks
 *
 */
public class VariableFacadeHolderConfig extends CapabilityConfig<IVariableFacadeHolder> {

    public static Capability<IVariableFacadeHolder> CAPABILITY = CapabilityManager.get(new CapabilityToken<>(){});

    public VariableFacadeHolderConfig() {
        super(
                CommonCapabilities._instance,
                "variable_facade_holder",
                IVariableFacadeHolder.class
        );
    }

}


text:
package org.elasticsearch.common.util.concurrent;

import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matcher;

import java.util.Locale;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.either;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasToString;
import static org.hamcrest.Matchers.lessThan;

/**
 * Tests for EsExecutors and its components like EsAbortPolicy.
 */
public class EsExecutorsTests extends ESTestCase {

    private final ThreadContext threadContext = new ThreadContext(Settings.EMPTY);

    private TimeUnit randomTimeUnit() {
        return TimeUnit.values()[between(0, TimeUnit.values().length - 1)];
    }

    private String getName() {
        return getClass().getName() + "/" + getTestName();
    }

    public void testFixedForcedExecution() throws Exception {
        EsThreadPoolExecutor executor = EsExecutors.newFixed(
            getName(),
            1,
            1,
            EsExecutors.daemonThreadFactory("test"),
            threadContext,
            randomBoolean()
        );
        final CountDownLatch wait = new CountDownLatch(1);

        final CountDownLatch exec1Wait = new CountDownLatch(1);
        final AtomicBoolean executed1 = new AtomicBoolean();
        executor.execute(new Runnable() {
            @Override
            public void run() {
                try {
                    wait.await();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                executed1.set(true);
                exec1Wait.countDown();
            }
        });

        final CountDownLatch exec2Wait = new CountDownLatch(1);
        final AtomicBoolean executed2 = new AtomicBoolean();
        executor.execute(new Runnable() {
            @Override
            public void run() {
                executed2.set(true);
                exec2Wait.countDown();
            }
        });

        final AtomicBoolean executed3 = new AtomicBoolean();
        final CountDownLatch exec3Wait = new CountDownLatch(1);
        executor.execute(new AbstractRunnable() {
            @Override
            protected void doRun() {
                executed3.set(true);
                exec3Wait.countDown();
            }

            @Override
            public boolean isForceExecution() {
                return true;
            }

            @Override
            public void onFailure(Exception e) {
                throw new AssertionError(e);
            }
        });

        wait.countDown();

        exec1Wait.await();
        exec2Wait.await();
        exec3Wait.await();

        assertThat(executed1.get(), equalTo(true));
        assertThat(executed2.get(), equalTo(true));
        assertThat(executed3.get(), equalTo(true));

        executor.shutdownNow();
    }

    public void testFixedRejected() throws Exception {
        EsThreadPoolExecutor executor = EsExecutors.newFixed(
            getName(),
            1,
            1,
            EsExecutors.daemonThreadFactory("test"),
            threadContext,
            randomBoolean()
        );
        final CountDownLatch wait = new CountDownLatch(1);

        final CountDownLatch exec1Wait = new CountDownLatch(1);
        final AtomicBoolean executed1 = new AtomicBoolean();
        executor.execute(new Runnable() {
            @Override
            public void run() {
                try {
                    wait.await();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                executed1.set(true);
                exec1Wait.countDown();
            }
        });

        final CountDownLatch exec2Wait = new CountDownLatch(1);
        final AtomicBoolean executed2 = new AtomicBoolean();
        executor.execute(new Runnable() {
            @Override
            public void run() {
                executed2.set(true);
                exec2Wait.countDown();
            }
        });

        final AtomicBoolean executed3 = new AtomicBoolean();
        try {
            executor.execute(new Runnable() {
                @Override
                public void run() {
                    executed3.set(true);
                }
            });
            fail("should be rejected...");
        } catch (EsRejectedExecutionException e) {
            // all is well
        }

        wait.countDown();

        exec1Wait.await();
        exec2Wait.await();

        assertThat(executed1.get(), equalTo(true));
        assertThat(executed2.get(), equalTo(true));
        assertThat(executed3.get(), equalTo(false));

        terminate(executor);
    }

    public void testScaleUp() throws Exception {
        final int min = between(1, 3);
        final int max = between(min + 1, 6);
        final CyclicBarrier barrier = new CyclicBarrier(max + 1);

        ThreadPoolExecutor pool = EsExecutors.newScaling(
            getClass().getName() + "/" + getTestName(),
            min,
            max,
            between(1, 100),
            randomTimeUnit(),
            EsExecutors.daemonThreadFactory("test"),
            threadContext
        );
        assertThat("Min property", pool.getCorePoolSize(), equalTo(min));
        assertThat("Max property", pool.getMaximumPoolSize(), equalTo(max));

        for (int i = 0; i < max; ++i) {
            final CountDownLatch latch = new CountDownLatch(1);
            pool.execute(() -> {
                latch.countDown();
                try {
                    barrier.await();
                    barrier.await();
                } catch (Exception e) {
                    throw new AssertionError(e);
                }
            });

            // wait until thread executes this task
            // otherwise, a task might be queued
            latch.await();
        }

        barrier.await();
        assertThat("wrong pool size", pool.getPoolSize(), equalTo(max));
        assertThat("wrong active size", pool.getActiveCount(), equalTo(max));
        barrier.await();
        terminate(pool);
    }

    public void testScaleDown() throws Exception {
        final int min = between(1, 3);
        final int max = between(min + 1, 6);
        final CyclicBarrier barrier = new CyclicBarrier(max + 1);

        final ThreadPoolExecutor pool = EsExecutors.newScaling(
            getClass().getName() + "/" + getTestName(),
            min,
            max,
            between(1, 100),
            TimeUnit.MILLISECONDS,
            EsExecutors.daemonThreadFactory("test"),
            threadContext
        );
        assertThat("Min property", pool.getCorePoolSize(), equalTo(min));
        assertThat("Max property", pool.getMaximumPoolSize(), equalTo(max));

        for (int i = 0; i < max; ++i) {
            final CountDownLatch latch = new CountDownLatch(1);
            pool.execute(() -> {
                latch.countDown();
                try {
                    barrier.await();
                    barrier.await();
                } catch (Exception e) {
                    throw new AssertionError(e);
                }
            });

            // wait until thread executes this task
            // otherwise, a task might be queued
            latch.await();
        }

        barrier.await();
        assertThat("wrong pool size", pool.getPoolSize(), equalTo(max));
        assertThat("wrong active size", pool.getActiveCount(), equalTo(max));
        barrier.await();
        assertBusy(() -> {
            assertThat("wrong active count", pool.getActiveCount(), equalTo(0));
            assertThat("idle threads didn't shrink below max. (" + pool.getPoolSize() + ")", pool.getPoolSize(), lessThan(max));
        });
        terminate(pool);
    }

    public void testRejectionMessageAndShuttingDownFlag() throws InterruptedException {
        int pool = between(1, 10);
        int queue = between(0, 100);
        int actions = queue + pool;
        final CountDownLatch latch = new CountDownLatch(1);
        EsThreadPoolExecutor executor = EsExecutors.newFixed(
            getName(),
            pool,
            queue,
            EsExecutors.daemonThreadFactory("dummy"),
            threadContext,
            randomBoolean()
        );
        try {
            for (int i = 0; i < actions; i++) {
                executor.execute(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            latch.await();
                        } catch (InterruptedException e) {
                            throw new RuntimeException(e);
                        }
                    }
                });
            }
            try {
                executor.execute(new Runnable() {
                    @Override
                    public void run() {
                        // Doesn't matter is going to be rejected
                    }

                    @Override
                    public String toString() {
                        return "dummy runnable";
                    }
                });
                fail("Didn't get a rejection when we expected one.");
            } catch (EsRejectedExecutionException e) {
                assertFalse("Thread pool registering as terminated when it isn't", e.isExecutorShutdown());
                String message = e.getMessage();
                assertThat(message, containsString("dummy runnable"));
                assertThat(
                    message,
                    either(containsString("on EsThreadPoolExecutor[name = " + getName())).or(
                        containsString("on EWMATrackingEsThreadPoolExecutor[name = " + getName())
                    )
                );
                assertThat(message, containsString("queue capacity = " + queue));
                assertThat(message, containsString("[Running"));
                /*
                 * While you'd expect all threads in the pool to be active when the queue gets long enough to cause rejections this isn't
                 * always the case. Sometimes you'll see "active threads = <pool - 1>", presumably because one of those threads has finished
                 * its current task but has yet to pick up another task. You too can reproduce this by adding the @Repeat annotation to this
                 * test with something like 10000 iterations. I suspect you could see "active threads = <any natural number <= to pool>". So
                 * that is what we assert.
                 */
                @SuppressWarnings({ "rawtypes", "unchecked" })
                Matcher<String>[] activeThreads = new Matcher[pool + 1];
                for (int p = 0; p <= pool; p++) {
                    activeThreads[p] = containsString("active threads = " + p);
                }
                assertThat(message, anyOf(activeThreads));
                assertThat(message, containsString("queued tasks = " + queue));
                assertThat(message, containsString("completed tasks = 0"));
            }
        } finally {
            latch.countDown();
            terminate(executor);
        }
        try {
            executor.execute(new Runnable() {
                @Override
                public void run() {
                    // Doesn't matter is going to be rejected
                }

                @Override
                public String toString() {
                    return "dummy runnable";
                }
            });
            fail("Didn't get a rejection when we expected one.");
        } catch (EsRejectedExecutionException e) {
            assertTrue("Thread pool not registering as terminated when it is", e.isExecutorShutdown());
            String message = e.getMessage();
            assertThat(message, containsString("dummy runnable"));
            assertThat(
                message,
                either(containsString("on EsThreadPoolExecutor[name = " + getName())).or(
                    containsString("on EWMATrackingEsThreadPoolExecutor[name = " + getName())
                )
            );
            assertThat(message, containsString("queue capacity = " + queue));
            assertThat(message, containsString("[Terminated"));
            assertThat(message, containsString("active threads = 0"));
            assertThat(message, containsString("queued tasks = 0"));
            assertThat(message, containsString("completed tasks = " + actions));
        }
    }

    public void testInheritContext() throws InterruptedException {
        int pool = between(1, 10);
        int queue = between(0, 100);
        final CountDownLatch latch = new CountDownLatch(1);
        final CountDownLatch executed = new CountDownLatch(1);

        threadContext.putHeader("foo", "bar");
        final Integer one = Integer.valueOf(1);
        threadContext.putTransient("foo", one);
        EsThreadPoolExecutor executor = EsExecutors.newFixed(
            getName(),
            pool,
            queue,
            EsExecutors.daemonThreadFactory("dummy"),
            threadContext,
            randomBoolean()
        );
        try {
            executor.execute(() -> {
                try {
                    latch.await();
                } catch (InterruptedException e) {
                    fail();
                }
                assertEquals(threadContext.getHeader("foo"), "bar");
                assertSame(threadContext.getTransient("foo"), one);
                assertNull(threadContext.getHeader("bar"));
                assertNull(threadContext.getTransient("bar"));
                executed.countDown();
            });
            threadContext.putTransient("bar", "boom");
            threadContext.putHeader("bar", "boom");
            latch.countDown();
            executed.await();

        } finally {
            latch.countDown();
            terminate(executor);
        }
    }

    public void testGetTasks() throws InterruptedException {
        int pool = between(1, 10);
        int queue = between(0, 100);
        final CountDownLatch latch = new CountDownLatch(1);
        final CountDownLatch executed = new CountDownLatch(1);
        EsThreadPoolExecutor executor = EsExecutors.newFixed(
            getName(),
            pool,
            queue,
            EsExecutors.daemonThreadFactory("dummy"),
            threadContext,
            randomBoolean()
        );
        try {
            Runnable r = () -> {
                latch.countDown();
                try {
                    executed.await();
                } catch (InterruptedException e) {
                    fail();
                }
            };
            executor.execute(r);
            latch.await();
            executor.getTasks().forEach((runnable) -> assertSame(runnable, r));
            executed.countDown();

        } finally {
            latch.countDown();
            terminate(executor);
        }
    }

    public void testNodeProcessorsBound() {
        final Setting<Integer> processorsSetting = EsExecutors.NODE_PROCESSORS_SETTING;
        final int available = Runtime.getRuntime().availableProcessors();
        final int processors = randomIntBetween(available + 1, Integer.MAX_VALUE);
        final Settings settings = Settings.builder().put(processorsSetting.getKey(), processors).build();
        final IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> processorsSetting.get(settings));
        final String expected = String.format(
            Locale.ROOT,
            "Failed to parse value [%d] for setting [%s] must be <= %d",
            processors,
            processorsSetting.getKey(),
            available
        );
        assertThat(e, hasToString(containsString(expected)));
    }

}


text:
<?php

namespace fkooman\OAuth\ResourceServer;

use fkooman\OAuth\Common\Scope;

class TokenIntrospectionTest extends \PHPUnit_Framework_TestCase
{
    public function testNotActive()
    {
        $t = new TokenIntrospection(array("active" => false));
        $this->assertFalse($t->getActive());
    }

    public function testComplete()
    {
        $now = time();

        $t = new TokenIntrospection(
            array(
                "active" => true,
                "exp" => $now + 1000,
                "iat" => $now - 1000,
                "sub" => "foo",
                "client_id" => "bar",
                "aud" => "foobar",
                "scope" => "foo bar baz",
                "token_type" => "bearer",
                "x-ext" => array("proprietary", "extension", "data")
            )
        );
        $this->assertTrue($t->getActive());
        $this->assertEquals($now + 1000, $t->getExpiresAt());
        $this->assertEquals($now - 1000, $t->getIssuedAt());
        $this->assertEquals("foo", $t->getSub());
        $this->assertEquals("bar", $t->getClientId());
        $this->assertEquals("foobar", $t->getAud());
        $this->assertTrue(
            $t->getScope()->equals(
                new Scope(
                    array(
                        "foo",
                        "bar",
                        "baz"
                    )
                )
            )
        );
        $this->assertEquals("bearer", $t->getTokenType());
        $token = $t->getToken();
        $this->assertEquals(array("proprietary", "extension", "data"), $token["x-ext"]);
    }

    public function testActive()
    {
        $t = new TokenIntrospection(array("active" => true));
        $this->assertTrue($t->getActive());
        // non exiting key should return false
        $this->assertFalse($t->getSub());
    }

    /**
     * @expectedException fkooman\OAuth\ResourceServer\TokenIntrospectionException
     * @expectedExceptionMessage active key should be set and its value a boolean
     */
    public function testMissingActive()
    {
        $t = new TokenIntrospection(array());
    }

    /**
     * @expectedException fkooman\OAuth\ResourceServer\TokenIntrospectionException
     * @expectedExceptionMessage token issued in the future
     */
    public function testIssueTimeInFuture()
    {
        $t = new TokenIntrospection(array("active" => true, "iat" => time()+1000));
    }

    /**
     * @expectedException fkooman\OAuth\ResourceServer\TokenIntrospectionException
     * @expectedExceptionMessage token expired before it was issued
     */
    public function testExpiresBeforeIssued()
    {
        $t = new TokenIntrospection(array("active" => true, "iat" => time()-500, "exp" => time()-1000));
    }

    /**
     * @expectedException fkooman\OAuth\ResourceServer\TokenIntrospectionException
     * @expectedExceptionMessage iat value must be positive integer
     */
    public function testNegativeIssueTime()
    {
        $t = new TokenIntrospection(array("active" => true, "iat" => -4));
    }

    /**
     * @expectedException fkooman\OAuth\ResourceServer\TokenIntrospectionException
     * @expectedExceptionMessage iat value must be positive integer
     */
    public function testNonIntIssueTime()
    {
        $t = new TokenIntrospection(array("active" => true, "iat" => "1234567"));
    }

    /**
     * @expectedException fkooman\OAuth\ResourceServer\TokenIntrospectionException
     * @expectedExceptionMessage exp value must be positive integer
     */
    public function testNonIntExpiryTime()
    {
        $t = new TokenIntrospection(array("active" => true, "exp" => "1234567"));
    }

    /**
     * @expectedException fkooman\OAuth\ResourceServer\TokenIntrospectionException
     * @expectedExceptionMessage exp value must be positive integer
     */
    public function testNegativeExpiryTime()
    {
        $t = new TokenIntrospection(array("active" => true, "exp" => -4));
    }
}


text:
<?xml version="1.0" ?><component loc="43:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/HilTimerMilliC.nc" nicename="HilTimerMilliC" qname="HilTimerMilliC">
      <documentation loc="33:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/HilTimerMilliC.nc">
        <short>
 HilTimerMilliC provides a parameterized interface to a virtualized
 millisecond timer.</short>
        <long>
 HilTimerMilliC provides a parameterized interface to a virtualized
 millisecond timer.  TimerMilliC in tos/system/ uses this component to
 allocate new timers.

 @author Cory Sharp <cssharp@eecs.berkeley.edu>
 @see  Please refer to TEP 102 for more information about this component and its
          intended use.
</long>
      </documentation>
      <configuration/>
      <wiring>
        <wire loc="58:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/HilTimerMilliC.nc">
          <from><interface-ref name="TimerMilli" ref="0x2b6106224670" scoped=""/></from>
          <to><interface-ref name="Timer" ref="0x2b610639b690" scoped=""/></to>
        </wire>
        <wire loc="59:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/HilTimerMilliC.nc">
          <from><interface-ref name="LocalTime" ref="0x2b610621d1a0" scoped=""/></from>
          <to><interface-ref name="LocalTime" ref="0x2b610638ccf0" scoped=""/></to>
        </wire>
        <wire loc="57:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/HilTimerMilliC.nc">
          <from><interface-ref name="Init" ref="0x2b6106228850" scoped=""/></from>
          <to><interface-ref name="Init" ref="0x2b6106303760" scoped=""/></to>
        </wire>
        <wire loc="61:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/HilTimerMilliC.nc">
          <from><interface-ref name="TimerFrom" ref="0x2b6106395c30" scoped=""/></from>
          <to><interface-ref name="Timer" ref="0x2b6106343cf0" scoped=""/></to>
        </wire>
        <wire loc="62:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/HilTimerMilliC.nc">
          <from><interface-ref name="Alarm" ref="0x2b610633d1d0" scoped=""/></from>
          <to><interface-ref name="Alarm" ref="0x2b6106302020" scoped=""/></to>
        </wire>
        <wire loc="63:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/HilTimerMilliC.nc">
          <from><interface-ref name="Counter" ref="0x2b61063b9020" scoped=""/></from>
          <to><interface-ref name="Counter" ref="0x2b61062ab020" scoped=""/></to>
        </wire>
      </wiring>
    <specification><interface loc="46:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/HilTimerMilliC.nc" name="TimerMilli" provided="1" ref="0x2b6106224670">
      <component-ref nicename="HilTimerMilliC" qname="HilTimerMilliC"/>
      <type-interface alignment="I:2" size="I:2"><interface-ref name="TimerMilli" ref="0x2b6106224670" scoped=""/></type-interface>
      <instance>
        <interfacedef-ref nicename="Timer" qname="Timer"/>
        <arguments>
          <type-tag alignment="I:2" size="I:2"><struct-ref ref="0x2b6105f515c0"/>
            <typename><typedef-ref name="TMilli" ref="0x2b6105f51930"/></typename>
          </type-tag>
        </arguments>
      </instance>
      <interface-parameters>
        <type-int alignment="I:1" cname="unsigned char" size="I:1" unsigned="">
          <typename><typedef-ref name="uint8_t" ref="0x2b6104f08160"/></typename>
        </type-int>
      </interface-parameters>
      <interface-functions>
        <function-ref name="getNow" ref="0x2b6106220c40" scoped=""/>
        <function-ref name="fired" ref="0x2b61062211e0" scoped=""/>
        <function-ref name="startPeriodicAt" ref="0x2b6106220020" scoped=""/>
        <function-ref name="isOneShot" ref="0x2b6106221ae0" scoped=""/>
        <function-ref name="getdt" ref="0x2b610621f590" scoped=""/>
        <function-ref name="gett0" ref="0x2b610621f110" scoped=""/>
        <function-ref name="isRunning" ref="0x2b6106221660" scoped=""/>
        <function-ref name="startPeriodic" ref="0x2b6106223390" scoped=""/>
        <function-ref name="startOneShotAt" ref="0x2b6106220630" scoped=""/>
        <function-ref name="startOneShot" ref="0x2b6106223860" scoped=""/>
        <function-ref name="stop" ref="0x2b6106223d30" scoped=""/>
      </interface-functions>
    </interface><interface loc="47:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/HilTimerMilliC.nc" name="LocalTime" provided="1" ref="0x2b610621d1a0">
      <component-ref nicename="HilTimerMilliC" qname="HilTimerMilliC"/>
      <type-interface alignment="I:2" size="I:2"><interface-ref name="LocalTime" ref="0x2b610621d1a0" scoped=""/></type-interface>
      <instance>
        <interfacedef-ref nicename="LocalTime" qname="LocalTime"/>
        <arguments>
          <type-tag alignment="I:2" size="I:2"><struct-ref ref="0x2b6105f515c0"/>
            <typename><typedef-ref name="TMilli" ref="0x2b6105f51930"/></typename>
          </type-tag>
        </arguments>
      </instance>
      <interface-functions>
        <function-ref name="get" ref="0x2b610621ddd0" scoped=""/>
      </interface-functions>
    </interface><interface loc="45:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/HilTimerMilliC.nc" name="Init" provided="1" ref="0x2b6106228850">
      <component-ref nicename="HilTimerMilliC" qname="HilTimerMilliC"/>
      <type-interface alignment="I:2" size="I:2"><interface-ref name="Init" ref="0x2b6106228850" scoped=""/></type-interface>
      <instance>
        <interfacedef-ref nicename="Init" qname="Init"/>
      </instance>
      <interface-functions>
        <function-ref name="init" ref="0x2b6106228bd0" scoped=""/>
      </interface-functions>
    </interface></specification><referenced><interface loc="43:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/AlarmMilli32C.nc" name="Init" provided="1" ref="0x2b6106303760">
      <component-ref nicename="HilTimerMilliC.AlarmMilli32C" qname="HilTimerMilliC.AlarmMilli32C"/>
      <type-interface alignment="I:2" size="I:2"><interface-ref name="Init" ref="0x2b6106303760" scoped=""/></type-interface>
      <instance>
        <interfacedef-ref nicename="Init" qname="Init"/>
      </instance>
      <interface-functions>
        <function-ref name="init" ref="0x2b6106303ae0" scoped=""/>
      </interface-functions>
    </interface><interface loc="49:/opt/tinyos-release-tinyos-2_1_2//tos/lib/timer/AlarmToTimerC.nc" name="Alarm" provided="0" ref="0x2b610633d1d0">
      <component-ref nicename="HilTimerMilliC.AlarmToTimerC" qname="HilTimerMilliC.AlarmToTimerC"/>
      <type-interface alignment="I:2" size="I:2"><interface-ref name="Alarm" ref="0x2b610633d1d0" scoped=""/></type-interface>
      <instance>
        <interfacedef-ref nicename="Alarm" qname="Alarm"/>
        <arguments>
          <type-tag alignment="I:2" size="I:2"><struct-ref ref="0x2b6105f515c0"/>
            <typename><typedef-ref name="TMilli" ref="0x2b6105f51930"/></typename>
          </type-tag>
          <type-int alignment="I:2" cname="unsigned long" size="I:4" unsigned="">
            <typename><typedef-ref name="uint32_t" ref="0x2b6104f08920"/></typename>
          </type-int>
        </arguments>
      </instance>
      <interface-functions>
        <function-ref name="getNow" ref="0x2b610633ab30" scoped=""/>
        <function-ref name="fired" ref="0x2b610633c9f0" scoped=""/>
        <function-ref name="startAt" ref="0x2b610633a4e0" scoped=""/>
        <function-ref name="isRunning" ref="0x2b610633a020" scoped=""/>
        <function-ref name="getAlarm" ref="0x2b6106339020" scoped=""/>
        <function-ref name="start" ref="0x2b610633c020" scoped=""/>
        <function-ref name="stop" ref="0x2b610633c530" scoped=""/>
      </interface-functions>
    </interface><interface loc="44:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/AlarmMilli32C.nc" name="Alarm" provided="1" ref="0x2b6106302020">
      <component-ref nicename="HilTimerMilliC.AlarmMilli32C" qname="HilTimerMilliC.AlarmMilli32C"/>
      <type-interface alignment="I:2" size="I:2"><interface-ref name="Alarm" ref="0x2b6106302020" scoped=""/></type-interface>
      <instance>
        <interfacedef-ref nicename="Alarm" qname="Alarm"/>
        <arguments>
          <type-tag alignment="I:2" size="I:2"><struct-ref ref="0x2b6105f515c0"/>
            <typename><typedef-ref name="TMilli" ref="0x2b6105f51930"/></typename>
          </type-tag>
          <type-int alignment="I:2" cname="unsigned long" size="I:4" unsigned="">
            <typename><typedef-ref name="uint32_t" ref="0x2b6104f08920"/></typename>
          </type-int>
        </arguments>
      </instance>
      <interface-functions>
        <function-ref name="getNow" ref="0x2b6106300870" scoped=""/>
        <function-ref name="fired" ref="0x2b6106301840" scoped=""/>
        <function-ref name="startAt" ref="0x2b6106300220" scoped=""/>
        <function-ref name="isRunning" ref="0x2b6106301d00" scoped=""/>
        <function-ref name="getAlarm" ref="0x2b6106300d30" scoped=""/>
        <function-ref name="start" ref="0x2b6106302e30" scoped=""/>
        <function-ref name="stop" ref="0x2b6106301380" scoped=""/>
      </interface-functions>
    </interface><interface loc="48:/opt/tinyos-release-tinyos-2_1_2//tos/lib/timer/VirtualizeTimerC.nc" name="Timer" provided="1" ref="0x2b610639b690">
      <component-ref nicename="HilTimerMilliC.VirtualizeTimerC" qname="HilTimerMilliC.VirtualizeTimerC"/>
      <type-interface alignment="I:2" size="I:2"><interface-ref name="Timer" ref="0x2b610639b690" scoped=""/></type-interface>
      <instance>
        <interfacedef-ref nicename="Timer" qname="Timer"/>
        <arguments>
          <type-tag alignment="I:2" size="I:2"><struct-ref ref="0x2b6105f515c0"/>
            <typename><typedef-ref name="TMilli" ref="0x2b6105f51930"/></typename>
          </type-tag>
        </arguments>
      </instance>
      <interface-parameters>
        <type-int alignment="I:1" cname="unsigned char" size="I:1" unsigned="">
          <typename><typedef-ref name="uint8_t" ref="0x2b6104f08160"/></typename>
        </type-int>
      </interface-parameters>
      <interface-functions>
        <function-ref name="getNow" ref="0x2b6106397cf0" scoped=""/>
        <function-ref name="fired" ref="0x2b6106398260" scoped=""/>
        <function-ref name="startPeriodicAt" ref="0x2b6106397090" scoped=""/>
        <function-ref name="isOneShot" ref="0x2b6106398ba0" scoped=""/>
        <function-ref name="getdt" ref="0x2b6106395680" scoped=""/>
        <function-ref name="gett0" ref="0x2b61063951e0" scoped=""/>
        <function-ref name="isRunning" ref="0x2b6106398700" scoped=""/>
        <function-ref name="startPeriodic" ref="0x2b610639a390" scoped=""/>
        <function-ref name="startOneShotAt" ref="0x2b61063976c0" scoped=""/>
        <function-ref name="startOneShot" ref="0x2b610639a880" scoped=""/>
        <function-ref name="stop" ref="0x2b610639ad70" scoped=""/>
      </interface-functions>
    </interface><interface loc="48:/opt/tinyos-release-tinyos-2_1_2//tos/lib/timer/AlarmToTimerC.nc" name="Timer" provided="1" ref="0x2b6106343cf0">
      <component-ref nicename="HilTimerMilliC.AlarmToTimerC" qname="HilTimerMilliC.AlarmToTimerC"/>
      <type-interface alignment="I:2" size="I:2"><interface-ref name="Timer" ref="0x2b6106343cf0" scoped=""/></type-interface>
      <instance>
        <interfacedef-ref nicename="Timer" qname="Timer"/>
        <arguments>
          <type-tag alignment="I:2" size="I:2"><struct-ref ref="0x2b6105f515c0"/>
            <typename><typedef-ref name="TMilli" ref="0x2b6105f51930"/></typename>
          </type-tag>
        </arguments>
      </instance>
      <interface-functions>
        <function-ref name="getNow" ref="0x2b610633e220" scoped=""/>
        <function-ref name="fired" ref="0x2b61063417c0" scoped=""/>
        <function-ref name="startPeriodicAt" ref="0x2b610633f590" scoped=""/>
        <function-ref name="isOneShot" ref="0x2b610633f110" scoped=""/>
        <function-ref name="getdt" ref="0x2b610633eb20" scoped=""/>
        <function-ref name="gett0" ref="0x2b610633e6a0" scoped=""/>
        <function-ref name="isRunning" ref="0x2b6106341c40" scoped=""/>
        <function-ref name="startPeriodic" ref="0x2b6106342940" scoped=""/>
        <function-ref name="startOneShotAt" ref="0x2b610633fba0" scoped=""/>
        <function-ref name="startOneShot" ref="0x2b6106342e10" scoped=""/>
        <function-ref name="stop" ref="0x2b6106341340" scoped=""/>
      </interface-functions>
    </interface><interface loc="49:/opt/tinyos-release-tinyos-2_1_2//tos/lib/timer/VirtualizeTimerC.nc" name="TimerFrom" provided="0" ref="0x2b6106395c30">
      <component-ref nicename="HilTimerMilliC.VirtualizeTimerC" qname="HilTimerMilliC.VirtualizeTimerC"/>
      <type-interface alignment="I:2" size="I:2"><interface-ref name="TimerFrom" ref="0x2b6106395c30" scoped=""/></type-interface>
      <instance>
        <interfacedef-ref nicename="Timer" qname="Timer"/>
        <arguments>
          <type-tag alignment="I:2" size="I:2"><struct-ref ref="0x2b6105f515c0"/>
            <typename><typedef-ref name="TMilli" ref="0x2b6105f51930"/></typename>
          </type-tag>
        </arguments>
      </instance>
      <interface-functions>
        <function-ref name="getNow" ref="0x2b6106390110" scoped=""/>
        <function-ref name="fired" ref="0x2b61063926a0" scoped=""/>
        <function-ref name="startPeriodicAt" ref="0x2b61063914a0" scoped=""/>
        <function-ref name="isOneShot" ref="0x2b6106391020" scoped=""/>
        <function-ref name="getdt" ref="0x2b6106390a10" scoped=""/>
        <function-ref name="gett0" ref="0x2b6106390590" scoped=""/>
        <function-ref name="isRunning" ref="0x2b6106392b20" scoped=""/>
        <function-ref name="startPeriodic" ref="0x2b6106394860" scoped=""/>
        <function-ref name="startOneShotAt" ref="0x2b6106391ab0" scoped=""/>
        <function-ref name="startOneShot" ref="0x2b6106394d30" scoped=""/>
        <function-ref name="stop" ref="0x2b6106392220" scoped=""/>
      </interface-functions>
    </interface><interface loc="43:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/CounterMilli32C.nc" name="Counter" provided="1" ref="0x2b61062ab020">
      <component-ref nicename="CounterMilli32C" qname="CounterMilli32C"/>
      <type-interface alignment="I:2" size="I:2"><interface-ref name="Counter" ref="0x2b61062ab020" scoped=""/></type-interface>
      <instance>
        <interfacedef-ref nicename="Counter" qname="Counter"/>
        <arguments>
          <type-tag alignment="I:2" size="I:2"><struct-ref ref="0x2b6105f515c0"/>
            <typename><typedef-ref name="TMilli" ref="0x2b6105f51930"/></typename>
          </type-tag>
          <type-int alignment="I:2" cname="unsigned long" size="I:4" unsigned="">
            <typename><typedef-ref name="uint32_t" ref="0x2b6104f08920"/></typename>
          </type-int>
        </arguments>
      </instance>
      <interface-functions>
        <function-ref name="get" ref="0x2b61062abe30" scoped=""/>
        <function-ref name="clearOverflow" ref="0x2b61062a6800" scoped=""/>
        <function-ref name="isOverflowPending" ref="0x2b61062a6340" scoped=""/>
        <function-ref name="overflow" ref="0x2b61062a6cc0" scoped=""/>
      </interface-functions>
    </interface><interface loc="48:/opt/tinyos-release-tinyos-2_1_2//tos/lib/timer/CounterToLocalTimeC.nc" name="LocalTime" provided="1" ref="0x2b610638ccf0">
      <component-ref nicename="HilTimerMilliC.CounterToLocalTimeC" qname="HilTimerMilliC.CounterToLocalTimeC"/>
      <type-interface alignment="I:2" size="I:2"><interface-ref name="LocalTime" ref="0x2b610638ccf0" scoped=""/></type-interface>
      <instance>
        <interfacedef-ref nicename="LocalTime" qname="LocalTime"/>
        <arguments>
          <type-tag alignment="I:2" size="I:2"><struct-ref ref="0x2b6105f515c0"/>
            <typename><typedef-ref name="TMilli" ref="0x2b6105f51930"/></typename>
          </type-tag>
        </arguments>
      </instance>
      <interface-functions>
        <function-ref name="get" ref="0x2b610638b980" scoped=""/>
      </interface-functions>
    </interface><interface loc="49:/opt/tinyos-release-tinyos-2_1_2//tos/lib/timer/CounterToLocalTimeC.nc" name="Counter" provided="0" ref="0x2b61063b9020">
      <component-ref nicename="HilTimerMilliC.CounterToLocalTimeC" qname="HilTimerMilliC.CounterToLocalTimeC"/>
      <type-interface alignment="I:2" size="I:2"><interface-ref name="Counter" ref="0x2b61063b9020" scoped=""/></type-interface>
      <instance>
        <interfacedef-ref nicename="Counter" qname="Counter"/>
        <arguments>
          <type-tag alignment="I:2" size="I:2"><struct-ref ref="0x2b6105f515c0"/>
            <typename><typedef-ref name="TMilli" ref="0x2b6105f51930"/></typename>
          </type-tag>
          <type-int alignment="I:2" cname="unsigned long" size="I:4" unsigned="">
            <typename><typedef-ref name="uint32_t" ref="0x2b6104f08920"/></typename>
          </type-int>
        </arguments>
      </instance>
      <interface-functions>
        <function-ref name="get" ref="0x2b61063b9e30" scoped=""/>
        <function-ref name="clearOverflow" ref="0x2b61063b8800" scoped=""/>
        <function-ref name="isOverflowPending" ref="0x2b61063b8340" scoped=""/>
        <function-ref name="overflow" ref="0x2b61063b8cc0" scoped=""/>
      </interface-functions>
    </interface><component loc="46(HilTimerMilliC.AlarmToTimerC):/opt/tinyos-release-tinyos-2_1_2//tos/lib/timer/AlarmToTimerC.nc" nicename="HilTimerMilliC.AlarmToTimerC" qname="HilTimerMilliC.AlarmToTimerC">
      <documentation loc="36:/opt/tinyos-release-tinyos-2_1_2//tos/lib/timer/AlarmToTimerC.nc">
        <short>
 AlarmToTimerC converts a 32-bit Alarm to a Timer.</short>
        <long>
 AlarmToTimerC converts a 32-bit Alarm to a Timer.

See TEP102 for more details.
 @param precision_tag A type indicating the precision of the Alarm and
 Timer being converted.

 @author Cory Sharp <cssharp@eecs.berkeley.edu>
</long>
      </documentation>
      <instance number="0">
        <component-ref nicename="AlarmToTimerC" qname="AlarmToTimerC"/>
        <arguments>
          <type-tag alignment="I:2" size="I:2"><struct-ref ref="0x2b6105f515c0"/>
            <typename><typedef-ref name="TMilli" ref="0x2b6105f51930"/></typename>
          </type-tag>
        </arguments>
      </instance>
      <module/>
    </component><component loc="46(HilTimerMilliC.CounterToLocalTimeC):/opt/tinyos-release-tinyos-2_1_2//tos/lib/timer/CounterToLocalTimeC.nc" nicename="HilTimerMilliC.CounterToLocalTimeC" qname="HilTimerMilliC.CounterToLocalTimeC">
      <documentation loc="36:/opt/tinyos-release-tinyos-2_1_2//tos/lib/timer/CounterToLocalTimeC.nc">
        <short>
 CounterToLocalTimeC converts a 32-bit LocalTime to a Counter.</short>
        <long>
 CounterToLocalTimeC converts a 32-bit LocalTime to a Counter.

See TEP102 for more details.
 @param precision_tag A type indicating the precision of the LocalTime and
 Counter being converted.

 @author Cory Sharp <cssharp@eecs.berkeley.edu>
</long>
      </documentation>
      <instance number="0">
        <component-ref nicename="CounterToLocalTimeC" qname="CounterToLocalTimeC"/>
        <arguments>
          <type-tag alignment="I:2" size="I:2"><struct-ref ref="0x2b6105f515c0"/>
            <typename><typedef-ref name="TMilli" ref="0x2b6105f51930"/></typename>
          </type-tag>
        </arguments>
      </instance>
      <module/>
    </component><component loc="41:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/CounterMilli32C.nc" nicename="CounterMilli32C" qname="CounterMilli32C">
      <documentation loc="33:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/CounterMilli32C.nc">
        <short>
 CounterMilli32C provides at 32-bit counter at 1024 ticks per second.</short>
        <long>
 CounterMilli32C provides at 32-bit counter at 1024 ticks per second.

 @author Cory Sharp <cssharp@eecs.berkeley.edu>
 @see  Please refer to TEP 102 for more information about this component and its
          intended use.
</long>
      </documentation>
      <configuration/>
      <wiring>
        <wire loc="50:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/CounterMilli32C.nc">
          <from><interface-ref name="Counter" ref="0x2b61062ab020" scoped=""/></from>
          <to><interface-ref name="Counter" ref="0x2b61062d80f0" scoped=""/></to>
        </wire>
        <wire loc="52:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/CounterMilli32C.nc">
          <from><interface-ref name="CounterFrom" ref="0x2b61062d6540" scoped=""/></from>
          <to><interface-ref name="Msp430Counter32khz" ref="0x2b61062a2060" scoped=""/></to>
        </wire>
      </wiring>
    </component><component loc="41(HilTimerMilliC.AlarmMilli32C):/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/AlarmMilli32C.nc" nicename="HilTimerMilliC.AlarmMilli32C" qname="HilTimerMilliC.AlarmMilli32C">
      <documentation loc="33:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/AlarmMilli32C.nc">
        <short>
 AlarmMilliC is the alarm for async millisecond alarms

 </short>
        <long>
 AlarmMilliC is the alarm for async millisecond alarms

 @author Cory Sharp <cssharp@eecs.berkeley.edu>
 @see  Please refer to TEP 102 for more information about this component and its
          intended use.
</long>
      </documentation>
      <instance number="0">
        <component-ref nicename="AlarmMilli32C" qname="AlarmMilli32C"/>
      </instance>
      <configuration/>
      <wiring>
        <wire loc="53:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/AlarmMilli32C.nc">
          <from><interface-ref name="Alarm" ref="0x2b6106302020" scoped=""/></from>
          <to><interface-ref name="Alarm" ref="0x2b61080e2020" scoped=""/></to>
        </wire>
        <wire loc="52:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/AlarmMilli32C.nc">
          <from><interface-ref name="Init" ref="0x2b6106303760" scoped=""/></from>
          <to><interface-ref name="Init" ref="0x2b61080e9380" scoped=""/></to>
        </wire>
        <wire loc="55:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/AlarmMilli32C.nc">
          <from><interface-ref name="AlarmFrom" ref="0x2b61080dc780" scoped=""/></from>
          <to><interface-ref name="Alarm" ref="0x2b61080e9bd0" scoped=""/></to>
        </wire>
        <wire loc="56:/opt/tinyos-release-tinyos-2_1_2//tos/chips/msp430/timer/AlarmMilli32C.nc">
          <from><interface-ref name="Counter" ref="0x2b61080de3d0" scoped=""/></from>
          <to><interface-ref name="Counter" ref="0x2b61062ab020" scoped=""/></to>
        </wire>
      </wiring>
    </component><component loc="46(HilTimerMilliC.VirtualizeTimerC):/opt/tinyos-release-tinyos-2_1_2//tos/lib/timer/VirtualizeTimerC.nc" nicename="HilTimerMilliC.VirtualizeTimerC" qname="HilTimerMilliC.VirtualizeTimerC">
      <documentation loc="34:/opt/tinyos-release-tinyos-2_1_2//tos/lib/timer/VirtualizeTimerC.nc">
        <short>
 VirtualizeTimerC uses a single Timer to create up to 255 virtual timers.</short>
        <long>
 VirtualizeTimerC uses a single Timer to create up to 255 virtual timers.

See TEP102 for more details.

 @param precision_tag A type indicating the precision of the Timer being
   virtualized.
 @param max_timers Number of virtual timers to create.

 @author Cory Sharp <cssharp@eecs.berkeley.edu>
</long>
      </documentation>
      <instance number="0">
        <component-ref nicename="VirtualizeTimerC" qname="VirtualizeTimerC"/>
        <arguments>
          <type-tag alignment="I:2" size="I:2"><struct-ref ref="0x2b6105f515c0"/>
            <typename><typedef-ref name="TMilli" ref="0x2b6105f51930"/></typename>
          </type-tag>
          <value cst="I:6">
            <type-int alignment="I:2" cname="unsigned int" size="I:2" unsigned=""/>
          </value>
        </arguments>
      </instance>
      <module/>
    </component></referenced></component>


text:
package org.dcm4chex.xds.audit;

import java.net.InetAddress;
import java.net.UnknownHostException;

import javax.security.jacc.PolicyContext;
import javax.security.jacc.PolicyContextException;
import javax.servlet.http.HttpServletRequest;

/**
 * @author Gunter Zeilinger <gunterze@gmail.com>
 * @version $Revision: 3313 $ $Date: 2007-05-07 13:52:31 +0200 (Mo, 07 Mai 2007) $
 * @since Mar 7, 2007
 */
public class HttpUserInfo {
    private static final String WEB_REQUEST_KEY =
            "javax.servlet.http.HttpServletRequest";
    private String userId;
    private String ip;
    private String hostName;
	private String requestURI;

    public HttpUserInfo(boolean enableDNSLookups) {
        try {
            HttpServletRequest rq = (HttpServletRequest)
                    PolicyContext.getContext(WEB_REQUEST_KEY);
            init(rq, enableDNSLookups);
        } catch (PolicyContextException e) {
            userId = "UNKOWN_USER";
        }
    }
    public HttpUserInfo(HttpServletRequest rq, boolean enableDNSLookups) {
        init(rq, enableDNSLookups);
    }

    private void init(HttpServletRequest rq, boolean enableDNSLookups) {
        userId = rq.getRemoteUser();
        String xForward = (String) rq.getHeader("x-forwarded-for");
        if (xForward != null) {
            int pos = xForward.indexOf(',');
            ip = (pos > 0 ? xForward.substring(0,pos) : xForward).trim();
        } else {
            ip = rq.getRemoteAddr();
        }
        if ( enableDNSLookups ) {
            try {
                hostName = InetAddress.getByName(ip).getHostName();
            } catch (UnknownHostException ignore) {
                hostName = ip;
            }
        } else {
            hostName = ip;
        }
        requestURI = rq.getRequestURI();
    }

    public String getUserId() {
        return userId;
    }
    public String getIP() {
        return ip;
    }

    public String getHostName() {
        return hostName;
    }
	public String getRequestURI() {
		return requestURI;
	}

}


text:
<!DOCTYPE html>

	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width">
	@section('title')
		<title>{{{$title}}}</title>
	@show
	{{ HTML::script('js/vendor/modernizr.js') }}
	{{ HTML::script('js/vendor/jquery.js') }}
	{{ HTML::style('css/font-awesome.min.css') }}
	{{ HTML::style('http://fonts.googleapis.com/css?family=Amatic+SC:400,700') }}
	{{ HTML::style('http://lab.lepture.com/editor/editor.css') }}
	{{ HTML::style('css/open-iconic-foundation.css') }}
	{{ HTML::style('css/lepture.css') }}
	{{ HTML::style('css/foundation.css') }}
	{{ HTML::style('css/admin.css') }}

Menu

Easy Peasy Lemon Squeezy

							{{HTML::linkRoute('admin.menu.index','Menu')}}

							{{HTML::linkRoute('admin.pages.index','Pages')}}

							{{HTML::linkRoute('posts.index','Articles')}}

							{{ HTML::linkRoute('comment.list','Commentaires') }}

							@if(Auth::user()->admin == 1)
								{{ HTML::linkRoute('admin.user.index','Utilisateurs') }}
							@else
								{{ HTML::linkRoute('admin.user.show','Mon profil',Auth::user()->id) }}
							@endif

						@if(Auth::check())

								{{-- HTML::link('auth/logout','Se déconnecter') --}}

						@else

								{{HTML::link('auth/login','Se connecter')}}

						@endif


text:
You've probably already cloned this repository since we walked through
cloning and committing to the project. If you haven't cloned the
project, you can clone it by running:

```
eval "$(ssh-agent -s)"
ssh-add
cd ~
git clone git@github.com:boosted-chimps/boosted-examples.git
```

Cloning the repository will create a `boosted-examples` directory
within your home directory.

Move into `boosted-examples/homework/`. There is a github component to
the homework so we'll start working in this directory.

```
cd boosted-examples/homework/
```

## Assignment

1. Create a directory for yourself (e.g. `abutcher`) within `~/boosted-examples/homework`.

2. Within directory you just created, create a `homework1.py` file which will contain your work (e.g. `~/boosted-examples/homework/abutcher/homework1.py`).

3. Edit `homework1.py` and write the following functions:
  * Create a function which, given a string, will return `True` if the
    string is a palindrome. The function must return `False` if the
    provided string is not a palindrome. A palindrome is a word or
    phrase that reads the same backward as forward such as `"racecar"`.
    This function must ignore spaces in the string such that a phrase
    like `"are we not drawn onward to new era"` will be recognized as a
    palindrome.
  * Create a function that accepts a list of strings and prints out
    which strings are palindromes (using the palindrome function).
  ```python
  >>> palindromes(["racecar", "are we not drawn onward to new era", "malathar"])
  racecar is a palindrome
  are we not drawn onward to new era is a palindrome
  ```
4. Commit your `homework1.py` file using git and push your new file to github.


text:
package harmonizer_test

import (
	"errors"
	"os"

	"code.cloudfoundry.org/lager/lagertest"
	"code.cloudfoundry.org/operationq"
	"code.cloudfoundry.org/operationq/fake_operationq"
	"code.cloudfoundry.org/rep/generator/fake_generator"
	"code.cloudfoundry.org/rep/harmonizer"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/tedsuo/ifrit"
)

var _ = Describe("EventConsumer", func() {
	var (
		logger        *lagertest.TestLogger
		fakeGenerator *fake_generator.FakeGenerator
		fakeQueue     *fake_operationq.FakeQueue

		consumer *harmonizer.EventConsumer
		process  ifrit.Process
	)

	BeforeEach(func() {
		logger = lagertest.NewTestLogger("test")
		fakeGenerator = new(fake_generator.FakeGenerator)
		fakeQueue = new(fake_operationq.FakeQueue)

		consumer = harmonizer.NewEventConsumer(logger, fakeGenerator, fakeQueue)
	})

	JustBeforeEach(func() {
		process = ifrit.Invoke(consumer)
	})

	AfterEach(func() {
		process.Signal(os.Interrupt)
		Eventually(process.Wait()).Should(Receive())
	})

	Context("when subscribing to the operation stream succeeds", func() {
		var (
			receivedOperations chan<- operationq.Operation
		)

		BeforeEach(func() {
			operations := make(chan operationq.Operation)
			receivedOperations = operations

			fakeGenerator.OperationStreamReturns(operations, nil)
		})

		Context("when an operation is received", func() {
			var fakeOperation *fake_operationq.FakeOperation

			BeforeEach(func() {
				fakeOperation = new(fake_operationq.FakeOperation)
			})

			It("pushes it onto the queue", func() {
				receivedOperations <- fakeOperation

				Eventually(fakeQueue.PushCallCount).Should(Equal(1))
				Expect(fakeQueue.PushArgsForCall(0)).To(Equal(fakeOperation))
			})
		})

		Context("when the operation stream terminates", func() {
			It("exits happily", func() {
				close(receivedOperations)

				Eventually(process.Wait()).Should(Receive(BeNil()))
			})
		})
	})

	Context("when subscribing to events fails", func() {
		disaster := errors.New("nope")

		BeforeEach(func() {
			fakeGenerator.OperationStreamReturns(nil, disaster)
		})

		It("exits with failure", func() {
			Eventually(process.Wait()).Should(Receive(Equal(disaster)))
		})
	})
})


text:
.. _dojo/store/util/SimpleQueryEngine:

=================================
dojo/store/util/SimpleQueryEngine
=================================

:Authors: Kris Zyp
:Project owner: Kris Zyp
:since: V1.6

.. contents ::
  :depth: 2

Introduction
============

The SimpleQueryEngine utility provides basic querying functionality for JavaScript objects. The main export of SimpleQueryEngine is a function that can be called with a query (and options optionally) and returns another function that will execute queries against an array. The query can be an object in which case the results are filtered to objects with properties that match the name value pairs provided by the query object. The query can be a function in which case the results are filtered to objects that when passed to the provided function return a truthy value. The query can also be a string, in which case the string is used to lookup up a method on the store that acts as the filter function.

Options
=======

The SimpleQueryEngine also handles sorting and paging per the dojo/store API. The query options argument (the second argument) may be an object with the following properties:

* start - The start offset of the results
* count - The (maximum) number of objects to return in the results
* sort - An array of sort objects (that have an "attribute" and "descending" property) to describe the sort order. Alternately this may be a function that can be passed to the standard Array.prototype.sort() method.

Examples
========

.. js ::

  require(["dojo/store/util/SimpleQueryEngine"],
      function(SimpleQueryEngine){
          var someData = [
              {id:1, name:"One"},
              {id:2, name:"Two"}
          ];
          SimpleQueryEngine({name:"One"})(someData) -> // Returns an array with just the first object

          SimpleQueryEngine(function(object){
          return object.id > 1;
  })(someData) // Returns an array with just the first object

See Also
========

The dojo/store/Memory store uses the SimpleQueryEngine for querying. SimpleQueryEngine can also be used with JsonRest store to make it Observable.

:ref:`dojo/store/Memory <dojo/store/Memory>`


text:
<form action="login_submit" method="POST">
    <input type="hidden" name="fw" value="<?php echo base_url();?>article/displist/0">

用户名:<input type="text" name="username">

密码:<input type="password" name="password">

<input type="submit" value="登录">

</form>


text:
<?xml version="1.0" encoding="UTF-8"?>
<lcm:SubmitObjectsRequest xmlns:lcm="urn:oasis:names:tc:ebxml-regrep:xsd:lcm:3.0">
    <rim:RegistryObjectList xmlns:rim="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0">
        <rim:RegistryPackage id="SubmissionSet" objectType="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:RegistryPackage">
            <rim:Slot name="submissionTime">
                <rim:ValueList>
                    <rim:Value>20041225235050</rim:Value>
                </rim:ValueList>
            </rim:Slot>
            <rim:Name>
                <rim:LocalizedString xml:lang="en-us" charset="UTF-8" value="Physical"/>
            </rim:Name>
            <rim:Description>
                <rim:LocalizedString xml:lang="en-us" charset="UTF-8" value="Annual physical"/>
            </rim:Description>
            <rim:VersionInfo versionName="1.1"/>
            <rim:Classification id="scl1" objectType="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Classification" classifiedObject="SubmissionSet" classificationNode="urn:uuid:a54d6aa5-d40d-43f9-88c5-b4633d873bdd"/>
            <rim:Classification id="scl2" objectType="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Classification" classificationScheme="urn:uuid:a7058bb9-b4e4-4307-ba5b-e3f0ab85e12d" classifiedObject="SubmissionSet" nodeRepresentation="">
                <rim:Slot name="authorInstitution">
                    <rim:ValueList>
                        <rim:Value>Cleveland Clinic</rim:Value>
                        <rim:Value>Berea Community</rim:Value>
                    </rim:ValueList>
                </rim:Slot>
                <rim:Slot name="authorPerson">
                    <rim:ValueList>
                        <rim:Value>^Dopplemeyer^Sherry^^^</rim:Value>
                    </rim:ValueList>
                </rim:Slot>
                <rim:Slot name="authorRole">
                    <rim:ValueList>
                        <rim:Value>Primary Surgon</rim:Value>
                    </rim:ValueList>
                </rim:Slot>
                <rim:Slot name="authorSpecialty">
                    <rim:ValueList>
                        <rim:Value>Orthopedic</rim:Value>
                    </rim:ValueList>
                </rim:Slot>
                <rim:Name/>
                <rim:Description/>
                <rim:VersionInfo versionName="1.1"/>
            </rim:Classification>
            <rim:Classification id="scl3" objectType="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Classification" classificationScheme="urn:uuid:aa543740-bdda-424e-8c96-df4873be8500" classifiedObject="SubmissionSet" nodeRepresentation="History and Physical">
                <rim:Slot name="codingScheme">
                    <rim:ValueList>
                        <rim:Value>Connect-a-thon contentTypeCodes</rim:Value>
                    </rim:ValueList>
                </rim:Slot>
                <rim:Name>
                    <rim:LocalizedString xml:lang="en-us" charset="UTF-8" value="History and Physical"/>
                </rim:Name>
                <rim:Description/>
                <rim:VersionInfo versionName="1.1"/>
            </rim:Classification>
            <rim:ExternalIdentifier id="sei1" objectType="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExternalIdentifier" identificationScheme="urn:uuid:96fdda7c-d067-4183-912e-bf5ee74998a8" value="1.42.20100709101812.3" registryObject="SubmissionSet">
                <rim:Name>
                    <rim:LocalizedString xml:lang="en-us" charset="UTF-8" value="XDSSubmissionSet.uniqueId"/>
                </rim:Name>
            </rim:ExternalIdentifier>
            <rim:ExternalIdentifier id="sei3" objectType="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExternalIdentifier" identificationScheme="urn:uuid:554ac39e-e3fe-47fe-b233-965d2a147832" value="1.3.6.1.4.1.21367.2010.1.2.900" registryObject="SubmissionSet">
                <rim:Name>
                    <rim:LocalizedString xml:lang="en-us" charset="UTF-8" value="XDSSubmissionSet.sourceId"/>
                </rim:Name>
            </rim:ExternalIdentifier>
            <rim:ExternalIdentifier id="sei4" objectType="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:ExternalIdentifier" identificationScheme="urn:uuid:6b5aea1a-874d-4603-a4bc-96a0a7b38446" value="$patient_id$" registryObject="SubmissionSet">
                <rim:Name>
                    <rim:LocalizedString xml:lang="en-us" charset="UTF-8" value="XDSSubmissionSet.patientId"/>
                </rim:Name>
            </rim:ExternalIdentifier>
        </rim:RegistryPackage>
        <rim:Association id="Assoc" objectType="urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:Association" associationType="urn:ihe:iti:2010:AssociationType:UpdateAvailabilityStatus" sourceObject="SubmissionSet"
        targetObject="$document$">
            <rim:Slot name="NewStatus">
                <rim:ValueList>
                    <rim:Value>$new_status$</rim:Value>
                </rim:ValueList>
            </rim:Slot>
            <rim:Slot name="OriginalStatus">
                <rim:ValueList>
                    <rim:Value>$old_status$</rim:Value>
                </rim:ValueList>
            </rim:Slot>
        </rim:Association>
    </rim:RegistryObjectList>
</lcm:SubmitObjectsRequest>


text:
Welcome to Temple Shir Tikvah!

How good it is to be together in community

Inclusive

What does that really mean?

It means that we welcome and fully integrate everyone who wants to live a Jewish life or who is supportive of family members who do.

Everyone includes the whole megillah:  Jews who have been Jewish from the start, families who light the menorah and trim the Christmas tree, folks who can remember their bat or bar mitzvah haftorah--and those who don't know what a haftorah is.  And included, of course, is the constellation of family structures and sexualities.

Inclusive also means that it's okay if the size of our bank accounts differs considerably, because we make equal opportunity membership possible.

Call To Action

				× Close

Joyous

At Shir Tikvah, joy can be big and loud, or intimate and quiet.

It's ten teenagers making pizza before a youth group meeting.

It's the deep, long breath taken when chanting a niggun—a repetitive melody without words before a prayer.

It's a group of folks spending the day at a Habitat for Humanity worksite.

It's two sets of grandparents, one Catholic, the other Jewish, when they hand the Torah to their grandchild at her bat mitzvah.

It's the community welcoming a newborn at a Friday night service, and it's the feeling that returns, with time, when remembering a loved one.

Call To Action

				× Close

Community

We're a bottom-up congregation, as opposed to top-down.  We create our own programs; we reach a consensus before making decisions; the clergy and members are partners.  Like a well functioning family, we are good humored and respectful of our differences - unless you're a Yankee's fan.

We also share a purpose—which is to create a living, breathing Jewish spiritual home that is generous of heart and hospitable to wherever we are - or whomever we accompany - on the Jewish journey. Making a community like this takes a lot of work and a lot of love, but there is nothing more worthwhile.

Call To Action

				× Close

Inclusive

Joyous

Community

					For a relatively small place, a lot happens at Shir Tikvah.  All of us began as new members and were helped to find our way.  Start by finding out more about us — we look forward to getting to know you.

					Experience Shir Tikvah

Upcoming Events

						20 Sep 2013

							Shabbat Service with Rim and Beth

						1 Nov 2013

							Susce dapibus, tellus ac cursus commodo.

						15 Dec 2013

							Susce dapibus, tellus ac cursus commodo.

						20 Dec 2013

							Susce dapibus, tellus ac cursus commodo.

					See Full Calendar »

							A short Title will go here

							Annual Meeting and Dinner

							A Really long title will go here on multiple lines

							A Really long title will go here on multiple lines

							A short Title will go here


text:
__author__ = 'jawaad'

import codecs
import logging

from tbar import YuubinBango, unicode_csv_reader

class RedisYuubinBango(YuubinBango):
    """Enables the use of Redis-DB with Japanese Postal Code data."""

    def _save(self, pipeline):
        """Uses pipeline / connection sent by default.
        You should use Redis pipelines since they are faster than simple connections"""
        return pipeline.hmset(self.code, self.to_dict())

    @classmethod
    def save(cls, data, pipeline):
        obj = cls(data)
        obj._save(pipeline)

    @classmethod
    def load(cls, connection, postal_code):
        d = connection.hgetall(postal_code)
        return cls([d[k].decode("utf8") for k in cls.fields()])

def load_data_into_redis(init_file, connection):
    """Initializes the Redis DB from initfile in the Redis.config file.
    Download the file from here: http://www.post.japanpost.jp/zipcode/dl/kogaki/zip/ken_all.zip"""
    try:
        with open(init_file, "r") as f:
            csv_content = codecs.getreader("CP932")(f)
            csv_line_gen = unicode_csv_reader(csv_content)
            pipeline = connection.pipeline()
            for x in csv_line_gen:
                RedisYuubinBango.save(x, pipeline)
            pipeline.execute()
    except IOError:
        logging.exception("Could not open Initialization File: {}".format(init_file))


text:
extern NSString* const FLCancelExceptionName;

@interface FLCancelError : NSError
@end

@interface FLCancelException : FLErrorException
@end

@interface NSError (FLCancelling)
+ (NSError*) cancelError;
@property (readonly, nonatomic, assign) BOOL isCancelError;
@end


text:
"""
Memory Backend
--------------

Provides a simple dictionary-based backend.

"""

from dogpile.cache.api import CacheBackend, NO_VALUE

class MemoryBackend(CacheBackend):
    """A backend that uses a plain dictionary.

    There is no size management, and values which
    are placed into the dictionary will remain
    until explicitly removed.   Note that
    Dogpile's expiration of items is based on
    timestamps and does not remove them from
    the cache.

    E.g.::

        from dogpile.cache import make_region

        region = make_region().configure(
            'dogpile.cache.memory'
        )

    To use a Python dictionary of your choosing,
    it can be passed in with the ``cache_dict``
    argument::

        my_dictionary = {}
        region = make_region().configure(
            'dogpile.cache.memory',
            arguments={
                "cache_dict":my_dictionary
            }
        )

    """
    def __init__(self, arguments):
        self._cache = arguments.pop("cache_dict", {})

    def get(self, key):
        return self._cache.get(key, NO_VALUE)

    def get_multi(self, keys):
        return [
            self._cache.get(key, NO_VALUE)
            for key in keys
        ]

    def set(self, key, value):
        self._cache[key] = value

    def set_multi(self, mapping):
        for key,value in mapping.items():
            self._cache[key] = value

    def delete(self, key):
        self._cache.pop(key, None)

    def delete_multi(self, keys):
        for key in keys:
            self._cache.pop(key, None)


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LeetCode
{
    class Reshape_the_Matrix
    {
        public int[,] MatrixReshape(int[,] nums, int r, int c)
        {
            int[,] n = new int[r,c];
            return n;

        }
    }
}


text:
import {createEventTarget} from 'react-interactions/events/src/dom/testing-library';

let React;
let ReactFeatureFlags;
let FocusContain;
let TabbableScope;

describe('FocusContain', () => {
  beforeEach(() => {
    jest.resetModules();
    ReactFeatureFlags = require('shared/ReactFeatureFlags');
    ReactFeatureFlags.enableScopeAPI = true;
    ReactFeatureFlags.enableFlareAPI = true;
    FocusContain = require('../FocusContain').default;
    TabbableScope = require('../TabbableScope').default;
    React = require('react');
  });

  describe('ReactDOM', () => {
    let ReactDOM;
    let container;

    beforeEach(() => {
      ReactDOM = require('react-dom');
      container = document.createElement('div');
      document.body.appendChild(container);
    });

    afterEach(() => {
      document.body.removeChild(container);
      container = null;
    });

    it('handles tab operations by default', () => {
      const inputRef = React.createRef();
      const input2Ref = React.createRef();
      const buttonRef = React.createRef();
      const button2Ref = React.createRef();
      const divRef = React.createRef();

      const Test = () => (
        <FocusContain tabScope={TabbableScope}>
          <input ref={inputRef} />
          <button ref={buttonRef} />

          <input ref={input2Ref} tabIndex={-1} />
          <button ref={button2Ref} />
        </FocusContain>
      );

      ReactDOM.render(<Test />, container);
      expect(document.activeElement).toBe(inputRef.current);
      createEventTarget(document.activeElement).tabNext();
      expect(document.activeElement).toBe(buttonRef.current);
      createEventTarget(document.activeElement).tabNext();
      expect(document.activeElement).toBe(divRef.current);
      createEventTarget(document.activeElement).tabNext();
      expect(document.activeElement).toBe(button2Ref.current);
      createEventTarget(document.activeElement).tabPrevious();
      expect(document.activeElement).toBe(divRef.current);
    });

    it('handles focus containment', () => {
      const inputRef = React.createRef();
      const input2Ref = React.createRef();
      const input3Ref = React.createRef();
      const buttonRef = React.createRef();
      const button2Ref = React.createRef();

      const Test = () => (

          <FocusContain tabScope={TabbableScope}>
            <input ref={inputRef} tabIndex={-1} />
            <button ref={buttonRef} id={1} />
            <button ref={button2Ref} id={2} />
            <input ref={input2Ref} tabIndex={-1} />
          </FocusContain>
          <input ref={input3Ref} />

      );

      ReactDOM.render(<Test />, container);
      buttonRef.current.focus();
      createEventTarget(document.activeElement).tabNext();
      expect(document.activeElement).toBe(button2Ref.current);
      createEventTarget(document.activeElement).tabNext();
      expect(document.activeElement).toBe(buttonRef.current);
      createEventTarget(document.activeElement).tabNext();
      expect(document.activeElement).toBe(button2Ref.current);
      createEventTarget(document.activeElement).tabPrevious();
      expect(document.activeElement).toBe(buttonRef.current);
      createEventTarget(document.activeElement).tabPrevious();
      expect(document.activeElement).toBe(button2Ref.current);
      // Focus should be restored to the contained area
      const rAF = window.requestAnimationFrame;
      window.requestAnimationFrame = x => setTimeout(x);
      input3Ref.current.focus();
      jest.advanceTimersByTime(1);
      window.requestAnimationFrame = rAF;
      expect(document.activeElement).toBe(button2Ref.current);
    });

    it('works with a disabled nested FocusContain', () => {
      const inputRef = React.createRef();
      const input2Ref = React.createRef();
      const buttonRef = React.createRef();
      const button2Ref = React.createRef();
      const button3Ref = React.createRef();
      const button4Ref = React.createRef();

      const Test = () => (
        <FocusContain tabScope={TabbableScope}>
          <input ref={inputRef} tabIndex={-1} />
          <button ref={buttonRef} id={1} />
          <FocusContain tabScope={TabbableScope} disabled={true}>
            <button ref={button2Ref} id={2} />
            <button ref={button3Ref} id={3} />
          </FocusContain>
          <input ref={input2Ref} tabIndex={-1} />
          <button ref={button4Ref} id={4} />
        </FocusContain>
      );

      ReactDOM.render(<Test />, container);
      expect(document.activeElement).toBe(buttonRef.current);
      createEventTarget(document.activeElement).tabNext();
      expect(document.activeElement).toBe(button2Ref.current);
      createEventTarget(document.activeElement).tabNext();
      expect(document.activeElement).toBe(button3Ref.current);
      createEventTarget(document.activeElement).tabNext();
      expect(document.activeElement).toBe(button4Ref.current);
      createEventTarget(document.activeElement).tabPrevious();
      expect(document.activeElement).toBe(button3Ref.current);
      createEventTarget(document.activeElement).tabPrevious();
      expect(document.activeElement).toBe(button2Ref.current);
    });

    it('works with enabled nested FocusContain', () => {
      const inputRef = React.createRef();
      const input2Ref = React.createRef();
      const buttonRef = React.createRef();
      const button2Ref = React.createRef();
      const button3Ref = React.createRef();
      const button4Ref = React.createRef();

      const Test = () => (
        <FocusContain tabScope={TabbableScope}>
          <input ref={inputRef} tabIndex={-1} />
          <button ref={buttonRef} id={1} />
          <FocusContain tabScope={TabbableScope} disabled={false}>
            <button ref={button2Ref} id={2} />
            <button ref={button3Ref} id={3} />
          </FocusContain>
          <input ref={input2Ref} tabIndex={-1} />
          <button ref={button4Ref} id={4} />
        </FocusContain>
      );

      ReactDOM.render(<Test />, container);
      expect(document.activeElement).toBe(button2Ref.current);
      createEventTarget(document.activeElement).tabNext();
      expect(document.activeElement).toBe(button3Ref.current);
      createEventTarget(document.activeElement).tabNext();
      expect(document.activeElement).toBe(button2Ref.current);
      createEventTarget(document.activeElement).tabPrevious();
      expect(document.activeElement).toBe(button3Ref.current);
      createEventTarget(document.activeElement).tabPrevious();
      expect(document.activeElement).toBe(button2Ref.current);
    });

    it('should work as expected with suspense fallbacks', () => {
      const buttonRef = React.createRef();
      const button2Ref = React.createRef();
      const button3Ref = React.createRef();
      const button4Ref = React.createRef();
      const button5Ref = React.createRef();

      function SuspendedComponent() {
        throw new Promise(() => {
          // Never resolve
        });
      }

      function Component() {
        return (
          <React.Fragment>
            <button ref={button5Ref} id={5} />
            <SuspendedComponent />
          </React.Fragment>
        );
      }

      const Test = () => (
        <FocusContain tabScope={TabbableScope}>
          <button ref={buttonRef} id={1} />
          <button ref={button2Ref} id={2} />
          <React.Suspense fallback={<button ref={button3Ref} id={3} />}>
            <Component />
          </React.Suspense>
          <button ref={button4Ref} id={4} />
        </FocusContain>
      );

      ReactDOM.render(<Test />, container);
      buttonRef.current.focus();
      expect(document.activeElement).toBe(buttonRef.current);
      createEventTarget(document.activeElement).tabNext();
      expect(document.activeElement).toBe(button2Ref.current);
      createEventTarget(document.activeElement).tabNext();
      expect(document.activeElement).toBe(button3Ref.current);
      createEventTarget(document.activeElement).tabNext();
      expect(document.activeElement).toBe(button4Ref.current);
      createEventTarget(document.activeElement).tabPrevious();
      expect(document.activeElement).toBe(button3Ref.current);
      createEventTarget(document.activeElement).tabPrevious();
      expect(document.activeElement).toBe(button2Ref.current);
    });
  });
});


text:
<!doctype html>

	<title>you are what you say</title>
	<meta charset="utf-8" />
 	<link rel="stylesheet" href="css/main.css"/>

Please allow this page to access your camera.

Your browser does not support the Camera API.

	<button id="pause">pause / resume</button>


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Uses of Class filesystem.FileSystemItem (DOSBox 1.0.0-SNAPSHOT API)</title>
<meta name="date" content="2016-03-26">
<link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes

Uses of Class
filesystem.FileSystemItem

Packages that use FileSystemItem

Package
Description

filesystem

Uses of FileSystemItem in filesystem

Subclasses of FileSystemItem in filesystem

Modifier and Type
Class and Description

class
Directory

This class implements the behavior of concrete directories.

class
File

This class implements the behavior of concrete files.

Methods in filesystem that return FileSystemItem

Modifier and Type
Method and Description

FileSystemItem
Drive.getItemFromPath(String givenItemPath)

Returns the object of a given path name.

Methods in filesystem that return types with arguments of type FileSystemItem

Modifier and Type
Method and Description

abstract ArrayList<FileSystemItem>
FileSystemItem.getContent()

Returns the content of the item.

ArrayList<FileSystemItem>
File.getContent()

null is returned since a files does not contain any subitems.

ArrayList<FileSystemItem>
Directory.getContent()

An array list with the content of this directory (files and
 subdirectories) is returned.

Methods in filesystem with parameters of type FileSystemItem

Modifier and Type
Method and Description

void
Directory.remove(FileSystemItem item)

Removes a directory or a file from current directory.

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev

Next

Frames

No Frames

All Classes

Copyright © 2016 René Anderes. All rights reserved.