text:
package com.slamdunk.api;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;

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

public class HttpRequest {

    /**
     * GET data from Dribbble using the request URI
     * with URL parameters
     *
     * @param requestURI Dribbble URI requested
     * @param param Parameter to be inserted in the URI
     * @return JSONObject containing a response
     */
    public JSONObject get(String requestURI, String param) {
        return getData(requestURI.replace("?", param));
    }

    /**
     * Workhorse method that GETs data from a URL and
     * returns the result as a JSON object
     *
     * @param requestURI The Dribbble endpoint requested
     * @return JSONObject containing the full Dribbble API response
     */
    protected JSONObject getData(String requestURI) {
        String jsonResult = "";

        JSONObject json = null;

        try {
            URL url = new URL(requestURI);
            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));

            String responseLine;
            while ((responseLine = in.readLine()) != null) {
                jsonResult += responseLine;
            }

            in.close();

            json = new JSONObject(jsonResult);
        } catch (MalformedURLException e) {
            throw new RuntimeException("Invalid URL requested");
        } catch (IOException e) {
            throw new RuntimeException("Could not read from requested stream");
        } catch (JSONException e) {
            throw new RuntimeException("JSON could not be formed");
        }

        return json;
    }

}


text:
import {__platform_browser_private__ as _} from '@angular/platform-browser';

export type DomAdapter = typeof _._DomAdapter;
export var DomAdapter: typeof _.DomAdapter = _.DomAdapter;
export var setRootDomAdapter: typeof _.setRootDomAdapter = _.setRootDomAdapter;
export var getDOM: typeof _.getDOM = _.getDOM;

redpajama_set_name: RedPajamaGithub


text:
package infodynamics.measures.discrete;

import infodynamics.utils.MathsUtils;
import infodynamics.utils.MatrixUtils;

/**
 *
 Predictive information calculator for univariate discrete (int[]) data.
 * See definition of Predictive information (PI) by Bialek et al. below,
 * also is a form of the Excess Entropy (see Crutchfield and Feldman below),
 * Basically, PI is the mutual information between the past state
 * of a time-series process X and its future state.
 * The past state at time n
 * is represented by an embedding vector of k values from X_n backwards,
 * each separated by \tau steps, giving
 * X^k_n = [ X_{n-(k-1)\tau}, ... , X_{n-\tau}, X_n].
 * We call k the embedding dimension, and \tau
 * the embedding delay (only delay = 1 is implemented at the moment).
 * The future state at time n
 * is defined similarly into the future:
 * each separated by \tau steps, giving
 * X^k+_n = [ X_{n+1}, X_{n+\tau}, X_{n+(k-1)\tau}].
 * PI is then the mutual information between X^k_n and X^k+_n.

 *
 *
Usage of the class is intended to follow this paradigm:

 *

 *
Construct the calculator:
 * 			{@link #PredictiveInformationCalculatorDiscrete(int, int)};

 *
Initialise the calculator using {@link #initialise()};

 *
Provide the observations/samples for the calculator
 *      	to set up the PDFs, using one or more calls to
 * 			sets of {@link #addObservations(int[])} methods, then

 *
Compute the required quantities, being one or more of:
 *

 *
the average entropy: {@link #computeAverageLocalOfObservations()};

 *
local entropy values, such as {@link #computeLocal(int[])};

 *
and variants of these.

 *

 *

 *
As an alternative to steps 3 and 4, the user may undertake
 * 			standalone computation from a single set of observations, via
 *  		e.g.: {@link #computeLocal(int[])},
 *  		{@link #computeAverageLocal(int[])} etc.

 *

 * 		Return to step 2 to re-use the calculator on a new data set.
 *

 *

 *
 *
TODO Inherit from {@link SingleAgentMeasureDiscreteInContextOfPastCalculator}
 *  as {@link ActiveInformationCalculatorDiscrete} does; Tidy up the Javadocs for
 *  the methods, which are somewhat preliminary

 *
 *
References:

 *

 *
Bialek, W., Nemenman, I., and Tishby, N.,
 *
 * 	"Complexity through nonextensivity",
 *  Physica A, 302, 89-99. (2001).

 *
J. P. Crutchfield, D. P. Feldman,
 *
 * 	"Regularities Unseen, Randomness Observed: Levels of Entropy Convergence",
 *  Chaos, Vol. 13, No. 1. (2003), pp. 25-54.

 *

 *
 * @author Joseph Lizier (email,
 * www)
 */
public class PredictiveInformationCalculatorDiscrete {

	private double average = 0.0;
	private double max = 0.0;
	private double min = 0.0;
	private int observations = 0;
	private int k = 0; // history/future block length k.
	private int numDiscreteValues = 0; // number of individual states.
	private int[][]	jointCount = null; // Count for (x[t+1], x[t]) tuples
	private int[] prevCount = null; // Count for x[t]
	private int[] nextCount = null; // Count for x[t+1]
	private int[] maxShiftedValue = null; // states * (base^(history-1))

	private int base_power_k = 0;
	private double log_base = 0;

	/**
	 * User was formerly forced to create new instances through this factory method.
	 * Retained for backwards compatibility.
	 *
	 * @param numDiscreteValues Number of discrete values (e.g. 2 for binary states)
	 * @param blockLength
	 * @deprecated
	 * @return
	 */
	public static PredictiveInformationCalculatorDiscrete newInstance(int numDiscreteValues, int blockLength) {
		return new PredictiveInformationCalculatorDiscrete(numDiscreteValues, blockLength);
	}

	/**
	 * Construct a new instance
	 *
	 * @param numDiscreteValues number of quantisation levels for each variable.
	 *        E.g. binary variables are in base-2.
	 * @param blockLength embedded history length of the past and future to use -
	 *        this is k in Schreiber's notation.
	 */
	public PredictiveInformationCalculatorDiscrete(int numDiscreteValues, int blockLength) {
		super();

		this.numDiscreteValues = numDiscreteValues;
		k = blockLength;
		base_power_k = MathsUtils.power(numDiscreteValues, k);
		log_base = Math.log(numDiscreteValues);

		if (blockLength < 1) {
			throw new RuntimeException("History k " + blockLength + " is not >= 1 for Predictive information calculator");
		}
		if (k > Math.log(Integer.MAX_VALUE) / log_base) {
			throw new RuntimeException("Base and history combination too large");
		}

		// Create storage for counts of observations
		jointCount = new int[base_power_k][base_power_k];
		prevCount = new int[base_power_k];
		nextCount = new int[base_power_k];

		// Create constants for tracking prevValues and nextValues
		maxShiftedValue = new int[numDiscreteValues];
		for (int v = 0; v < numDiscreteValues; v++) {
			maxShiftedValue[v] = v * MathsUtils.power(numDiscreteValues, k-1);
		}
	}

	/**
	 * Initialise calculator, preparing to take observation sets in
	 * Should be called prior to any of the addObservations() methods.
	 * You can reinitialise without needing to create a new object.
	 *
	 */
	public void initialise(){
		average = 0.0;
		max = 0.0;
		min = 0.0;
		observations = 0;

		MatrixUtils.fill(jointCount, 0);
		MatrixUtils.fill(prevCount, 0);
		MatrixUtils.fill(nextCount, 0);
	}

	/**
 	 * Add observations in to our estimates of the pdfs.
	 *
	 * @param timeSeries time series of agent states
	 */
	public void addObservations(int timeSeries[]) {
		int timeSteps = timeSeries.length;
		// increment the count of observations:
		// (we miss out on k observations at the start and k-1 at the end)
		if (timeSteps - k - (k-1) <= 0) {
			// Nothing to do
			return;
		}
		observations += (timeSteps - k - (k-1));

		// Initialise and store the current previous value
		//  and next values (next val set for t = k-1)
		int prevVal = 0;
		int nextVal = 0;
		for (int p = 0; p < k; p++) {
			prevVal *= numDiscreteValues;
			prevVal += timeSeries[p];
			nextVal *= numDiscreteValues;
			nextVal += timeSeries[k-1+p];
		}

		// 1. Count the tuples observed
		for (int t = k; t < timeSteps - (k-1); t++) {
			// Update the next value:
			nextVal -= maxShiftedValue[timeSeries[t-1]];
			nextVal *= numDiscreteValues;
			nextVal += timeSeries[k-1+t];
			// Update the counts
			jointCount[nextVal][prevVal]++;
			prevCount[prevVal]++;
			nextCount[nextVal]++;
			// Update the previous value:
			prevVal -= maxShiftedValue[timeSeries[t-k]];
			prevVal *= numDiscreteValues;
			prevVal += timeSeries[t];
		}
	}

	/**
 	 * Add observations in to our estimates of the pdfs.
 	 * This call suitable only for homogeneous agents, as all
 	 *  agents will contribute to single pdfs.
	 *
	 * @param states 1st index is time, 2nd index is agent number
	 */
	public void addObservations(int states[][]) {
		int rows = states.length;
		int columns = states[0].length;
		// (we miss out on k observations at the start and k-1 at the end)
		if (rows - k - (k-1) <= 0) {
			// Nothing to do
			return;
		}
		observations += (rows - k - (k-1))*columns;

		// Initialise and store the current previous and
		//  next val (next val set for t = k-1) value for each column
		int[] prevVal = new int[columns];
		int[] nextVal = new int[columns];
		for (int c = 0; c < columns; c++) {
			prevVal[c] = 0;
			nextVal[c] = 0;
			for (int p = 0; p < k; p++) {
				prevVal[c] *= numDiscreteValues;
				prevVal[c] += states[p][c];
				nextVal[c] *= numDiscreteValues;
				nextVal[c] += states[k-1+p][c];
			}
		}

		// 1. Count the tuples observed
		for (int r = k; r < rows - (k-1); r++) {
			for (int c = 0; c < columns; c++) {
				// Update the next value:
				nextVal[c] -= maxShiftedValue[states[r-1][c]];
				nextVal[c] *= numDiscreteValues;
				nextVal[c] += states[k-1+r][c];
				// Update the counts
				jointCount[nextVal[c]][prevVal[c]]++;
				prevCount[prevVal[c]]++;
				nextCount[nextVal[c]]++;
				// Update the previous value:
				prevVal[c] -= maxShiftedValue[states[r-k][c]];
				prevVal[c] *= numDiscreteValues;
				prevVal[c] += states[r][c];
			}
		}
	}

	/**
 	 * Add observations in to our estimates of the pdfs.
 	 * This call suitable only for homogeneous agents, as all
 	 *  agents will contribute to single pdfs.
	 *
	 * @param states 1st index is time, 2nd and 3rd index give the 2D agent number
	 */
	public void addObservations(int states[][][]) {
		int timeSteps = states.length;
		// (we miss out on k observations at the start and k-1 at the end)
		if (timeSteps - k - (k-1) <= 0) {
			// Nothing to do
			return;
		}
		int agentRows = states[0].length;
		if (agentRows == 0) {
			return;
		}
		int agentColumns = states[0][0].length;
		// increment the count of observations:
		observations += (timeSteps - k - (k-1)) * agentRows * agentColumns;

		// Initialise and store the current previous and
		// next (next val set for t = k-1) value for each column
		int[][] prevVal = new int[agentRows][agentColumns];
		int[][] nextVal = new int[agentRows][agentColumns];
		for (int r = 0; r < agentRows; r++) {
			for (int c = 0; c < agentColumns; c++) {
				prevVal[r][c] = 0;
				nextVal[r][c] = 0;
				for (int p = 0; p < k; p++) {
					prevVal[r][c] *= numDiscreteValues;
					prevVal[r][c] += states[p][r][c];
					nextVal[r][c] *= numDiscreteValues;
					nextVal[r][c] += states[k-1+p][r][c];
				}
			}
		}

		// 1. Count the tuples observed
		for (int t = k; t < timeSteps - (k-1); t++) {
			for (int r = 0; r < agentRows; r++) {
				for (int c = 0; c < agentColumns; c++) {
					// Update the next value:
					nextVal[r][c] -= maxShiftedValue[states[t-1][r][c]];
					nextVal[r][c] *= numDiscreteValues;
					nextVal[r][c] += states[k-1+t][r][c];
					// Update the counts
					jointCount[nextVal[r][c]][prevVal[r][c]]++;
					prevCount[prevVal[r][c]]++;
					nextCount[nextVal[r][c]]++;
					// Update the previous value:
					prevVal[r][c] -= maxShiftedValue[states[t-k][r][c]];
					prevVal[r][c] *= numDiscreteValues;
					prevVal[r][c] += states[t][r][c];
				}
			}
		}
	}

