text:
using System;
using UnityEngine;
using UnityEngine.UI;

namespace Demonixis.Toolbox.UI
{
    public sealed class UISelectorWidget : MonoBehaviour
    {
        private int _index = 0;
        private int _size = 0;

        [SerializeField]
        private Text text = null;
        [SerializeField]
        private string[] options = null;
        [SerializeField]
        private bool interactable = true;

        public string[] Options
        {
            get { return options; }
            set
            {
                options = value;
                _size = options.Length;
                Index = 0;
            }
        }

        public int Index
        {
            get { return _index; }
            set
            {
                _index = value;
                if (_index >= _size)
                    _index = 0;
                else if (_index < 0)
                    _index = _size - 1;

                UpdateText();
            }
        }

        public string Value
        {
            get { return options[_index]; }
            set { SetValueActive(value); }
        }

        public event Action<string> ValueChanged = null;
        public event Action<int> IndexChanged = null;

        private void Awake()
        {
            if (_size == 0 && options != null)
                _size = options.Length;
        }

        private void Start()
        {
            UpdateText(false);
        }

        public void Setup<T>(int selected, Action<string> valueChanged)
        {
            var type = typeof(T);
            if (!type.IsEnum)
                throw new UnityException("This is not an Enum");

            var values = Enum.GetNames(type);
            Options = values;
            Index = selected;
            ValueChanged += valueChanged;
        }

        public void Setup<T>(int selected, Action<int> indexChanged)
        {
            var type = typeof(T);
            if (!type.IsEnum)
                throw new UnityException("This is not an Enum");

            var values = Enum.GetNames(type);
            Options = values;
            Index = selected;
            IndexChanged += indexChanged;
        }

        public void Setup(ref string[] values, string selected, Action<string> valueCHanged)
        {
            Options = values;
            Index = Array.IndexOf(values, selected);
            ValueChanged += valueCHanged;
        }

        public void SetInteractable(bool isInteractable)
        {
            var buttons = GetComponentsInChildren<Button>();
            for (int i = 0, l = buttons.Length; i < l; i++)
                buttons[i].interactable = isInteractable;

            interactable = isInteractable;
            enabled = interactable;
        }

        public void ChangeValue(bool inc)
        {
            if (interactable)
                Index += inc ? 1 : -1;
        }

        public void SetValueActive(string value)
        {
            var index = Array.IndexOf(options, value);
            if (index > -1)
                Index = index;
        }

        public void UpdateText(bool notify = true)
        {
            if (text != null)
                text.text = options[_index];

            if (!notify)
                return;

            if (ValueChanged != null && notify)
                ValueChanged(options[_index]);

            if (IndexChanged != null)
                IndexChanged.Invoke(_index);
        }
    }
}


text:
package com.siyeh.ig.logging;

import com.intellij.psi.*;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
import com.siyeh.InspectionGadgetsBundle;
import org.jetbrains.annotations.NotNull;

import java.util.HashMap;
import java.util.Map;

