text:
package com.ilscipio.scipio.ce.webapp.ftl.doc;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * scipio-lib template helper.
 *

 * An instance of this is stored as tmplHelper in data model.
 */
public class ScipioLibTemplateHelper extends TemplateHelper {
    // NOTE: some of the Parser methods could actually be moved here, but don't need for now

    public ScipioLibTemplateHelper(String inFileExtension, String outFileExtension) {
        super(inFileExtension, outFileExtension);
    }

    private static final Pattern bulletPat = Pattern.compile(
            "^([ ]*)[*]"
            , Pattern.DOTALL + Pattern.MULTILINE);

    /**
     * WARN: assumes no trailing whitespace
     */
    public boolean hasBulletList(String text) {
        return bulletPat.matcher(text).find();
    }

    private static final Pattern textLibEntryRefPat = Pattern.compile(
            "([a-zA-Z0-9][a-zA-Z0-9/._-]*[a-zA-Z0-9])?([@#])([a-zA-Z0-9_]{2,})"
            , Pattern.DOTALL);

    /**
     * Parses the text for lib-entry like references, basically those containing
     * "@" or "#" characters, and returns a list where each entry is either
     * a piece of text or a map describing a link to an entry.
     */
    public List<Object> splitByLibEntryRefs(String text, Map<String, Map<String, Object>> entryMap,
            Map<String, Map<String, Object>> libMap) {
        List<Object> textList = new ArrayList<>();

        Matcher m = textLibEntryRefPat.matcher(text);

        int lastEndIndex = 0;
        while(m.find()) {
            // Add text in between
            if (lastEndIndex < m.start()) {
                textList.add(text.substring(lastEndIndex, m.start()));
            }

            String ref = m.group();

            Map<String, Object> entryInfo = findEntryGlobal(ref, entryMap, libMap);
            if (entryInfo != null) {
                textList.add(entryInfo);
            }
            else {
                // Got nothing. Just add as regular text, BUT if the previous was regular
                // text, combine it so don't affect other parsing
                if (textList.size() > 0) {
                    Object lastText = textList.get(textList.size() - 1);
                    if (lastText instanceof String) {
                        textList.remove(textList.size() - 1);
                        textList.add(((String) lastText) + ref);
                    }
                    else {
                        textList.add(ref);
                    }
                }
                else {
                    textList.add(ref);
                }
            }

            lastEndIndex = m.end();
        }

        // Add last part, but combine with previous if was only text
        if (lastEndIndex < text.length()) {
            String finalPart = text.substring(lastEndIndex);
            if (textList.size() > 0) {
                Object lastText = textList.get(textList.size() - 1);
                if (lastText instanceof String) {
                    textList.remove(textList.size() - 1);
                    textList.add(((String) lastText) + finalPart);
                }
                else {
                    textList.add(finalPart);
                }
            }
            else {
                textList.add(finalPart);
            }
        }
        return textList;
    }

    private static final Pattern rawTextPat = Pattern.compile(
            "\\[\\[\\[(.*?)\\]\\]\\]"
            , Pattern.DOTALL);
    private static final Pattern plainTextPat = Pattern.compile(
            "\\(\\(\\((.*?)\\)\\)\\)"
            , Pattern.DOTALL);

    private static final Pattern codeTextPat = Pattern.compile(
            "\\{\\{\\{(.*?)\\}\\}\\}"
            , Pattern.DOTALL);

    private static final Pattern linkManualPat = Pattern.compile(
            ">>>(.*?)<<<"
            , Pattern.DOTALL);

    private static final Pattern linkAutoPat = Pattern.compile(
            "(^|\\b)((https?|file)://([^)\\s\\n])+)"
            , Pattern.DOTALL);

    @SuppressWarnings("unchecked")
    private Object fixupLink(Object linkObj, Map<String, Map<String, Object>> entryMap,
            Map<String, Map<String, Object>> libMap, Map<String, Object> libInfo) {
        if (linkObj instanceof Map && ((Map<String, Object>) linkObj).get("type").equals("link")) {
            Map<String, Object> linkInfo = (Map<String, Object>) linkObj;

            msgHandler.logDebug(
                    "====================================\n" +
                    "linkInfo: " + linkInfo.toString() + "\n" +
                    "====================================");

            // FIXME?: Currently only support href==label
            String value = (String) linkInfo.get("value");

            if (value.startsWith("http://") || value.startsWith("https://") || value.startsWith("file://") || value.startsWith("//")) {
                // absolute, do nothing
                linkInfo.put("text", value);
            }
            else if (value.startsWith("/")) {
                // absolute to server, do nothing
                linkInfo.put("text", value);
            }
            else if (value.startsWith("./")) {
                // relative to current, just strip the prefix
                value = value.substring(2);
                linkInfo.put("text", value);

                // 2016-10-27: check if this is a valid doc link, so template can process it
                if (libMap.containsKey(value) ||
                        (value.endsWith(inFileExtension) && libMap.containsKey(value.substring(0, value.length() - inFileExtension.length())))) {
                    linkInfo.put("isDocLink", Boolean.TRUE);
                }
            }
            else if (value.startsWith("../")) {
                // relative to current
                // WARN: this currently bypasses the auto-doc stuff
                linkInfo.put("text", value);
            }
            else {
                //String libDocPath = (String) libInfo.get("libDocPath");
                linkInfo.put("text", value);
                // 2016-10-27: let the template process the link instead
                // relative to doc root. need to adjust the link.
                //value = getTargetRelLibDocPath(value, libDocPath);

                // 2016-10-27: check if this is a valid doc link, so template can process it
                if (libMap.containsKey(value) ||
                        (value.endsWith(inFileExtension) && libMap.containsKey(value.substring(0, value.length() - inFileExtension.length())))) {
                    linkInfo.put("isDocLink", Boolean.TRUE);
                }
            }
            if (value.endsWith(inFileExtension)) {
                value = value.substring(0, value.length() - inFileExtension.length()) + outFileExtension;
            }
            linkInfo.put("value", value);
            return linkInfo;
        }
        else {
            return linkObj;
        }
    }

    /**
     * Splits by [[[, ]]], (((, ))), {{{, }}}, and potential entry refs.
     */
    public List<Object> splitByTextualElems(String text, Map<String, Map<String, Object>> entryMap,
            Map<String, Map<String, Object>> libMap, Map<String, Object> libInfo) {
        List<Object> res;
        Map<String, Object> modelMap;
        List<Object> prevSplit;

        msgHandler.logDebug(
                "====================================\n" +
                "splitByTextualElems: " + (text.length() > 400 ? text.substring(0, 399) : text) + "\n" +
                "====================================");

        // split by raw text
        modelMap = FtlDocFileParser.makeObjectMap();
        modelMap.put("type", "text-raw");
        res = splitByPat(text, rawTextPat, modelMap, "origText", "value");

        // split remaining text parts by plain pat
        prevSplit = res;
        res = new ArrayList<>();
        modelMap = FtlDocFileParser.makeObjectMap();
        modelMap.put("type", "text-plain");
        for(Object part : prevSplit) {
            if (part instanceof String) {
                List<Object> listSplit = splitByPat((String) part, plainTextPat, modelMap, "origText", "value");
                res.addAll(listSplit);
            }
            else {
                res.add(part);
            }
        }

        // split remaining text parts by code pat
        prevSplit = res;
        res = new ArrayList<>();
        modelMap = FtlDocFileParser.makeObjectMap();
        modelMap.put("type", "text-code");
        for(Object part : prevSplit) {
            if (part instanceof String) {
                List<Object> listSplit = splitByPat((String) part, codeTextPat, modelMap, "origText", "value");
                res.addAll(listSplit);
            }
            else {
                res.add(part);
            }
        }

        // split remaining text parts by entry refs
        prevSplit = res;
        res = new ArrayList<>();
        for(Object part : prevSplit) {
            if (part instanceof String) {
                List<Object> listSplit = splitByLibEntryRefs((String) part, entryMap, libMap);
                res.addAll(listSplit);
            }
            else {
                res.add(part);
            }
        }

        // split remaining text parts by manual links
        prevSplit = res;
        res = new ArrayList<>();
        modelMap = FtlDocFileParser.makeObjectMap();
        modelMap.put("type", "link");
        for(Object part : prevSplit) {
            if (part instanceof String) {
                List<Object> listSplit = splitByPat((String) part, linkManualPat, modelMap, "origText", "value");
                List<Object> fixupListSplit = new ArrayList<>();
                for(Object listObj : listSplit) {
                    fixupListSplit.add(fixupLink(listObj, entryMap, libMap, libInfo));
                }
                res.addAll(fixupListSplit);
            }
            else {
                res.add(part);
            }
        }

        // split remaining text parts by automatic links
        prevSplit = res;
        res = new ArrayList<>();
        modelMap = FtlDocFileParser.makeObjectMap();
        modelMap.put("type", "link");
        for(Object part : prevSplit) {
            if (part instanceof String) {
                List<Object> listSplit = splitByPat((String) part, linkAutoPat, modelMap, "origText", null, "value");
                List<Object> fixupListSplit = new ArrayList<>();
                for(Object listObj : listSplit) {
                    fixupListSplit.add(fixupLink(listObj, entryMap, libMap, libInfo));
                }
                res.addAll(fixupListSplit);
            }
            else {
                res.add(part);
            }
        }

        // debug
        /*
        for(Object part : res) {
            if (part instanceof Map) {
                String type = (String) ((Map<String, Object>) part).get("type");
                if ("text-code".equals(type)) {
                    msgHandler.logDebug("text-code: " + part);
                }
                else if ("text-raw".equals(type)) {
                    msgHandler.logDebug("text-raw: " + part);
                }
            }
        }*/

        return res;
    }

    // NOTE: don't end this with $; capture the newline
    private static final Pattern strictTitlePat = Pattern.compile(
            "^[ ]*[*][ ]*([^*\\n]*?)[ ]*[*][ ]*(\\n|\\z)"
            , Pattern.DOTALL + Pattern.MULTILINE);

    /**
     * Splits text into a list of maps (titles) and strings (regular text).
     * Only parses strict top-level titles.
     */
    public List<Object> splitByTitles(String text) {
        Map<String, Object> modelMap = FtlDocFileParser.makeObjectMap();
        modelMap.put("type", "title");
        return splitByPat(text, strictTitlePat, modelMap, "origText", "value");
    }

