text:
package org.elasticsearch.indices.recovery;

import org.elasticsearch.Version;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.Streamable;
import org.elasticsearch.common.transport.DummyTransportAddress;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.indices.recovery.RecoveryState.*;
import org.elasticsearch.test.ElasticsearchTestCase;
import org.junit.Test;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;

import static org.elasticsearch.test.VersionUtils.randomVersion;
import static org.hamcrest.Matchers.*;

public class RecoveryStateTest extends ElasticsearchTestCase {

    abstract class Streamer<T extends Streamable> extends Thread {

        private T lastRead;
        final private AtomicBoolean shouldStop;
        final private T source;
        final AtomicReference<Throwable> error = new AtomicReference<>();
        final Version streamVersion;

        Streamer(AtomicBoolean shouldStop, T source) {
            this(shouldStop, source, randomVersion(random()));
        }

        Streamer(AtomicBoolean shouldStop, T source, Version streamVersion) {
            this.shouldStop = shouldStop;
            this.source = source;
            this.streamVersion = streamVersion;
        }

        public T lastRead() throws Throwable {
            Throwable t = error.get();
            if (t != null) {
                throw t;
            }
            return lastRead;
        }

        public T serializeDeserialize() throws IOException {
            BytesStreamOutput out = new BytesStreamOutput();
            source.writeTo(out);
            out.close();
            StreamInput in = StreamInput.wrap(out.bytes());
            T obj = deserialize(in);
            lastRead = obj;
            return obj;
        }

        protected T deserialize(StreamInput in) throws IOException {
            T obj = createObj();
            obj.readFrom(in);
            return obj;
        }

        abstract T createObj();

        @Override
        public void run() {
            try {
                while (shouldStop.get() == false) {
                    serializeDeserialize();
                }
                serializeDeserialize();
            } catch (Throwable t) {
                error.set(t);
            }
        }
    }

    public void testTimers() throws Throwable {
        final Timer timer;
        Streamer<Timer> streamer;
        AtomicBoolean stop = new AtomicBoolean();
        if (randomBoolean()) {
            timer = new Timer();
            streamer = new Streamer<Timer>(stop, timer) {
                @Override
                Timer createObj() {
                    return new Timer();
                }
            };
        } else if (randomBoolean()) {
            timer = new Index();
            streamer = new Streamer<Timer>(stop, timer) {
                @Override
                Timer createObj() {
                    return new Index();
                }
            };
        } else if (randomBoolean()) {
            timer = new VerifyIndex();
            streamer = new Streamer<Timer>(stop, timer) {
                @Override
                Timer createObj() {
                    return new VerifyIndex();
                }
            };
        } else {
            timer = new Translog();
            streamer = new Streamer<Timer>(stop, timer) {
                @Override
                Timer createObj() {
                    return new Translog();
                }
            };
        }

        timer.start();
        assertThat(timer.startTime(), greaterThan(0l));
        assertThat(timer.stopTime(), equalTo(0l));
        Timer lastRead = streamer.serializeDeserialize();
        final long time = lastRead.time();
        assertThat(time, lessThanOrEqualTo(timer.time()));
        assertBusy(new Runnable() {
            @Override
            public void run() {
                assertThat("timer timer should progress compared to captured one ", time, lessThan(timer.time()));
            }
        });
        assertThat("captured time shouldn't change", lastRead.time(), equalTo(time));

        if (randomBoolean()) {
            timer.stop();
            assertThat(timer.stopTime(), greaterThanOrEqualTo(timer.startTime()));
            assertThat(timer.time(), equalTo(timer.stopTime() - timer.startTime()));
            lastRead = streamer.serializeDeserialize();
            assertThat(lastRead.startTime(), equalTo(timer.startTime()));
            assertThat(lastRead.time(), equalTo(timer.time()));
            assertThat(lastRead.stopTime(), equalTo(timer.stopTime()));
        }

        timer.reset();
        assertThat(timer.startTime(), equalTo(0l));
        assertThat(timer.time(), equalTo(0l));
        assertThat(timer.stopTime(), equalTo(0l));
        lastRead = streamer.serializeDeserialize();
        assertThat(lastRead.startTime(), equalTo(0l));
        assertThat(lastRead.time(), equalTo(0l));
        assertThat(lastRead.stopTime(), equalTo(0l));

    }

    public void testIndex() throws Throwable {
        File[] files = new File[randomIntBetween(1, 20)];
        ArrayList<File> filesToRecover = new ArrayList<>();
        long totalFileBytes = 0;
        long totalReusedBytes = 0;
        int totalReused = 0;
        for (int i = 0; i < files.length; i++) {
            final int fileLength = randomIntBetween(1, 1000);
            final boolean reused = randomBoolean();
            totalFileBytes += fileLength;
            files[i] = new RecoveryState.File("f_" + i, fileLength, reused);
            if (reused) {
                totalReused++;
                totalReusedBytes += fileLength;
            } else {
                filesToRecover.add(files[i]);
            }
        }

        Collections.shuffle(Arrays.asList(files));
        final RecoveryState.Index index = new RecoveryState.Index();

        if (randomBoolean()) {
            // initialize with some data and then reset
            index.start();
            for (int i = randomIntBetween(0, 10); i > 0; i--) {
                index.addFileDetail("t_" + i, randomIntBetween(1, 100), randomBoolean());
                if (randomBoolean()) {
                    index.addSourceThrottling(randomIntBetween(0, 20));
                }
                if (randomBoolean()) {
                    index.addTargetThrottling(randomIntBetween(0, 20));
                }
            }
            if (randomBoolean()) {
                index.stop();
            }
            index.reset();
        }

        // before we start we must report 0
        assertThat(index.recoveredFilesPercent(), equalTo((float) 0.0));
        assertThat(index.recoveredBytesPercent(), equalTo((float) 0.0));
        assertThat(index.sourceThrottling().nanos(), equalTo(Index.UNKNOWN));
        assertThat(index.targetThrottling().nanos(), equalTo(Index.UNKNOWN));

        index.start();
        for (File file : files) {
            index.addFileDetail(file.name(), file.length(), file.reused());
        }

        logger.info("testing initial information");
        assertThat(index.totalBytes(), equalTo(totalFileBytes));
        assertThat(index.reusedBytes(), equalTo(totalReusedBytes));
        assertThat(index.totalRecoverBytes(), equalTo(totalFileBytes - totalReusedBytes));
        assertThat(index.totalFileCount(), equalTo(files.length));
        assertThat(index.reusedFileCount(), equalTo(totalReused));
        assertThat(index.totalRecoverFiles(), equalTo(filesToRecover.size()));
        assertThat(index.recoveredFileCount(), equalTo(0));
        assertThat(index.recoveredBytes(), equalTo(0l));
        assertThat(index.recoveredFilesPercent(), equalTo(filesToRecover.size() == 0 ? 100.0f : 0.0f));
        assertThat(index.recoveredBytesPercent(), equalTo(filesToRecover.size() == 0 ? 100.0f : 0.0f));

        long bytesToRecover = totalFileBytes - totalReusedBytes;
        boolean completeRecovery = bytesToRecover == 0 || randomBoolean();
        if (completeRecovery == false) {
            bytesToRecover = randomIntBetween(1, (int) bytesToRecover);
            logger.info("performing partial recovery ([{}] bytes of [{}])", bytesToRecover, totalFileBytes - totalReusedBytes);
        }
        AtomicBoolean streamShouldStop = new AtomicBoolean();

        Streamer<Index> backgroundReader = new Streamer<RecoveryState.Index>(streamShouldStop, index) {
            @Override
            Index createObj() {
                return new Index();
            }
        };

        backgroundReader.start();

        long recoveredBytes = 0;
        long sourceThrottling = Index.UNKNOWN;
        long targetThrottling = Index.UNKNOWN;
        while (bytesToRecover > 0) {
            File file = randomFrom(filesToRecover);
            final long toRecover = Math.min(bytesToRecover, randomIntBetween(1, (int) (file.length() - file.recovered())));
            final long throttledOnSource = rarely() ? randomIntBetween(10, 200) : 0;
            index.addSourceThrottling(throttledOnSource);
            if (sourceThrottling == Index.UNKNOWN) {
                sourceThrottling = throttledOnSource;
            } else {
                sourceThrottling += throttledOnSource;
            }
            index.addRecoveredBytesToFile(file.name(), toRecover);
            file.addRecoveredBytes(toRecover);
            final long throttledOnTarget = rarely() ? randomIntBetween(10, 200) : 0;
            if (targetThrottling == Index.UNKNOWN) {
                targetThrottling = throttledOnTarget;
            } else {
                targetThrottling += throttledOnTarget;
            }
            index.addTargetThrottling(throttledOnTarget);
            bytesToRecover -= toRecover;
            recoveredBytes += toRecover;
            if (file.reused() || file.fullyRecovered()) {
                filesToRecover.remove(file);
            }
        }

        if (completeRecovery) {
            assertThat(filesToRecover.size(), equalTo(0));
            index.stop();
            assertThat(index.time(), equalTo(index.stopTime() - index.startTime()));
            assertThat(index.time(), equalTo(index.stopTime() - index.startTime()));
        }

        logger.info("testing serialized information");
        streamShouldStop.set(true);
        backgroundReader.join();
        final Index lastRead = backgroundReader.lastRead();
        assertThat(lastRead.fileDetails().toArray(), arrayContainingInAnyOrder(index.fileDetails().toArray()));
        assertThat(lastRead.startTime(), equalTo(index.startTime()));
        if (completeRecovery) {
            assertThat(lastRead.time(), equalTo(index.time()));
        } else {
            assertThat(lastRead.time(), lessThanOrEqualTo(index.time()));
        }
        assertThat(lastRead.stopTime(), equalTo(index.stopTime()));
        assertThat(lastRead.targetThrottling(), equalTo(index.targetThrottling()));
        assertThat(lastRead.sourceThrottling(), equalTo(index.sourceThrottling()));

        logger.info("testing post recovery");
        assertThat(index.totalBytes(), equalTo(totalFileBytes));
        assertThat(index.reusedBytes(), equalTo(totalReusedBytes));
        assertThat(index.totalRecoverBytes(), equalTo(totalFileBytes - totalReusedBytes));
        assertThat(index.totalFileCount(), equalTo(files.length));
        assertThat(index.reusedFileCount(), equalTo(totalReused));
        assertThat(index.totalRecoverFiles(), equalTo(files.length - totalReused));
        assertThat(index.recoveredFileCount(), equalTo(index.totalRecoverFiles() - filesToRecover.size()));
        assertThat(index.recoveredBytes(), equalTo(recoveredBytes));
        assertThat(index.targetThrottling().nanos(), equalTo(targetThrottling));
        assertThat(index.sourceThrottling().nanos(), equalTo(sourceThrottling));
        if (index.totalRecoverFiles() == 0) {
            assertThat((double) index.recoveredFilesPercent(), equalTo(100.0));
            assertThat((double) index.recoveredBytesPercent(), equalTo(100.0));
        } else {
            assertThat((double) index.recoveredFilesPercent(), closeTo(100.0 * index.recoveredFileCount() / index.totalRecoverFiles(), 0.1));
            assertThat((double) index.recoveredBytesPercent(), closeTo(100.0 * index.recoveredBytes() / index.totalRecoverBytes(), 0.1));
        }
    }

