text:
// @TFDCLERK_HEADER_START@

// @TFDCLERK_HEADER_END@

TFD.prototype._do_relist = function() {
    // TODO
    // rough mockup:
    // - post-submit ui updates
    //      - date input box -> link to new discussion log page
    //      - disable comments box
    //      - add progress info area
    // - "Adding discussion to new date..."
    //      - add discussion to new date, plus relist template
    //      - " done ([[diff]])"
    // - "Removing discussion from old date..."
    //      - replace contents of section with {{relisted}}
    //      - " done ([[diff]])"
    // - "Updating discussion link on template(s):\n* [[Template:A]]..."
    //      - update |link param of {{template for discussion}}
    //      - " done ([[diff]])"
    // - replace gray buttons with progressive refresh button
};

TFD.prototype._get_relist_date = function() {
    return new Date(this.box.find(".tfdclerk-date").val()).toLogDateFormat();
};

TFD.prototype._on_date_change = function() {
    var date = this._get_relist_date();
    var title = "Wikipedia:Templates for discussion/Log/" + date;
    var info = this.box.find(".tfdclerk-discussion-info");
    info.empty();

    if (mw.config.get("wgTitle") == "Templates for discussion")
        var this_date = this.head.prevAll().filter("h3").first().find("a")
            .prop("title").split("/Log/")[1];
    else
        var this_date = mw.config.get("wgTitle").split("/Log/")[1];

    if (date == null || date == this_date) {
        this._block_submit("bad-date");
        info.append($("<span/>", {
            addClass: "tfdclerk-bad-date",
            text: date == this_date ? "Same as current date" : "Invalid date"
        }));
        return;
    }

    this._unblock_submit("bad-date");
    this._block_submit("checking-discussion");
    info.append(this._build_loading_node("span", "Checking discussion"));

    TFDClerk.api_get(this, {
        action: "query",
        indexpageids: "",
        titles: title
    }, function(data) {
        this._unblock_submit("checking-discussion");
        info.empty().append($("<span/>", {text: "Log: "})).append($("<a/>", {
            href: mw.util.getUrl(title),
            title: title,
            text: date,
            addClass: data.query.pageids[0] < 0 ? "new" : ""
        }));
        if (date == (new Date().toLogDateFormat()))
            info.append($("<span/>", {text: " (today)"}));
    });
};

TFD.prototype.relist = function() {
    var self = this;
    if (this._guard)
        return;
    this._guard = true;

    this._add_option_box("relist", "Relisting discussion", this._do_relist,
        function() {
            this._add_option_table([
                [
                    $("<label/>", {
                        for: "tfdclerk-date-" + this.id,
                        text: "New date:"
                    }),
                    $("<input/>", {
                        id: "tfdclerk-date-" + this.id,
                        addClass: "tfdclerk-date",
                        name: "date",
                        type: "date",
                        value: new Date().toDatePickerFormat(),
                        change: function() { self._on_date_change(); }
                    }).add($("<span/>", {
                        addClass: "tfdclerk-discussion-info"
                    }))
                ],
                [
                    $("<label/>", {
                        for: "tfdclerk-comments-" + this.id,
                        text: "Comments:"
                    }),
                    $("<textarea/>", {
                        id: "tfdclerk-comments-" + this.id,
                        name: "comments",
                        rows: 2,
                        cols: 60,
                        placeholder: "Optional. Do not sign."
                    })
                ]
            ]);
            this._on_date_change();
        });
};


text:
package com.thread.pool;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;

public class DefaultThreadPool<Job extends Runnable> implements ThreadPool<Job> {
	private static final int MAX_WORKER_NUMBERS = 10;
	private static final int MIN_WORKER_NUMBERS = 1;
	private static final int DEFAULT_WORKER_NUMBERS = 5;
	private final LinkedList<Job> jobs = new LinkedList<Job>();
	private final List<Worker> workers = Collections.synchronizedList(new ArrayList<Worker>());
	private int workerNum = DEFAULT_WORKER_NUMBERS;
	private AtomicLong threadNum = new AtomicLong();

	public DefaultThreadPool(){
		initializeWokers(DEFAULT_WORKER_NUMBERS);
	}

	public DefaultThreadPool(int num){
		workerNum = num>MAX_WORKER_NUMBERS?MAX_WORKER_NUMBERS
				:num<MIN_WORKER_NUMBERS?MIN_WORKER_NUMBERS:num;
		initializeWokers(workerNum);
	}

	private void initializeWokers(int num){
		for(int i=0;i<num;i++){
			Worker worker = new Worker();
			workers.add(worker);
			Thread thread = new Thread(worker, "Threadpool-worker-"+threadNum.incrementAndGet());
			thread.start();
		}
	}

	@Override
	public void execute(Job job) {
		if(job!=null){
			synchronized(jobs){
				jobs.addLast(job);
				jobs.notify();
			}
		}
	}

	@Override
	public void addWorkers(int num) {
		synchronized(jobs){
			if(workerNum+num>MAX_WORKER_NUMBERS){
				num = MAX_WORKER_NUMBERS-workerNum;
			}
			initializeWokers(num);
			workerNum += num;
		}
	}

	@Override
	public void removeWorkers(int num) {
		synchronized (jobs) {
			if(num>workerNum){
				throw new IllegalArgumentException("beyond worknum");
			}
			int count=0;
			while(count<num){
				Worker worker = workers.get(count);
				if(workers.remove(worker)){
					worker.shutdown();
					count++;
				}
			}
			workerNum-=count;
		}
	}

	@Override
	public void shutdown() {
		for(Worker worker:workers){
			worker.shutdown();
		}
	}

	@Override
	public int getJobSize() {
		return jobs.size();
	}

	public class Worker implements Runnable{
		private volatile boolean running = true;

		@Override
		public void run() {
			while(running){
				Job job = null;
				synchronized(jobs){
					while(jobs.isEmpty()){
						try {
							jobs.wait();
						} catch (InterruptedException e) {
							Thread.currentThread().interrupt();
							return;
						}
					}
					job = jobs.removeFirst();
				}

				if(job!=null){
					job.run();
				}
			}
		}

		public void shutdown(){
			running = false;
		}

	}

}

redpajama_set_name: RedPajamaGithub


text:
namespace sfg {

Widget::Ptr Bin::GetChild() const {
	if( GetChildren().size() < 1 ) {
		return Widget::Ptr();
	}

	return *GetChildren().begin();
}

void Bin::HandleAdd( Widget::Ptr child ) {
	Container::HandleAdd( child );

	if( GetChildren().size() > 1 ) {
#if defined( SFGUI_DEBUG )
		std::cerr << "SFGUI warning: Only one widget can be added to a Bin.\n";
#endif

		Remove( child );
	}
}

}


text:
package com.speedment.generator.standard.entity;

import com.speedment.common.codegen.model.File;
import com.speedment.common.codegen.model.Interface;
import com.speedment.common.injector.Injector;
import com.speedment.generator.translator.AbstractEntityAndManagerTranslator;
import com.speedment.runtime.config.Table;

/**
 *
 * @author Emil Forslund
 * @author Per-Åke Minborg
 */
public class EntityTranslator extends AbstractEntityAndManagerTranslator<Interface> {

    public EntityTranslator(Injector injector, Table table) {
        super(injector, table, Interface::of);
    }

    @Override
    protected Interface makeCodeGenModel(File file) {
        return newBuilder(file, getSupport().entityName()).build()
            .public_().add(getSupport().generatedEntityType());
    }

    @Override
    protected String getClassOrInterfaceName() {
        return getSupport().entityName();
    }

    @Override
    protected String getJavadocRepresentText() {
        return "The main interface for entities of the {@code " +
            getDocument().getId() + "}-table in the database.";
    }
}


text:
require 'fileutils'
require_relative "htmlgen"
require_relative "parser"

  class Executer

    def self.execute(input, output)
      # TEST INPUT
      raise ArgumentError.new("Argument is missing") if input.nil?
      check_file(input)

      # PARSE XML
      parsed_file = Parser.new(input).parse_and_check_data

      # CREATE OR ASSIGN PATH
      directory(input, output)

      # HTML GENERATE FROM PARSED XML
      htmls = Htmlgen.new(parsed_file, output)
      htmls.create_htmls!
    end

    def self.check_file(input)
        file = File.open(input, "r")
        raise MalformedXML.new("XML file is not valid") if !Nokogiri::XML(file).errors.empty?
    end

    def self.directory(input, output)
      dir = File.expand_path(output)
      FileUtils.mkdir(dir) unless File.exists?(dir)
    end

    class MalformedXML < Nokogiri::XML::SyntaxError
    end
  end


text:
package org.apache.shindig.social.core.oauth;

import org.apache.shindig.common.testing.FakeHttpServletRequest;
import org.apache.shindig.common.uri.UriBuilder;
import org.apache.shindig.social.core.oauth2.OAuth2Servlet;
import org.apache.shindig.social.dataservice.integration.AbstractLargeRestfulTests;
import org.easymock.Capture;
import org.easymock.EasyMock;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;

import javax.servlet.http.HttpServletResponse;

import java.io.PrintWriter;
import java.net.URLEncoder;

public class OAuth2ImplicitFlowTest extends AbstractLargeRestfulTests {
  protected OAuth2Servlet servlet = null;

  public static final String IMPLICIT_CLIENT_ID = "advancedImplicitClient";

  protected static final String REDIRECT_URI = "http://localhost:8080/oauthclients/ImplicitClientHelper.html";

  @Before
  @Override
  public void abstractLargeRestfulBefore() throws Exception {
    super.abstractLargeRestfulBefore();
    servlet = new OAuth2Servlet();
    injector.injectMembers(servlet);
  };

  /**
   * Test retrieving an access token using a public client with a redirect uri
   *
   * @throws Exception
   */
  @Test
  public void testGetAccessTokenWithRedirectParamAndState() throws Exception {
    FakeHttpServletRequest req = new FakeHttpServletRequest(
        "http://localhost:8080/oauth2");
    req.setContentType("application/x-www-form-urlencoded");
    req.setPostData(
        "client_id=" + IMPLICIT_CLIENT_ID
            + "&response_type=token&state=PRESERVEME&redirect_uri="
            + URLEncoder.encode(REDIRECT_URI, "UTF-8"), "UTF-8");
    req.setMethod("GET");
    req.setServletPath("/oauth2");
    req.setPathInfo("/authorize");
    HttpServletResponse resp = mock(HttpServletResponse.class);
    Capture<String> redirectURI = new Capture<String>();
    resp.setHeader(EasyMock.eq("Location"), EasyMock.capture(redirectURI));
    resp.setStatus(HttpServletResponse.SC_FOUND);
    MockServletOutputStream outputStream = new MockServletOutputStream();
    EasyMock.expect(resp.getOutputStream()).andReturn(outputStream).anyTimes();
    PrintWriter writer = new PrintWriter(outputStream);
    EasyMock.expect(resp.getWriter()).andReturn(writer).anyTimes();
    replay();
    servlet.service(req, resp);
    writer.flush();
    String fragment = UriBuilder.parse(redirectURI.getValue()).getFragment();
    assertTrue(redirectURI.getValue().startsWith(REDIRECT_URI));
    assertTrue(fragment.contains("token_type=bearer"));
    assertTrue(fragment.contains("access_token="));
    assertTrue(fragment.contains("expires_in="));
    assertTrue(fragment.contains("state=PRESERVEME"));

    verify();
  }