    /**
     * Splits text into a list of maps (indented blocks) and strings (regular text).
     * Only parses strict top-level titles.
     */
    @SuppressWarnings("unchecked")
    public List<Object> splitByIndentBlocks(String text, int minSize, int maxSize) {
        // NOTE: don't use $ here; capture newline
        final Pattern indentLinePat = Pattern.compile(
                "^([ ]" + makeRegexRangeExpr(minSize, maxSize) + ")(\\S.*)(\\n|\\z)"
                , Pattern.MULTILINE); // NOTE: no DOTALL

        // Get all the indented lines
        Map<String, Object> modelMap = FtlDocFileParser.makeObjectMap();
        modelMap.put("type", "indent");
        List<Object> lineList = splitByPat(text, indentLinePat, modelMap, "origText", "indentSpaces", "value");

        // Combine the lines into blocks
        int lastBlockIndentSize = 0;

        msgHandler.logDebug(
                "====================================\n" +
                "splitByIndentBlocks: entry count: " + lineList.size() + "\n" +
                "====================================");

        List<Object> res = new ArrayList<>();
        for(Object entry : lineList) {
            if (entry instanceof String) {
                String entryText = (String) entry;

                msgHandler.logDebug("TEXT: " + entryText);

                res.add(entryText);
                // a piece of text breaking up a code block
                lastBlockIndentSize = 0;

                msgHandler.logDebug("did reset");
            }
            else {
                Map<String, Object> lineInfo = (Map<String, Object>) entry;

                String indentSpaces = (String) lineInfo.get("indentSpaces");
                int indentSize = indentSpaces.length();
                lineInfo.put("indentSize", indentSize);

                msgHandler.logDebug("INDENT LINE: " + lineInfo.get("value").toString());

                msgHandler.logDebug("indentSize " + indentSize + " lastBlockIndentSize " + lastBlockIndentSize );

                if (lastBlockIndentSize > 0 && indentSize >= lastBlockIndentSize) {
                    msgHandler.logDebug("append: indentSize " + indentSize + " lastBlockIndentSize " + lastBlockIndentSize);

                    // combine with last line
                    Map<String, Object> blockInfo = (Map<String, Object>) res.get(res.size() - 1);
                    // Add the text, but make sure to keep right number of spaces

                    String blockText = (String) blockInfo.get("value");
                    String lineText = (String) lineInfo.get("value");

                    blockText += "\n"; // excluded from value in regexp
                    for(int i = 0; i < (indentSize - lastBlockIndentSize); i++) {
                        blockText += " ";
                    }
                    blockText += lineText;

                    blockInfo.put("value", blockText);
                }
                else {
                    msgHandler.logDebug("was new block");

                    // new block
                    res.add(lineInfo); // already in valid format for block
                    lastBlockIndentSize = indentSize;
                }
            }
        }

        return res;
    }

    public List<Object> splitByIndentBlocks(String text) {
        return splitByIndentBlocks(text, 2, -1);
    }

    /**
     * Finds and parses the first list. The list will never have a "title" or
     * leading text; only sub-lists will. This parses using INDENTATION.
     * Currently non-recursive only and does not recognize sub-lists, caller must do that.
     *

     * Version that can isolate a list without consuming excess text.
     */
    public Map<String, Object> findParseBulletList(String text, boolean recurse) {
        if (recurse == true) {
            throw new UnsupportedOperationException("findParseBulletList doesn't recurse at the moment, ambiguous");
        }

        // get the first bullet
        Matcher m = bulletPat.matcher(text);
        if (m.find()) {
            Map<String, Object> listInfo = FtlDocFileParser.makeObjectMap();

            int textStartIndex = m.start();
            int textEndIndex = text.length();   // don't know yet
            int indentSize = m.group(1).length();

            msgHandler.logDebug(
                    "====================================\n" +
                    "findParseBulletList: found bullet match: '" + m.group() + "'\n" +
                    "====================================");

            // just cut text slow, but whatever
            String listText = text.substring(textStartIndex);

            // NOTE: these pats use NOT DOTALL. Go line-by-line. MULTILINE is for ^ and $.
            // NOTE: don't end this with $; capture the newline
            Pattern listLinePat;
            if (indentSize > 0) {
                listLinePat = Pattern.compile("^[ ]{" + indentSize + "}([* ])[ ](.*)$");
            }
            else {
                listLinePat = Pattern.compile("^([* ])[ ](.*)$");
            }

            msgHandler.logDebug("Pattern: " + listLinePat.toString());

            int lineCharsConsumed = 0;
            int numLinesConsumed = 0;
            // NOTE: intentionally hardcode \n for now
            String[] lines = listText.split("\n");
            List<Object> listItemTexts = new ArrayList<>();
            String listItemText = null;

            for(String line : lines) {
                Matcher linem = listLinePat.matcher(line);
                if (linem.matches()) {
                    lineCharsConsumed += line.length();
                    numLinesConsumed += 1;

                    String firstChar = linem.group(1);
                    String lineText = linem.group(2);

                    if ("*".equals(firstChar)) {
                        if (listItemText != null) {
                            // save previous
                            listItemTexts.add(cleanTextValueSafe(listItemText));
                        }

                        // start new item
                        listItemText = lineText;
                    }
                    else {
                        if (listItemText == null) {
                            throw new IllegalStateException("Error parsing bullet lists... regexp not working");
                        }
                        // append
                        listItemText += "\n" + lineText;
                    }
                }
                else {
                    break;
                }
            }

            // finish off previous
            if (listItemText != null) {
                listItemTexts.add(cleanTextValueSafe(listItemText));
            }

            int charsConsumed;
            if (numLinesConsumed >= lines.length) {
                charsConsumed = lineCharsConsumed + ("\n".length() * (numLinesConsumed - 1));
            }
            else {
                charsConsumed = lineCharsConsumed + ("\n".length() * numLinesConsumed);
            }

            // must add original startIndex to get the real endIndex (on the orig text); relative
            textEndIndex = textStartIndex + charsConsumed;

            List<Object> items = listItemTexts;

            /* this used to treat sub-lists as special items, but get more versatile markup if we don't.
               also now let caller do this.
            List<Map<String, Object>> items = new ArrayList<>();

            // Go through items, and create sub-lists where necessary.
            for(String itemText : listItemTexts) {
                Map<String, Object> itemInfo = makeObjectMap();

                Map<String, Object> subList = findParseBulletList(itemText);
                if (subList != null) {
                    // leading text
                    int subStartIndex = (int) subList.get("startIndex");
                    if (subStartIndex > 0) {
                        itemInfo.put("leadingText", itemText.substring(0, subStartIndex));
                    }
                    // trailing text
                    // NOTE: there shouldn't be any trailing text normally...
                    int subEndIndex = (int) subList.get("endIndex");
                    if (subEndIndex < itemText.length()) {
                        itemInfo.put("trailingText", itemText.substring(subEndIndex));
                    }

                    itemInfo.put("items", subList.get("items"));
                }
                else {
                    itemInfo.put("leadingText", itemText);
                }
                items.add(itemInfo);
            }*/

            if (text.contains("generic field arrangement of no specific pattern and no")) {
                msgHandler.logDebug("FOUND PROBLEMATIC");
            }
            msgHandler.logDebug("text length: " + text.length() +
                    " startIndex: " + textStartIndex + " endIndex: " + textEndIndex);
            //msgHandler.logDebug("items: " + items.toString());

            listInfo.put("items", items);
            listInfo.put("startIndex", textStartIndex);
            listInfo.put("endIndex", textEndIndex);
            listInfo.put("type", "list");
            return listInfo;
        }
        else {
            return null;
        }
    }

    /**
     * Returns list of maps and strings.
     * String is piece of text, while each map describes a list.
     *

     * If recurse, the list elems are passed through splitByMarkupElems
     */
    @SuppressWarnings("unchecked")
    public List<Object> splitByLists(String text, boolean recurse) {
        List<Object> textList = new ArrayList<>();

        String remainText = text;

        msgHandler.logDebug(
                "====================================\n" +
                "splitByLists\n" +
                "====================================");

        while (true) {
            Map<String, Object> listInfo = findParseBulletList(remainText, false); // we recurse ourselves below
            if (listInfo == null) {
                break;
            }

            int startIndex = (int) listInfo.get("startIndex");
            int endIndex = (int) listInfo.get("endIndex");

            // Add text before list
            if (startIndex > 0) {
                textList.add(remainText.substring(0, startIndex));
            }

            if (recurse) {
                List<Object> parsedItems = new ArrayList<>();
                List<Object> itemTexts = (List<Object>) listInfo.get("items");
                if (itemTexts != null && !itemTexts.isEmpty()) {
                    for(Object itemEntry : itemTexts) {
                        String itemText = (String) itemEntry;
                        List<Object> parsedItemList = splitByStructuralElems(itemText);
                        parsedItems.add(parsedItemList);
                    }
                }
                // just replace directly, we know we can
                listInfo.put("items", parsedItems);
            }

            // Add the list
            textList.add(listInfo);

            // Update matcher to start at updated position
            // FIXME: This method is really dumb, there must be a better way...
            // ... however also very simple
            remainText = remainText.substring(endIndex);
        }

        // last piece of text remaining
        if (!remainText.isEmpty()) {
            textList.add(remainText);
        }

        msgHandler.logDebug("textList size: " + textList.size());

        return textList;
    }

    // just try to match everything possible here. note will consume (and discard) leading space.
    // NOTE: don't end this with $; capture the newline (but leave outside value)
    private static final Pattern notesPat = Pattern.compile(
            "(?:[ ]+|^[ ]*)([A-Z]{3}[A-Z ]*[A-Z])([?]:|:)[ ]*(.*?)(\\n|\\z)"
            , Pattern.MULTILINE); // NOTE: no DOTALL

    /**
     * Splits text into a list of maps (titles) and strings (regular text).
     *

     * Notes are hard to handle, they occur almost anywhere and need to treat specially.
     * NOTE: This does not combine notes and lists, see {@link #combineStructuralElems}
     *

     * Also, notes will always consume the whitespace that comes before them, and whitespace
     * around value on same line.
     * It may have no value after this call.
     */
    @SuppressWarnings("unchecked")
    public List<Object> splitByNotes(String text) {
        Map<String, Object> modelMap = FtlDocFileParser.makeObjectMap();
        modelMap.put("type", "note");
        List<Object> bareList = splitByPat(text, notesPat, modelMap,  "origText", "label", "sep", "value");
        // This is too unwieldly to do in regex:
        // check if note started a new line or not, and also clean value found so far (same line)

        msgHandler.logDebug(
                "====================================\n" +
                "splitByNotes: entry count: " + bareList.size() + "\n" +
                "====================================");

        List<Object> res = new ArrayList<>();
        boolean lastWasNewline = true;

        for(Object bare : bareList) {
            if (bare instanceof String) {
                String bareText = (String) bare;
                if (bareText.isEmpty()) {
                    msgHandler.logDebug(" - text was empty");

                }
                else if (bareText.endsWith("\n")) {
                    lastWasNewline = true;
                }
                else {
                    lastWasNewline = false;
                }
                res.add(bare);

                msgHandler.logDebug("TEXT: " + bareText);
            }
            else {
                Map<String, Object> noteInfo = (Map<String, Object>) bare;

                String value = (String) noteInfo.get("value");
                if (value != null) {
                    value = cleanTextValue(value);
                }
                if (value.isEmpty()) {
                    value = null;
                }
                noteInfo.put("value", value);

                noteInfo.put("labelAndSep", ((String) noteInfo.get("label")) + ((String) noteInfo.get("sep")));

                noteInfo.put("ownLine", lastWasNewline);
                lastWasNewline = true;

                res.add(noteInfo);

                msgHandler.logDebug("NOTE: label: " + (String) noteInfo.get("label") + " value: " + value);

            }
        }

        return res;
    }