    public void testStageSequenceEnforcement() {
        final DiscoveryNode discoveryNode = new DiscoveryNode("1", DummyTransportAddress.INSTANCE, Version.CURRENT);
        Stage[] stages = Stage.values();
        int i = randomIntBetween(0, stages.length - 1);
        int j;
        do {
            j = randomIntBetween(0, stages.length - 1);
        } while (j == i);
        Stage t = stages[i];
        stages[i] = stages[j];
        stages[j] = t;
        try {
            RecoveryState state = new RecoveryState(new ShardId("bla", 0), randomBoolean(), randomFrom(Type.values()), discoveryNode, discoveryNode);
            for (Stage stage : stages) {
                state.setStage(stage);
            }
            fail("succeeded in performing the illegal sequence [" + Strings.arrayToCommaDelimitedString(stages) + "]");
        } catch (IllegalStateException e) {
            // cool
        }

        // but reset should be always possible.
        stages = Stage.values();
        i = randomIntBetween(1, stages.length - 1);
        ArrayList<Stage> list = new ArrayList<>(Arrays.asList(Arrays.copyOfRange(stages, 0, i)));
        list.addAll(Arrays.asList(stages));
        RecoveryState state = new RecoveryState(new ShardId("bla", 0), randomBoolean(), randomFrom(Type.values()), discoveryNode, discoveryNode);
        for (Stage stage : list) {
            state.setStage(stage);
        }

        assertThat(state.getStage(), equalTo(Stage.DONE));
    }

    public void testTranslog() throws Throwable {
        final Translog translog = new Translog();
        AtomicBoolean stop = new AtomicBoolean();
        Streamer<Translog> streamer = new Streamer<Translog>(stop, translog) {
            @Override
            Translog createObj() {
                return new Translog();
            }
        };

        // we don't need to test the time aspect, it's done in the timer test
        translog.start();
        assertThat(translog.recoveredOperations(), equalTo(0));
        assertThat(translog.totalOperations(), equalTo(Translog.UNKNOWN));
        assertThat(translog.totalOperationsOnStart(), equalTo(Translog.UNKNOWN));
        streamer.start();
        // force one
        streamer.serializeDeserialize();
        int ops = 0;
        int totalOps = 0;
        int totalOpsOnStart = randomIntBetween(10, 200);
        translog.totalOperationsOnStart(totalOpsOnStart);
        for (int i = scaledRandomIntBetween(10, 200); i > 0; i--) {
            final int iterationOps = randomIntBetween(1, 10);
            totalOps += iterationOps;
            translog.totalOperations(totalOps);
            assertThat((double) translog.recoveredPercent(), closeTo(100.0 * ops / totalOps, 0.1));
            for (int j = iterationOps; j > 0; j--) {
                ops++;
                translog.incrementRecoveredOperations();
            }
            assertThat(translog.recoveredOperations(), equalTo(ops));
            assertThat(translog.totalOperations(), equalTo(totalOps));
            assertThat(translog.recoveredPercent(), equalTo(100.f));
            assertThat(streamer.lastRead().recoveredOperations(), greaterThanOrEqualTo(0));
            assertThat(streamer.lastRead().recoveredOperations(), lessThanOrEqualTo(ops));
            assertThat(streamer.lastRead().totalOperations(), lessThanOrEqualTo(totalOps));
            assertThat(streamer.lastRead().totalOperationsOnStart(), lessThanOrEqualTo(totalOpsOnStart));
            assertThat(streamer.lastRead().recoveredPercent(), either(greaterThanOrEqualTo(0.f)).or(equalTo(-1.f)));
        }

        boolean stopped = false;
        if (randomBoolean()) {
            translog.stop();
            stopped = true;
        }

        if (randomBoolean()) {
            translog.reset();
            ops = 0;
            totalOps = Translog.UNKNOWN;
            totalOpsOnStart = Translog.UNKNOWN;
            assertThat(translog.recoveredOperations(), equalTo(0));
            assertThat(translog.totalOperationsOnStart(), equalTo(Translog.UNKNOWN));
            assertThat(translog.totalOperations(), equalTo(Translog.UNKNOWN));
        }

        stop.set(true);
        streamer.join();
        final Translog lastRead = streamer.lastRead();
        assertThat(lastRead.recoveredOperations(), equalTo(ops));
        assertThat(lastRead.totalOperations(), equalTo(totalOps));
        assertThat(lastRead.totalOperationsOnStart(), equalTo(totalOpsOnStart));
        assertThat(lastRead.startTime(), equalTo(translog.startTime()));
        assertThat(lastRead.stopTime(), equalTo(translog.stopTime()));

        if (stopped) {
            assertThat(lastRead.time(), equalTo(translog.time()));
        } else {
            assertThat(lastRead.time(), lessThanOrEqualTo(translog.time()));
        }
    }

    public void testStart() throws IOException {
        final VerifyIndex verifyIndex = new VerifyIndex();
        AtomicBoolean stop = new AtomicBoolean();
        Streamer<VerifyIndex> streamer = new Streamer<VerifyIndex>(stop, verifyIndex) {
            @Override
            VerifyIndex createObj() {
                return new VerifyIndex();
            }
        };

        // we don't need to test the time aspect, it's done in the timer test
        verifyIndex.start();
        assertThat(verifyIndex.checkIndexTime(), equalTo(0l));
        // force one
        VerifyIndex lastRead = streamer.serializeDeserialize();
        assertThat(lastRead.checkIndexTime(), equalTo(0l));

        long took = randomLong();
        if (took < 0) {
            took = -took;
            took = Math.max(0l, took);

        }
        verifyIndex.checkIndexTime(took);
        assertThat(verifyIndex.checkIndexTime(), equalTo(took));

        boolean stopped = false;
        if (randomBoolean()) {
            verifyIndex.stop();
            stopped = true;
        }

        if (randomBoolean()) {
            verifyIndex.reset();
            took = 0;
            assertThat(verifyIndex.checkIndexTime(), equalTo(took));
        }

        lastRead = streamer.serializeDeserialize();
        assertThat(lastRead.checkIndexTime(), equalTo(took));
        assertThat(lastRead.startTime(), equalTo(verifyIndex.startTime()));
        assertThat(lastRead.stopTime(), equalTo(verifyIndex.stopTime()));

        if (stopped) {
            assertThat(lastRead.time(), equalTo(verifyIndex.time()));
        } else {
            assertThat(lastRead.time(), lessThanOrEqualTo(verifyIndex.time()));
        }
    }

    @Test
    public void testConcurrentModificationIndexFileDetailsMap() throws InterruptedException {
        final Index index = new Index();
        final AtomicBoolean stop = new AtomicBoolean(false);
        Streamer<Index> readWriteIndex = new Streamer<Index>(stop, index) {
            @Override
            Index createObj() {
                return new Index();
            }
        };
        Thread modifyThread = new Thread() {
            public void run() {
                for (int i = 0; i < 1000; i++) {
                    index.addFileDetail(randomAsciiOfLength(10), 100, true);
                }
                stop.set(true);
            }
        };
        readWriteIndex.start();
        modifyThread.start();
        modifyThread.join();
        readWriteIndex.join();
        assertThat(readWriteIndex.error.get(), equalTo(null));
    }

    @Test
    public void testFileHashCodeAndEquals() {
        File f = new File("foo", randomIntBetween(0, 100), randomBoolean());
        File anotherFile = new File(f.name(), f.length(), f.reused());
        assertEquals(f, anotherFile);
        assertEquals(f.hashCode(), anotherFile.hashCode());
        int iters = randomIntBetween(10, 100);
        for (int i = 0; i < iters; i++) {
            f = new File("foo", randomIntBetween(0, 100), randomBoolean());
            anotherFile = new File(f.name(), randomIntBetween(0, 100), randomBoolean());
            if (f.equals(anotherFile)) {
                assertEquals(f.hashCode(), anotherFile.hashCode());
            } else if (f.hashCode() != anotherFile.hashCode()) {
               assertFalse(f.equals(anotherFile));
            }
        }

    }
}


text:
import copy
import fnmatch
import io
import itertools
import logging
import pkg_resources

import jenkins_jobs.local_yaml as local_yaml
from jenkins_jobs.constants import MAGIC_MANAGE_STRING
from jenkins_jobs.errors import JenkinsJobsException
from jenkins_jobs.registry import ModuleRegistry
from jenkins_jobs.formatter import deep_format
from jenkins_jobs.xml_config import XmlJob

logger = logging.getLogger(__name__)

def matches(what, glob_patterns):
    """
    Checks if the given string, ``what``, matches any of the glob patterns in
    the iterable, ``glob_patterns``

    :arg str what: String that we want to test if it matches a pattern
    :arg iterable glob_patterns: glob patterns to match (list, tuple, set,
    etc.)
    """
    return any(fnmatch.fnmatch(what, glob_pattern)
               for glob_pattern in glob_patterns)