  /**
   * Test retrieving an access token using a public client with redirect uri
   *
   * @throws Exception
   */
  @Test
  public void testGetAccessTokenNoRedirectParam() throws Exception {
    FakeHttpServletRequest req = new FakeHttpServletRequest(
        "http://localhost:8080/oauth2");
    req.setContentType("application/x-www-form-urlencoded");
    req.setPostData("client_id=" + IMPLICIT_CLIENT_ID + "&response_type=token",
        "UTF-8");
    req.setMethod("GET");
    req.setServletPath("/oauth2");
    req.setPathInfo("/authorize");
    HttpServletResponse resp = mock(HttpServletResponse.class);
    Capture<String> redirectURI = new Capture<String>();
    resp.setHeader(EasyMock.eq("Location"), EasyMock.capture(redirectURI));
    resp.setStatus(HttpServletResponse.SC_FOUND);
    MockServletOutputStream outputStream = new MockServletOutputStream();
    EasyMock.expect(resp.getOutputStream()).andReturn(outputStream).anyTimes();
    PrintWriter writer = new PrintWriter(outputStream);
    EasyMock.expect(resp.getWriter()).andReturn(writer).anyTimes();
    replay();
    servlet.service(req, resp);
    writer.flush();
    String fragment = UriBuilder.parse(redirectURI.getValue()).getFragment();
    assertTrue(redirectURI.getValue().startsWith(REDIRECT_URI));
    assertTrue(fragment.contains("token_type=bearer"));
    assertTrue(fragment.contains("access_token="));
    assertTrue(fragment.contains("expires_in="));
    verify();
  }

  /**
   * Test attempting to retrieve an access token using a bad redirect URI
   *
   * @throws Exception
   */
  @Test
  public void testGetAccessTokenWithBadRedirect() throws Exception {
    FakeHttpServletRequest req = new FakeHttpServletRequest(
        "http://localhost:8080/oauth2");
    req.setContentType("application/x-www-form-urlencoded");
    req.setPostData(
        "client_id=" + IMPLICIT_CLIENT_ID
            + "&response_type=token&redirect_uri="
            + URLEncoder.encode("BAD_REDIRECT", "UTF-8"), "UTF-8");
    req.setMethod("GET");
    req.setServletPath("/oauth2");
    req.setPathInfo("/authorize");
    HttpServletResponse resp = mock(HttpServletResponse.class);

    resp.setStatus(EasyMock.eq(HttpServletResponse.SC_FORBIDDEN));
    MockServletOutputStream outputStream = new MockServletOutputStream();
    EasyMock.expect(resp.getOutputStream()).andReturn(outputStream).anyTimes();
    PrintWriter writer = new PrintWriter(outputStream);
    EasyMock.expect(resp.getWriter()).andReturn(writer).anyTimes();
    replay();
    servlet.service(req, resp);
    writer.flush();

    verify();
    String response = new String(outputStream.getBuffer(), "UTF-8");
    JSONObject respObj = new JSONObject(response);
    assertTrue(respObj.has("error"));
  }

  /**
   * Test attempting to retrieve an access token using a bad client id
   *
   * @throws Exception
   */
  @Test
  public void testGetAccessTokenWithBadClientID() throws Exception {
    FakeHttpServletRequest req = new FakeHttpServletRequest(
        "http://localhost:8080/oauth2");
    req.setContentType("application/x-www-form-urlencoded");
    req.setPostData("client_id=BAD-ID&response_type=token&redirect_uri="
        + URLEncoder.encode(REDIRECT_URI, "UTF-8"), "UTF-8");
    req.setMethod("GET");
    req.setServletPath("/oauth2");
    req.setPathInfo("/authorize");
    HttpServletResponse resp = mock(HttpServletResponse.class);
    resp.setStatus(EasyMock.eq(HttpServletResponse.SC_FORBIDDEN));
    MockServletOutputStream outputStream = new MockServletOutputStream();
    EasyMock.expect(resp.getOutputStream()).andReturn(outputStream).anyTimes();
    PrintWriter writer = new PrintWriter(outputStream);
    EasyMock.expect(resp.getWriter()).andReturn(writer).anyTimes();
    replay();
    servlet.service(req, resp);
    writer.flush();

    verify();
    String response = new String(outputStream.getBuffer(), "UTF-8");
    JSONObject respObj = new JSONObject(response);
    assertTrue(respObj.has("error"));
  }

}


text:
import typing as T
import os, sys
from .. import mesonlib
from .. import mlog
from ..mesonlib import Popen_safe
import argparse

parser = argparse.ArgumentParser()

parser.add_argument('--cross-host', default=None, dest='cross_host',
                    help='cross compilation host platform')
parser.add_argument('args', nargs='+')

TOOL_WARNING_FILE = None
RELINKING_WARNING = 'Relinking will always happen on source changes.'

def dummy_syms(outfilename: str):
    """Just touch it so relinking happens always."""
    with open(outfilename, 'w'):
        pass

def write_if_changed(text: str, outfilename: str):
    try:
        with open(outfilename, 'r') as f:
            oldtext = f.read()
        if text == oldtext:
            return
    except FileNotFoundError:
        pass
    with open(outfilename, 'w') as f:
        f.write(text)

def print_tool_warning(tool: list, msg: str, stderr: str = None):
    global TOOL_WARNING_FILE
    if os.path.exists(TOOL_WARNING_FILE):
        return
    if len(tool) == 1:
        tool = tool[0]
    m = '{!r} {}. {}'.format(tool, msg, RELINKING_WARNING)
    if stderr:
        m += '\n' + stderr
    mlog.warning(m)
    # Write it out so we don't warn again
    with open(TOOL_WARNING_FILE, 'w'):
        pass

def get_tool(name: str) -> T.List[str]:
    evar = name.upper()
    if evar in os.environ:
        import shlex
        return shlex.split(os.environ[evar])
    return [name]

def call_tool(name: str, args: T.List[str], **kwargs) -> str:
    tool = get_tool(name)
    try:
        p, output, e = Popen_safe(tool + args, **kwargs)
    except FileNotFoundError:
        print_tool_warning(tool, 'not found')
        return None
    if p.returncode != 0:
        print_tool_warning(tool, 'does not work', e)
        return None
    return output

def call_tool_nowarn(tool: T.List[str], **kwargs) -> T.Tuple[str, str]:
    try:
        p, output, e = Popen_safe(tool, **kwargs)
    except FileNotFoundError:
        return None, '{!r} not found\n'.format(tool[0])
    if p.returncode != 0:
        return None, e
    return output, None

def gnu_syms(libfilename: str, outfilename: str):
    # Get the name of the library
    output = call_tool('readelf', ['-d', libfilename])
    if not output:
        dummy_syms(outfilename)
        return
    result = [x for x in output.split('\n') if 'SONAME' in x]
    assert(len(result) <= 1)
    # Get a list of all symbols exported
    output = call_tool('nm', ['--dynamic', '--extern-only', '--defined-only',
                              '--format=posix', libfilename])
    if not output:
        dummy_syms(outfilename)
        return
    for line in output.split('\n'):
        if not line:
            continue
        line_split = line.split()
        entry = line_split[0:2]
        # Store the size of symbols pointing to data objects so we relink
        # when those change, which is needed because of copy relocations
        # https://github.com/mesonbuild/meson/pull/7132#issuecomment-628353702
        if line_split[1].upper() in ('B', 'G', 'D') and len(line_split) >= 4:
            entry += [line_split[3]]
        result += [' '.join(entry)]
    write_if_changed('\n'.join(result) + '\n', outfilename)

def solaris_syms(libfilename: str, outfilename: str):
    # gnu_syms() works with GNU nm & readelf, not Solaris nm & elfdump
    origpath = os.environ['PATH']
    try:
        os.environ['PATH'] = '/usr/gnu/bin:' + origpath
        gnu_syms(libfilename, outfilename)
    finally:
        os.environ['PATH'] = origpath

def osx_syms(libfilename: str, outfilename: str):
    # Get the name of the library
    output = call_tool('otool', ['-l', libfilename])
    if not output:
        dummy_syms(outfilename)
        return
    arr = output.split('\n')
    for (i, val) in enumerate(arr):
        if 'LC_ID_DYLIB' in val:
            match = i
            break
    result = [arr[match + 2], arr[match + 5]] # Libreoffice stores all 5 lines but the others seem irrelevant.
    # Get a list of all symbols exported
    output = call_tool('nm', ['--extern-only', '--defined-only',
                              '--format=posix', libfilename])
    if not output:
        dummy_syms(outfilename)
        return
    result += [' '.join(x.split()[0:2]) for x in output.split('\n')]
    write_if_changed('\n'.join(result) + '\n', outfilename)

def openbsd_syms(libfilename: str, outfilename: str):
    # Get the name of the library
    output = call_tool('readelf', ['-d', libfilename])
    if not output:
        dummy_syms(outfilename)
        return
    result = [x for x in output.split('\n') if 'SONAME' in x]
    assert(len(result) <= 1)
    # Get a list of all symbols exported
    output = call_tool('nm', ['-D', '-P', '-g', libfilename])
    if not output:
        dummy_syms(outfilename)
        return
    # U = undefined (cope with the lack of --defined-only option)
    result += [' '.join(x.split()[0:2]) for x in output.split('\n') if x and not x.endswith('U ')]
    write_if_changed('\n'.join(result) + '\n', outfilename)

def cygwin_syms(impfilename: str, outfilename: str):
    # Get the name of the library
    output = call_tool('dlltool', ['-I', impfilename])
    if not output:
        dummy_syms(outfilename)
        return
    result = [output]
    # Get the list of all symbols exported
    output = call_tool('nm', ['--extern-only', '--defined-only',
                              '--format=posix', impfilename])
    if not output:
        dummy_syms(outfilename)
        return
    for line in output.split('\n'):
        if ' T ' not in line:
            continue
        result.append(line.split(maxsplit=1)[0])
    write_if_changed('\n'.join(result) + '\n', outfilename)

def _get_implib_dllname(impfilename: str) -> T.Tuple[T.List[str], str]:
    all_stderr = ''
    # First try lib.exe, which is provided by MSVC. Then llvm-lib.exe, by LLVM
    # for clang-cl.
    #
    # We cannot call get_tool on `lib` because it will look at the `LIB` env
    # var which is the list of library paths MSVC will search for import
    # libraries while linking.
    for lib in (['lib'], get_tool('llvm-lib')):
        output, e = call_tool_nowarn(lib + ['-list', impfilename])
        if output:
            # The output is a list of DLLs that each symbol exported by the import
            # library is available in. We only build import libraries that point to
            # a single DLL, so we can pick any of these. Pick the last one for
            # simplicity. Also skip the last line, which is empty.
            return output.split('\n')[-2:-1], None
        all_stderr += e
    # Next, try dlltool.exe which is provided by MinGW
    output, e = call_tool_nowarn(get_tool('dlltool') + ['-I', impfilename])
    if output:
        return [output], None
    all_stderr += e
    return ([], all_stderr)

def _get_implib_exports(impfilename: str) -> T.Tuple[T.List[str], str]:
    all_stderr = ''
    # Force dumpbin.exe to use en-US so we can parse its output
    env = os.environ.copy()
    env['VSLANG'] = '1033'
    output, e = call_tool_nowarn(get_tool('dumpbin') + ['-exports', impfilename], env=env)
    if output:
        lines = output.split('\n')
        start = lines.index('File Type: LIBRARY')
        end = lines.index('  Summary')
        return lines[start:end], None
    all_stderr += e
    # Next, try llvm-nm.exe provided by LLVM, then nm.exe provided by MinGW
    for nm in ('llvm-nm', 'nm'):
        output, e = call_tool_nowarn(get_tool(nm) + ['--extern-only', '--defined-only',
                                                     '--format=posix', impfilename])
        if output:
            result = []
            for line in output.split('\n'):
                if ' T ' not in line or line.startswith('.text'):
                    continue
                result.append(line.split(maxsplit=1)[0])
            return result, None
        all_stderr += e
    return ([], all_stderr)

