text:
package org.apache.ignite.spi.discovery.tcp.ipfinder.vm;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Objects;
import java.util.Set;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

/**  */
public class TcpDiscoveryVmIpFinderDnsResolveTest extends GridCommonAbstractTest {

    /** Fqnd */
    private static String FQDN = "test.domain";

    /** Multiple Fqnd */
    private static String MULTI_FQDN = "multi.test.domain";

    /** Incorrect fqnd */
    private static String BAD_FQDN = "bad.domain";

    /** Incorrect ip */
    private static String BAD_IP = "555.0.0.0";

    /** Incorrect ipv6 */
    private static String BAD_IP_6 = "[oo00::0000:ooo:ooo:ooo]";

    /** local host address */
    private static String LOCAL_HOST = "localhost";

    /** Ip1 */
    private static String IP1 = "10.0.0.1";

    /** Ip2 */
    private static String IP2 = "10.0.0.2";

    /** DNS service */
    private static TwoIpRoundRobinDnsService hostNameSvc;

    /** original DNS */
    private static Object nameSvc;

    /**
     */
    @BeforeClass
    public static void before() throws Exception {
        hostNameSvc = new TwoIpRoundRobinDnsService(FQDN, MULTI_FQDN, IP1, IP2);

        INameService.install(hostNameSvc);
    }

    /**
     */
    @AfterClass
    public static void cleanup() throws Exception {
        INameService.uninstall();
    }

    /**
     * Current test checks that in case if DNS will not be able to resolve hostname,
     * then no exceptions were thrown from getRegisteredAddresses method.
     */
    @Test
    public void testFqdnResolveWhenDnsCantResolveHostName() {
        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();

        Set<String> addrs = new HashSet<>();

        addrs.add(BAD_FQDN);
        addrs.add(BAD_FQDN + ":47500");
        addrs.add(BAD_FQDN + ":47501..47502");

        addrs.add(BAD_IP);
        addrs.add(BAD_IP + ":47500");
        addrs.add(BAD_IP + ":47501..47502");

        addrs.add(BAD_IP_6);
        addrs.add(BAD_IP_6 + ":47500");
        addrs.add(BAD_IP_6 + ":47501..47502");

        ipFinder.setAddresses(addrs);

        Collection<InetSocketAddress> resolved = ipFinder.getRegisteredAddresses();

        assertNotNull(resolved);

        //for every host 4 entries (for 0, 47500, 47501, 47502)
        assertEquals(resolved.size(), 12);

        Iterator<InetSocketAddress> it = resolved.iterator();

        System.out.println("Resolved addresses " + resolved);

        while (it.hasNext()) {
            InetSocketAddress addr = it.next();

            assertNull(addr.getAddress());
        }
    }

    /**
     * Current test checks that TcpDiscoveryVmIpFinder will return new IP if DNS service will change the FQDN resolution.
     *
     * @param fqdn - A fully qualified domain name.
     * @param expectedCount - how many addresses should be resolved.
     * @throws Exception on error.
     */
    public void fqdnResolveAfterDnsHostChange(String fqdn, int expectedCount) throws Exception {
        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();

        Set<String> addrs = new HashSet<>();

        addrs.add(fqdn);

        ipFinder.setAddresses(addrs);

        Collection<InetSocketAddress> resolved1 = ipFinder.getRegisteredAddresses();

        assertEquals(expectedCount, resolved1.size());

        InetSocketAddress addr1 = resolved1.iterator().next();

        //because of JAVA networkaddress cache ttl can be turn on.
        //will be great to change current test and run it in separate JVM.
        //and set there -Dsun.net.inetaddr.ttl=0 -Dsun.net.inetaddr.negative.ttl=0
        Thread.sleep(50_000);

        Collection<InetSocketAddress> resolved2 = ipFinder.getRegisteredAddresses();

        assertEquals(expectedCount, resolved2.size());

        InetSocketAddress addr2 = resolved2.iterator().next();

        log.info("Adrrs1 - " + addr1.getAddress() + " Adrrs2 - " + addr2.getAddress());

        assertFalse("Addresses weren't resolved second time. Probably DNS cache has TTL more then 1 min, if yes " +
                "then please mute this test. Adrrs1 - " + addr1.getAddress() + " Adrrs2 - " + addr2.getAddress(),
            addr1.equals(addr2));
    }

    /**
     * Current test checks that TcpDiscoveryVmIpFinder will return new IP if DNS service will change the FQDN resolution.
     * There are no ports set, only hostname.
     *
     * @throws Exception if failed.
     */
    @Test
    public void testFqdnResolveAfterDnsHostChange() throws Exception {
        fqdnResolveAfterDnsHostChange(FQDN, 1);
    }

    /**
     * Current test checks that TcpDiscoveryVmIpFinder will return new IP if DNS service will change the FQDN resolution.
     * Port will be used.
     *
     * @throws Exception if failed.
     */
    @Test
    public void testFqdnWithPortResolveAfterDnsHostChange() throws Exception {
        fqdnResolveAfterDnsHostChange(FQDN + ":47500", 1);
    }

    /**
     * Current test checks that TcpDiscoveryVmIpFinder will return new IP if DNS service will change the FQDN resolution.
     * Port range will be used,
     *
     * @throws Exception if failed.
     */
    @Test
    public void testFqdnWithPortRangeResolveAfterDnsHostChange() throws Exception {
        fqdnResolveAfterDnsHostChange(FQDN + ":47500..47501", 2);
    }

    /**
     * Current test checks that in case of roundrobin DNS server that returns two IP if we set the FQDN name with port range
     * then every pair of host/port addresses will have the same IP (not different).
     */
    @Test
    public void testFqdnWithPortRangeResolveWithTwoIpRoundRobinDns() {
        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();

        Set<String> addrs = new HashSet<>();

        addrs.add(FQDN + ":47500..47509");

        ipFinder.setAddresses(addrs);

        Collection<InetSocketAddress> resolved = ipFinder.getRegisteredAddresses();

        log.info("Resolved addresses are " + resolved);

        assertTrue(resolved.size() == 10);

        Iterator<InetSocketAddress> it = resolved.iterator();

        InetSocketAddress first = it.next();

        String ip = first.getAddress().getHostAddress();

        String host = first.getHostName();

        while (it.hasNext()) {
            InetSocketAddress curr = it.next();

            assertTrue("IP address isn't the same. ip - " + curr.getAddress().getHostAddress() + " expected " + ip,
                ip.equals(curr.getAddress().getHostAddress()));

            assertTrue("FQDN isn't the same. cur - " + curr.getHostName() + " expected " + host,
                host.equals(curr.getHostName()));
        }
    }

    /**
     * Current test checks that in case if TcpDiscoveryVmIpFinder has FQDN name and additional one "registeredAddress"
     * then both of them can be resolved.
     *
     * @param fgdn - A fully qualified domain name.
     * @param expectedSize - how many addresses should be resolved.
     * @param expectedDomainName - expected FQDN name.
     */
    public void fqdnResolveWithRegisteredAddrs(String fgdn, int expectedSize, String expectedDomainName) {
        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();

        Set<String> addrs = new HashSet<>();

        addrs.add(fgdn);

        ipFinder.setAddresses(addrs);

        Collection<InetSocketAddress> registerAddrs = new HashSet<>();

        registerAddrs.add(new InetSocketAddress(LOCAL_HOST, 0));

        ipFinder.registerAddresses(registerAddrs);

        Collection<InetSocketAddress> resolved = ipFinder.getRegisteredAddresses();

        assertTrue(resolved.size() == expectedSize);

        log.info("Resolved addresses are " + resolved);

        Iterator<InetSocketAddress> it = resolved.iterator();

        while (it.hasNext()) {
            InetSocketAddress addr = it.next();

            assertNotNull(addr);

            assertTrue(expectedDomainName.equals(addr.getHostName()) || LOCAL_HOST.equals(addr.getHostName()));
        }
    }

    /**
     * Current test checks that in case if TcpDiscoveryVmIpFinder has FQDN name and additional one "registeredAddress"
     * then both of them can be resolved. There are no ports will be used, only hostname.
     *
     * @throws Exception if failed.
     */
    @Test
    public void testFqdnResolveWithRegisteredAddrs() throws Exception {
        fqdnResolveWithRegisteredAddrs(FQDN, 2, FQDN);
    }

    /**
     * Current test checks that in case if TcpDiscoveryVmIpFinder has MULTI_FQDN (resolved to two ip) name
     * and additional one "registeredAddress" then both of them can be resolved. There are no ports will be used, only hostname.
     *
     * @throws Exception if failed.
     */
    @Test
    public void testMultiFqdnResolveWithRegisteredAddrs() throws Exception {
        fqdnResolveWithRegisteredAddrs(MULTI_FQDN, 3, MULTI_FQDN);
    }

    /**
     * Current test checks that in case if TcpDiscoveryVmIpFinder has FQDN name and additional one "registeredAddress"
     * then both of them can be resolved. Port will be used.
     *
     * @throws Exception if failed.
     */
    @Test
    public void testFqdnWithPortResolveWithRegisteredAddrs() throws Exception {
        fqdnResolveWithRegisteredAddrs(FQDN + ":47500", 2, FQDN);
    }

    /**
     * Current test checks that in case if TcpDiscoveryVmIpFinder has MULTI_FQDN (resolved to two ip) name
     * and additional one "registeredAddress" then both of them can be resolved. Port will be used.
     *
     * @throws Exception if failed.
     */
    @Test
    public void testMultiFqdnWithPortResolveWithRegisteredAddrs() throws Exception {
        fqdnResolveWithRegisteredAddrs(MULTI_FQDN + ":47500", 3, MULTI_FQDN);
    }

    /**
     * Current test checks that in case if TcpDiscoveryVmIpFinder has FQDN name and additional one "registeredAddress"
     * then both of them can be resolved. Port range will be used.
     *
     * @throws Exception if failed.
     */
    @Test
    public void testFqdnWithPortRangeResolveWithRegisteredAddrs() throws Exception {
        fqdnResolveWithRegisteredAddrs(FQDN + ":47500..47501", 3, FQDN);
    }

    /**
     * Current test checks that in case if TcpDiscoveryVmIpFinder has MULTI_FQDN (resolved to two ip) name
     * and additional one "registeredAddress" then both of them can be resolved. Port range will be used.
     *
     * @throws Exception if failed.
     */
    @Test
    public void testMultiFqdnWithPortRangeResolveWithRegisteredAddrs() throws Exception {
        fqdnResolveWithRegisteredAddrs(MULTI_FQDN + ":47500..47501", 5, MULTI_FQDN);
    }

