text:
package net.rajorshi.sunshine.app;

import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.text.format.Time;
import android.util.Log;

import net.rajorshi.sunshine.app.data.WeatherContract;
import net.rajorshi.sunshine.app.data.WeatherContract.WeatherEntry;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Vector;

public class FetchWeatherTask extends AsyncTask<String, Void, Void> {

    private final String LOG_TAG = FetchWeatherTask.class.getSimpleName();
    private final Context mContext;
    private ForecastAdapter mForecastAdapter;
    private boolean DEBUG = true;

    /*
        Hack: the openweathermap API is shittier than expected and fails to work most of the time
        Return this weather data in case it fails
     */
    private final static String WEATHER_DATA_MTV_JUN_4 = "{\"cod\":\"200\",\"message\":4.2116," +
            "\"city\":{\"id\":\"5375480\",\"name\":\"Mountain View\",\"coord\":{\"lon\":-122.075," +
            "\"lat\":37.4103},\"country\":\"United States of America\",\"population\":0},\"cnt\":7," +
            "\"list\":[{\"dt\":1401912000,\"temp\":{\"day\":20.17,\"min\":12.3,\"max\":20.17," +
            "\"night\":12.3,\"eve\":17.74,\"morn\":14.05},\"pressure\":1012.43,\"humidity\":77," +
            "\"weather\":[{\"id\":800,\"main\":\"Clear\",\"description\":\"sky is clear\"," +
            "\"icon\":\"01d\"}],\"speed\":1.67,\"deg\":253,\"clouds\":0},{\"dt\":1401998400," +
            "\"temp\":{\"day\":18.9,\"min\":10.74,\"max\":18.9,\"night\":10.74,\"eve\":15.54," +
            "\"morn\":14.02},\"pressure\":1009.89,\"humidity\":76,\"weather\":[{\"id\":800" +
            ",\"main\":\"Clear\",\"description\":\"sky is clear\",\"icon\":\"01d\"}],\"speed\":1.51" +
            ",\"deg\":225,\"clouds\":0},{\"dt\":1402084800,\"temp\":{\"day\":13.59,\"min\":13.57" +
            ",\"max\":14.1,\"night\":14.1,\"eve\":14.04,\"morn\":13.57},\"pressure\":1022.58" +
            ",\"humidity\":0,\"weather\":[{\"id\":800,\"main\":\"Clear\",\"description\":\"sky is " +
            "clear\",\"icon\":\"01d\"}],\"speed\":8.92,\"deg\":325,\"clouds\":0},{\"dt\":1402171200" +
            ",\"temp\":{\"day\":13.71,\"min\":13.71,\"max\":13.93,\"night\":13.93,\"eve\":13.73" +
            ",\"morn\":13.93},\"pressure\":1021.29,\"humidity\":0,\"weather\":[{\"id\":800,\"main\"" +
            ":\"Clear\",\"description\":\"sky is clear\",\"icon\":\"01d\"}],\"speed\":6.41," +
            "\"deg\":326,\"clouds\":0},{\"dt\":1402257600,\"temp\":{\"day\":13.55,\"min\":13.52," +
            "\"max\":13.72,\"night\":13.52,\"eve\":13.72,\"morn\":13.62},\"pressure\":1022.14," +
            "\"humidity\":0,\"weather\":[{\"id\":800,\"main\":\"Clear\",\"description\":" +
            "\"sky is clear\",\"icon\":\"01d\"}],\"speed\":9.72,\"deg\":320,\"clouds\":0},{\"dt\":" +
            "1402344000,\"temp\":{\"day\":12.72,\"min\":12.72,\"max\":13.22,\"night\":13.22,\"eve\"" +
            ":13.19,\"morn\":13.06},\"pressure\":1027.87,\"humidity\":0,\"weather\":[{\"id\":800," +
            "\"main\":\"Clear\",\"description\":\"sky is clear\",\"icon\":\"01d\"}],\"speed\":7.85" +
            ",\"deg\":322,\"clouds\":7},{\"dt\":1402430400,\"temp\":{\"day\":13.11,\"min\":12.89," +
            "\"max\":13.35,\"night\":13.26,\"eve\":13.35,\"morn\":12.89},\"pressure\":1029.35" +
            ",\"humidity\":0,\"weather\":[{\"id\":800,\"main\":\"Clear\",\"description\"" +
            ":\"sky is clear\",\"icon\":\"01d\"}],\"speed\":11.01,\"deg\":330,\"clouds\":0}]}";

    /* API key obtained from openweathermap.org/api for rajorshi_iiitc<at>yahoo.com */
    private static final String MY_APP_ID = "748cde420fe3fe44064530f3905eecca";

    public FetchWeatherTask(Context context) {
        mContext = context;
    }

    /**
     * Helper method to handle insertion of a new location in the weather database.
     *
     * @param locationSetting The location string used to request updates from the server.
     * @param cityName        A human-readable city name, e.g "Mountain View"
     * @param lat             the latitude of the city
     * @param lon             the longitude of the city
     * @return the row ID of the added location.
     */
    long addLocation(String locationSetting, String cityName, double lat, double lon) {
        // Students: First, check if the location with this city name exists in the db
        // If it exists, return the current ID
        long locationId;
        // Otherwise, insert it using the content resolver and the base URI
        Cursor locationCursor = mContext.getContentResolver().query(
                WeatherContract.LocationEntry.CONTENT_URI,
                new String[]{WeatherContract.LocationEntry._ID},
                WeatherContract.LocationEntry.COLUMN_LOCATION_SETTING + " = ?",
                new String[]{locationSetting},
                null
        );

        if (locationCursor.moveToFirst()) {
            int locationIdIndex = locationCursor.getColumnIndex(WeatherContract.LocationEntry._ID);
            locationId = locationCursor.getLong(locationIdIndex);
        } else {
            // Now that the content provider is set up, inserting rows of data is pretty simple.
            // First create a ContentValues object to hold the data you want to insert.
            ContentValues locationValues = new ContentValues();

            // Then add the data, along with the corresponding name of the data type,
            // so the content provider knows what kind of value is being inserted.
            locationValues.put(WeatherContract.LocationEntry.COLUMN_CITY_NAME, cityName);
            locationValues.put(WeatherContract.LocationEntry.COLUMN_LOCATION_SETTING, locationSetting);
            locationValues.put(WeatherContract.LocationEntry.COLUMN_COORD_LAT, lat);
            locationValues.put(WeatherContract.LocationEntry.COLUMN_COORD_LONG, lon);

            // Finally, insert location data into the database.
            Uri insertedUri = mContext.getContentResolver().insert(
                    WeatherContract.LocationEntry.CONTENT_URI,
                    locationValues
            );

            // The resulting URI contains the ID for the row.  Extract the locationId from the Uri.
            locationId = ContentUris.parseId(insertedUri);
        }

        locationCursor.close();
        // Wait, that worked?  Yes!
        return locationId;
    }