def windows_syms(impfilename: str, outfilename: str):
    # Get the name of the library
    result, e = _get_implib_dllname(impfilename)
    if not result:
        print_tool_warning('lib, llvm-lib, dlltool', 'do not work or were not found', e)
        dummy_syms(outfilename)
        return
    # Get a list of all symbols exported
    symbols, e = _get_implib_exports(impfilename)
    if not symbols:
        print_tool_warning('dumpbin, llvm-nm, nm', 'do not work or were not found', e)
        dummy_syms(outfilename)
        return
    result += symbols
    write_if_changed('\n'.join(result) + '\n', outfilename)

def gen_symbols(libfilename: str, impfilename: str, outfilename: str, cross_host: str):
    if cross_host is not None:
        # In case of cross builds just always relink. In theory we could
        # determine the correct toolset, but we would need to use the correct
        # `nm`, `readelf`, etc, from the cross info which requires refactoring.
        dummy_syms(outfilename)
    elif mesonlib.is_linux() or mesonlib.is_hurd():
        gnu_syms(libfilename, outfilename)
    elif mesonlib.is_osx():
        osx_syms(libfilename, outfilename)
    elif mesonlib.is_openbsd():
        openbsd_syms(libfilename, outfilename)
    elif mesonlib.is_windows():
        if os.path.isfile(impfilename):
            windows_syms(impfilename, outfilename)
        else:
            # No import library. Not sure how the DLL is being used, so just
            # rebuild everything that links to it every time.
            dummy_syms(outfilename)
    elif mesonlib.is_cygwin():
        if os.path.isfile(impfilename):
            cygwin_syms(impfilename, outfilename)
        else:
            # No import library. Not sure how the DLL is being used, so just
            # rebuild everything that links to it every time.
            dummy_syms(outfilename)
    elif mesonlib.is_sunos():
        solaris_syms(libfilename, outfilename)
    else:
        if not os.path.exists(TOOL_WARNING_FILE):
            mlog.warning('Symbol extracting has not been implemented for this '
                         'platform. ' + RELINKING_WARNING)
            # Write it out so we don't warn again
            with open(TOOL_WARNING_FILE, 'w'):
                pass
        dummy_syms(outfilename)

def run(args):
    global TOOL_WARNING_FILE
    options = parser.parse_args(args)
    if len(options.args) != 4:
        print('symbolextractor.py <shared library file> <import library> <output file>')
        sys.exit(1)
    privdir = os.path.join(options.args[0], 'meson-private')
    TOOL_WARNING_FILE = os.path.join(privdir, 'symbolextractor_tool_warning_printed')
    libfile = options.args[1]
    impfile = options.args[2] # Only used on Windows
    outfile = options.args[3]
    gen_symbols(libfile, impfile, outfile, options.cross_host)
    return 0

if __name__ == '__main__':
    sys.exit(run(sys.argv[1:]))


text:
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;
using Microsoft.WindowsAzure.Management.SiteRecovery.Models;

namespace Microsoft.Azure.Commands.RecoveryServices
{
    /// <summary>
    /// Azure Site Recovery Storage.
    /// </summary>
    [SuppressMessage(
        "Microsoft.StyleCop.CSharp.MaintainabilityRules",
        "SA1402:FileMayOnlyContainASingleClass",
        Justification = "Keeping all related objects together.")]
    public class ASRStorage
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ASRStorage" /> class.
        /// </summary>
        public ASRStorage()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ASRStorage" /> class with required
        /// parameters.
        /// </summary>
        /// <param name="storage">Storage object</param>
        public ASRStorage(AsrStorage storage)
        {
            this.ID = storage.ID;
            this.Name = storage.Name;
            this.Type = storage.Type;
            this.FabricObjectID = storage.FabricObjectID;
            this.FabricType = storage.FabricType;
            this.ServerId = storage.ServerID;

            if (this.Type == StorageType.Pool.ToString())
            {
                this.StoragePools = storage.StoragePools;
            }
        }

        /// <summary>
        /// Storage Type.
        /// </summary>
        public enum StorageType
        {
            /// <summary>
            /// Unknown type.
            /// </summary>
            Other = 0,

            /// <summary>
            /// Classification type.
            /// </summary>
            Classification,

            /// <summary>
            /// Pool type.
            /// </summary>
            Pool,
        }

        #region Properties
        /// <summary>
        /// Gets or sets name of the Storage.
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets Storage ID.
        /// </summary>
        public string ID { get; set; }

        /// <summary>
        /// Gets or sets Fabric object ID.
        /// </summary>
        public string FabricObjectID { get; set; }

        /// <summary>
        /// Gets or sets Server Id.
        /// </summary>
        public string ServerId { get; set; }

        /// <summary>
        /// Gets or sets to Type of Storage.
        /// </summary>
        public string Type { get; set; }

        /// <summary>
        /// Gets or sets Fabric type.
        /// </summary>
        public string FabricType { get; set; }

        /// <summary>
        /// Gets or sets storage pools for storage arrays.
        /// </summary>
        public IList<StoragePool> StoragePools { get; set; }

        #endregion
    }

    /// <summary>
    /// Azure Site Recovery Storage Mapping.
    /// </summary>
    [SuppressMessage(
        "Microsoft.StyleCop.CSharp.MaintainabilityRules",
        "SA1402:FileMayOnlyContainASingleClass",
        Justification = "Keeping all related objects together.")]
    public class ASRStorageMapping
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ASRStorageMapping" /> class.
        /// </summary>
        public ASRStorageMapping()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ASRStorageMapping" /> class with required
        /// parameters.
        /// </summary>
        /// <param name="storageMapping">Storage mapping object</param>
        public ASRStorageMapping(StorageMapping storageMapping)
        {
            this.PrimaryServerId = storageMapping.PrimaryServerId;
            this.PrimaryStorageId = storageMapping.PrimaryStorageId;
            this.PrimaryStorageName = storageMapping.PrimaryStorageName;
            this.RecoveryServerId = storageMapping.RecoveryServerId;
            this.RecoveryStorageId = storageMapping.RecoveryStorageId;
            this.RecoveryStorageName = storageMapping.RecoveryStorageName;
        }

        #region Properties
        /// <summary>
        /// Gets or sets Primary server Id.
        /// </summary>
        public string PrimaryServerId { get; set; }

        /// <summary>
        /// Gets or sets Primary storage Id.
        /// </summary>
        public string PrimaryStorageId { get; set; }

        /// <summary>
        /// Gets or sets Primary storage name.
        /// </summary>
        public string PrimaryStorageName { get; set; }

        /// <summary>
        /// Gets or sets Recovery server Id.
        /// </summary>
        public string RecoveryServerId { get; set; }

        /// <summary>
        /// Gets or sets Recovery storage Id.
        /// </summary>
        public string RecoveryStorageId { get; set; }

        /// <summary>
        /// Gets or sets Recovery storage name.
        /// </summary>
        public string RecoveryStorageName { get; set; }
        #endregion
    }

    /// <summary>
    /// Azure Site Recovery Storage Pool Mapping.
    /// </summary>
    [SuppressMessage(
        "Microsoft.StyleCop.CSharp.MaintainabilityRules",
        "SA1402:FileMayOnlyContainASingleClass",
        Justification = "Keeping all related objects together.")]
    public class ASRStoragePoolMapping
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ASRStoragePoolMapping" /> class.
        /// </summary>
        public ASRStoragePoolMapping()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ASRStoragePoolMapping" /> class with required
        /// parameters.
        /// </summary>
        /// <param name="storagePoolMapping">Storage mapping object</param>
        public ASRStoragePoolMapping(StoragePoolMapping storagePoolMapping)
        {
            this.PrimaryServerId = storagePoolMapping.PrimaryServerId;
            this.PrimaryStoragePoolId = storagePoolMapping.PrimaryStoragePoolId;
            this.PrimaryStoragePoolName = storagePoolMapping.PrimaryStoragePoolName;
            this.RecoveryServerId = storagePoolMapping.RecoveryServerId;
            this.RecoveryStoragePoolId = storagePoolMapping.RecoveryStoragePoolId;
            this.RecoveryStoragePoolName = storagePoolMapping.RecoveryStoragePoolName;
        }

        #region Properties
        /// <summary>
        /// Gets or sets Primary server Id.
        /// </summary>
        public string PrimaryServerId { get; set; }

        /// <summary>
        /// Gets or sets Primary storage pool Id.
        /// </summary>
        public string PrimaryStoragePoolId { get; set; }

        /// <summary>
        /// Gets or sets Primary storage pool name.
        /// </summary>
        public string PrimaryStoragePoolName { get; set; }

        /// <summary>
        /// Gets or sets Recovery server Id.
        /// </summary>
        public string RecoveryServerId { get; set; }

        /// <summary>
        /// Gets or sets Recovery storage pool Id.
        /// </summary>
        public string RecoveryStoragePoolId { get; set; }

        /// <summary>
        /// Gets or sets Recovery storage pool name.
        /// </summary>
        public string RecoveryStoragePoolName { get; set; }
        #endregion
    }
}


text:
#ifndef PROC_H
#define PROC_H

/* Here is the declaration of the process table.  It contains the process'
 * registers, memory map, accounting, and message send/receive information.
 * Many assembly code routines reference fields in it.  The offsets to these
 * fields are defined in the assembler include file sconst.h.  When changing
 * 'proc', be sure to change sconst.h to match.
 */

struct proc {
  struct stackframe_s p_reg;	/* process' registers saved in stack frame */

#if (CHIP == INTEL)
  reg_t p_ldt_sel;		/* selector in gdt giving ldt base and limit*/
  struct segdesc_s p_ldt[4];	/* local descriptors for code and data */
				/* 4 is LDT_SIZE - avoid include protect.h */
#endif /* (CHIP == INTEL) */

#if (CHIP == M68000)
  reg_t p_splow;		/* lowest observed stack value */
  int p_trap;			/* trap type (only low byte) */
  char *p_crp;			/* mmu table pointer (really struct _rpr *) */
  int p_nflips;			/* statistics */
#if defined(FPP)
  struct fsave p_fsave;		/* FPP state frame and registers */
  int align2;			/* make the struct size a multiple of 4 */
#endif
#endif /* (CHIP == M68000) */

  reg_t *p_stguard;		/* stack guard word */

  int p_nr;			/* number of this process (for fast access) */

  char p_int_blocked;		/* nonzero if int msg blocked by busy task */
  char p_int_held;		/* nonzero if int msg held by busy syscall */
  struct proc *p_nextheld;	/* next in chain of held-up int processes */

  int p_flags;			/* SENDING, RECEIVING, etc. */
  struct mem_map p_map[NR_SEGS];/* memory map */
  pid_t p_pid;			/* process id passed in from MM */
  int p_priority;		/* task, server, or user process */

  clock_t user_time;		/* user time in ticks */
  clock_t sys_time;		/* sys time in ticks */
  clock_t child_utime;		/* cumulative user time of children */
  clock_t child_stime;		/* cumulative sys time of children */

  timer_t *p_exptimers;		/* list of expired timers */

  struct proc *p_callerq;	/* head of list of procs wishing to send */
  struct proc *p_sendlink;	/* link to next proc wishing to send */
  message *p_messbuf;		/* pointer to message buffer */
  int p_getfrom;		/* from whom does process want to receive? */
  int p_sendto;

  struct proc *p_nextready;	/* pointer to next ready process */
  sigset_t p_pending;		/* bit map for pending signals */
  unsigned p_pendcount;		/* count of pending and unfinished signals */