	/**
 	 * Add observations for a single agent of the multi-agent system
 	 *  to our estimates of the pdfs.
 	 * This call should be made as opposed to addObservations(int states[][])
 	 *  for computing active info for heterogeneous agents.
	 *
	 * @param states 1st index is time, 2nd index is agent number
	 */
	public void addObservations(int states[][], int col) {
		int rows = states.length;
		// (we miss out on k observations at the start and k-1 at the end)
		if (rows - k - (k-1) <= 0) {
			// Nothing to do
			return;
		}
		observations += (rows - k - (k-1));

		// Initialise and store the current previous and
		//  next value (next val set for t = k-1) for each column
		int prevVal = 0;
		int nextVal = 0;
		for (int p = 0; p < k; p++) {
			prevVal *= numDiscreteValues;
			prevVal += states[p][col];
			nextVal *= numDiscreteValues;
			nextVal += states[k-1+p][col];
		}

		// 1. Count the tuples observed
		for (int r = k; r < rows - (k-1); r++) {
			// Update the next value:
			nextVal -= maxShiftedValue[states[r-1][col]];
			nextVal *= numDiscreteValues;
			nextVal += states[k-1+r][col];
			// Add to the count for this particular transition:
			// (cell's assigned as above)
			jointCount[nextVal][prevVal]++;
			prevCount[prevVal]++;
			nextCount[nextVal]++;
			// Update the previous value:
			prevVal -= maxShiftedValue[states[r-k][col]];
			prevVal *= numDiscreteValues;
			prevVal += states[r][col];
		}
	}

	/**
 	 * Add observations for a single agent of the multi-agent system
 	 *  to our estimates of the pdfs.
 	 * This call should be made as opposed to addObservations(int states[][])
 	 *  for computing active info for heterogeneous agents.
	 *
	 * @param states 1st index is time, 2nd and 3rd index give the 2D agent number
	 */
	public void addObservations(int states[][][], int agentIndex1, int agentIndex2) {
		int timeSteps = states.length;
		// (we miss out on k observations at the start and k-1 at the end)
		if (timeSteps - k - (k-1) <= 0) {
			// Nothing to do
			return;
		}
		// increment the count of observations:
		observations += (timeSteps - k - (k-1));

		// Initialise and store the current previous and
		//  next value (next val set for t = k-1) for each column
		int prevVal = 0;
		int nextVal = 0;
		for (int p = 0; p < k; p++) {
			prevVal *= numDiscreteValues;
			prevVal += states[p][agentIndex1][agentIndex2];
			nextVal *= numDiscreteValues;
			nextVal += states[k-1+p][agentIndex1][agentIndex2];
		}

		// 1. Count the tuples observed
		for (int t = k; t < timeSteps - (k-1); t++) {
			// Update the next value:
			nextVal -= maxShiftedValue[states[t-1][agentIndex1][agentIndex2]];
			nextVal *= numDiscreteValues;
			nextVal += states[k-1+t][agentIndex1][agentIndex2];
			// Add to the count for this particular transition:
			// (cell's assigned as above)
			jointCount[nextVal][prevVal]++;
			prevCount[prevVal]++;
			nextCount[nextVal]++;
			// Update the previous value:
			prevVal -= maxShiftedValue[states[t-k][agentIndex1][agentIndex2]];
			prevVal *= numDiscreteValues;
			prevVal += states[t][agentIndex1][agentIndex2];
		}
	}

	/**
	 * Returns the average predictive information from
	 *  the observed values which have been passed in previously.
	 *
	 * @return
	 */
	public double computeAverageLocalOfObservations() {
		double mi = 0.0;
		double miCont = 0.0;

		max = 0;
		min = 0;
		for (int nextVal = 0; nextVal < base_power_k; nextVal++) {
			// compute p_next
			double p_next = (double) nextCount[nextVal] / (double) observations;
			for (int prevVal = 0; prevVal < base_power_k; prevVal++) {
				// compute p_prev
				double p_prev = (double) prevCount[prevVal] / (double) observations;
				// compute p(prev, next)
				double p_joint = (double) jointCount[nextVal][prevVal] / (double) observations;
				// Compute MI contribution:
				if (p_joint > 0.0) {
					double logTerm = p_joint / (p_next * p_prev);
					double localValue = Math.log(logTerm) / log_base;
					miCont = p_joint * localValue;
					if (localValue > max) {
						max = localValue;
					} else if (localValue < min) {
						min = localValue;
					}
				} else {
					miCont = 0.0;
				}
				mi += miCont;
			}
		}

		average = mi;
		return mi;
	}

	/**
	 * Computes local predictive info for the given values
	 *
	 * @param next joint state of future (see code for {@link #addObservations(int[])}
	 *   for how the joint integer value is computed)
	 * @param past joint state of past (see code for {@link #addObservations(int[])}
	 *   for how the joint integer value is computed)
	 * @return
	 */
	public double computeLocalFromPreviousObservations(int next, int past){
		double logTerm = ( (double) jointCount[next][past] ) /
		  ( (double) nextCount[next] *
			(double) prevCount[past] );
		logTerm *= (double) observations;
		return Math.log(logTerm) / log_base;
	}

	/**
	 * Computes local predictive information for the given
	 *  states, using pdfs built up from observations previously
	 *  sent in via the addObservations method
	 *
	 * @param timeSeries time series of values
	 * @return array of local predictive information values
	 */
	public double[] computeLocalFromPreviousObservations(int timeSeries[]){
		int timeSteps = timeSeries.length;

		// Allocate for all rows even though we'll leave the first ones as zeros
		double[] localPredictive = new double[timeSteps];
		if (timeSteps < k + (k-1)) {
			// Nothing to do
			return localPredictive;
		}

		average = 0;
		max = 0;
		min = 0;

		// Initialise and store the current previous and
		//  next value (next val set for t = k-1)
		int prevVal = 0;
		int nextVal = 0;
		for (int p = 0; p < k; p++) {
			prevVal *= numDiscreteValues;
			prevVal += timeSeries[p];
			nextVal *= numDiscreteValues;
			nextVal += timeSeries[k-1+p];
		}

		double logTerm = 0.0;
		for (int t = k; t < timeSteps - (k-1); t++) {
			// Update the next value:
			nextVal -= maxShiftedValue[timeSeries[t-1]];
			nextVal *= numDiscreteValues;
			nextVal += timeSeries[k-1+t];
			logTerm = ( (double) jointCount[nextVal][prevVal] ) /
			  		  ( (double) nextCount[nextVal] *
			  			(double) prevCount[prevVal] );
			// Now account for the fact that we've
			//  just used counts rather than probabilities,
			//  and we've got two counts on the bottom
			//  but one count on the top:
			logTerm *= (double) observations;
			localPredictive[t] = Math.log(logTerm) / log_base;
			average += localPredictive[t];
			if (localPredictive[t] > max) {
				max = localPredictive[t];
			} else if (localPredictive[t] < min) {
				min = localPredictive[t];
			}
			// Update the previous value:
			prevVal -= maxShiftedValue[timeSeries[t-k]];
			prevVal *= numDiscreteValues;
			prevVal += timeSeries[t];
		}
		average = average/(double) (timeSteps - k - (k-1));

		return localPredictive;

	}

	/**
	 * Computes local predictive information for the given
	 *  states, using pdfs built up from observations previously
	 *  sent in via the addObservations method.
	 * This method to be used for homogeneous agents only, since
	 *  all observations are pooled together.
	 *
	 * @param timeSeries 1st index is time, 2nd index is agent number
	 * @return
	 */
	public double[][] computeLocalFromPreviousObservations(int timeSeries[][]){
		int rows = timeSeries.length;
		int columns = timeSeries[0].length;

		// Allocate for all rows even though we'll leave the first ones as zeros
		double[][] localPredictive = new double[rows][columns];
		if (rows < k + (k-1)) {
			// Nothing to do
			return localPredictive;
		}

		average = 0;
		max = 0;
		min = 0;

		// Initialise and store the current previous and
		//  next value (next val set for t = k-1) for each column
		int[] prevVal = new int[columns];
		int[] nextVal = new int[columns];
		for (int c = 0; c < columns; c++) {
			prevVal[c] = 0;
			nextVal[c] = 0;
			for (int p = 0; p < k; p++) {
				prevVal[c] *= numDiscreteValues;
				prevVal[c] += timeSeries[p][c];
				nextVal[c] *= numDiscreteValues;
				nextVal[c] += timeSeries[k-1+p][c];
			}
		}
		double logTerm = 0.0;
		for (int r = k; r < rows - (k-1); r++) {
			for (int c = 0; c < columns; c++) {
				// Update the next value:
				nextVal[c] -= maxShiftedValue[timeSeries[r-1][c]];
				nextVal[c] *= numDiscreteValues;
				nextVal[c] += timeSeries[k-1+r][c];
				logTerm = ( (double) jointCount[nextVal[c]][prevVal[c]] ) /
				  		  ( (double) nextCount[nextVal[c]] *
				  			(double) prevCount[prevVal[c]] );
				// Now account for the fact that we've
				//  just used counts rather than probabilities,
				//  and we've got two counts on the bottom
				//  but one count on the top:
				logTerm *= (double) observations;
				localPredictive[r][c] = Math.log(logTerm) / log_base;
				average += localPredictive[r][c];
				if (localPredictive[r][c] > max) {
					max = localPredictive[r][c];
				} else if (localPredictive[r][c] < min) {
					min = localPredictive[r][c];
				}
				// Update the previous value:
				prevVal[c] -= maxShiftedValue[timeSeries[r-k][c]];
				prevVal[c] *= numDiscreteValues;
				prevVal[c] += timeSeries[r][c];
			}
		}
		average = average/(double) (columns * (rows - k - (k-1)));

		return localPredictive;

	}

	/**
	 * Computes local active information storage for the given
	 *  states, using pdfs built up from observations previously
	 *  sent in via the addObservations method.
	 * This method to be used for homogeneous agents only, since
	 *  all observations are pooled together.
	 *
	 * @param timeSeries 1st index is time, 2nd and 3rd index give the 2D agent number
	 * @return
	 */
	public double[][][] computeLocalFromPreviousObservations(int timeSeries[][][]){
		int timeSteps = timeSeries.length;
		int agentRows = timeSeries[0].length;
		int agentColumns = timeSeries[0][0].length;

		// Allocate for all rows even though we'll leave the first and
		// last ones as zeros
		double[][][] localPredictive = new double[timeSteps][agentRows][agentColumns];
		if (timeSteps < k + (k-1)) {
			// Nothing to do
			return localPredictive;
		}
		average = 0;
		max = 0;
		min = 0;

		// Initialise and store the current previous and
		//  next value (next val set for t = k-1) for each agent
		int[][] prevVal = new int[agentRows][agentColumns];
		int[][] nextVal = new int[agentRows][agentColumns];
		for (int r = 0; r < agentRows; r++) {
			for (int c = 0; c < agentColumns; c++) {
				prevVal[r][c] = 0;
				nextVal[r][c] = 0;
				for (int p = 0; p < k; p++) {
					prevVal[r][c] *= numDiscreteValues;
					prevVal[r][c] += timeSeries[p][r][c];
					nextVal[r][c] *= numDiscreteValues;
					nextVal[r][c] += timeSeries[k-1+p][r][c];
				}
			}
		}
		double logTerm = 0.0;
		for (int t = k; t < timeSteps - (k-1); t++) {
			for (int r = 0; r < agentRows; r++) {
				for (int c = 0; c < agentColumns; c++) {
					// Update the next value:
					nextVal[r][c] -= maxShiftedValue[timeSeries[t-1][r][c]];
					nextVal[r][c] *= numDiscreteValues;
					nextVal[r][c] += timeSeries[k-1+t][r][c];
					logTerm = ( (double) jointCount[nextVal[r][c]][prevVal[r][c]] ) /
					  		  ( (double) nextCount[nextVal[r][c]] *
					  			(double) prevCount[prevVal[r][c]] );
					// Now account for the fact that we've
					//  just used counts rather than probabilities,
					//  and we've got two counts on the bottom
					//  but one count on the top:
					logTerm *= (double) observations;
					localPredictive[t][r][c] = Math.log(logTerm) / log_base;
					average += localPredictive[t][r][c];
					if (localPredictive[t][r][c] > max) {
						max = localPredictive[t][r][c];
					} else if (localPredictive[t][r][c] < min) {
						min = localPredictive[t][r][c];
					}
					// Update the previous value:
					prevVal[r][c] -= maxShiftedValue[timeSeries[t-k][r][c]];
					prevVal[r][c] *= numDiscreteValues;
					prevVal[r][c] += timeSeries[t][r][c];
				}
			}
		}
		average = average/(double) (agentRows * agentColumns * (timeSteps - k - (k-1)));

		return localPredictive;
	}