    /**
     * Take the String representing the complete forecast in JSON Format and
     * pull out the data we need to construct the Strings needed for the wireframes.
     * <p/>
     * Fortunately parsing is easy:  constructor takes the JSON string and converts it
     * into an Object hierarchy for us.
     */
    private void getWeatherDataFromJson(String forecastJsonStr,
                                        String locationSetting)
            throws JSONException {

        // Now we have a String representing the complete forecast in JSON Format.
        // Fortunately parsing is easy:  constructor takes the JSON string and converts it
        // into an Object hierarchy for us.

        // These are the names of the JSON objects that need to be extracted.

        // Location information
        final String OWM_CITY = "city";
        final String OWM_CITY_NAME = "name";
        final String OWM_COORD = "coord";

        // Location coordinate
        final String OWM_LATITUDE = "lat";
        final String OWM_LONGITUDE = "lon";

        // Weather information.  Each day's forecast info is an element of the "list" array.
        final String OWM_LIST = "list";

        final String OWM_PRESSURE = "pressure";
        final String OWM_HUMIDITY = "humidity";
        final String OWM_WINDSPEED = "speed";
        final String OWM_WIND_DIRECTION = "deg";

        // All temperatures are children of the "temp" object.
        final String OWM_TEMPERATURE = "temp";
        final String OWM_MAX = "max";
        final String OWM_MIN = "min";

        final String OWM_WEATHER = "weather";
        final String OWM_DESCRIPTION = "main";
        final String OWM_WEATHER_ID = "id";

        try {
            JSONObject forecastJson = new JSONObject(forecastJsonStr);
            JSONArray weatherArray = forecastJson.getJSONArray(OWM_LIST);

            JSONObject cityJson = forecastJson.getJSONObject(OWM_CITY);
            String cityName = cityJson.getString(OWM_CITY_NAME);

            JSONObject cityCoord = cityJson.getJSONObject(OWM_COORD);
            double cityLatitude = cityCoord.getDouble(OWM_LATITUDE);
            double cityLongitude = cityCoord.getDouble(OWM_LONGITUDE);

            long locationId = addLocation(locationSetting, cityName, cityLatitude, cityLongitude);

            // Insert the new weather information into the database
            Vector<ContentValues> cVVector = new Vector<ContentValues>(weatherArray.length());

            // OWM returns daily forecasts based upon the local time of the city that is being
            // asked for, which means that we need to know the GMT offset to translate this data
            // properly.

            // Since this data is also sent in-order and the first day is always the
            // current day, we're going to take advantage of that to get a nice
            // normalized UTC date for all of our weather.

            Time dayTime = new Time();
            dayTime.setToNow();

            // we start at the day returned by local time. Otherwise this is a mess.
            int julianStartDay = Time.getJulianDay(System.currentTimeMillis(), dayTime.gmtoff);

            // now we work exclusively in UTC
            dayTime = new Time();

            for (int i = 0; i < weatherArray.length(); i++) {
                // These are the values that will be collected.
                long dateTime;
                double pressure;
                int humidity;
                double windSpeed;
                double windDirection;

                double high;
                double low;

                String description;
                int weatherId;

                // Get the JSON object representing the day
                JSONObject dayForecast = weatherArray.getJSONObject(i);

                // Cheating to convert this to UTC time, which is what we want anyhow
                dateTime = dayTime.setJulianDay(julianStartDay + i);

                pressure = dayForecast.getDouble(OWM_PRESSURE);
                humidity = dayForecast.getInt(OWM_HUMIDITY);
                windSpeed = dayForecast.getDouble(OWM_WINDSPEED);
                windDirection = dayForecast.getDouble(OWM_WIND_DIRECTION);

                // Description is in a child array called "weather", which is 1 element long.
                // That element also contains a weather code.
                JSONObject weatherObject =
                        dayForecast.getJSONArray(OWM_WEATHER).getJSONObject(0);
                description = weatherObject.getString(OWM_DESCRIPTION);
                weatherId = weatherObject.getInt(OWM_WEATHER_ID);

                // Temperatures are in a child object called "temp".  Try not to name variables
                // "temp" when working with temperature.  It confuses everybody.
                JSONObject temperatureObject = dayForecast.getJSONObject(OWM_TEMPERATURE);
                high = temperatureObject.getDouble(OWM_MAX);
                low = temperatureObject.getDouble(OWM_MIN);

                ContentValues weatherValues = new ContentValues();

                weatherValues.put(WeatherEntry.COLUMN_LOC_KEY, locationId);
                weatherValues.put(WeatherEntry.COLUMN_DATE, dateTime);
                weatherValues.put(WeatherEntry.COLUMN_HUMIDITY, humidity);
                weatherValues.put(WeatherEntry.COLUMN_PRESSURE, pressure);
                weatherValues.put(WeatherEntry.COLUMN_WIND_SPEED, windSpeed);
                weatherValues.put(WeatherEntry.COLUMN_DEGREES, windDirection);
                weatherValues.put(WeatherEntry.COLUMN_MAX_TEMP, high);
                weatherValues.put(WeatherEntry.COLUMN_MIN_TEMP, low);
                weatherValues.put(WeatherEntry.COLUMN_SHORT_DESC, description);
                weatherValues.put(WeatherEntry.COLUMN_WEATHER_ID, weatherId);

                cVVector.add(weatherValues);
            }

            int inserted = 0;
            // add to database
            if (cVVector.size() > 0) {
                // Student: call bulkInsert to add the weatherEntries to the database here
                ContentValues[] cvArray = new ContentValues[cVVector.size()];
                cVVector.toArray(cvArray);
                inserted = mContext.getContentResolver().bulkInsert(WeatherEntry.CONTENT_URI, cvArray);
            }

            Log.d(LOG_TAG, "FetchWeatherTask Complete. " + inserted + " Inserted");

        } catch (JSONException e) {
            Log.e(LOG_TAG, e.getMessage(), e);
            e.printStackTrace();
        }
    }