class YamlParser(object):
    def __init__(self, config=None, plugins_info=None):
        self.data = {}
        self.jobs = []
        self.xml_jobs = []
        self.config = config
        self.registry = ModuleRegistry(self.config, plugins_info)
        self.path = ["."]
        if self.config:
            if config.has_section('job_builder') and \
                    config.has_option('job_builder', 'include_path'):
                self.path = config.get('job_builder',
                                       'include_path').split(':')
        self.keep_desc = self.get_keep_desc()
        self.merge_defaults = self.get_merge_defaults()

    def get_keep_desc(self):
        keep_desc = False
        if self.config and self.config.has_section('job_builder') and \
                self.config.has_option('job_builder', 'keep_descriptions'):
            keep_desc = self.config.getboolean('job_builder',
                                               'keep_descriptions')
        return keep_desc

    def get_merge_defaults(self):
        merge_defaults = False
        if self.config and self.config.has_section('job_builder') and \
                self.config.has_option('job_builder', 'merge_defaults'):
            merge_defaults = self.config.getboolean('job_builder',
                                                    'merge_defaults')
        return merge_defaults

    def parse_fp(self, fp):
        data = local_yaml.load(fp, search_path=self.path)
        if data:
            if not isinstance(data, list):
                raise JenkinsJobsException(
                    "The topmost collection in file '{fname}' must be a list,"
                    " not a {cls}".format(fname=getattr(fp, 'name', fp),
                                          cls=type(data)))
            for item in data:
                cls, dfn = next(iter(item.items()))
                group = self.data.get(cls, {})
                if len(item.items()) > 1:
                    n = None
                    for k, v in item.items():
                        if k == "name":
                            n = v
                            break
                    # Syntax error
                    raise JenkinsJobsException("Syntax error, for item "
                                               "named '{0}'. Missing indent?"
                                               .format(n))
                name = dfn['name']
                if name in group:
                    self._handle_dups("Duplicate entry found in '{0}: '{1}' "
                                      "already defined".format(fp.name, name))
                group[name] = dfn
                self.data[cls] = group

    def parse(self, fn):
        with io.open(fn, 'r', encoding='utf-8') as fp:
            self.parse_fp(fp)

    def _handle_dups(self, message):

        if not (self.config and self.config.has_section('job_builder') and
                self.config.getboolean('job_builder', 'allow_duplicates')):
            logger.error(message)
            raise JenkinsJobsException(message)
        else:
            logger.warn(message)

    def getJob(self, name):
        job = self.data.get('job', {}).get(name, None)
        if not job:
            return job
        return self.applyDefaults(job)

    def getJobGroup(self, name):
        return self.data.get('job-group', {}).get(name, None)

    def getJobTemplate(self, name):
        job = self.data.get('job-template', {}).get(name, None)
        if not job:
            return job
        return self.applyDefaults(job)

    def applyDefaults(self, data, override_dict=None):
        if override_dict is None:
            override_dict = {}

        whichdefaults = data.get('defaults', 'global')
        defaults = copy.deepcopy(self.data.get('defaults',
                                 {}).get(whichdefaults, {}))
        if defaults == {} and whichdefaults != 'global':
            raise JenkinsJobsException("Unknown defaults set: '{0}'"
                                       .format(whichdefaults))

        for key in override_dict.keys():
            defaults[key] = override_dict[key]

        newdata = {}
        newdata.update(defaults)

        if self.merge_defaults:
            if newdata == {}:
                newdata.update(data)
            else:
                self.deepUpdate(newdata, data)
        else:
            newdata.update(data)
        return newdata

    def deepUpdate(self, data, updated_data):
        if hasattr(data, 'format') or (hasattr(updated_data, 'format') or
                                       hasattr(data, '__int__') or
                                       hasattr(updated_data, '__int__')):
            return

        common_keys = self._findCommonKey(data, updated_data)
        for common_key in common_keys:
            self._deepUpdate(common_key, data, updated_data)

        diff_keys = self._findDiffKey(data, updated_data)
        for diff_key in diff_keys:
            data[diff_key] = updated_data[diff_key]

    def _deepUpdate(self, common_key, data, updated_data):
        attr = data[common_key]
        updated_attr = updated_data[common_key]

        if hasattr(attr, 'format') or (hasattr(updated_attr, 'format') or
                                       hasattr(attr, '__int__') or
                                       hasattr(updated_attr, '__int__')):
            data[common_key] = updated_attr
        elif hasattr(attr, 'keys'):
            self.deepUpdate(attr, updated_attr)
        elif hasattr(attr, '__iter__'):
            for ele in updated_attr:
                if hasattr(ele, 'format') and ele not in attr:
                    attr.append(ele)
                    continue
                if hasattr(ele, 'keys'):
                    for od in attr:
                        if hasattr(od, 'keys') and \
                                self._findCommonKey(od, ele):
                            self.deepUpdate(od, ele)
                            break
                    else:
                        attr.append(ele)

    def _findCommonKey(self, data, updated_data):
        return list(set(data.keys()).intersection(set(updated_data.keys())))

    def _findDiffKey(self, data, updated_data):
        return list(set(updated_data.keys()).difference(set(data.keys())))

    def formatDescription(self, job):
        if self.keep_desc:
            description = job.get("description", None)
        else:
            description = job.get("description", '')
        if description is not None:
            job["description"] = description + \
                self.get_managed_string().lstrip()

    def expandYaml(self, jobs_glob=None):
        changed = True
        while changed:
            changed = False
            for module in self.registry.modules:
                if hasattr(module, 'handle_data'):
                    if module.handle_data(self):
                        changed = True

        for job in self.data.get('job', {}).values():
            if jobs_glob and not matches(job['name'], jobs_glob):
                logger.debug("Ignoring job {0}".format(job['name']))
                continue
            logger.debug("Expanding job '{0}'".format(job['name']))
            job = self.applyDefaults(job)
            self.formatDescription(job)
            self.jobs.append(job)
        for project in self.data.get('project', {}).values():
            logger.debug("Expanding project '{0}'".format(project['name']))
            # use a set to check for duplicate job references in projects
            seen = set()
            for jobspec in project.get('jobs', []):
                if isinstance(jobspec, dict):
                    # Singleton dict containing dict of job-specific params
                    jobname, jobparams = next(iter(jobspec.items()))
                    if not isinstance(jobparams, dict):
                        jobparams = {}
                else:
                    jobname = jobspec
                    jobparams = {}
                job = self.getJob(jobname)
                if job:
                    # Just naming an existing defined job
                    if jobname in seen:
                        self._handle_dups("Duplicate job '{0}' specified "
                                          "for project '{1}'".format(
                                              jobname, project['name']))
                    seen.add(jobname)
                    continue
                # see if it's a job group
                group = self.getJobGroup(jobname)
                if group:
                    for group_jobspec in group['jobs']:
                        if isinstance(group_jobspec, dict):
                            group_jobname, group_jobparams = \
                                next(iter(group_jobspec.items()))
                            if not isinstance(group_jobparams, dict):
                                group_jobparams = {}
                        else:
                            group_jobname = group_jobspec
                            group_jobparams = {}
                        job = self.getJob(group_jobname)
                        if job:
                            if group_jobname in seen:
                                self._handle_dups(
                                    "Duplicate job '{0}' specified for "
                                    "project '{1}'".format(group_jobname,
                                                           project['name']))
                            seen.add(group_jobname)
                            continue
                        template = self.getJobTemplate(group_jobname)
                        # Allow a group to override parameters set by a project
                        d = {}
                        d.update(project)
                        d.update(jobparams)
                        d.update(group)
                        d.update(group_jobparams)
                        # Except name, since the group's name is not useful
                        d['name'] = project['name']
                        if template:
                            self.expandYamlForTemplateJob(d, template,
                                                          jobs_glob)
                    continue
                # see if it's a template
                template = self.getJobTemplate(jobname)
                if template:
                    d = {}
                    d.update(project)
                    d.update(jobparams)
                    self.expandYamlForTemplateJob(d, template, jobs_glob)
                else:
                    raise JenkinsJobsException("Failed to find suitable "
                                               "template named '{0}'"
                                               .format(jobname))
        # check for duplicate generated jobs
        seen = set()
        # walk the list in reverse so that last definition wins
        for job in self.jobs[::-1]:
            if job['name'] in seen:
                self._handle_dups("Duplicate definitions for job '{0}' "
                                  "specified".format(job['name']))
                self.jobs.remove(job)
            seen.add(job['name'])

    def expandYamlForTemplateJob(self, project, template, jobs_glob=None):
        dimensions = []
        template_name = template['name']
        # reject keys that are not useful during yaml expansion
        for k in ['jobs']:
            project.pop(k)
        for (k, v) in project.items():
            tmpk = '{{{0}}}'.format(k)
            if tmpk not in template_name:
                logger.debug("Variable %s not in name %s, rejecting from job"
                             " matrix expansion.", tmpk, template_name)
                continue
            if type(v) == list:
                dimensions.append(zip([k] * len(v), v))
        # XXX somewhat hackish to ensure we actually have a single
        # pass through the loop
        if len(dimensions) == 0:
            dimensions = [(("", ""),)]

        for values in itertools.product(*dimensions):
            params = copy.deepcopy(project)
            params = self.applyDefaults(params, template)

            expanded_values = {}
            for (k, v) in values:
                if isinstance(v, dict):
                    inner_key = next(iter(v))
                    expanded_values[k] = inner_key
                    expanded_values.update(v[inner_key])
                else:
                    expanded_values[k] = v

            params.update(expanded_values)
            params = deep_format(params, params)
            allow_empty_variables = self.config \
                and self.config.has_section('job_builder') \
                and self.config.has_option(
                    'job_builder', 'allow_empty_variables') \
                and self.config.getboolean(
                    'job_builder', 'allow_empty_variables')

            for key in template.keys():
                if key not in params:
                    params[key] = template[key]

            expanded = deep_format(template, params, allow_empty_variables)

            job_name = expanded.get('name')
            if jobs_glob and not matches(job_name, jobs_glob):
                continue

            self.formatDescription(expanded)
            self.jobs.append(expanded)

    def get_managed_string(self):
        # The \n\n is not hard coded, because they get stripped if the
        # project does not otherwise have a description.
        return "\n\n" + MAGIC_MANAGE_STRING

    def generateXML(self):
        for job in self.jobs:
            self.xml_jobs.append(self.getXMLForJob(job))

    def getXMLForJob(self, data):
        kind = data.get('project-type', 'freestyle')

        for ep in pkg_resources.iter_entry_points(
                group='jenkins_jobs.projects', name=kind):
            Mod = ep.load()
            mod = Mod(self.registry)
            xml = mod.root_xml(data)
            self.gen_xml(xml, data)
            job = XmlJob(xml, data['name'])
            return job

    def gen_xml(self, xml, data):
        for module in self.registry.modules:
            if hasattr(module, 'gen_xml'):
                module.gen_xml(self, xml, data)

redpajama_set_name: RedPajamaGithub


text:
(function () {
    'use strict';

    describe('opentele.parserServices', function () {
        var nodesParser;

        beforeEach(module('opentele.parserServices'));

        beforeEach(inject(function (_nodesParser_) {
            nodesParser = _nodesParser_;
        }));

        describe('can check for unsupported nodes', function() {

            it('should return true if all node types are supported by parser', function() {
                var nodes = [
                        { "IONode": {"nodeName": "157"}},
                        { "EndNode": {"nodeName": "159"}}
                    ];

                expect(function() {nodesParser.validate(nodes);}).not.toThrow();
            });

            it('should throw error when on node is unsupported by parser', function() {
                var nodes = [
                    { "IONode": {"nodeName": "157"}},
                    { "UnsupportedNode": {"nodeName": "159"}}
                ];

                expect(function() {nodesParser.validate(nodes);}).toThrow('The following Node types are not supported: UnsupportedNode');
            });

            it('should throw error when empty or null node list is passed', function() {
                expect(function() {nodesParser.validate([]);}).toThrow('Questionnaire Node list was empty or null.');
                expect(function() {nodesParser.validate(null);}).toThrow('Questionnaire Node list was empty or null.');
            });
        });
    });
}());


text:
package com.appspot.trent.denis;

public class PTRRecord {

    private String value;

    public PTRRecord(String value) {
        this.value = value;
    }

    public String toString() {
       return value;
    }

    public boolean equals(PTRRecord other) {
        return value.equals(other.toString());
    }

    public byte getBuffer() {
        return Byte.valueOf(value);
    }
}


text:
package ca.qc.bergeron.marcantoine.crammeur.librairy.itext;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.pdf.PdfCopy;
import com.itextpdf.text.pdf.PdfReader;

import java.io.FileOutputStream;
import java.io.IOException;

/**
 * Created by Marc-Antoine on 2017-01-12.
 */

public class PDF {

    public void createPdf(String filename, PdfReader[] readers) throws IOException, DocumentException {
        Document document = new Document();
        PdfCopy copy = new PdfCopy(document, new FileOutputStream(filename));
        copy.setMergeFields();
        document.open();
        for (PdfReader reader : readers) {
            copy.addDocument(reader);
        }
        document.close();
        for (PdfReader reader : readers) {
            reader.close();
        }
    }
}


text:
package org.apache.hadoop.mapreduce;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.io.WritableUtils;
import org.apache.hadoop.mapred.TIPStatus;

/** A report on the state of a task. */
@InterfaceAudience.Private
@InterfaceStability.Evolving
public class TaskReport implements Writable {
  private TaskID taskid;
  private float progress;
  private String state;
  private String[] diagnostics;
  private long startTime;
  private long finishTime;
  private Counters counters;
  private TIPStatus currentStatus;

  private Collection<TaskAttemptID> runningAttempts =
    new ArrayList<TaskAttemptID>();
  private TaskAttemptID successfulAttempt = new TaskAttemptID();
  public TaskReport() {
    taskid = new TaskID();
  }

  /**
   * Creates a new TaskReport object
   * @param taskid
   * @param progress
   * @param state
   * @param diagnostics
   * @param currentStatus
   * @param startTime
   * @param finishTime
   * @param counters
   */
  public TaskReport(TaskID taskid, float progress, String state,
             String[] diagnostics, TIPStatus currentStatus,
             long startTime, long finishTime,
             Counters counters) {
    this.taskid = taskid;
    this.progress = progress;
    this.state = state;
    this.diagnostics = diagnostics;
    this.currentStatus = currentStatus;
    this.startTime = startTime;
    this.finishTime = finishTime;
    this.counters = counters;
  }

  /** The id of the task. */
  public TaskID getTaskId() { return taskid; }