    /**
     * Current test checks that in case if FQDN name with port range can be resolved in several IP addresses at the same time
     * then should be returned set with full ip/port sets for all ip addresses that can be resolved.
     */
    @Test
    public void testMultiFqdnResolveWithPortRange() {
        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();

        Collection<String> addrs = new ArrayList<>();

        addrs.add(MULTI_FQDN + ":47500..47509");

        ipFinder.setAddresses(addrs);

        Collection<InetSocketAddress> resolved = ipFinder.getRegisteredAddresses();

        assertTrue(resolved.size() == 20);

        log.info("Resolved addresses are " + resolved);

        Iterator<InetSocketAddress> it = resolved.iterator();

        int cntIp1 = 0;

        int cntIp2 = 0;

        while (it.hasNext()) {
            InetSocketAddress curr = it.next();

            assertTrue(MULTI_FQDN.equals(curr.getHostName()));

            if (IP1.equals(curr.getAddress().getHostAddress()))
                cntIp1++;
            if (IP2.equals(curr.getAddress().getHostAddress()))
                cntIp2++;
        }

        assertTrue(cntIp1 == 10);

        assertTrue(cntIp2 == 10);
    }

    /**
     * Current test checks that if FQDN name can be resolved in several IP addresses at the same time
     * then all of them should be returned.
     *
     * @param fqdn - A fully qualified domain name.
     */
    public void multiFqdnResolve(String fqdn) {
        TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();

        Collection<String> addrs = new ArrayList<>();

        addrs.add(fqdn);

        ipFinder.setAddresses(addrs);

        Collection<InetSocketAddress> resolved = ipFinder.getRegisteredAddresses();

        assertTrue(resolved.size() == 2);

        log.info("Resolved addresses are " + resolved);

        Iterator<InetSocketAddress> it = resolved.iterator();

        InetSocketAddress addr1 = it.next();

        InetSocketAddress addr2 = it.next();

        assertNotNull(addr1);

        assertNotNull(addr2);

        assertTrue(MULTI_FQDN.equals(addr1.getHostName()) && MULTI_FQDN.equals(addr2.getHostName()));

        assertFalse("Addresses are the same. Adrrs1 - " + addr1.getAddress() +
            " Adrrs2 - " + addr2.getAddress(), addr1.equals(addr2));
    }

    /**
     * Current test checks that if FQDN name can be resolved in several IP addresses at the same time
     * then all of them should be returned. There are no ports, only host name
     */
    @Test
    public void testMultiFqdnResolve() {
        multiFqdnResolve(MULTI_FQDN);
    }

    /**
     * Current test checks that if FQDN name can be resolved in several IP addresses at the same time
     * then all of them should be returned. Only one port will be set.
     */
    @Test
    public void testMultiFqdnWithPortResolve() {
        multiFqdnResolve(MULTI_FQDN + ":47500");
    }

    /**
     * Custom hostname service.
     */
    @SuppressWarnings("restriction")
    public static class TwoIpRoundRobinDnsService implements INameService {
        /** ip1 */
        private final String ip1;

        /** ip2 */
        private final String ip2;

        /** fqdn */
        private final String fqdn;

        /** multiple fqdn */
        private final String multipleFqdn;

        /** change flag */
        private boolean needReturnIp1 = false;

        /** */
        public TwoIpRoundRobinDnsService(String fqdn, String multipleFqdn, String ip1, String ip2) {
            this.multipleFqdn = multipleFqdn;
            this.ip1 = ip1;
            this.ip2 = ip2;
            this.fqdn = fqdn;
        }

        /** {@inheritDoc} */
        @Override public InetAddress[] lookupAllHostAddr(String paramStr) throws UnknownHostException {
            if (fqdn.equals(paramStr)) {
                String ip = needReturnIp1 ? ip1 : ip2;

                needReturnIp1 = !needReturnIp1;

                final byte[] arrOfByte = sun.net.util.IPAddressUtil.textToNumericFormatV4(ip);

                final InetAddress addr = InetAddress.getByAddress(paramStr, arrOfByte);

                return new InetAddress[] {addr};
            }
            else if (multipleFqdn.equals(paramStr)) {
                final byte[] arrOfByte1 = sun.net.util.IPAddressUtil.textToNumericFormatV4(ip1);

                final byte[] arrOfByte2 = sun.net.util.IPAddressUtil.textToNumericFormatV4(ip2);

                final InetAddress addr1 = InetAddress.getByAddress(paramStr, arrOfByte1);

                final InetAddress addr2 = InetAddress.getByAddress(paramStr, arrOfByte2);

                return new InetAddress[] {addr1, addr2};
            }
            else
                throw new UnknownHostException();
        }

        /** {@inheritDoc} */
        @Override public String getHostByAddr(byte[] paramArrOfByte) throws UnknownHostException {
            throw new UnknownHostException();
        }

        /** {@inheritDoc} */
        @Override public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;
            TwoIpRoundRobinDnsService svc = (TwoIpRoundRobinDnsService)o;
            return needReturnIp1 == svc.needReturnIp1 &&
                Objects.equals(ip1, svc.ip1) &&
                Objects.equals(ip2, svc.ip2) &&
                Objects.equals(fqdn, svc.fqdn) &&
                Objects.equals(multipleFqdn, svc.multipleFqdn);
        }

        /** {@inheritDoc} */
        @Override public int hashCode() {

            return Objects.hash(ip1, ip2, fqdn, multipleFqdn, needReturnIp1);
        }
    }

    /** */
    public interface INameService extends InvocationHandler {
        /** */
        static void install(
            INameService dns
        ) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException, ClassNotFoundException {
            final Class<?> inetAddrCls = InetAddress.class;

            Object neu;

            Field nameSvcField;

            try {
                //JAVA 9+ class
                final Class<?> iface = Class.forName("java.net.InetAddress$NameService");

                nameSvcField = inetAddrCls.getDeclaredField("nameService");

                neu = Proxy.newProxyInstance(iface.getClassLoader(), new Class<?>[] {iface}, dns);
            }
            catch (final ClassNotFoundException | NoSuchFieldException e) {
                //JAVA <8 class
                nameSvcField = inetAddrCls.getDeclaredField("nameServices");

                final Class<?> iface = Class.forName("sun.net.spi.nameservice.NameService");

                neu = Collections.singletonList(Proxy.newProxyInstance(iface.getClassLoader(), new Class<?>[] {iface}, dns));
            }

            nameSvcField.setAccessible(true);

            nameSvc = nameSvcField.get(inetAddrCls);

            nameSvcField.set(inetAddrCls, neu);
        }

        /** */
        static void uninstall() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
            final Class<?> inetAddrCls = InetAddress.class;

            Field nameSvcField;

            try {
                //JAVA 9+ class
                Class.forName("java.net.InetAddress$NameService");

                nameSvcField = inetAddrCls.getDeclaredField("nameService");
            }
            catch (final ClassNotFoundException | NoSuchFieldException e) {
                //JAVA <8 class
                nameSvcField = inetAddrCls.getDeclaredField("nameServices");
            }

            nameSvcField.setAccessible(true);

            nameSvcField.set(inetAddrCls, nameSvc);
        }

        /**
         * Lookup a host mapping by name. Retrieve the IP addresses associated with a host
         *
         * @param host the specified hostname
         * @return array of IP addresses for the requested host
         * @throws UnknownHostException if no IP address for the {@code host} could be found
         */
        InetAddress[] lookupAllHostAddr(final String host) throws UnknownHostException;

        /**
         * Lookup the host corresponding to the IP address provided
         *
         * @param addr byte array representing an IP address
         * @return {@code String} representing the host name mapping
         * @throws UnknownHostException if no host found for the specified IP address
         */
        String getHostByAddr(final byte[] addr) throws UnknownHostException;

        /** */
        @Override default Object invoke(final Object proxy, final Method method,
            final Object[] args) throws Throwable {
            switch (method.getName()) {
                case "lookupAllHostAddr":
                    return lookupAllHostAddr((String)args[0]);
                case "getHostByAddr":
                    return getHostByAddr((byte[])args[0]);
                default:
                    final StringBuilder o = new StringBuilder();

                    o.append(method.getReturnType().getCanonicalName() + " " + method.getName() + "(");

                    final Class<?>[] ps = method.getParameterTypes();

                    for (int i = 0; i < ps.length; ++i) {
                        if (i > 0)
                            o.append(", ");

                        o.append(ps[i].getCanonicalName()).append(" p").append(i);
                    }

                    o.append(")");

                    throw new UnsupportedOperationException(o.toString());
            }
        }
    }
}


text:
package eu.larkc.RDFPig.pig;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.pig.ExecType;
import org.apache.pig.PigServer;
import org.apache.pig.backend.executionengine.ExecException;
import org.apache.pig.backend.executionengine.ExecJob;
import org.apache.pig.tools.pigstats.OutputStats;
import org.openrdf.query.QueryEvaluationException;
import org.openrdf.query.algebra.QueryRoot;
import org.openrdf.query.algebra.TupleExpr;
import org.openrdf.query.parser.ParsedQuery;
import org.openrdf.query.parser.sparql.SPARQLParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import eu.larkc.RDFPig.Configuration;
import eu.larkc.RDFPig.costCalculators.JoinTypeSelector;

/**
 * Notes: The PigServer can actually directly read a file using
 * PigServer.openIterator
 *
 *
 */
public class Executor {

	protected static Logger logger = LoggerFactory.getLogger(Executor.class);

	private StatisticsCollector stats;

	Path outputDir = null;
	Path inputDir = null;
	JoinTypeSelector joinTypeSelector = new JoinTypeSelector();

	/* Abstract the class with a new object */
	public Cache cache = new Cache();

	public class Cache {

		private Map<TupleExpr, List<TupleSetMetadata>> storedExpressions = new TreeMap<TupleExpr, List<TupleSetMetadata>>(
				new TupleExprComparator());

		public TupleSetMetadata getFromCache(TupleExpr expr) {
			List<TupleSetMetadata> values = storedExpressions.get(expr);
			if (values == null || values.isEmpty())
				return null;
			TupleSetMetadata max = values.get(0);
			for (TupleSetMetadata t : values)
				if (t.sampleRate > max.sampleRate)
					max = t;
			return max;
		}

		public TupleSetMetadata getFromCache(TupleExpr expr, double sample) {
			List<TupleSetMetadata> values = storedExpressions.get(expr);
			if (values != null) {
				for (TupleSetMetadata value : values) {
					if (value.sampleRate >= sample) {
						return value;
					}
				}
			}
			return null;
		}

		public TupleSetMetadata getFromCacheWithSamplingLessThan(
				TupleExpr expr, double sample) {
			List<TupleSetMetadata> values = storedExpressions.get(expr);
			if (values != null) {
				for (TupleSetMetadata value : values) {
					if (value.sampleRate < sample) {
						return value;
					}
				}
			}
			return null;
		}

		public void putInCache(TupleExpr expr, TupleSetMetadata meta) {
			List<TupleSetMetadata> list = storedExpressions.get(expr);
			if (list == null) {
				list = new ArrayList<TupleSetMetadata>();
				storedExpressions.put(expr, list);
			}
			list.add(meta);
		}
	}