public class LoggingConditionDisagreesWithLogStatementInspection
        extends BaseInspection {

    enum Log4jPriority {
        TRACE, DEBUG, INFO, WARN, ERROR, FATAL
    }
    enum UtilLoggingLevel {
        SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST
    }

    private static final Map<String, Log4jPriority> log4jLogMethodNames =
            new HashMap();
    static {
        log4jLogMethodNames.put("debug", Log4jPriority.DEBUG);
        log4jLogMethodNames.put("error", Log4jPriority.ERROR);
        log4jLogMethodNames.put("fatal", Log4jPriority.FATAL);
        log4jLogMethodNames.put("info", Log4jPriority.INFO);
        log4jLogMethodNames.put("trace", Log4jPriority.TRACE);
        log4jLogMethodNames.put("warn", Log4jPriority.WARN);
    }

    private static final Map<String, UtilLoggingLevel> utilLogMethodNames =
            new HashMap();
    static {
        utilLogMethodNames.put("severe", UtilLoggingLevel.SEVERE);
        utilLogMethodNames.put("warning", UtilLoggingLevel.WARNING);
        utilLogMethodNames.put("info", UtilLoggingLevel.INFO);
        utilLogMethodNames.put("config", UtilLoggingLevel.CONFIG);
        utilLogMethodNames.put("fine", UtilLoggingLevel.FINE);
        utilLogMethodNames.put("finer", UtilLoggingLevel.FINER);
        utilLogMethodNames.put("finest", UtilLoggingLevel.FINEST);
    }

    @NotNull
    public String getDisplayName() {
        return InspectionGadgetsBundle.message(
                "logging.condition.disagrees.with.log.statement.display.name");
    }

    @NotNull
    protected String buildErrorString(Object... infos) {
        return InspectionGadgetsBundle.message(
                "logging.condition.disagrees.with.log.statement.problem.descriptor",
                infos[0]);
    }

    public BaseInspectionVisitor buildVisitor() {
        return new LoggingConditionDisagreesWithLogStatementVisitor();
    }

    private static class LoggingConditionDisagreesWithLogStatementVisitor
            extends BaseInspectionVisitor {

        public void visitMethodCallExpression(
                PsiMethodCallExpression expression) {
            super.visitMethodCallExpression(expression);
            final PsiReferenceExpression methodExpression =
                    expression.getMethodExpression();
            final String referenceName = methodExpression.getReferenceName();
            final Log4jPriority priority =
                    log4jLogMethodNames.get(referenceName);
            final UtilLoggingLevel level =
                    utilLogMethodNames.get(referenceName);
            if (priority == null && level == null) {
                return;
            }
            final PsiMethod method = expression.resolveMethod();
            if (method == null) {
                return;
            }
            final PsiClass containingClass = method.getContainingClass();
            final String qualifiedName = containingClass.getQualifiedName();
            boolean log4j = false;
            boolean javaUtilLogging = false;
            boolean commonsLogging = false;
            if ("org.apache.log4j.Logger".equals(qualifiedName) ||
                    "org.apache.log4j.Category".equals(qualifiedName)) {
                log4j = true;
            } else if ("java.util.logging.Logger".equals(qualifiedName)) {
                javaUtilLogging = true;
            } else if ("org.apache.commons.logging.Log".equals(qualifiedName)) {
                commonsLogging = true;
            } else {
                return;
            }
            final PsiElement parent = expression.getParent();
            if (!(parent instanceof PsiExpressionStatement)) {
                return;
            }
            final PsiElement grandParent = parent.getParent();
            final PsiIfStatement ifStatement;
            if (grandParent instanceof PsiCodeBlock) {
                final PsiElement greatGrandParent = grandParent.getParent();
                if (!(greatGrandParent instanceof PsiBlockStatement)) {
                    return;
                }
                final PsiElement greatGreatGrandParent =
                        greatGrandParent.getParent();
                if (!(greatGreatGrandParent instanceof PsiIfStatement)) {
                    return;
                }
                ifStatement = (PsiIfStatement) greatGreatGrandParent;
            } else if (grandParent instanceof PsiIfStatement) {
                ifStatement = (PsiIfStatement) grandParent;
            } else {
                return;
            }
            final PsiExpression condition = ifStatement.getCondition();
            if (!(condition instanceof PsiMethodCallExpression)) {
                return;
            }
            final PsiExpression qualifier =
                    methodExpression.getQualifierExpression();
            if (!(qualifier instanceof PsiReferenceExpression)) {
                return;
            }
            final PsiReferenceExpression referenceExpression =
                    (PsiReferenceExpression) qualifier;
            final PsiElement target = referenceExpression.resolve();
            if (target == null) {
                return;
            }

            final PsiMethodCallExpression methodCallExpression =
                    (PsiMethodCallExpression) condition;
            final PsiReferenceExpression conditionMethodExpression =
                    methodCallExpression.getMethodExpression();
            final PsiExpression conditionQualifier =
                    conditionMethodExpression.getQualifierExpression();
            if (!(conditionQualifier instanceof PsiReferenceExpression)) {
                return;
            }
            final PsiReferenceExpression conditionReferenceExpression =
                    (PsiReferenceExpression) conditionQualifier;
            final PsiElement conditionTarget =
                    conditionReferenceExpression.resolve();
            if (!target.equals(conditionTarget)) {
                return;
            }
            if (commonsLogging &&
                    !hasCommonsLoggingProblem(priority, methodCallExpression)) {
                return;
            } else if (log4j &&
                    !hasLog4jProblem(priority, methodCallExpression)) {
                return;
            } else if (javaUtilLogging &&
                    !hasUtilLoggingProblem(level, methodCallExpression)) {
                return;
            }
            registerMethodCallError(methodCallExpression, referenceName);
        }

        private static boolean hasUtilLoggingProblem(
                UtilLoggingLevel level,
                PsiMethodCallExpression methodCallExpression) {
            final PsiReferenceExpression methodExpression =
                    methodCallExpression.getMethodExpression();
            final String methodName = methodExpression.getReferenceName();
            if (!"isLoggable".equals(methodName)) {
                return false;
            }
            final PsiExpressionList argumentList =
                    methodCallExpression.getArgumentList();
            final PsiExpression[] arguments = argumentList.getExpressions();
            if (arguments.length != 1) {
                return false;
            }
            final PsiExpression argument = arguments[0];
            if (!(argument instanceof PsiReferenceExpression)) {
                return false;
            }
            final PsiReferenceExpression argumentReference =
                    (PsiReferenceExpression) argument;
            final PsiType type = argument.getType();
            if (!(type instanceof PsiClassType)) {
                return false;
            }
            final PsiClassType classType = (PsiClassType) type;
            final PsiClass aClass = classType.resolve();
            if (aClass == null) {
                return false;
            }
            final String qName = aClass.getQualifiedName();
            if (!"java.util.logging.Level".equals(qName)) {
                return false;
            }
            final PsiElement argumentTarget =
                    argumentReference.resolve();
            if (!(argumentTarget instanceof PsiField)) {
                return false;
            }
            final PsiField field = (PsiField) argumentTarget;
            final String name = field.getName();
            UtilLoggingLevel enabledFor =
                    UtilLoggingLevel.valueOf(name);
            return enabledFor != level;
        }

        private static boolean hasCommonsLoggingProblem(
                Log4jPriority priority,
                PsiMethodCallExpression methodCallExpression) {
            final PsiReferenceExpression methodExpression =
                    methodCallExpression.getMethodExpression();
            final String methodName = methodExpression.getReferenceName();
            Log4jPriority enabledFor = null;
            if ("isTraceEnabled".equals(methodName)) {
                enabledFor = Log4jPriority.TRACE;
            } else if ("isDebugEnabled".equals(methodName)) {
                enabledFor = Log4jPriority.DEBUG;
            } else if ("isInfoEnabled".equals(methodName)) {
                enabledFor = Log4jPriority.INFO;
            } else if ("isWarnEnabled".equals(methodName)) {
                enabledFor = Log4jPriority.WARN;
            } else if ("isErrorEnabled".equals(methodName)) {
                enabledFor = Log4jPriority.ERROR;
            } else if ("isFatalEnabled".equals(methodName)) {
                enabledFor = Log4jPriority.FATAL;
            }
            return enabledFor != priority;
        }

        private static boolean hasLog4jProblem(
                Log4jPriority priority,
                PsiMethodCallExpression methodCallExpression) {
            final PsiReferenceExpression methodExpression =
                    methodCallExpression.getMethodExpression();
            final String methodName = methodExpression.getReferenceName();
            Log4jPriority enabledFor = null;
            if ("isDebugEnabled".equals(methodName)) {
                enabledFor = Log4jPriority.DEBUG;
            } else if ("isInfoEnabled".equals(methodName)) {
                enabledFor = Log4jPriority.INFO;
            } else if ("isTraceEnabled".equals(methodName)) {
                enabledFor = Log4jPriority.TRACE;
            } else if ("isEnabledFor".equals(methodName)) {
                final PsiExpressionList argumentList =
                        methodCallExpression.getArgumentList();
                final PsiExpression[] arguments = argumentList.getExpressions();
                for (PsiExpression argument : arguments) {
                    if (!(argument instanceof PsiReferenceExpression)) {
                        continue;
                    }
                    final PsiReferenceExpression argumentReference =
                            (PsiReferenceExpression) argument;
                    final PsiType type = argument.getType();
                    if (!(type instanceof PsiClassType)) {
                        continue;
                    }
                    final PsiClassType classType = (PsiClassType) type;
                    final PsiClass aClass = classType.resolve();
                    if (aClass == null) {
                        continue;
                    }
                    final String qName = aClass.getQualifiedName();
                    if (!"org.apache.log4j.Priority".equals(qName)) {
                        continue;
                    }
                    final PsiElement argumentTarget =
                            argumentReference.resolve();
                    if (!(argumentTarget instanceof PsiField)) {
                        continue;
                    }
                    final PsiField field = (PsiField) argumentTarget;
                    final String name = field.getName();
                    enabledFor = Log4jPriority.valueOf(name);
                }
            }
            return enabledFor != priority;
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
using System.Drawing;

namespace BacteriaSurvive.BL
{
    public class GridPoint
    {
        public Bacteria Bacteria { get; private set; }
        public Point Coordinate { get; private set; }

        public GridPoint(Bacteria bacteria, Point coordinate)
        {
            Bacteria = bacteria;
            Coordinate = coordinate;
        }
    }
}


text:
ACCEPTED

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Annls mycol. 37(3): 220 (1939)

#### Original name
Phyllachora afra Syd., 1939

### Remarks
null


text:
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspkdebug.h>
#include <pspsdk.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

PSP_MODULE_INFO("SioKprintf", PSP_MODULE_KERNEL, 1, 1);

#define DEFAULT_BAUD 115200

/* Define some important parameters, not really sure on names. Probably doesn't matter */
#define PSP_UART4_FIFO 0xBE500000
#define PSP_UART4_STAT 0xBE500018
#define PSP_UART4_DIV1 0xBE500024
#define PSP_UART4_DIV2 0xBE500028
#define PSP_UART4_CTRL 0xBE50002C
#define PSP_UART_CLK   96000000
#define PSP_UART_TXFULL  0x20
#define PSP_UART_RXEMPTY 0x10

/* Some function prototypes we will need */
int sceHprmEnd(void);
int sceSysregUartIoEnable(int uart);
int sceSysconCtrlHRPower(int power);

void sioPutchar(int ch)
{
	while(_lw(PSP_UART4_STAT) & PSP_UART_TXFULL);
	_sw(ch, PSP_UART4_FIFO);
}

void sioSetBaud(int baud)
{
	int div1, div2;

	/* rate set using the rough formula div1 = (PSP_UART_CLK / baud) >> 6 and
	 * div2 = (PSP_UART_CLK / baud) & 0x3F
	 * The uart4 driver actually uses a slightly different formula for div 2 (it
	 * adds 32 before doing the AND, but it doesn't seem to make a difference
	 */
	div1 = PSP_UART_CLK / baud;
	div2 = div1 & 0x3F;
	div1 >>= 6;

	_sw(div1, PSP_UART4_DIV1);
	_sw(div2, PSP_UART4_DIV2);
	_sw(0x60, PSP_UART4_CTRL);
}

static void _sioInit(void)
{
	/* Shut down the remote driver */
	sceHprmEnd();
	/* Enable UART 4 */
	sceSysregUartIoEnable(4);
	/* Enable remote control power */
	sceSysconCtrlHRPower(1);
	/* Delay briefly */
	sceKernelDelayThread(2000000);
}

static void PutCharDebug(unsigned short *data, unsigned int type)
{
	if((type & 0xFF00) == 0)
	{
		if(type == '\n')
		{
			sioPutchar('\r');
		}

		sioPutchar(type);
	}
}

int main_thread(SceSize args, void *argp)
{
	_sioInit();
	sioSetBaud(115200);

	sceKernelRegisterDebugPutchar(PutCharDebug);

	sceKernelExitDeleteThread(0);

	return 0;
}

/* Entry point */
int module_start(SceSize args, void *argp)
{
	int thid;

	/* Create a high priority thread */
	thid = sceKernelCreateThread("SioKprintf", main_thread, 7, 0x800, 0, NULL);
	if(thid >= 0)
	{
		sceKernelStartThread(thid, args, argp);
	}

	return 0;
}

/* Module stop entry */
int module_stop(SceSize args, void *argp)
{
	return 0;
}


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

namespace Clack
{
    public class Program
    {
        static void Main(string[] args)
        {
            using (Clack clack = new Clack())
            {
                clack.Init();
                clack.Listen();
            }
        }
    }
}


text:
package org.exist.xquery;

import org.exist.storage.DBBroker;
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.Database;
import org.xmldb.api.base.ResourceSet;
import org.xmldb.api.base.XMLDBException;
import org.xmldb.api.modules.CollectionManagementService;
import org.xmldb.api.modules.XMLResource;
import org.xmldb.api.modules.XQueryService;

import junit.framework.TestCase;

public class NamespaceUpdateTest extends TestCase {

	private final static String URI = "xmldb:exist://" + DBBroker.ROOT_COLLECTION;

	private final static String namespaces =
		"<test xmlns='http://www.foo.com'>"
			+ "<section>"
			+ "<title>Test Document</title>"
			+ "<c:comment xmlns:c='http://www.other.com'>This is my comment</c:comment>"
			+ "</section>"
			+ "</test>";

	private Collection testCollection;

	public void testUpdateAttribute() {
		try {
			XQueryService service = (XQueryService) testCollection.getService("XQueryService", "1.0");
			String query =
				"declare namespace t='http://www.foo.com';\n" +
				"<test xmlns='http://www.foo.com'>\n" +
				"{\n" +
				"	update insert attribute { 'ID' } { 'myid' } into /t:test\n" +
				"}\n" +
				"</test>";
			service.query(query);

			query =
				"declare namespace t='http://www.foo.com';\n" +
				"/t:test/@ID";
			ResourceSet result = service.query(query);
			assertEquals(1, result.getSize());
			assertEquals("myid", result.getResource(0).getContent().toString());
		} catch (Exception e) {
			fail(e.getMessage());
		}
	}

	protected void setUp() {
		try {
			// initialize driver
			Class cl = Class.forName("org.exist.xmldb.DatabaseImpl");
			Database database = (Database) cl.newInstance();
			database.setProperty("create-database", "true");
			DatabaseManager.registerDatabase(database);

			Collection root =
				DatabaseManager.getCollection(
					URI,
					"admin",
					null);
			CollectionManagementService service =
				(CollectionManagementService) root.getService(
					"CollectionManagementService",
					"1.0");
			testCollection = service.createCollection("test");
			assertNotNull(testCollection);

			XMLResource doc =
				(XMLResource) root.createResource("namespace-updates.xml", "XMLResource");
			doc.setContent(namespaces);
			testCollection.storeResource(doc);
		} catch (ClassNotFoundException e) {
		} catch (InstantiationException e) {
		} catch (IllegalAccessException e) {
		} catch (XMLDBException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		junit.textui.TestRunner.run(NamespaceUpdateTest.class);
	}
}


text:
<?php
/**
 * Class OneClickRemoveUserInput
 *
 * @package Freshwork\Transbank
 * @subpackage WebpayOneClick
 * @author Gonzalo De Spirito <gonzunigad@gmail.com>
 * @version 0.1 (06/07/2016)
 */

namespace Freshwork\Transbank\WebpayOneClick;

/**
 * Class OneClickRemoveUserInput
 *
 * @package Freshwork\Transbank\WebpayOneClick
 */
class OneClickRemoveUserInput
{
    /** @var string $tbkUser Unique customer inscription identifier */
    public $tbkUser;

    /** @var string $username Customer username */
    public $username;
}


text: require 'inkscape_merge/processor'


text:
<!DOCTYPE html>

<meta charset="UTF-8">

<title>_wordpress2jekyll.py - RDoc Documentation</title>

<link href="../fonts.css" rel="stylesheet">
<link href="../rdoc.css" rel="stylesheet">

    Home

    Pages
    Classes
    Methods

  <form action="#" method="get" accept-charset="utf-8">

      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">

  </form>

Pages

LICENSE

README

Readme

_wordpress2jekyll.py

style.css

#!/usr/bin/env python3

import sys, re

def re_sub(pattern, replacement, string):

def _r(m):
        # Now this is ugly.
        # Python has a "feature" where unmatched groups return None
        # then re.sub chokes on this.
        # see http://bugs.python.org/issue1519638

        # this works around and hooks into the internal of the re module...

        # the match object is replaced with a wrapper that
        # returns "" instead of None for unmatched groups

        class _m():
                def __init__(self, m):
                        self.m=m
                        self.string=m.string
                def group(self, n):
                        return m.group(n) or ""

        return re._expand(pattern, _m(m), replacement)

return re.sub(pattern, _r, string)

def parseCaptions(content):

"""
[caption id="attachment_76716" align="aligncenter" width="500"]<a href="http://martin-thoma.com/wp-content/uploads/2013/11/WER-calculation.png"><img src="http://martin-thoma.com/wp-content/uploads/2013/11/WER-calculation.png" alt="WER calculation" width="500" height="494" class="size-full wp-image-76716" /></a> WER calculation[/caption]

to

{% caption align="aligncenter" width="500" alt="WER calculation" text="WER calculation" url="../images/2013/11/WER-calculation.png" %}
"""
import re

pattern = '\[caption(.*?)align="(?P<align>.*?)"(.*?)(caption="(?P<caption>.*?)")?(.*?)\]' + \
    '<a(.*?)href=\"(?P<url>.*?)\"(?P<asonst>.*?)>' + \
    '<img(.*?)' + \
        'class=\"(?P<imgclass>.*?)\"\s*' + \
        'src=\"(?P<imgurl>http://martin-thoma.com/wp-content/uploads/(?P<innerurl>.*?))\" ' + \
        'alt=\"(?P<alt>.*?)\"\s*' + \
        '(title=\"(?P<title>.*?)\")?\s*' + \
        'width=\"(?P<width>.*?)\"\s*' + \
        'height=\"(?P<height>.*?)\"\s*' + \
        '(?P<isonst>.*?)/>' + \
    '</a>\s*' + \
    '(?P<text>.*?)\[/caption\]'
pattern = re.compile(pattern)
results = [m.groupdict() for m in pattern.finditer(content)]
for result in results:
    for key, value in result.items():
        print("%s:\t%s" % (key, value))

content = re_sub(pattern, '{% caption align="\g<align>" width="\g<width>" caption="\g<caption>\g<text>" url="../images/\g<innerurl>" alt="\g<alt>" title="\g<title>" height="\g<height>" class="\g<imgclass>" %}', content)

return content

def pageCodeConversion(page):

yaml, content = getYaml(page)

content = content.replace("[latex]", "$")
content = content.replace("[/latex]", "$")

# Syntax highlighter: also '[python collapse="true"]'
# [c] is dangerous. Use it with caution!
for language in ['python', 'cpp', 'text', 'bash', 'java', 'javascript']:
    content = content.replace("["+language+"]", "{% highlight "+language+" %}")
    content = content.replace("[/"+language+"]", "{% endhighlight %}")
content = parseCaptions(content)
return "---" + yaml + "---" + content

def getYaml(content):

tmp, yaml, *content = content.split("---") #here you need python3
content = "---".join(content)
return (yaml, content)

def featuredImage(website, content):

post2image = {}
# Get all featured image urls connected to posts
import urllib2
from bs4 import BeautifulSoup

# Parse Website for images
while website:
    response = urllib2.urlopen(website)
    html = response.read()
    soup = BeautifulSoup(html)
    for entry in soup.find_all("div", "entry"):
        img = entry.find("img")
        if img is not None:
            imgsrc = img['src'].split("uploads/")[1]

            a = entry.find("a", "readmore")
            post = a['href'][len(website):-1]

            post2image[post] = imgsrc

    nav = soup.find("div", "alignleft")
    if nav is not None:
        website = nav.find("a")
        if website is not None:
            website = website['href']
    else:
        website = None
    print(website)

yaml, content = getYaml(content)
hasFeaturedImage = False

for i, line in enumerate(yaml.split("\n")):
    if ":" in line:
        if line.startswith("featured_image"):
            hasFeaturedImage = True
            break
        if line.startswith("comment"):
            commentline = i

if not hasFeaturedImage:
    mdfilename = filename[len("./_posts/2013-11-18-"):-len(".markdown")]
    if mdfilename not in post2image:
        print("w warning: %s might not have a featured image." % mdfilename)
    else:
        print("# success: %s" % mdfilename)
        imgsrc = post2image[mdfilename]
        newsrc = "---" + yamml + "featured_image: "+imgsrc+"\n" + "---" + content
        with open(filename, 'w') as f:
            f.write(newsrc)
else:
    print("x info: %s has already a featured image" % filename)

def changeYaml(content):

tmp, yaml, *contentArray = content.split("---")
newContent = "---\n"
isComment = False
isTagOrCat = False
for line in yaml.split("\n"):
    if line.startswith("layout:") or \
        line.startswith("title:") or \
        line.startswith("author:") or \
        line.startswith("date:") or \
        line.startswith("context:") or \
        line.startswith("featured_image:"):
        newContent += line + "\n"
        isComment = False
        isTagOrCat = False
    elif line.startswith("status:") or \
        line.startswith("published:") or \
        line.startswith("author_login:") or \
        line.startswith("author_email:") or \
        line.startswith("author_url:") or \
        line.startswith("wordpress_id:") or \
        line.startswith("wordpress_url:") or \
        line.startswith("published:"):
        isComment = False
        isTagOrCat = False
        pass#ignore those lines (that means: delete them!)
    elif line.startswith("comments:"):
        isComment = True
    elif line.startswith("tags:"):
        newContent += line + "\n"
        isTagOrCat = True
    elif line.startswith("categories:"):
        newContent += line + "\n"
        isTagOrCat = True
    elif line.startswith("-") and isComment:
        pass
    elif line.startswith("-") and isTagOrCat:
        newContent += line + "\n"
    else:
        print(line)
newContent += "---"
newContent += "---".join(contentArray)
return newContent

def forEveryPost(website, operation, development=True):

from os import listdir
directory = "./_drafts/"
files = sorted(listdir(directory))
for f in files:
    filename = directory+f

    with open(filename) as f:
        content = f.read()
    newContent = operation(content)

    print(filename)
    if not development:
        with open(filename, 'w') as f:
            f.write(newContent)
    else:
        #print(newContent)
        print("#"*80)

if __name__ == "__main__":

"""
from argparse import ArgumentParser
parser = ArgumentParser()
# Add more options if you like
parser.add_argument("-f", "--file", dest="filename", required="True",
                  help="convert file FILE", metavar="FILE")

args = parser.parse_args()

pageCodeConversion(args.filename)
"""

# improve things
forEveryPost("http://martin-thoma.com/", pageCodeConversion, False)

Validate

Generated by RDoc 4.1.1.

Based on Darkfish by Michael Granger.


text:
require "travis/worker/version"

require 'resque'
require 'resque/heartbeat'
require 'travis/worker/core_ext/ruby/hash/deep_symbolize_keys'
require 'socket'

module Travis
  module Worker
    class VmNotFound < RuntimeError; end

    autoload :Application,     'travis/worker/application'
    autoload :BuildDispatcher, 'travis/worker/build_dispatcher'
    autoload :Builders,        'travis/worker/builders'
    autoload :Config,          'travis/worker/config'
    autoload :Job,             'travis/worker/job'
    autoload :Reporter,        'travis/worker/reporter'
    autoload :Shell,           'travis/worker/shell'

    module Workers
      autoload :Base,     'travis/worker/workers/base'
      autoload :Amqp,     'travis/worker/workers/amqp'
      autoload :Resque,   'travis/worker/workers/resque'
    end

    class << self

      # @group Resque API

      def init
        Resque.redis = ENV['REDIS_URL'] = Travis::Worker.config.redis.url
      end

      def perform(payload)
        Workers::Resque.new(payload).work!
      end

      # @endgroup

      def config
        @config ||= Config.new
      end

      # @group SSH shell access

      attr_writer :shell

      def discard_shell!
        @shell = nil
      end # discard_shell!

      def shell
        @shell ||= Travis::Worker::Shell::Session.new(vm, vagrant.config.ssh)
      end

      # @endgroup

      # @group AMQP connection

      attr_accessor :amqp_connection

      # @endgroup

      def name
        @name ||= "#{hostname}:#{ENV['VM']}"
      end

      def hostname
        @hostname ||= Socket.gethostname
      end

      def vm
        @vm ||= vagrant.vms[(ENV['VM'] || '').to_sym] || raise(VmNotFound, "could not find vm #{ENV['VM'].inspect}")
      end

      def vagrant
        @vagrant ||= begin
          require 'vagrant'
          ::Vagrant::Environment.new.load!
        end
      end
    end
  end # Worker
end # Travis


text:
using System;
using System.Numerics;
using System.Linq;

namespace _01.ConvertBaseToBase
{
    class ConvertBaseToBase
    {
        static void Main(string[] args)
        {
            BigInteger[] input = Console.ReadLine()
                .Split(' ')
                .Select(BigInteger.Parse)
                .ToArray();
            string result = string.Empty;

            BigInteger baseN = input[0]; // 2 <= N <= 10
            BigInteger numberToConvert = input[1];

            string preResult = string.Empty;
            BigInteger reminder = 0;

            while (numberToConvert > 0)
            {
                reminder = numberToConvert % baseN;
                numberToConvert /= baseN;
                preResult += reminder.ToString();
            }

            for (int i = preResult.Length - 1; i >= 0; i--)
            {
                result += preResult[i];
            }

            Console.WriteLine(result);
        }
    }
}


text:
#ifndef _STDERR_PLUGIN_
#define _STDERR_PLUGIN_

#include <dae/daeTypes.h>
#include <dae/daeErrorHandler.h>

/**
 * The @c stdErrPlugin class is the default implementation of daeErrorHandler. It routes the Error
 * and Warning messaged to stdout.
 */
class DLLSPEC stdErrPlugin : public daeErrorHandler {
public:
	stdErrPlugin();
	virtual ~stdErrPlugin();

public:
	void handleError( daeString msg );
	void handleWarning( daeString msg );
};

/**
 * The @c quietErrorHandler class is an alternative implementation of daeErrorHandler. It suppresses
 * error and warning messages. The easiest way to use it is like this:
 *   daeErrorHandler::setErrorHandler(&quietErrorHandler::getInstance());
 */
class DLLSPEC quietErrorHandler : public daeErrorHandler {
public:
	quietErrorHandler() { }
	void handleError(daeString msg) { }
	void handleWarning(daeString msg) { }

	static quietErrorHandler& getInstance() { return theInstance; }

private:
	static quietErrorHandler theInstance;
};

#endif


text:
layout: post
title: "Updating map values in Clojure"
comments: true
date: 2014-11-28 7:05
category: blog
tags: [clojure]
share: true
---

This post is an experiment in stream of consciousness programming.
I will attempt to recreate my thought process, even errors.
I believe this may be more useful to my future self than having perfect code and wondering how I ever came up with that. Plus it gives me an excuse to write less than prefect posts and get [back to attaining vision]({% post_url 2014-10-07-back-to-attaining-vision %}).
So here goes.

The other day I needed to update the values of specific keys in a map.
I wanted to apply a function to the values of these keys.

As an example, say we have the following map:
{% highlight clojure %}
user=> (def m {:a 1 :b 2 :c 3 :d 4})
#'user/m
{% endhighlight %}

We want to apply an arbitrary function, say `inc`, to the values of keys `:a` and `:b`, resulting in the following map:

{% highlight clojure %}
{:a 2 :b 3 :c 3 :d 4}
{% endhighlight %}

Googling a bit, I found a post by Jay Fields, [Clojure: Apply a Function To Each Value of a Map](http://blog.jayfields.com/2011/08/clojure-apply-function-to-each-value-of.html), that did almost what I needed, but not quite.
I don't want to apply the function to all values, just a specific subset.

Next I searched [clojure.core](http://clojure.github.io/clojure/clojure.core-api.html).
The function `update-in` seem to be the closest thing to what we're looking for.
Let's try it out.

{% highlight clojure %}
user=> (update-in m [:a :b] inc)

NullPointerException   clojure.lang.Numbers.ops (Numbers.java:961)
{% endhighlight %}

That didn't quite work.
Let's take a look at the docs.

{% highlight clojure %}
user=> (doc update-in)
-------------------------
clojure.core/update-in
([m [k & ks] f & args])
  'Updates' a value in a nested associative structure, where ks is a
  sequence of keys and f is a function that will take the old value
  and any supplied args and return the new value, and returns a new
  nested structure.  If any levels do not exist, hash-maps will be
  created.
{% endhighlight %}

This updates a nested associative array, not exactly what we need.

{% highlight clojure %}
user=> (update-in m [:a] inc)
{:c 3, :b 2, :d 4, :a 2}
{% endhighlight %}

Hmm. That won't do.

Switching gears, maybe we can create a vector of updated key-values and `assoc` them onto the existing map.
Let's take all the keys we want to update the values of, create a vector of `[key updated-value]` for each and `assoc` them onto the original map.

{% highlight clojure %}
user=> (map #(vector % (inc (% m))) [:a :b])
([:a 2] [:b 3])
user=> (mapcat #(vector % (inc (% m))) [:a :b])
(:a 2 :b 3)
{% endhighlight %}

So we have a seq of `kvs`, now let's `assoc` the mappings to our original map.

{% highlight clojure %}
user=> (apply assoc m (mapcat #(vector % (inc (% m))) [:a :b]))
{:c 3, :b 3, :d 4, :a 2}
{% endhighlight %}

This works, but there has to be a better way.

Let's try to get rid of the ugly mapcat-vector calls.
Let's create a function for updating key-value pairs and use a for-comprehension.

{% highlight clojure %}
user=> (defn map-keys [f & ks]
  #_=>   (for [k ks] [k (f k)]))
#'user/map-keys
user=> (map-keys (comp inc m) :a :b)
([:a 2] [:b 3])
{% endhighlight %}

Oops. Let's flatten that out.

{% highlight clojure %}
user=> (defn map-keys [f & ks]
  #_=>   (flatten (for [k ks] [k (f k)])))
#'user/map-keys
user=> (map-keys (comp inc m) :a :b)
(:a 2 :b 3)
user=> (apply assoc m (apply map-keys (comp inc m) [:a :b]))
{:c 3, :b 3, :d 4, :a 2}
{% endhighlight %}

That gives us what we want, but depending on your tastes, may be more complicated than the original.

I'm not sure

{% highlight clojure %}
(defn map-keys [f & ks] (flatten (for [k ks] [k (f k)])))
{% endhighlight %}

is better than

{% highlight clojure %}
(defn map-keys [f & ks] (mapcat #(vector % (f %)) ks))
{% endhighlight %}

Pick your poison.

__Next try:__
Instead of creating a vector of key-values, let's have map-keys create a map and then we can merge it with the existing map.

{% highlight clojure %}
user=> (defn map-keys
  #_=>   [f & ks]
  #_=>   (into {}
  #_=>         (for [k ks] [k (f k)])))
#'user/map-keys
user=> (map-keys (comp inc m) :a :b)
{:a 2, :b 3}
user=> (merge m (apply map-keys (comp inc m) [:a :b]))
{:c 3, :b 3, :d 4, :a 2}
{% endhighlight %}

This gives us the right answer, but we can do better.
Let's add the `merge` into the function to make it cleaner.

{% highlight clojure %}
user=> (defn map-keys
  #_=>   [m ks f]
  #_=>   (merge m
  #_=>     (into {}
  #_=>       (for [k ks] [k (f (k m))]))))
#'user/map-keys

user=> (map-keys m [:a :b] inc)
{:c 3, :b 3, :d 4, :a 2}
{% endhighlight %}

Let's add optional args to function to make it more useful.

{% highlight clojure %}
user=> (defn map-keys
  #_=>   [m ks f & args]
  #_=>   (merge m
  #_=>     (into {}
  #_=>       (for [k ks] [k (apply f (k m) args)]))))
#'user/map-keys
;; Make sure we didn't introduce regressions
user=> (map-keys m [:a :b] inc)
{:c 3, :b 3, :d 4, :a 2}
;; Test function with extra args
user=> (map-keys m [:a :b] * 5)
{:c 3, :b 10, :d 4, :a 5}
{% endhighlight %}

Perfect. I know this is perfectly good Clojure code.
We are iterating over the keys and only applying the function to those keys.

From looking at the definition of `map-keys`, what we are actually doing is iterating over keys.
So let's go back to `update-in`.
If we think about it, what we really want is to call `update-in`
on each key and accumulate the results.

Ding. Ding. Ding. What we wanted all along was `reduce`.

{% highlight clojure %}
user=> (defn map-values
  #_=>   [m keys f]
  #_=>   (reduce #(update-in %1 [%2] f) m keys))
#'user/map-values
user=> (map-values m [:a :b] inc)
{:c 3, :b 3, :d 4, :a 2}
{% endhighlight %}

Perfect.

Now let's clean it up a little to accept functions with parameters.

{% highlight clojure %}
user=> (defn map-values
  #_=>   [m keys f & args]
  #_=>   (reduce #(apply update-in %1 [%2] f args) m keys))
#'user/map-values
;; Let's make sure we haven't broken anything.
user=> (map-values m [:a :b] inc)
{:c 3, :b 3, :d 4, :a 2}
;; And a function with args.
user=> (map-values m [:a :b] * 5)
{:c 3, :b 10, :d 4, :a 5}
{% endhighlight %}

There are many ways to implement updating keys, there is no right way.
I prefer the reduce variant as I believe it is more concise.

### Conclusion

I finally hit upon the `reduce` variant when I stepped back and and saw that what I really wanted was to call `update-in` many times and accumulate the results.

As a rule of thumb, whenever I think, _"Man, that function is almost what I need, I just wish I could apply it to multiple arguments separately and compose the results"_, I start to think the situation may be calling for a `reduce` implementation.


text:
/**
 * Autogenerated by Thrift Compiler (0.9.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
package org.apache.accumulo.core.gc.thrift;

import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;

import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@SuppressWarnings("all") public class GCMonitorService {

  public interface Iface {

    public GCStatus getStatus(org.apache.accumulo.trace.thrift.TInfo tinfo, org.apache.accumulo.core.security.thrift.TCredentials credentials) throws org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException, org.apache.thrift.TException;

  }

  public interface AsyncIface {

    public void getStatus(org.apache.accumulo.trace.thrift.TInfo tinfo, org.apache.accumulo.core.security.thrift.TCredentials credentials, org.apache.thrift.async.AsyncMethodCallback<AsyncClient.getStatus_call> resultHandler) throws org.apache.thrift.TException;

  }

  public static class Client extends org.apache.thrift.TServiceClient implements Iface {
    public static class Factory implements org.apache.thrift.TServiceClientFactory<Client> {
      public Factory() {}
      public Client getClient(org.apache.thrift.protocol.TProtocol prot) {
        return new Client(prot);
      }
      public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
        return new Client(iprot, oprot);
      }
    }

    public Client(org.apache.thrift.protocol.TProtocol prot)
    {
      super(prot, prot);
    }

    public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
      super(iprot, oprot);
    }

    public GCStatus getStatus(org.apache.accumulo.trace.thrift.TInfo tinfo, org.apache.accumulo.core.security.thrift.TCredentials credentials) throws org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException, org.apache.thrift.TException
    {
      send_getStatus(tinfo, credentials);
      return recv_getStatus();
    }

    public void send_getStatus(org.apache.accumulo.trace.thrift.TInfo tinfo, org.apache.accumulo.core.security.thrift.TCredentials credentials) throws org.apache.thrift.TException
    {
      getStatus_args args = new getStatus_args();
      args.setTinfo(tinfo);
      args.setCredentials(credentials);
      sendBase("getStatus", args);
    }

    public GCStatus recv_getStatus() throws org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException, org.apache.thrift.TException
    {
      getStatus_result result = new getStatus_result();
      receiveBase(result, "getStatus");
      if (result.isSetSuccess()) {
        return result.success;
      }
      if (result.sec != null) {
        throw result.sec;
      }
      throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getStatus failed: unknown result");
    }

  }
  public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface {
    public static class Factory implements org.apache.thrift.async.TAsyncClientFactory<AsyncClient> {
      private org.apache.thrift.async.TAsyncClientManager clientManager;
      private org.apache.thrift.protocol.TProtocolFactory protocolFactory;
      public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) {
        this.clientManager = clientManager;
        this.protocolFactory = protocolFactory;
      }
      public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) {
        return new AsyncClient(protocolFactory, clientManager, transport);
      }
    }

    public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) {
      super(protocolFactory, clientManager, transport);
    }

    public void getStatus(org.apache.accumulo.trace.thrift.TInfo tinfo, org.apache.accumulo.core.security.thrift.TCredentials credentials, org.apache.thrift.async.AsyncMethodCallback<getStatus_call> resultHandler) throws org.apache.thrift.TException {
      checkReady();
      getStatus_call method_call = new getStatus_call(tinfo, credentials, resultHandler, this, ___protocolFactory, ___transport);
      this.___currentMethod = method_call;
      ___manager.call(method_call);
    }

    public static class getStatus_call extends org.apache.thrift.async.TAsyncMethodCall {
      private org.apache.accumulo.trace.thrift.TInfo tinfo;
      private org.apache.accumulo.core.security.thrift.TCredentials credentials;
      public getStatus_call(org.apache.accumulo.trace.thrift.TInfo tinfo, org.apache.accumulo.core.security.thrift.TCredentials credentials, org.apache.thrift.async.AsyncMethodCallback<getStatus_call> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
        super(client, protocolFactory, transport, resultHandler, false);
        this.tinfo = tinfo;
        this.credentials = credentials;
      }

      public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
        prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getStatus", org.apache.thrift.protocol.TMessageType.CALL, 0));
        getStatus_args args = new getStatus_args();
        args.setTinfo(tinfo);
        args.setCredentials(credentials);
        args.write(prot);
        prot.writeMessageEnd();
      }

      public GCStatus getResult() throws org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException, org.apache.thrift.TException {
        if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
          throw new IllegalStateException("Method call not finished!");
        }
        org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());
        org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);
        return (new Client(prot)).recv_getStatus();
      }
    }

  }

  public static class Processor<I extends Iface> extends org.apache.thrift.TBaseProcessor<I> implements org.apache.thrift.TProcessor {
    private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName());
    public Processor(I iface) {
      super(iface, getProcessMap(new HashMap<String, org.apache.thrift.ProcessFunction<I, ? extends org.apache.thrift.TBase>>()));
    }

    protected Processor(I iface, Map<String,  org.apache.thrift.ProcessFunction<I, ? extends  org.apache.thrift.TBase>> processMap) {
      super(iface, getProcessMap(processMap));
    }

    private static <I extends Iface> Map<String,  org.apache.thrift.ProcessFunction<I, ? extends  org.apache.thrift.TBase>> getProcessMap(Map<String,  org.apache.thrift.ProcessFunction<I, ? extends  org.apache.thrift.TBase>> processMap) {
      processMap.put("getStatus", new getStatus());
      return processMap;
    }

    public static class getStatus<I extends Iface> extends org.apache.thrift.ProcessFunction<I, getStatus_args> {
      public getStatus() {
        super("getStatus");
      }

      public getStatus_args getEmptyArgsInstance() {
        return new getStatus_args();
      }

      protected boolean isOneway() {
        return false;
      }

      public getStatus_result getResult(I iface, getStatus_args args) throws org.apache.thrift.TException {
        getStatus_result result = new getStatus_result();
        try {
          result.success = iface.getStatus(args.tinfo, args.credentials);
        } catch (org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException sec) {
          result.sec = sec;
        }
        return result;
      }
    }

  }

  public static class getStatus_args implements org.apache.thrift.TBase<getStatus_args, getStatus_args._Fields>, java.io.Serializable, Cloneable   {
    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getStatus_args");

    private static final org.apache.thrift.protocol.TField TINFO_FIELD_DESC = new org.apache.thrift.protocol.TField("tinfo", org.apache.thrift.protocol.TType.STRUCT, (short)2);
    private static final org.apache.thrift.protocol.TField CREDENTIALS_FIELD_DESC = new org.apache.thrift.protocol.TField("credentials", org.apache.thrift.protocol.TType.STRUCT, (short)1);

    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
    static {
      schemes.put(StandardScheme.class, new getStatus_argsStandardSchemeFactory());
      schemes.put(TupleScheme.class, new getStatus_argsTupleSchemeFactory());
    }

    public org.apache.accumulo.trace.thrift.TInfo tinfo; // required
    public org.apache.accumulo.core.security.thrift.TCredentials credentials; // required

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
      TINFO((short)2, "tinfo"),
      CREDENTIALS((short)1, "credentials");

      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        switch(fieldId) {
          case 2: // TINFO
            return TINFO;
          case 1: // CREDENTIALS
            return CREDENTIALS;
          default:
            return null;
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
    static {
      Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
      tmpMap.put(_Fields.TINFO, new org.apache.thrift.meta_data.FieldMetaData("tinfo", org.apache.thrift.TFieldRequirementType.DEFAULT,
          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.accumulo.trace.thrift.TInfo.class)));
      tmpMap.put(_Fields.CREDENTIALS, new org.apache.thrift.meta_data.FieldMetaData("credentials", org.apache.thrift.TFieldRequirementType.DEFAULT,
          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, org.apache.accumulo.core.security.thrift.TCredentials.class)));
      metaDataMap = Collections.unmodifiableMap(tmpMap);
      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getStatus_args.class, metaDataMap);
    }

    public getStatus_args() {
    }

    public getStatus_args(
      org.apache.accumulo.trace.thrift.TInfo tinfo,
      org.apache.accumulo.core.security.thrift.TCredentials credentials)
    {
      this();
      this.tinfo = tinfo;
      this.credentials = credentials;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getStatus_args(getStatus_args other) {
      if (other.isSetTinfo()) {
        this.tinfo = new org.apache.accumulo.trace.thrift.TInfo(other.tinfo);
      }
      if (other.isSetCredentials()) {
        this.credentials = new org.apache.accumulo.core.security.thrift.TCredentials(other.credentials);
      }
    }

    public getStatus_args deepCopy() {
      return new getStatus_args(this);
    }

    @Override
    public void clear() {
      this.tinfo = null;
      this.credentials = null;
    }

    public org.apache.accumulo.trace.thrift.TInfo getTinfo() {
      return this.tinfo;
    }

    public getStatus_args setTinfo(org.apache.accumulo.trace.thrift.TInfo tinfo) {
      this.tinfo = tinfo;
      return this;
    }

    public void unsetTinfo() {
      this.tinfo = null;
    }

    /** Returns true if field tinfo is set (has been assigned a value) and false otherwise */
    public boolean isSetTinfo() {
      return this.tinfo != null;
    }

    public void setTinfoIsSet(boolean value) {
      if (!value) {
        this.tinfo = null;
      }
    }

    public org.apache.accumulo.core.security.thrift.TCredentials getCredentials() {
      return this.credentials;
    }

    public getStatus_args setCredentials(org.apache.accumulo.core.security.thrift.TCredentials credentials) {
      this.credentials = credentials;
      return this;
    }

    public void unsetCredentials() {
      this.credentials = null;
    }

    /** Returns true if field credentials is set (has been assigned a value) and false otherwise */
    public boolean isSetCredentials() {
      return this.credentials != null;
    }

    public void setCredentialsIsSet(boolean value) {
      if (!value) {
        this.credentials = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case TINFO:
        if (value == null) {
          unsetTinfo();
        } else {
          setTinfo((org.apache.accumulo.trace.thrift.TInfo)value);
        }
        break;

      case CREDENTIALS:
        if (value == null) {
          unsetCredentials();
        } else {
          setCredentials((org.apache.accumulo.core.security.thrift.TCredentials)value);
        }
        break;

      }
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case TINFO:
        return getTinfo();

      case CREDENTIALS:
        return getCredentials();

      }
      throw new IllegalStateException();
    }

    /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      if (field == null) {
        throw new IllegalArgumentException();
      }

      switch (field) {
      case TINFO:
        return isSetTinfo();
      case CREDENTIALS:
        return isSetCredentials();
      }
      throw new IllegalStateException();
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof getStatus_args)
        return this.equals((getStatus_args)that);
      return false;
    }

    public boolean equals(getStatus_args that) {
      if (that == null)
        return false;

      boolean this_present_tinfo = true && this.isSetTinfo();
      boolean that_present_tinfo = true && that.isSetTinfo();
      if (this_present_tinfo || that_present_tinfo) {
        if (!(this_present_tinfo && that_present_tinfo))
          return false;
        if (!this.tinfo.equals(that.tinfo))
          return false;
      }

      boolean this_present_credentials = true && this.isSetCredentials();
      boolean that_present_credentials = true && that.isSetCredentials();
      if (this_present_credentials || that_present_credentials) {
        if (!(this_present_credentials && that_present_credentials))
          return false;
        if (!this.credentials.equals(that.credentials))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public int compareTo(getStatus_args other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;
      getStatus_args typedOther = (getStatus_args)other;

      lastComparison = Boolean.valueOf(isSetTinfo()).compareTo(typedOther.isSetTinfo());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetTinfo()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tinfo, typedOther.tinfo);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      lastComparison = Boolean.valueOf(isSetCredentials()).compareTo(typedOther.isSetCredentials());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetCredentials()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.credentials, typedOther.credentials);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      return 0;
    }

    public _Fields fieldForId(int fieldId) {
      return _Fields.findByThriftId(fieldId);
    }

    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
      schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
      schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
    }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("getStatus_args(");
      boolean first = true;

      sb.append("tinfo:");
      if (this.tinfo == null) {
        sb.append("null");
      } else {
        sb.append(this.tinfo);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("credentials:");
      if (this.credentials == null) {
        sb.append("null");
      } else {
        sb.append(this.credentials);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws org.apache.thrift.TException {
      // check for required fields
      // check for sub-struct validity
      if (tinfo != null) {
        tinfo.validate();
      }
      if (credentials != null) {
        credentials.validate();
      }
    }

    private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
      try {
        write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
      } catch (org.apache.thrift.TException te) {
        throw new java.io.IOException(te);
      }
    }

    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
      try {
        read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
      } catch (org.apache.thrift.TException te) {
        throw new java.io.IOException(te);
      }
    }

    private static class getStatus_argsStandardSchemeFactory implements SchemeFactory {
      public getStatus_argsStandardScheme getScheme() {
        return new getStatus_argsStandardScheme();
      }
    }

    private static class getStatus_argsStandardScheme extends StandardScheme<getStatus_args> {

      public void read(org.apache.thrift.protocol.TProtocol iprot, getStatus_args struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TField schemeField;
        iprot.readStructBegin();
        while (true)
        {
          schemeField = iprot.readFieldBegin();
          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
            break;
          }
          switch (schemeField.id) {
            case 2: // TINFO
              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
                struct.tinfo = new org.apache.accumulo.trace.thrift.TInfo();
                struct.tinfo.read(iprot);
                struct.setTinfoIsSet(true);
              } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            case 1: // CREDENTIALS
              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
                struct.credentials = new org.apache.accumulo.core.security.thrift.TCredentials();
                struct.credentials.read(iprot);
                struct.setCredentialsIsSet(true);
              } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            default:
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
          }
          iprot.readFieldEnd();
        }
        iprot.readStructEnd();

        // check for required fields of primitive type, which can't be checked in the validate method
        struct.validate();
      }

      public void write(org.apache.thrift.protocol.TProtocol oprot, getStatus_args struct) throws org.apache.thrift.TException {
        struct.validate();

        oprot.writeStructBegin(STRUCT_DESC);
        if (struct.credentials != null) {
          oprot.writeFieldBegin(CREDENTIALS_FIELD_DESC);
          struct.credentials.write(oprot);
          oprot.writeFieldEnd();
        }
        if (struct.tinfo != null) {
          oprot.writeFieldBegin(TINFO_FIELD_DESC);
          struct.tinfo.write(oprot);
          oprot.writeFieldEnd();
        }
        oprot.writeFieldStop();
        oprot.writeStructEnd();
      }

    }

    private static class getStatus_argsTupleSchemeFactory implements SchemeFactory {
      public getStatus_argsTupleScheme getScheme() {
        return new getStatus_argsTupleScheme();
      }
    }

    private static class getStatus_argsTupleScheme extends TupleScheme<getStatus_args> {

      @Override
      public void write(org.apache.thrift.protocol.TProtocol prot, getStatus_args struct) throws org.apache.thrift.TException {
        TTupleProtocol oprot = (TTupleProtocol) prot;
        BitSet optionals = new BitSet();
        if (struct.isSetTinfo()) {
          optionals.set(0);
        }
        if (struct.isSetCredentials()) {
          optionals.set(1);
        }
        oprot.writeBitSet(optionals, 2);
        if (struct.isSetTinfo()) {
          struct.tinfo.write(oprot);
        }
        if (struct.isSetCredentials()) {
          struct.credentials.write(oprot);
        }
      }

      @Override
      public void read(org.apache.thrift.protocol.TProtocol prot, getStatus_args struct) throws org.apache.thrift.TException {
        TTupleProtocol iprot = (TTupleProtocol) prot;
        BitSet incoming = iprot.readBitSet(2);
        if (incoming.get(0)) {
          struct.tinfo = new org.apache.accumulo.trace.thrift.TInfo();
          struct.tinfo.read(iprot);
          struct.setTinfoIsSet(true);
        }
        if (incoming.get(1)) {
          struct.credentials = new org.apache.accumulo.core.security.thrift.TCredentials();
          struct.credentials.read(iprot);
          struct.setCredentialsIsSet(true);
        }
      }
    }

  }

  public static class getStatus_result implements org.apache.thrift.TBase<getStatus_result, getStatus_result._Fields>, java.io.Serializable, Cloneable   {
    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getStatus_result");

    private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0);
    private static final org.apache.thrift.protocol.TField SEC_FIELD_DESC = new org.apache.thrift.protocol.TField("sec", org.apache.thrift.protocol.TType.STRUCT, (short)1);

    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
    static {
      schemes.put(StandardScheme.class, new getStatus_resultStandardSchemeFactory());
      schemes.put(TupleScheme.class, new getStatus_resultTupleSchemeFactory());
    }

    public GCStatus success; // required
    public org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException sec; // required

    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
    @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
      SUCCESS((short)0, "success"),
      SEC((short)1, "sec");

      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();

      static {
        for (_Fields field : EnumSet.allOf(_Fields.class)) {
          byName.put(field.getFieldName(), field);
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, or null if its not found.
       */
      public static _Fields findByThriftId(int fieldId) {
        switch(fieldId) {
          case 0: // SUCCESS
            return SUCCESS;
          case 1: // SEC
            return SEC;
          default:
            return null;
        }
      }

      /**
       * Find the _Fields constant that matches fieldId, throwing an exception
       * if it is not found.
       */
      public static _Fields findByThriftIdOrThrow(int fieldId) {
        _Fields fields = findByThriftId(fieldId);
        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
        return fields;
      }

      /**
       * Find the _Fields constant that matches name, or null if its not found.
       */
      public static _Fields findByName(String name) {
        return byName.get(name);
      }

      private final short _thriftId;
      private final String _fieldName;

      _Fields(short thriftId, String fieldName) {
        _thriftId = thriftId;
        _fieldName = fieldName;
      }

      public short getThriftFieldId() {
        return _thriftId;
      }

      public String getFieldName() {
        return _fieldName;
      }
    }

    // isset id assignments
    public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
    static {
      Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
      tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT,
          new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, GCStatus.class)));
      tmpMap.put(_Fields.SEC, new org.apache.thrift.meta_data.FieldMetaData("sec", org.apache.thrift.TFieldRequirementType.DEFAULT,
          new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT)));
      metaDataMap = Collections.unmodifiableMap(tmpMap);
      org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getStatus_result.class, metaDataMap);
    }

    public getStatus_result() {
    }

    public getStatus_result(
      GCStatus success,
      org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException sec)
    {
      this();
      this.success = success;
      this.sec = sec;
    }

    /**
     * Performs a deep copy on <i>other</i>.
     */
    public getStatus_result(getStatus_result other) {
      if (other.isSetSuccess()) {
        this.success = new GCStatus(other.success);
      }
      if (other.isSetSec()) {
        this.sec = new org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException(other.sec);
      }
    }

    public getStatus_result deepCopy() {
      return new getStatus_result(this);
    }

    @Override
    public void clear() {
      this.success = null;
      this.sec = null;
    }

    public GCStatus getSuccess() {
      return this.success;
    }

    public getStatus_result setSuccess(GCStatus success) {
      this.success = success;
      return this;
    }

    public void unsetSuccess() {
      this.success = null;
    }

    /** Returns true if field success is set (has been assigned a value) and false otherwise */
    public boolean isSetSuccess() {
      return this.success != null;
    }

    public void setSuccessIsSet(boolean value) {
      if (!value) {
        this.success = null;
      }
    }

    public org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException getSec() {
      return this.sec;
    }

    public getStatus_result setSec(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException sec) {
      this.sec = sec;
      return this;
    }

    public void unsetSec() {
      this.sec = null;
    }

    /** Returns true if field sec is set (has been assigned a value) and false otherwise */
    public boolean isSetSec() {
      return this.sec != null;
    }

    public void setSecIsSet(boolean value) {
      if (!value) {
        this.sec = null;
      }
    }

    public void setFieldValue(_Fields field, Object value) {
      switch (field) {
      case SUCCESS:
        if (value == null) {
          unsetSuccess();
        } else {
          setSuccess((GCStatus)value);
        }
        break;

      case SEC:
        if (value == null) {
          unsetSec();
        } else {
          setSec((org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)value);
        }
        break;

      }
    }

    public Object getFieldValue(_Fields field) {
      switch (field) {
      case SUCCESS:
        return getSuccess();

      case SEC:
        return getSec();

      }
      throw new IllegalStateException();
    }

    /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
    public boolean isSet(_Fields field) {
      if (field == null) {
        throw new IllegalArgumentException();
      }

      switch (field) {
      case SUCCESS:
        return isSetSuccess();
      case SEC:
        return isSetSec();
      }
      throw new IllegalStateException();
    }

    @Override
    public boolean equals(Object that) {
      if (that == null)
        return false;
      if (that instanceof getStatus_result)
        return this.equals((getStatus_result)that);
      return false;
    }

    public boolean equals(getStatus_result that) {
      if (that == null)
        return false;

      boolean this_present_success = true && this.isSetSuccess();
      boolean that_present_success = true && that.isSetSuccess();
      if (this_present_success || that_present_success) {
        if (!(this_present_success && that_present_success))
          return false;
        if (!this.success.equals(that.success))
          return false;
      }

      boolean this_present_sec = true && this.isSetSec();
      boolean that_present_sec = true && that.isSetSec();
      if (this_present_sec || that_present_sec) {
        if (!(this_present_sec && that_present_sec))
          return false;
        if (!this.sec.equals(that.sec))
          return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      return 0;
    }

    public int compareTo(getStatus_result other) {
      if (!getClass().equals(other.getClass())) {
        return getClass().getName().compareTo(other.getClass().getName());
      }

      int lastComparison = 0;
      getStatus_result typedOther = (getStatus_result)other;

      lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetSuccess()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, typedOther.success);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      lastComparison = Boolean.valueOf(isSetSec()).compareTo(typedOther.isSetSec());
      if (lastComparison != 0) {
        return lastComparison;
      }
      if (isSetSec()) {
        lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sec, typedOther.sec);
        if (lastComparison != 0) {
          return lastComparison;
        }
      }
      return 0;
    }

    public _Fields fieldForId(int fieldId) {
      return _Fields.findByThriftId(fieldId);
    }

    public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
      schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
    }

    public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
      schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
      }

    @Override
    public String toString() {
      StringBuilder sb = new StringBuilder("getStatus_result(");
      boolean first = true;

      sb.append("success:");
      if (this.success == null) {
        sb.append("null");
      } else {
        sb.append(this.success);
      }
      first = false;
      if (!first) sb.append(", ");
      sb.append("sec:");
      if (this.sec == null) {
        sb.append("null");
      } else {
        sb.append(this.sec);
      }
      first = false;
      sb.append(")");
      return sb.toString();
    }

    public void validate() throws org.apache.thrift.TException {
      // check for required fields
      // check for sub-struct validity
      if (success != null) {
        success.validate();
      }
    }

    private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
      try {
        write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
      } catch (org.apache.thrift.TException te) {
        throw new java.io.IOException(te);
      }
    }

    private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
      try {
        read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
      } catch (org.apache.thrift.TException te) {
        throw new java.io.IOException(te);
      }
    }

    private static class getStatus_resultStandardSchemeFactory implements SchemeFactory {
      public getStatus_resultStandardScheme getScheme() {
        return new getStatus_resultStandardScheme();
      }
    }

    private static class getStatus_resultStandardScheme extends StandardScheme<getStatus_result> {

      public void read(org.apache.thrift.protocol.TProtocol iprot, getStatus_result struct) throws org.apache.thrift.TException {
        org.apache.thrift.protocol.TField schemeField;
        iprot.readStructBegin();
        while (true)
        {
          schemeField = iprot.readFieldBegin();
          if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
            break;
          }
          switch (schemeField.id) {
            case 0: // SUCCESS
              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
                struct.success = new GCStatus();
                struct.success.read(iprot);
                struct.setSuccessIsSet(true);
              } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            case 1: // SEC
              if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
                struct.sec = new org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException();
                struct.sec.read(iprot);
                struct.setSecIsSet(true);
              } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
              }
              break;
            default:
              org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
          }
          iprot.readFieldEnd();
        }
        iprot.readStructEnd();

        // check for required fields of primitive type, which can't be checked in the validate method
        struct.validate();
      }

      public void write(org.apache.thrift.protocol.TProtocol oprot, getStatus_result struct) throws org.apache.thrift.TException {
        struct.validate();

        oprot.writeStructBegin(STRUCT_DESC);
        if (struct.success != null) {
          oprot.writeFieldBegin(SUCCESS_FIELD_DESC);
          struct.success.write(oprot);
          oprot.writeFieldEnd();
        }
        if (struct.sec != null) {
          oprot.writeFieldBegin(SEC_FIELD_DESC);
          struct.sec.write(oprot);
          oprot.writeFieldEnd();
        }
        oprot.writeFieldStop();
        oprot.writeStructEnd();
      }

    }

    private static class getStatus_resultTupleSchemeFactory implements SchemeFactory {
      public getStatus_resultTupleScheme getScheme() {
        return new getStatus_resultTupleScheme();
      }
    }

    private static class getStatus_resultTupleScheme extends TupleScheme<getStatus_result> {

      @Override
      public void write(org.apache.thrift.protocol.TProtocol prot, getStatus_result struct) throws org.apache.thrift.TException {
        TTupleProtocol oprot = (TTupleProtocol) prot;
        BitSet optionals = new BitSet();
        if (struct.isSetSuccess()) {
          optionals.set(0);
        }
        if (struct.isSetSec()) {
          optionals.set(1);
        }
        oprot.writeBitSet(optionals, 2);
        if (struct.isSetSuccess()) {
          struct.success.write(oprot);
        }
        if (struct.isSetSec()) {
          struct.sec.write(oprot);
        }
      }

      @Override
      public void read(org.apache.thrift.protocol.TProtocol prot, getStatus_result struct) throws org.apache.thrift.TException {
        TTupleProtocol iprot = (TTupleProtocol) prot;
        BitSet incoming = iprot.readBitSet(2);
        if (incoming.get(0)) {
          struct.success = new GCStatus();
          struct.success.read(iprot);
          struct.setSuccessIsSet(true);
        }
        if (incoming.get(1)) {
          struct.sec = new org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException();
          struct.sec.read(iprot);
          struct.setSecIsSet(true);
        }
      }
    }

  }

}