	/**
	 * Computes local predictive information for the given
	 *  states, using pdfs built up from observations previously
	 *  sent in via the addObservations method.
	 * This method is suitable for heterogeneous agents since the
	 *  user specifies which agent to take the observations from.
	 *
	 * @param states 1st index is time, 2nd index is agent number
	 * @param col gives the column index identifying the agent
	 * @return
	 */
	public double[] computeLocalFromPreviousObservations(int states[][], int col){
		int rows = states.length;
		//int columns = states[0].length;

		// Allocate for all rows even though we'll leave the first ones as zeros
		double[] localPredictive = new double[rows];
		if (rows < k + (k-1)) {
			// Nothing to do
			return localPredictive;
		}
		average = 0;
		max = 0;
		min = 0;

		// Initialise and store the current previous and
		//  next value (next val set for t = k-1) for each column
		int prevVal = 0;
		int nextVal = 0;
		for (int p = 0; p < k; p++) {
			prevVal *= numDiscreteValues;
			prevVal += states[p][col];
			nextVal *= numDiscreteValues;
			nextVal += states[k-1+p][col];
		}
		double logTerm = 0.0;
		for (int r = k; r < rows - (k-1); r++) {
			// Update the next value:
			nextVal -= maxShiftedValue[states[r-1][col]];
			nextVal *= numDiscreteValues;
			nextVal += states[k-1+r][col];
			logTerm = ( (double) jointCount[nextVal][prevVal] ) /
			  		  ( (double) nextCount[nextVal] *
			  			(double) prevCount[prevVal] );
			// Now account for the fact that we've
			//  just used counts rather than probabilities,
			//  and we've got two counts on the bottom
			//  but one count on the top:
			logTerm *= (double) observations;
			localPredictive[r] = Math.log(logTerm) / log_base;
			average += localPredictive[r];
			if (localPredictive[r] > max) {
				max = localPredictive[r];
			} else if (localPredictive[r] < min) {
				min = localPredictive[r];
			}
			// Update the previous value:
			prevVal -= maxShiftedValue[states[r-k][col]];
			prevVal *= numDiscreteValues;
			prevVal += states[r][col];
		}
		average = average/(double) (rows - k - (k-1));

		return localPredictive;

	}

	/**
	 * Computes local predictive information for the given
	 *  states, using pdfs built up from observations previously
	 *  sent in via the addObservations method.
	 * This method is suitable for heterogeneous agents, since the
	 *  relevant agent is identified
	 *
	 * @param timeSeries 1st index is time, 2nd and 3rd index give the 2D agent number
	 * @param agentIndex1 gives the first index identifying the agent
	 * @param agentIndex2 gives the second index identifying the agent
	 * @return
	 */
	public double[] computeLocalFromPreviousObservations(int timeSeries[][][], int agentIndex1, int agentIndex2){
		int timeSteps = timeSeries.length;
		//int columns = states[0].length;

		// Allocate for all rows even though we'll leave the first ones as zeros
		double[] localPredictive = new double[timeSteps];
		if (timeSteps < k + (k-1)) {
			// Nothing to do
			return localPredictive;
		}
		average = 0;
		max = 0;
		min = 0;

		// Initialise and store the current previous and
		//  next value (next val set for t = k-1) for each column
		int prevVal = 0;
		int nextVal = 0;
		for (int p = 0; p < k; p++) {
			prevVal *= numDiscreteValues;
			prevVal += timeSeries[p][agentIndex1][agentIndex2];
			nextVal *= numDiscreteValues;
			nextVal += timeSeries[k-1+p][agentIndex1][agentIndex2];
		}
		double logTerm = 0.0;
		for (int t = k; t < timeSteps - (k-1); t++) {
			// Update the next value:
			nextVal -= maxShiftedValue[timeSeries[t-1][agentIndex1][agentIndex2]];
			nextVal *= numDiscreteValues;
			nextVal += timeSeries[k-1+t][agentIndex1][agentIndex2];
			logTerm = ( (double) jointCount[nextVal][prevVal] ) /
			  		  ( (double) nextCount[nextVal] *
			  			(double) prevCount[prevVal] );
			// Now account for the fact that we've
			//  just used counts rather than probabilities,
			//  and we've got two counts on the bottom
			//  but one count on the top:
			logTerm *= (double) observations;
			localPredictive[t] = Math.log(logTerm) / log_base;
			average += localPredictive[t];
			if (localPredictive[t] > max) {
				max = localPredictive[t];
			} else if (localPredictive[t] < min) {
				min = localPredictive[t];
			}
			// Update the previous value:
			prevVal -= maxShiftedValue[timeSeries[t-k][agentIndex1][agentIndex2]];
			prevVal *= numDiscreteValues;
			prevVal += timeSeries[t][agentIndex1][agentIndex2];
		}
		average = average/(double) (timeSteps - k - (k-1));

		return localPredictive;

	}

	/**
	 * Standalone routine to
	 * compute local predictive information from a time series.
	 * Return an array of local values.
	 * First k and last k-1 rows are zeros.
	 *
	 * @param timeSeries time series array of states
	 * @return time series of local predictive information values
	 */
	public double[] computeLocal(int timeSeries[]) {

		initialise();
		addObservations(timeSeries);
		return computeLocalFromPreviousObservations(timeSeries);
	}

	/**
	 * Standalone routine to
	 * compute local predictive information across a 2D spatiotemporal
	 *  time series of the observations of homogeneous agents.
	 * This method to be called for homogeneous agents only, as all
	 *  observations are pooled together.
	 * First k and last k-1 rows are zeros.
	 *
	 * @param timeSeries 2D array of states (first index is time, second is variable id)
	 * @return multivariate time series of local predictive information values
	 *  (1st index is time, second is variable id)
	 */
	public double[][] computeLocal(int timeSeries[][]) {

		initialise();
		addObservations(timeSeries);
		return computeLocalFromPreviousObservations(timeSeries);
	}

	/**
	 * Standalone routine to
	 * compute local predictive information across a 3D spatiotemporal
	 *  array of the states of homogeneous agents
	 * This method to be called for homogeneous agents only, as all
	 *  observations are pooled together.
	 * First k and last k-1 rows are zeros.
	 *
	 * @param timeSeries 2D array of states (first index is time, second
	 *  and third are variable ids)
	 * @return multivariate time series of local predictive information values
	 *  (1st index is time, second and third are variable ids)
	 */
	public double[][][] computeLocal(int timeSeries[][][]) {

		initialise();
		addObservations(timeSeries);
		return computeLocalFromPreviousObservations(timeSeries);
	}

	/**
	 * Standalone routine to
	 * compute average predictive information across a
	 *  time series.
	 *
	 * @param timeSeries time series array of states
	 * @return average predictive information values
	 */
	public double computeAverageLocal(int timeSeries[]) {

		initialise();
		addObservations(timeSeries);
		return computeAverageLocalOfObservations();
	}

	/**
	 * Standalone routine to
	 * compute average predictive information across a 2D spatiotemporal
	 *  array of the states of homogeneous agents.
	 * This method to be called for homogeneous agents only, as all
	 *  observations are pooled together.
	 *
	 * @param timeSeries 2D array of states (first index is time, second is variable id)
	 * @return average predictive information value
	 */
	public double computeAverageLocal(int timeSeries[][]) {

		initialise();
		addObservations(timeSeries);
		return computeAverageLocalOfObservations();
	}

	/**
	 * Standalone routine to
	 * compute average predictive information across a 3D spatiotemporal
	 *  array of the states of homogeneous agents
	 * This method to be called for homogeneous agents only, as all
	 *  observations are pooled together.
	 *
	 * @param timeSeries 2D array of states (first index is time, second
	 *  and third are variable ids)
	 * @return average predictive information value
	 */
	public double computeAverageLocal(int timeSeries[][][]) {

		initialise();
		addObservations(timeSeries);
		return computeAverageLocalOfObservations();
	}

	/**
	 * Standalone routine to
	 * compute local predictive information for one agent in a 2D spatiotemporal
	 *  array of the states of agents
	 * First k and last k-1 rows are zeros.
	 *
	 * This method should be used for heterogeneous agents.
	 *
	 * @param timeSeries 2D array of states (first index is time, second is variable id)
	 * @param col index of the agent whose local values should be calculated
	 * @return time series of local predictive information values for the given agent id
	 */
	public double[] computeLocal(int timeSeries[][], int col) {

		initialise();
		addObservations(timeSeries, col);
		return computeLocalFromPreviousObservations(timeSeries, col);
	}

	/**
	 * Standalone routine to
	 * compute local predictive information for one agent in a 3D spatiotemporal
	 *  array of the states of agents
	 * First k and last k-1 rows are zeros.
	 * This method should be used for heterogeneous agents.
	 *
	 * @param timeSeries 3D array of states (first index is time, second
	 *  and third are variable id)
	 * @param agentIndex1 row index of agent
	 * @param agentIndex2 column index of agent
	 * @return time series of local predictive information values for the given agent id
	 */
	public double[] computeLocal(int timeSeries[][][], int agentIndex1, int agentIndex2) {

		initialise();
		addObservations(timeSeries, agentIndex1, agentIndex2);
		return computeLocalFromPreviousObservations(timeSeries, agentIndex1, agentIndex2);
	}

	/**
	 * Standalone routine to
	 * compute average local predictive information
	 * for a single agent in a 2D spatiotemporal time series.
	 * This method suitable for heterogeneous agents, since the agent
	 *  to be investigated is named.
	 *
	 * @param timeSeries 2D array of states (first index is time, second is variable id)
	 * @param col index of the agent whose local values should be calculated
	 * @return average predictive info for the given agent id
	 */
	public double computeAverageLocal(int timeSeries[][], int col) {

		initialise();
		addObservations(timeSeries, col);
		return computeAverageLocalOfObservations();
	}

	/**
	 * Standalone routine to
	 * compute average local active information storage
	 * for a single agent in a 3D spatiotemporal time series.
	 * This method suitable for heterogeneous agents, since the agent
	 *  to be investigated is named.
	 *
	 * @param timeSeries 3D array of states (first index is time, second
	 *  and third are variable id)
	 * @param agentIndex1 row index of agent
	 * @param agentIndex2 column index of agent
	 * @return average predictive info for the given agent id
	 */
	public double computeAverageLocal(int timeSeries[][][], int agentIndex1, int agentIndex2) {

		initialise();
		addObservations(timeSeries, agentIndex1, agentIndex2);
		return computeAverageLocalOfObservations();
	}

	/**
	 *
	 * @return the last predictive information computed since the
	 *  previous {@link #initialise()} call.
	 */
	public double getLastAverage() {
		return average;
	}

	/**
	 *
	 * @return the last maximum local predictive information computed since the
	 *  previous {@link #initialise()} call.
	 */
	public double getLastMax() {
		return max;
	}

	/**
	 *
	 * @return the last minimum local predictive information computed since the
	 *  previous {@link #initialise()} call.
	 */
	public double getLastMin() {
		return min;
	}

	/**
	 * Writes the current probability distribution functions
	 *
	 * @return
	 */
	public void writePdfs() {
		double mi = 0.0;
		double miCont = 0.0;

		System.out.println("nextVal p(next) prevVal p(prev) p(joint) logTerm localVal");
		for (int nextVal = 0; nextVal < base_power_k; nextVal++) {
			// compute p_next
			double p_next = (double) nextCount[nextVal] / (double) observations;
			for (int prevVal = 0; prevVal < base_power_k; prevVal++) {
				// compute p_prev
				double p_prev = (double) prevCount[prevVal] / (double) observations;
				// compute p(prev, next)
				double p_joint = (double) jointCount[nextVal][prevVal] / (double) observations;
				// Compute MI contribution:
				if (p_joint > 0.0) {
					double logTerm = p_joint / (p_next * p_prev);
					double localValue = Math.log(logTerm) / log_base;
					miCont = p_joint * localValue;
					System.out.println(String.format("%7d    %.2f %7d    %.2f     %.2f    %.2f     %.2f",
							nextVal, p_next, prevVal, p_prev, p_joint, logTerm, localValue));
				} else {
					miCont = 0.0;
					System.out.println(String.format("%7d    %.2f %7d    %.2f     %.2f    %.2f     %.2f",
							nextVal, p_next, prevVal, p_prev, p_joint, 0.0, 0.0));
				}
				mi += miCont;
			}
		}
		System.out.println("Average is " + mi);

		return;
	}

	/**
	 * Utility function to compute the combined past values of x up to and including time step t
	 *  (i.e. (x_{t-k+1}, ... ,x_{t-1},x_{t}))
	 *
	 * @param x time series
	 * @param t time step to compute joint past value up to
	 * @return joint discrete value computed from the (x_{t-k+1}, ... ,x_{t-1},x_{t})
	 */
	public int computePastValue(int[] x, int t) {
		int pastVal = 0;
		for (int p = 0; p < k; p++) {
			pastVal *= numDiscreteValues;
			pastVal += x[t - k + 1 + p];
		}
		return pastVal;
	}

	/**
	 * Utility function to compute the combined past values of x up to
	 * and including time step t for a given variable number within x
	 *  (i.e. (x_{t-k+1,i}, ... ,x_{t-1,i},x_{t,i}))
	 *
	 * @param x 2D multivariate time series
	 * @param i column or agent number within x.
	 * @param t time step to compute joint past value up to
	 * @return joint discrete value computed from the (x_{t-k+1,i}, ... ,x_{t-1,i},x_{t,i}))
	 */
	public int computePastValue(int[][] x, int i, int t) {
		int pastVal = 0;
		for (int p = 0; p < k; p++) {
			pastVal *= numDiscreteValues;
			pastVal += x[t - k + 1 + p][i];
		}
		return pastVal;
	}