	public Executor(String inDir, String outDir) throws IOException {
		inputDir = new Path(inDir);
		outputDir = new Path(outDir);

		// Clean the output directory
		FileSystem fs = FileSystem
				.get(new org.apache.hadoop.conf.Configuration());
		fs.delete(outputDir, true);
		this.stats = new StatisticsCollector();
	}

	/********* PUBLIC METHOD ***********/
	public Map<TupleExpr, TupleSetMetadata> execute(
			Collection<? extends TupleExpr> input, double sampleRate)
			throws IOException, QueryEvaluationException {
		Map<TupleExpr, TupleSetMetadata> output = new HashMap<TupleExpr, TupleSetMetadata>();

		PigQueriesGenerator gen = new PigQueriesGenerator(this,
				joinTypeSelector);
		List<String> pigScripts = new LinkedList<String>();
		gen.setup(pigScripts, inputDir.toString());

		Map<TupleExpr, TupleSetMetadata> toExecuteExpressions = new HashMap<TupleExpr, TupleSetMetadata>();
		for (TupleExpr expr : input) {
			TupleSetMetadata info = cache.getFromCache(expr, sampleRate);
			if (info != null) {
				logger.info(expr + " found in cache");
				output.put(expr, info);
			} else {
				info = gen.evaluate(expr, cache, outputDir, pigScripts,
						sampleRate);
				toExecuteExpressions.put(expr, info);
			}
		}

		// If pigScripts is greater than 0 than need to execute the scripts
		if (pigScripts.size() > 0) {
			logger.info("Running using " + pigScripts.size()
					+ " pig statements");
			printScripts(pigScripts);

			List<ExecJob> jobs = executePigScripts(pigScripts);

			long startTime = System.currentTimeMillis();
			// Update the size of the expressions
			for (Map.Entry<TupleExpr, TupleSetMetadata> entry : toExecuteExpressions
					.entrySet()) {
				if (sampleRate == 1.0) {
					// Get the size of the expression
					for (ExecJob job : jobs) {
						for (OutputStats stats : job.getStatistics()
								.getOutputStats()) {
							if (stats.getAlias().equals(entry.getValue().name)) {
								entry.getValue().size = stats
										.getNumberRecords();
							}
						}
					}
					output.put(entry.getKey(), entry.getValue());
				} else {
					long count = 0;

					FileSystem fs = FileSystem
							.get(new org.apache.hadoop.conf.Configuration());
					FileStatus[] files = fs
							.listStatus(entry.getValue().location);
					int n = 0;
					long max = 0;
					for (FileStatus file : files) {
						if (!file.getPath().getName().startsWith("_")) {
							FSDataInputStream in = fs.open(file.getPath());
							BufferedReader reader = new BufferedReader(
									new InputStreamReader(in));
							String line;
							while ((line = reader.readLine()) != null) {
								long value = Long.valueOf(line);
								n++;
								count += value;
								if (value > max) {
									max = value;
								}
							}
							reader.close();
						}
					}

					// Skewness index is the difference between the max and the
					// average
					if (n > 0) {
						entry.getValue().skewness = max - (count / n);
					}

					entry.getValue().size = count;
				}

				if (!entry.getKey().getClass().equals(QueryRoot.class)) {
					cache.putInCache(entry.getKey(), entry.getValue());
				}
			}

			stats.processStatistics(jobs, toExecuteExpressions,
					System.currentTimeMillis() - startTime, startTime);
		}
		return output;
	}

	private void printScripts(List<String> scripts) {
		for (String line : scripts) {
			logger.info(line);
		}
	}

	PigServer pigServer;

	private List<ExecJob> executePigScripts(List<String> queries)
			throws ExecException, IOException {
		String pigMode = Configuration.getInstance().getProperty(
				Configuration.PIG_MODE);

		pigServer = new PigServer(
				pigMode.equalsIgnoreCase("local") ? ExecType.LOCAL
						: ExecType.MAPREDUCE);

		if (!Configuration.getInstance().getPropertyBoolean(
				Configuration.USE_LZO)) {
			pigServer.getPigContext().getProperties()
					.setProperty("pig.tmpfilecompression", "false");
		} else {
			pigServer.getPigContext().getProperties()
					.setProperty("pig.tmpfilecompression", "true");
			pigServer.getPigContext().getProperties()
					.setProperty("pig.tmpfilecompression.codec", "lzo");
		}
		pigServer.setBatchOn();
		pigServer.registerJar("RDFPig.jar");

		// Eliminate duplicates, pig does not like them.
		LinkedHashSet<String> queriesNoDuplicates = new LinkedHashSet<String>(
				queries);

		for (String line : queriesNoDuplicates) {
			pigServer.registerQuery(line);
		}
		return pigServer.executeBatch();
	}

	/** Method to test the bindings manager **/
	private void test(String[] args) throws Exception {
		FileReader fr = new FileReader(args[0]);
		BufferedReader br = new BufferedReader(fr);
		String line;
		String query = "";
		while ((line = br.readLine()) != null)
			query += line + "\n";
		br.close();
		fr.close();
		SPARQLParser parser = new SPARQLParser();
		ParsedQuery q = parser.parseQuery(query, "http://www.vu.nl");
		TupleExpr tupleExpr = q.getTupleExpr();
		QueryRoot root = new QueryRoot();
		root.setArg(tupleExpr);
		logger.info(tupleExpr.toString());
		List<TupleExpr> set = new ArrayList<TupleExpr>();
		set.add(root);
		execute(set, 1.0);
	}

	public static void main(String[] args) throws Exception {
		if (args.length != 3) {
			System.err.println("Args: [query file] [input dir] [output dir]");
		}

		new Executor(args[1], args[2]).test(args);
	}
}

redpajama_set_name: RedPajamaGithub


text:
package org.apache.poi.hssf.record.chart;

import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.hssf.record.StandardRecord;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.LittleEndianOutput;

/**
 * STARTOBJECT - Chart Future Record Type Start Object (0x0854)
 */
public final class ChartStartObjectRecord extends StandardRecord {
	public static final short sid = 0x0854;

	private short rt;
	private short grbitFrt;
	private short iObjectKind;
	private short iObjectContext;
	private short iObjectInstance1;
	private short iObjectInstance2;

	public ChartStartObjectRecord(RecordInputStream in) {
		rt = in.readShort();
		grbitFrt = in.readShort();
		iObjectKind = in.readShort();
		iObjectContext = in.readShort();
		iObjectInstance1 = in.readShort();
		iObjectInstance2 = in.readShort();
	}

	@Override
	protected int getDataSize() {
		return 2 + 2 + 2 + 2 + 2 + 2;
	}

	@Override
	public short getSid() {
		return sid;
	}

	@Override
	public void serialize(LittleEndianOutput out) {
		out.writeShort(rt);
		out.writeShort(grbitFrt);
		out.writeShort(iObjectKind);
		out.writeShort(iObjectContext);
		out.writeShort(iObjectInstance1);
		out.writeShort(iObjectInstance2);
	}

	public String toString() {

		StringBuffer buffer = new StringBuffer();

		buffer.append("[STARTOBJECT]\n");
		buffer.append("    .rt              =").append(HexDump.shortToHex(rt)).append('\n');
		buffer.append("    .grbitFrt        =").append(HexDump.shortToHex(grbitFrt)).append('\n');
		buffer.append("    .iObjectKind     =").append(HexDump.shortToHex(iObjectKind)).append('\n');
		buffer.append("    .iObjectContext  =").append(HexDump.shortToHex(iObjectContext)).append('\n');
		buffer.append("    .iObjectInstance1=").append(HexDump.shortToHex(iObjectInstance1)).append('\n');
		buffer.append("    .iObjectInstance2=").append(HexDump.shortToHex(iObjectInstance2)).append('\n');
		buffer.append("[/STARTOBJECT]\n");
		return buffer.toString();
	}
}


text:
#include <vector>
#include <shogun/lib/common.h>

#ifndef BLOCK_H__
#define BLOCK_H__

namespace shogun
{

class CFeatures;

namespace internal
{

/**
 * @brief Class that holds a block feature. A block feature is a shallow
 * copy of an underlying (non-owning) feature object. In its constructor,
 * it increases the refcount of the original object (since it has to be
 * alive as long as the block is alive) and it decreases the refcount of
 * the original object in destructor.
 */
class Block
{
private:
	/**
	 * Constructor to create a block object. It makes a shallow copy of
	 * the underlying feature object, and adds subset according to the
	 * block begin index and the blocksize.
	 *
	 * Increases the reference count of the underlying feature object.
	 *
	 * @param feats The underlying feature object.
	 * @param index The index of the block.
	 * @param size The size of the block (number of feature vectors).
	 */
	Block(CFeatures* feats, index_t index, index_t size);
public:
	/**
	 * Copy constructor. Every time a block is copied or assigned, the underlying
	 * feature object is SG_REF'd.
	 */
	Block(const Block& other);

	/**
	 * Assignment operator. Every time a block is copied or assigned, the underlying
	 * feature object is SG_REF'd.
	 */
	Block& operator=(const Block& other);

	/**
	 * Destructor. Decreases the reference count of the underlying feature object.
	 */
	~Block();

	/**
	 * Method that creates a number of block objects. See @Block for details.
	 *
	 * @param feats The underlying feature object.
	 * @param num_blocks The number of blocks to be formed.
	 * @param size The size of the block (number of feature vectors).
	 */
	static std::vector<Block> create_blocks(CFeatures* feats, index_t num_blocks, index_t size);

	/**
	 * Operator overloading for getting the block object as a naked ptr (non-const, unsafe).
	 */
	inline operator CFeatures*()
	{
		return m_block;
	}

private:
	/** Shallow copy representing the block */
	CFeatures* m_block;

	/** Underlying feature object */
	CFeatures* m_feats;
};

}

}
#endif // BLOCK_H__


text:
<?php

namespace Nicklas\Comment\HTMLForm\Admin;

use \Anax\HTMLForm\FormModel;
use \Anax\DI\DIInterface;
use \Nicklas\Comment\Modules\User;

/**
 * Example of FormModel implementation.
 */
class CreateUserForm2 extends FormModel
{
    /**
     * Constructor injects with DI container.
     *
     * @param Anax\DI\DIInterface $di a service container
     */
    public function __construct(DIInterface $di)
    {
        parent::__construct($di);
        $this->form->create(
            [
                "id" => __CLASS__,
                "legend" => "Create user",
                "fieldset" => true
            ],
            [
                "name" => [
                    "type"        => "text",
                    "validation" => ["not_empty"]
                ],

                "email" => [
                    "type"        => "text",
                ],

                "password" => [
                    "type"        => "password",
                    "validation" => ["not_empty"]
                ],

                "password-again" => [
                    "type"        => "password",
                    "validation" => [
                        "match" => "password"
                    ],
                ],

                "select" => [
                    "type"        => "select",
                    "label"       => "Select authority",
                    "options"     => ["admin" => "admin", "user" => "user"],
                ],

                "submit" => [
                    "type" => "submit",
                    "value" => "Skapa user",
                    "callback" => [$this, "callbackSubmit"]
                ],
            ]
        );
    }