    /**
     * This performs high-level combination of elements already split.
     *

     * Notes may consume lists and indent blocks.
     */
    @SuppressWarnings("unchecked")
    public List<Object> combineStructuralElems(List<Object> elemList) {
        List<Object> res = new ArrayList<>();

        int i = 0;

        msgHandler.logDebug(
                "====================================\n" +
                "combineStructuralElems: entry count: " + elemList.size() + "\n" +
                "====================================");

        while(i < elemList.size()) {
            // NOTE: slow if not ArrayList
            Object elemObj = elemList.get(i);

            if (elemObj instanceof Map) {
                Map<String, Object> elemInfo = (Map<String, Object>) elemObj;
                String type = (String) elemInfo.get("type");

                // notes should only consume next elem if they were on their own line
                if (("note".equals(type) &&
                    Boolean.TRUE.equals(elemInfo.get("ownLine")))) {

                    msgHandler.logDebug("Got NOTE on own line: " + elemInfo.toString());

                    Object nextElemObj = null;
                    if ((i+1) < elemList.size()) {
                        nextElemObj = elemList.get(i+1);
                    }

                    msgHandler.logDebug("Next elem is: " + nextElemObj);

                    if (nextElemObj != null && nextElemObj instanceof Map) {
                        Map<String, Object> nextElemInfo = (Map<String, Object>) nextElemObj;
                        String nextElemType = (String) nextElemInfo.get("type");

                        msgHandler.logDebug("Got next elem: " + nextElemInfo.toString());

                        // only allow consuming list if note has no value of its own
                        if ((elemInfo.get("value") == null) && "list".equals(nextElemType)) {
                            // consume it and put it as the value for the note
                            i++;
                            elemInfo.put("value", nextElemInfo);
                        }
                        else if ("indent".equals(nextElemType)) {
                            // consume it and put it (or add) as the TEXT value for the note
                            i++;
                            String currValue = (String) (elemInfo.get("value"));
                            String indentText = (String) nextElemInfo.get("value");
                            currValue = (currValue != null ? (currValue + "\n") : "") + indentText;

                            elemInfo.put("value", currValue);
                        }
                    }
                }

                res.add(elemInfo);
            }
            else {
                res.add(elemObj);
            }
            i++;
        }

        return res;
    }

    /**
     * High-level, splits text into a list of maps (markup elements) and strings (regular text).
     * For lists, applies recursively.
     * NOTE: does not split by entry refs, main markup elems only.
     */
    public List<Object> splitByStructuralElems(String text) {
        List<Object> res;
        List<Object> prevSplit;

        // split by simple/strict titles first
        res = splitByTitles(text);

        // split remaining text parts by lists, and also do lists recursively
        prevSplit = res;
        res = new ArrayList<>();
        for(Object part : prevSplit) {
            if (part instanceof String) {
                List<Object> listSplit = splitByLists((String) part, true);
                res.addAll(listSplit);
            }
            else {
                res.add(part);
            }
        }

        // split remaining text parts by notes ("NOTE:")
        prevSplit = res;
        res = new ArrayList<>();
        for(Object part : prevSplit) {
            if (part instanceof String) {
                List<Object> listSplit = splitByNotes((String) part);
                res.addAll(listSplit);
            }
            else {
                res.add(part);
            }
        }

        // split remaining text parts by indent blocks
        prevSplit = res;
        res = new ArrayList<>();
        for(Object part : prevSplit) {
            if (part instanceof String) {
                List<Object> listSplit = splitByIndentBlocks((String) part);
                res.addAll(listSplit);
            }
            else {
                res.add(part);
            }
        }

        // combine some of the resulting elems with high-level logic
        res = combineStructuralElems(res);

        return res;
    }

}


text:
<!DOCTYPE html>

  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <meta name="author" content="xgqfrms">
  <meta name="generator" content="VS code">
  <title>preload prefetch</title>

  <link rel="preload" as="style" onload="this.rel = 'stylesheet'" href="./preload.css">
  <link rel="prefetch" as="style" onload="this.rel = 'stylesheet'" href="./prefetch.css">

  <link rel="preload" as="script" href="./preload.js" onload="log(`preload.js load`);const preloadScript = document.createElement(`script`);preloadScript.src = `./preload.js`;document.body.appendChild(preloadScript);">
  <link rel="prefetch" as="script" href="./prefetch.js" onload="log(`prefetch.js load`);const prefetchScript = document.createElement(`script`);prefetchScript.src = `./prefetch.js`;document.body.appendChild(prefetchScript);">

    <link rel="stylesheet" href="./preload.css">
    <link rel="stylesheet" href="./prefetch.css">

preload prefetch

preload

prefetch

copyright© xgqfrms 2020

    JavaScript is disabled or fails to load

redpajama_set_name: RedPajamaGithub


text:
.class public Lcom/android/internal/app/IntentForwarderActivity;
.super Landroid/app/Activity;
.source "IntentForwarderActivity.java"

# static fields
.field public static FORWARD_INTENT_TO_MANAGED_PROFILE:Ljava/lang/String;

.field public static FORWARD_INTENT_TO_USER_OWNER:Ljava/lang/String;

.field public static TAG:Ljava/lang/String;

# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 47
    const-string v0, "IntentForwarderActivity"

    sput-object v0, Lcom/android/internal/app/IntentForwarderActivity;->TAG:Ljava/lang/String;

    .line 49
    const-string v0, "com.android.internal.app.ForwardIntentToUserOwner"

    sput-object v0, Lcom/android/internal/app/IntentForwarderActivity;->FORWARD_INTENT_TO_USER_OWNER:Ljava/lang/String;

    .line 52
    const-string v0, "com.android.internal.app.ForwardIntentToManagedProfile"

    sput-object v0, Lcom/android/internal/app/IntentForwarderActivity;->FORWARD_INTENT_TO_MANAGED_PROFILE:Ljava/lang/String;

    return-void
.end method

.method public constructor <init>()V
    .locals 0

    .prologue
    .line 45
    invoke-direct {p0}, Landroid/app/Activity;-><init>()V

    return-void
.end method

.method private getManagedProfile()Landroid/os/UserHandle;
    .locals 7

    .prologue
    .line 145
    const-string/jumbo v4, "user"

    invoke-virtual {p0, v4}, Lcom/android/internal/app/IntentForwarderActivity;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Landroid/os/UserManager;

    .line 146
    .local v3, "userManager":Landroid/os/UserManager;
    const/4 v4, 0x0

    invoke-virtual {v3, v4}, Landroid/os/UserManager;->getProfiles(I)Ljava/util/List;

    move-result-object v1

    .line 147
    .local v1, "relatedUsers":Ljava/util/List;, "Ljava/util/List<Landroid/content/pm/UserInfo;>;"
    invoke-interface {v1}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v0

    .local v0, "i$":Ljava/util/Iterator;
    :cond_0
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v4

    if-eqz v4, :cond_1

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Landroid/content/pm/UserInfo;

    .line 148
    .local v2, "userInfo":Landroid/content/pm/UserInfo;
    invoke-virtual {v2}, Landroid/content/pm/UserInfo;->isManagedProfile()Z

    move-result v4

    if-eqz v4, :cond_0

    new-instance v4, Landroid/os/UserHandle;

    iget v5, v2, Landroid/content/pm/UserInfo;->id:I

    invoke-direct {v4, v5}, Landroid/os/UserHandle;-><init>(I)V

    .line 152
    .end local v2    # "userInfo":Landroid/content/pm/UserInfo;
    :goto_0
    return-object v4

    .line 150
    :cond_1
    sget-object v4, Lcom/android/internal/app/IntentForwarderActivity;->TAG:Ljava/lang/String;

    new-instance v5, Ljava/lang/StringBuilder;

    invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V

    sget-object v6, Lcom/android/internal/app/IntentForwarderActivity;->FORWARD_INTENT_TO_MANAGED_PROFILE:Ljava/lang/String;

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, " has been called, but there is no managed profile"

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v4, v5}, Landroid/util/Slog;->wtf(Ljava/lang/String;Ljava/lang/String;)I

    .line 152
    const/4 v4, 0x0

    goto :goto_0
.end method