text:
namespace content {

ShellRenderViewObserver::ShellRenderViewObserver(RenderView* render_view)
    : RenderViewObserver(render_view) {
}

ShellRenderViewObserver::~ShellRenderViewObserver() {
}

void ShellRenderViewObserver::DidClearWindowObject(
    blink::WebLocalFrame* frame) {
  if (CommandLine::ForCurrentProcess()->HasSwitch(
          switches::kExposeInternalsForTesting)) {
    blink::WebTestingSupport::injectInternalsObject(frame);
  }

  if (CommandLine::ForCurrentProcess()->HasSwitch(
          switches::kExposeIpcEcho)) {
    RenderView* view = render_view();
    if (!ipc_echo_)
      ipc_echo_.reset(new IPCEcho(view->GetWebView()->mainFrame()->document(),
                                  RenderThread::Get(), view->GetRoutingID()));
    ipc_echo_->Install(view->GetWebView()->mainFrame());
  }
}

bool ShellRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
  bool handled = true;
  IPC_BEGIN_MESSAGE_MAP(ShellRenderViewObserver, message)
    IPC_MESSAGE_HANDLER(ShellViewMsg_EchoPong, OnEchoPong)
    IPC_MESSAGE_UNHANDLED(handled = false)
  IPC_END_MESSAGE_MAP()