	/**
	 * Utility function to compute the combined past values of x up to
	 * and including time step t for a given variable number within x
	 *  (i.e. (x_{t-k+1,i,j}, ... ,x_{t-1,i,j},x_{t,i,j}))
	 *
	 * @param x 3D multivariate time series
	 * @param i 1st index to identify agent within x.
	 * @param i 2nd index to identify agent within x.
	 * @param t time step to compute joint past value up to
	 * @return joint discrete value computed from the (x_{t-k+1,i}, ... ,x_{t-1,i},x_{t,i}))
	 */
	public int computePastValue(int[][][] x, int i, int j, int t) {
		int pastVal = 0;
		for (int p = 0; p < k; p++) {
			pastVal *= numDiscreteValues;
			pastVal += x[t - k + 1 + p][i][j];
		}
		return pastVal;
	}
}


text:
package com.amazonaws.services.lightsail.model.transform;

import java.util.List;
import javax.annotation.Generated;

import com.amazonaws.SdkClientException;
import com.amazonaws.services.lightsail.model.*;

import com.amazonaws.protocol.*;
import com.amazonaws.annotation.SdkInternalApi;

/**
 * PortInfoMarshaller
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
@SdkInternalApi
public class PortInfoMarshaller {

    private static final MarshallingInfo<Integer> FROMPORT_BINDING = MarshallingInfo.builder(MarshallingType.INTEGER)
            .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("fromPort").build();
    private static final MarshallingInfo<Integer> TOPORT_BINDING = MarshallingInfo.builder(MarshallingType.INTEGER).marshallLocation(MarshallLocation.PAYLOAD)
            .marshallLocationName("toPort").build();
    private static final MarshallingInfo<String> PROTOCOL_BINDING = MarshallingInfo.builder(MarshallingType.STRING).marshallLocation(MarshallLocation.PAYLOAD)
            .marshallLocationName("protocol").build();
    private static final MarshallingInfo<List> CIDRS_BINDING = MarshallingInfo.builder(MarshallingType.LIST).marshallLocation(MarshallLocation.PAYLOAD)
            .marshallLocationName("cidrs").build();
    private static final MarshallingInfo<List> IPV6CIDRS_BINDING = MarshallingInfo.builder(MarshallingType.LIST).marshallLocation(MarshallLocation.PAYLOAD)
            .marshallLocationName("ipv6Cidrs").build();
    private static final MarshallingInfo<List> CIDRLISTALIASES_BINDING = MarshallingInfo.builder(MarshallingType.LIST)
            .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("cidrListAliases").build();

    private static final PortInfoMarshaller instance = new PortInfoMarshaller();

    public static PortInfoMarshaller getInstance() {
        return instance;
    }

    /**
     * Marshall the given parameter object.
     */
    public void marshall(PortInfo portInfo, ProtocolMarshaller protocolMarshaller) {

        if (portInfo == null) {
            throw new SdkClientException("Invalid argument passed to marshall(...)");
        }

        try {
            protocolMarshaller.marshall(portInfo.getFromPort(), FROMPORT_BINDING);
            protocolMarshaller.marshall(portInfo.getToPort(), TOPORT_BINDING);
            protocolMarshaller.marshall(portInfo.getProtocol(), PROTOCOL_BINDING);
            protocolMarshaller.marshall(portInfo.getCidrs(), CIDRS_BINDING);
            protocolMarshaller.marshall(portInfo.getIpv6Cidrs(), IPV6CIDRS_BINDING);
            protocolMarshaller.marshall(portInfo.getCidrListAliases(), CIDRLISTALIASES_BINDING);
        } catch (Exception e) {
            throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
        }
    }

}


text:
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateObjectivesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('objectives', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->foreign('user_id')->references('id')->on('users');
            $table->integer('unit_id')->unsigned();
            $table->foreign('unit_id')->references('id')->on('units');
            $table->string('name');
            $table->string('slug')->nullable();
            $table->text('description');
            $table->string('comment');
            $table->string('status')->comment="in-progress, completed or archieved";
            $table->integer('parent_id')->nullable();
            $table->integer('modified_by')->nullable();
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('objectives');
    }
}


text:
#include "precomp.hpp"
#include <kode.h>
#include "XMOpenCV2/videostab/log.hpp"

using namespace std;

namespace cv
{
namespace videostab
{

void LogToStdout::print(const char *format, ...)
{
	KDVaListKHR args;
    KD_VA_START_KHR(args, format);
    kdVlogMessagefKHR(format, args);
    KD_VA_END_KHR(args);
}

} // namespace videostab
} // namespace cv


text:
'use strict'

angular.module('lmisChromeApp')
  .service('batchService', function (storageService, $q) {
    this.save = function (batch) {
      return storageService.save(storageService.BATCHES, batch)
    }

    this.saveBatches = function (batches) {
      var promises = []
      batches.forEach(function (b) {
        promises.push(storageService.save(storageService.BATCHES, b))
      })
      return $q.all(promises)
    }

    this.get = function (uuid) {
      return storageService.find(storageService.BATCHES, uuid)
    }

    this.getAll = function () {
      return storageService.all(storageService.BATCHES)
    }

    this.getByBatchNo = function (batchNo) {
      return this.getAll()
        .then(function (res) {
          var batches = res.filter(function (b) {
            return b.batchNo === batchNo
          })
          if (batches.length > 0) {
            return batches[0]
          } else {
            return $q.reject('batch no does not exist.')
          }
        })
    }

    this.getBatchNos = function () {
      var batchNos = {}
      return this.getAll()
        .then(function (batches) {
          batches.forEach(function (b) {
            batchNos[b.batchNo] = b
          })
          return batchNos
        })
    }

    this.extractBatch = function (bundleLines) {
      var batches = []
      var bl
      var batch
      for (var i in bundleLines) {
        bl = bundleLines[i]
        batch = {
          batchNo: bl.batchNo,
          expiryDate: bl.expiryDate,
          profile: bl.productProfile
        }
        batches.push(batch)
      }
      return batches
    }
  })


text:
using HomeCinema.Entities;
using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HomeCinema.Data.Configurations
{
    public class UserConfiguration : EntityBaseConfiguration<User>
    {
        public UserConfiguration()
        {
            Property(u => u.Username).IsRequired().HasMaxLength(100);
            Property(u => u.Email).IsRequired().HasMaxLength(200);
            Property(u => u.HashedPassword).IsRequired().HasMaxLength(200);
            Property(u => u.Salt).IsRequired().HasMaxLength(200);
            Property(u => u.IsLocked).IsRequired();
            Property(u => u.DateCreated);
        }
    }
}


text:
@interface YSDemoViewController ()

@end

@implementation YSDemoViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor colorWithRed:arc4random_uniform(256)/255.0
                                                green:arc4random_uniform(256)/255.0
                                                 blue:arc4random_uniform(256)/255.0
                                                alpha:1.0];
}

@end


text:
module Buginabox
  module CommentsHelper
  end
end


text:
module Fog
  module HP
    class DNS

      class Real
        # Update an existing DNS record
        #
        # ==== Parameters
        # * 'domain_id'<~String> - UUId of domain of record
        # * 'record_id'<~String> - UUId of record to update
        # * options<~Hash>:
        #   * 'name'<~String> - Name of record
        #   * 'description'<~String> - Description for the record
        #   * 'type'<~String> - Type of the record i.e. 'A'
        #   * 'data'<~String> - Data required by the record
        #   * 'priority'<~Integer> - Priority
        #   * 'ttl'<~Integer> - TTL of the record
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'id'<~String> - UUID of the record
        #     * 'name'<~String> - Name of the record
        #     * 'description'<~String> - Description for the record
        #     * 'type'<~String> - Type of the record
        #     * 'domain_id'<~String> - UUID of the domain
        #     * 'ttl'<~Integer> - TTL of the record
        #     * 'data'<~String> - Data required by the record
        #     * 'priority'<~Integer> - Priority for the record
        #     * 'created_at'<~String> - created date time stamp
        #     * 'updated_at'<~String> - updated date time stamp
        def update_record(domain_id, record_id, options={})
          data = {}
          l_options = [:name, :description, :type, :data, :priority, :ttl]
          l_options.select{|o| options[o]}.each do |key|
            data[key] = options[key]
          end

          request(
            :body    => Fog::JSON.encode(data),
            :expects => 200,
            :method  => 'PUT',
            :path    => "domains/#{domain_id}/records/#{record_id}"
          )
        end

      end

      class Mock
        def update_record(domain_id, record_id, options)
          response = Excon::Response.new
          if record = list_records_in_a_domain(domain_id).body['records'].detect { |_| _['id'] == record_id }
            record['name']      = options[:name]      if options[:name]
            record['type']      = options[:type]      if options[:type]
            record['data']      = options[:data]      if options[:data]
            record['priority']  = options[:priority]  if options[:priority]

            response.status = 200
            response.body   = record
            response
          else
            raise Fog::HP::DNS::NotFound
          end
        end

      end

    end
  end
end


text:
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;

/* @var $this yii\web\View */
/* @var $model backend\modules\inventory\models\Tankstatus */
/* @var $form yii\widgets\ActiveForm */
?>

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'tank_status_name')->textInput(['maxlength' => true]) ?>

        <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>

    <?php ActiveForm::end(); ?>


text:
using System;
using System.Collections.Generic;
using System.Web;
using KNKVPlugin.Converters;
using KNKVPlugin.Model;

namespace KNKVPlugin
{
	public partial class Request
	{
		/// <summary>
		/// Returns all poules positions for the current club (the club is determined by the service using the service code)
		/// </summary>
		/// <returns></returns>
		public ResponseResult<List<Poule>> GetPositions()
		{
			return GetPositions(null);
		}

		/// <summary>
		/// Returns poule positions for the given teams
		/// </summary>
		/// <param name="teamIds"></param>
		/// <returns></returns>
		public ResponseResult<List<Poule>> GetPositions(int[] teamIds)
		{
			var queryString = HttpUtility.ParseQueryString(String.Empty);
			queryString["t"] = "standing";
			queryString["t_id"] = (teamIds != null) ? String.Join(",", teamIds) : String.Empty;
			queryString["p"] = "0";
			queryString["full"] = "0";

			var response = Execute(queryString);
			var converter = new PositionsConverter();
			var positions = converter.Convert(response);
			return positions;
		}
	}
}


text:
<!DOCTYPE html>
<html lang="en" style="margin: 0; padding: 0; background: f0f0f0;">
<head>
	<title>sea-something | Jon Andersson</title>
</head>
<body style="margin: 0; padding: 0">
	<script src="main.js"></script>
</body>
</html>


text:
import * as browser from 'vs/base/browser/browser';
import * as DOM from 'vs/base/browser/dom';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
import { EventType, Gesture, GestureEvent } from 'vs/base/browser/touch';
import { cleanMnemonic, Direction, IMenuOptions, IMenuStyles, Menu, MENU_ESCAPED_MNEMONIC_REGEX, MENU_MNEMONIC_REGEX } from 'vs/base/browser/ui/menu/menu';
import { ActionRunner, IAction, IActionRunner, Separator, SubmenuAction } from 'vs/base/common/actions';
import { asArray } from 'vs/base/common/arrays';
import { RunOnceScheduler } from 'vs/base/common/async';
import { Codicon } from 'vs/base/common/codicons';
import { Emitter, Event } from 'vs/base/common/event';
import { KeyCode, KeyMod, ScanCode, ScanCodeUtils } from 'vs/base/common/keyCodes';
import { ResolvedKeybinding } from 'vs/base/common/keybindings';
import { Disposable, dispose, IDisposable } from 'vs/base/common/lifecycle';
import { isMacintosh } from 'vs/base/common/platform';
import * as strings from 'vs/base/common/strings';
import { withNullAsUndefined } from 'vs/base/common/types';
import 'vs/css!./menubar';
import * as nls from 'vs/nls';

const $ = DOM.$;

export interface IMenuBarOptions {
	enableMnemonics?: boolean;
	disableAltFocus?: boolean;
	visibility?: string;
	getKeybinding?: (action: IAction) => ResolvedKeybinding | undefined;
	alwaysOnMnemonics?: boolean;
	compactMode?: Direction;
	actionRunner?: IActionRunner;
	getCompactMenuActions?: () => IAction[];
}

export interface MenuBarMenu {
	actions: IAction[];
	label: string;
}

interface MenuBarMenuWithElements extends MenuBarMenu {
	titleElement?: HTMLElement;
	buttonElement?: HTMLElement;
}

enum MenubarState {
	HIDDEN,
	VISIBLE,
	FOCUSED,
	OPEN
}

export class MenuBar extends Disposable {

	static readonly OVERFLOW_INDEX: number = -1;

	private menus: MenuBarMenuWithElements[];

	private overflowMenu!: MenuBarMenuWithElements & { titleElement: HTMLElement; buttonElement: HTMLElement };

	private focusedMenu: {
		index: number;
		holder?: HTMLElement;
		widget?: Menu;
	} | undefined;

	private focusToReturn: HTMLElement | undefined;
	private menuUpdater: RunOnceScheduler;

	// Input-related
	private _mnemonicsInUse: boolean = false;
	private openedViaKeyboard: boolean = false;
	private awaitingAltRelease: boolean = false;
	private ignoreNextMouseUp: boolean = false;
	private mnemonics: Map<string, number>;

	private updatePending: boolean = false;
	private _focusState: MenubarState;
	private actionRunner: IActionRunner;

	private readonly _onVisibilityChange: Emitter<boolean>;
	private readonly _onFocusStateChange: Emitter<boolean>;