    @Override
    protected Void doInBackground(String... params) {

        // If there's no zip code, there's nothing to look up.  Verify size of params.
        if (params.length == 0) {
            return null;
        }
        String locationQuery = params[0];

        // These two need to be declared outside the try/catch
        // so that they can be closed in the finally block.
        HttpURLConnection urlConnection = null;
        BufferedReader reader = null;

        // Will contain the raw JSON response as a string.
        String forecastJsonStr = null;

        String format = "json";
        String units = "metric";
        int numDays = 14;

        try {
            // Construct the URL for the OpenWeatherMap query
            // Possible parameters are avaiable at OWM's forecast API page, at
            // http://openweathermap.org/API#forecast
            final String FORECAST_BASE_URL =
                    "http://api.openweathermap.org/data/2.5/forecast/daily?";
            final String QUERY_PARAM = "q";
            final String FORMAT_PARAM = "mode";
            final String UNITS_PARAM = "units";
            final String DAYS_PARAM = "cnt";
            final String APPID_PARAM = "APPID";

            Uri builtUri = Uri.parse(FORECAST_BASE_URL).buildUpon()
                    .appendQueryParameter(QUERY_PARAM, params[0])
                    .appendQueryParameter(FORMAT_PARAM, format)
                    .appendQueryParameter(UNITS_PARAM, units)
                    .appendQueryParameter(DAYS_PARAM, Integer.toString(numDays))
                    .appendQueryParameter(APPID_PARAM, MY_APP_ID)
                    .build();

            URL url = new URL(builtUri.toString());

            // Create the request to OpenWeatherMap, and open the connection
            urlConnection = (HttpURLConnection) url.openConnection();
            urlConnection.setRequestMethod("GET");
            urlConnection.connect();

            // Read the input stream into a String
            InputStream inputStream = urlConnection.getInputStream();
            StringBuffer buffer = new StringBuffer();
            if (inputStream == null) {
                // Nothing to do.
                return null;
            }
            reader = new BufferedReader(new InputStreamReader(inputStream));

            String line;
            while ((line = reader.readLine()) != null) {
                // Since it's JSON, adding a newline isn't necessary (it won't affect parsing)
                // But it does make debugging a *lot* easier if you print out the completed
                // buffer for debugging.
                buffer.append(line + "\n");
            }

            if (buffer.length() == 0) {
                // Stream was empty.  No point in parsing.
                return null;
            }
            forecastJsonStr = buffer.toString();
            getWeatherDataFromJson(forecastJsonStr, locationQuery);
        } catch (IOException e) {
            Log.e(LOG_TAG, "Error ", e);
            // If the code didn't successfully get the weather data, there's no point in attemping
            // to parse it.
            forecastJsonStr = WEATHER_DATA_MTV_JUN_4;
            try {
                getWeatherDataFromJson(forecastJsonStr, locationQuery);
            } catch (JSONException ee) {
                Log.e(LOG_TAG, ee.getMessage(), ee);
                e.printStackTrace();            }
        } catch (JSONException e) {
            Log.e(LOG_TAG, e.getMessage(), e);
            e.printStackTrace();
        } finally {
            if (urlConnection != null) {
                urlConnection.disconnect();
            }
            if (reader != null) {
                try {
                    reader.close();
                } catch (final IOException e) {
                    Log.e(LOG_TAG, "Error closing stream", e);
                }
            }
        }

        // This will only happen if there was an error getting or parsing the forecast.
        return null;
    }

}

redpajama_set_name: RedPajamaGithub


text:
package nokogiri.internals.c14n;

import java.util.Iterator;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;

import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

/**
 * Implements " Exclusive XML
 * Canonicalization, Version 1.0 "

 * Credits: During restructuring of the Canonicalizer framework, Ren??
 * Kollmorgen from Software AG submitted an implementation of ExclC14n which
 * fitted into the old architecture and which based heavily on my old (and slow)
 * implementation of "Canonical XML". A big "thank you" to Ren?? for this.
 *

 * THIS  implementation is a complete rewrite of the algorithm.
 *
 * @author Christian Geuer-Pollmann <geuerp@apache.org>
 * @version $Revision: 1147448 $
 * @see
 *          XML Canonicalization, Version 1.0
 */
public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {

    private static final String XML_LANG_URI = Constants.XML_LANG_SPACE_SpecNS;
    private static final String XMLNS_URI = Constants.NamespaceSpecNS;

    /**
      * This Set contains the names (Strings like "xmlns" or "xmlns:foo") of
      * the inclusive namespaces.
      */
    private SortedSet<String> inclusiveNSSet;

    private final SortedSet<Attr> result = new TreeSet<Attr>(COMPARE);

    /**
     * Constructor Canonicalizer20010315Excl
     *
     * @param includeComments
     */
    public Canonicalizer20010315Excl(boolean includeComments) {
        super(includeComments);
    }

    /**
     * Method engineCanonicalizeSubTree
     * @inheritDoc
     * @param rootNode
     *
     * @throws CanonicalizationException
     */
    @Override
    public byte[] engineCanonicalizeSubTree(Node rootNode, CanonicalFilter filter)
        throws CanonicalizationException {
        return engineCanonicalizeSubTree(rootNode, "", null);
    }

    /**
     * Method engineCanonicalizeSubTree
     *  @inheritDoc
     * @param rootNode
     * @param inclusiveNamespaces
     *
     * @throws CanonicalizationException
     */
    @Override
    public byte[] engineCanonicalizeSubTree(
        Node rootNode, String inclusiveNamespaces, CanonicalFilter filter
    ) throws CanonicalizationException {
        return engineCanonicalizeSubTree(rootNode, inclusiveNamespaces, null, filter);
    }

    /**
     * Method engineCanonicalizeSubTree
     * @param rootNode
     * @param inclusiveNamespaces
     * @param excl A element to exclude from the c14n process.
     * @return the rootNode c14n.
     * @throws CanonicalizationException
     */
    public byte[] engineCanonicalizeSubTree(
        Node rootNode, String inclusiveNamespaces, Node excl, CanonicalFilter filter
    ) throws CanonicalizationException{
        inclusiveNSSet = InclusiveNamespaces.prefixStr2Set(inclusiveNamespaces);
        return super.engineCanonicalizeSubTree(rootNode, excl, filter);
    }

    @Override
    protected Iterator<Attr> handleAttributesSubtree(Element element, NameSpaceSymbTable ns)
        throws CanonicalizationException {
        // result will contain the attrs which have to be output
        final SortedSet<Attr> result = this.result;
        result.clear();

        // The prefix visibly utilized (in the attribute or in the name) in
        // the element
        SortedSet<String> visiblyUtilized = new TreeSet<String>();
        if (inclusiveNSSet != null && !inclusiveNSSet.isEmpty()) {
            visiblyUtilized.addAll(inclusiveNSSet);
        }

        if (element.hasAttributes()) {
            NamedNodeMap attrs = element.getAttributes();
            int attrsLength = attrs.getLength();
            for (int i = 0; i < attrsLength; i++) {
                Attr attribute = (Attr) attrs.item(i);
                String NName = attribute.getLocalName();
                String NNodeValue = attribute.getNodeValue();

                if (!XMLNS_URI.equals(attribute.getNamespaceURI())) {
                    // Not a namespace definition.
                    // The Element is output element, add the prefix (if used) to
                    // visiblyUtilized
                    String prefix = attribute.getPrefix();
                    if (prefix != null && !(prefix.equals(XML) || prefix.equals(XMLNS))) {
                        visiblyUtilized.add(prefix);
                    }
                    // Add to the result.
                    result.add(attribute);
                } else if (!(XML.equals(NName) && XML_LANG_URI.equals(NNodeValue))
                    && ns.addMapping(NName, NNodeValue, attribute)
                    && C14nHelper.namespaceIsRelative(NNodeValue)) {
                    // The default mapping for xml must not be output.
                    // New definition check if it is relative.
                    Object exArgs[] = {element.getTagName(), NName, attribute.getNodeValue()};
                    throw new CanonicalizationException(
                        "c14n.Canonicalizer.RelativeNamespace", exArgs
                    );
                }
            }
        }
        String prefix = null;
        if (element.getNamespaceURI() != null
            && !(element.getPrefix() == null || element.getPrefix().length() == 0)) {
            prefix = element.getPrefix();
        } else {
            prefix = XMLNS;
        }
        visiblyUtilized.add(prefix);

        for (String s : visiblyUtilized) {
            Attr key = ns.getMapping(s);
            if (key != null) {
                result.add(key);
            }
        }

        return result.iterator();
    }

    /**
     * @inheritDoc
     * @param element
     * @throws CanonicalizationException
     */
    @Override
    protected final Iterator<Attr> handleAttributes(Element element, NameSpaceSymbTable ns)
        throws CanonicalizationException {
        // result will contain the attrs which have to be output
        final SortedSet<Attr> result = this.result;
        result.clear();

        // The prefix visibly utilized (in the attribute or in the name) in
        // the element
        Set<String> visiblyUtilized = null;
        // It's the output selected.
        boolean isOutputElement = isVisibleDO(element, ns.getLevel()) == 1;
        if (isOutputElement) {
            visiblyUtilized = new TreeSet<String>();
            if (inclusiveNSSet != null && !inclusiveNSSet.isEmpty()) {
                visiblyUtilized.addAll(inclusiveNSSet);
            }
        }

        if (element.hasAttributes()) {
            NamedNodeMap attrs = element.getAttributes();
            int attrsLength = attrs.getLength();
            for (int i = 0; i < attrsLength; i++) {
                Attr attribute = (Attr) attrs.item(i);

                String NName = attribute.getLocalName();
                String NNodeValue = attribute.getNodeValue();

                if (!XMLNS_URI.equals(attribute.getNamespaceURI())) {
                    if (isVisible(attribute) && isOutputElement) {
                        // The Element is output element, add the prefix (if used)
                        // to visibyUtilized
                        String prefix = attribute.getPrefix();
                        if (prefix != null && !(prefix.equals(XML) || prefix.equals(XMLNS))) {
                            visiblyUtilized.add(prefix);
                        }
                        // Add to the result.
                        result.add(attribute);
                    }
                } else if (isOutputElement && !isVisible(attribute) && !XMLNS.equals(NName)) {
                    ns.removeMappingIfNotRender(NName);
                } else {
                    if (!isOutputElement && isVisible(attribute)
                        && inclusiveNSSet.contains(NName)
                        && !ns.removeMappingIfRender(NName)) {
                        Node n = ns.addMappingAndRender(NName, NNodeValue, attribute);
                        if (n != null) {
                            result.add((Attr)n);
                            if (C14nHelper.namespaceIsRelative(attribute)) {
                                Object exArgs[] = { element.getTagName(), NName, attribute.getNodeValue() };
                                throw new CanonicalizationException(
                                    "c14n.Canonicalizer.RelativeNamespace", exArgs
                                );
                            }
                        }
                    }

                    if (ns.addMapping(NName, NNodeValue, attribute)
                        && C14nHelper.namespaceIsRelative(NNodeValue)) {
                        // New definition check if it is relative
                        Object exArgs[] = { element.getTagName(), NName, attribute.getNodeValue() };
                        throw new CanonicalizationException(
                            "c14n.Canonicalizer.RelativeNamespace", exArgs
                        );
                    }
                }
            }
        }

        if (isOutputElement) {
            // The element is visible, handle the xmlns definition
            Attr xmlns = element.getAttributeNodeNS(XMLNS_URI, XMLNS);
            if (xmlns != null && !isVisible(xmlns)) {
                // There is a definition but the xmlns is not selected by the
                // xpath. then xmlns=""
                ns.addMapping(XMLNS, "", nullNode);
            }

            String prefix = null;
            if (element.getNamespaceURI() != null
                && !(element.getPrefix() == null || element.getPrefix().length() == 0)) {
                prefix = element.getPrefix();
            } else {
                prefix = XMLNS;
            }
            visiblyUtilized.add(prefix);

            for (String s : visiblyUtilized) {
                Attr key = ns.getMapping(s);
                if (key != null) {
                    result.add(key);
                }
            }
        }

        return result.iterator();
    }

    /*
    protected void circumventBugIfNeeded(XMLSignatureInput input)
        throws CanonicalizationException, ParserConfigurationException,
               IOException, SAXException {
        if (!input.isNeedsToBeExpanded() || inclusiveNSSet.isEmpty() || inclusiveNSSet.isEmpty()) {
            return;
        }
        Document doc = null;
        if (input.getSubNode() != null) {
            doc = XMLUtils.getOwnerDocument(input.getSubNode());
        } else {
            doc = XMLUtils.getOwnerDocument(input.getNodeSet());
        }
        XMLUtils.circumventBug2650(doc);
    }
    */
}