  return handled;
}

void ShellRenderViewObserver::OnEchoPong(int id, const std::string& body) {
  ipc_echo_->DidRespondEcho(id, body.size());
}

}  // namespace content


text:
package http

import (
	"github.com/micro/go-micro/client"
)

type httpPublication struct {
	topic       string
	contentType string
	message     interface{}
}

func newHTTPPublication(topic string, message interface{}, contentType string) client.Publication {
	return &httpPublication{
		message:     message,
		topic:       topic,
		contentType: contentType,
	}
}

func (h *httpPublication) ContentType() string {
	return h.contentType
}

func (h *httpPublication) Topic() string {
	return h.topic
}

func (h *httpPublication) Message() interface{} {
	return h.message
}


text:
#ifdef USE_TI_UIOPTIONDIALOG

#import "TiUIOptionDialogProxy.h"
#import "TiUtils.h"
#import "TiApp.h"
#import "TiToolbar.h"
#import "TiToolbarButton.h"
#import	"TiTab.h"

@implementation TiUIOptionDialogProxy
@synthesize dialogView;

- (void) dealloc
{
	RELEASE_TO_NIL(actionSheet);
	RELEASE_TO_NIL(dialogView);
	RELEASE_TO_NIL_AUTORELEASE(alertController);
	[super dealloc];
}