	private numMenusShown: number = 0;
	private menuStyle: IMenuStyles | undefined;
	private overflowLayoutScheduled: IDisposable | undefined = undefined;

	constructor(private container: HTMLElement, private options: IMenuBarOptions = {}) {
		super();

		this.container.setAttribute('role', 'menubar');
		if (this.isCompact) {
			this.container.classList.add('compact');
		}

		this.menus = [];
		this.mnemonics = new Map<string, number>();

		this._focusState = MenubarState.VISIBLE;

		this._onVisibilityChange = this._register(new Emitter<boolean>());
		this._onFocusStateChange = this._register(new Emitter<boolean>());

		this.createOverflowMenu();

		this.menuUpdater = this._register(new RunOnceScheduler(() => this.update(), 200));

		this.actionRunner = this.options.actionRunner ?? this._register(new ActionRunner());
		this._register(this.actionRunner.onBeforeRun(() => {
			this.setUnfocusedState();
		}));

		this._register(DOM.ModifierKeyEmitter.getInstance().event(this.onModifierKeyToggled, this));

		this._register(DOM.addDisposableListener(this.container, DOM.EventType.KEY_DOWN, (e) => {
			const event = new StandardKeyboardEvent(e as KeyboardEvent);
			let eventHandled = true;
			const key = !!e.key ? e.key.toLocaleLowerCase() : '';

			const tabNav = isMacintosh && !this.isCompact;

			if (event.equals(KeyCode.LeftArrow) || (tabNav && event.equals(KeyCode.Tab | KeyMod.Shift))) {
				this.focusPrevious();
			} else if (event.equals(KeyCode.RightArrow) || (tabNav && event.equals(KeyCode.Tab))) {
				this.focusNext();
			} else if (event.equals(KeyCode.Escape) && this.isFocused && !this.isOpen) {
				this.setUnfocusedState();
			} else if (!this.isOpen && !event.ctrlKey && this.options.enableMnemonics && this.mnemonicsInUse && this.mnemonics.has(key)) {
				const menuIndex = this.mnemonics.get(key)!;
				this.onMenuTriggered(menuIndex, false);
			} else {
				eventHandled = false;
			}

			// Never allow default tab behavior when not compact
			if (!this.isCompact && (event.equals(KeyCode.Tab | KeyMod.Shift) || event.equals(KeyCode.Tab))) {
				event.preventDefault();
			}

			if (eventHandled) {
				event.preventDefault();
				event.stopPropagation();
			}
		}));

		this._register(DOM.addDisposableListener(window, DOM.EventType.MOUSE_DOWN, () => {
			// This mouse event is outside the menubar so it counts as a focus out
			if (this.isFocused) {
				this.setUnfocusedState();
			}
		}));

		this._register(DOM.addDisposableListener(this.container, DOM.EventType.FOCUS_IN, (e) => {
			const event = e as FocusEvent;

			if (event.relatedTarget) {
				if (!this.container.contains(event.relatedTarget as HTMLElement)) {
					this.focusToReturn = event.relatedTarget as HTMLElement;
				}
			}
		}));

		this._register(DOM.addDisposableListener(this.container, DOM.EventType.FOCUS_OUT, (e) => {
			const event = e as FocusEvent;

			// We are losing focus and there is no related target, e.g. webview case
			if (!event.relatedTarget) {
				this.setUnfocusedState();
			}
			// We are losing focus and there is a target, reset focusToReturn value as not to redirect
			else if (event.relatedTarget && !this.container.contains(event.relatedTarget as HTMLElement)) {
				this.focusToReturn = undefined;
				this.setUnfocusedState();
			}
		}));

		this._register(DOM.addDisposableListener(window, DOM.EventType.KEY_DOWN, (e: KeyboardEvent) => {
			if (!this.options.enableMnemonics || !e.altKey || e.ctrlKey || e.defaultPrevented) {
				return;
			}

			const key = e.key.toLocaleLowerCase();
			if (!this.mnemonics.has(key)) {
				return;
			}

			this.mnemonicsInUse = true;
			this.updateMnemonicVisibility(true);

			const menuIndex = this.mnemonics.get(key)!;
			this.onMenuTriggered(menuIndex, false);
		}));

		this.setUnfocusedState();
	}

	push(arg: MenuBarMenu | MenuBarMenu[]): void {
		const menus: MenuBarMenu[] = asArray(arg);

		menus.forEach((menuBarMenu) => {
			const menuIndex = this.menus.length;
			const cleanMenuLabel = cleanMnemonic(menuBarMenu.label);

			const mnemonicMatches = MENU_MNEMONIC_REGEX.exec(menuBarMenu.label);

			// Register mnemonics
			if (mnemonicMatches) {
				const mnemonic = !!mnemonicMatches[1] ? mnemonicMatches[1] : mnemonicMatches[3];

				this.registerMnemonic(this.menus.length, mnemonic);
			}

			if (this.isCompact) {
				this.menus.push(menuBarMenu);
			} else {
				const buttonElement = $('div.menubar-menu-button', { 'role': 'menuitem', 'tabindex': -1, 'aria-label': cleanMenuLabel, 'aria-haspopup': true });
				const titleElement = $('div.menubar-menu-title', { 'role': 'none', 'aria-hidden': true });

				buttonElement.appendChild(titleElement);
				this.container.insertBefore(buttonElement, this.overflowMenu.buttonElement);

				this.updateLabels(titleElement, buttonElement, menuBarMenu.label);

				this._register(DOM.addDisposableListener(buttonElement, DOM.EventType.KEY_UP, (e) => {
					const event = new StandardKeyboardEvent(e as KeyboardEvent);
					let eventHandled = true;

					if ((event.equals(KeyCode.DownArrow) || event.equals(KeyCode.Enter)) && !this.isOpen) {
						this.focusedMenu = { index: menuIndex };
						this.openedViaKeyboard = true;
						this.focusState = MenubarState.OPEN;
					} else {
						eventHandled = false;
					}

					if (eventHandled) {
						event.preventDefault();
						event.stopPropagation();
					}
				}));

				this._register(Gesture.addTarget(buttonElement));
				this._register(DOM.addDisposableListener(buttonElement, EventType.Tap, (e: GestureEvent) => {
					// Ignore this touch if the menu is touched
					if (this.isOpen && this.focusedMenu && this.focusedMenu.holder && DOM.isAncestor(e.initialTarget as HTMLElement, this.focusedMenu.holder)) {
						return;
					}

					this.ignoreNextMouseUp = false;
					this.onMenuTriggered(menuIndex, true);

					e.preventDefault();
					e.stopPropagation();
				}));

				this._register(DOM.addDisposableListener(buttonElement, DOM.EventType.MOUSE_DOWN, (e: MouseEvent) => {
					// Ignore non-left-click
					const mouseEvent = new StandardMouseEvent(e);
					if (!mouseEvent.leftButton) {
						e.preventDefault();
						return;
					}

					if (!this.isOpen) {
						// Open the menu with mouse down and ignore the following mouse up event
						this.ignoreNextMouseUp = true;
						this.onMenuTriggered(menuIndex, true);
					} else {
						this.ignoreNextMouseUp = false;
					}

					e.preventDefault();
					e.stopPropagation();
				}));

				this._register(DOM.addDisposableListener(buttonElement, DOM.EventType.MOUSE_UP, (e) => {
					if (e.defaultPrevented) {
						return;
					}

					if (!this.ignoreNextMouseUp) {
						if (this.isFocused) {
							this.onMenuTriggered(menuIndex, true);
						}
					} else {
						this.ignoreNextMouseUp = false;
					}
				}));

				this._register(DOM.addDisposableListener(buttonElement, DOM.EventType.MOUSE_ENTER, () => {
					if (this.isOpen && !this.isCurrentMenu(menuIndex)) {
						buttonElement.focus();
						this.cleanupCustomMenu();
						this.showCustomMenu(menuIndex, false);
					} else if (this.isFocused && !this.isOpen) {
						this.focusedMenu = { index: menuIndex };
						buttonElement.focus();
					}
				}));

				this.menus.push({
					label: menuBarMenu.label,
					actions: menuBarMenu.actions,
					buttonElement: buttonElement,
					titleElement: titleElement
				});
			}
		});
	}

	createOverflowMenu(): void {
		const label = this.isCompact ? nls.localize('mAppMenu', 'Application Menu') : nls.localize('mMore', 'More');
		const buttonElement = $('div.menubar-menu-button', { 'role': 'menuitem', 'tabindex': this.isCompact ? 0 : -1, 'aria-label': label, 'aria-haspopup': true });
		const titleElement = $('div.menubar-menu-title.toolbar-toggle-more' + Codicon.menuBarMore.cssSelector, { 'role': 'none', 'aria-hidden': true });

		buttonElement.appendChild(titleElement);
		this.container.appendChild(buttonElement);
		buttonElement.style.visibility = 'hidden';

		this._register(DOM.addDisposableListener(buttonElement, DOM.EventType.KEY_UP, (e) => {
			const event = new StandardKeyboardEvent(e as KeyboardEvent);
			let eventHandled = true;

			const triggerKeys = [KeyCode.Enter];
			if (!this.isCompact) {
				triggerKeys.push(KeyCode.DownArrow);
			} else {
				triggerKeys.push(KeyCode.Space);

				if (this.options.compactMode === Direction.Right) {
					triggerKeys.push(KeyCode.RightArrow);
				} else if (this.options.compactMode === Direction.Left) {
					triggerKeys.push(KeyCode.LeftArrow);
				}
			}

			if ((triggerKeys.some(k => event.equals(k)) && !this.isOpen)) {
				this.focusedMenu = { index: MenuBar.OVERFLOW_INDEX };
				this.openedViaKeyboard = true;
				this.focusState = MenubarState.OPEN;
			} else {
				eventHandled = false;
			}

			if (eventHandled) {
				event.preventDefault();
				event.stopPropagation();
			}
		}));

		this._register(Gesture.addTarget(buttonElement));
		this._register(DOM.addDisposableListener(buttonElement, EventType.Tap, (e: GestureEvent) => {
			// Ignore this touch if the menu is touched
			if (this.isOpen && this.focusedMenu && this.focusedMenu.holder && DOM.isAncestor(e.initialTarget as HTMLElement, this.focusedMenu.holder)) {
				return;
			}

			this.ignoreNextMouseUp = false;
			this.onMenuTriggered(MenuBar.OVERFLOW_INDEX, true);

			e.preventDefault();
			e.stopPropagation();
		}));

		this._register(DOM.addDisposableListener(buttonElement, DOM.EventType.MOUSE_DOWN, (e) => {
			// Ignore non-left-click
			const mouseEvent = new StandardMouseEvent(e);
			if (!mouseEvent.leftButton) {
				e.preventDefault();
				return;
			}

			if (!this.isOpen) {
				// Open the menu with mouse down and ignore the following mouse up event
				this.ignoreNextMouseUp = true;
				this.onMenuTriggered(MenuBar.OVERFLOW_INDEX, true);
			} else {
				this.ignoreNextMouseUp = false;
			}

			e.preventDefault();
			e.stopPropagation();
		}));

		this._register(DOM.addDisposableListener(buttonElement, DOM.EventType.MOUSE_UP, (e) => {
			if (e.defaultPrevented) {
				return;
			}

			if (!this.ignoreNextMouseUp) {
				if (this.isFocused) {
					this.onMenuTriggered(MenuBar.OVERFLOW_INDEX, true);
				}
			} else {
				this.ignoreNextMouseUp = false;
			}
		}));

		this._register(DOM.addDisposableListener(buttonElement, DOM.EventType.MOUSE_ENTER, () => {
			if (this.isOpen && !this.isCurrentMenu(MenuBar.OVERFLOW_INDEX)) {
				this.overflowMenu.buttonElement.focus();
				this.cleanupCustomMenu();
				this.showCustomMenu(MenuBar.OVERFLOW_INDEX, false);
			} else if (this.isFocused && !this.isOpen) {
				this.focusedMenu = { index: MenuBar.OVERFLOW_INDEX };
				buttonElement.focus();
			}
		}));

		this.overflowMenu = {
			buttonElement: buttonElement,
			titleElement: titleElement,
			label: 'More',
			actions: []
		};
	}

	updateMenu(menu: MenuBarMenu): void {
		const menuToUpdate = this.menus.filter(menuBarMenu => menuBarMenu.label === menu.label);
		if (menuToUpdate && menuToUpdate.length) {
			menuToUpdate[0].actions = menu.actions;
		}
	}

	override dispose(): void {
		super.dispose();

		this.menus.forEach(menuBarMenu => {
			menuBarMenu.titleElement?.remove();
			menuBarMenu.buttonElement?.remove();
		});

		this.overflowMenu.titleElement.remove();
		this.overflowMenu.buttonElement.remove();

		dispose(this.overflowLayoutScheduled);
		this.overflowLayoutScheduled = undefined;
	}

	blur(): void {
		this.setUnfocusedState();
	}