text:
<?php

/* @var $this \yii\web\View */
/* @var $content string */

use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use app\assets\AppAsset;
use yii\helpers\Url;
AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">

    <meta charset="<?= Yii::$app->charset ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta property="og:title" content="Visconti" />
    <meta property="og:type" content="Community of Practice" />
    <meta property="og:url" content="http://cop.viscontiproject.eu/" />
    <meta property="og:image" content="../web/images/avatar_big.png" />
    <meta property="og:description"  content="VISConti Project, a Community of Practice where students can have their ideas and projects evaluated by true experts." />
    <?= Html::csrfMetaTags() ?>
	<link rel="icon" type="image/png" href="../images/icon.png?v=1" />
    <title><?= Html::encode($this->title) ?></title>
    <?php //$this->head() ?>
    <?php
		$controller = Yii::$app->controller;
		$is = (($controller->action->id === "create")) ? true : false;
		if($is)
			echo '<link href="/web/assets/e473f026/dropzone/dist/min/dropzone2.min.css" rel="stylesheet">';
        if (YII_ENV_DEV)
            echo '<link href="/web/assets/ba2b43d0/toolbar.css" rel="stylesheet">	';
    ?>
	<link href='http://fonts.googleapis.com/css?family=Oxygen:400,700' rel='stylesheet'>
	<link href="../web/css/site.css" rel="stylesheet">

<?php $this->beginBody() ?>

					<?php $isfaq = ($controller->action->id === "faq") ? true : false; ?>
					<li<?php if(!$isfaq) echo' class="active"'; ?>>
					<?php if($isfaq && Yii::$app->user->isGuest) echo 'Login / Register'; else echo 'Home';?>

					<li<?php if($isfaq) echo' class="active"'; ?>>FAQ

				<?php
					if(!Yii::$app->user->isGuest){
                        if(Yii::$app->user->identity->type=='e')
                        echo 'user->id . '">'. Yii::$app->user->identity->getEmail() .'';
                        else echo 'user->id . '">'. Yii::$app->user->identity->getEmail() .'';
                    }
				?>

	<?php
		$is = (($controller->action->id === "faq" && Yii::$app->user->isGuest) || ($controller->action->id === "profile") || ($controller->action->id === "account") || ($controller->action->id === "login") || ($controller->action->id === "register")) ? true : false;
		if(!$is) {
			echo '

';
	?>

<?php
    NavBar::begin([
        'brandUrl' => Yii::$app->homeUrl,
        'options' => [
			'id' => 'menu1',
            'class' => 'col-md-2 col-sm-3',
        ],
    ]);
    $navItems=[
    ['label' => 'Home', 'url' => ['/site/index']]
  ];
    $navItemsRight=[];
  if (Yii::$app->user->isGuest) {
    array_push($navItemsRight,['label' => 'Sign In', 'url' => ['/site/login']],['label' => 'Sign Up', 'url' => ['/site/register']]);
  } else {
    if(Yii::$app->user->identity->type == 's'){
        array_push($navItemsRight, ['label' => 'Update Profile', 'url' => Url::to(['student/update', 'id' => Yii::$app->user->id])]);
    }else array_push($navItemsRight, ['label' => 'Update Profile', 'url' => Url::to(['expert/update', 'id' => Yii::$app->user->id])]);
    array_push($navItemsRight,
		['label' => 'Logout',
        'url' => ['/site/logout'],
        'linkOptions' => ['data-method' => 'post']]
    );
  }

  if(!Yii::$app->user->isGuest && Yii::$app->user->identity->type=='s')
  {
    array_push($navItems,
        ['label'=>'Create Canvas', 'url'=>['canvas/create']]);
  }
echo '
Site Menu
';
echo Nav::widget([
    'items' => $navItems,
]);
echo '
Account Menu
';
echo Nav::widget([
    'items' => $navItemsRight,
]);
    NavBar::end();
?>

	<?php } ?>

        <?= $content ?>

			© VISConti <?= date('Y') ?>