  /** The amount completed, between zero and one. */
  public float getProgress() { return progress; }

  /** The most recent state, reported by the Reporter. */
  public String getState() { return state; }

  /** A list of error messages. */
  public String[] getDiagnostics() { return diagnostics; }

  /** A table of counters. */
  public Counters getTaskCounters() { return counters; }

  /** The current status */
  public TIPStatus getCurrentStatus() {
    return currentStatus;
  }

  /**
   * Get finish time of task.
   * @return 0, if finish time was not set else returns finish time.
   */
  public long getFinishTime() {
    return finishTime;
  }

  /**
   * set finish time of task.
   * @param finishTime finish time of task.
   */
  protected void setFinishTime(long finishTime) {
    this.finishTime = finishTime;
  }

  /**
   * Get start time of task.
   * @return 0 if start time was not set, else start time.
   */
  public long getStartTime() {
    return startTime;
  }

  /**
   * set start time of the task.
   */
  protected void setStartTime(long startTime) {
    this.startTime = startTime;
  }

  /**
   * set successful attempt ID of the task.
   */
  protected void setSuccessfulAttemptId(TaskAttemptID t) {
    successfulAttempt = t;
  }

  /**
   * Get the attempt ID that took this task to completion
   */
  public TaskAttemptID getSuccessfulTaskAttemptId() {
    return successfulAttempt;
  }

  /**
   * set running attempt(s) of the task.
   */
  protected void setRunningTaskAttemptIds(
      Collection<TaskAttemptID> runningAttempts) {
    this.runningAttempts = runningAttempts;
  }

  /**
   * Get the running task attempt IDs for this task
   */
  public Collection<TaskAttemptID> getRunningTaskAttemptIds() {
    return runningAttempts;
  }

  @Override
  public boolean equals(Object o) {
    if(o == null)
      return false;
    if(o.getClass().equals(this.getClass())) {
      TaskReport report = (TaskReport) o;
      return counters.equals(report.getTaskCounters())
             && Arrays.toString(this.diagnostics)
                      .equals(Arrays.toString(report.getDiagnostics()))
             && this.finishTime == report.getFinishTime()
             && this.progress == report.getProgress()
             && this.startTime == report.getStartTime()
             && this.state.equals(report.getState())
             && this.taskid.equals(report.getTaskId());
    }
    return false;
  }

  @Override
  public int hashCode() {
    return (counters.toString() + Arrays.toString(this.diagnostics)
            + this.finishTime + this.progress + this.startTime + this.state
            + this.taskid.toString()).hashCode();
  }
  //////////////////////////////////////////////
  // Writable
  //////////////////////////////////////////////
  public void write(DataOutput out) throws IOException {
    taskid.write(out);
    out.writeFloat(progress);
    Text.writeString(out, state);
    out.writeLong(startTime);
    out.writeLong(finishTime);
    WritableUtils.writeStringArray(out, diagnostics);
    counters.write(out);
    WritableUtils.writeEnum(out, currentStatus);
    if (currentStatus == TIPStatus.RUNNING) {
      WritableUtils.writeVInt(out, runningAttempts.size());
      TaskAttemptID t[] = new TaskAttemptID[0];
      t = runningAttempts.toArray(t);
      for (int i = 0; i < t.length; i++) {
        t[i].write(out);
      }
    } else if (currentStatus == TIPStatus.COMPLETE) {
      successfulAttempt.write(out);
    }
  }

  public void readFields(DataInput in) throws IOException {
    this.taskid.readFields(in);
    this.progress = in.readFloat();
    this.state = Text.readString(in);
    this.startTime = in.readLong();
    this.finishTime = in.readLong();

    diagnostics = WritableUtils.readStringArray(in);
    counters = new Counters();
    counters.readFields(in);
    currentStatus = WritableUtils.readEnum(in, TIPStatus.class);
    if (currentStatus == TIPStatus.RUNNING) {
      int num = WritableUtils.readVInt(in);
      for (int i = 0; i < num; i++) {
        TaskAttemptID t = new TaskAttemptID();
        t.readFields(in);
        runningAttempts.add(t);
      }
    } else if (currentStatus == TIPStatus.COMPLETE) {
      successfulAttempt.readFields(in);
    }
  }
}


text:
require 'rspec'
require 'rack/test'
require 'sinatra/base'
require_relative '../lib/sinatra/rroute'
require_relative 'test_app'

RSpec.configure do |config|
  config.include Rack::Test::Methods
end

describe "Rroute" do
  # Setup

  def app
    TestApp
  end

  before(:each) do
    @user = { :name => 'John', :age => 32}
  end

  # Tests

  describe "#paths" do
    it "merges route mappings into `settings.app_paths' uppon a GET \
request" do
      get '/paths/randomname/randomdescription/'
      paths = {:paths_test_path =>
        {:http_method=>:get,
          :regex =>"/paths/:name/:description/?",
          :controller =>:paths_test,
          :mask =>"/paths/:name/:description/"},
        :route =>
        {:http_method =>:get,
          :regex =>"/route/:name/?",
          :controller =>nil,
          :mask =>"/route/:name"},
        :color =>
        {:http_method =>:get,
          :regex =>"/api/new/color/:name/:value/?",
          :controller =>:show_color,
          :mask =>"/api/new/color/:name/:value"},
        :blue =>
        {:http_method =>:post,
          :regex =>"/important/api/blue/:name/:value/?",
          :controller =>:post_blue,
          :mask =>"/important/api/blue/:name/:value"},
        :something =>
        {:http_method =>:get,
          :regex =>"/something/:name/:value/?",
          :controller =>:api_something,
          :mask =>"/something/:name/:value"}}
      expect(last_response).to be_ok
      expect(last_response.body).to eq(paths.inspect)
    end
  end

  describe "#gget" do
    it "successfully dispatches a GET request and defines a route mask" do
      get "/user/#{@user[:name]}/#{@user[:age]}/"
      expect(last_response).to be_ok
      expect(app.settings.app_paths[:user][:mask]).to eq("/user/:name/:age\
/")
      expect(last_response.body).to eq("/user/#{@user[:name]}/\
#{@user[:age]}/")
    end
  end

  describe "#gget (2)" do
    it "successfully dispatches a GET request and defines a route mask
(using a RegExp-quoted string as route)" do
      get "/regex/#{@user[:name]}/#{@user[:age]}/"
      expect(last_response).to be_ok
      expect(last_response.body).to eq("/regex/#{@user[:name]}/\
#{@user[:age]}/")
    end
  end

  describe "#gget (3)" do
    it "successfully dispatches a GET request and defines a route mask
(using a nested controller reference - instance method)" do
      get '/nested/controller/references'
      expect(last_response).to be_ok
      expect(last_response.body)
        .to include('95475e78-f2c9-11e3-ba43-60eb69544a6d')
    end
  end

  describe "#gget (4)" do
    it "successfully dispatches a GET request and defines a route mask
(using a nested controller reference - class method)" do
      get '/nested/controller/references/another/one'
      expect(last_response).to be_ok
      expect(last_response.body)
        .to include('98985e7e-f2c9-11e3-b9d9-60eb69544a6d')
    end
  end

  describe "#ppost" do
    it "successfully dispatches a POST request and defines a route mask" do
      post "/user/new/#{@user[:name]}/#{@user[:age]}/"
      expect(last_response).to be_ok
      expect(app.settings.app_paths[:new_user][:mask]).to eq("/user/new/\
:name/:age/")
      expect(last_response.body).to eq("/user/new/#{@user[:name]}/\
#{@user[:age]}/")
    end
  end

  describe "#pput" do
    it "successfully dispatches a PUT request and defines a route mask" do
      put "/user/change/#{@user[:name]}/#{@user[:age]}/"
      expect(last_response).to be_ok
      expect(app.settings.app_paths[:change_user][:mask]).to eq("/user/\
change/:name/:age/")
      expect(last_response.body).to eq("/user/change/#{@user[:name]}/\
#{@user[:age]}/")
    end
  end

  describe "#ddelete" do
    it "successfully dispatches a DELETE request and defines a route \
mask" do
      delete "/user/delete/#{@user[:name]}/#{@user[:age]}/"
      expect(last_response).to be_ok
      expect(app.settings.app_paths[:delete_user][:mask]).to eq("/user/\
delete/:name/:age/")
      expect(last_response.body).to eq("/user/delete/#{@user[:name]}/\
#{@user[:age]}/")
    end
  end

  describe "#hhead" do
    it "successfully dispatches a HEAD request and defines a route \
  mask" do
      head "/user/head/#{@user[:name]}/#{@user[:age]}/"
      expect(last_response).to be_ok
      expect(app.settings.app_paths[:head_user][:mask]).to eq("/user/\
head/:name/:age/")
      expect(last_response.body).to be_empty
    end
  end

  describe "#ppath" do
    it "successfully dispatches a GET request and defines a route \
mask (using `ppath')" do
      get "/user/moreinfo/#{@user[:name]}/#{@user[:age]}/"
      expect(last_response).to be_ok
      expect(app.settings.app_paths[:more_user_info][:mask]).to eq("/user/\
moreinfo/:name/:age/")
      expect(last_response.body).to eq("/user/moreinfo/#{@user[:name]}/\
#{@user[:age]}/")
    end
  end

  describe "#nnampespace" do
    it "successfully dispatches a GET request and defines a route \
mask (using `nnamespace' and `gget')" do
      # /api/v1/beta
      get "/api/v1/beta/user/#{@user[:name]}/#{@user[:age]}/"
      expect(last_response).to be_ok
      expect(app.settings.app_paths[:api_user_beta][:mask]).to eq("/api/\
v1/beta/user/:name/:age/")
      expect(last_response.body).to eq("/api/v1/beta/user/#{@user[:name]}/\
#{@user[:age]}/")

      # /api/v1/alpha
      get "/api/v1/alpha/user/#{@user[:name]}/#{@user[:age]}/"
      expect(last_response).to be_ok
      expect(app.settings.app_paths[:api_user_alpha][:mask]).to eq("/api/\
v1/alpha/user/:name/:age/")
      expect(last_response.body).to eq("/api/v1/alpha/user/\
#{@user[:name]}/#{@user[:age]}/")

      # `mmap' in a `nnamespace' block
      get "/api/v1/overview/#{@user[:name]}/#{@user[:age]}/"
      expect(last_response).to be_ok
      expect(app.settings.app_paths[:api_overview][:mask]).to eq("/api/\
v1/overview/:name/:age/")
      expect(last_response.body).to eq("/api/v1/overview/\
#{@user[:name]}/#{@user[:age]}/")
    end
  end

  describe "#nnampespace (2)" do
    it "successfully dispatches a GET request and defines a route mask \
  (using `nnamespace' and Sinatra's `get', `post', `put' and `delete')" do
      # GET
      get "/user/sinatra/get/#{@user[:name]}/#{@user[:age]}/"
      expect(last_response).to be_ok
      expect(last_response.body).to eq('User GET')
      # POST
      post "/user/sinatra/post/#{@user[:name]}/#{@user[:age]}/"
      expect(last_response).to be_ok
      expect(last_response.body).to eq('User POST')
    end
  end

  describe "#mmap" do
    it "successfully dispatches a GET request and defines a route \
mask (using `mmap' and Sinatra's built-in `get')" do
      get "/user/mmap/#{@user[:name]}/#{@user[:age]}/"
      expect(last_response).to be_ok
      expect(app.settings.app_paths[:mmap_user][:mask]).to eq("/user/mmap/\
:name/:age/")
      expect(last_response.body).to eq("/user/mmap/#{@user[:name]}/\
#{@user[:age]}/")
    end
  end

  describe "#mmap (2)" do
    it "successfully dispatches a GET request and defines a route \
mask (using `mmap', Sinatra's built-in `get' and a quoted string as route)" do
      get "/user/mmap/regex/#{@user[:name]}/#{@user[:age]}/"
      expect(last_response).to be_ok
      expect(app.settings.app_paths[:mmap_user][:mask]).to eq("/user/mmap/\
:name/:age/")
      expect(last_response.body).to eq("/user/mmap/regex/#{@user[:name]}/\
#{@user[:age]}/")
    end
  end

  describe "#generate_paths" do
    it "successfully dispatches a GET request and generates \
`settings.app_paths')" do
      get '/generate/paths/'
      expect(last_response).to be_ok
      expect(last_response.body).to eq 'Paths have been generated.'
      expect(app.settings.app_paths).not_to be(nil)
    end
  end