-(NSMutableDictionary*)langConversionTable
{
    return [NSMutableDictionary dictionaryWithObject:@"title" forKey:@"titleid"];
}

-(NSString*)apiName
{
    return @"Ti.UI.OptionDialog";
}

-(void)show:(id)args
{
	ENSURE_SINGLE_ARG_OR_NIL(args,NSDictionary);
    // prevent more than one JS thread from showing an alert box at a time
    if ([NSThread isMainThread]==NO) {
        [self rememberSelf];
        TiThreadPerformOnMainThread(^{[self show:args];}, YES);
        return;
    }

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(suspended:) name:kTiSuspendNotification object:nil];

	showDialog = YES;
	NSMutableArray *options = [self valueForKey:@"options"];
	if (IS_NULL_OR_NIL(options))
	{
		options = [[[NSMutableArray alloc] initWithCapacity:2] autorelease];
		[options addObject:NSLocalizedString(@"OK",@"Alert OK Button")];
	}

    forceOpaqueBackground = [TiUtils boolValue:[self valueForKey:@"opaquebackground"] def:NO];
    persistentFlag = [TiUtils boolValue:[self valueForKey:@"persistent"] def:YES];
    cancelButtonIndex = [TiUtils intValue:[self valueForKey:@"cancel"] def:-1];
    destructiveButtonIndex = [TiUtils intValue:[self valueForKey:@"destructive"] def:-1];
    if (cancelButtonIndex >= [options count]) {
        cancelButtonIndex = -1;
    }
    if (destructiveButtonIndex >= [options count]) {
        destructiveButtonIndex = -1;
    }

    [self setDialogView:[args objectForKey:@"view"]];
    animated = [TiUtils boolValue:@"animated" properties:args def:YES];
    id obj = [args objectForKey:@"rect"];
    if (obj!=nil)
    {
        dialogRect = [TiUtils rectValue:obj];
    }
    else
    {
        dialogRect = CGRectZero;
    }

    if ([TiUtils isIOS8OrGreater]) {
        RELEASE_TO_NIL(alertController);
        [[[TiApp app] controller] incrementActiveAlertControllerCount];
        alertController = [[UIAlertController alertControllerWithTitle:[TiUtils stringValue:[self valueForKey:@"title"]]
                                                               message:[TiUtils stringValue:[self valueForKey:@"message"]]
                                                        preferredStyle:UIAlertControllerStyleActionSheet] retain];

        int curIndex = 0;
        //Configure the Buttons
        for (id btn in options) {
            NSString* btnName = [TiUtils stringValue:btn];
            if (!IS_NULL_OR_NIL(btnName)) {
                UIAlertAction* theAction = [UIAlertAction actionWithTitle:btnName
                                                                    style:((curIndex == cancelButtonIndex) ? UIAlertActionStyleCancel : ((curIndex == destructiveButtonIndex) ? UIAlertActionStyleDestructive : UIAlertActionStyleDefault))
                                                                  handler:^(UIAlertAction * action){
                                                                      [self fireClickEventWithAction:action];
                                                                  }];
                [alertController addAction:theAction];
            }
            curIndex++;
        }

        BOOL isPopover = NO;

        if ([TiUtils isIPad]) {
            UIViewController* topVC = [[[TiApp app] controller] topPresentedController];
            isPopover = ( (topVC.modalPresentationStyle == UIModalPresentationPopover) && (![topVC isKindOfClass:[UIAlertController class]]) );
            /**
             ** This block commented out since it seems to have no effect on the alert controller.
             ** If you read the modalPresentationStyle after setting the value, it still shows UIModalPresentationPopover
             ** However not configuring the UIPopoverPresentationController seems to do the trick.
             ** This hack in place to conserve current behavior. Should revisit when iOS7 is dropped so that
             ** option dialogs are always presented in UIModalPresentationPopover
            if (isPopover) {
                alertController.modalPresentationStyle = UIModalPresentationCurrentContext;
                alertController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
            }
            */
        }
        /*See Comment above. Remove if condition to see difference in behavior on iOS8*/
        if (!isPopover) {
            UIPopoverPresentationController* presentationController =  alertController.popoverPresentationController;
            presentationController.permittedArrowDirections = UIPopoverArrowDirectionAny;
            presentationController.delegate = self;
        }

        [self retain];
        [[TiApp app] showModalController:alertController animated:animated];

    } else {
        if (actionSheet != nil) {
            [actionSheet setDelegate:nil];
            [actionSheet release];
        }
        actionSheet = [[UIActionSheet alloc] init];
        [actionSheet setDelegate:self];

        [actionSheet setTitle:[TiUtils stringValue:[self valueForKey:@"title"]]];

        for (id thisOption in options)
        {
            NSString * thisButtonName = [TiUtils stringValue:thisOption];
            [actionSheet addButtonWithTitle:thisButtonName];
        }

        [actionSheet setCancelButtonIndex:cancelButtonIndex];
        [actionSheet setDestructiveButtonIndex:destructiveButtonIndex];

        [self retain];

        if ([TiUtils isIPad])
        {
            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceRotationBegan:) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
            [self updateOptionDialogNow];
            return;
        }
        [actionSheet showInView:[[TiApp app] topMostView]];
    }
}