  char p_name[16];		/* name of the process */
};

/* Guard word for task stacks. */
#define STACK_GUARD	((reg_t) (sizeof(reg_t) == 2 ? 0xBEEF : 0xDEADBEEF))

/* Bits for p_flags in proc[].  A process is runnable iff p_flags == 0. */
#define NO_MAP		0x01	/* keeps unmapped forked child from running */
#define SENDING		0x02	/* set when process blocked trying to send */
#define RECEIVING	0x04	/* set when process blocked trying to recv */
#define PENDING		0x08	/* set when inform() of signal pending */
#define SIG_PENDING	0x10	/* keeps to-be-signalled proc from running */
#define P_STOP		0x20	/* set when process is being traced */

/* Values for p_priority */
#define PPRI_NONE	0	/* Slot is not in use */
#define PPRI_TASK	1	/* Part of the kernel */
#define PPRI_SERVER	2	/* System process outside the kernel */
#define PPRI_USER	3	/* User process */
#define PPRI_IDLE	4	/* Idle process */

/* Magic process table addresses. */
#define BEG_PROC_ADDR (&proc[0])
#define END_PROC_ADDR (&proc[NR_TASKS + NR_PROCS])
#define END_TASK_ADDR (&proc[NR_TASKS])
#define BEG_SERV_ADDR (&proc[NR_TASKS])
#define BEG_USER_ADDR (&proc[NR_TASKS + LOW_USER])

#define NIL_PROC          ((struct proc *) 0)
#define isidlehardware(n) ((n) == IDLE || (n) == HARDWARE)
#define isokprocn(n)      ((unsigned) ((n) + NR_TASKS) < NR_PROCS + NR_TASKS)
#define isoksrc_dest(n)   (isokprocn(n) || (n) == ANY)
#define isrxhardware(n)   ((n) == ANY || (n) == HARDWARE)
#define issysentn(n)      ((n) == FS_PROC_NR || (n) == MM_PROC_NR)
#define isemptyp(p)       ((p)->p_priority == PPRI_NONE)
#define istaskp(p)        ((p)->p_priority == PPRI_TASK)
#define isservp(p)        ((p)->p_priority == PPRI_SERVER)
#define isuserp(p)        ((p)->p_priority == PPRI_USER)
#define proc_addr(n)      (pproc_addr + NR_TASKS)[(n)]
#define cproc_addr(n)     (&(proc + NR_TASKS)[(n)])
#define proc_number(p)    ((p)->p_nr)
#define proc_vir2phys(p, vir) \
			  (((phys_bytes)(p)->p_map[D].mem_phys << CLICK_SHIFT) \
							+ (vir_bytes) (vir))

EXTERN struct proc proc[NR_TASKS + NR_PROCS];	/* process table */
EXTERN struct proc *pproc_addr[NR_TASKS + NR_PROCS];
/* ptrs to process table slots; fast because now a process entry can be found
   by indexing the pproc_addr array, while accessing an element i requires
   a multiplication with sizeof(struct proc) to determine the address */
EXTERN struct proc *bill_ptr;	/* ptr to process to bill for clock ticks */
EXTERN struct proc *rdy_head[NQ];	/* pointers to ready list headers */
EXTERN struct proc *rdy_tail[NQ];	/* pointers to ready list tails */

#endif /* PROC_H */


text:
package krasa.build.backend.facade;

import krasa.build.backend.dto.BuildableComponentDto;
import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
import org.apache.wicket.protocol.ws.api.message.IWebSocketPushMessage;

import java.io.Serializable;

public class ComponentChangedEvent implements Serializable, IWebSocketPushMessage {

	private IPartialPageRequestHandler handler;
	private BuildableComponentDto buildableComponentDto;

	public ComponentChangedEvent(BuildableComponentDto buildableComponentDto) {
		this.buildableComponentDto = buildableComponentDto;
	}

	public BuildableComponentDto getBuildableComponentDto() {
		return buildableComponentDto;
	}

	public IPartialPageRequestHandler getHandler() {
		return handler;
	}

	public void setHandler(IPartialPageRequestHandler handler) {
		this.handler = handler;
	}
}


text:
using ReMi.Commands.Auth;
using ReMi.Contracts.Cqrs.Commands;
using ReMi.DataAccess.BusinessEntityGateways.Auth;
using System;

namespace ReMi.CommandHandlers.Auth
{
    public class UpdateAccountCommandHandler : IHandleCommand<UpdateAccountCommand>
    {
        public Func<IAccountsGateway> AccountsGatewayFactory { get; set; }

        public void Handle(UpdateAccountCommand request)
        {
            using (var gateway = AccountsGatewayFactory())
            {
                gateway.UpdateAccount(request.Account);
            }
        }
    }
}


text:
toofr-chrome
============

Chrome extension for the Toofr API


text:
<?php

require_once __DIR__.'/../Base.php';

use Kanboard\Model\TaskFinder;
use Kanboard\Model\TaskCreation;
use Kanboard\Model\User;
use Kanboard\Model\Task;
use Kanboard\Model\Project;
use Kanboard\Model\UserUnreadNotification;

class UserUnreadNotificationTest extends Base
{
    public function testHasNotification()
    {
        $wn = new UserUnreadNotification($this->container);
        $p = new Project($this->container);
        $tf = new TaskFinder($this->container);
        $tc = new TaskCreation($this->container);
        $u = new User($this->container);

        $this->assertEquals(1, $p->create(array('name' => 'test')));
        $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));

        $this->assertFalse($wn->hasNotifications(1));

        $wn->create(1, Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));

        $this->assertTrue($wn->hasNotifications(1));
    }

    public function testMarkAllAsRead()
    {
        $wn = new UserUnreadNotification($this->container);
        $p = new Project($this->container);
        $tf = new TaskFinder($this->container);
        $tc = new TaskCreation($this->container);
        $u = new User($this->container);

        $this->assertEquals(1, $p->create(array('name' => 'test')));
        $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));

        $wn->create(1, Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));

        $this->assertTrue($wn->hasNotifications(1));
        $this->assertTrue($wn->markAllAsRead(1));

        $this->assertFalse($wn->hasNotifications(1));
        $this->assertFalse($wn->markAllAsRead(1));
    }

    public function testMarkAsRead()
    {
        $wn = new UserUnreadNotification($this->container);
        $p = new Project($this->container);
        $tf = new TaskFinder($this->container);
        $tc = new TaskCreation($this->container);
        $u = new User($this->container);

        $this->assertEquals(1, $p->create(array('name' => 'test')));
        $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));

        $wn->create(1, Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));

        $this->assertTrue($wn->hasNotifications(1));

        $this->assertFalse($wn->markAsRead(2, 1));
        $this->assertTrue($wn->markAsRead(1, 1));

        $this->assertFalse($wn->hasNotifications(1));
        $this->assertFalse($wn->markAsRead(1, 1));
    }

    public function testGetAll()
    {
        $wn = new UserUnreadNotification($this->container);
        $p = new Project($this->container);
        $tf = new TaskFinder($this->container);
        $tc = new TaskCreation($this->container);
        $u = new User($this->container);

        $this->assertEquals(1, $p->create(array('name' => 'test')));
        $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1)));

        $wn->create(1, Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));
        $wn->create(1, Task::EVENT_CREATE, array('task' => $tf->getDetails(1)));

        $this->assertEmpty($wn->getAll(2));

        $notifications = $wn->getAll(1);
        $this->assertCount(2, $notifications);
        $this->assertArrayHasKey('title', $notifications[0]);
        $this->assertTrue(is_array($notifications[0]['event_data']));
    }
}


text:
<?php

namespace Invisnik\LaravelSteamAuth;

use Illuminate\Support\Fluent;

class SteamInfo extends Fluent
{
    /**
     * {@inheritdoc}
     */
    public function __construct($data)
    {
        $steamID = $data['steamid'] ?? null;
        unset($data['steamid']);

        parent::__construct($data);

        $this->attributes['steamID64'] = $steamID;
    }
}


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" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta name="author" content="Ramirez Gonzalez Juan Jose"/>
    <meta name="author" content="kraker_orion@ciencias.unam.mx"/>
    <meta name="author" content="Hector E. Gomez Morales"/>
    <meta name="author" content="hectoregm@gmail.com"/>

    <meta name="description" content="Aplicaciones Web : Práctica 1"/>
    <meta name="keywords" content="aplicaciones web, practica 1, selene marisol martinez ramirez,
                                   facultad de ciencias, seminario de ciencias computacionales, unam, html, css"/>

    <title>Práctica 1 - Aplicaciones Web</title>

    <meta http-equiv="content-script-type" content="text/javascript"/>

    <meta http-equiv="content-style-type" content="text/css"/>
    <link type="text/css" rel="stylesheet" href="public/css/main.css" />
    <link type="text/css" rel="stylesheet" href="public/css/style.css" />
    <link type="text/css" rel="stylesheet"
          href="public/css/dojo_slideshow.css" />
    <link type="text/css" rel="stylesheet" id="currentStyle" href="public/css/liquid_layout_i.css" />

    <link type="image/vnd.microsoft.icon" rel="shortcut icon" href="public/images/favicon.gif"/>

          Práctica 1 - Aplicaciones Web

          Distribucion 'I'
          Distribucion 'H'
          Distribucion 'L'
          Distribucion 3C

Columna Derecha

          Lorem ipsum ad his scripta blandit partiendo, eum fastidii accumsan
          euripidis in, eum liber hendrerit an. Qui ut wisi vocibus suscipiantur, quo
          dicit ridens inciderint id. Quo mundi lobortis reformidans eu, legimus
          senserit definiebas an eos. Eu sit tincidunt incorrupte definitionem, vis
          mutat affert percipit cu, eirmod consectetuer signiferumque eu per. In
          usu latine equidem dolores. Quo no falli viris intellegam, ut fugit veritus
          placerat per. Ius id vidit volumus mandamus, vide veritus democritum te
          nec, ei eos debet libris consulatu. No mei ferri graeco dicunt, ad cum veri
          accommodare. Sed at malis omnesque delicata, usu et iusto zzril meliore.
          Dicunt maiorum eloquentiam cum cu, sit summo dolor essent te. Ne quodsi nusquam
          legendos has, ea dicit voluptua eloquentiam pro, ad sit quas qualisque. Eos
          vocibus deserunt quaestio ei. Blandit incorrupte quaerendum in quo, nibh
          impedit id vis, vel no nullam semper audiam. Ei populo graeci consulatu mei,
          has ea stet modus phaedrum. Inani oblique ne has, duo et veritus detraxit.
          Lorem ipsum ad his scripta blandit partiendo, eum fastidii accumsan
          euripidis in, eum liber

Columna Izquierda

              Distribucion 'I'

              Distribucion 'H'

              Distribucion 'L'

              Distribucion 3C

          Lorem ipsum ad his scripta blandit
          partiendo, eum fastidii accumsan
          euripidis in, eum liber hendrerit an.
          Qui ut wisi vocibus suscipiantur, quo
          dicit ridens inciderint id. Quo mundi
          lobortis reformidans eu, legimus
          senserit definiebas an eos. Eu sit
          tincidunt incorrupte definitionem,
          vis mutat affert percipit cu, eirmod
          consectetuer signiferumque eu per. In
          usu latine equidem dolores. Quo no
          falli viris intellegam, ut fugit veritus
          placerat per. Ius id vidit volumus
          mandamus, vide veritus democritum
          te nec,       ei eos debet libris consulatu.
          No mei ferri graeco dicunt, ad cum veri
          accommodare. Sed at malis omnesque delicata,
          usu et iusto zzril meliore.   Dicunt maiorum
          eloquentiam cum cu, sit summo dolor essent te.
          Ne quodsi nusquam legendos has, ea dicit
          voluptua eloquentiam pro, ad sit quas qualisque.
          Eos   vocibus deserunt quaestio ei. Blandit
          incorrupte quaerendum in quo, nibh impedit id
          vis, vel no nullam semper