# virtual methods
.method protected onCreate(Landroid/os/Bundle;)V
    .locals 21
    .param p1, "savedInstanceState"    # Landroid/os/Bundle;

    .prologue
    .line 57
    invoke-super/range {p0 .. p1}, Landroid/app/Activity;->onCreate(Landroid/os/Bundle;)V

    .line 58
    invoke-virtual/range {p0 .. p0}, Lcom/android/internal/app/IntentForwarderActivity;->getIntent()Landroid/content/Intent;

    move-result-object v7

    .line 60
    .local v7, "intentReceived":Landroid/content/Intent;
    invoke-virtual {v7}, Landroid/content/Intent;->getComponent()Landroid/content/ComponentName;

    move-result-object v18

    invoke-virtual/range {v18 .. v18}, Landroid/content/ComponentName;->getClassName()Ljava/lang/String;

    move-result-object v5

    .line 64
    .local v5, "className":Ljava/lang/String;
    sget-object v18, Lcom/android/internal/app/IntentForwarderActivity;->FORWARD_INTENT_TO_USER_OWNER:Ljava/lang/String;

    move-object/from16 v0, v18

    invoke-virtual {v5, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v18

    if-eqz v18, :cond_0

    .line 65
    const v17, 0x1040531

    .line 66
    .local v17, "userMessageId":I
    sget-object v16, Landroid/os/UserHandle;->OWNER:Landroid/os/UserHandle;

    .line 75
    .local v16, "userDest":Landroid/os/UserHandle;
    :goto_0
    if-nez v16, :cond_2

    .line 76
    invoke-virtual/range {p0 .. p0}, Lcom/android/internal/app/IntentForwarderActivity;->finish()V

    .line 135
    :goto_1
    return-void

    .line 67
    .end local v16    # "userDest":Landroid/os/UserHandle;
    .end local v17    # "userMessageId":I
    :cond_0
    sget-object v18, Lcom/android/internal/app/IntentForwarderActivity;->FORWARD_INTENT_TO_MANAGED_PROFILE:Ljava/lang/String;

    move-object/from16 v0, v18

    invoke-virtual {v5, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v18

    if-eqz v18, :cond_1

    .line 68
    const v17, 0x1040532

    .line 69
    .restart local v17    # "userMessageId":I
    invoke-direct/range {p0 .. p0}, Lcom/android/internal/app/IntentForwarderActivity;->getManagedProfile()Landroid/os/UserHandle;

    move-result-object v16

    .restart local v16    # "userDest":Landroid/os/UserHandle;
    goto :goto_0

    .line 71
    .end local v16    # "userDest":Landroid/os/UserHandle;
    .end local v17    # "userMessageId":I
    :cond_1
    sget-object v18, Lcom/android/internal/app/IntentForwarderActivity;->TAG:Ljava/lang/String;

    new-instance v19, Ljava/lang/StringBuilder;

    invoke-direct/range {v19 .. v19}, Ljava/lang/StringBuilder;-><init>()V

    const-class v20, Lcom/android/internal/app/IntentForwarderActivity;

    invoke-virtual/range {v20 .. v20}, Ljava/lang/Class;->getName()Ljava/lang/String;

    move-result-object v20

    invoke-virtual/range {v19 .. v20}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v19

    const-string v20, " cannot be called directly"

    invoke-virtual/range {v19 .. v20}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v19

    invoke-virtual/range {v19 .. v19}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v19

    invoke-static/range {v18 .. v19}, Landroid/util/Slog;->wtf(Ljava/lang/String;Ljava/lang/String;)I

    .line 72
    const/16 v17, -0x1

    .line 73
    .restart local v17    # "userMessageId":I
    const/16 v16, 0x0

    .restart local v16    # "userDest":Landroid/os/UserHandle;
    goto :goto_0

    .line 79
    :cond_2
    new-instance v11, Landroid/content/Intent;

    invoke-direct {v11, v7}, Landroid/content/Intent;-><init>(Landroid/content/Intent;)V

    .line 80
    .local v11, "newIntent":Landroid/content/Intent;
    const/16 v18, 0x0

    move-object/from16 v0, v18

    invoke-virtual {v11, v0}, Landroid/content/Intent;->setComponent(Landroid/content/ComponentName;)Landroid/content/Intent;

    .line 82
    const/16 v18, 0x0

    move-object/from16 v0, v18

    invoke-virtual {v11, v0}, Landroid/content/Intent;->setPackage(Ljava/lang/String;)Landroid/content/Intent;

    .line 83
    const/high16 v18, 0x3000000

    move/from16 v0, v18

    invoke-virtual {v11, v0}, Landroid/content/Intent;->addFlags(I)Landroid/content/Intent;

    .line 85
    invoke-virtual/range {p0 .. p0}, Lcom/android/internal/app/IntentForwarderActivity;->getUserId()I

    move-result v3

    .line 86
    .local v3, "callingUserId":I
    invoke-static {}, Landroid/app/AppGlobals;->getPackageManager()Landroid/content/pm/IPackageManager;

    move-result-object v8

    .line 87
    .local v8, "ipm":Landroid/content/pm/IPackageManager;
    invoke-virtual/range {p0 .. p0}, Lcom/android/internal/app/IntentForwarderActivity;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v18

    move-object/from16 v0, v18

    invoke-virtual {v11, v0}, Landroid/content/Intent;->resolveTypeIfNeeded(Landroid/content/ContentResolver;)Ljava/lang/String;

    move-result-object v12

    .line 88
    .local v12, "resolvedType":Ljava/lang/String;
    const/4 v4, 0x0

    .line 89
    .local v4, "canForward":Z
    invoke-virtual {v11}, Landroid/content/Intent;->getSelector()Landroid/content/Intent;

    move-result-object v14

    .line 90
    .local v14, "selector":Landroid/content/Intent;
    if-nez v14, :cond_3

    .line 91
    move-object v14, v11

    .line 94
    :cond_3
    :try_start_0
    invoke-virtual/range {v16 .. v16}, Landroid/os/UserHandle;->getIdentifier()I

    move-result v18

    move/from16 v0, v18

    invoke-interface {v8, v14, v12, v3, v0}, Landroid/content/pm/IPackageManager;->canForwardTo(Landroid/content/Intent;Ljava/lang/String;II)Z
    :try_end_0
    .catch Landroid/os/RemoteException; {:try_start_0 .. :try_end_0} :catch_0

    move-result v4

    .line 99
    :goto_2
    if-eqz v4, :cond_6

    .line 100
    invoke-virtual {v11, v3}, Landroid/content/Intent;->setContentUserHint(I)V

    .line 102
    invoke-virtual/range {p0 .. p0}, Lcom/android/internal/app/IntentForwarderActivity;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object v18

    const/high16 v19, 0x10000

    invoke-virtual/range {v16 .. v16}, Landroid/os/UserHandle;->getIdentifier()I

    move-result v20

    move-object/from16 v0, v18

    move/from16 v1, v19

    move/from16 v2, v20

    invoke-virtual {v0, v11, v1, v2}, Landroid/content/pm/PackageManager;->resolveActivityAsUser(Landroid/content/Intent;II)Landroid/content/pm/ResolveInfo;

    move-result-object v13

    .line 106
    .local v13, "ri":Landroid/content/pm/ResolveInfo;
    iget-object v0, v13, Landroid/content/pm/ResolveInfo;->activityInfo:Landroid/content/pm/ActivityInfo;

    move-object/from16 v18, v0

    move-object/from16 v0, v18

    iget-object v0, v0, Landroid/content/pm/ActivityInfo;->applicationInfo:Landroid/content/pm/ApplicationInfo;

    move-object/from16 v18, v0

    move-object/from16 v0, v18

    iget v0, v0, Landroid/content/pm/ApplicationInfo;->uid:I

    move/from16 v18, v0

    const/16 v19, 0x3e8

    invoke-static/range {v18 .. v19}, Landroid/os/UserHandle;->isSameApp(II)Z

    move-result v18

    if-nez v18, :cond_5

    const/4 v15, 0x1

    .line 110
    .local v15, "shouldShowDisclosure":Z
    :goto_3
    const/16 v18, 0x0

    :try_start_1
    invoke-virtual/range {v16 .. v16}, Landroid/os/UserHandle;->getIdentifier()I

    move-result v19

    move-object/from16 v0, p0

    move-object/from16 v1, v18

    move/from16 v2, v19

    invoke-virtual {v0, v11, v1, v2}, Lcom/android/internal/app/IntentForwarderActivity;->startActivityAsCaller(Landroid/content/Intent;Landroid/os/Bundle;I)V
    :try_end_1
    .catch Ljava/lang/RuntimeException; {:try_start_1 .. :try_end_1} :catch_1

    .line 127
    :goto_4
    if-eqz v15, :cond_4

    .line 128
    move-object/from16 v0, p0

    move/from16 v1, v17

    invoke-virtual {v0, v1}, Lcom/android/internal/app/IntentForwarderActivity;->getString(I)Ljava/lang/String;

    move-result-object v18

    const/16 v19, 0x1

    move-object/from16 v0, p0

    move-object/from16 v1, v18

    move/from16 v2, v19

    invoke-static {v0, v1, v2}, Landroid/widget/Toast;->makeText(Landroid/content/Context;Ljava/lang/CharSequence;I)Landroid/widget/Toast;

    move-result-object v18

    invoke-virtual/range {v18 .. v18}, Landroid/widget/Toast;->show()V

    .line 134
    .end local v13    # "ri":Landroid/content/pm/ResolveInfo;
    .end local v15    # "shouldShowDisclosure":Z
    :cond_4
    :goto_5
    invoke-virtual/range {p0 .. p0}, Lcom/android/internal/app/IntentForwarderActivity;->finish()V

    goto/16 :goto_1

    .line 96
    :catch_0
    move-exception v6

    .line 97
    .local v6, "e":Landroid/os/RemoteException;
    sget-object v18, Lcom/android/internal/app/IntentForwarderActivity;->TAG:Ljava/lang/String;

    const-string v19, "PackageManagerService is dead?"

    invoke-static/range {v18 .. v19}, Landroid/util/Slog;->e(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_2

    .line 106
    .end local v6    # "e":Landroid/os/RemoteException;
    .restart local v13    # "ri":Landroid/content/pm/ResolveInfo;
    :cond_5
    const/4 v15, 0x0

    goto :goto_3

    .line 111
    .restart local v15    # "shouldShowDisclosure":Z
    :catch_1
    move-exception v6

    .line 112
    .local v6, "e":Ljava/lang/RuntimeException;
    const/4 v10, -0x1

    .line 113
    .local v10, "launchedFromUid":I
    const-string v9, "?"

    .line 115
    .local v9, "launchedFromPackage":Ljava/lang/String;
    :try_start_2
    invoke-static {}, Landroid/app/ActivityManagerNative;->getDefault()Landroid/app/IActivityManager;

    move-result-object v18

    invoke-virtual/range {p0 .. p0}, Lcom/android/internal/app/IntentForwarderActivity;->getActivityToken()Landroid/os/IBinder;

    move-result-object v19

    invoke-interface/range {v18 .. v19}, Landroid/app/IActivityManager;->getLaunchedFromUid(Landroid/os/IBinder;)I

    move-result v10

    .line 117
    invoke-static {}, Landroid/app/ActivityManagerNative;->getDefault()Landroid/app/IActivityManager;

    move-result-object v18

    invoke-virtual/range {p0 .. p0}, Lcom/android/internal/app/IntentForwarderActivity;->getActivityToken()Landroid/os/IBinder;

    move-result-object v19

    invoke-interface/range {v18 .. v19}, Landroid/app/IActivityManager;->getLaunchedFromPackage(Landroid/os/IBinder;)Ljava/lang/String;
    :try_end_2
    .catch Landroid/os/RemoteException; {:try_start_2 .. :try_end_2} :catch_2

    move-result-object v9

    .line 122
    :goto_6
    sget-object v18, Lcom/android/internal/app/IntentForwarderActivity;->TAG:Ljava/lang/String;

    new-instance v19, Ljava/lang/StringBuilder;

    invoke-direct/range {v19 .. v19}, Ljava/lang/StringBuilder;-><init>()V

    const-string v20, "Unable to launch as UID "

    invoke-virtual/range {v19 .. v20}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v19

    move-object/from16 v0, v19

    invoke-virtual {v0, v10}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v19

    const-string v20, " package "

    invoke-virtual/range {v19 .. v20}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v19

    move-object/from16 v0, v19

    invoke-virtual {v0, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v19

    const-string v20, ", while running in "

    invoke-virtual/range {v19 .. v20}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v19

    invoke-static {}, Landroid/app/ActivityThread;->currentProcessName()Ljava/lang/String;

    move-result-object v20

    invoke-virtual/range {v19 .. v20}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v19

    invoke-virtual/range {v19 .. v19}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v19

    move-object/from16 v0, v18

    move-object/from16 v1, v19

    invoke-static {v0, v1, v6}, Landroid/util/Slog;->wtf(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I

    goto :goto_4

    .line 131
    .end local v6    # "e":Ljava/lang/RuntimeException;
    .end local v9    # "launchedFromPackage":Ljava/lang/String;
    .end local v10    # "launchedFromUid":I
    .end local v13    # "ri":Landroid/content/pm/ResolveInfo;
    .end local v15    # "shouldShowDisclosure":Z
    :cond_6
    sget-object v18, Lcom/android/internal/app/IntentForwarderActivity;->TAG:Ljava/lang/String;

    new-instance v19, Ljava/lang/StringBuilder;

    invoke-direct/range {v19 .. v19}, Ljava/lang/StringBuilder;-><init>()V

    const-string/jumbo v20, "the intent: "

    invoke-virtual/range {v19 .. v20}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v19

    move-object/from16 v0, v19

    invoke-virtual {v0, v11}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v19

    const-string v20, "cannot be forwarded from user "

    invoke-virtual/range {v19 .. v20}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v19

    move-object/from16 v0, v19

    invoke-virtual {v0, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v19

    const-string v20, " to user "

    invoke-virtual/range {v19 .. v20}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v19

    invoke-virtual/range {v16 .. v16}, Landroid/os/UserHandle;->getIdentifier()I

    move-result v20

    invoke-virtual/range {v19 .. v20}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v19

    invoke-virtual/range {v19 .. v19}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v19

    invoke-static/range {v18 .. v19}, Landroid/util/Slog;->wtf(Ljava/lang/String;Ljava/lang/String;)I

    goto/16 :goto_5

    .line 119
    .restart local v6    # "e":Ljava/lang/RuntimeException;
    .restart local v9    # "launchedFromPackage":Ljava/lang/String;
    .restart local v10    # "launchedFromUid":I
    .restart local v13    # "ri":Landroid/content/pm/ResolveInfo;
    .restart local v15    # "shouldShowDisclosure":Z
    :catch_2
    move-exception v18

    goto :goto_6
.end method


text:
<?php
namespace Skrz\Bundle\BunnyBundle;

/**
 * @author Jakub Kulhan <jakub.kulhan@gmail.com>
 */
final class ContentTypes
{

	/**
	 * JSON serialization
	 */
	const APPLICATION_JSON = "application/json";

	/**
	 * Protocol Buffers serialization
	 */
	const APPLICATION_PROTOBUF = "application/protobuf";

}


text:
          Back

Floating Action Button Morph

        email
        email_fill
        email
        Inbox

        today
        today_fill
        today
        Calendar

        cloud
        cloud_fill
        file_upload
        Upload

      add
      add

      add
      add

      add
      add

Link 1

Link 2

Link 3

Link 4

Choose Something

Link 1

Link 2

Link 3

Link 4

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quia, quo rem beatae, delectus eligendi est saepe molestias perferendis suscipit, commodi labore ipsa non quasi eum magnam neque ducimus! Quasi, numquam.

Maiores culpa, itaque! Eaque natus ab cum ipsam numquam blanditiis a, quia, molestiae aut laudantium recusandae ipsa. Ad iste ex asperiores ipsa, mollitia perferendis consectetur quam eaque, voluptate laboriosam unde.

Sed odit quis aperiam temporibus vitae necessitatibus, laboriosam, exercitationem dolores odio sapiente provident. Accusantium id, itaque aliquam libero ipsum eos fugiat distinctio laboriosam exercitationem sequi facere quas quidem magnam reprehenderit.

Pariatur corporis illo, amet doloremque. Ab veritatis sunt nisi consectetur error modi, nam illo et nostrum quia aliquam ipsam vitae facere voluptates atque similique odit mollitia, rerum placeat nobis est.

Et impedit soluta minus a autem adipisci cupiditate eius dignissimos nihil officia dolore voluptatibus aperiam reprehenderit esse facilis labore qui, officiis consectetur. Ipsa obcaecati aspernatur odio assumenda veniam, ipsum alias.

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Culpa ipsa debitis sed nihil eaque dolore cum iste quibusdam, accusamus doloribus, tempora quia quos voluptatibus corporis officia at quas dolorem earum!

Quod soluta eos inventore magnam suscipit enim at hic in maiores temporibus pariatur tempora minima blanditiis vero autem est perspiciatis totam dolorum, itaque repellat? Nobis necessitatibus aut odit aliquam adipisci.

Tenetur delectus perspiciatis ex numquam, unde corrupti velit! Quam aperiam, animi fuga veritatis consectetur, voluptatibus atque consequuntur dignissimos itaque, sint impedit cum cumque at. Adipisci sint, iusto blanditiis ullam? Vel?

Dignissimos velit officia quibusdam! Eveniet beatae, aut, omnis temporibus consequatur expedita eaque aliquid quos accusamus fugiat id iusto autem obcaecati repellat fugit cupiditate suscipit natus quas doloribus? Temporibus necessitatibus, libero.

Architecto quisquam ipsa fugit facere, repudiandae asperiores vitae obcaecati possimus, labore excepturi reprehenderit consectetur perferendis, ullam quidem hic, repellat fugiat eaque fuga. Consectetur in eveniet, deleniti recusandae omnis eum quas?

Quos nulla consequatur quo, officia quaerat. Nulla voluptatum, assumenda quibusdam, placeat cum aut illo deleniti dolores commodi odio ipsam, recusandae est pariatur veniam repudiandae blanditiis. Voluptas unde deleniti quisquam, nobis?

Atque qui quaerat quasi officia molestiae, molestias totam incidunt reprehenderit laboriosam facilis veritatis, non iusto! Dolore ipsam obcaecati voluptates minima maxime minus qui mollitia facere. Nostrum esse recusandae voluptatibus eligendi.


text:
import * as React from "react";
import { Fun } from "./Fun";

function VerifyInstrumentation() {
  const works = typeof window["__mEx"] === "function";
  if (works) {
    return null;
  }
  return (

      Code instrumentation isn't working. Try reloading this page or restarting
      FromJS. This may also happen if you open the FromJS web server in a
      browser window that wasn't created by FromJS.

  );
}

export class App extends React.Component {
  render() {
    return (

        <VerifyInstrumentation />

Get started with FromJS

Click "Enable DOM inspector" in the bottom right corner

Click on an element somewhere on this page

A sidebar will pop up with analysis information

Inspecting other sites

          Just naviate to another page in this Chrome window. The page will
          automatically analyzed and the "Enable DOM inspector" button
          displayed.

Tips

          Instead of using the DOM inspector you can also use the{" "}
          fromJSInspect function. For example, you can run{" "}
          fromJSInspect(document.querySelector("#app")) in the
          console.

          If you control the code of the site your're inspecting you can also
          just pass a value into `fromJSInspect`. Or use it when eval'ing code:

{`fromJSEval(\`
    var href = location.href;
    var str = "Current URL: " + href;
    fromJSInspect(str);
\`)`}

Caveats

          Expect lots of slowness and breaking behavior. Delete the
          `fromjs-session` directory after using FromJS to save disk space.

Some fun things to inspect

        <Fun />

Issue Tracker

          You can ask questions and report bugs{" "}
          on Github
          .

    );
  }
}


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

	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" href="demo.css" type="text/css" />

	<title>Mif.Tree Checkbox Demo</title>

Tree with dependencies checkboxes

	<input type="button" value="getChecked" id="getChecked"></input>


text:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="true"
        android:drawable="@drawable/pic_btn_selected" /><!--设置选中图片-->
    <item android:state_checked="false"
        android:drawable="@drawable/pic_btn_unselected" /><!--设置未选中图片-->
</selector>


text:
layout: post
title: Ebony plumper Marie Leone hardcore sex
titleinfo: pornvd
desc: Watch Ebony plumper Marie Leone hardcore sex. Pornhub is the ultimate xxx porn and sex site.
---

Ebony plumper Marie Leone hardcore sex

Watch Ebony plumper Marie Leone hardcore sex. Pornhub is the ultimate xxx porn and sex site.


text:
package com.facebook.imagepipeline.animated.factory;

import java.util.concurrent.ScheduledExecutorService;

import android.content.res.Resources;
import android.graphics.Rect;
import android.os.SystemClock;
import android.util.DisplayMetrics;

import com.facebook.common.time.MonotonicClock;
import com.facebook.imagepipeline.animated.base.AnimatedDrawable;
import com.facebook.imagepipeline.animated.base.AnimatedDrawableBackend;
import com.facebook.imagepipeline.animated.base.AnimatedDrawableCachingBackend;
import com.facebook.imagepipeline.animated.base.AnimatedDrawableDiagnostics;
import com.facebook.imagepipeline.animated.base.AnimatedDrawableOptions;
import com.facebook.imagepipeline.animated.base.AnimatedImage;
import com.facebook.imagepipeline.animated.base.AnimatedImageResult;
import com.facebook.imagepipeline.animated.impl.AnimatedDrawableBackendProvider;
import com.facebook.imagepipeline.animated.impl.AnimatedDrawableCachingBackendImplProvider;
import com.facebook.imagepipeline.animated.impl.AnimatedDrawableDiagnosticsImpl;
import com.facebook.imagepipeline.animated.impl.AnimatedDrawableDiagnosticsNoop;
import com.facebook.imagepipeline.animated.util.AnimatedDrawableUtil;

/**
 * Factory for instances of {@link AnimatedDrawable}.
 */
public class AnimatedDrawableFactory {

  private final AnimatedDrawableBackendProvider mAnimatedDrawableBackendProvider;
  private final AnimatedDrawableCachingBackendImplProvider mAnimatedDrawableCachingBackendProvider;
  private final AnimatedDrawableUtil mAnimatedDrawableUtil;
  private final ScheduledExecutorService mScheduledExecutorServiceForUiThread;
  private final MonotonicClock mMonotonicClock;
  private final Resources mResources;

  public AnimatedDrawableFactory(
      AnimatedDrawableBackendProvider animatedDrawableBackendProvider,
      AnimatedDrawableCachingBackendImplProvider animatedDrawableCachingBackendProvider,
      AnimatedDrawableUtil animatedDrawableUtil,
      ScheduledExecutorService scheduledExecutorService,
      Resources resources) {
    mAnimatedDrawableBackendProvider = animatedDrawableBackendProvider;
    mAnimatedDrawableCachingBackendProvider = animatedDrawableCachingBackendProvider;
    mAnimatedDrawableUtil = animatedDrawableUtil;
    mScheduledExecutorServiceForUiThread = scheduledExecutorService;
    mMonotonicClock = new MonotonicClock() {
      @Override
      public long now() {
        // Must be SystemClock.uptimeMillis to be compatible with what Android's View uses.
        return SystemClock.uptimeMillis();
      }
    };
    mResources = resources;
  }

  /**
   * Creates an {@link AnimatedDrawable} based on an {@link AnimatedImage}.
   *
   * @param animatedImageResult the result of the code
   * @return a newly constructed {@link AnimatedDrawable}
   */
  public AnimatedDrawable create(AnimatedImageResult animatedImageResult) {
    return create(animatedImageResult, AnimatedDrawableOptions.DEFAULTS);
  }

  /**
   * Creates an {@link AnimatedDrawable} based on an {@link AnimatedImage}.
   *
   * @param animatedImageResult the result of the code
   * @param options additional options
   * @return a newly constructed {@link AnimatedDrawable}
   */
  public AnimatedDrawable create(
      AnimatedImageResult animatedImageResult,
      AnimatedDrawableOptions options) {
    AnimatedImage animatedImage = animatedImageResult.getImage();
    Rect initialBounds = new Rect(0, 0, animatedImage.getWidth(), animatedImage.getHeight());
    AnimatedDrawableBackend animatedDrawableBackend =
        mAnimatedDrawableBackendProvider.get(animatedImageResult, initialBounds);
    return createAnimatedDrawable(options, animatedDrawableBackend);
  }

  private AnimatedDrawable createAnimatedDrawable(
      AnimatedDrawableOptions options,
      AnimatedDrawableBackend animatedDrawableBackend) {
    DisplayMetrics displayMetrics = mResources.getDisplayMetrics();
    AnimatedDrawableDiagnostics animatedDrawableDiagnostics;
    AnimatedDrawableCachingBackend animatedDrawableCachingBackend =
        mAnimatedDrawableCachingBackendProvider.get(
            animatedDrawableBackend,
            options);
    if (options.enableDebugging) {
      animatedDrawableDiagnostics =
          new AnimatedDrawableDiagnosticsImpl(mAnimatedDrawableUtil, displayMetrics);
    } else {
      animatedDrawableDiagnostics = AnimatedDrawableDiagnosticsNoop.getInstance();
    }

    return new AnimatedDrawable(
        mScheduledExecutorServiceForUiThread,
        animatedDrawableCachingBackend,
        animatedDrawableDiagnostics,
        mMonotonicClock);
  }
}


text:
/**
 * @fileOverview Usage model unit tests.
 */
var Promise = require('bluebird');
var sinon = require('sinon');
var floordate = require('floordate');
var assert = require('chai').assert;

var kansasError = require('../../lib/util/error');
var fixtures = require('../lib/fixtures');

describe('Usage Model', function() {
  var fix;

  fixtures.setupCase(function(res) {
    fix = res;
  });

  it('usage() consumes a unit', function(done) {
    fix.usageModel.consume(fix.token).then(function(remaining) {
      assert.equal(remaining, 9);
    }).then(done, done);
  });
  it('usage() over limit returns error', function(done) {

    // create an array with 10 elements of the token to consume.
    var consume = Array.apply(null, new Array(10)).map(function() {
      return fix.token;
    });
    Promise.map(consume, function(token) {
      return fix.usageModel.consume(token);
    })
      .then(function() {
        return fix.usageModel.consume(fix.token).then(function() {
          throw new Error('Should not allow to consume');
        }).catch(function(err) {
          assert.instanceOf(err, kansasError.UsageLimit);
        });
      }).then(done, done);
  });
  it('usage() accepts units to consume', function(done) {
    fix.usageModel.consume(fix.token, 10)
      .then(function() {
        return fix.usageModel.consume(fix.token).then(function() {
          throw new Error('Should not allow to consume');
        }).catch(function(err) {
          assert.instanceOf(err, kansasError.UsageLimit);
        });
      }).then(done, done);
  });

  describe('Check month period', function() {
    var clock;
    beforeEach(function() {
      var floored = floordate(Date.now(), 'month');
      clock = sinon.useFakeTimers(floored.getTime());
    });
    afterEach(function() {
      clock.restore();
    });
    it('Will roll over to next month and reset limit', function(done) {
      var consume = Array.apply(null, new Array(10)).map(function() {
        return fix.token;
      });

      Promise.map(consume, function(token) {
        return fix.usageModel.consume(token);
      })
        .then(function() {

          // move time fwd 40days.
          var moveFwd = 40 * 24 * 3600 * 1000;
          clock.tick(moveFwd);
          return fix.usageModel.consume(fix.token).then(function(remaining) {
            assert(remaining, 9);
          });
        }).then(done, done);
    });
  });
});


text:
package main

import (
	"log"
	"path/filepath"
	"time"

	"github.com/pkg/errors"

	"go.ligato.io/cn-infra/v2/agent"
	pm "go.ligato.io/cn-infra/v2/exec/processmanager"
	"go.ligato.io/cn-infra/v2/exec/processmanager/status"
	"go.ligato.io/cn-infra/v2/logging"
)

const pluginName = "process-manager-example"

func main() {
	pmPlugin := pm.DefaultPlugin
	example := &PMExample{
		Log:      logging.ForPlugin(pluginName),
		PM:       &pmPlugin,
		finished: make(chan struct{}),
	}

	a := agent.NewAgent(
		agent.AllPlugins(example),
		agent.QuitOnClose(example.finished),
	)
	if err := a.Run(); err != nil {
		log.Fatal(err)
	}
}

// PMExample demonstrates the usage of the process manager plugin.
type PMExample struct {
	Log logging.PluginLogger
	PM  pm.ProcessManager

	finished chan struct{}
}

// Init starts the example
func (p *PMExample) Init() error {
	go p.runExample()
	return nil
}

// Close frees the plugin resources.
func (p *PMExample) Close() error {
	return nil
}

// String returns name of the plugin.
func (p *PMExample) String() string {
	return pluginName
}

// Runs example with step by step description
func (p *PMExample) runExample() {
	// Simple process handling (start, restart, watch, delete)
	if err := p.simpleExample(); err != nil {
		p.Log.Errorf("simple process manager example failed with error: %v", err)
	}
	close(p.finished)
	return
}

func (p *PMExample) simpleExample() error {
	p.Log.Infof("starting simple process manager example")
	// Process manager plugin has internal cache for all processes created via its API. These processes
	// are considered as known to plugin. The example uses test-process - a simple application which
	// keeps running after start, so it can be handled by process manager.
	// At first, the process needs to be defined with unique name and command. Since test process allows
	// to use argument, use option 'Args()' to start the application with it and set max uptime to 60 seconds.
	// Then initialize status channel since status notifications are required, and provide it to the plugin
	// via 'Notify()'.
	cmd := filepath.Join("../", "test-process", "test-process")
	notifyChan := make(chan status.ProcessStatus)
	pr := p.PM.NewProcess("test-pr", cmd, pm.Args("-max-uptime=60"), pm.Notify(notifyChan))

	// The process is initialized. We can verify that via plugin manager API (prInst == pr)
	prInst := p.PM.GetProcessByName("test-pr")
	if prInst == nil {
		return errors.Errorf("expected process instance is nil")
	}

	// Since the watch channel is used, start watcher in another goroutine. The watcher will track the process status
	// during the example.
	var state status.ProcessStatus
	go p.runWatcher(&state, notifyChan)

	if err := pr.Start(); err != nil {
		return err
	}
	p.Log.Infof("Let's wait for the process to start")
	time.Sleep(2 * time.Second)
	if state == status.Sleeping || state == status.Running || state == status.Idle {
		p.Log.Infof("success!")
	} else {
		return errors.Errorf("failed to start the test process within timeout")
	}

	// Now the process is running and we can use the instance to read various process definitions. The most common:
	pid := pr.GetPid()
	p.Log.Infof("PID: %d", pid)
	p.Log.Infof("Instance name: %s", pr.GetInstanceName())
	p.Log.Infof("Start time: %d", pr.GetStartTime().Nanosecond())
	p.Log.Infof("Uptime (s): %f", pr.GetUptime().Seconds())

	// Let's try to restart the process
	if err := pr.Restart(); err != nil {
		return err
	}
	p.Log.Infof("Let's wait for process to restart")
	time.Sleep(2 * time.Second)

	// Restarted process is expected to have different process ID. We stored old PID, so let's compare it with
	// the new one.
	if pid == pr.GetPid() {
		p.Log.Warnf("PID of restarted process is the same, perhaps the restart was not successful")
	} else {
		p.Log.Infof("success!")
	}
	p.Log.Infof("new PID: %d", pid)
	p.Log.Infof("Uptime (s): %f", pr.GetUptime().Seconds())

	// Now lets stop the process
	if err := pr.Stop(); err != nil {
		return err
	}
	p.Log.Infof("Let's wait for process to stop")
	time.Sleep(2 * time.Second)

	// Important: we stopped the process using SIGTERM, which causes process to become defunct because with the current
	// setup, the example is a parent process which is still running. If we try to start it again with 'Start()',
	// the operating system spawns a new process which instance will NOT be passed to the plugin manager by os package
	// and the new process will become unmanageable.
	// There are several options what to do:
	// * use Wait(). It waits for process status and terminates it completely.
	// * stop the process with the StopAndWait() which merges the two procedures together
	// * create a process with 'AutoTermination' option. It causes that every managed process which becomes zombie
	// will be terminated automatically.
	// Since we already stopped the process, the only thing we can do is to wait
	if _, err := pr.Wait(); err != nil {
		return err
	}
	p.Log.Infof("Let's wait for process to complete")
	time.Sleep(2 * time.Second)

	// Stopped process can be started again, etc. If we want to get rid of the process completely, we have to delete
	// it via plugin API. It requires plugin name (not instance name). Deleted process is not stopped if running.
	// Delete also closes notification channel.
	prName := pr.GetName()
	if err := p.PM.Delete(prName); err != nil {
		return err
	}
	if err := p.PM.GetProcessByName(prName); err != nil {
		return errors.Errorf("process was expected to be removed, but is still exists")
	}

	p.Log.Infof("simple process manager example is completed")

	return nil
}

// Starts the process watcher using provided chanel.
func (p *PMExample) runWatcher(state *status.ProcessStatus, notifyChan chan status.ProcessStatus) {
	for {
		select {
		case currentState, ok := <-notifyChan:
			if !ok {
				p.Log.Infof("===>(watcher) process watcher ended")
				return
			}
			*state = currentState
			p.Log.Infof("===>(watcher) received test process state: %s", currentState)
		}
	}
}


text:
import React from "react";
import ReactDOM from "react-dom";
import MuiThemeProvider from "material-ui/styles/MuiThemeProvider";
import injectTapEventPlugin from "react-tap-event-plugin";

import App from "./App";
import Summary from "./components/summary/Summary";
import Menu from "./components/menus/SpicyMenu";
import AddMenu from "./components/menus/AddMenu";
import MenuDetail from "./components/menus/MenuDetail";

import {BrowserRouter as Router, browserHistory, Route, Redirect} from "react-router-dom";

injectTapEventPlugin();

const Root = () => (
    <MuiThemeProvider>
        <Router history={browserHistory}>
            <div>
                <Route path="/" component={App}/>
                <Route path="/menu" component={Menu}/>
                <Route path="/summary" component={Summary}/>
                <Route path="/addMenu" component={AddMenu}/>
                <Route path="/menuDetail/:id" component={MenuDetail}/>
                <Redirect from="/" to="/menu"/>
            </div>
        </Router>
    </MuiThemeProvider>
);

ReactDOM.render(<Root />, document.getElementById('root'));


text:
engageSpark badges app using [react-native](http://facebook.github.io/react-native/).

# Why?

Because writing mobile apps in js is more fun than say Java, Objc-C and Swift.

# TODO

- Adding new badge to user
- Filtering of added vs all badges
- iOS version


text:
//
//  UIImage+YYAdd.h
//  YYKit
//
//  Created by ibireme on 13-4-4.
//  Copyright (c) 2013 ibireme. All rights reserved.
//

#import <UIKit/UIKit.h>

/**
 Provide some commen method for `UIImage`.
 Image process is based on CoreGraphic and vImage.
 */
@interface UIImage (YYAdd)

#pragma mark - Image Decode
///=============================================================================
/// @name Image Decode
///=============================================================================

/**
 Decompress this image, so when the image is displayed on screen, the main
 thread won't be blocked by additional decode. It will cost more memory.
 If the image is already decoded, or fail to decode, it just return itself.

 @return a image decoded, or just return itself if no needed.

 @see isImageDecoded
 */
- (UIImage *)imageByDecoded;

/**
 Wherher the image can be display on screen without additional decode.

 @see imageByDecoded

 @warning It just a hint for your code, change it has no other effect.
 */
@property (nonatomic, assign) BOOL isImageDecoded;

#pragma mark - Create image
///=============================================================================
/// @name Create image
///=============================================================================

/**
 Create an animated image with GIF data. After created, you can access
 the images via property '.images'. If the data is not animated gif, this
 function is same as [UIImage imageWithData:data scale:scale];

 @discussion     It has a better display performance, but costs more memory
                 (width * height * frames). It only suited to display small gif
                 such as animated emoji. If you want to display large gif, see
                 `YYGIFImage`.

 @param data     GIF data.

 @param scale    The scale factor

 @return A new image created from GIF, or nil when an error occurs.
 */
+ (UIImage *)imageWithSmallGIFData:(NSData *)data scale:(CGFloat)scale;

/**
 Whether the data is animated GIF.

 @param data Image data

 @return Returns YES only if the data is gif and contains more than one frame,
         otherwise returns NO.
 */
+ (BOOL)isAnimatedGIFData:(NSData *)data;

/**
 Create an image from a PDF file data or path.

 @discussion If the PDF has multi page, is just return's the first page's
 content. Image's scale is equal to current screen's scale, size is same as
 PDF's origin size.

 @param dataOrPath PDF data in `NSData`, or PDF file path in `NSString`.

 @return A new image create from PDF, or nil when an error occurs.
 */
+ (UIImage *)imageWithPDF:(id)dataOrPath;

/**
 Create an image from a PDF file data or path.

 @discussion If the PDF has multi page, is just return's the first page's
 content. Image's scale is equal to current screen's scale.

 @param dataOrPath  PDF data in `NSData`, or PDF file path in `NSString`.

 @param size     The new image's size, PDF's content will be stretched as needed.

 @return A new image create from PDF, or nil when an error occurs.
 */
+ (UIImage *)imageWithPDF:(id)dataOrPath size:(CGSize)size;

/**
 Create a square image from apple emoji.

 @discussion It creates a square image from apple emoji, image's scale is equal
 to current screen's scale. The original emoji image in `AppleColorEmoji` font
 is in size 160*160 px.

 @param emoji single emoji, such as @"😄".

 @param size  image's size.

 @return Image from emoji, or nil when an error occurs.
 */
+ (UIImage *)imageWithEmoji:(NSString *)emoji size:(CGFloat)size;

/**
 Create and return a 1x1 point size image with the given color.

 @param color  The color.
 */
+ (UIImage *)imageWithColor:(UIColor *)color;

/**
 Create and return a pure color image with the given color and size.

 @param color  The color.
 @param size   New image's type.
 */
+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size;

#pragma mark - Image Info
///=============================================================================
/// @name Image Info
///=============================================================================

/**
 Returns the color from the pixel pointed in this image.

 @param point  The point inside this image.
               point.x is in range [0,image.width-1],
               point.y is in range [0,image.height-1].
               If the point is out of this image, nil value will be returned.
 */
- (UIColor *)colorAtPoint:(CGPoint)point;

/**
 Whether this image has alpha channel.
 */
- (BOOL)hasAlphaChannel;

#pragma mark - Modify Image
///=============================================================================
/// @name Modify Image
///=============================================================================

/**
 Draws the entire image in the specified rectangle, content changed with
 the contentMode.

 @discussion This method draws the entire image in the current graphics context,
 respecting the image's orientation setting. In the default coordinate system,
 images are situated down and to the right of the origin of the specified
 rectangle. This method respects any transforms applied to the current graphics
 context, however.

 @param rect        The rectangle in which to draw the image.

 @param contentMode Draw content mode
 */
- (void)drawInRect:(CGRect)rect withContentMode:(UIViewContentMode)contentMode;

/**
 Returns a new image which is scaled from this image.
 The image will be stretched as needed.

 @param size  The new size to be scaled, values should be positive.

 @return      The new image with the given size.
 */
- (UIImage *)imageByResizeToSize:(CGSize)size;

/**
 Returns a new image which is scaled from this image.
 The image content will be changed with thencontentMode.

 @param size        The new size to be scaled, values should be positive.

 @param contentMode The content mode for image content.

 @return The new image with the given size.
 */
- (UIImage *)imageByResizeToSize:(CGSize)size contentMode:(UIViewContentMode)contentMode;

/**
 Returns a new image which is cropped from this image.

 @param rect  Image's inner rect.

 @return      The new image, or nil if an error occurs.
 */
- (UIImage *)imageByCropToRect:(CGRect)rect;

/**
 Returns a new image which is edge inset from this image.

 @param insets  Inset (positive) for each of the edges, values can be negative to 'outset'.

 @param color   Extend edge's fill color, nil means clear color.

 @return        The new image, or nil if an error occurs.
 */
- (UIImage *)imageByInsetEdge:(UIEdgeInsets)insets withColor:(UIColor *)color;

/**
 Rounds the image with a given corner size.

 @param radius  The radius of each corner oval. Values larger than half the
                rectangle's width or height are clamped appropriately to half
                the width or height.
 */
- (UIImage *)imageByRoundCornerRadius:(CGFloat)radius;

/**
 Rounds the image with a given corner size.

 @param radius       The radius of each corner oval. Values larger than half the
                     rectangle's width or height are clamped appropriately to
                     half the width or height.

 @param corners      A bitmask value that identifies the corners that you want
                     rounded. You can use this parameter to round only a subset
                     of the corners of the rectangle.

 @param borderWidth  The inset border with clear color. Values larger than half
                     the rectangle's width or height are clamped appropriately
                     to half the width or height.
 */
- (UIImage *)imageByRoundCornerRadius:(CGFloat)radius
                              corners:(UIRectCorner)corners
                          borderWidth:(CGFloat)borderWidth;

/**
 Returns a rotated image (relative to the center).

 @param radians   Rotated radians in counterclockwise.⟲

 @param fitSize   YES: new image's size is extend to fit all content.
                  NO: image's size will not change, content may be clipped.
 */
- (UIImage *)imageByRotate:(CGFloat)radians fitSize:(BOOL)fitSize;

/**
 Returns a image rotated counterclockwise by a quarter‑turn (90°). ⤺
 The width and height will be exchanged.
 */
- (UIImage *)imageByRotateLeft90;

/**
 Returns a image rotated clockwise by a quarter‑turn (90°). ⤼
 The width and height will be exchanged.
 */
- (UIImage *)imageByRotateRight90;

/**
 Returns a image rotated 180° . ↻
 */
- (UIImage *)imageByRotate180;

/**
 Returns a vertically flipped image. ⥯
 */
- (UIImage *)imageByFlipVertical;

/**
 Returns a horizontally flipped image. ⇋
 */
- (UIImage *)imageByFlipHorizontal;

#pragma mark - Image Effect
///=============================================================================
/// @name Image Effect
///=============================================================================

/**
 Tint the image in alpha channel with the given color.

 @param color  The color.
 */
- (UIImage *)imageByTintColor:(UIColor *)color;

/**
 Returns a grayscaled image.
 */
- (UIImage *)imageByGrayscale;

/**
 Applies a blur effect to this image. Suitable for blur any content.
 */
- (UIImage *)imageByBlurSoft;

/**
 Applies a blur effect to this image. Suitable for blur any content except pure white.
 */
- (UIImage *)imageByBlurLight;

/**
 Applies a blur effect to this image. Suitable for displaying black text.
 */
- (UIImage *)imageByBlurExtraLight;

/**
 Applies a blur effect to this image. Suitable for displaying white text.
 */
- (UIImage *)imageByBlurDark;

/**
 Applies a blur and tint color to this image.

 @param tintColor  The tint color.
 */
- (UIImage *)imageByBlurWithTint:(UIColor *)tintColor;

/**
 Applies a blur, tint color, and saturation adjustment to this image,
 optionally within the area specified by @a maskImage.

 @param blurRadius     The radius of the blur in points, 0 means no blur effect.

 @param tintColor      An optional UIColor object that is uniformly blended with
                       the result of the blur and saturation operations. The
                       alpha channel of this color determines how strong the
                       tint is. nil means no tint.

 @param tintBlendMode  The @a tintColor blend mode. Default is kCGBlendModeNormal (0).

 @param saturation     A value of 1.0 produces no change in the resulting image.
                       Values less than 1.0 will desaturation the resulting image
                       while values greater than 1.0 will have the opposite effect.
                       0 means gray scale.

 @param maskImage      If specified, @a inputImage is only modified in the area(s)
                       defined by this mask.  This must be an image mask or it
                       must meet the requirements of the mask parameter of
                       CGContextClipToMask.

 @return               image with effect, or nil if an error occurs (e.g. no
                       enough memory).
 */
- (UIImage *)imageByBlurRadius:(CGFloat)blurRadius
                     tintColor:(UIColor *)tintColor
                      tintMode:(CGBlendMode)tintBlendMode
                    saturation:(CGFloat)saturation
                     maskImage:(UIImage *)maskImage;

@end

#pragma mark - Helper functions

/**
 Create a decoded image (may useful for display), see `-imageByDecoded`.
 */
CGImageRef CGImageCreateDecoded(CGImageRef imageRef);


text:
var gulp = require('gulp');
var ts = require('gulp-typescript');
var tsd = require('gulp-tsd');
var sourcemaps = require('gulp-sourcemaps');
var del = require('del');
var insert = require('gulp-insert');

var tsProject = ts.createProject({
    declarationFiles: true,
    noExternalResolve: true,
    sortOutput: true,
    module: "commonjs"
});

gulp.task('ts-compile', ['ts-typings'], function () {
    var tsResult = gulp.src(['src/*.ts', 'typings/**/*.ts'])
                       .pipe(sourcemaps.init())
                       .pipe(ts(tsProject));
    tsResult.dts.pipe(gulp.dest('./build/definitions'));
    return tsResult.js.pipe(sourcemaps.write())
                      .pipe(insert.prepend("#!/usr/bin/env node\n"))
                      .pipe(gulp.dest('./build'));
})

gulp.task('ts-typings', function (cb) {
    tsd({
        command: 'reinstall',
        config: './tsd.json'
    },cb);
});

gulp.task('clean', function(cb) {
    del(['build', 'typings'], cb);
});

gulp.task('default', function() {
    gulp.start('ts-compile', 'ts-typings');
});

gulp.task('watch', ['ts-compile'], function() {
    gulp.watch('src/*.ts', ['ts-compile']);
});


text:
package org.bzewdu.tools.perftrend.util;

import java.io.*;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Date;
import java.util.StringTokenizer;
import java.util.Vector;

public class Util {
    public static final String SlashNet;
    static String _localHost;

    public static StringBuffer createMsgBuf(final Thread t) {
        final StringBuffer buf = new StringBuffer(t.toString());
        buf.append(":  ");
        buf.append(new Date());
        buf.append(' ');
        return buf;
    }

    public static StringBuffer createMsgBuf() {
        return createMsgBuf(Thread.currentThread());
    }

    public static String[] findAllPatterns(final File f, final String pattern) throws IOException {
        final int len = pattern.length();
        BufferedReader in = null;
        int count = 0;
        try {
            in = new BufferedReader(new FileReader(f));
            String line;
            while ((line = in.readLine()) != null) {
                if (line.contains(pattern)) {
                    ++count;
                }
            }
        } finally {
            if (in != null) {
                in.close();
            }
        }
        final String[] strarr = new String[count];
        count = 0;
        try {
            in = new BufferedReader(new FileReader(f));
            String line;
            while ((line = in.readLine()) != null) {
                if (line.contains(pattern)) {
                    strarr[count] = line;
                    ++count;
                }
            }
        } finally {
            in.close();
        }
        return strarr;
    }

    public static String fgrep(final String pattern, final BufferedReader in) throws IOException {
        final int len = pattern.length();
        String line;
        while ((line = in.readLine()) != null) {
            if (line.contains(pattern)) {
                return line;
            }
        }
        return null;
    }

    public static String fgrep(final String pattern, final File f) throws FileNotFoundException, IOException {
        BufferedReader in = null;
        try {
            in = new BufferedReader(new FileReader(f));
            return fgrep(pattern, in);
        } finally {
            if (in != null) {
                in.close();
            }
        }
    }

    public static String fileContains(final File f, final String pattern) throws FileNotFoundException, IOException {
        return fgrep(pattern, f);
    }

    public static long copy(final InputStream src, final OutputStream dst) throws IOException {
        long total = 0L;
        final byte[] buf = new byte[4096];
        int cnt;
        while ((cnt = src.read(buf, 0, 4096)) > 0) {
            dst.write(buf, 0, cnt);
            total += cnt;
        }
        return total;
    }

    public static long copy(final Reader src, final Writer dst) throws IOException {
        long total = 0L;
        final char[] buf = new char[4096];
        int cnt;
        while ((cnt = src.read(buf, 0, 4096)) > 0) {
            dst.write(buf, 0, cnt);
            total += cnt;
        }
        return total;
    }

    public static long copy(final File src, final File dst, final boolean append) throws IOException {
        FileInputStream is = null;
        FileOutputStream os = null;
        try {
            is = new FileInputStream(src);
            os = new FileOutputStream(dst.getPath(), append);
            return copy(is, os);
        } finally {
            if (is != null) {
                is.close();
            }
            if (os != null) {
                os.close();
            }
        }
    }

    public static long copy(final File src, final File dst) throws IOException {
        return copy(src, dst, false);
    }

    public static long copy(final File src, final OutputStream dst) throws IOException {
        FileInputStream loc_src = null;
        try {
            loc_src = new FileInputStream(src);
            return copy(loc_src, dst);
        } finally {
            if (loc_src != null) {
                loc_src.close();
            }
        }
    }

    public static long copy(final File src, final Writer dst) throws IOException {
        FileReader loc_src = null;
        try {
            loc_src = new FileReader(src);
            return copy(loc_src, dst);
        } finally {
            if (loc_src != null) {
                loc_src.close();
            }
        }
    }

    public static int tail(final BufferedReader src, final BufferedWriter dst, final int count) throws IOException {
        int i = 0;
        boolean wrapped = false;
        String[] lines;
        for (lines = new String[count]; (lines[i] = src.readLine()) != null; i = 0, wrapped = true) {
            if (++i == count) {
            }
        }
        if (!wrapped) {
            return 0;
        }
        final int end = i;
        if (++i == count) {
            i = 0;
        }
        do {
            dst.write(lines[i]);
            dst.newLine();
            if (++i == count) {
                i = 0;
            }
        } while (i != end);
        dst.flush();
        return count;
    }

    public static int tail(final BufferedReader src, final BufferedWriter dst) throws IOException {
        return tail(src, dst, 10);
    }

    public static long tail(final File src, final BufferedWriter dst, final int count) throws IOException {
        BufferedReader loc_src = null;
        try {
            loc_src = new BufferedReader(new FileReader(src));
            return tail(loc_src, dst, count);
        } finally {
            if (loc_src != null) {
                loc_src.close();
            }
        }
    }

    public static boolean stringContains(final String src, final String key, final String token) {
        final StringTokenizer st = new StringTokenizer(src, token);
        boolean retval = false;
        while (st.hasMoreTokens()) {
            if (st.nextToken().equals(key)) {
                retval = true;
                break;
            }
        }
        return retval;
    }

    public static boolean stringContains(final String src, final String key) {
        boolean retval = false;
        for (int i = 0; i < src.length(); ++i) {
            for (int j = 0; j < key.length() && key.charAt(j) == src.charAt(i + j); ++j) {
                if (j == key.length() - 1) {
                    retval = true;
                }
            }
        }
        return retval;
    }

    public static String[] tokenize(final String s) {
        final StringTokenizer tokens = new StringTokenizer(s, " \t");
        final int count = tokens.countTokens();
        final String[] v = new String[count];
        for (int i = 0; i < count; ++i) {
            v[i] = tokens.nextToken();
        }
        return v;
    }

    public static boolean samePath(final String s1, final String s2, final String domain) {
        return s1.equals(s2) || (slashNetPath(s1).equals(slashNetPath(s2)) && sameHost(slashNetHost(s1), slashNetHost(s2), domain));
    }

    public static String slashNetHost(final String path) {
        if (path.startsWith(Util.SlashNet)) {
            final int start = Util.SlashNet.length();
            final int end = path.indexOf(File.separator, start);
            return path.substring(start, end);
        }
        if (Util._localHost != null) {
            return Util._localHost;
        }
        try {
            Util._localHost = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e) {
            throw new RuntimeException("no hostname");
        }
        return Util._localHost;
    }

    public static String slashNetPath(final String path) {
        final int len = Util.SlashNet.length();
        return path.startsWith(Util.SlashNet) ? path.substring(path.indexOf(File.separator, len + 1)) : path;
    }

    public static boolean sameHost(final String host1, final String host2, final String domain) {
        if (host1.equals(host2)) {
            return true;
        }
        final String h1 = (host1.indexOf(46) < 0) ? (host1.concat(domain).toLowerCase() + '.') : (host1.toLowerCase() + '.');
        final String h2 = (host2.indexOf(46) < 0) ? (host2.concat(domain).toLowerCase() + '.') : (host2.toLowerCase() + '.');
        return h1.startsWith(h2) || h2.startsWith(h1);
    }

    public static String[] readFromFile(final File readFrom) throws FileNotFoundException, IOException {
        final Vector<String> v = new Vector<String>();
        final BufferedReader in = new BufferedReader(new FileReader(readFrom));
        int i = 0;
        String line;
        while ((line = in.readLine()) != null) {
            v.add(i, line);
            ++i;
        }
        in.close();
        final String[] str = new String[v.size()];
        for (i = 0; i < v.size(); ++i) {
            str[i] = (String) v.get(i);
        }
        return str;
    }

    public static boolean commandNotFound(final File log, final String cmd) throws IOException {
        if (log.length() > cmd.length() + 1024) {
            return false;
        }
        String s = null;
        try {
            s = fileContains(log, cmd);
        } catch (FileNotFoundException ignored) {
        }
        return s != null && s.indexOf("not found") > 0;
    }

    static {
        SlashNet = File.separator + "net" + File.separator;
    }
}


text:
<?php

$lastOperatorChanged = false;
$lastOperatorId = false;

foreach ($messages as $msg ) : if ($msg->user_id > -1 || $msg->user_id == -2) :

if ($lastOperatorId !== false && $lastOperatorId != $msg->user_id) {
    $lastOperatorChanged = true;
} else {
    $lastOperatorChanged = false;
}

$lastOperatorId = $msg->user_id;

?>
<div class="message-row<?php echo $msg->user_id == 0 ? ' response' : ' message-admin'.($lastOperatorChanged == true ? ' operator-changes' : '')?>" id="msg-<?php echo $msg->id?>">
<?php echo date(erLhcoreClassModule::$dateDateHourFormat,$msg->time);?>
<span class="usr-tit<?php echo $msg->user_id == 0 ? ' vis-tit' : ' op-tit'?>"><?php echo $msg->user_id == 0 ? htmlspecialchars($chat->nick) : htmlspecialchars($msg->name_support) ?>: <?php echo erLhcoreClassBBCode::make_clickable(htmlspecialchars($msg->msg))?>

<?php endif; endforeach; ?>


text:
package net.automatalib.automata.simple;

import java.util.Collection;
import java.util.Iterator;

import net.automatalib.automata.concepts.StateIDs;
import net.automatalib.automata.helpers.SimpleStateIDs;
import net.automatalib.automata.helpers.StateIDGrowingMapping;
import net.automatalib.automata.helpers.StateIDStaticMapping;
import net.automatalib.commons.util.mappings.MutableMapping;
import net.automatalib.ts.simple.SimpleTS;
import org.checkerframework.checker.nullness.qual.Nullable;

/**
 * A simple automaton, i.e., a {@link SimpleTS} with a finite number of states.
 *
 * @param <S>
 *         state class.
 * @param <I>
 *         input symbol class.
 *
 * @author Malte Isberner
 */
public interface SimpleAutomaton<S, I> extends SimpleTS<S, I>, Iterable<S> {

    @Override
    default Iterator<S> iterator() {
        return getStates().iterator();
    }

    /**
     * Retrieves all states of the transition system. Implementing classes should return an unmodifiable collection
     *
     * @return all states in the transition system
     */
    Collection<S> getStates();

    @Override
    default <@Nullable V> MutableMapping<S, V> createStaticStateMapping() {
        return new StateIDStaticMapping<>(stateIDs(), size());
    }

    @Override
    default <@Nullable V> MutableMapping<S, V> createDynamicStateMapping() {
        return new StateIDGrowingMapping<>(stateIDs(), size());
    }

    default StateIDs<S> stateIDs() {
        return new SimpleStateIDs<>(this);
    }

    /**
     * Retrieves the size (number of states) of this transition system.
     *
     * @return the number of states of this transition system
     */
    default int size() {
        return getStates().size();
    }
}