end


text:
module.exports = exports = {};
exports.getShareCount = getShareCount;
exports.getLinksFromTweets = getLinksFromTweets;

var request = require('../../../patches/requestPatch'),
		async = require('async'),
		utils = require('../../../lib/utils'),
		Twitter = require('twit'),
		dataUtils = require('../../../data/utils/'),
		colors = require('colors'),
		rateLimit = require('function-rate-limit');

var config = require('boring-config')('config.cson')

// https://dev.twitter.com/rest/public/rate-limiting
// 'Search will be rate limited at 180 queries per 15 minute window for the time being'
var TWITTER_RATE_LIMIT = {
	CALLS: 180,
	TIME: 15 * 60 * 1000
}

var getTweetsRateLimited = rateLimit(TWITTER_RATE_LIMIT.CALLS, TWITTER_RATE_LIMIT.TIME, function(searchTerm, since, callback){
	twitter.get('search/tweets', {q: escape(searchTerm) + ' since:' + since, count: 100}, function (err, data, res) {
		callback(err, data.statuses || null);
	});
})

var twitter = new Twitter({
	consumer_key: config.twitter.consumerKey,
	consumer_secret: config.twitter.consumerSecret,
	access_token: config.twitter.accessToken,
	access_token_secret: config.twitter.accessTokenSecret
});

var validLinkKeywords = [
	'(product)',
	'(products)',
	'(review)',
	'(reviews)',
	'(reviewed)',
	'(launch)',
	'(launched)',
	'(release)',
	'(releases)',
	'(released)',
	'(announce)',
	'(announced)',
	'(announcement)',
	'(update)',
	'(updated)',
	'(new)'
];

var VALID_LINK_REGEX = new RegExp(validLinkKeywords.join('|'), 'gi');

// return top 100 tweets matching search term
var getTweets = function getTweets(searchTerm, callback) {
	var now = new Date(),
			since = '';

	now.setDate(now.getDate() - 1);
	since = [now.getFullYear(), now.getMonth() + 1, now.getDate()].join('-');
	searchTerm = dataUtils.cleanProductName(searchTerm);
	getTweetsRateLimited(searchTerm, since, callback);
}

// extract t.co links from array of tweets provided
var harvestLinks = function harvestLinks(tweets) {
	var urlRegEx = /https?:\/\/[a-z]+.[a-zA-Z]+\/[a-zA-Z0-9]+/g,
			urlsFromTweets = [],
			distinctUrls = [];

	urlsFromTweets = tweets.map(function (elm, idx, self) {
		return elm.text.match(urlRegEx);
	});

	if (urlsFromTweets.length > 0) {
		urlsFromTweets = urlsFromTweets.reduce(function (prev, curr) {
			if (prev) return prev.concat(curr);
			else if (curr) return curr.concat();
			else return;
		});

		if (urlsFromTweets) {

			urlsFromTweets = urlsFromTweets.map(function (url) {
				if (distinctUrls.indexOf(url) < 0) {
					distinctUrls.push(url);
				}
			});
		}
	}

	return distinctUrls;
}

// helper to ensure full URL is obtained from a shortened one
var getFullUrl = function getFullUrl(url, callback) {
	var options = {
		url: url,
		method: 'HEAD',
		followAllRedirects: true,
		maxRedirects: 10
	};

	request(options, function (err, res, body) {
		if (err) {
			// https://github.com/joyent/node/issues/4863
			if ( err.code === 'HPE_INVALID_CONSTANT' ) {
				err = 'HTTP parse error - site is sending back invalid HTML'
			}
			log('#request() callback error', err, url);
			callback();
		} else {
			callback(res.request.href);
		}
	});
}

function getLinksFromTweets(searchTerm, callback) {

	getTweets(searchTerm.trim(), function (err, tweets) {
		if (err) {
			callback(err);
		} else {
			var fullUrls = [];
			var links = harvestLinks(tweets).filter(function (el) {
				return Boolean(el);
			});

			var getLink = function getLink(url, cb) {
				getFullUrl(url, function (url) {
					if (url && url.search(VALID_LINK_REGEX) !== -1) {
						if (fullUrls.indexOf(url) < 0) {
							console.log('===>>> secondary url:'.yellow, url.yellow);

							// TODO: write the url out to a file for manual verification

							fullUrls.push(url);
						}
					}

					cb();
				});
			};

			// get full URL and then sharing stats for each tweeted link
			async.eachLimit(links, 3, getLink, function (err) {
				if (err) {
					log('async #getLink() error', err);
					callback(err);
				} else {
					callback(null, fullUrls);
				}
			});
		}
	});
}

// wrapper to get share count of a given URL
function getShareCount(url, callback) {
	var options = {
		url: 'http://urls.api.twitter.com/1/urls/count.json?url=' + escape(url),
		headers: { 'User-Agent': config.twitter.userAgent },
		encoding: 'utf8',
		timeout: 5000
	};

	request(options, function (err, res, body) {
		var parsedBody = {};
		if ( body ) {
			parsedBody = JSON.parse(body)
		} else {
			err = 'No body in response'
		}
		log('twitter shares'.blue, url);
		if ( err ) {
			log('Error getting Twitter share count', err)
			// TODO: callback with null even though we have an error?
			// If we always call callback with null, change signature.
			callback(null, 0);
		} else {
			callback(null, parsedBody.count || 0);
		}
	});
}


text:
package eu.bcvsolutions.idm.core.model.jaxb;

import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "services")
public class IdmScriptServicesType {

	private List<IdmScriptServiceType> services;

	@XmlElement(name="service", type = IdmScriptServiceType.class)
	public List<IdmScriptServiceType> getServices() {
		return services;
	}

	public void setServices(List<IdmScriptServiceType> services) {
		this.services = services;
	}

}


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.8"/>
<title>illacceptanything: firstblog1.urls Namespace Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>

<link href="navtree.css" rel="stylesheet" type="text/css"/>

<link href="doxygen.css" rel="stylesheet" type="text/css" />

illacceptanything
    2.0

Main Page

Namespaces

Data Structures

Files

Namespace List

Namespace Members

Variables

firstblog1.urls Namespace Reference

Variables

tuple 	urlpatterns

Variable Documentation

          tuple firstblog1.urls.urlpatterns

Initial value:

    1 = patterns('',

    2     # Examples:

    3     url(r'^$', 'blog1.views.home', name='home'),

    4                        #url(r'^blog/', include('blog.urls')),

    5     url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    6

    7     #uncomment the next line to enable the admin

    8

    9     url(r'^admin/', include(admin.site.urls)),

   10

   11 )

setup.url

string url

Definition: bak/setup.py:28

Definition at line 8 of file urls.py.

firstblog1

urls

Generated on Fri Apr 10 2015 15:21:50 for illacceptanything by

     1.8.8


text:
import Koa from 'koa'
import bodyParser from 'koa-bodyparser'
import jsonp from 'koa-jsonp'
import cors from 'kcors'
// import cors from 'koa-cors'
import logger from 'koa-logger'

const app = new Koa()
app.proxy = true
app.use(logger())

// TODO: wait for this: https://github.com/koajs/cors/pull/20
app.use((ctx, next) => {
  ctx.set('Access-Control-Allow-Origin', '*')
  ctx.set('Access-Control-Allow-Methods', 'GET,HEAD,PUT,POST,DELETE')
  ctx.set('Access-Control-Allow-Credentials', 'true')
  return next()
})
app.use(cors({
  origin: '*'
}))
app.use(jsonp())
app.use(bodyParser({
  onerror: (err, ctx) => {
    console.log(err)
    ctx.throw('body parse error', 422)
  }
}))

export default app


text:
package uk.gov.phe.erdst.sc.awag.service.validation.impl;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import uk.gov.phe.erdst.sc.awag.service.validation.annotations.ValidIdsArray;
import uk.gov.phe.erdst.sc.awag.service.validation.utils.ValidationConstants;

public class IdsArrayValidator implements ConstraintValidator<ValidIdsArray, Long[]>
{
    @Override
    public void initialize(ValidIdsArray annotation)
    {
    }

    @Override
    public boolean isValid(Long[] ids, ConstraintValidatorContext context)
    {
        for (Long id : ids)
        {
            if (!isIdValid(id))
            {
                return false;
            }
        }

        return true;
    }

    private boolean isIdValid(Long id)
    {
        if (id == null)
        {
            return false;
        }

        return id >= ValidationConstants.ENTITY_MIN_ID;
    }
}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Podosphaera oxyacanthae f. sp

### Remarks
null


text:
package com.amazonaws.services.greengrass.model;

import java.io.Serializable;
import javax.annotation.Generated;