Sección Principal

            Lorem ipsum ad his scripta blandit partiendo, eum fastidii accumsan
            euripidis in, eum liber hendrerit an. Qui ut wisi vocibus suscipiantur, quo
            dicit ridens inciderint id. Quo mundi lobortis reformidans eu, legimus
            senserit definiebas an eos. Eu sit tincidunt incorrupte definitionem, vis
            mutat affert percipit cu, eirmod consectetuer signiferumque eu per. In
            usu latine equidem dolores. Quo no falli viris intellegam, ut fugit veritus
            placerat per. Ius id vidit volumus mandamus, vide veritus democritum te
            nec, ei eos debet libris consulatu. No mei ferri graeco dicunt, ad cum veri
            accommodare. Sed at malis omnesque delicata, usu et iusto zzril meliore.
            Dicunt maiorum eloquentiam cum cu, sit summo dolor essent te. Ne quodsi nusquam
            legendos has, ea dicit voluptua eloquentiam pro, ad sit quas qualisque. Eos
            vocibus deserunt quaestio ei. Blandit incorrupte quaerendum in quo, nibh
            impedit id vis, vel no nullam semper audiam. Ei populo graeci consulatu mei,
            has ea stet modus phaedrum. Inani oblique ne has, duo et veritus detraxit.

          Práctica 1 - Aplicaciones Web

          Distribucion 'I'
          Distribucion 'H'
          Distribucion 'L'
          Distribucion 3C


text:
FROM debian:jessie