-(void)hide:(id)args
{
    if (!showDialog) {
        return;
    }
	if (actionSheet == nil && alertController == nil){
		return;
	}

	id options = nil;
	if ([args count]>0) {
		options = [args objectAtIndex:0];
	}
	BOOL animatedhide = [TiUtils boolValue:@"animated" properties:options def:YES];

    TiThreadPerformOnMainThread(^{
        if (actionSheet != nil) {
            if ([actionSheet isVisible]) {
                [actionSheet dismissWithClickedButtonIndex:[actionSheet cancelButtonIndex] animated:animatedhide];
            }
            else if(showDialog) {
                [self completeWithButton:[actionSheet cancelButtonIndex]];
            }
        } else if (alertController != nil) {
            [alertController dismissViewControllerAnimated:animated completion:^{
                [self cleanup];
            }];
        }
    }, NO);
}

-(void)suspended:(NSNotification*)note
{
    if (!persistentFlag) {
        [self hide:[NSArray arrayWithObject: [NSDictionary dictionaryWithObject:NUMBOOL(NO) forKey:@"animated"]]];
    }
}

#pragma mark UIPopoverPresentationControllerDelegate
- (void)prepareForPopoverPresentation:(UIPopoverPresentationController *)popoverPresentationController
{
    if (dialogView != nil) {
        if ([dialogView supportsNavBarPositioning] && [dialogView isUsingBarButtonItem]) {
            UIBarButtonItem* theItem = [dialogView barButtonItem];
            if (theItem != nil) {
                popoverPresentationController.barButtonItem = [dialogView barButtonItem];
                return;
            }
        }

        if ([dialogView conformsToProtocol:@protocol(TiToolbar)])
        {
            UIToolbar *toolbar = [(id<TiToolbar>)dialogView toolbar];
            if (toolbar != nil) {
                popoverPresentationController.sourceView = toolbar;
                popoverPresentationController.sourceRect = [toolbar bounds];
                return;
            }
        }

        if ([dialogView conformsToProtocol:@protocol(TiTab)])
        {
            id<TiTab> tab = (id<TiTab>)dialogView;
            UITabBar *tabbar = [[tab tabGroup] tabbar];
            if (tabbar != nil) {
                popoverPresentationController.sourceView = tabbar;
                popoverPresentationController.sourceRect = [tabbar bounds];
                return;
            }
        }

        UIView* view = [dialogView view];
        if (view != nil) {
            popoverPresentationController.sourceView = view;
            popoverPresentationController.sourceRect = (CGRectEqualToRect(CGRectZero, dialogRect)?CGRectMake(view.bounds.size.width/2, view.bounds.size.height/2, 1, 1):dialogRect);
            return;
        }
    }

    //Fell through.
    UIViewController* presentingController = [alertController presentingViewController];
    popoverPresentationController.sourceView = [presentingController view];
    popoverPresentationController.sourceRect = (CGRectEqualToRect(CGRectZero, dialogRect)?CGRectMake(presentingController.view.bounds.size.width/2, presentingController.view.bounds.size.height/2, 1, 1):dialogRect);;
}