	getWidth(): number {
		if (!this.isCompact && this.menus) {
			const left = this.menus[0].buttonElement!.getBoundingClientRect().left;
			const right = this.hasOverflow ? this.overflowMenu.buttonElement.getBoundingClientRect().right : this.menus[this.menus.length - 1].buttonElement!.getBoundingClientRect().right;
			return right - left;
		}

		return 0;
	}

	getHeight(): number {
		return this.container.clientHeight;
	}

	toggleFocus(): void {
		if (!this.isFocused && this.options.visibility !== 'hidden') {
			this.mnemonicsInUse = true;
			this.focusedMenu = { index: this.numMenusShown > 0 ? 0 : MenuBar.OVERFLOW_INDEX };
			this.focusState = MenubarState.FOCUSED;
		} else if (!this.isOpen) {
			this.setUnfocusedState();
		}
	}

	private updateOverflowAction(): void {
		if (!this.menus || !this.menus.length) {
			return;
		}

		const overflowMenuOnlyClass = 'overflow-menu-only';

		// Remove overflow only restriction to allow the most space
		this.container.classList.toggle(overflowMenuOnlyClass, false);

		const sizeAvailable = this.container.offsetWidth;
		let currentSize = 0;
		let full = this.isCompact;
		const prevNumMenusShown = this.numMenusShown;
		this.numMenusShown = 0;

		const showableMenus = this.menus.filter(menu => menu.buttonElement !== undefined && menu.titleElement !== undefined) as (MenuBarMenuWithElements & { titleElement: HTMLElement; buttonElement: HTMLElement })[];
		for (const menuBarMenu of showableMenus) {
			if (!full) {
				const size = menuBarMenu.buttonElement.offsetWidth;
				if (currentSize + size > sizeAvailable) {
					full = true;
				} else {
					currentSize += size;
					this.numMenusShown++;
					if (this.numMenusShown > prevNumMenusShown) {
						menuBarMenu.buttonElement.style.visibility = 'visible';
					}
				}
			}

			if (full) {
				menuBarMenu.buttonElement.style.visibility = 'hidden';
			}
		}

		// If below minimium menu threshold, show the overflow menu only as hamburger menu
		if (this.numMenusShown - 1 <= showableMenus.length / 2) {
			for (const menuBarMenu of showableMenus) {
				menuBarMenu.buttonElement.style.visibility = 'hidden';
			}

			full = true;
			this.numMenusShown = 0;
			currentSize = 0;
		}

		// Overflow
		if (this.isCompact) {
			this.overflowMenu.actions = [];
			for (let idx = this.numMenusShown; idx < this.menus.length; idx++) {
				this.overflowMenu.actions.push(new SubmenuAction(`menubar.submenu.${this.menus[idx].label}`, this.menus[idx].label, this.menus[idx].actions || []));
			}

			const compactMenuActions = this.options.getCompactMenuActions?.();
			if (compactMenuActions && compactMenuActions.length) {
				this.overflowMenu.actions.push(new Separator());
				this.overflowMenu.actions.push(...compactMenuActions);
			}

			this.overflowMenu.buttonElement.style.visibility = 'visible';
		} else if (full) {
			// Can't fit the more button, need to remove more menus
			while (currentSize + this.overflowMenu.buttonElement.offsetWidth > sizeAvailable && this.numMenusShown > 0) {
				this.numMenusShown--;
				const size = showableMenus[this.numMenusShown].buttonElement.offsetWidth;
				showableMenus[this.numMenusShown].buttonElement.style.visibility = 'hidden';
				currentSize -= size;
			}

			this.overflowMenu.actions = [];
			for (let idx = this.numMenusShown; idx < showableMenus.length; idx++) {
				this.overflowMenu.actions.push(new SubmenuAction(`menubar.submenu.${showableMenus[idx].label}`, showableMenus[idx].label, showableMenus[idx].actions || []));
			}

			if (this.overflowMenu.buttonElement.nextElementSibling !== showableMenus[this.numMenusShown].buttonElement) {
				this.overflowMenu.buttonElement.remove();
				this.container.insertBefore(this.overflowMenu.buttonElement, showableMenus[this.numMenusShown].buttonElement);
			}

			this.overflowMenu.buttonElement.style.visibility = 'visible';
		} else {
			this.overflowMenu.buttonElement.remove();
			this.container.appendChild(this.overflowMenu.buttonElement);
			this.overflowMenu.buttonElement.style.visibility = 'hidden';
		}

		// If we are only showing the overflow, add this class to avoid taking up space
		this.container.classList.toggle(overflowMenuOnlyClass, this.numMenusShown === 0);
	}

	private updateLabels(titleElement: HTMLElement, buttonElement: HTMLElement, label: string): void {
		const cleanMenuLabel = cleanMnemonic(label);

		// Update the button label to reflect mnemonics

		if (this.options.enableMnemonics) {
			const cleanLabel = strings.escape(label);

			// This is global so reset it
			MENU_ESCAPED_MNEMONIC_REGEX.lastIndex = 0;
			let escMatch = MENU_ESCAPED_MNEMONIC_REGEX.exec(cleanLabel);

			// We can't use negative lookbehind so we match our negative and skip
			while (escMatch && escMatch[1]) {
				escMatch = MENU_ESCAPED_MNEMONIC_REGEX.exec(cleanLabel);
			}

			const replaceDoubleEscapes = (str: string) => str.replace(/&&/g, '&');

			if (escMatch) {
				titleElement.innerText = '';
				titleElement.append(
					strings.ltrim(replaceDoubleEscapes(cleanLabel.substr(0, escMatch.index)), ' '),
					$('mnemonic', { 'aria-hidden': 'true' }, escMatch[3]),
					strings.rtrim(replaceDoubleEscapes(cleanLabel.substr(escMatch.index + escMatch[0].length)), ' ')
				);
			} else {
				titleElement.innerText = replaceDoubleEscapes(cleanLabel).trim();
			}
		} else {
			titleElement.innerText = cleanMenuLabel.replace(/&&/g, '&');
		}

		const mnemonicMatches = MENU_MNEMONIC_REGEX.exec(label);

		// Register mnemonics
		if (mnemonicMatches) {
			const mnemonic = !!mnemonicMatches[1] ? mnemonicMatches[1] : mnemonicMatches[3];

			if (this.options.enableMnemonics) {
				buttonElement.setAttribute('aria-keyshortcuts', 'Alt+' + mnemonic.toLocaleLowerCase());
			} else {
				buttonElement.removeAttribute('aria-keyshortcuts');
			}
		}
	}

	style(style: IMenuStyles): void {
		this.menuStyle = style;
	}

	update(options?: IMenuBarOptions): void {
		if (options) {
			this.options = options;
		}

		// Don't update while using the menu
		if (this.isFocused) {
			this.updatePending = true;
			return;
		}

		this.menus.forEach(menuBarMenu => {
			if (!menuBarMenu.buttonElement || !menuBarMenu.titleElement) {
				return;
			}

			this.updateLabels(menuBarMenu.titleElement, menuBarMenu.buttonElement, menuBarMenu.label);
		});

		if (!this.overflowLayoutScheduled) {
			this.overflowLayoutScheduled = DOM.scheduleAtNextAnimationFrame(() => {
				this.updateOverflowAction();
				this.overflowLayoutScheduled = undefined;
			});
		}

		this.setUnfocusedState();
	}

	private registerMnemonic(menuIndex: number, mnemonic: string): void {
		this.mnemonics.set(mnemonic.toLocaleLowerCase(), menuIndex);
	}

	private hideMenubar(): void {
		if (this.container.style.display !== 'none') {
			this.container.style.display = 'none';
			this._onVisibilityChange.fire(false);
		}
	}

	private showMenubar(): void {
		if (this.container.style.display !== 'flex') {
			this.container.style.display = 'flex';
			this._onVisibilityChange.fire(true);

			this.updateOverflowAction();
		}
	}

	private get focusState(): MenubarState {
		return this._focusState;
	}

	private set focusState(value: MenubarState) {
		if (this._focusState >= MenubarState.FOCUSED && value < MenubarState.FOCUSED) {
			// Losing focus, update the menu if needed

			if (this.updatePending) {
				this.menuUpdater.schedule();
				this.updatePending = false;
			}
		}

		if (value === this._focusState) {
			return;
		}

		const isVisible = this.isVisible;
		const isOpen = this.isOpen;
		const isFocused = this.isFocused;

		this._focusState = value;

		switch (value) {
			case MenubarState.HIDDEN:
				if (isVisible) {
					this.hideMenubar();
				}

				if (isOpen) {
					this.cleanupCustomMenu();
				}

				if (isFocused) {
					this.focusedMenu = undefined;

					if (this.focusToReturn) {
						this.focusToReturn.focus();
						this.focusToReturn = undefined;
					}
				}

				break;
			case MenubarState.VISIBLE:
				if (!isVisible) {
					this.showMenubar();
				}

				if (isOpen) {
					this.cleanupCustomMenu();
				}

				if (isFocused) {
					if (this.focusedMenu) {
						if (this.focusedMenu.index === MenuBar.OVERFLOW_INDEX) {
							this.overflowMenu.buttonElement.blur();
						} else {
							this.menus[this.focusedMenu.index].buttonElement?.blur();
						}
					}

					this.focusedMenu = undefined;

					if (this.focusToReturn) {
						this.focusToReturn.focus();
						this.focusToReturn = undefined;
					}
				}

				break;
			case MenubarState.FOCUSED:
				if (!isVisible) {
					this.showMenubar();
				}

				if (isOpen) {
					this.cleanupCustomMenu();
				}

				if (this.focusedMenu) {
					if (this.focusedMenu.index === MenuBar.OVERFLOW_INDEX) {
						this.overflowMenu.buttonElement.focus();
					} else {
						this.menus[this.focusedMenu.index].buttonElement?.focus();
					}
				}
				break;
			case MenubarState.OPEN:
				if (!isVisible) {
					this.showMenubar();
				}

				if (this.focusedMenu) {
					this.showCustomMenu(this.focusedMenu.index, this.openedViaKeyboard);
				}
				break;
		}

		this._focusState = value;
		this._onFocusStateChange.fire(this.focusState >= MenubarState.FOCUSED);
	}

	get isVisible(): boolean {
		return this.focusState >= MenubarState.VISIBLE;
	}

	private get isFocused(): boolean {
		return this.focusState >= MenubarState.FOCUSED;
	}

	private get isOpen(): boolean {
		return this.focusState >= MenubarState.OPEN;
	}

	private get hasOverflow(): boolean {
		return this.isCompact || this.numMenusShown < this.menus.length;
	}

	private get isCompact(): boolean {
		return this.options.compactMode !== undefined;
	}

	private setUnfocusedState(): void {
		if (this.options.visibility === 'toggle' || this.options.visibility === 'hidden') {
			this.focusState = MenubarState.HIDDEN;
		} else if (this.options.visibility === 'classic' && browser.isFullscreen()) {
			this.focusState = MenubarState.HIDDEN;
		} else {
			this.focusState = MenubarState.VISIBLE;
		}

		this.ignoreNextMouseUp = false;
		this.mnemonicsInUse = false;
		this.updateMnemonicVisibility(false);
	}

	private focusPrevious(): void {

		if (!this.focusedMenu || this.numMenusShown === 0) {
			return;
		}

		let newFocusedIndex = (this.focusedMenu.index - 1 + this.numMenusShown) % this.numMenusShown;
		if (this.focusedMenu.index === MenuBar.OVERFLOW_INDEX) {
			newFocusedIndex = this.numMenusShown - 1;
		} else if (this.focusedMenu.index === 0 && this.hasOverflow) {
			newFocusedIndex = MenuBar.OVERFLOW_INDEX;
		}

		if (newFocusedIndex === this.focusedMenu.index) {
			return;
		}

		if (this.isOpen) {
			this.cleanupCustomMenu();
			this.showCustomMenu(newFocusedIndex);
		} else if (this.isFocused) {
			this.focusedMenu.index = newFocusedIndex;
			if (newFocusedIndex === MenuBar.OVERFLOW_INDEX) {
				this.overflowMenu.buttonElement.focus();
			} else {
				this.menus[newFocusedIndex].buttonElement?.focus();
			}
		}
	}

	private focusNext(): void {
		if (!this.focusedMenu || this.numMenusShown === 0) {
			return;
		}

		let newFocusedIndex = (this.focusedMenu.index + 1) % this.numMenusShown;
		if (this.focusedMenu.index === MenuBar.OVERFLOW_INDEX) {
			newFocusedIndex = 0;
		} else if (this.focusedMenu.index === this.numMenusShown - 1) {
			newFocusedIndex = MenuBar.OVERFLOW_INDEX;
		}

		if (newFocusedIndex === this.focusedMenu.index) {
			return;
		}

		if (this.isOpen) {
			this.cleanupCustomMenu();
			this.showCustomMenu(newFocusedIndex);
		} else if (this.isFocused) {
			this.focusedMenu.index = newFocusedIndex;
			if (newFocusedIndex === MenuBar.OVERFLOW_INDEX) {
				this.overflowMenu.buttonElement.focus();
			} else {
				this.menus[newFocusedIndex].buttonElement?.focus();
			}
		}
	}