RUN apt-get update \
&& apt-get install -y curl \
&& rm -rf /var/lib/apt/lists/*

RUN curl -LO "https://nodejs.org/dist/v4.5.0/node-v4.5.0-linux-x64.tar.gz" \
&& tar -xzf node-v4.5.0-linux-x64.tar.gz -C /usr/local --strip-components=1 \
&& rm node-v4.5.0-linux-x64.tar.gz

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Bundle app source
COPY . /usr/src/app

# Install app dependencies
#RUN npm install

EXPOSE 5000
CMD [ "node", "src/scheduler.js" ]


text:
export enum BuildStatus {
  NOT_BUILT,
  NOT_BUILT_BUILDING,
  DISABLED,
  DISABLED_BUILDING,
  BLUE,
  BLUE_BUILDING,
  YELLOW,
  YELLOW_BUILDING,
  RED,
  RED_BUILDING,
  ABORTED,
  ABORTED_BUILDING,
  UNKNOWN
}


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

    require('./style.css');

    angular.module('mmNavigation', [])
        .controller('NavigationController', require('../src/controller.js'))
        .directive('mmNavigation', require('../src/directive.js'));

})();


text:
from __future__ import division

__author__ = "Jon Sanders"
__copyright__ = "Copyright 2014, Jon Sanders"
__credits__ = ["Jon Sanders"]
__license__ = "GPL"
__version__ = "1.9.1"
__maintainer__ = "Jon Sanders"
__email__ = "jonsan@gmail.com"
__status__ = "Development"

from qiime.util import load_qiime_config, parse_command_line_parameters,\
    get_options_lookup, make_option
from qiime.parse import parse_qiime_parameters, parse_taxonomy, parse_mapping_file_to_dict
from qiime.filter import sample_ids_from_metadata_description
from bfillings.uclust import get_clusters_from_fasta_filepath
from bfillings.usearch import usearch_qf

from scipy.stats import spearmanr
import os.path

from biom import load_table

import numpy as np

options_lookup = get_options_lookup()
script_info = {}
script_info['brief_description'] = """
A script to filter sequences by potential contaminants"""
script_info['script_description'] = """
This script performs a series of filtering steps on a sequence file with the
intent of removing contaminant sequences. It requires input of an OTU table, a
sample map, an OTU map, a sequence FASTA file, and an output directory.

There are two primary approaches the script can take: (1) comparing sequence
abundances in blank control sequence libraries to those in sample libraries,
where sequences present in blanks are presumed to be contaminants, and (2)
comparing sequences in sample libraries to a database of known contaminants.

In approach (1), OTUs (or unique sequences, if OTU table and map are defined at
100% identity) are tested for their maximum and mean presence in blank and
sample libraries, and excluded if they satisfy the given criteria. For example,
if you want to exclude any sequences whose maximum abundance in a blank sample
is more than 10% the maximum abundance in a sample (maxB > 0.1 * maxS), you
would choose '--removal_stat_blank maxB --removal_stat_sample maxS
--removal_differential 0.1'. For this approach, you must also provide a column
in your mapping file that indicates which samples to use as blanks, and pass
this information to the script with the 'valid states' option (e.g.
'Blank:True')

In approach (2), you must provide a fasta library of putative contaminants.
These may be previously clustered OTUs from the blank samples, commonly
sequenced contaminants (if known), or another fasta file. Sequences will be
clustered against this fasta file using Uclust-Ref, and any that match within
a given percent similarity (using the '-c' or '--contaminant_similarity' option)
will be marked as putative contaminants.

When using approach (2), it is possible to remove 'real' sequences from samples
that just happen to be similar to contaminants. This may be detectable when
using unique sequence OTU tables/maps as input, if the 'real' sequences are
nonetheless slightly different from contaminants. In this case, it may be
desireable to reinstate those unique sequences that are present in samples but
not in blanks. You may do this using criteria of relative abundance (similar to
approach [1], where a sequence is reinstated if its max presence in a sample is
greater than its max presence in a blank, i.e. maxS > X * maxB) or of incidence
in non-blank samples (i.e. reinstated if present in two or more samples). If
both criteria are provided, you must choose to reinstate either the intersection
of the criteria (i.e. BOTH more abundant in samples AND present in 2 or more)
or the union (i.e. EITHER more abundant in samples OR present in 2 or more).
"""
script_info['script_usage'] = []
script_info['script_usage'].append(("""Example:""", """
The following steps are performed by the command below:

1. Calculate max relative abundance of each sequence in samples and blanks

2. Identify sequences whose maximum abunance in blanks is more than 10% their
maximum abundance in samples.

3. Output OTU maps of sequences for which above is true, and for which above is
false.
""", """
decontaminate.py -i unique_seqs_otu_table.biom -o filter_out_dir
-m metadata_mapping_file.txt -f unique_seqs_rep_set.fna
-M unique_seqs_otus.txt -s 'Blank:True' --removal_stat_blank maxB
--removal_stat_sample maxS --removal_differential 0.1
"""))
script_info['output_description'] = """
This script will output a tab-delimited summary table, indicating the relative
abundance stats for each sequence considered, along with its fate at each step
of the process.

It will also output an OTU map for each category of sequences identified (e.g.
those never identified as contaminants, those identified as reference-based
contaminants, those identified as abundance-based contaminants, and those
reinstated). These OTU maps can then be used to filter in the input FASTA file.

Output file naming:
contamination_summary.txt -- tab-delimited per-sequence summary file
assed_otu_map.txt -- OTU map of non-contaminant sequences
ref_contaminants_otu_map.txt -- OTU map of reference contaminant sequences
abund_contaminants_otu_map.txt -- OTU map of abundance contaminant sequences
reinstated_contaminants_otu_map.txt -- OTU map of reinstated sequences
"""
script_info['required_options'] = [
    options_lookup["output_dir"]
    ]
script_info['optional_options'] = [
    options_lookup["otu_table_as_primary_input"],
    make_option('--mothur_counts_fp',
                type='existing_filepath',
                help='path to mothur counts table as input'),
    options_lookup["mapping_fp"],
    make_option('-M', '--otu_map_fp', type="existing_filepath",
                 help='the input OTU map file'),
    make_option('-s',
                '--valid_states', type='string',
                help="Column header:value pair in mapping file identifying blank samples"),
    make_option('--blank_id_fp',
                type='existing_filepath',
                help='path to file listing blank sample ids'),
    options_lookup["input_fasta"],
    make_option('--contaminant_db_fp', type="existing_filepath",
              help='A FASTA file of potential contaminant sequences'),
    make_option('-c', '--contaminant_similarity', type='float', default=0.97,
                help=('Sequence similarity threshold for contaminant matches')),
    make_option('-r', '--max_correlation', type='float',
                help=('Maximum Spearman correlation for contaminant identification')),
    make_option('--correlate_header', type='string',
                help=('Column header in mapping file with correlation data')),
    make_option('--min_relabund_threshold', type="float",
                help='discard sequences below this relative abundance threshold'),
    make_option('--prescreen_threshold', type="float",
                help='prescreen libraries that lose more than this proportion of sequences'),
    make_option('--removal_stat_blank', type="choice", choices=["maxB", "avgB"],
                 help='blank statistic to be used for removal (maxB, avgB)'),
    make_option('--removal_stat_sample', type="choice", choices=["maxS", "avgS"],
                 help='sample statistic to be used for removal (maxS, avgS)'),
    make_option('--removal_differential', type="float",
                 help='differential proportion for removal (maxB > X * maxS)'),
    make_option('--reinstatement_stat_blank', type="choice", choices=["maxB", "avgB"],
                 help='blank statistic to be used for reinstatement (maxB, avgB)'),
    make_option('--reinstatement_stat_sample', type="choice", choices=["maxS", "avgS"],
                 help='sample statistic to be used for reinstatement (maxS, avgS)'),
    make_option('--reinstatement_differential', type="float",
                 help='differential proportion for reinstatement (maxS > X * maxB)'),
    make_option('--reinstatement_sample_number', type="int",
                 help='minimum number of samples necessary for reinstatement'),
    make_option('--reinstatement_method', type="choice", choices=["union", "intersection"],
                 help='method to rectify reinstatement criteria'),
    make_option('--drop_lib_threshold', type="float",
                 help='read loss threshold to drop libraries from output table'),
    make_option('--write_filtered_output', action="store_true",
                 help='write an output table filtered of contaminants'),
    make_option('--write_per_library_stats', action="store_true",
                 help='write a per-library decontamination summary'),
    make_option('--write_per_seq_stats', action="store_true",
                 help='write a per-sequence decontamination summary'),
    make_option('--write_per_seq_disposition', action="store_true",
                 help='write a per-sequence disposition file'),
    make_option('--write_output_seq_lists', action="store_true",
                 help='write separate sequence name lists for each contaminant category')

    ]

script_info['version'] = __version__

def pick_ref_contaminants(queries, ref_db_fp, input_fasta_fp, contaminant_similarity, output_dir):
    # Blast against contaminant DB

    clusters, failures, seeds = get_clusters_from_fasta_filepath(
        input_fasta_fp,
        input_fasta_fp,
        percent_ID=contaminant_similarity,
        max_accepts=1,
        max_rejects=8,
        stepwords=8,
        word_length=8,
        optimal=False,
        exact=False,
        suppress_sort=False,
        output_dir=output_dir,
        enable_rev_strand_matching=False,
        subject_fasta_filepath=ref_db_fp,
        suppress_new_clusters=True,
        return_cluster_maps=True,
        stable_sort=False,
        save_uc_files=True,
        HALT_EXEC=False)

    # Pick seqs that fail the similarity to contaminants rule

    ref_contaminants = set(queries) - set(failures)

    return(ref_contaminants)

def pick_corr_contaminants(sample_biom,
                           corr_data_dict,
                           max_r):

    # Filter biom to only samples for which correlate data available
    sample_biom_filt = sample_biom.filter(
        lambda val, id_, metadata: id_ in corr_data_dict,
        invert=False,
        inplace=False)

    otus = sample_biom_filt.ids(axis='observation')
    samples = sample_biom_filt.ids(axis='sample')

    # Make array of correlate data in same order as biom file
    correlate = [corr_data_dict[x] for x in samples]

    obs_corr_dict = {}

    # Make a 2D array of normalized biom table values
    norm_array = sample_biom_filt.norm(inplace=False).matrix_data.toarray()

    t = 0

    for otu in otus:
        obs_corr_dict[otu] = spearmanr(norm_array[t], correlate)

        t += 1

    # get keys (otu names) for OTUs with less than minimum correlation
    obs_corr_contaminants = [x for x in obs_corr_dict if obs_corr_dict[x][0] < max_r]

    return(set(obs_corr_contaminants), obs_corr_dict)

def reinstate_abund_seqs(putative_contaminants,
                         contamination_stats_dict,
                         contamination_stats_header,
                         reinstatement_stat_sample,
                         reinstatement_stat_blank,
                         reinstatement_differential):

    abund_reinstated_seqs = compare_blank_abundances(contamination_stats_dict,
                            contamination_stats_header,
                            reinstatement_stat_sample,
                            reinstatement_stat_blank,
                            reinstatement_differential,
                            negate=False)

    # Only consider seqs as reinstated if previously identified as contaminants
    abund_reinstated_seqs = set(putative_contaminants) & set(abund_reinstated_seqs)

    return(abund_reinstated_seqs)

def reinstate_incidence_seqs(putative_contaminants,
                         unique_seq_biom,
                         blank_sample_ids,
                         reinstatement_sample_number):

    sample_biom = unique_seq_biom.filter(lambda val, id_, metadata:
        id_ in blank_sample_ids, invert=True, inplace=False)

    incidence_reinstated_seqs = sample_biom.pa().filter(
            lambda val, id_, metadata: val.sum() >= reinstatement_sample_number,
            axis='observation', inplace=False).ids(
            axis='observation')

    # Only consider seqs as reinstated if previously identified as contaminants
    incidence_reinstated_seqs = set(putative_contaminants) & set(incidence_reinstated_seqs)

    return(incidence_reinstated_seqs)

def mothur_counts_to_biom(mothur_fp):

    mothur_biom = load_table(mothur_fp)
    mothur_biom.type = u'OTU table'
    filter_biom = mothur_biom.filter(
        lambda val, id_, metadata: id_ in 'total', invert=True)

    return(filter_biom)

def biom_to_mothur_counts(biom_obj):

    sample_ids = biom_obj.ids(axis='sample')
    otu_ids = biom_obj.ids(axis='observation')
    otu_totals = biom_obj.sum(axis='observation')

    outstring = 'Representative_Sequence\ttotal\t' + '\t'.join(sample_ids) + '\n'

    for otu in otu_ids:
        otu_data = biom_obj.data(id = otu, axis = 'observation')
        outstring += '{0}\t{1}\t{2}\n'.format(otu,
                                              int(otu_data.sum()),
                                              '\t'.join(str(x) for x in otu_data.astype('int')))

    return(outstring)

def prescreen_libraries(unique_seq_biom,
                        blank_sample_ids,
                        removal_stat_sample,
                        removal_stat_blank,
                        removal_differential,
                        prescreen_threshold):

    contamination_stats_header, contamination_stats_dict = \
            get_contamination_stats(unique_seq_biom, blank_sample_ids)

    abund_contaminants = compare_blank_abundances(contamination_stats_dict,
                                contamination_stats_header,
                                removal_stat_sample,
                                removal_stat_blank,
                                removal_differential,
                                negate=True)

    # make relabund table
    norm_biom = unique_seq_biom.norm(inplace = False)

    # filter out sequences marked as contaminants
    norm_biom.filter(lambda val, id_, metadata: id_ in abund_contaminants,
                     axis='observation', invert=True, inplace=True)

    # filter out samples above threshold
    norm_biom.filter(lambda val, id_, metadata: sum(val) > prescreen_threshold,
                          axis='sample', invert=False, inplace=True)

    # Now only have samples failing the prescreening
    above_threshold_samples = norm_biom.ids(axis='sample')

    return above_threshold_samples

def get_contamination_stats(biom_file, blank_sample_ids=None, exp_sample_ids=[], proportional=False):
    if not proportional:
        biom_file = biom_file.norm(inplace=False)

    header = ['maxS','avgS']

    # Calculate blank stats if blank sample names are provided
    if blank_sample_ids:
        blanks = True

        blank_data = biom_file.filter(blank_sample_ids, axis='sample',
                                      invert=False, inplace=False).matrix_data
        maxB = blank_data.max(axis=1).todense().tolist()
        avgB = blank_data.mean(axis=1).tolist()

        header.append('maxB')
        header.append('avgB')
    else:
        # Otherwise, set the 'blanks' to an empty list
        blank_sample_ids = []
        blanks = False

    # If specific list of experimental sample IDs aren't provided,
    # assume everything not marked blank is an experimental sample

    if len(exp_sample_ids) == 0:
        exp_sample_ids = set(biom_file.ids(axis='sample')) - set(blank_sample_ids)

    sample_data = biom_file.filter(exp_sample_ids, axis='sample',
        invert=False, inplace=False).matrix_data

    maxS = sample_data.max(axis=1).todense().tolist()
    avgS = sample_data.mean(axis=1).tolist()

    stats_dict = {}

    i = 0
    if blanks:
        for otu in biom_file.ids(axis='observation'):
            stats_dict[otu] = [maxS[i][0], avgS[i][0], maxB[i][0], avgB[i][0]]
            i += 1
    else:
        for otu in biom_file.ids(axis='observation'):
            stats_dict[otu] = [maxS[i][0], avgS[i][0]]
            i += 1

    return(header, stats_dict)

def pick_min_relabund_threshold(stats_dict, stats_header, min_relabund, sample_stat='maxS'):

    i_s = stats_header.index(sample_stat)

    passed_otus = set()

    for otu in stats_dict:
        if(float(stats_dict[otu][i_s]) < float(min_relabund)):
            passed_otus.add(otu)

    return(passed_otus)

def compare_blank_abundances(stats_dict, stats_header,
                            sample_stat, blank_stat, scalar=1, negate=False):
    """Note that this method will default to returning sequences for which
    the criteria sample_stat > blank_stat * scalar are TRUE, i.e. non-contam
    sequences. To return contaminants (sequences that FAIL the inequality),
    set negate to True."""

    i_s = stats_header.index(sample_stat)
    i_b = stats_header.index(blank_stat)

    passed_otus = set()

    for otu in stats_dict:
        if((float(stats_dict[otu][i_s]) > (float(scalar) * float(stats_dict[otu][i_b]))) != negate):
            passed_otus.add(otu)

    # print passed_otus
    return(passed_otus)

def calc_per_category_decontam_stats(biom_obj, filter_otus):
    reads = biom_obj.filter(lambda val, id_, metadata: id_ in filter_otus,
                     axis='observation', invert=False, inplace=False).sum(axis = 'sample')
    otus = biom_obj.pa(inplace = False).filter(lambda val, id_, metadata: id_ in filter_otus,
                     axis='observation', invert=False, inplace=False).sum(axis = 'sample')

    return(reads.tolist(),otus.tolist())

def calc_per_library_decontam_stats(start_biom, output_dict):
    # calculate starting number of sequences and unique sequences per library

    steps = ['below_relabund_threshold','putative_contaminants','ever_good_seqs','reinstated_seqs','all_good_seqs']

    results_dict = {}

    results_dict['starting'] = calc_per_category_decontam_stats(start_biom, start_biom.ids(axis='observation'))
    results_header = ['starting']

    for step in steps:
        if step in output_dict:
            results_dict[step] = calc_per_category_decontam_stats(start_biom, output_dict[step])
            results_header.append(step)

    return(results_dict, results_header)

def filter_contaminated_libraries(unique_seq_biom, contaminant_otus, contam_threshold):
    # make relabund table
    norm_biom = unique_seq_biom.norm(inplace = False)

    # filter out sequences marked as contaminants
    norm_biom.filter(lambda val, id_, metadata: id_ in contaminant_otus,
                     axis='observation', invert=True, inplace=True)

    # filter out samples above threshold
    norm_biom.filter(lambda val, id_, metadata: sum(val) > contam_threshold,
                          axis='sample', invert=False, inplace=True)

    # filter contam sequences from original biom
    filtered_biom = unique_seq_biom.filter(lambda val, id_, metadata: id_ in contaminant_otus,
                     axis='observation', invert=True, inplace=False)

    # filter samples that lost too much relative to starting from original biom
    filtered_biom = filtered_biom.filter(lambda val, id_, metadata: id_ in norm_biom.ids(axis='sample'),
                     axis='sample', invert=False, inplace=True)

    return(filtered_biom)

def print_filtered_otu_map(input_otu_map_fp, output_otu_map_fp, filter_set):

    output_otu_map_f = open(output_otu_map_fp, 'w')
    for line in open(input_otu_map_fp, 'U'):
        seq_identifier = line.strip().split('\t')[0]
        # write OTU line if present in the filter set
        if seq_identifier in filter_set:
            output_otu_map_f.write(line)
    output_otu_map_f.close()
    return

def print_filtered_mothur_counts(mothur_counts_fp, output_counts_fp, filter_set):

    output_counts_f = open(output_counts_fp, 'w')

    t = 0

    for line in open(mothur_counts_fp, 'U'):
        seq_identifier = line.strip().split('\t')[0]

        # only write this line if the otu has more than n sequences (so
        # greater than n tab-separated fields including the otu identifier)
        # or if it's the header (first) line
        if seq_identifier in filter_set or t == 0:
            output_counts_f.write(line)
        t += 1

    output_counts_f.close()
    return

def print_per_library_stats(per_library_stats, per_library_stats_header, lib_ids, dropped_libs=[]):

    outline = 'Library\t'

    outline += '_reads\t'.join(per_library_stats_header) + '_reads\t'

    outline += '_otus\t'.join(per_library_stats_header) + '_otus'

    if len(dropped_libs) > 0:
        outline += '\tlibrary_discarded'
        discard = True
    else:
        discard = False

    outline += '\n'

    t = 0
    for lib in lib_ids:

        outline += lib

        for category in per_library_stats_header:
            outline += '\t' + str(int(per_library_stats[category][0][t]))

        for category in per_library_stats_header:
            outline += '\t' + str(int(per_library_stats[category][1][t]))

        if discard:
            if lib in dropped_libs:
                outline += '\tTrue'
            else:
                outline += '\tFalse'

        outline += '\n'

        t += 1

    return(outline)

def print_otu_disposition(input_seqs, output_dict, hierarchy=[]):
    outline = ''

    if hierarchy == []:
        hierarchy = ['below_relabund_threshold', 'putative_contaminants','reinstated_seqs','ever_good_seqs']

    # Subset hierarchy to levels also in output dict:

    hierarchy = [x for x in hierarchy if x in output_dict]

    # Check that the levels of the hierarchy are non-overlapping:

    for x in range(len(hierarchy) - 1):
        for y in range(x + 1,len(hierarchy)):
            if not output_dict[hierarchy[x]].isdisjoint(output_dict[hierarchy[y]]):
                print('warning: non-disjoint sets in the disposition hierarchy')

    seqs_left = set(input_seqs)

    for seq in input_seqs:
        for level in hierarchy:
            if seq in output_dict[level]:
                outline += '{0}\t{1}\n'.format(seq,level)
                break

    return(outline)

def print_filtered_seq_headers(seq_headers, output_headers_fp, filter_set):

    output_headers_f = open(output_headers_fp, 'w')

    for x in seq_headers:
        if x in filter_set:
            output_headers_f.write('{0}\n'.format(x))

    output_headers_f.close()
    return

def print_filtered_output(output_method, unfiltered_input, output_dir, output_dict, output_categories=None):
    output_fn = 'print_filtered_' + output_method

    if not output_categories:
        output_categories = output_dict.keys()

    if output_method == 'seq_headers':
        output_fn = print_filtered_seq_headers
    elif output_method == 'mothur_counts':
        output_fn = print_filtered_mothur_counts
    elif output_method == 'otu_map':
        output_fn = print_filtered_otu_map

    for category in output_categories:
        output_fn(unfiltered_input,
                  os.path.join(output_dir,
                          '{0}_{1}.txt'.format(category, output_method)),
                  output_dict[category])
    return

def print_results_file(seq_ids,
                       output_dict,
                       output_fp,
                       stats_header=None,
                       stats_dict=None,
                       corr_data_dict=None):

    output_f = open(output_fp, 'w')

    header = "SeqID"

    sorted_categories = sorted(output_dict.keys())

    for category in sorted_categories:
        header += '\t{0}'.format(category)

    if stats_header:
        for x in stats_header:
            header += '\t{0}'.format(x)

    if corr_data_dict:
        header += '\t{0}\t{1}'.format('spearman_r','spearman_p')

    output_f.write(header + '\n')

    for otu in seq_ids:
        outline = str(otu)

        for category in sorted_categories:
            outline += '\t{0}'.format(1 if otu in output_dict[category] else 0)

        if stats_header:
            t = 0
            for x in stats_header:
                outline += '\t{0:.3f}'.format(stats_dict[otu][t])
                t += 1

        if corr_data_dict:
            outline += '\t{0:.3f}\t{1:.3f}'.format(
                                           corr_data_dict[otu][0],
                                           corr_data_dict[otu][1])

        output_f.write(outline + '\n')

    return

def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)
    otu_table_fp = opts.otu_table_fp
    mothur_counts_fp = opts.mothur_counts_fp
    mapping_fp = opts.mapping_fp
    valid_states = opts.valid_states
    blank_id_fp = opts.blank_id_fp
    contaminant_db_fp = opts.contaminant_db_fp
    contaminant_similarity = opts.contaminant_similarity
    max_correlation = opts.max_correlation
    correlate_header = opts.correlate_header
    input_fasta_fp = opts.input_fasta_fp
    otu_map_fp = opts.otu_map_fp
    output_dir = opts.output_dir
    min_relabund_threshold = opts.min_relabund_threshold
    prescreen_threshold = opts.prescreen_threshold
    removal_stat_blank = opts.removal_stat_blank
    removal_stat_sample = opts.removal_stat_sample
    removal_differential = opts.removal_differential
    reinstatement_stat_sample = opts.reinstatement_stat_sample
    reinstatement_stat_blank = opts.reinstatement_stat_blank
    reinstatement_differential = opts.reinstatement_differential
    reinstatement_sample_number = opts.reinstatement_sample_number
    reinstatement_method = opts.reinstatement_method
    write_output_seq_lists = opts.write_output_seq_lists
    write_filtered_output = opts.write_filtered_output
    drop_lib_threshold = opts.drop_lib_threshold
    write_per_seq_stats = opts.write_per_seq_stats
    write_per_library_stats = opts.write_per_library_stats
    write_per_seq_disposition = opts.write_per_seq_disposition

    # Make unique seq OTU table (biom file)

    # Compute unique seq stats
    #   output biom file with unique seq stats

    # Optionally: make candidate contaminant DB
    #   remove sequences present at higher abundance in samples
    #   cluster blanks
    #   remove low-abundance contaminant OTUs

    # Filter by similarity against candidate contaminant DB
    #   annotate unique seq OTU table with top hit (OTU#, rep seq, ID%)
    #   make list of seqs @ threshold

    # Calculate reinstatement rule for filtered sequences

    # Generate lists of seqs failing:
    #   - unique seq rule
    #   - hit to contaminant
    #   - reinstatement after hit

    # Make sure passed at least one of an OTU biom or mothur counts table file
    input_file_counter = 0

    if mothur_counts_fp:
        input_file_counter += 1
        unique_seq_biom = mothur_counts_to_biom(mothur_counts_fp)
        mothur_output = True
        print "mothur input"

    if otu_table_fp:
        input_file_counter += 1
        unique_seq_biom = load_table(otu_table_fp)
        mothur_output = False
        print "BIOM input"

    if input_file_counter != 1:
        option_parser.error("must provide ONLY ONE of an OTU table biom file or"
                            "mothur counts table")

    # Check to make sure that if blank-based contamination filtering requested,
    # all necessary options are specified:

    removal_options_counter = 0
    if removal_stat_blank:
        removal_options_counter += 1
    if removal_stat_sample:
        removal_options_counter += 1
    if removal_differential:
        removal_options_counter += 1

    if ((removal_options_counter > 0) and (removal_options_counter < 3)):
        option_parser.error("Must provide all of "
                            "removal_stats_blank, "
                            "removal_stat_sample, and "
                            "removal_differential, or none.")
    elif removal_options_counter == 0:
        blank_stats_removal = False
    elif removal_options_counter == 3:
        blank_stats_removal = True

    # If reference-based filtering requested, make sure all necessary options
    # have been specified:

    if contaminant_db_fp and not input_fasta_fp:
        option_parser.error("If specifying ref-based contaminant ID, must "
                            "also specify path to input sequence fasta")

    # If correlation-based filtering requested, make sure correlate data
    # are specified

    if max_correlation and not correlate_header:
        option_parser.error("If specifying maximum Spearman correlation, must "
                           "also provide map column header for correlate data")

    # If sequence reinstatement is requested, make sure all necessary options
    # are specified

    reinstatement_options_counter = 0
    if reinstatement_stat_blank:
        reinstatement_options_counter += 1
    if reinstatement_stat_sample:
        reinstatement_options_counter += 1
    if reinstatement_differential:
        reinstatement_options_counter += 1

    if ((reinstatement_options_counter > 0) and
        (reinstatement_options_counter < 3)):
        option_parser.error("Must provide all of "
                            "reinstatement_stats_blank, "
                            "reinstatement_stat_sample, and "
                            "reinstatement_differential, or none.")

    if ((reinstatement_options_counter == 3 and reinstatement_sample_number)
        and not reinstatement_method):
        option_parser.error("If providing sample number AND abundance criteria "
                            "for sequence reinstatement, must also provide "
                            "a method for combining results.")

    if reinstatement_options_counter == 3 or reinstatement_sample_number:
        reinstatement = True
    else:
        reinstatement = False

    # get blank sample IDs from mapping file or sample ID list

    if mapping_fp and valid_states:
        blank_sample_ids = sample_ids_from_metadata_description(
            open(mapping_fp, 'U'), valid_states)
        blanks = True
    elif blank_id_fp is not None:
        blank_id_f = open(blank_id_fp, 'Ur')
        blank_sample_ids = set([line.strip().split()[0]
                                for line in blank_id_f
                                if not line.startswith('#')])
        blank_id_f.close()
        blanks = True
    else:
        blanks = False

    # Initialize output objets

    output_dict = {}
    contaminant_types = []

    contamination_stats_dict = None
    contamination_stats_header = None
    corr_data_dict = None

    # Do blank-based stats calculations, if not there check to make sure no
    # blank-dependent methods are requested:

    if blanks:
        if prescreen_threshold:
            low_contam_libraries = prescreen_libraries(unique_seq_biom,
                                                       blank_sample_ids,
                                                       removal_stat_sample,
                                                       removal_stat_blank,
                                                       removal_differential,
                                                       prescreen_threshold)

            contamination_stats_header, contamination_stats_dict = \
                get_contamination_stats(unique_seq_biom,
                                        blank_sample_ids,
                                        exp_sample_ids=low_contam_libraries)
        else:
            contamination_stats_header, contamination_stats_dict = \
                get_contamination_stats(unique_seq_biom, blank_sample_ids)

    elif (blank_stats_removal or reinstatement or prescreen_threshold):
        option_parser.error("Blank-based filtering requested but no blank"
                            "samples indicated in mapping file or ID file.")
    else:
        contamination_stats_header, contamination_stats_dict = \
            get_contamination_stats(unique_seq_biom)

    seq_ids = unique_seq_biom.ids(axis='observation')

    # Do blank-based contaminant identification

    if min_relabund_threshold:
        output_dict['below_relabund_threshold'] = pick_min_relabund_threshold(
                                                  contamination_stats_dict,
                                                  contamination_stats_header,
                                                  min_relabund_threshold)

    if blank_stats_removal:
        output_dict['abund_contaminants'] = compare_blank_abundances(contamination_stats_dict,
                                contamination_stats_header,
                                removal_stat_sample,
                                removal_stat_blank,
                                removal_differential,
                                negate=True)

        contaminant_types.append('abund_contaminants')

    # Do reference-based contaminant identification

    if contaminant_db_fp:
        output_dict['ref_contaminants'] = pick_ref_contaminants(seq_ids, contaminant_db_fp, input_fasta_fp, contaminant_similarity, output_dir)

        contaminant_types.append('ref_contaminants')

    # Do spearman correlation based contaminant identification

    if max_correlation:
        metadata_dict = parse_mapping_file_to_dict(open(mapping_fp, 'U'))[0]

        corr_data_dict = {x: float(metadata_dict[x][correlate_header]) for x in metadata_dict}

        output_dict['corr_contaminants'], corr_contaminant_dict = pick_corr_contaminants(unique_seq_biom,
                                                   corr_data_dict,
                                                   max_correlation)

        contaminant_types.append('corr_contaminants')
    else:
        corr_contaminant_dict = None

    # Putative contaminants are those that have been identified by any method

    output_dict['putative_contaminants'] = set.union(*map(set, [output_dict[x] for x in contaminant_types]))

    # If considering low abundance sequences, remove those from consideration as potential contaminants

    if 'below_relabund_threshold' in output_dict:
        output_dict['putative_contaminants'] = output_dict['putative_contaminants'] - set(output_dict['below_relabund_threshold'])

    # Pick abundance-criterion seqs to reinstate

    if (reinstatement_stat_blank and reinstatement_stat_sample and reinstatement_differential):
        output_dict['abund_reinstated_seqs'] = reinstate_abund_seqs(output_dict['putative_contaminants'],
                     contamination_stats_dict,
                     contamination_stats_header,
                     reinstatement_stat_sample,
                     reinstatement_stat_blank,
                     reinstatement_differential)

        output_dict['reinstated_seqs'] = output_dict['abund_reinstated_seqs']

    # Pick incidence-criterion seqs to reinstate
    if reinstatement_sample_number:
        output_dict['incidence_reinstated_seqs'] = reinstate_incidence_seqs(
                     output_dict['putative_contaminants'],
                     unique_seq_biom,
                     blank_sample_ids,
                     reinstatement_sample_number)

        output_dict['reinstated_seqs'] = output_dict['incidence_reinstated_seqs']

    # combine incidence and abundance reinstatements
    if reinstatement_sample_number and reinstatement_stat_blank:
        if reinstatement_method == "union":
            output_dict['reinstated_seqs'] = output_dict['abund_reinstated_seqs'] | output_dict['incidence_reinstated_seqs']
        elif reinstatement_method == "intersection":
            output_dict['reinstated_seqs'] = output_dict['abund_reinstated_seqs'] & output_dict['incidence_reinstated_seqs']

    # make sets for sequence _never_ identified as contaminants:

    output_dict['ever_good_seqs'] = set(seq_ids) - output_dict['putative_contaminants']

    # If considering low abundance sequences, remove those from consideration as potential contaminants

    if 'below_relabund_threshold' in output_dict:
        output_dict['ever_good_seqs'] = output_dict['ever_good_seqs'] - set(output_dict['below_relabund_threshold'])

    # Make set of good seqs for final filtering

    final_good_seqs = output_dict['ever_good_seqs']

    # ...and those either never ID'd as contaminants or reinstated:
    if reinstatement:
        output_dict['all_good_seqs'] = set(output_dict['ever_good_seqs'] | output_dict['reinstated_seqs'])
        final_good_seqs = output_dict['all_good_seqs']
        # ...and those who remain contaminants after reinstatement:
        output_dict['never_good_seqs'] = set(output_dict['putative_contaminants'] - output_dict['reinstated_seqs'])

    # print filtered OTU maps if given a QIIME OTU map input

    if otu_map_fp:
        print_filtered_output('otu_map', otu_map_fp, output_dir, output_dict)

    # print filtered Mothur counts tables if given a Mothur counts table input

    if mothur_output:
        print_filtered_output('mothur_counts', mothur_counts_fp, output_dir, output_dict)

    # print filtered seq header files if requested

    if write_output_seq_lists:
        print_filtered_output('seq_headers', seq_ids, output_dir, output_dict)

    # filter final biom file to just good seqs

    filtered_biom = unique_seq_biom.filter(lambda val, id_, metadata: id_ in final_good_seqs,
                     axis='observation', invert=False, inplace=False)

    # drop heavily contaminated libraries if requested

    if drop_lib_threshold:
        dropped_libs = unique_seq_biom.norm(inplace=False).filter(lambda val, id_, metadata: id_ in final_good_seqs,
                 axis='observation', invert=False, inplace=False).filter(lambda val, id_, metadata: sum(val) >= drop_lib_threshold,
                 axis='sample', invert=True, inplace=False).ids(axis='sample')
        filtered_biom.filter(lambda val, id_, metadata: id_ in dropped_libs,
                 axis='sample', invert=True, inplace=True)
    else:
        dropped_libs = []

    # print filtered biom/mothur_output if library filtering is requested

    if write_filtered_output:

        if mothur_output:
            output_counts_string = biom_to_mothur_counts(filtered_biom)
            with open(os.path.join(output_dir,'decontaminated_table.counts'), "w") as output_counts_file:
                output_counts_file.write(output_counts_string)
        else:
            output_biom_string = filtered_biom.to_json('Filtered by decontaminate.py')
            output_biom_string
            with open(os.path.join(output_dir,'decontaminated_otu_table.biom'), "w") as output_biom_file:
                output_biom_file.write(output_biom_string)

    # print per-library stats if requested

    if write_per_library_stats:
        per_library_stats, per_library_stats_header = calc_per_library_decontam_stats(unique_seq_biom, output_dict)
        library_stats_string = print_per_library_stats(per_library_stats, per_library_stats_header, unique_seq_biom.ids(axis='sample'), dropped_libs=dropped_libs)

        with open(os.path.join(output_dir,'decontamination_per_library_stats.txt'), "w") as output_stats_file:
            output_stats_file.write(library_stats_string)

    # print otu by disposition file if requested

    if write_per_seq_disposition:
        per_seq_disposition = print_otu_disposition(seq_ids, output_dict)

        with open(os.path.join(output_dir,'decontamination_per_otu_disposition.txt'), "w") as output_stats_file:
            output_stats_file.write(per_seq_disposition)

    # print log file / per-seq info
    if write_per_seq_stats:
        print_results_file(seq_ids,
                       output_dict,
                       os.path.join(output_dir,'contamination_summary.txt'),
                       contamination_stats_header,
                       contamination_stats_dict,
                       corr_contaminant_dict)

if __name__ == "__main__":
    main()


text:
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace UnrealBuildTool
{
	public interface IUEBuildDeploy
	{
		/**
		 * Register the platform with the UEBuildDeploy class.
		 */
		void RegisterBuildDeploy();

		/**
		 * Prepare the target for deployment.
		 *
		 * @param InTarget The target for deployment.
		 *
		 * @return bool True if successful, false if not.
		 */
		bool PrepTargetForDeployment(UEBuildTarget InTarget);

		/**
		 * Prepare the target for deployment.
		 */
		bool PrepForUATPackageOrDeploy(string ProjectName, string ProjectDirectory, string ExecutablePath, string EngineDirectory, bool bForDistribution, string CookFlavor, bool bIsDataDeploy);
	}

	/// <summary>
	///  Base class to handle deploy of a target for a given platform
	/// </summary>
	public abstract class UEBuildDeploy : IUEBuildDeploy
	{
		static Dictionary<UnrealTargetPlatform, IUEBuildDeploy> BuildDeployDictionary = new Dictionary<UnrealTargetPlatform, IUEBuildDeploy>();

		/**
		 *	Register the given platforms UEBuildDeploy instance
		 *
		 *	@param	InPlatform			The UnrealTargetPlatform to register with
		 *	@param	InBuildDeploy		The UEBuildDeploy instance to use for the InPlatform
		 */
		public static void RegisterBuildDeploy(UnrealTargetPlatform InPlatform, IUEBuildDeploy InBuildDeploy)
		{
			if (BuildDeployDictionary.ContainsKey(InPlatform) == true)
			{
				Log.TraceWarning("RegisterBuildDeply Warning: Registering build deploy {0} for {1} when it is already set to {2}",
					InBuildDeploy.ToString(), InPlatform.ToString(), BuildDeployDictionary[InPlatform].ToString());
				BuildDeployDictionary[InPlatform] = InBuildDeploy;
			}
			else
			{
				BuildDeployDictionary.Add(InPlatform, InBuildDeploy);
			}
		}

		/**
		 *	Retrieve the UEBuildDeploy instance for the given TargetPlatform
		 *
		 *	@param	InPlatform			The UnrealTargetPlatform being built
		 *
		 *	@return	UEBuildDeploy		The instance of the build deploy
		 */
		public static IUEBuildDeploy GetBuildDeploy(UnrealTargetPlatform InPlatform)
		{
			if (BuildDeployDictionary.ContainsKey(InPlatform) == true)
			{
				return BuildDeployDictionary[InPlatform];
			}
			// A platform does not *have* to have a deployment handler...
			return null;
		}

		/**
		 *	Register the platform with the UEBuildDeploy class
		 */
		public abstract void RegisterBuildDeploy();

		/**
		 *	Prepare the target for deployment
		 *
		 *	@param	InTarget		The target for deployment
		 *
		 *	@return	bool			true if successful, false if not
		 */
		public virtual bool PrepTargetForDeployment(UEBuildTarget InTarget)
		{
			return true;
		}

		/**
		 * Prepare the target for deployment
		 */
		public virtual bool PrepForUATPackageOrDeploy(string ProjectName, string ProjectDirectory, string ExecutablePath, string EngineDirectory, bool bForDistribution, string CookFlavor, bool bIsDataDeploy)
		{
			return true;
		}
	}
}