- (void)popoverPresentationController:(UIPopoverPresentationController *)popoverPresentationController willRepositionPopoverToRect:(inout CGRect *)rect inView:(inout UIView **)view
{
    //This will never be called when using bar button item
    BOOL canUseDialogRect = !CGRectEqualToRect(CGRectZero, dialogRect);
    UIView* theSourceView = *view;
    BOOL shouldUseViewBounds = ([theSourceView isKindOfClass:[UIToolbar class]] || [theSourceView isKindOfClass:[UITabBar class]]);

    if (shouldUseViewBounds) {
        rect->origin = CGPointMake(theSourceView.bounds.origin.x, theSourceView.bounds.origin.y);
        rect->size = CGSizeMake(theSourceView.bounds.size.width, theSourceView.bounds.size.height);
    } else if (!canUseDialogRect) {
        rect->origin = CGPointMake(theSourceView.bounds.size.width/2, theSourceView.bounds.size.height/2);
        rect->size = CGSizeMake(1, 1);
    }

    popoverPresentationController.sourceRect = *rect;
}

- (void)popoverPresentationControllerDidDismissPopover:(UIPopoverPresentationController *)popoverPresentationController
{
    [self cleanup];
}

#pragma mark AlertView Delegate

- (void)willPresentActionSheet:(UIActionSheet *)actionSheet_
{
    //TIMOB-15939. Workaround rendering issue on iPAD on iOS7
    if (actionSheet_ == actionSheet && forceOpaqueBackground &&[TiUtils isIOS7OrGreater] && [TiUtils isIPad]) {
        NSArray* subviews = [actionSheet subviews];

        for (UIView* subview in subviews) {
            [subview setBackgroundColor:[UIColor whiteColor]];
        }
        [actionSheet setBackgroundColor:[UIColor whiteColor]];
    }
}