/**
 *
 * @see AWS API Documentation
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class AssociateServiceRoleToAccountResult extends com.amazonaws.AmazonWebServiceResult<com.amazonaws.ResponseMetadata> implements Serializable,
        Cloneable {

    /** The time when the service role was associated with the account. */
    private String associatedAt;

    /**
     * The time when the service role was associated with the account.
     *
     * @param associatedAt
     *        The time when the service role was associated with the account.
     */

    public void setAssociatedAt(String associatedAt) {
        this.associatedAt = associatedAt;
    }

    /**
     * The time when the service role was associated with the account.
     *
     * @return The time when the service role was associated with the account.
     */

    public String getAssociatedAt() {
        return this.associatedAt;
    }

    /**
     * The time when the service role was associated with the account.
     *
     * @param associatedAt
     *        The time when the service role was associated with the account.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public AssociateServiceRoleToAccountResult withAssociatedAt(String associatedAt) {
        setAssociatedAt(associatedAt);
        return this;
    }

    /**
     * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
     * redacted from this string using a placeholder value.
     *
     * @return A string representation of this object.
     *
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getAssociatedAt() != null)
            sb.append("AssociatedAt: ").append(getAssociatedAt());
        sb.append("}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;

        if (obj instanceof AssociateServiceRoleToAccountResult == false)
            return false;
        AssociateServiceRoleToAccountResult other = (AssociateServiceRoleToAccountResult) obj;
        if (other.getAssociatedAt() == null ^ this.getAssociatedAt() == null)
            return false;
        if (other.getAssociatedAt() != null && other.getAssociatedAt().equals(this.getAssociatedAt()) == false)
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;

        hashCode = prime * hashCode + ((getAssociatedAt() == null) ? 0 : getAssociatedAt().hashCode());
        return hashCode;
    }

    @Override
    public AssociateServiceRoleToAccountResult clone() {
        try {
            return (AssociateServiceRoleToAccountResult) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
        }
    }

}


text:
class DebugController < ApplicationController

  def index
  end

end


text:
<!DOCTYPE html>

	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>CuapCuap · Tentang Kami</title>

	<link rel="stylesheet" href="http://cdn.everything.io/kickstart/3.x/css/kickstart.min.css" />

Hot

New

Akademis

Riset

Seni

Olahraga

Santai

						<form action="/search" method="get" accept-charset="utf-8">
							<input type="search" class="search_bar" name="keyword" placeholder="Cari sesuatu?">
						</form>

TENTANG CUAP CUAP CAPUNG

Ullamcorper ac egestas sociis adipiscing mauris semper parturient litora ut a a justo ante tortor class orci et convallis ullamcorper. Est malesuada a commodo interdum maecenas lectus platea commodo lacus vestibulum placerat suspendisse dictumst vestibulum porta senectus ullamcorper a. Metus ultrices vestibulum metus suscipit parturient parturient a himenaeos mi parturient ad a cras sodales vulputate eros. Pretium aliquam consectetur a a cubilia ut turpis adipiscing parturient pulvinar aenean scelerisque inceptos luctus vivamus vulputate libero a leo morbi parturient vel blandit risus. Urna a dui diam tempor nibh purus praesent vestibulum tristique scelerisque quam ut adipiscing porttitor senectus tortor. Suspendisse a a netus diam faucibus accumsan lacinia placerat taciti in a maecenas tellus commodo donec condimentum eu sed a mus duis.

		Et morbi eleifend adipiscing consequat molestie vestibulum a sed lorem dolor eros condimentum etiam ullamcorper posuere cras sem. Egestas duis nunc in cum condimentum fermentum a cras eu ad orci enim a habitant hendrerit vestibulum congue hac scelerisque a nisl rhoncus vestibulum scelerisque. Suspendisse a parturient scelerisque ut nibh faucibus id eu fusce fusce leo senectus nam duis suspendisse praesent ultrices at tempus.

TIM KAMI

					Name Is Nama

					Sebagai Om Om Genit

					Name Is Nama

					Sebagai Om Om Genit

					Name Is Nama

					Sebagai Om Om Genit

					Name Is Nama

					Sebagai Om Om Genit

					Name Is Nama

					Sebagai Om Om Genit

					Name Is Nama

					Sebagai Om Om Genit

					Name Is Nama

					Sebagai Om Om Genit

					Name Is Nama

					Sebagai Om Om Genit

					Name Is Nama

					Sebagai Om Om Genit

© Tim SBF PTI 2015, All Rights Reserved.

Tentang Kami

Bantuan

Kontak


text:
require 'chef/knife'
require 'chef/knife/elb_base'
require 'chef/knife/elb_listener_base'

class Chef
  class Knife
    class ElbListenerAdd < Knife
      include Chef::Knife::ElbBase
      include Chef::Knife::ElbListenerBase

      banner 'knife elb listener add ELB (options)'

      def run
        validate!

        response = connection.create_load_balancer_listeners(@name_args.first, build_listeners(config))

        ui.output(Chef::JSONCompat.from_json(response.data[:body].to_json))
      end

      private

      def validate!
        super

        unless @name_args.size == 1
          ui.error('Please specify the ELB ID')
          exit 1
        end
      end
    end
  end
end


text:
<?xml version="1.0"?>
<!-- Copyright (C) 2011-2015 Free Software Foundation, Inc.

     Copying and distribution of this file, with or without modification,
     are permitted in any medium without royalty provided the copyright
     notice and this notice are preserved.  -->

<!DOCTYPE feature SYSTEM "gdb-syscalls.dtd">

<!-- This file was generated using the following file:

     /usr/src/linux/arch/mips/include/asm/unistd.h

     The file mentioned above belongs to the Linux Kernel.  -->

<syscalls_info>
  <syscall name="read" number="6000"/>
  <syscall name="write" number="6001"/>
  <syscall name="open" number="6002"/>
  <syscall name="close" number="6003"/>
  <syscall name="stat" number="6004"/>
  <syscall name="fstat" number="6005"/>
  <syscall name="lstat" number="6006"/>
  <syscall name="poll" number="6007"/>
  <syscall name="lseek" number="6008"/>
  <syscall name="mmap" number="6009"/>
  <syscall name="mprotect" number="6010"/>
  <syscall name="munmap" number="6011"/>
  <syscall name="brk" number="6012"/>
  <syscall name="rt_sigaction" number="6013"/>
  <syscall name="rt_sigprocmask" number="6014"/>
  <syscall name="ioctl" number="6015"/>
  <syscall name="pread64" number="6016"/>
  <syscall name="pwrite64" number="6017"/>
  <syscall name="readv" number="6018"/>
  <syscall name="writev" number="6019"/>
  <syscall name="access" number="6020"/>
  <syscall name="pipe" number="6021"/>
  <syscall name="_newselect" number="6022"/>
  <syscall name="sched_yield" number="6023"/>
  <syscall name="mremap" number="6024"/>
  <syscall name="msync" number="6025"/>
  <syscall name="mincore" number="6026"/>
  <syscall name="madvise" number="6027"/>
  <syscall name="shmget" number="6028"/>
  <syscall name="shmat" number="6029"/>
  <syscall name="shmctl" number="6030"/>
  <syscall name="dup" number="6031"/>
  <syscall name="dup2" number="6032"/>
  <syscall name="pause" number="6033"/>
  <syscall name="nanosleep" number="6034"/>
  <syscall name="getitimer" number="6035"/>
  <syscall name="setitimer" number="6036"/>
  <syscall name="alarm" number="6037"/>
  <syscall name="getpid" number="6038"/>
  <syscall name="sendfile" number="6039"/>
  <syscall name="socket" number="6040"/>
  <syscall name="connect" number="6041"/>
  <syscall name="accept" number="6042"/>
  <syscall name="sendto" number="6043"/>
  <syscall name="recvfrom" number="6044"/>
  <syscall name="sendmsg" number="6045"/>
  <syscall name="recvmsg" number="6046"/>
  <syscall name="shutdown" number="6047"/>
  <syscall name="bind" number="6048"/>
  <syscall name="listen" number="6049"/>
  <syscall name="getsockname" number="6050"/>
  <syscall name="getpeername" number="6051"/>
  <syscall name="socketpair" number="6052"/>
  <syscall name="setsockopt" number="6053"/>
  <syscall name="getsockopt" number="6054"/>
  <syscall name="clone" number="6055"/>
  <syscall name="fork" number="6056"/>
  <syscall name="execve" number="6057"/>
  <syscall name="exit" number="6058"/>
  <syscall name="wait4" number="6059"/>
  <syscall name="kill" number="6060"/>
  <syscall name="uname" number="6061"/>
  <syscall name="semget" number="6062"/>
  <syscall name="semop" number="6063"/>
  <syscall name="semctl" number="6064"/>
  <syscall name="shmdt" number="6065"/>
  <syscall name="msgget" number="6066"/>
  <syscall name="msgsnd" number="6067"/>
  <syscall name="msgrcv" number="6068"/>
  <syscall name="msgctl" number="6069"/>
  <syscall name="fcntl" number="6070"/>
  <syscall name="flock" number="6071"/>
  <syscall name="fsync" number="6072"/>
  <syscall name="fdatasync" number="6073"/>
  <syscall name="truncate" number="6074"/>
  <syscall name="ftruncate" number="6075"/>
  <syscall name="getdents" number="6076"/>
  <syscall name="getcwd" number="6077"/>
  <syscall name="chdir" number="6078"/>
  <syscall name="fchdir" number="6079"/>
  <syscall name="rename" number="6080"/>
  <syscall name="mkdir" number="6081"/>
  <syscall name="rmdir" number="6082"/>
  <syscall name="creat" number="6083"/>
  <syscall name="link" number="6084"/>
  <syscall name="unlink" number="6085"/>
  <syscall name="symlink" number="6086"/>
  <syscall name="readlink" number="6087"/>
  <syscall name="chmod" number="6088"/>
  <syscall name="fchmod" number="6089"/>
  <syscall name="chown" number="6090"/>
  <syscall name="fchown" number="6091"/>
  <syscall name="lchown" number="6092"/>
  <syscall name="umask" number="6093"/>
  <syscall name="gettimeofday" number="6094"/>
  <syscall name="getrlimit" number="6095"/>
  <syscall name="getrusage" number="6096"/>
  <syscall name="sysinfo" number="6097"/>
  <syscall name="times" number="6098"/>
  <syscall name="ptrace" number="6099"/>
  <syscall name="getuid" number="6100"/>
  <syscall name="syslog" number="6101"/>
  <syscall name="getgid" number="6102"/>
  <syscall name="setuid" number="6103"/>
  <syscall name="setgid" number="6104"/>
  <syscall name="geteuid" number="6105"/>
  <syscall name="getegid" number="6106"/>
  <syscall name="setpgid" number="6107"/>
  <syscall name="getppid" number="6108"/>
  <syscall name="getpgrp" number="6109"/>
  <syscall name="setsid" number="6110"/>
  <syscall name="setreuid" number="6111"/>
  <syscall name="setregid" number="6112"/>
  <syscall name="getgroups" number="6113"/>
  <syscall name="setgroups" number="6114"/>
  <syscall name="setresuid" number="6115"/>
  <syscall name="getresuid" number="6116"/>
  <syscall name="setresgid" number="6117"/>
  <syscall name="getresgid" number="6118"/>
  <syscall name="getpgid" number="6119"/>
  <syscall name="setfsuid" number="6120"/>
  <syscall name="setfsgid" number="6121"/>
  <syscall name="getsid" number="6122"/>
  <syscall name="capget" number="6123"/>
  <syscall name="capset" number="6124"/>
  <syscall name="rt_sigpending" number="6125"/>
  <syscall name="rt_sigtimedwait" number="6126"/>
  <syscall name="rt_sigqueueinfo" number="6127"/>
  <syscall name="rt_sigsuspend" number="6128"/>
  <syscall name="sigaltstack" number="6129"/>
  <syscall name="utime" number="6130"/>
  <syscall name="mknod" number="6131"/>
  <syscall name="personality" number="6132"/>
  <syscall name="ustat" number="6133"/>
  <syscall name="statfs" number="6134"/>
  <syscall name="fstatfs" number="6135"/>
  <syscall name="sysfs" number="6136"/>
  <syscall name="getpriority" number="6137"/>
  <syscall name="setpriority" number="6138"/>
  <syscall name="sched_setparam" number="6139"/>
  <syscall name="sched_getparam" number="6140"/>
  <syscall name="sched_setscheduler" number="6141"/>
  <syscall name="sched_getscheduler" number="6142"/>
  <syscall name="sched_get_priority_max" number="6143"/>
  <syscall name="sched_get_priority_min" number="6144"/>
  <syscall name="sched_rr_get_interval" number="6145"/>
  <syscall name="mlock" number="6146"/>
  <syscall name="munlock" number="6147"/>
  <syscall name="mlockall" number="6148"/>
  <syscall name="munlockall" number="6149"/>
  <syscall name="vhangup" number="6150"/>
  <syscall name="pivot_root" number="6151"/>
  <syscall name="_sysctl" number="6152"/>
  <syscall name="prctl" number="6153"/>
  <syscall name="adjtimex" number="6154"/>
  <syscall name="setrlimit" number="6155"/>
  <syscall name="chroot" number="6156"/>
  <syscall name="sync" number="6157"/>
  <syscall name="acct" number="6158"/>
  <syscall name="settimeofday" number="6159"/>
  <syscall name="mount" number="6160"/>
  <syscall name="umount2" number="6161"/>
  <syscall name="swapon" number="6162"/>
  <syscall name="swapoff" number="6163"/>
  <syscall name="reboot" number="6164"/>
  <syscall name="sethostname" number="6165"/>
  <syscall name="setdomainname" number="6166"/>
  <syscall name="create_module" number="6167"/>
  <syscall name="init_module" number="6168"/>
  <syscall name="delete_module" number="6169"/>
  <syscall name="get_kernel_syms" number="6170"/>
  <syscall name="query_module" number="6171"/>
  <syscall name="quotactl" number="6172"/>
  <syscall name="nfsservctl" number="6173"/>
  <syscall name="getpmsg" number="6174"/>
  <syscall name="putpmsg" number="6175"/>
  <syscall name="afs_syscall" number="6176"/>
  <syscall name="reserved177" number="6177"/>
  <syscall name="gettid" number="6178"/>
  <syscall name="readahead" number="6179"/>
  <syscall name="setxattr" number="6180"/>
  <syscall name="lsetxattr" number="6181"/>
  <syscall name="fsetxattr" number="6182"/>
  <syscall name="getxattr" number="6183"/>
  <syscall name="lgetxattr" number="6184"/>
  <syscall name="fgetxattr" number="6185"/>
  <syscall name="listxattr" number="6186"/>
  <syscall name="llistxattr" number="6187"/>
  <syscall name="flistxattr" number="6188"/>
  <syscall name="removexattr" number="6189"/>
  <syscall name="lremovexattr" number="6190"/>
  <syscall name="fremovexattr" number="6191"/>
  <syscall name="tkill" number="6192"/>
  <syscall name="reserved193" number="6193"/>
  <syscall name="futex" number="6194"/>
  <syscall name="sched_setaffinity" number="6195"/>
  <syscall name="sched_getaffinity" number="6196"/>
  <syscall name="cacheflush" number="6197"/>
  <syscall name="cachectl" number="6198"/>
  <syscall name="sysmips" number="6199"/>
  <syscall name="io_setup" number="6200"/>
  <syscall name="io_destroy" number="6201"/>
  <syscall name="io_getevents" number="6202"/>
  <syscall name="io_submit" number="6203"/>
  <syscall name="io_cancel" number="6204"/>
  <syscall name="exit_group" number="6205"/>
  <syscall name="lookup_dcookie" number="6206"/>
  <syscall name="epoll_create" number="6207"/>
  <syscall name="epoll_ctl" number="6208"/>
  <syscall name="epoll_wait" number="6209"/>
  <syscall name="remap_file_pages" number="6210"/>
  <syscall name="rt_sigreturn" number="6211"/>
  <syscall name="fcntl64" number="6212"/>
  <syscall name="set_tid_address" number="6213"/>
  <syscall name="restart_syscall" number="6214"/>
  <syscall name="semtimedop" number="6215"/>
  <syscall name="fadvise64" number="6216"/>
  <syscall name="statfs64" number="6217"/>
  <syscall name="fstatfs64" number="6218"/>
  <syscall name="sendfile64" number="6219"/>
  <syscall name="timer_create" number="6220"/>
  <syscall name="timer_settime" number="6221"/>
  <syscall name="timer_gettime" number="6222"/>
  <syscall name="timer_getoverrun" number="6223"/>
  <syscall name="timer_delete" number="6224"/>
  <syscall name="clock_settime" number="6225"/>
  <syscall name="clock_gettime" number="6226"/>
  <syscall name="clock_getres" number="6227"/>
  <syscall name="clock_nanosleep" number="6228"/>
  <syscall name="tgkill" number="6229"/>
  <syscall name="utimes" number="6230"/>
  <syscall name="mbind" number="6231"/>
  <syscall name="get_mempolicy" number="6232"/>
  <syscall name="set_mempolicy" number="6233"/>
  <syscall name="mq_open" number="6234"/>
  <syscall name="mq_unlink" number="6235"/>
  <syscall name="mq_timedsend" number="6236"/>
  <syscall name="mq_timedreceive" number="6237"/>
  <syscall name="mq_notify" number="6238"/>
  <syscall name="mq_getsetattr" number="6239"/>
  <syscall name="vserver" number="6240"/>
  <syscall name="waitid" number="6241"/>
  <syscall name="add_key" number="6243"/>
  <syscall name="request_key" number="6244"/>
  <syscall name="keyctl" number="6245"/>
  <syscall name="set_thread_area" number="6246"/>
  <syscall name="inotify_init" number="6247"/>
  <syscall name="inotify_add_watch" number="6248"/>
  <syscall name="inotify_rm_watch" number="6249"/>
  <syscall name="migrate_pages" number="6250"/>
  <syscall name="openat" number="6251"/>
  <syscall name="mkdirat" number="6252"/>
  <syscall name="mknodat" number="6253"/>
  <syscall name="fchownat" number="6254"/>
  <syscall name="futimesat" number="6255"/>
  <syscall name="newfstatat" number="6256"/>
  <syscall name="unlinkat" number="6257"/>
  <syscall name="renameat" number="6258"/>
  <syscall name="linkat" number="6259"/>
  <syscall name="symlinkat" number="6260"/>
  <syscall name="readlinkat" number="6261"/>
  <syscall name="fchmodat" number="6262"/>
  <syscall name="faccessat" number="6263"/>
  <syscall name="pselect6" number="6264"/>
  <syscall name="ppoll" number="6265"/>
  <syscall name="unshare" number="6266"/>
  <syscall name="splice" number="6267"/>
  <syscall name="sync_file_range" number="6268"/>
  <syscall name="tee" number="6269"/>
  <syscall name="vmsplice" number="6270"/>
  <syscall name="move_pages" number="6271"/>
  <syscall name="set_robust_list" number="6272"/>
  <syscall name="get_robust_list" number="6273"/>
  <syscall name="kexec_load" number="6274"/>
  <syscall name="getcpu" number="6275"/>
  <syscall name="epoll_pwait" number="6276"/>
  <syscall name="ioprio_set" number="6277"/>
  <syscall name="ioprio_get" number="6278"/>
  <syscall name="utimensat" number="6279"/>
  <syscall name="signalfd" number="6280"/>
  <syscall name="timerfd" number="6281"/>
  <syscall name="eventfd" number="6282"/>
  <syscall name="fallocate" number="6283"/>
  <syscall name="timerfd_create" number="6284"/>
  <syscall name="timerfd_gettime" number="6285"/>
  <syscall name="timerfd_settime" number="6286"/>
  <syscall name="signalfd4" number="6287"/>
  <syscall name="eventfd2" number="6288"/>
  <syscall name="epoll_create1" number="6289"/>
  <syscall name="dup3" number="6290"/>
  <syscall name="pipe2" number="6291"/>
  <syscall name="inotify_init1" number="6292"/>
  <syscall name="preadv" number="6293"/>
  <syscall name="pwritev" number="6294"/>
  <syscall name="rt_tgsigqueueinfo" number="6295"/>
  <syscall name="perf_event_open" number="6296"/>
  <syscall name="accept4" number="6297"/>
  <syscall name="recvmmsg" number="6298"/>
  <syscall name="getdents64" number="6299"/>
  <syscall name="fanotify_init" number="6300"/>
  <syscall name="fanotify_mark" number="6301"/>
  <syscall name="prlimit64" number="6302"/>
</syscalls_info>


text:
package org.qi4j.sample.dcicargo.sample_b.data.factory.exception;

import org.qi4j.sample.dcicargo.sample_b.data.structure.handling.HandlingEvent;

/**
 * If a {@link HandlingEvent} can't be created from a given set of parameters.
 *
 * It is a checked exception because it's not a programming error, but rather a
 * special case that the application is built to handle. It can occur during normal
 * program execution.
 */