<?php $this->endBody() ?>
<?php
	if($isfaq && Yii::$app->user->isGuest)
		echo '';
?>

<?php $this->endPage() ?>


text:
package org.apache.isis.core.metamodel.facets.propparam.specification;

import org.apache.isis.applib.AbstractDomainObject;

public class DomainObjectWithoutMustSatisfyAnnotations extends AbstractDomainObject {

    private String firstName;

    public String getFirstName() {
        resolve(firstName);
        return firstName;
    }

    public void setFirstName(final String firstName) {
        this.firstName = firstName;
        objectChanged();
    }

    private String lastName;

    public String getLastName() {
        resolve(lastName);
        return lastName;
    }

    public void setLastName(final String lastName) {
        this.lastName = lastName;
        objectChanged();
    }

    public void changeLastName(final String lastName) {
        setLastName(lastName);
    }

}


text:
<?php
namespace AclRole\Mapper\Factory;

use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Stdlib\Hydrator\Aggregate\AggregateHydrator;
use AclRole\Mapper\RoleMapper;
use AclRole\Hydrator\RoleHydrator;
use AclRole\Entity\RoleEntity;

class RoleMapperFactory implements FactoryInterface
{

    /**
     *
     * {@inheritDoc}
     * @see \Zend\ServiceManager\FactoryInterface::createService()
     */
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $hydrator = new AggregateHydrator();

        $hydrator->add(new RoleHydrator());

        $prototype = new RoleEntity();

        $readAdapter = $serviceLocator->get('db1');

        $writeAdapter = $serviceLocator->get('db2');

        return new RoleMapper($readAdapter, $writeAdapter, $hydrator, $prototype);
    }
}


text:
<!DOCTYPE html>

    <title>Typson playground</title>

    <textarea id="source">
interface Dimension {
    /** Width in cm */
        width: number;

    /** Height in cm */
        height: number;

    /** Length in cm */
        length:  number;
}
    </textarea>
    <button id="generate">Run</button>


text:
package akka.actor

import java.lang.reflect.{ Modifier, ParameterizedType, TypeVariable }

import akka.dispatch._
import akka.japi.Creator
import akka.routing._
import akka.util.Reflect

import scala.annotation.varargs
import scala.language.existentials
import scala.reflect.ClassTag

/**
 * Java API: Factory for Props instances.
 */
trait AbstractProps {

  def isAbstract(clazz: Class[_]) =
    if (Modifier.isAbstract(clazz.getModifiers))
      throw new IllegalArgumentException(s"Actor class [${clazz.getName}] must not be abstract")

  /**
   * Java API: create a Props given a class and its constructor arguments.
   */
  @varargs
  def create(clazz: Class[_], args: AnyRef*): Props = Props(clazz = clazz, args = args.toSeq)

  /**
   * Create new Props from the given [[akka.japi.Creator]].
   *
   * You can not use a Java 8 lambda with this method since the generated classes
   * don't carry enough type information.
   *
   * Use the Props.create(actorClass, creator) instead.
   */
  def create[T <: Actor](creator: Creator[T]): Props = {
    val cc = creator.getClass
    if ((cc.getEnclosingClass ne null) && (cc.getModifiers & Modifier.STATIC) == 0)
      throw new IllegalArgumentException("cannot use non-static local Creator to create actors; make it static (e.g. local to a static method) or top-level")
    val ac = classOf[Actor]
    val coc = classOf[Creator[_]]
    val actorClass = Reflect.findMarker(cc, coc) match {
      case t: ParameterizedType ⇒
        t.getActualTypeArguments.head match {
          case c: Class[_] ⇒ c // since T <: Actor
          case v: TypeVariable[_] ⇒
            v.getBounds collectFirst { case c: Class[_] if ac.isAssignableFrom(c) && c != ac ⇒ c } getOrElse ac
          case x ⇒ throw new IllegalArgumentException(s"unsupported type found in Creator argument [$x]")
        }
      case c: Class[_] if (c == coc) ⇒
        throw new IllegalArgumentException(s"erased Creator types are unsupported, use Props.create(actorClass, creator) instead")
    }
    Props(clazz = classOf[CreatorConsumer], args = Seq(actorClass, creator))
  }

  /**
   * Create new Props from the given [[akka.japi.Creator]] with the type set to the given actorClass.
   */
  def create[T <: Actor](actorClass: Class[T], creator: Creator[T]): Props = {
    Props(clazz = classOf[CreatorConsumer], args = Seq(actorClass, creator))
  }
}


text:
.. blogpost::
    :title: List of tools needed to build the documentation
    :keywords: documentation, startup
    :date: 2017-04-27
    :categories: installation

    I have been setting up a couple of times
    a machine to build this documentation and others
    for my teachings. I do that on Windows.
    Here is the list of tools I need:

    * :epkg:`Miktex`: there is one question during the installation about
      silent installation of new packages, change the default value to yes.
    * :epkg:`GraphViz`
    * :epkg:`InkScape`

    About Python:

    * `Python 3.6 <https://www.python.org/>`_

    And the necessary modules:

    ::

        pip install pymyinstall
        pymy_install --set=pyquickhelper
        pip install pyquickhelper

    A couple of others might be needed.
    I usually use a couple of editors:

    * :epkg:`SciTe`: the most simple one
    * :epkg:`TexnicCenter`: for latex

    And some useful tools:

    * `7zip <http://www.7-zip.org/>`_

    I usually install
    `Visual Studio Community Edition 2015 <http://www.xavierdupre.fr/app/pymyinstall/helpsphinx/blog/2017/2017-04-18_vs2015.html>`_
    just in case a module requires C++.
    Sometimes, I create a new module just for a new documentation with notebooks.
    I start from this template
    `python3_module_template <https://github.com/sdpython/python3_module_template/>`_.
    I change the name, update the dependencies in
    `setup.py <https://github.com/sdpython/python3_module_template/blob/master/setup.py>`_,
    update the automated build if the project is open source (travis, appveyor...).
    I then modify the file
    `.local.jenkins.win.yml <https://github.com/sdpython/python3_module_template/blob/master/.local.jenkins.win.yml>`_
    which I use to define an automated build on `Jenkins <https://jenkins.io/>`_.
    The module is automated but still quite strict about its design.
    Notebooks have to be placed into
    `_doc/notebooks <https://github.com/sdpython/python3_module_template/tree/master/_doc/notebooks>`_,
    examples into `_doc/examples <https://github.com/sdpython/python3_module_template/tree/master/_doc/examples>`_
    and documentation into `_doc/sphinxdoc/source <https://github.com/sdpython/python3_module_template/tree/master/_doc/sphinxdoc/source>`_.
    The documentation can be compiled by just running:

    ::

        python setup.py build_sphinx

    The unit tests by running:

    ::

        python setup.py unittests