    /**
     * Callback for submit-button which should return true if it could
     * carry out its work and false if something failed.
     *
     * @return boolean true if okey, false if something went wrong.
     */
    public function callbackSubmit()
    {
        // Get values from the submitted form
        $name       = $this->form->value("name");
        $email       = $this->form->value("email");
        $password      = $this->form->value("password");
        $passwordAgain = $this->form->value("password-again");

        // Check password matches
        if ($password !== $passwordAgain) {
            $this->form->rememberValues();
            $this->form->addOutput("Password did not match.");
            return false;
        }

        if (strpos($name, '%') !== false) {
            $this->form->addOutput("% is not allowed");
            return false;
        }

         $user = new User();
         $user->setDb($this->di->get("db"));

        if ($user->userExists($name)) {
             $this->form->addOutput("User already exists");
             return false;
        }

          $user->name = $name;
          $user->email = $email;
          $user->authority = $this->form->value("select");
          $user->setPassword($password);
          $user->save();

          $this->form->addOutput("You added the user");
          return true;
    }
}


text:
package app

import (
	"time"

	. "github.com/AnnatarHe/exam-online-be/app/models"

	"fmt"

	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/postgres"
	"github.com/revel/revel"
	"github.com/revel/revel/cache"
	"gopkg.in/redis.v5"
)

// Gorm: the database instance
var Gorm *gorm.DB

// Redis: the redis instance
var Redis *redis.Client

// init the database
func initDatabase() {
	var err error

	config := revel.Config

	username, _ := config.String("db.username")
	pwd, _ := config.String("db.pwd")
	dbname, _ := config.String("db.dbname")
	connstring := fmt.Sprintf("host=db user=%s password=%s dbname=%s sslmode=disable", username, pwd, dbname)

	Gorm, err = gorm.Open("postgres", connstring)
	// defer Gorm.Close()
	Gorm.LogMode(true)

	if err != nil {
		revel.INFO.Println("DB error: ", err)
	}

	if err = Gorm.AutoMigrate(
		&Course{}, &User{}, &News{}, &Paper{}, &Question{}, &StudentPaper{},
	).Error; err != nil {
		revel.INFO.Printf("No error should happen when create table, but got %+v", err)
	}

	revel.INFO.Println("DB Connected")
}

// init redis server
func initRedis() {
	// Redis = redis.NewClient(&redis.Options{
	// 	Addr:     "redis:6379",
	// 	Password: "",
	// 	DB:       0,
	// })

	// pong, err := Redis.Ping().Result()
	// revel.INFO.Println("redis: ", pong, err)
	cache.Instance = cache.NewRedisCache("redis:6379", "", time.Hour*24)
}

// InitDB: 初始化数据库
func InitDB() {
	initDatabase()
	initRedis()
}

func init() {
	// Filters is the default set of global filters.
	revel.Filters = []revel.Filter{
		revel.PanicFilter,             // Recover from panics and display an error page instead.
		revel.RouterFilter,            // Use the routing table to select the right Action
		revel.FilterConfiguringFilter, // A hook for adding or removing per-Action filters.
		revel.ParamsFilter,            // Parse parameters into Controller.Params.
		revel.SessionFilter,           // Restore and write the session cookie.
		revel.FlashFilter,             // Restore and write the flash cookie.
		revel.ValidationFilter,        // Restore kept validation errors and save new ones from cookie.
		revel.I18nFilter,              // Resolve the requested language
		HeaderFilter,                  // Add some security based headers
		revel.InterceptorFilter,       // Run interceptors around the action.
		revel.CompressFilter,          // Compress the result.
		revel.ActionInvoker,           // Invoke the action.
	}

	// register startup functions with OnAppStart
	// ( order dependent )
	revel.OnAppStart(InitDB)
	// revel.OnAppStart(FillCache)
}

// TODO turn this into revel.HeaderFilter
// should probably also have a filter for CSRF
// not sure if it can go in the same filter or not
var HeaderFilter = func(c *revel.Controller, fc []revel.Filter) {
	// Add some common security headers
	c.Response.Out.Header().Add("X-Frame-Options", "SAMEORIGIN")
	c.Response.Out.Header().Add("X-XSS-Protection", "1; mode=block")
	c.Response.Out.Header().Add("X-Content-Type-Options", "nosniff")

	fc[0](c, fc[1:]) // Execute the next filter stage.
}


text:
package com.navercorp.pinpoint.profiler.plugin;

import com.navercorp.pinpoint.bootstrap.plugin.jdbc.JdbcUrlParserV2;
import com.navercorp.pinpoint.bootstrap.plugin.uri.UriExtractorProvider;

import java.lang.instrument.ClassFileTransformer;
import java.util.List;

/**
 * @author Woonduk Kang(emeroad)
 */
public class PluginSetupResult {

    private final DefaultProfilerPluginSetupContext setupContext;
    private final ClassFileTransformerLoader transformerRegistry;

    public PluginSetupResult(DefaultProfilerPluginSetupContext setupContext, ClassFileTransformerLoader transformerRegistry) {
        this.setupContext = setupContext;
        this.transformerRegistry = transformerRegistry;
    }

    public List<JdbcUrlParserV2> getJdbcUrlParserList() {
        return this.setupContext.getJdbcUrlParserList();
    }

    public List<ClassFileTransformer> getClassTransformerList() {
        return transformerRegistry.getClassTransformerList();
    }

    public List<UriExtractorProvider> getUriExtractorProviderList() {
        return this.setupContext.getUriExtractorProviderList();
    }

}


text:
haello-Android-Application
==========================

This Android app was developed for a bachelor thesis in "Computer Science and Visual Computing" at the Technical University of Vienna by Moritz Tomasi.