text:
package OpenXPKI::Server::Workflow::Activity::CRLIssuance::ImportCRL;

use strict;
use base qw( OpenXPKI::Server::Workflow::Activity );

use OpenXPKI::Server::Context qw( CTX );
use OpenXPKI::Exception;
use OpenXPKI::Template;
use OpenXPKI::Debug;
use Data::Dumper;
use File::Temp;
use MIME::Base64;
use Workflow::Exception qw(configuration_error);

sub execute {

    ##! 1: 'start'

    my $self = shift;
    my $workflow = shift;

    my $data = $self->param('data');

    my $target_key = $self->param('target_key') || 'crl_serial';

    if ($data) {
        my $crl = CTX('api')->import_crl({ DATA => $data });
        $workflow->context()->param( { $target_key => $crl->{crl_key} } );
    } else {
        $workflow->context()->param( { $target_key => undef } );
    }
    return 1;
}

1;
__END__

=head1 Name

OpenXPKI::Server::Workflow::Activity::CRLIssuance::ImportCRL

=head1 Description

This activity can be used to import CRLs into the system. It should be
used for externally controlled realms only.

=head2 Activity Configuration

=over

=item data

Must hold the PEM encoded CRL to import, activity will return without error
if this is empty.

=item target_key

Name of context key to write the serial number of the imported CRL to.
Optional, default is crl_serial.