public class CannotCreateHandlingEventException extends Exception
{
    public CannotCreateHandlingEventException( String s )
    {
        super( s );
    }
}


text:
<?php

class Fooorder extends Eloquent {

	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'fooorders';

	/**
	 * The attributes excluded from the model's JSON form.
	 *
	 * @var array
	 */
	protected $fillable = array('name', 'room','quantity');

protected $softDelete = true;
}


text:
package org.ihtsdo.otf.mapping.test.rest;

import org.ihtsdo.otf.mapping.helpers.MapUserRole;
import org.ihtsdo.otf.mapping.jpa.MapUserJpa;
import org.ihtsdo.otf.mapping.jpa.services.MappingServiceJpa;
import org.ihtsdo.otf.mapping.jpa.services.rest.SecurityServiceRest;
import org.ihtsdo.otf.mapping.model.MapUser;
import org.ihtsdo.otf.mapping.rest.impl.SecurityServiceRestImpl;
import org.ihtsdo.otf.mapping.services.MappingService;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

/**
 * Implementation of the "Security Service REST Degenerate Use" Test Cases.
 */
public class SecurityServiceEdgeCasesTest {

  /** The securityService. */
  private static SecurityServiceRest securityService;

  /** The mapping service. */
  private static MappingService mappingService;

  /**
   * Create test fixtures for class.
   *
   * @throws Exception the exception
   */
  @BeforeClass
  public static void setupClass() throws Exception {
    securityService = new SecurityServiceRestImpl();
    mappingService = new MappingServiceJpa();

    // create map users
    MapUser user = new MapUserJpa();
    user.setName("guest");
    user.setUserName("guest");
    user.setEmail("guest");
    user.setApplicationRole(MapUserRole.VIEWER);
    mappingService.addMapUser(user);

    MapUser demoUser = new MapUserJpa();
    demoUser.setName("demo_lead");
    demoUser.setUserName("demo_lead");
    demoUser.setEmail("demo_lead");
    demoUser.setApplicationRole(MapUserRole.VIEWER);
    mappingService.addMapUser(demoUser);
  }

  /**
   * Create test fixtures per test.
   *
   * @throws Exception the exception
   */
  @SuppressWarnings("static-method")
  @Before
  public void setup() throws Exception {
    securityService = new SecurityServiceRestImpl();
  }

  /**
   * Test edge cases of the authenticate methods of {@link SecurityServiceRestImpl}.
   *
   * @throws Exception the exception
   */
  @SuppressWarnings("static-method")
  @Test
  public void testEdgeCasesRestSecurity001() throws Exception {

    securityService.authenticate("guest", "guest");
    securityService.authenticate("guest", "guest");
    securityService.authenticate("demo_lead", ".");
    securityService.authenticate("demo_lead", ".");
  }

  /**
   * Test edge cases of logout for {@link SecurityServiceRestImpl}.
   *
   * @throws Exception the exception
   */
  @SuppressWarnings("static-method")
  @Test
  public void testEdgeCasesRestSecurity002() throws Exception {
    securityService.logout("guest");

    securityService.authenticate("guest", "guest");
    securityService.logout("guest");
    securityService.logout("guest");

    securityService.authenticate("demo_lead", ".");
    securityService.logout("demo_lead");
    securityService.logout("demo_lead");

  }

  /**
   * Teardown.
   *
   * @throws Exception the exception
   */
  @After
  public void teardown() throws Exception {
    // do nothing
  }

  /**
   * Teardown class.
   *
   * @throws Exception the exception
   */
  @AfterClass
  public static void teardownClass() throws Exception {
    // remove the users
    for (MapUser user : mappingService.getMapUsers().getMapUsers()) {
      mappingService.removeMapUser(user.getId());
    }

    mappingService.close();
  }

}


text:
Installing MPF on Mac (Aug 29, 2022 update)
=========================================

This is the new step-by-step process we are actively working out to get MPF 0.56 (current dev branch) installed on a Mac.

Overview of MPF on macOS
------------------------