- (void)actionSheet:(UIActionSheet *)actionSheet_ didDismissWithButtonIndex:(NSInteger)buttonIndex;
{
	if (buttonIndex == -2)
	{
		return;
		//A -2 is used by us to indicate that this was programatically dismissed to properly
		//place the option dialog during a roation.
	}
	[self completeWithButton:buttonIndex];
}

#pragma mark Internal Use Only
-(void) fireClickEventWithAction:(UIAlertAction*)theAction
{
    if ([self _hasListeners:@"click"]) {
        NSUInteger indexOfAction = [[alertController actions] indexOfObject:theAction];

        NSMutableDictionary *event = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                      NUMUINTEGER(indexOfAction),@"index",
                                      NUMINT(cancelButtonIndex),@"cancel",
                                      NUMINT(destructiveButtonIndex),@"destructive",
                                      nil];

        [self fireEvent:@"click" withObject:event];
    }
    [self cleanup];
}

-(void)cleanup
{
    if (showDialog) {
        showDialog = NO;
        [[[TiApp app] controller] decrementActiveAlertControllerCount];
        RELEASE_TO_NIL_AUTORELEASE(alertController);
        [[NSNotificationCenter defaultCenter] removeObserver:self];
        [self forgetSelf];
        [self release];
    }
}

-(void)completeWithButton:(NSInteger)buttonIndex
{
    if (showDialog) {
        showDialog = NO;
        if ([self _hasListeners:@"click"])
        {
            NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:
                                   NUMINTEGER(buttonIndex),@"index",
                                   NUMINTEGER([actionSheet cancelButtonIndex]),@"cancel",
                                   NUMINTEGER([actionSheet destructiveButtonIndex]),@"destructive",
                                   nil];
            [self fireEvent:@"click" withObject:event];
        }
        [[NSNotificationCenter defaultCenter] removeObserver:self];
        [self forgetSelf];
        [self release];
    }
}

-(void)deviceRotationBegan:(NSNotification *)notification
{
    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(updateOptionDialogNow) object:nil];
    NSTimeInterval delay = [[UIApplication sharedApplication] statusBarOrientationAnimationDuration];
    UIInterfaceOrientation nextOrientation = [[notification.userInfo objectForKey:UIApplicationStatusBarOrientationUserInfoKey] intValue];
    UIInterfaceOrientation currentOrientation = [UIApplication sharedApplication].statusBarOrientation;
    if (UIInterfaceOrientationIsPortrait(currentOrientation) == UIInterfaceOrientationIsPortrait(nextOrientation)) {
        ++accumulatedOrientationChanges; // double for a 180 degree orientation change
    }
    if (++accumulatedOrientationChanges > 1) {
        delay *= MIN(accumulatedOrientationChanges, 4);
    }
	[actionSheet dismissWithClickedButtonIndex:-2 animated:animated];
	[self performSelector:@selector(updateOptionDialogNow) withObject:nil afterDelay:delay];
}

-(void)updateOptionDialogNow;
{
	if (!showDialog) {
		return;
	}
    accumulatedOrientationChanges = 0;
	UIView *view = nil;
	if (dialogView==nil)
	{
		view = [[[[TiApp app] window] subviews] lastObject];
	}
	else
	{
		//TODO: need to deal with button in a Toolbar which will have a nil view

		if ([dialogView supportsNavBarPositioning] && [dialogView isUsingBarButtonItem])
		{
			UIBarButtonItem *button = [dialogView barButtonItem];
			[actionSheet showFromBarButtonItem:button animated:animated];
			return;
		}

		if ([dialogView conformsToProtocol:@protocol(TiToolbar)])
		{
			UIToolbar *toolbar = [(id<TiToolbar>)dialogView toolbar];
			[actionSheet showFromToolbar:toolbar];
			return;
		}

		if ([dialogView conformsToProtocol:@protocol(TiTab)])
		{
			id<TiTab> tab = (id<TiTab>)dialogView;
			UITabBar *tabbar = [[tab tabGroup] tabbar];
			[actionSheet showFromTabBar:tabbar];
			return;
		}

		view = [dialogView view];
		CGRect rect;
		if (CGRectIsEmpty(dialogRect))
		{
			if(view == nil)
			{
				rect = CGRectZero;
			}
			else
			{
				rect = [view bounds];
			}

		}
		else
		{
			rect = dialogRect;
		}

		[actionSheet showFromRect:rect inView:view animated:animated];
		return;
	}
	[actionSheet showInView:view];
}

@end

#endif


text:
using System;

namespace OrigoDB.Core.Modeling.Messaging
{
    [Serializable, Immutable]
    public class TextMessage : Message
    {
        public readonly string Body;

        public TextMessage(String body, String subject = "") : base(subject)
        {
            Body = body;
        }
    }
}