text:
#ifndef DEVDUINO_FONT_H
#define DEVDUINO_FONT_H

#include <stdint.h>

/**
* Default namespace for devduino related code.
*/

	/**
	 * \brief A font is the graphical representation of a set of characters to display.
	 *
	 * A font is composed of glyphs which are a graphical representation of a character.
	 */
	class Font {
	public:
		/**
		 * \brief Get the size of font.
		 *
		 * Size of font correspond to its height.
		 *
		 * \return the size of font.
		 */
		virtual uint8_t getSize() = 0;

		/**
		 * \brief Get the width of the glyph.
		 *
		 * \param characterCode The code of the character to get width for.
		 *
		 * \return the width of glyph.
		 */
		virtual uint8_t getGlyphWidth(uint8_t characterCode) = 0;

		/**
		 * \brief Get the height of the glyph.
		 *
		 * \param characterCode The code of the character to get height for.
		 *
		 * \return the height of glyph.
		 */
		virtual uint8_t getGlyphHeight(uint8_t characterCode) = 0;

		/**
		 * \brief Get the pixels of the glyph.
		 *
		 * \attention For implementors, the ordering of the buffer of pixels must be compatible with the display buffer.
		 *
		 * \param characterCode The code of the character to get pixels for.
		 *
		 * \return A pointer to the pixels of glyph.
		 */
		virtual const uint8_t* getGlyphPixels(uint8_t characterCode) = 0;

		/**
		 * \brief Get the kerning of the glyph.
		 *
		 * \param characterCode The code of the character to get kerning for.
		 * \param previousCharacterCode The code of the character preceding the one to get kerning for.
		 *
		 * \return The kerning to apply between this character and previous one.
		 */
		virtual int8_t getGlyphKerning(uint8_t characterCode, uint8_t previousCharacterCode) = 0;

		/**
		 * \brief Get the number of pixels to advance on X axis after having rendered this font.
		 *
		 * \param characterCode The code of the character to get advance for.
		 *
		 * \return The number of pixels representing advancement.
		 */
		virtual uint8_t getGlyphXAdvance(uint8_t characterCode) = 0;

		/**
		* \brief Get the number of pixels to advance on X axis before rendering this font.
		*
		* \param characterCode The code of the character to get offset for.
		*
		* \return The number of pixels representing offset.
		*/
		virtual int8_t getGlyphXOffset(uint8_t characterCode) = 0;

		/**
		* \brief Get the number of pixels to advance on Y axis before rendering this font.
		*
		* \param characterCode The code of the character to get offset for.
		*
		* \return The number of pixels representing offset.
		*/
		virtual int8_t getGlyphYOffset(uint8_t characterCode) = 0;
	};

#endif //DEVDUINO_FONT_H


text:
from zope.interface import Interface

class ISaver(Interface):
    pass

class IAfterSaver(Interface):
    pass

class ISASession(Interface):
    pass

class ISABase(Interface):
    pass


text:
/**
 * @file
 * Implementation of the OS abstraction layer for the kernel device driver
 */

#ifndef _OSK_ARCH_TIMERS_H
#define _OSK_ARCH_TIMERS_H

#ifndef _OSK_H_
#error "Include mali_osk.h directly"
#endif

#ifdef CONFIG_MALI_DEBUG
void oskp_debug_test_timer_stats( void );
#endif

enum hrtimer_restart oskp_timer_callback_wrapper( struct hrtimer * hr_timer );

OSK_STATIC_INLINE osk_error osk_timer_init(osk_timer * const tim)
{
	OSK_ASSERT(NULL != tim);

	OSK_DEBUG_CODE( oskp_debug_test_timer_stats() );

	hrtimer_init(&tim->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	tim->timer.function = NULL;

	OSK_DEBUG_CODE(	tim->active = MALI_FALSE );
	OSK_ASSERT(0 ==	object_is_on_stack(tim));
	return OSK_ERR_NONE;
}

OSK_STATIC_INLINE osk_error osk_timer_on_stack_init(osk_timer * const tim)
{
	OSK_ASSERT(NULL != tim);
	hrtimer_init_on_stack(&tim->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	tim->timer.function = NULL;

	OSK_DEBUG_CODE(	tim->active = MALI_FALSE );
	OSK_ASSERT(0 !=	object_is_on_stack(tim));
	return OSK_ERR_NONE;
}

OSK_STATIC_INLINE osk_error osk_timer_start(osk_timer *tim, u32 delay)
{
	osk_error err;
	u64 delay_ns = delay * (u64)1000000U;

	err = osk_timer_start_ns( tim, delay_ns );

	return err;
}

OSK_STATIC_INLINE osk_error osk_timer_start_ns(osk_timer *tim, u64 delay_ns)
{
	ktime_t kdelay;
	int was_active;
	OSK_ASSERT(NULL != tim);
	OSK_ASSERT(NULL != tim->timer.function);
	OSK_ASSERT(delay_ns != 0);

	kdelay = ns_to_ktime( delay_ns );

	was_active = hrtimer_start( &tim->timer, kdelay, HRTIMER_MODE_REL );

	OSK_ASSERT( was_active == 0 ); /* You cannot start a timer that has already been started */

	CSTD_UNUSED( was_active );
	OSK_DEBUG_CODE(	tim->active = MALI_TRUE );
	return OSK_ERR_NONE;
}

OSK_STATIC_INLINE osk_error osk_timer_modify(osk_timer *tim, u32 new_delay)
{
	osk_error err;
	u64 delay_ns = new_delay * (u64)1000000U;

	err = osk_timer_modify_ns( tim, delay_ns );
	return err;
}

OSK_STATIC_INLINE osk_error osk_timer_modify_ns(osk_timer *tim, u64 new_delay_ns)
{
	ktime_t kdelay;
	int was_active;
	OSK_ASSERT(NULL != tim);
	OSK_ASSERT(NULL != tim->timer.function);
	OSK_ASSERT(0 != new_delay_ns);

	kdelay = ns_to_ktime( new_delay_ns );

	/* hrtimers will stop the existing timer if it's running on any cpu, so
	 * it's safe just to start the timer again: */
	was_active = hrtimer_start( &tim->timer, kdelay, HRTIMER_MODE_REL );

	CSTD_UNUSED( was_active );
	OSK_DEBUG_CODE(	tim->active = MALI_TRUE );
	return OSK_ERR_NONE;
}

OSK_STATIC_INLINE void osk_timer_stop(osk_timer *tim)
{
	int was_active;
	OSK_ASSERT(NULL != tim);
	OSK_ASSERT(NULL != tim->timer.function);

	was_active = hrtimer_cancel(&tim->timer);

	CSTD_UNUSED( was_active );
	OSK_DEBUG_CODE( tim->active = MALI_FALSE );
}

OSK_STATIC_INLINE void osk_timer_callback_set(osk_timer *tim, osk_timer_callback callback, void *data)
{
	OSK_ASSERT(NULL != tim);
	OSK_ASSERT(NULL != callback);
	OSK_DEBUG_CODE(
		if (MALI_FALSE == tim->active)
		{
		}
	);

	tim->timer.function = &oskp_timer_callback_wrapper;

	/* osk_timer_callback uses void * for the callback parameter instead of unsigned long in Linux */
	tim->callback = callback;
	tim->data = data;
}

OSK_STATIC_INLINE void osk_timer_term(osk_timer *tim)
{
	OSK_ASSERT(NULL != tim);
	OSK_ASSERT(0 ==	object_is_on_stack(tim));
	OSK_DEBUG_CODE(
		if (MALI_FALSE == tim->active)
		{
		}
	);
	/* Nothing to do */
}

OSK_STATIC_INLINE void osk_timer_on_stack_term(osk_timer *tim)
{
	OSK_ASSERT(NULL != tim);
	OSK_ASSERT(0 !=	object_is_on_stack(tim));
	OSK_DEBUG_CODE(
		if (MALI_FALSE == tim->active)
		{
		}
	);
	destroy_hrtimer_on_stack(&tim->timer);
}

#endif /* _OSK_ARCH_TIMERS_H_ */


text: export * from './prose.module';


text:
<?php namespace CSP\Test\Directive;

use CSP\Test\TestCase;
use CSP\Directive\ReportURIDirective;
use CSP\URI;

class ReportURIDirectiveTest extends TestCase
{
    /**
     * @coversNothing
     */
    public function testDirective()
    {
        $this->assertInstanceOf(
            'CSP\Directive\AbstractDirective',
            new ReportURIDirective
        );
    }

    /**
     * @covers CSP\Directive\ReportURIDirective::setValue
     */
    public function testSetValueArgumentException()
    {
        $this->setExpectedException('InvalidArgumentException', 'ReportURIDirective value must be an instance of URI');
        $directive = new ReportURIDirective;
        $directive->setValue('ABCDE');
    }

    /**
     * @covers CSP\Directive\ReportURIDirective::setValue
     */
    public function testSetValue()
    {
        $directive = new ReportURIDirective;
        $sourceList = new URI('http://example.com');
        $directive->setValue($sourceList);
        $this->assertSame($sourceList, $directive->getValue());
    }

    /**
     * @covers CSP\Directive\ReportURIDirective::renderValue
     */
    public function testRenderValue()
    {
        $uri = $this->getMock('CSP\URI', array(
            'render',
        ), array('http://example.com'));

        $uri
            ->expects($this->once())
            ->method('render')
            ->will($this->returnValue('ABCDE'));

        $directive = new ReportURIDirective($uri);
        $this->assertSame('ABCDE', $directive->renderValue());
    }
}


text:
void initConsole( void )
{
	int hConHandle;
	long lStdHandle;

	CONSOLE_SCREEN_BUFFER_INFO conInfo;
	FILE *fp;

	AllocConsole();

	GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &conInfo);

	conInfo.dwSize.Y = MAX_CONSOLE_LINES;

	SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), conInfo.dwSize);

	lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
	hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);

	fp = _fdopen(hConHandle, "w");
	*stdout = *fp;
	setvbuf(stdout, NULL, _IONBF, 0);

	lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
	hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);

	fp = _fdopen( hConHandle, "r" );
	*stdin = *fp;
	setvbuf( stdin, NULL, _IONBF, 0 );

	lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
	hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);

	fp = _fdopen( hConHandle, "w" );
	*stderr = *fp;
	setvbuf( stderr, NULL, _IONBF, 0 );

	ios::sync_with_stdio();
}