=back


text:
include Makefile.variable

announce:
	$(call becho,"=== Ello Streams Project ===")

get-tools:
	@go get -u "github.com/Masterminds/glide"
	@go build "github.com/Masterminds/glide"
	@go get -u "github.com/alecthomas/gometalinter"
	# This is broken for the moment due to https://github.com/opennota/check/issues/25
	# When that's fixed we can go back to the `gometalinter` command instead of individual installs
	# @gometalinter --install --update --force
	@go get -u -f "golang.org/x/tools/cmd/goimports"
	@go get -u -f "github.com/kisielk/errcheck"
	@go get -u -f "github.com/gordonklaus/ineffassign"
	@go get -u -f "github.com/mibk/dupl"
	@go get -u -f "github.com/alecthomas/gometalinter"
	@go get -u -f "golang.org/x/tools/cmd/gotype"
	@go get -u -f "github.com/tsenart/deadcode"
	@go get -u -f "github.com/alecthomas/gocyclo"
	@go get -u -f "github.com/mvdan/interfacer/cmd/interfacer"
	@go get -u -f "github.com/golang/lint/golint"
	@$(PRINT_OK)

install:export GO15VENDOREXPERIMENT=1
install: test
	@echo "=== go install ==="
	@go install -ldflags=$(GOLDFLAGS)
	@$(PRINT_OK)

# From streams

all: test build docker

setup: announce get-tools dependencies

#TODO Try getting rid of the vendor flag env var after 1.6 is out
dependencies:export GO15VENDOREXPERIMENT=1
dependencies:
	@glide install
	@glide rebuild
	@$(PRINT_OK)

clean:
	@rm -rf vendor
	@rm -rf bin
	@$(PRINT_OK)

vet:export GO15VENDOREXPERIMENT=1
vet:
	@go vet `glide novendor`
	@$(PRINT_OK)

# TODO Re-enable these linters once vendor support is better (potentially 1.6)
lint:export GO15VENDOREXPERIMENT=1
lint:
	@gometalinter --vendor  --deadline=10s --disable=gotype --disable=varcheck --disable=aligncheck --disable=structcheck --disable=errcheck --disable=interfacer --dupl-threshold=70 `glide novendor`
	@$(PRINT_OK)

fmt:export GO15VENDOREXPERIMENT=1
fmt:
	@gofmt -s -w `glide nv | sed 's/\.\.\./*.go/g' | sed 's/.\///'`
	@$(PRINT_OK)

build:export GO15VENDOREXPERIMENT=1
build:
	@mkdir -p bin/
	@go build -ldflags $(GOLDFLAGS) -o bin/streams
	@$(PRINT_OK)

rebuild: clean build

docker: test
	@docker build -t streams . > /dev/null 2>&1
	@$(PRINT_OK)

test:export GO15VENDOREXPERIMENT=1
test:export LOGXI=dat:sqlx=off
test: fmt vet lint
	@go test `glide novendor` -cover
	@$(PRINT_OK)

server:export GO15VENDOREXPERIMENT=1
server:
	@go run main.go

server-w:
	@gin -a 8080 -i run

.PHONY: setup cloc errcheck vet lint fmt install build test deploy docker