This repository contains the source code for the haello Android application. It uses [**haello RESTful web service**](https://github.com/2lastview/haello-Rest-Service)
to extract text from images and translate said text into a specified language. Further it gives you
the possibility to enrich this translation with information from Wikipedia, Wiktionary and Google.

## Description

* You can choose an image from the gallery or by taking one with the camera.

* Choose a source language by tapping on FROM. If you select "Unknown" the web service will
detect the language automatically using [goslate](http://pythonhosted.org/goslate/).
By tapping on TO you can select the target language. There is also a third option for editing the image.

* After tapping on GO the extracted text and translation are shown. By pressing on a single word for
a little longer you can search for it in Wikipedia, Wiktionary or on Google.

* By tapping CORRECT AND RETRY you can correct the mistakes made by the ocr engine manually. In this
stage there is also the possibility to change the TO language.

* By swiping left, or tapping on the IMAGE tab, you can see the chosen image.

## Build

Import the root folder into your IDE (tested on Android Studio). Find the class [translate](https://github.com/2lastview/haello-Android-Application/blob/master/app/src/main/java/com/example/moritztomasi/clicklesstextenricherapplication/enrichment/Translate.java). There the
TRANSLATE_URL can be pointed to the URL where a implementation of the [haello RESTful web service](https://github.com/2lastview/haello-Rest-Service)
is deployed. Then simply build and run the project.

## Support

The application has been tested with SDK version 16 and above.

## Dependencies

* [SlidingUpPanel](https://github.com/umano/AndroidSlidingUpPanel) by umano.

* Wiktionary is not queried directly. A Wiktionary Parser written by Yves Bourques is used. Information
regarding this parser can be found on his [website](http://www.igrec.ca/projects/wiktionary-text-parser/).

## Copyright and License

Author: Moritz Tomasi (moritz.tomasi at gmail dot com)

License: [Apache 2.0 License](https://github.com/2lastview/haello-Android-Application/blob/master/LICENSE)


text:
/** @module state */ /** for typedoc */
export class Glob {
  text: string;
  glob: Array<string>;

  constructor(text: string) {
    this.text = text;
    this.glob = text.split('.');
  }

  matches(name: string) {
    let segments = name.split('.');

    // match single stars
    for (let i = 0, l = this.glob.length; i < l; i++) {
      if (this.glob[i] === '*') segments[i] = '*';
    }

    // match greedy starts
    if (this.glob[0] === '**') {
       segments = segments.slice(segments.indexOf(this.glob[1]));
       segments.unshift('**');
    }
    // match greedy ends
    if (this.glob[this.glob.length - 1] === '**') {
       segments.splice(segments.indexOf(this.glob[this.glob.length - 2]) + 1, Number.MAX_VALUE);
       segments.push('**');
    }
    if (this.glob.length != segments.length) return false;

    return segments.join('') === this.glob.join('');
  }

  static is(text: string) {
    return text.indexOf('*') > -1;
  }

  static fromString(text: string) {
    if (!this.is(text)) return null;
    return new Glob(text);
  }
}


text:
title: LIFT
date: '2020-01-10'
area: inprogress
subdomain: Hepatology
authors:
  - authorimage: /img/uploads/serp0682.jpg
    authorname: 'Marina Serper, MD, MS'
    authorrole: Principal Investigator
  - authorimage: /img/uploads/rees3825.jpg
    authorname: 'Peter Reese, MD, MSCE'
    authorrole: Investigator
summary: >-
  Conducted a home‐based, remotely monitored intervention using wearable
  accelerometer devices to promote post‐transplant physical activity
features:
  - feature: Financial Incentives
  - feature: Misfit Pedometer Integration
spotlight: ''
---


text:
using System;
using System.Collections.Generic;
using MindTouch.Xml;

namespace MindTouch.Dream.Services.PubSub {

    /// <summary>
    /// Contract for implementing an event dispatcher for the pub sub service.
    /// </summary>
    /// <remarks>
    /// The default implementation is <see cref="Dispatcher"/>.
    /// </remarks>
    public interface IPubSubDispatcher {

        //--- Properties ---

        /// <summary>
        /// The combined set of pub sub subscriptions.
        /// </summary>
        PubSubSubscriptionSet CombinedSet { get; }

        /// <summary>
        /// Retrieve a subscription set by location key.
        /// </summary>
        /// <param name="location">Location postfix of subscription set resource uri on the pub sub service.</param>
        /// <returns></returns>
        PubSubSubscriptionSet this[string location] { get; }

        //--- Methods ---

        /// <summary>
        /// Retrieve all uncombined subscription sets.
        /// </summary>
        /// <returns>Enumerable of <see cref="PubSubSubscriptionSet"/>.</returns>
        IEnumerable<PubSubSubscriptionSet> GetAllSubscriptionSets();

        /// <summary>
        /// Register a subscription set
        /// </summary>
        /// <param name="setDoc">Xml formatted subscription set.</param>
        /// <returns>Tuple of subscription set and <see langword="True"/> if the set was newly created, or <see langword="False"/> if the set existed (does not update the set).</returns>
        Tuplet<PubSubSubscriptionSet, bool> RegisterSet(XDoc setDoc);

        /// <summary>
        /// Dispatch an event against the registered subscriptions.
        /// </summary>
        /// <param name="ev">Dispatch event instance.</param>
        void Dispatch(DispatcherEvent ev);

        /// <summary>
        /// Replace an existing set.
        /// </summary>
        /// <param name="location">Set resource location uri postfix.</param>
        /// <param name="setDoc">New set document.</param>
        /// <returns>Updated set.</returns>
        PubSubSubscriptionSet ReplaceSet(string location, XDoc setDoc);

        /// <summary>
        /// Remove a set.
        /// </summary>
        /// <param name="location">Set resource location uri postfix.</param>
        /// <returns><see langword="True"/> if a set existed at the provided location.</returns>
        bool RemoveSet(string location);

        //--- Events ---

        /// <summary>
        /// Event fired anytime the combined subscription set has changed.
        /// </summary>
        event EventHandler<EventArgs> CombinedSetUpdated;
    }
}


text:
{% load static %}

<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="refresh" content="1; url={{ redirect.destination_url }}">

    <title>Redirecting...</title>

    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="{% static 'img/favicons/apple-touch-icon-144x144.png' %}">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="{% static 'img/favicons/apple-touch-icon-152x152.png' %}">
    <link rel="icon" type="image/png" sizes="32x32" href="{% static 'img/favicons/favicon-32x32.png' %}" >
    <link rel="icon" type="image/png" sizes="16x16" href="{% static 'img/favicons/favicon-16x16.png' %}" >

    <script>
      window.location.href = "{{ redirect.destination_url }}";
    </script>
</head>


text:
#ifndef SRC_COMPONENTS_INCLUDE_UTILS_MACRO_H_
#define SRC_COMPONENTS_INCLUDE_UTILS_MACRO_H_

#ifdef DEBUG
#include <assert.h>
#else  // RELEASE
#include <stdio.h>
#endif
#include "logger.h"

// A macro to set some action for variable to avoid "unused variable" warning
#define UNUSED(x) (void) x;
// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
  TypeName(const TypeName&);               \
  void operator=(const TypeName&)

// A macro to allow utils::Singleton call derivative constructor and destructor
#define FRIEND_BASE_SINGLETON_CLASS(TypeName) \
  friend class utils::Singleton<TypeName>

#define FRIEND_BASE_SINGLETON_CLASS_WITH_DELETER(TypeName, TypeDeleter) \
  friend class utils::Singleton<TypeName, TypeDeleter>

// A macro to allow utils::deleters::Deleter::~Deleter() call class destructor
#define FRIEND_DELETER_DESTRUCTOR(TypeName) \
  friend utils::deleters::Deleter<TypeName>::~Deleter()

#ifdef DEBUG
#define ASSERT(condition) \
  FLUSH_LOGGER();         \
  do {                    \
    DEINIT_LOGGER();      \
    assert(condition);    \
  } while (false)
#else  // RELEASE
#define ASSERT(condition)                                        \
  fprintf(stderr,                                                \
          "Failed condition \"" #condition "\" [%s:%d][%s]\n\n", \
          __FILE__,                                              \
          __LINE__,                                              \
          __FUNCTION__)
#endif

#define DCHECK(condition)                                                     \
  if (!(condition)) {                                                         \
    CREATE_LOGGERPTR_LOCAL(logger_, "Utils");                                 \
    LOG4CXX_FATAL(logger_,                                                    \
                  "DCHECK failed with \"" << #condition << "\" ["             \
                                          << __FUNCTION__ << "][" << __FILE__ \
                                          << ':' << __LINE__ << ']');         \
    ASSERT((condition));                                                      \
  }

/*
 * Will cauch assert on debug version,
 * Will return return_value in release build
 */
#define DCHECK_OR_RETURN(condition, return_value)                             \
  if (!(condition)) {                                                         \
    CREATE_LOGGERPTR_LOCAL(logger_, "Utils");                                 \
    LOG4CXX_FATAL(logger_,                                                    \
                  "DCHECK failed with \"" << #condition << "\" ["             \
                                          << __FUNCTION__ << "][" << __FILE__ \
                                          << ':' << __LINE__ << ']');         \
    ASSERT((condition));                                                      \
    return (return_value);                                                    \
  }
/*
 * Will cauch assert on debug version,
 * Will return return_value in release build
 */
#define DCHECK_OR_RETURN_VOID(condition)                                      \
  if (!(condition)) {                                                         \
    CREATE_LOGGERPTR_LOCAL(logger_, "Utils");                                 \
    LOG4CXX_FATAL(logger_,                                                    \
                  "DCHECK failed with \"" << #condition << "\" ["             \
                                          << __FUNCTION__ << "][" << __FILE__ \
                                          << ':' << __LINE__ << ']');         \
    ASSERT((condition));                                                      \
    return;                                                                   \
  }

#define EXPORT_FUNCTION(TypeName) extern "C" TypeName* Create();

#define EXPORT_FUNCTION_IMPL(TypeName) \
  extern "C" TypeName* Create() {      \
    return new TypeName();             \
  }

#define NOTREACHED() DCHECK(!"Unreachable code")

// Allows to perform static check that virtual function from base class is
// actually being overriden if compiler support is available
#if __cplusplus >= 201103L
#define OVERRIDE override
#define FINAL final
#else
#define OVERRIDE
#define FINAL
#endif

/*
* @brief Calculate size of na array
* @param arr  array, which size need to calculate
*/
#define ARRAYSIZE(arr) sizeof(arr) / sizeof(*arr)

#ifdef BUILD_TESTS
#define FRIEND_TEST(test_case_name, test_name) \
  friend class test_case_name##_##test_name##_Test
#else  // BUILD_TESTS
#define FRIEND_TEST(test_case_name, test_name)
#endif  // BUILD_TESTS

/*
* @brief deprecate a method declaration, a warning will be thrown by your
*        compiler if a method with this macro is used
*/
#if __cplusplus > 201103L
#define DEPRECATED [[deprecated]]
#else
#ifdef __GNUC__
#define DEPRECATED __attribute__((deprecated))
#define DEPRECATED_CLASS __attribute__((deprecated))
#elif defined(_MSC_VER)
#define DEPRECATED __declspec(deprecated)
#else
#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
#define DEPRECATED
#endif
#endif

#endif  // SRC_COMPONENTS_INCLUDE_UTILS_MACRO_H_


text:
require 'log4r'

module Vagrant
  module Hosts
    autoload :Base,    'vagrant/hosts/base'
    autoload :Arch,    'vagrant/hosts/arch'
    autoload :BSD,     'vagrant/hosts/bsd'
    autoload :FreeBSD, 'vagrant/hosts/freebsd'
    autoload :Fedora,  'vagrant/hosts/fedora'
    autoload :OpenSUSE, 'vagrant/hosts/opensuse'
    autoload :Gentoo,  'vagrant/hosts/gentoo'
    autoload :Linux,   'vagrant/hosts/linux'
    autoload :Windows, 'vagrant/hosts/windows'

    # This method detects the correct host based on the `match?` methods
    # implemented in the registered hosts.
    def self.detect(registry)
      logger = Log4r::Logger.new("vagrant::hosts")

      # Sort the hosts by their precedence
      host_klasses = registry.to_hash.values
      host_klasses = host_klasses.sort_by { |a| a.precedence }.reverse
      logger.debug("Host path search classes: #{host_klasses.inspect}")

      # Test for matches and return the host class that matches
      host_klasses.each do |klass|
        if klass.match?
          logger.info("Host class: #{klass}")
          return klass
        end
      end

      # No matches found...
      return nil
    end
  end
end


text:
from ...Core.registers import Registers
from ...Core.commands import Commands
from ...Core.config import FUNCTIONS_LABEL_PREFIX
from ...Core.types import Types

from ...Deep.functions import return_function

def function(compiler, node):
    """ Компиляция функций (объявление, вызов, исполнение, возврат к месту вызова) """
    function_number = compiler.environment.start(node.name)
    finish_function = compiler.labels.create()
    function_start_place = compiler.code.get_current_place() + 4

    # При последовательном выполнении пропускаем выполнение тела функции,
    # т. к. в этом случае это лишь объвление функции, вызов будет позже
    compiler.code.add(Commands.JMP, finish_function)

    # На эту метку переходим при вызове
    compiler.code.add_label(FUNCTIONS_LABEL_PREFIX + str(function_number))

    compiler.code.add(Commands.PUSH, Registers.EBP)\
        .add(Commands.MOV, [Registers.EBP, Registers.ESP])

    # Привязываем мапу аргументов с их порядковыми номерами к метке функции
    args_map = {k: v for v, k in enumerate(reversed(node.args.elements))}
    compiler.environment.set_args(args_map)

    # Компилируем код тела функции
    node.body.compile_asm(compiler)

    return_type = compiler.environment.get_return_type(node.name)

    if not return_type:
        compiler.types.set(Types.NOTHING)
        return_function(compiler, args_map)

    compiler.code.add_label(finish_function)

    need_memory = compiler.environment.finish()
    compiler.code.allocate_stack_memory(need_memory, function_start_place)


text:
<?php

namespace Morannon\Base\Gateway;

use Morannon\Base\Response\BaseSentResponse;
use Morannon\Base\SMS\SMSInterface;

class NoopGateway extends AbstractGateway
{
    /**
     * {@inheritdoc}
     */
    public function sendSMS(SMSInterface $sms)
    {
        $id = rand();
        $sms->setMessageId(rand());

        $response = new BaseSentResponse($sms, 1);
        $response->setData(array('id' => $id));
        $response->setMessageId($id);

        return $response;
    }
}


text:
import os
import json
import config as cfg
import sqlite3 as sq
from shortyutils import GetShorty
from urllib.parse import urlparse
from collections import OrderedDict
from user_agents import parse as parse_ua
from flask import Flask, request, Response, redirect

app = Flask('get-shorty')

app.config.update(dict(
    DATABASE=os.path.join(app.root_path, cfg.DATABASE)))
sht = GetShorty(app.config['DATABASE'])

def init_db():
    """ Initialize the DB """
    with sq.connect(app.config['DATABASE']) as conn:
        cursor = conn.cursor()
        try:
            with app.open_resource('schema.sql', mode='r') as f:
                cursor.executescript(f.read())
            conn.commit()
        except sq.OperationalError:
            print("Table already created")

@app.cli.command('initdb')
def initdb_command():
    """Creates the database tables."""
    print('Initializing database.')
    init_db()

def dict_factory(cursor, row):
    """Dictionary factory, uses OrderedDict to preserve the order of the parameters"""
    d = OrderedDict()
    for idx, col in enumerate(cursor.description):
        d[col[0]] = row[idx]
    return d

def valid_url(url):
    """
    Validates that the url provided is in a valid format.

    :param url: an url
    :returns: True if it is a valid url, False otherwise
    :raises OperationalError: raises an exception if there's a problem with the DB
    """
    parsed = urlparse(url)
    if parsed.scheme and parsed.netloc:
        return True
    return False

@app.route('/api/1.0/create', methods=['POST'])
def create():
    """
    Endpoint to create a short url and optional specify some targets(mobile, tablet)

    :param url: The default url to be shorten, target=Desktop/default
    :param url-mobile: [Optional] The url to redirect if the client is a mobile device
    :param url-tablet: [Optional] The url to redirect if the client is a tablet
    :returns: JSON, params = shorten, url , mobile, tablet
    :raises OperationalError: raises an exception if there's a problem with the DB
    """
    url, mobile_url, tablet_url = None, None, None
    errors = []
    params = request.get_json(force=True)
    if 'url' in params and params['url']:
        url = params['url']
        if not valid_url(url):
            errors.append(cfg.ERROR_URL)
        # Checks if the parameter exists and if isn't empty
        if 'url-mobile' in params and params['url-mobile']:
            mobile_url = params['url-mobile']
            if not valid_url(params['url-mobile']):
                errors.append(cfg.ERROR_MOBILE)
        if 'url-tablet' in params and params['url-tablet']:
            tablet_url = params['url-tablet']
            if not valid_url(params['url-tablet']):
                errors.append(cfg.ERROR_TABLET)
        if not errors:
            shorten = sht.long_to_short(url, mobile_url, tablet_url)
            if not shorten:
                return Response(json.dumps(dict(errors=cfg.ERROR_SERVER)), status=500, mimetype="application/json")
            response_data = OrderedDict(
                shorten="{0}/{1}".format(cfg.HOST, shorten))  # ,
            # url="{}".format(url), mobile=mobile_url, tablet=tablet_url)
            return Response(json.dumps(response_data), status=201, mimetype="application/json")
    else:
        errors.append(cfg.ERROR_MISSING)
    return Response(json.dumps(dict(errors=errors)), status=422, mimetype="application/json")

@app.route('/api/1.0/list', methods=['GET'])
def get_urls():
    """
    Lists all urls with the targets and redirects/hits counter

    :returns: JSON, all the data in the urls table
    :raises: raises an exception if there's a problem with the DB
    """
    query = 'SELECT * from urls;'
    with sq.connect(app.config['DATABASE']) as conn:
        conn.row_factory = dict_factory
        cursor = conn.cursor()
        try:
            cursor.execute(query)
            rows = cursor.fetchall()
            for row in rows:
                short = row['short']
                row['short'] = '{host}/{short}'.format(
                    host=cfg.HOST, short=row['short'])
            return Response(json.dumps(rows), status=200, mimetype="application/json")
        except:
            return Response(json.dumps(dict(errors=cfg.ERROR_SERVER)), status=500, mimetype="application/json")

@app.route('/<string:urlcode>', methods=['GET'])
def lookup(urlcode):
    """
    Endpoint that recieves the short url and redirects to the long url target
    Case insensitive for better usability

    :param urlcode: The code of the short url
    :returns: redirects to target
    """
    urlcode = urlcode.lower()
    result = sht.short_to_long(urlcode)
    if result:
        url = result['default_url']
        target = 'default'
        ua = parse_ua(request.headers.get('User-Agent'))
        if result['mobile_url'] and ua.is_mobile:
            url = result['mobile_url']
            target = 'mobile'
        elif result['tablet_url'] and ua.is_tablet:
            url = result['tablet_url']
            target = 'tablet'
        sht.hit(urlcode, target)
        return redirect(url)
        return Response(str(result['mobile_url ']))
    return Response('{"error":"URL NOT FOUND"}', status=404, mimetype="application/json")

if __name__ == '__main__':
    init_db()
    app.run(debug=True)


text:
var createElementFor = require('./createElementFor')
var setElementTransform = require('./setElementTransform')
var AbstractRectangle = require('../AbstractRectangle')
var Space = require('../Space')
var extend = require('extend')

var DOM_SPACENODE_PROPERTY = '_tapspace_node'

// Constructor

var SpaceView = function (space) {
  // Parameters
  //   space
  //     a Space, optional, default to null. Null means that
  //     the view has not given a space.
  //
  if (typeof space === 'undefined') space = null

  AbstractRectangle.call(this)

  // This is the DOM container. Populated in mount().
  this._el = null

  // Mapping from AbstractNode#id to HTMLElement
  // Every HTMLElement created by the view is stored here.
  this._elements = {}
  // Mapping from AbstractNode#id to a map from an event name to a handler fn.
  // Event handlers of every rendered AbstractNode are stored here.
  this._handlers = {}
  // Mapping from an event name to a handler fn.
  // Handlers for the view's events like 'added'. Populated in mount().
  this._viewHandlers = {}

  // View is now ready to be added onto the space.
  // Note that this implicitly sets
  //   this._parent = space
  // Therefore, to access the space, call this.getParent() or this._parent

  if (typeof space === 'object' && space !== null) {
    // Test if valid space
    if (!(space instanceof Space)) {
      throw new Error('Parent of a View must be a Space.')
    }
    this.setParent(space)
  }
}

// Prototype mixin

var p = extend({}, AbstractRectangle.prototype)
SpaceView.prototype = p

// Public methods

p.fitScale = function (ipath) {
  // Overwrite AbstractRectangle#fitScale() to throw an error
  // when the view is not yet mounted and thus has no proper
  // dimensions with to fit.
  //
  if (!this.isMounted()) {
    throw new Error(
      'View is not yet mounted and thus has no proper size ' +
        'for fitting. Call mount() before fitScale().'
    )
  }

  return AbstractRectangle.prototype.fitScale.call(this, ipath)
}

p.fitSize = function () {
  // Override AbstractRectangle#fitSize
  throw new Error('Use refreshSize to resize the view and fitScale to fit.')
}

p.getElementBySpaceItem = function (abstractNode) {
  // Get HTML element representation of the space node.
  // Return null if not found.

  // Get DOM element
  var n = this._elements[abstractNode.id]

  // n will be undefined if not found in _elements.
  if (n) {
    return n
  }
  return null
}

p.getContainer = function () {
  // Return the DOM root element of the space view.
  // Return null if not yet mounted.
  return this._el
}

p.getSpaceItemByElementId = function (id) {
  // Get AbstractNode by HTML element id
  // Return null if no node for such id.
  var el = document.getElementById(id)

  if (el && Object.prototype.hasOwnProperty.call(el, DOM_SPACENODE_PROPERTY)) {
    return el[DOM_SPACENODE_PROPERTY]
  }

  return null
}

p.isMounted = function () {
  return this._el !== null
}

p.mount = function (htmlContainer) {
  // Begin to use htmlContainer as the DOM root for the space.
  //
  // Design decision:
  //   In v3 the HTML container was provided via the constructor.
  //   This led to a poor coding style where 'new SpaceView'
  //   was called just for its rendering side-effect. In v4
  //   we wanted the side-effect to be more explicit and made
  //   it a separate method 'mount'.
  //

  // Test if valid dom element
  if (!(htmlContainer && 'tagName' in htmlContainer)) {
    throw new Error('Container should be a DOM Element')
  }

  // If same container, no reason to do anything
  if (this._el === htmlContainer) {
    return
  }

  // Clear the old container
  this.unmount()
  this._el = htmlContainer

  // Init style.
  // Note:
  // "position: relative" is needed to enable "overflow: hidden".
  // Without "overflow: hidden", if transformed elements get outside
  // the initial viewport, Chrome on Android increases
  // the dimensions of the document.
  this._el.style.position = 'relative'
  this._el.style.overflow = 'hidden'
  this._el.style.display = 'block'

  // Init size in space.
  this._setSize(this._el.clientWidth, this._el.clientHeight)

  // Render the space.
  // Note that this renders also an element for the SpaceView,
  // although the element will be 0x0 and meant for the children of the view.
  // It is possible that the view is mounted before parented.
  if (this._parent) {
    this._renderElementFor(this._parent)
  }

  // A HTMLElement was rendered for the space itself.
  // This element is a bit special, because it should not react
  // to transformations of the Space (how could it, Space does not transform)
  // but to transformations of the SpaceView.

  var view = this
  this._viewHandlers = {
    added: function () {
      // If the view becomes attached to a new parent,
      // render the content of the new parent.
      // See [1] for interaction with the 'childAdded' handler of the parent.
      view._renderElementFor(view._parent)
    },
    transformed: function () {
      // View becomes transformed.
      // => inverse transform HTMLElement of the Space
      //   => Browser retransforms HTMLElements of the descendants.
      // =>
      var el, vel, tr, vtr
      el = view._elements[view._parent.id]
      vel = view._elements[view.id]
      tr = view._T.inverse()
      vtr = view._T

      setElementTransform(el, tr)
      // This undoes the transformation for the view's children
      setElementTransform(vel, vtr)
    }
  }

  this.on('added', this._viewHandlers.added)
  this.on('transformed', this._viewHandlers.transformed)
}

var setParentSuperProto = p.setParent
p.setParent = function (newParent) {
  // Override the AbstractNode#setParent so that only a Space
  // is allowed to become the parent of a SpaceView.
  if (!(newParent instanceof Space)) {
    throw new Error('A View can only be a child of a Space')
  }

  // Remove elements of the oldParent if the parent is about to change.
  // It is easier to remove the elements before _parent changes. That
  // would be the case if removal happens as a reaction to 'removed' event.
  if (this._parent === newParent) {
    return
  }
  if (this._parent !== null) {
    this._removeElementOf(this._parent)
  }

  setParentSuperProto.call(this, newParent)
}

p.unmount = function () {
  // Detach the view from HTML DOM

  if (!this.isMounted()) {
    // No need to remove anything.
    // Unnecessary unmount call can be a programming error
    // but sometimes we just want to be sure the view is unmounted.
    return
  }

  // No need to react to events in the space.
  this.off('added', this._viewHandlers.added)
  this.off('transformed', this._viewHandlers.transformed)
  this._viewHandlers = {}

  // Detach all rendered elements.
  // Note that unmount can be called before first setParent.
  if (this._parent) {
    this._removeElementOf(this._parent)
  }

  // Forget now empty container,
  // so that possible next mount goes smoothly.
  this._el = null
}

p.refreshSize = function () {
  // Recompute size from the container element.
  // See [2]
  if (this.isMounted()) {
    this._setSize(this._el.clientWidth, this._el.clientHeight)
  } else {
    throw new Error('Unmounted view cannot be resized.')
  }
}

p.setSize = function () {
  // Override AbstractRectangle#setSize
  throw new Error('Use refreshSize to resize the view.')
}

p.setISize = function () {
  // Override AbstractRectangle#setISize
  throw new Error('Use refreshSize to resize the view.')
}

// Private(ish) methods

p._getViewSpecificId = function (abstractNodeId) {
  // Each rendered element has own ID. The ID differs from
  // the id of space nodes because a space node can become
  // visualized through multiple views.
  return this.id + '-' + abstractNodeId
}

p._removeElementOf = function (abstractNode) {
  // Removes the HTMLElement of abstractNode.
  // Does not remove the abstractNode from the view,
  // only from DOM.
  //
  // Note that the give abstractNode is probably already detached from
  // the Space. Therefore abstractNode.isRoot() probably returns true and
  // cannot be used to determine if the abstractNode is space.
  var el, on
  var view = this
  var n = abstractNode // alias

  if (!this.isMounted()) {
    throw new Error('Cannot remove element when view is not mounted.')
  }

  // Recursively remove the elements of the child nodes.
  // Does not remove the child nodes.
  n.getChildren().forEach(function (child) {
    view._removeElementOf(child)
  })

  // Stop event handlers.
  on = this._handlers[n.id]
  if (n === this || n === this._parent) {
    // When AbstractNode is the Space or SpaceView itself,
    // only a handler for childAdded has been created.
    n.off('childAdded', on.childAdded)
  } else {
    n.off('childAdded', on.childAdded)
    n.off('removed', on.removed)
    n.off('resized', on.resized)
    n.off('transformed', on.transformed)
  }

  // Remove connections to functions and elements.
  el = this._elements[n.id]
  delete el[DOM_SPACENODE_PROPERTY]
  delete this._elements[n.id]
  delete this._handlers[n.id]

  // Remove from DOM
  el.parentElement.removeChild(el)
}

p._renderElementFor = function (abstractNode) {
  // Creates the element for abstractNode and renders it
  // to the view. Renders also the children of the node.
  var el, parentEl, on
  var view = this
  var n = abstractNode

  // Ensure that the view if mounted to DOM. Otherwise
  // asking for the render is a bug.
  if (!this.isMounted()) {
    throw new Error('Do not render elements before mounting the view')
  }

  // Prevent bugs that double-render elements
  if (Object.prototype.hasOwnProperty.call(this._elements, n.id)) {
    throw new Error('An element should not be added twice to the same view.')
  }

  // Create HTMLElement for the node.
  // If the node is Space, SpaceGroup, or SpaceView,
  // a special 0x0 div is created.
  // Provide SpaceView constructor to avoid a circular dependency.
  el = createElementFor(n, SpaceView)
  // Each must have unique ID so we can reference to them.
  el.id = this._getViewSpecificId(n.id)

  // Allow reference from the element to the abstractNode and vice versa.
  // It becomes important to carefully undo the reference
  // to prevent memory leaks.
  el[DOM_SPACENODE_PROPERTY] = n
  this._elements[n.id] = el

  if (n === this._parent) {
    // So n, i.e. the AbstractNode, is Space.
    // Space has a special handling for its HTMLElement.
    // The element is transformed only when the view transforms.
    // This is the way how the transformation of the view affects to
    // the CSS3 transforms of HTMLElements of the children
    // of the space. The browser takes a product of the CSS3 transforms
    // of HTMLElement and its parents.

    // Add the element to the view's container.
    this._el.appendChild(el)

    // Define how view should react to changes in Space.
    // Note that Space cannot emit 'removed', 'resized', or 'transformed'
    on = {
      childAdded: function (ev) {
        // Child added to root, therefore render it to view.
        // However, if the child is the view itself, do not render
        // because the view has been already rendered in the view's
        // handler for the 'added' event. See note [1] for details.
        if (ev.newChild !== view) {
          // If parent does not change, we only need to rearrange the elements.
          if (ev.oldParent === ev.source) {
            view._reorderElementOf(ev.newChild)
          } else {
            view._renderElementFor(ev.newChild)
          }
        }
      }
    }
    n.on('childAdded', on.childAdded)
  } else {
    // Is a descendant of Space

    // Add the new element to the parent element.
    parentEl = this._elements[n.getParent().id]
    parentEl.appendChild(el)

    // Define how view should react to changes in AbstractNode
    // by setting up handlers.

    if (n === this) {
      // View itself is a descendant of Space and therefore _renderElementFor
      // is called also for the view's AbstractNode.
      //
      // If the view's AbstractNode becomes removed, the view has
      // a special handling for that, defined in unmount().
      //
      // If the view's AbstractNode becomes resized, the view has
      // a special handler for that, defined in mount() TODO.
      // The HTMLElement for the view is a 0x0 and should remain so
      // and therefore we cannot use the default _resizeElementOf.
      //
      // If the view becomes transformed, there is no need to
      // transform it's HTMLElement because the element should stay still.
      // By avoiding unnecessary retransformation we also avoid possible
      // rounding errors.
      //
      // Note that we bound has childAdded handler also for the view.
      // This way we can fix elements to the view, like a health bar, or
      // dropdown menu.
      //
      on = {
        childAdded: function (ev) {
          // Child added. If the parent does not change, we only need to
          // rearrange the elements.
          if (ev.oldParent === ev.source) {
            view._reorderElementOf(ev.newChild)
          } else {
            view._renderElementFor(ev.newChild)
          }
        }
      }
      n.on('childAdded', on.childAdded)
    } else {
      // Is a descendant of the root and not the view itself.
      on = {
        childAdded: function (ev) {
          // If the parent does not change, we only need to
          // rearrange the elements.
          if (ev.oldParent === ev.source) {
            view._reorderElementOf(ev.newChild)
          } else {
            view._renderElementFor(ev.newChild)
          }
        },
        removed: function (ev) {
          if (ev.oldParent === ev.newParent) {
            // Rearrange elements in childAdded handler.
          } else {
            view._removeElementOf(n)
          }
        },
        resized: function () {
          view._resizeElementOf(n)
        },
        transformed: function () {
          // When the space element transforms,
          // update the local CSS transform of the dom element.
          setElementTransform(view._elements[n.id], n._T)
        }
      }

      n.on('childAdded', on.childAdded)
      n.on('removed', on.removed)
      n.on('resized', on.resized)
      n.on('transformed', on.transformed)

      // Set initial size and transformation
      if (n instanceof AbstractRectangle) {
        on.resized()
      }
      on.transformed()
    }
  }

  // Store for _removeElementOf
  this._handlers[n.id] = on

  // Repeat for children to render everything.
  n.getChildren().forEach(function (child) {
    view._renderElementFor(child)
  })
}

p._reorderElementOf = function (item) {
  // Item's order has probably changed in space. We manipulate
  // the DOM so that the element order matches the order in space.
  var el, parentEl, nextSibling, nextEl

  el = this._elements[item.id]
  parentEl = this._elements[item._parent.id]

  nextSibling = item.getNextSibling()

  if (nextSibling) {
    // Next sibling exists. Move the item's element so that it becomes before.
    nextEl = this._elements[nextSibling.id]
    parentEl.insertBefore(el, nextEl)
  } else {
    // Item is the last. Move the element last.
    parentEl.appendChild(el)
  }
}

p._resizeElementOf = function (item) {
  var el, wh
  wh = item.getSize()
  el = this._elements[item.id]
  el.style.width = wh.width + 'px'
  el.style.height = wh.height + 'px'
}

// As we override setSize, provide private access to AbstractRectangle#setSize
p._setSize = AbstractRectangle.prototype.setSize

module.exports = SpaceView


text:
<?php
/*
Plugin Name: Slack Integration for WordPress
Plugin URI: http://wordpress.org/plugins/slack-wordpress/
Description: Slack Integration for WordPress.
Author: Eray Alakese
Version: 1.7.1
Author URI: http://erayalakese.com/
*/
require_once("inc/api.class.php");
require_once("inc/plugin.class.php");

function activate()
{
	$plugin = new Slack_Plugin();
}
//register_activation_hook(__FILE__, 'activate');

global $slack_plugin;
$slack_plugin = new Slack_Plugin();

?>


text:
package org.apache.flume.formatter.output;

import org.apache.flume.Context;
import org.joda.time.LocalDateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import java.io.File;

/**
 *
 */
public class RollTimePathManager extends DefaultPathManager {

  private final DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyMMddHHmmss");
  private String lastRoll;

  public RollTimePathManager(Context context) {
    super(context);
  }

  @Override
  public File nextFile() {
    StringBuilder sb = new StringBuilder();
    String date = formatter.print(LocalDateTime.now());
    if (!date.equals(lastRoll)) {
      getFileIndex().set(0);
      lastRoll = date;
    }
    sb.append(getPrefix()).append(date).append("-");
    sb.append(getFileIndex().incrementAndGet());
    if (getExtension().length() > 0) {
      sb.append(".").append(getExtension());
    }
    currentFile = new File(getBaseDirectory(), sb.toString());

    return currentFile;
  }

  public static class Builder implements PathManager.Builder {
    @Override
    public PathManager build(Context context) {
      return new RollTimePathManager(context);
    }
  }

}


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

<meta http-equiv="content-type" content="text/html; charset=utf-8" >
<title>Italy - Rome 2012
 -  Proposal</title>
<meta name="author" content="Sarah Haselbauer" >

<link rel="alternate" type="application/rss+xml" title="devopsdays RSS Feed" href="http://www.devopsdays.org/feed/" >

<link rel="stylesheet" href="/css/devops.min.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="/css/blueprint/print.css" type="text/css" media="print">

      Home

      Contact

      Events

      Presentations

      Blog

Italy - Rome 2012
 -  Proposal

Gold sponsors

welcome
propose
program
location
register
sponsor
contact

Back to proposals overview - program

Building an infrastructure to support continuous delivery

Abstract:

Build tools such as Maven, Ant and Gradle are now commonplace. This is
an important step towards optimization of software development and
delivery processes, so this talk will of course include a description of
the code's journey from the developer's machine to the running system,
and all the steps taken and tools encountered along the way. However,
this is only half the story: besides the transformations the code
undergoes throughout the software engineering process, the
infrastructure must also go through something similar. While the code
journey has become quite transparent, there is still a lot of silence on
the subject of infrastructure. When it comes to target environment
setup, there is often no versioning, no revision to a fallback state, no
tests and no documentation on how the target environment can reach the
state in which the main piece of delivery, namely the software, can be
successfully deployed and used.

Along with software engineering processes, this talk describes the
advantages, risks and possibilities of an automated infrastructure
setup. It offers options on how versioning and testing of an automated
infrastructure setup may be realized and integrated in the software
engineering process. And of course, topics such as build tools, bug
tracking, authentication, artifact repositories, continuous integration
and continuous deployment are addressed.

Speaker:
Sara Haselbauer

Please enable JavaScript to view the comments powered by Disqus.
blog comments powered by Disqus

Silver sponsors

Media sponsors


text:
export { BsDatepickerConfig } from './bs-datepicker.config';
export { BsDatepickerContainerComponent } from './themes/bs/bs-datepicker-container.component';
export { BsDatepickerDirective } from './bs-datepicker.component';
export { BsDatepickerInlineConfig } from './bs-datepicker-inline.config';
export { BsDatepickerInlineContainerComponent } from './themes/bs/bs-datepicker-inline-container.component';
export { BsDatepickerInlineDirective } from './bs-datepicker-inline.component';
export { BsDaterangepickerInlineConfig } from './bs-daterangepicker-inline.config';
export { BsDaterangepickerInlineContainerComponent } from './themes/bs/bs-daterangepicker-inline-container.component';
export { BsDaterangepickerInlineDirective } from './bs-daterangepicker-inline.component';
export { BsDatepickerInputDirective } from './bs-datepicker-input.directive';
export { BsDaterangepickerInputDirective } from './bs-daterangepicker-input.directive';
export { BsDatepickerViewMode, DatepickerDateCustomClasses, DatepickerDateTooltipText } from './models';
export { BsDaterangepickerConfig } from './bs-daterangepicker.config';
export { BsDaterangepickerContainerComponent } from './themes/bs/bs-daterangepicker-container.component';
export { BsDaterangepickerDirective } from './bs-daterangepicker.component';
export { BsLocaleService } from './bs-locale.service';

export { BsDatepickerModule } from './bs-datepicker.module';


text:
<!DOCTYPE html>

    <title>StashPop Options</title>

        Email Options

                <input type="checkbox" id="emailIssuesList">
            Issues list

                <input type="checkbox" id="emailIssue">
            Individual issue

                <input type="checkbox" id="emailPullRequestList">
            Pull request list

                <input type="checkbox" id="emailPullRequest">
            Individual pull request

        Pull Request Options

                <input type="checkbox" id="jenkinsOpenDetailsLinksInNewTab">
            Open "details" links in a new tab

                <input type="checkbox" id="jenkinsShowRunTime">
            Show test run time

                <input type="checkbox" id="jenkinsShowFailureIndications">
            Show failure indications on PR page

                    <input type="checkbox" id="jenkinsShowTestFailures">
            And show structured test failures

                <input type="checkbox" id="jenkinsShowBugFilingButton">
            Show bug-filing button on failures

                <input type="checkbox" id="jenkinsShowRetestButton">
            Show retest button on failures

                <input type="checkbox" id="jenkinsOfferInlineFailuresOnPRList">
            Offer to inline test failures on PR lists

                <input type="checkbox" id="showCodeReviewInfo">
            Show code review information

                Code Review Options

                    Examples:

            Organization;Approved;Rejected;TestSignoff

            Organization/Repo;Approval1,Approval2;Rejected1,Rejected2;TestSignoff1,TestSignoff2

            Organization/Repo2;:+1:,:thumbsup:;:-1:;Test Signoff

            Organization/RepoToIgnore;;;

                    Configured options:

                        <textarea id="codeReviewOptions" rows="5" cols="75"></textarea>

                Issue creation routing:

                    Examples:

            OrganizationA/RepoWithoutIssues:OrganizationB/RepoWithIssues

                    Configured routes:

                        <textarea id="issueCreationRouting" rows="5" cols="75"></textarea>

                Non-default test suites:

                    Examples:

            OrganizationA:NonDefaultTestA

            OrganizationB/SpecificRepo:NonDefaultTestB

            OrganizationB/SpecificRepo:NonDefaultTestC

            OrganizationC/SpecificRepo:NonDefaultTestD:TestNameThatIndicatesTestDAlreadyRan

                    Test suites:

                        <textarea id="nonDefaultTestInfo" rows="5" cols="75"></textarea>

                Default labels when creating issues

                    Examples:

            OrganizationA:DefaultLabel1

            OrganizationB/SpecificRepo:DefaultLabel1,DefaultLabel2

                    Default labels:

                        <textarea id="defaultIssueLabels" rows="5" cols="75"></textarea>

                Jenkins test rerunning text

                    Examples:

            *:retest {0} please

            OrganizationA:retest {0} please

            OrganizationB/SpecificRepo:please rerun tests

                    Rerun text:

                        <textarea id="testRerunText" rows="5" cols="75"></textarea>

                Host permissions:

                    Examples:

            https://jenkins-server/*

                    Add new host:

            <input id="addHostPermissionHostname"></input>
            <button id="addHostPermission">Add</button>

                        <textarea id="existingHostPermissions" rows="5" cols="75" disabled="true"></textarea>

        <button id="save">Save</button>


text:
package mariculture.lib.util;

public class IdiotException extends RuntimeException {
    public IdiotException() {
        super();
    }

    public IdiotException(String s) {
        super(s);
    }
}


text:
A simple Django app to create a user profile using Django authentication.
The app has custom interface for sign in, register, forgot password, activation, edit user details and so.

It uses the follow dependecies from Nirvaris:

- [Nirvaris Default Theme](https://github.com/nirvaris/nirvaris-theme-default)

#Quick start

- Django admin must be installed, of course, and you have to run migrate. The app itself does not have any models.

- You can use pip from git to install it. A requirements file is provided with some dependencies.

```
pip install git+https://github.com/nirvaris/nirvaris-profile

```

- Add the _n\_profile_, and its dependencies, to your INSTALLED_APPS:

```python
    INSTALLED_APPS = (
        ...
        'n_profile',
        'themedefault',
    )
```

- As it sends emails for account activation and forgot password, you have to setup your SMTP details in your settings. [Django docs for sending emails](https://docs.djangoproject.com/en/1.9/topics/email/)

```
EMAIL_HOST = ''
EMAIL_PORT = 465
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = True
```

- Some Django variable used by the app. [Django docs](https://docs.djangoproject.com/en/1.9/ref/settings/#login-url)

```
LOGIN_URL = 'login'
LOGOUT_URL = 'logout'
```

- Some Nirvaris specific variables to your settings

```
NV_SITE_URL = 'http://localhost:8000/' # used to assemble the activation link
NV_AFTER_LOGIN_URL = 'profile-dashboard' # Or your own after login page
NV_MAX_TOKEN_DAYS = 10 # The limit in days for the activation email to be expired
NV_EMAIL_FROM = '' # The from email the app will send emails out
NV_SECRET_KEY = '' # This key is used by the crypto module to encrypt and decrypt the activation token.
```
- you have to add the url to your urls file:

```
url(r'^profile/', include('n_profile.urls')),
```
- The app's urls are:

```
<your-project-url>/profile/register
<your-project-url>/profile/resend-activation-email
<your-project-url>/profile/activation  #this one expect a parameter P with the activation token
<your-project-url>/profile/login
<your-project-url>/profile/forgot-password
<your-project-url>/profile/profile-dashboard
<your-project-url>/profile/logout
<your-project-url>/profile/change-password
<your-project-url>/profile/change-user-details
```


text:
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan
. "$PSScriptRoot\constants.ps1"

Describe "$CommandName Integration Tests" -Tags "IntegrationTests" {
    BeforeAll {
        $server = Connect-DbaInstance -SqlInstance $script:instance2
        $conn = $server.ConnectionContext
        # Get the systemhealth session
        $systemhealth = Get-DbaXESession -SqlInstance $server -Session system_health
        # Create a session with an invalid target
        $conn.ExecuteNonQuery("CREATE EVENT SESSION [dbatoolsci_session_invalid] ON SERVER ADD EVENT sqlserver.lock_acquired ADD TARGET package0.etw_classic_sync_target (SET default_etw_session_logfile_path = N'C:\dbatoolsci_session_doesnotexist\logfile.etl' );")
        $dbatoolsciInvalid = Get-DbaXESession -SqlInstance $server -Session dbatoolsci_session_invalid
        # Create a valid session
        $conn.ExecuteNonQuery("CREATE EVENT SESSION [dbatoolsci_session_valid] ON SERVER ADD EVENT sqlserver.lock_acquired;")
        $dbatoolsciValid = Get-DbaXESession -SqlInstance $server -Session dbatoolsci_session_valid
        # Record the Status of all sessions
        $allSessions = Get-DbaXESession -SqlInstance $server
    }
    BeforeEach {
        <#
        $systemhealth.Refresh()
        if ($systemhealth.IsRunning) {
            $systemhealth.Stop()
        }
        #>
        $systemhealth | Stop-DbaXESession #-ErrorAction SilentlyContinue
    }
    AfterAll {
        # Set the Status of all session back to what they were before the test
        foreach ($session in $allSessions) {
            $session.Refresh()
            if ($session.Status -eq "Stopped") {
                if ($session.IsRunning) {
                    $session.Stop()
                }
            }
            else {
                if (-Not $session.IsRunning) {
                    $session.Start()
                }
            }
        }

        # Drop created objects
        $conn.ExecuteNonQuery("IF EXISTS(SELECT * FROM sys.server_event_sessions WHERE name = 'dbatoolsci_session_invalid') DROP EVENT SESSION [dbatoolsci_session_invalid] ON SERVER;")
        $conn.ExecuteNonQuery("IF EXISTS(SELECT * FROM sys.server_event_sessions WHERE name = 'dbatoolsci_session_valid') DROP EVENT SESSION [dbatoolsci_session_valid] ON SERVER;")
    }

    Context "Verifying command works" {
        It "starts the system_health session" {
            $systemhealth | Start-DbaXESession
            $systemhealth.Refresh()
            $systemhealth.IsRunning | Should Be $true
        }

        It "does not change state if XE session is already started" {
            if (-Not $systemhealth.IsRunning) {
                $systemhealth.Start()
            }
            $systemhealth | Start-DbaXESession -WarningAction SilentlyContinue
            $systemhealth.Refresh()
            $systemhealth.IsRunning | Should Be $true
        }

        It "starts the other XE Sessions when one has an error" {
            # Start system_health and the invalid session
            Start-DbaXESession $server -Session $systemhealth.Name, $dbatoolsciInvalid.Name -WarningAction SilentlyContinue
            $systemhealth.Refresh()
            $dbatoolsciInvalid.Refresh()
            $systemhealth.IsRunning | Should Be $true
            $dbatoolsciInvalid.IsRunning | Should Be $false
        }

        It "starts all XE Sessions except the system ones if -AllSessions is used" {
            Start-DbaXESession $server -AllSessions -WarningAction SilentlyContinue
            $systemhealth.Refresh()
            $dbatoolsciValid.Refresh()
            $systemhealth.IsRunning | Should Be $false
            $dbatoolsciValid.IsRunning | Should Be $true
        }

    }
}


text:
void
_parse_comment(PyObject * comment_obj, bool & has_comment, char & comment);

typedef std::vector<char> buf_t;

enum{_int = 0, _float = 1, _str = 2};
enum{_inds_cols = 0, _names_cols = 1, _all_cols = 2};
enum{max_num_cols = 1000, max_field_len = 128};

typedef std::pair<const char *, const char *> _ParsedT;

PyObject *
_ParsedTo_string(const _ParsedT & t);

long
_ParsedTo_long(const _ParsedT & t, bool & err);
PyObject *
_ParsedTo_int(const _ParsedT & t);

double
_ParsedTo_double(const _ParsedT & t, bool & err);
PyObject *
_ParsedTo_float(const _ParsedT & t);

char *
pystring_as_string(PyObject * o, long & len);

long *
parse_longs(PyObject * iterator, long & num, bool & err);
char * *
parse_strings(PyObject * iterator, long & num, bool & err);

extern "C" PyObject *
parser_max_field_len(PyObject *module, PyObject *args, PyObject *keyword_args);

#endif // #ifndef PARSER_DEFS_HPP