#endif // WINDOWS


text:
package io.github.netdex.CircuitDetector.util;

import static org.bukkit.ChatColor.*;

import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.Location;

import mkremins.fanciful.FancyMessage;

public class Violation {

	private Location loc;
	private long lastInstance;
	private long timeDiff;
	private int instances;

	public Violation(Location loc) {
		this.loc = loc;
		instances = 0;
	}

	/**
	 * Increase the instance counter by 1
	 */
	public void addInstance() {
		instances++;
	}

	/**
	 * Get the number of instances of this violation
	 *
	 * @return the number of instances of this violation
	 */
	public int getInstances() {
		return instances;
	}

	public void updateCTime(){
		timeDiff = System.currentTimeMillis() - lastInstance;
		lastInstance = System.currentTimeMillis();
	}

	/**
	 * Get the difference in time from given to last activation
	 *
	 * @return the difference in time from given to last activation
	 */
	public long getTimeDiff() {
		return timeDiff;
	}

	/**
	 * Get the violation's location
	 *
	 * @return the violation's location
	 */
	public Location getLocation() {
		return loc;
	}

	/**
	 * Get the violation's chunk
	 *
	 * @return the violation's chunk
	 */
	public Chunk getChunk() {
		return loc.getChunk();
	}

	/**
	 * Destroy the violation's circuit
	 */
	public void nukeCircuit() {
		Util.destroyCircuit(loc.getBlock(), true);
	}

	public FancyMessage getLogMessage() {
		return new FancyMessage("[TP] ")
					.color(GREEN).style(BOLD)
					.tooltip("Teleport to " + Util.formatLocation(loc))
					.command("/tp " + loc.getBlockX() + " " + loc.getBlockY() + " " + loc.getBlockZ())
				.then("[KILL]")
					.color(RED).style(BOLD)
					.tooltip("Kill entire circuit")
					.command("/cd kill " + loc.getBlockX() + " " + loc.getBlockY() + " " + loc.getBlockZ())

				.then(" : ")
				.color(DARK_GRAY)
				.then("\"").color(AQUA)
				.then(loc.getBlock().getType().name()).color(AQUA)
				.then("\"").color(AQUA)
				.then(" x").color(DARK_RED)
				.then(instances + "").color(DARK_RED)
				.then(" DIFF: ").color(ChatColor.GREEN)
				.then(timeDiff + "");

	}

	@Override
	public boolean equals(Object o) {
		if (o instanceof Violation) {
			if (((Violation) o).getLocation() == loc)
				return true;
		}
		return false;
	}
}


text:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmKeyGen
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmKeyGen))
        Me.TabControl1 = New System.Windows.Forms.TabControl
        Me.tab2 = New System.Windows.Forms.TabPage
        Me.btnKeyGen = New System.Windows.Forms.Button
        Me.lblActivationKey = New System.Windows.Forms.Label
        Me.txtActivationKey = New System.Windows.Forms.TextBox
        Me.txtKey = New System.Windows.Forms.TextBox
        Me.lblKey = New System.Windows.Forms.Label
        Me.MenuStrip1 = New System.Windows.Forms.MenuStrip
        Me.HelpToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.AboutToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.btnExit = New System.Windows.Forms.Button
        Me.TabControl1.SuspendLayout()
        Me.tab2.SuspendLayout()
        Me.MenuStrip1.SuspendLayout()
        Me.GroupBox1.SuspendLayout()
        Me.SuspendLayout()
        '
        'TabControl1
        '
        Me.TabControl1.Controls.Add(Me.tab2)
        Me.TabControl1.Location = New System.Drawing.Point(1, 31)
        Me.TabControl1.Name = "TabControl1"
        Me.TabControl1.SelectedIndex = 0
        Me.TabControl1.Size = New System.Drawing.Size(585, 174)
        Me.TabControl1.TabIndex = 9
        '
        'tab2
        '
        Me.tab2.Controls.Add(Me.btnKeyGen)
        Me.tab2.Controls.Add(Me.lblActivationKey)
        Me.tab2.Controls.Add(Me.txtActivationKey)
        Me.tab2.Controls.Add(Me.txtKey)
        Me.tab2.Controls.Add(Me.lblKey)
        Me.tab2.Location = New System.Drawing.Point(4, 22)
        Me.tab2.Name = "tab2"
        Me.tab2.Padding = New System.Windows.Forms.Padding(3)
        Me.tab2.Size = New System.Drawing.Size(577, 148)
        Me.tab2.TabIndex = 1
        Me.tab2.Text = "KeyGen"
        Me.tab2.UseVisualStyleBackColor = True
        '
        'btnKeyGen
        '
        Me.btnKeyGen.Location = New System.Drawing.Point(400, 16)
        Me.btnKeyGen.Name = "btnKeyGen"
        Me.btnKeyGen.Size = New System.Drawing.Size(167, 118)
        Me.btnKeyGen.TabIndex = 9
        Me.btnKeyGen.Text = "&Generate"
        Me.btnKeyGen.UseVisualStyleBackColor = True
        '
        'lblActivationKey
        '
        Me.lblActivationKey.AutoSize = True
        Me.lblActivationKey.Location = New System.Drawing.Point(11, 55)
        Me.lblActivationKey.Name = "lblActivationKey"
        Me.lblActivationKey.Size = New System.Drawing.Size(75, 13)
        Me.lblActivationKey.TabIndex = 13
        Me.lblActivationKey.Text = "Activation Key"
        '
        'txtActivationKey
        '
        Me.txtActivationKey.Location = New System.Drawing.Point(9, 71)
        Me.txtActivationKey.Multiline = True
        Me.txtActivationKey.Name = "txtActivationKey"
        Me.txtActivationKey.ReadOnly = True
        Me.txtActivationKey.Size = New System.Drawing.Size(385, 63)
        Me.txtActivationKey.TabIndex = 12
        '
        'txtKey
        '
        Me.txtKey.Location = New System.Drawing.Point(9, 32)
        Me.txtKey.Name = "txtKey"
        Me.txtKey.Size = New System.Drawing.Size(385, 20)
        Me.txtKey.TabIndex = 10
        '
        'lblKey
        '
        Me.lblKey.AutoSize = True
        Me.lblKey.Location = New System.Drawing.Point(11, 16)
        Me.lblKey.Name = "lblKey"
        Me.lblKey.Size = New System.Drawing.Size(75, 13)
        Me.lblKey.TabIndex = 11
        Me.lblKey.Text = "Challenge Key"
        '
        'MenuStrip1
        '
        Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.HelpToolStripMenuItem})
        Me.MenuStrip1.Location = New System.Drawing.Point(0, 0)
        Me.MenuStrip1.Name = "MenuStrip1"
        Me.MenuStrip1.Size = New System.Drawing.Size(594, 28)
        Me.MenuStrip1.TabIndex = 10
        Me.MenuStrip1.Text = "MenuStrip1"
        '
        'HelpToolStripMenuItem
        '
        Me.HelpToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.AboutToolStripMenuItem})
        Me.HelpToolStripMenuItem.Name = "HelpToolStripMenuItem"
        Me.HelpToolStripMenuItem.Size = New System.Drawing.Size(45, 24)
        Me.HelpToolStripMenuItem.Text = "Help"
        '
        'AboutToolStripMenuItem
        '
        Me.AboutToolStripMenuItem.Name = "AboutToolStripMenuItem"
        Me.AboutToolStripMenuItem.Size = New System.Drawing.Size(112, 24)
        Me.AboutToolStripMenuItem.Text = "About"
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.btnExit)
        Me.GroupBox1.Location = New System.Drawing.Point(3, 207)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(583, 66)
        Me.GroupBox1.TabIndex = 11
        Me.GroupBox1.TabStop = False
        '
        'btnExit
        '
        Me.btnExit.Location = New System.Drawing.Point(7, 16)
        Me.btnExit.Name = "btnExit"
        Me.btnExit.Size = New System.Drawing.Size(570, 40)
        Me.btnExit.TabIndex = 0
        Me.btnExit.Text = "E&xit"
        Me.btnExit.UseVisualStyleBackColor = True
        '
        'frmKeyGen
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(594, 274)
        Me.ControlBox = False
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.TabControl1)
        Me.Controls.Add(Me.MenuStrip1)
        Me.HelpButton = True
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MainMenuStrip = Me.MenuStrip1
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmKeyGen"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "KeyGen2014@BluePhoenix"
        Me.TabControl1.ResumeLayout(False)
        Me.tab2.ResumeLayout(False)
        Me.tab2.PerformLayout()
        Me.MenuStrip1.ResumeLayout(False)
        Me.MenuStrip1.PerformLayout()
        Me.GroupBox1.ResumeLayout(False)
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub
    Friend WithEvents TabControl1 As System.Windows.Forms.TabControl
    Friend WithEvents tab2 As System.Windows.Forms.TabPage
    Friend WithEvents MenuStrip1 As System.Windows.Forms.MenuStrip
    Friend WithEvents HelpToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents AboutToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
    Friend WithEvents btnKeyGen As System.Windows.Forms.Button
    Friend WithEvents lblActivationKey As System.Windows.Forms.Label
    Friend WithEvents txtActivationKey As System.Windows.Forms.TextBox
    Friend WithEvents txtKey As System.Windows.Forms.TextBox
    Friend WithEvents lblKey As System.Windows.Forms.Label
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents btnExit As System.Windows.Forms.Button

End Class


text:
export default (method, ...params) => {
    return async dispatch => {
        let response = null;
        try {
            response = await method(...params);
            if (response) {
                console.log('dispatching ', response);
                dispatch(response.data);
            }
        }
        catch (error) {
            console.error(error);
        }
    }
}


text:
namespace Lucene
{
    SnowballFilter::SnowballFilter(TokenStreamPtr input, const String& name) : TokenFilter(input)
    {
        stemmer = sb_stemmer_new(StringUtils::toUTF8(name).c_str(), "UTF_8");
        if (stemmer == NULL)
            boost::throw_exception(IllegalArgumentException(L"language not available for stemming:" + name));
        termAtt = addAttribute<TermAttribute>();
        utf8Result = newLucene<UTF8Result>();
    }

    SnowballFilter::~SnowballFilter()
    {
    }

    bool SnowballFilter::incrementToken()
    {
        if (input->incrementToken())
        {
            StringUtils::toUTF8(termAtt->termBuffer().get(), termAtt->termLength(), utf8Result);
            const sb_symbol* stemmed = sb_stemmer_stem(stemmer, utf8Result->result.get(), utf8Result->length);
            if (stemmed == NULL)
                boost::throw_exception(RuntimeException(L"exception stemming word:" + termAtt->term()));
            int32_t newlen = StringUtils::toUnicode(stemmed, sb_stemmer_length(stemmer), termAtt->termBuffer());
            termAtt->setTermLength(newlen);
            return true;
        }
        else
            return false;
    }
}