	private updateMnemonicVisibility(visible: boolean): void {
		if (this.menus) {
			this.menus.forEach(menuBarMenu => {
				if (menuBarMenu.titleElement && menuBarMenu.titleElement.children.length) {
					const child = menuBarMenu.titleElement.children.item(0) as HTMLElement;
					if (child) {
						child.style.textDecoration = (this.options.alwaysOnMnemonics || visible) ? 'underline' : '';
					}
				}
			});
		}
	}

	private get mnemonicsInUse(): boolean {
		return this._mnemonicsInUse;
	}

	private set mnemonicsInUse(value: boolean) {
		this._mnemonicsInUse = value;
	}

	private get shouldAltKeyFocus(): boolean {
		if (isMacintosh) {
			return false;
		}

		if (!this.options.disableAltFocus) {
			return true;
		}

		if (this.options.visibility === 'toggle') {
			return true;
		}

		return false;
	}

	public get onVisibilityChange(): Event<boolean> {
		return this._onVisibilityChange.event;
	}

	public get onFocusStateChange(): Event<boolean> {
		return this._onFocusStateChange.event;
	}

	private onMenuTriggered(menuIndex: number, clicked: boolean) {
		if (this.isOpen) {
			if (this.isCurrentMenu(menuIndex)) {
				this.setUnfocusedState();
			} else {
				this.cleanupCustomMenu();
				this.showCustomMenu(menuIndex, this.openedViaKeyboard);
			}
		} else {
			this.focusedMenu = { index: menuIndex };
			this.openedViaKeyboard = !clicked;
			this.focusState = MenubarState.OPEN;
		}
	}

	private onModifierKeyToggled(modifierKeyStatus: DOM.IModifierKeyStatus): void {
		const allModifiersReleased = !modifierKeyStatus.altKey && !modifierKeyStatus.ctrlKey && !modifierKeyStatus.shiftKey && !modifierKeyStatus.metaKey;

		if (this.options.visibility === 'hidden') {
			return;
		}

		// Prevent alt-key default if the menu is not hidden and we use alt to focus
		if (modifierKeyStatus.event && this.shouldAltKeyFocus) {
			if (ScanCodeUtils.toEnum(modifierKeyStatus.event.code) === ScanCode.AltLeft) {
				modifierKeyStatus.event.preventDefault();
			}
		}

		// Alt key pressed while menu is focused. This should return focus away from the menubar
		if (this.isFocused && modifierKeyStatus.lastKeyPressed === 'alt' && modifierKeyStatus.altKey) {
			this.setUnfocusedState();
			this.mnemonicsInUse = false;
			this.awaitingAltRelease = true;
		}

		// Clean alt key press and release
		if (allModifiersReleased && modifierKeyStatus.lastKeyPressed === 'alt' && modifierKeyStatus.lastKeyReleased === 'alt') {
			if (!this.awaitingAltRelease) {
				if (!this.isFocused && this.shouldAltKeyFocus) {
					this.mnemonicsInUse = true;
					this.focusedMenu = { index: this.numMenusShown > 0 ? 0 : MenuBar.OVERFLOW_INDEX };
					this.focusState = MenubarState.FOCUSED;
				} else if (!this.isOpen) {
					this.setUnfocusedState();
				}
			}
		}

		// Alt key released
		if (!modifierKeyStatus.altKey && modifierKeyStatus.lastKeyReleased === 'alt') {
			this.awaitingAltRelease = false;
		}

		if (this.options.enableMnemonics && this.menus && !this.isOpen) {
			this.updateMnemonicVisibility((!this.awaitingAltRelease && modifierKeyStatus.altKey) || this.mnemonicsInUse);
		}
	}

	private isCurrentMenu(menuIndex: number): boolean {
		if (!this.focusedMenu) {
			return false;
		}

		return this.focusedMenu.index === menuIndex;
	}

	private cleanupCustomMenu(): void {
		if (this.focusedMenu) {
			// Remove focus from the menus first
			if (this.focusedMenu.index === MenuBar.OVERFLOW_INDEX) {
				this.overflowMenu.buttonElement.focus();
			} else {
				this.menus[this.focusedMenu.index].buttonElement?.focus();
			}

			if (this.focusedMenu.holder) {
				this.focusedMenu.holder.parentElement?.classList.remove('open');

				this.focusedMenu.holder.remove();
			}

			if (this.focusedMenu.widget) {
				this.focusedMenu.widget.dispose();
			}

			this.focusedMenu = { index: this.focusedMenu.index };
		}
	}

	private showCustomMenu(menuIndex: number, selectFirst = true): void {
		const actualMenuIndex = menuIndex >= this.numMenusShown ? MenuBar.OVERFLOW_INDEX : menuIndex;
		const customMenu = actualMenuIndex === MenuBar.OVERFLOW_INDEX ? this.overflowMenu : this.menus[actualMenuIndex];

		if (!customMenu.actions || !customMenu.buttonElement || !customMenu.titleElement) {
			return;
		}

		const menuHolder = $('div.menubar-menu-items-holder', { 'title': '' });

		customMenu.buttonElement.classList.add('open');

		const titleBoundingRect = customMenu.titleElement.getBoundingClientRect();
		const titleBoundingRectZoom = DOM.getDomNodeZoomLevel(customMenu.titleElement);

		if (this.options.compactMode === Direction.Right) {
			menuHolder.style.top = `${titleBoundingRect.top}px`;
			menuHolder.style.left = `${titleBoundingRect.left + this.container.clientWidth}px`;
		} else if (this.options.compactMode === Direction.Left) {
			menuHolder.style.top = `${titleBoundingRect.top}px`;
			menuHolder.style.right = `${this.container.clientWidth}px`;
			menuHolder.style.left = 'auto';
		} else {
			menuHolder.style.top = `${titleBoundingRect.bottom * titleBoundingRectZoom}px`;
			menuHolder.style.left = `${titleBoundingRect.left * titleBoundingRectZoom}px`;
		}

		customMenu.buttonElement.appendChild(menuHolder);

		const menuOptions: IMenuOptions = {
			getKeyBinding: this.options.getKeybinding,
			actionRunner: this.actionRunner,
			enableMnemonics: this.options.alwaysOnMnemonics || (this.mnemonicsInUse && this.options.enableMnemonics),
			ariaLabel: withNullAsUndefined(customMenu.buttonElement.getAttribute('aria-label')),
			expandDirection: this.isCompact ? this.options.compactMode : Direction.Right,
			useEventAsContext: true
		};

		const menuWidget = this._register(new Menu(menuHolder, customMenu.actions, menuOptions));
		if (this.menuStyle) {
			menuWidget.style(this.menuStyle);
		}

		this._register(menuWidget.onDidCancel(() => {
			this.focusState = MenubarState.FOCUSED;
		}));

		if (actualMenuIndex !== menuIndex) {
			menuWidget.trigger(menuIndex - this.numMenusShown);
		} else {
			menuWidget.focus(selectFirst);
		}

		this.focusedMenu = {
			index: actualMenuIndex,
			holder: menuHolder,
			widget: menuWidget
		};
	}
}


text:
<configuration>

    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%date{HH:mm:ss} %-5level %logger{0} {%method} - %msg%n</pattern>
        </encoder>
    </appender>

    <root level="info">
        <appender-ref ref="console"/>
    </root>

</configuration>


text:
from djangojsonmodel.util import DotDict

def implied_relations(models):
    fields = []
    for k, model in enumerate(models):
        f = DotDict()
        f.required = False
        f.m2m = False
        f.reverse_fk = True
        f.child = model['relname']
        f.model = model['relname']
        f.name = model['field']
        f.verbose_name = model['verbose_name']
        f.type = 'fk'
        f.implied_relation = True
        fields.append(f)
    return fields

def add_relations(c, rels):
    for model in c['models']:
        c['models'][model]['fields'] += implied_relations(rels)
    return c


text:
The kodeWeave editor, unlike kodeWeave touch. It incorporates the use of multiple files, has live preview integrated with them, and can load all your favorite libraries by simply checking a box.