MPF works on macOS running on both Intel and Apple Silicon (M1/M2 processors). The instructions are ALMOST the same for both, except Apple Silicon M1/M2 processors have a few extra steps for the time being. (We are still waiting for one of the libraries MPF needs to be compiled for M1/M2, so there's a workaround until then.)

Apple Silicon (M1/M2 processors) require macOS Monterey as well as Python 3.9. With Intel processors, MPF can work as far back as 10.14 (or so? let us know!), and can use Python 3.7, 3.8, or 3.9.

Here is the quick version:

1. If you do not have Python, install Python 3.9.13 from python.org. If you have an M1/M2 Mac, be sure to get the Universal installer, not the Intel one.

   macOS 64-bit Intel-only installer (https://www.python.org/ftp/python/3.9.13/python-3.9.13-macosx10.9.pkg)

   macOS 64-bit universal installer (https://www.python.org/ftp/python/3.9.13/python-3.9.13-macos11.pkg)

   Choose the default installation location. If you want to install to a custom location, remember that location for Step 5.

2. Install Homebrew (https://brew.sh/). Open your command terminal and paste in this command:

   ``/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"``

   This will also install the Xcode command line tools if you don't have them. A lot of stuff will scroll by and it might take awhile.

3. Use Homebrew (or 'brew') to install the libraries and other support files MPF needs: ``brew install SDL2 SDL2_mixer SDL2_image gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly pipx``

4. Run ``pipx ensurepath`` which will configure things pipx installs to be able to run from anywhere.

5. Use pipx to install MPF with the Text UI components. ``pipx install "mpf[cli]" --pip-args="--pre" --python /Library/Frameworks/Python.framework/Versions/3.9/bin/python3 --verbose --include-deps``.

6. Use pipx to install MPF-MC into the mpf environment. ``pipx inject mpf mpf-mc --pip-args="--pre" --verbose --include-deps --include-apps``

7. Updated MPF Monitor instructions (which work with pipx) are :doc:`here </tools/monitor/installation>`.

At this point, MPF 0.56.0.devXX and MPF-MC 0.56.0.devXX are installed. (The "XX" in the version will be the dev build numbers.)

To test, download the ``mpf-examples`` repo from here: https://github.com/missionpinball/mpf-examples. You can either clone it locally, or download the zip file and unzip it. Either is fine, just do what you're most comfortable with. Be sure to download / switch to the ``dev`` branch.

Then back in the terminal, change into the ``mpf-examples`` folder (or whatever folder you just unzipped that into), then change into the ``mc_demo`` folder, then run ``mpf both``. That should launch the mc_demo code (which is Media Controller demo). A window should open with a red background and some text about slides, you should be able to use the right arrow key to advance to the next slide. You should be able to use the left arrow key to go back to the previous slide and you should hear a drum and cymbal sound when you change the slide.

You will see a bunch of warnings about some classes implemented in multiple locations, and how one will be used, but which one is undefined. It sounds scary, but this is normal. (For now.) We are investigating whether this is something we need to fix, and how we'll fix it if it is. But for now, it's fine.

You can also run the "demo_man" game from the ``mpf-examples`` folder. Change into the ``demo_man`` folder and run ``mpf both -X``. You should see the DMD window pop up. The window you ran the command from will have some warnings which cover up the nice
text UI display. Just grab a corner of the window with the mouse and resize the window (just make it a tiny bit bigger and smaller) and that will cause the window contents to completely refresh and you should see the expected MPF text UI display showing switch status, ball locations, etc. (See the screenshots below for details)

At this point, MPF is ready to go!

Notes, Caveats & Next Steps
---------------------------

If have existing SDL and Gstreamer libraries installed (check the ``/Library/Frameworks`` folder), you can delete them. The versions that brew installs will go into the ``/opt/homebrew`` folder.

Do NOT use brew to install Python. Why? Because the Python in brew is meant to support other brew packages that need python, and as such it will automatically "upgrade" you to the latest Python, even on its own, which means your Python will flip to 3.10 and MPF won't work and you'll be sad. So that's why we install the "Framework Python" from python.org. (Why's it called "Framework Python"? Because it installs like a framework to that ``/Library/Frameworks`` folder.)

The Apple Silicon Macs need the Xcode command-line tools installed because the ruamel.yaml library that MPF uses to read YAML files doesn't have a pre-built version for M1/M2 Macs, so it has to be built locally. This process is automstic and transparent when the Xcode tools are installed.

If you do not see the "normal" MPF text UI display, and instead see something like this:

.. image:: images/bad-display.jpg

This is because those warnings mentioned above print on top of the nice MPF display. To fix this, just grab a corner of the window with the mouse and resize it to be a bit bigger and then smaller again. This will cause the entire window to update and you should see the expected MPF text UI display showing switch status, ball locations, etc. (See the screenshots below for details)

.. image:: images/good-display.jpg

Alternately, if you don't want to resize the window every time, you can open two different terminal windows, and run ``mpf -X`` in one and ``mpf mc`` in the other.

Keeping MPF up-to-date
-----------------------

Once you have MPF installed via the procedure above, you can keep it up-to-date by running the final two pipx commands from above which you used to install MPF and MPF-MC.

Questions? Comments? Need help? You can post a reply into the MPF new installers for macOS thread in the MPF Users Google Group: https://groups.google.com/g/mpf-users/c/BIemtw17lx0

What if you borked it?
----------------------

There aren't too many things that could go wrong, but if your environment is broken and you want to remove everything and start over, here are some notes:

To remove homebrew, run the following command:
____
``/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"``

Homebrew installs everything to ``/opt/homebrew``, which means if you just delete that folder, everything will be gone.

To fix Python versions:
____
Another problem is sometimes the system's default Python will be the homebrew one, and not that one that you installed from python.org. This can be a problem because MPF requires Python 3.7, 3.8, or 3.9 (3.9 only on M1/M2 Macs), but the homebrew python could be version 3.10 which won't work with MPF. So if you need to check or change this, you can use the following command:

``which python3``

You will see a path to the version of python that runs when you just type ``python3`` from the command line. Ideally you want it to be the version you installed, which will be:

``/Library/Frameworks/Python.framework/Versions/3.9/bin/python3``

If you see something else, then run ``which -a python3`` to see what other versions are installed. Then copy the path to the version you installed (which will be the ``/Library/Frameworks/...`` version), and use that in Step 5 (the initial pipx installation command) when you install MPF.

To fix errors about failing to load assets:
____
If you get an error about a failure while loading assets, and you see some references to PIL, there's a potential conflict with an image library that you can remove. To do that, use the following command:

``pipx runpip mpf uninstall pillow``

This command uses pipx to run a pip command inside the mpf environment to uninstall a package called pillow.


text:
namespace device {

class BluetoothAdapter;
class BluetoothDeviceWin;

// The BluetoothSocketWin class implements BluetoothSocket for the Microsoft
// Windows platform.
class BluetoothSocketWin : public BluetoothSocketNet {
 public:
  static scoped_refptr<BluetoothSocketWin> CreateBluetoothSocket(
      scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
      scoped_refptr<BluetoothSocketThread> socket_thread);

  // Connect to the peer device and calls |success_callback| when the
  // connection has been established successfully. If an error occurs, calls
  // |error_callback| with a system error message.
  void Connect(const BluetoothDeviceWin* device,
               const BluetoothUUID& uuid,
               const base::Closure& success_callback,
               const ErrorCompletionCallback& error_callback);

  // Listens using this socket using an RFCOMM service published as UUID |uuid|
  // with Channel |options.channel|, or an automatically allocated Channel if
  // |options.channel| is null. |success_callback| will be called if the service
  // is successfully registered, |error_callback| on failure with a message
  // explaining the cause.
  void Listen(scoped_refptr<BluetoothAdapter> adapter,
              const BluetoothUUID& uuid,
              const BluetoothAdapter::ServiceOptions& options,
              const base::Closure& success_callback,
              const ErrorCompletionCallback& error_callback);

  // BluetoothSocketNet:
  void ResetData() override;

  // BluetoothSocket:
  void Accept(const AcceptCompletionCallback& success_callback,
              const ErrorCompletionCallback& error_callback) override;

 protected:
  ~BluetoothSocketWin() override;

 private:
  struct ServiceRegData;

  BluetoothSocketWin(scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
                     scoped_refptr<BluetoothSocketThread> socket_thread);

  void DoConnect(const base::Closure& success_callback,
                 const ErrorCompletionCallback& error_callback);
  void DoListen(const BluetoothUUID& uuid,
      int rfcomm_channel,
      const base::Closure& success_callback,
      const ErrorCompletionCallback& error_callback);
  void DoAccept(const AcceptCompletionCallback& success_callback,
                const ErrorCompletionCallback& error_callback);
  void OnAcceptOnSocketThread(const AcceptCompletionCallback& success_callback,
                              const ErrorCompletionCallback& error_callback,
                              int accept_result);
  void OnAcceptOnUI(std::unique_ptr<net::TCPSocket> accept_socket,
                    const net::IPEndPoint& peer_address,
                    const AcceptCompletionCallback& success_callback,
                    const ErrorCompletionCallback& error_callback);

  std::string device_address_;
  bool supports_rfcomm_;
  uint8_t rfcomm_channel_;
  BTH_ADDR bth_addr_;

  // Data members below are only used when listening.
  scoped_refptr<device::BluetoothAdapter> adapter_;
  std::unique_ptr<ServiceRegData> service_reg_data_;
  std::unique_ptr<net::TCPSocket> accept_socket_;
  net::IPEndPoint accept_address_;

  DISALLOW_COPY_AND_ASSIGN(BluetoothSocketWin);
};

}  // namespace device

#endif  // DEVICE_BLUETOOTH_BLUETOOTH_SOCKET_WIN_H_


text:
import React, { Component } from 'react';
import Relay from 'react-relay';
import { Link } from 'react-router';
import Drawer from 'material-ui/Drawer';
import MenuItem from 'material-ui/MenuItem';
import Subheader from 'material-ui/Subheader';
import Divider from 'material-ui/Divider';
import CommitteeMenuItem from './CommitteeMenuItem';

class Navigation extends Component {
    render () {
        const { open, app } = this.props;
        return (
            <Drawer
                dock={true}
                open={open}
                containerStyle={{
                    top: 50,
                }}>
                <MenuItem
                    containerElement={<Link to="/" />}
                    primaryText="Accueil" />
                <Divider />
                <Subheader>Comités</Subheader>
                {app.committees.map((committee, index) => (
                    <CommitteeMenuItem
                        key={index}
                        committee={committee} />
                ))}
            </Drawer>
        );
    }
}

export default Relay.createContainer(Navigation, {
    fragments: {
        app: () => Relay.QL`
            fragment on App {
                committees {
                    ${CommitteeMenuItem.getFragment('committee')}
                }
            }
        `,
    },
});


text: Welcome in grobid-smecta.


text:
>>> s = 'How might I make alternating caps in python?'
>>> ''.join([l.upper() if i % 2 != 0 else l for i, l in enumerate(s)])
'HOw mIgHt I mAkE AlTeRnAtInG CaPs iN PyThOn?'


text:
<?php

namespace Order\Service;

use Foundation\Crud\AbstractCrudService as CrudService;
use Foundation\Entity\EntityInterface;

class RoleService extends CrudService
{
    /**
     * @param array $data
     * @return \Foundation\Entity\EntityInterface
     * @throws \Foundation\Exception\NotFoundException
     */
    public function hydrate(array $data)
    {
        $object = parent::hydrate($data);

        if ($parentId = $data['parentId']) {
            $object->setParent($this->fetch($parentId));
        }

        return $object;
    }

    public function extract(EntityInterface $object)
    {
        $data = parent::extract($object);
        unset($data['parent']);
        $data['parentId'] = $object->getParent()->getId();

        return $data;
    }

}