You can head to kodeWeave Touch's [public repository](https://github.com/mikethedj4/kodeWeave-Touch/) if you're looking for a mobile/touch friendly IDE. (Note: kodeWeave touch is just a basic prototyper like [jsfiddle.net](http://jsfiddle.net/) only difference is it was made to be a mobile/touch friendly alternative.

### Version
in development (not yet pre-alpha)

### License
MIT

### Availability
kodeWeave editor will be made as a Chrome application and a web application.

You can use the amazing [Atom IDE](https://atom.io/) if you're a Windows, Linux, or Mac user.

### Tech
kodeWeave editor uses a number of open source projects to work properly:

* [jQuery](http://jquery.com/) - duh
* [TogetherJS](https://togetherjs.com/) - awesome collaboration tool
* [JQWidgets](http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxsplitter/index.htm#demos/jqxsplitter/nested-splitters.htm) - awesome plugin for resizable columns
* [Codemirror](http://codemirror.net/) - awesome web-based text editor
* [Inlet](https://github.com/enjalot/Inlet) - awesome inline color picker and numeric slider for Codemirror

### Development

Want to contribute? Great!

If you'd like to become a kodeWeave developer.
You can contact the software manager Michael at either [Facebook](http://facebook.com/mikethedj4) [Twitter](http://twitter.com/mikethedj4) or via [Email](mailto:mikethedj4@yahoo.com).

You can also submit a pull request here on Github :)

**Note:** kodeWeave is being developed on the [Koding Network](https://koding.com/R/mikethedj4).

Of course kodeWeave is free and open source, so you can always fork the project and have fun :)

### Todos

 - Fix: All values to added files get pushed to whom joins lobby last in Teamwork, but everyone else gets no value.


text:
module Authorable
  extend ActiveSupport::Concern

  included do
    # parse author string into CSL format
    def get_one_author(author, options = { sep: " " })
      return "" if author.blank?

      name_parts = author.split(options[:sep])
      if options[:reversed]
        family = name_parts.first
        given = name_parts.length > 1 ? name_parts[1..-1].join(" ") : ""
      else
        family = name_parts.last
        given = name_parts.length > 1 ? name_parts[0..-2].join(" ") : ""
      end

      { "family" => String(family).titleize,
        "given" => String(given).titleize }
    end

    # parse array of author strings into CSL format
    def get_authors(authors, options = { sep: " " })
      Array(authors).map { |author| get_one_author(author, options) }
    end
  end
end


text:
PyMethodDef pymathMethods[] =
{

	{ "divides", pymath_divides, METH_VARARGS,
			"Returns true if first arg divides second arg." },

	{ "pow", pymath_pow, METH_VARARGS,
			"Returns (a^b) mod c." },

	//...

	{ NULL, NULL, 0, NULL }

};

PyMODINIT_FUNC
initpymath(void)
{
	(void) Py_InitModule("pymath", pymathMethods);
}


text:
<!doctype html>

	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>DT_TEBubbleTrail | demofile</title>
	<meta name="description" content="Documentation for demofile">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="../assets/css/main.css">

						Search
						<input id="tsd-search-field" type="text" />

Preparing search index...

The search index is not available

					demofile

						Options

								All

Public

Public/Protected

All

							<input type="checkbox" id="tsd-filter-inherited" checked />
							Inherited
							<input type="checkbox" id="tsd-filter-externals" checked />
							Externals
							<input type="checkbox" id="tsd-filter-only-exported" />
							Only exported

					Menu

					Globals

					"sendtabletypes"

					DT_TEBubbleTrail

Interface DT_TEBubbleTrail

Hierarchy

						DT_TEBubbleTrail

Index

Properties

m_<wbr>f<wbr>Speed

m_<wbr>fl<wbr>WaterZ

m_<wbr>n<wbr>Count

m_<wbr>n<wbr>Model<wbr>Index

m_<wbr>vec<wbr>Maxs

m_<wbr>vec<wbr>Mins

Properties

m_<wbr>f<wbr>Speed

m_<wbr>f<wbr>Speed: number

Defined in src/sendtabletypes.ts:1971

m_<wbr>fl<wbr>WaterZ

m_<wbr>fl<wbr>WaterZ: number

Defined in src/sendtabletypes.ts:1969

m_<wbr>n<wbr>Count

m_<wbr>n<wbr>Count: number

Defined in src/sendtabletypes.ts:1970

m_<wbr>n<wbr>Model<wbr>Index

m_<wbr>n<wbr>Model<wbr>Index: number

Defined in src/sendtabletypes.ts:1968

m_<wbr>vec<wbr>Maxs

m_<wbr>vec<wbr>Maxs: Vector

Defined in src/sendtabletypes.ts:1967

m_<wbr>vec<wbr>Mins

m_<wbr>vec<wbr>Mins: Vector

Defined in src/sendtabletypes.ts:1966

						Globals

						"sendtabletypes"

						DT_<wbr>TEBubble<wbr>Trail

								m_<wbr>f<wbr>Speed

								m_<wbr>fl<wbr>WaterZ

								m_<wbr>n<wbr>Count

								m_<wbr>n<wbr>Model<wbr>Index

								m_<wbr>vec<wbr>Maxs

								m_<wbr>vec<wbr>Mins

Legend

Object literal

Variable

Function

Function with type parameter

Type alias

Type alias with type parameter

Interface

Interface with type parameter

Property

Class

Class with type parameter

Enumeration

Generated using TypeDoc


text:
import {isEmpty} from 'lodash';
import {userDomain} from './actions';

const initialState = {
  loading: false,
  loaded: false,
  error: null,
  users: [],
  selected: null,
}

export default (state = {}, action = {}) => {
  if (isEmpty(state)) {
    state = {...initialState};
  }
  switch (action.type) {
    case `${userDomain}.LIST/LOAD`:
      return {...state, loading: true};

    case `${userDomain}.LIST/RECEIVE`:
      return {...state, loading: false, loaded: true, users: action.payload};

    default:
      return state;
  }
}


text:
import invoke

from . import release
from . import static

ns = invoke.Collection(release, static)


text:
.wu-example {
	position: relative;
	padding: 45px 15px 15px;
	margin: 15px 0;
	background-color: #fafafa;
	box-shadow: inset 0 3px 6px rgba(0, 0, 0, .05);
	border-color: #e5e5e5 #eee #eee;
	border-style: solid;
	border-width: 1px 0;
}
.webuploader-container {
	position: relative;
}
.webuploader-element-invisible {
	position: absolute !important;
	clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
    clip: rect(1px,1px,1px,1px);
}
.webuploader-pick {
	position: relative;
	display: inline-block;
	cursor: pointer;
	background: #00b7ee;
	padding: 6px 15px;
	color: #fff;
	text-align: center;
	border-radius: 3px;
	overflow: hidden;
}
.webuploader-pick-hover {
	background: #00a2d4;
}

.webuploader-pick-disable {
	opacity: 0.6;
	pointer-events:none;
}

.up-picker {
	display: inline-block;
	line-height: 1.428571429;
	vertical-align: middle;
	margin: 0 12px 0 0;
}
#picker .webuploader-pick {
	padding: 6px 12px;
	display: block;
}

#uploader-demo .thumbnail {
	width: 110px;
	height: 110px;
}
#uploader-demo .thumbnail img {
	width: 100%;
}
.uploader-list {
	width: 100%;
	overflow: hidden;
}
.file-item {
	float: left;
	position: relative;
	margin: 0 20px 20px 0;
	padding: 4px;
}
.file-item .error {
	position: absolute;
	top: 4px;
	left: 4px;
	right: 4px;
	background: red;
	color: white;
	text-align: center;
	height: 20px;
	font-size: 14px;
	line-height: 23px;
}
.file-item .info {
	position: absolute;
	left: 4px;
	bottom: 4px;
	right: 4px;
	height: 20px;
	line-height: 20px;
	text-indent: 5px;
	background: rgba(0, 0, 0, 0.6);
	color: white;
	overflow: hidden;
	white-space: nowrap;
	text-overflow : ellipsis;
	font-size: 12px;
	z-index: 10;
}
.upload-state-done:after {
	content:"\f00c";
	font-family: FontAwesome;
	font-style: normal;
	font-weight: normal;
	line-height: 1;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	font-size: 32px;
	position: absolute;
	bottom: 0;
	right: 4px;
	color: #4cae4c;
	z-index: 99;
}
.file-item .progress {
	position: absolute;
	right: 4px;
	bottom: 4px;
	height: 3px;
	left: 4px;
	height: 4px;
	overflow: hidden;
	z-index: 15;
	margin:0;
	padding: 0;
	border-radius: 0;
	background: transparent;
}
.file-item .progress span {
	display: block;
	overflow: hidden;
	width: 0;
	height: 100%;
	background: #d14 url(../img/progress.png) repeat-x;
	-webit-transition: width 200ms linear;
	-moz-transition: width 200ms linear;
	-o-transition: width 200ms linear;
	-ms-transition: width 200ms linear;
	transition: width 200ms linear;
	-webkit-animation: progressmove 2s linear infinite;
	-moz-animation: progressmove 2s linear infinite;
	-o-animation: progressmove 2s linear infinite;
	-ms-animation: progressmove 2s linear infinite;
	animation: progressmove 2s linear infinite;
	-webkit-transform: translateZ(0);
}
@-webkit-keyframes progressmove {
	0% {
		background-position: 0 0;
	}
	100% {
		background-position: 17px 0;
	}
}
@-moz-keyframes progressmove {
	0% {
		background-position: 0 0;
	}
	100% {
		background-position: 17px 0;
	}
}
@keyframes progressmove {
	0% {
		background-position: 0 0;
	}
	100% {
		background-position: 17px 0;
	}
}

a.travis {
	position: relative;
	top: -4px;
	right: 15px;
}


text:
namespace BrainCloud
{
	BrainCloudRTT::BrainCloudRTT(RTTComms* in_comms, BrainCloudClient* in_client)
		: m_client(in_client), m_commsLayer(in_comms)
	{
	}

	void BrainCloudRTT::requestClientConnection(IServerCallback* in_callback)
	{
		Json::Value nullMsg = Json::nullValue;
		ServerCall* sc = new ServerCall(ServiceName::RTTRegistration, ServiceOperation::RequestClientConnection, nullMsg, in_callback);
		m_client->getBrainCloudComms()->addToQueue(sc);
	}

	// RTT stuff
    void BrainCloudRTT::enableRTT(IRTTConnectCallback* in_callback, bool in_useWebSocket)
    {
        m_commsLayer->enableRTT(in_callback, in_useWebSocket);
    }

    void BrainCloudRTT::disableRTT()
    {
        m_commsLayer->disableRTT();
    }

    bool BrainCloudRTT::getRTTEnabled()
    {
        return m_commsLayer->isRTTEnabled();
    }

    BrainCloudRTT::RTTConnectionStatus BrainCloudRTT::getConnectionStatus()
    {
        return m_commsLayer->getConnectionStatus();
    }

    void BrainCloudRTT::registerRTTEventCallback(IRTTCallback* in_callback)
    {
        m_commsLayer->registerRTTCallback(ServiceName::Event, in_callback);
    }

    void BrainCloudRTT::deregisterRTTEventCallback()
    {
        m_commsLayer->deregisterRTTCallback(ServiceName::Event);
    }

    void BrainCloudRTT::registerRTTChatCallback(IRTTCallback* in_callback)
    {
        m_commsLayer->registerRTTCallback(ServiceName::Chat, in_callback);
    }

    void BrainCloudRTT::deregisterRTTChatCallback()
    {
        m_commsLayer->deregisterRTTCallback(ServiceName::Chat);
    }

    void BrainCloudRTT::registerRTTMessagingCallback(IRTTCallback* in_callback)
    {
        m_commsLayer->registerRTTCallback(ServiceName::Messaging, in_callback);
    }

    void BrainCloudRTT::deregisterRTTMessagingCallback()
    {
        m_commsLayer->deregisterRTTCallback(ServiceName::Messaging);
    }

    void BrainCloudRTT::registerRTTLobbyCallback(IRTTCallback* in_callback)
    {
        m_commsLayer->registerRTTCallback(ServiceName::Lobby, in_callback);
    }

    void BrainCloudRTT::deregisterRTTLobbyCallback()
    {
        m_commsLayer->deregisterRTTCallback(ServiceName::Lobby);
    }

    void BrainCloudRTT::registerRTTPresenceCallback(IRTTCallback* in_callback)
    {
        m_commsLayer->registerRTTCallback(ServiceName::Presence, in_callback);
    }

    void BrainCloudRTT::deregisterRTTPresenceCallback()
    {
        m_commsLayer->deregisterRTTCallback(ServiceName::Presence);
    }

    void BrainCloudRTT::registerRTTBlockchainRefresh(IRTTCallback* in_callback)
    {
        m_commsLayer->registerRTTCallback(ServiceName::UserItems, in_callback);
    }

    void BrainCloudRTT::deregisterRTTBlockchainRefresh()
    {
        m_commsLayer->deregisterRTTCallback(ServiceName::UserItems);
    }

    void BrainCloudRTT::deregisterAllRTTCallbacks()
    {
        m_commsLayer->deregisterAllRTTCallbacks();
    }

    const std::string& BrainCloudRTT::getRTTConnectionId() const
    {
        return m_commsLayer->getConnectionId();
    }

}


text:
import {Component, OnInit, OnDestroy} from '@angular/core';
// import Error = protractor.error.Error;
import {AlertMessage, ALERT_TYPE_INFO} from "./alert-message";
import {BroadcasterService} from "../../common/services/broadcaster.service";
import {Subscription} from "rxjs/Subscription";

@Component({
  selector: 'error',
  providers: [],
  templateUrl: './alert.component.html'
})
export class AlertComponent implements OnInit, OnDestroy {

  constructor(private broadcasterService: BroadcasterService) {

  }

  private eventSub: Subscription = Subscription.EMPTY;

  alertMessages: AlertMessage[] = [];

  ngOnInit(): void {
    this.eventSub = this.broadcasterService.on<AlertMessage>('alertComponent').subscribe(
      alert => {
        this.alertMessages.push(alert);
      }
    )
  }

  ngOnDestroy(): void {
    if (!this.eventSub.closed) {
      this.eventSub.unsubscribe();
    }
  }

}


text:
#ifndef _SIR_DEFAULTS_H_INCLUDED
#define _SIR_DEFAULTS_H_INCLUDED

#include "sirtypes.h"

/**
 * @addtogroup custom
 * @{
 */

/** Default levels for \a stdout. */
static const sir_levels sir_stdout_def_lvls
    = SIRL_DEBUG | SIRL_INFO | SIRL_NOTICE | SIRL_WARN;

/** Default options for \a stdout. */
static const sir_options sir_stdout_def_opts
    = SIRO_NOTIME | SIRO_NOPID | SIRO_NOTID;

/** Default levels for \a stderr. */
static const sir_levels sir_stderr_def_lvls
    = SIRL_ERROR | SIRL_CRIT | SIRL_EMERG;

/** Default options for \a stderr. */
static const sir_options sir_stderr_def_opts
    = SIRO_NOTIME | SIRO_NOPID | SIRO_NOTID;

/** Default levels for \a syslog (if enabled). */
static const sir_levels sir_syslog_def_lvls
    = SIRL_WARN | SIRL_CRIT | SIRL_ALERT | SIRL_EMERG;

/** Default levels for \a log \a files. */
static const sir_levels sir_file_def_lvls
    = SIRL_ALL;

/** Default options for \a log \a files. */
static const sir_options sir_file_def_opts
    = 0; /* (all output) */

/** Default mapping of ::sir_level to ::sir_textstyle. */
static const sir_style_map sir_default_styles[SIR_NUMLEVELS] = {
    {SIRL_DEBUG, SIRS_FG_DGRAY},
    {SIRL_INFO, SIRS_FG_WHITE},
    {SIRL_NOTICE, SIRS_FG_CYAN},
    {SIRL_WARN, SIRS_FG_YELLOW},
    {SIRL_ERROR, SIRS_FG_RED},
    {SIRL_CRIT, SIRS_BRIGHT | SIRS_FG_RED},
    {SIRL_ALERT, SIRS_BRIGHT | SIRS_FG_BLACK | SIRS_BG_LYELLOW},
    {SIRL_EMERG, SIRS_BRIGHT | SIRS_FG_LYELLOW | SIRS_BG_RED},
};

/** @} */

#endif /* !_SIR_DEFAULTS_H_INCLUDED */


text:
/** @file   ir.h
    @author M. P. Hayes, UCECE
    @date   23 August 2010
    @brief  Infrared driver.

    @defgroup IR Infrared (IR) driver

    This module implements a simple hardware abstraction of an IR LED and
    IR receiver.
*/

#ifndef IR_H
#define IR_H

#include "system.h"

#ifndef IR_MODULATION_FREQ
/** The nominal modulation frequency.  This can be defined in system.h.  */
#define IR_MODULATION_FREQ 36e3
#endif

/** Modulate the IR transmitter LED at IR_MODULATION_FREQ.
    @param state is 1 to enable modulation, 0 to disable modulation
    @param count is the number of modulation periods
    @note This returns after @c count modulation periods.  */
void ir_tx_set (uint8_t state, uint16_t count);

/** Return output state of IR receiver.
    @return IR receiver state (1 = IR modulation detected).  */
uint8_t ir_rx_get (void);

/* Initialise PIOs for IR transmitter LED and receiver.  */
void ir_init (void);

#endif


text:
Rubik's Cube
============
Rubik's cube for [Interactive Computer Graphics](http://faculty.cooper.edu/sable2/courses/spring2013/ece462/), built with code from [Angel](http://www.cs.unm.edu/~angel/BOOK/INTERACTIVE_COMPUTER_GRAPHICS/SIXTH_EDITION/CODE/). An arcball is used for natural cube manipulation.

setup
-----
`gcc` is required, along with a graphics card that supports OpenGL 3. In the root directory, run

```
$ make
```

run
---

```
$ rubik.exe <filename to save to> <number of rotations | filename to load from>
```

commands
--------

button | action
--- | ---
Left Mouse | Orbit around cube
Right Mouse | Rotate layer
Scrollwheel | Zoom in/out
Enter | randomly rotate one layer
s | save state to the specified file
Space | reset orientation
q | quit

A light background means that the cube is unsolved, while a dark background indicates the cube is solved.