text:
package com.ltsllc.miranda.network;

import com.ltsllc.miranda.Message;
import com.ltsllc.miranda.clientinterface.MirandaException;
import com.ltsllc.miranda.network.messages.ConnectToMessage;
import com.ltsllc.miranda.network.messages.SendNetworkMessage;
import com.ltsllc.miranda.network.states.NetworkReadyState;
import com.ltsllc.miranda.node.networkMessages.JoinWireMessage;
import com.ltsllc.miranda.test.TestCase;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Matchers;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import static org.mockito.Mockito.*;

/**
 * Created by Clark on 3/20/2017.
 */
public class TestNetworkReadyState extends TestCase {
    private NetworkReadyState networkReadyState;

    public NetworkReadyState getNetworkReadyState() {
        return networkReadyState;
    }

    public void reset () throws Exception {
        super.reset();

        networkReadyState = null;
    }

    @Before
    public void setup () throws Exception {
        reset();

        super.setup();

        setuplog4j();

        networkReadyState = new NetworkReadyState(getMockNetwork());
    }

    @Test
    public void testProcessConnectToMessage () throws MirandaException {
        ConnectToMessage connectToMessage = new ConnectToMessage("foo.com", 6789, null, this);

        getNetworkReadyState().processMessage(connectToMessage);

        verify(getMockNetwork(), atLeastOnce()).connect(Matchers.any(ConnectToMessage.class));
    }

    @Test
    public void testProcessSendNetworkMessageSuccess () throws MirandaException {
        JoinWireMessage joinWireMessage = new JoinWireMessage("foo.com", "192.168.1.1", 6789, "a node");
        SendNetworkMessage sendNetworkMessage = new SendNetworkMessage(null, this, joinWireMessage, -1);

        getNetworkReadyState().processMessage(sendNetworkMessage);

        try {
            verify(getMockNetwork(), atLeastOnce()).sendOnNetwork(Matchers.any(SendNetworkMessage.class));
        } catch (NetworkException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    @Test
    public void testProcessSendNetworkMessageExceptionUnrecognizedHandle () throws MirandaException {
        BlockingQueue<Message> queue = new LinkedBlockingQueue<Message>();
        JoinWireMessage joinWireMessage = new JoinWireMessage("foo.com", "192.168.1.1", 6789, "a node");
        SendNetworkMessage sendNetworkMessage = new SendNetworkMessage(queue, this, joinWireMessage, -1);
        NetworkException networkException = new NetworkException("Test", NetworkException.Errors.UnrecognizedHandle);

        try {
            doThrow(networkException).when(getMockNetwork()).sendOnNetwork(Matchers.any(SendNetworkMessage.class));
        } catch (NetworkException e) {
            e.printStackTrace();
            System.exit(1);
        }

        getNetworkReadyState().processMessage(sendNetworkMessage);

        try {
            verify(getMockNetwork(), atLeastOnce()).sendOnNetwork(Matchers.any(SendNetworkMessage.class));
        } catch (NetworkException e) {
            e.printStackTrace();
            System.exit(1);
        }

        assert (contains(Message.Subjects.UnknownHandle, queue));
    }

    @Test
    public void testProcessSendNetworkMessageException () throws MirandaException {
        BlockingQueue<Message> queue = new LinkedBlockingQueue<Message>();
        JoinWireMessage joinWireMessage = new JoinWireMessage("foo.com", "192.168.1.1", 6789, "a node");
        SendNetworkMessage sendNetworkMessage = new SendNetworkMessage(queue, this, joinWireMessage, -1);
        NetworkException networkException = new NetworkException("Test", NetworkException.Errors.ExceptionSending);

        try {
            doThrow(networkException).when(getMockNetwork()).sendOnNetwork(Matchers.any(SendNetworkMessage.class));
        } catch (NetworkException e) {
            e.printStackTrace();
            System.exit(1);
        }

        getNetworkReadyState().processMessage(sendNetworkMessage);

        try {
            verify(getMockNetwork(), atLeastOnce()).sendOnNetwork(Matchers.any(SendNetworkMessage.class));
        } catch (NetworkException e) {
            e.printStackTrace();
            System.exit(1);
        }

        assert (contains(Message.Subjects.NetworkError, queue));

    }
}


text:
<?php

function LoadLayout($Content, $Variables)
{
    // ...
    extract($Variables);

    // Load Content
    ob_start();
    include_once($Content);
    $content = ob_get_contents();
    ob_end_clean();

    // Load Layout
    include_once("../templates/Layout.php");
}

redpajama_set_name: RedPajamaGithub


text:
bp4u-irc-bots
=============

We have you cover for very low ruble!

To make a new bot, subclass the Bot class. Override handle\_pm to do stuff when your bot gets private messaged, handle\_msg to do stuff when a message goes out to a channel your bot is on, handle\_join when someone joins a channel your bot is on, etc.
To start the bot running, instantiate it and then call "yourbot.process()" in a while True loop. Thats's it

Currently the Bot superclass has no SSL support. If the IRC server you're using doesn't allow external non-SSL connections, you may need to convince the server operator to let you run the bot on their server. SSL support is (hopefully) coming soon.


text: export default from './Notice';


text:
import { ValidatorFn, Validators } from '@angular/forms';
import { DomainBase } from './do-domain-base';

export class DoEmail extends DomainBase {
    validators = [Validators.pattern('\w+@\w+\.\w+')]
}


text: export default from 'buildo-react-components/src/flex/FlexView';


text:
package org.apache.sysml.test.integration.functions.unary.matrix;

import org.junit.Test;

import org.apache.sysml.test.integration.AutomatedTestBase;
import org.apache.sysml.test.integration.TestConfiguration;

public class CosTest extends AutomatedTestBase
{

	private static final String TEST_DIR = "functions/unary/matrix/";
	private static final String TEST_CLASS_DIR = TEST_DIR + CosTest.class.getSimpleName() + "/";
	private static final double EPS = 1e-14;

	@Override
	public void setUp() {
		addTestConfiguration("PositiveTest",
				new TestConfiguration(TEST_CLASS_DIR, "CosTest", new String[] { "vector", "matrix" }));
		addTestConfiguration("NegativeTest",
				new TestConfiguration(TEST_CLASS_DIR, "CosTest", new String[] { "vector", "matrix" }));
		addTestConfiguration("RandomTest",
				new TestConfiguration(TEST_CLASS_DIR, "CosTest", new String[] { "vector", "matrix" }));
	}

	@Test
	public void testPositive() {
		if(shouldSkipTest())
			return;
		int rows = 10;
		int cols = 10;

		TestConfiguration config = availableTestConfigurations.get("PositiveTest");
		config.addVariable("rows", rows);
		config.addVariable("cols", cols);

		loadTestConfiguration(config);

		double[][] vector = getRandomMatrix(rows, 1, 0, 1, 1, -1);
		double[][] cosVector = new double[rows][1];
		for(int i = 0; i < rows; i++) {
			cosVector[i][0] = Math.cos(vector[i][0]);
		}
		writeInputMatrix("vector", vector);
		writeExpectedMatrix("vector", cosVector);

		double[][] matrix = getRandomMatrix(rows, cols, 0, 1, 1, -1);
		double[][] cosMatrix = new double[rows][cols];
		for(int i = 0; i < rows; i++) {
			for(int j = 0; j < cols; j++) {
				cosMatrix[i][j] = Math.cos(matrix[i][j]);
			}
		}
		writeInputMatrix("matrix", matrix);
		writeExpectedMatrix("matrix", cosMatrix);

		runTest();

		compareResults(EPS);
	}

	@Test
	public void testNegative() {
		if(shouldSkipTest())
			return;
		int rows = 10;
		int cols = 10;

		TestConfiguration config = availableTestConfigurations.get("NegativeTest");
		config.addVariable("rows", rows);
		config.addVariable("cols", cols);

		loadTestConfiguration(config);

		double[][] vector = getRandomMatrix(rows, 1, -1, 0, 1, -1);
		double[][] cosVector = new double[rows][1];
		for(int i = 0; i < rows; i++) {
			cosVector[i][0] = Math.cos(vector[i][0]);
		}
		writeInputMatrix("vector", vector);
		writeExpectedMatrix("vector", cosVector);

		double[][] matrix = getRandomMatrix(rows, cols, -1, 0, 1, -1);
		double[][] cosMatrix = new double[rows][cols];
		for(int i = 0; i < rows; i++) {
			for(int j = 0; j < cols; j++) {
				cosMatrix[i][j] = Math.cos(matrix[i][j]);
			}
		}
		writeInputMatrix("matrix", matrix);
		writeExpectedMatrix("matrix", cosMatrix);

		runTest();

		compareResults(EPS);
	}

	@Test
	public void testRandom() {
		if(shouldSkipTest())
			return;
		int rows = 10;
		int cols = 10;

		TestConfiguration config = availableTestConfigurations.get("RandomTest");
		config.addVariable("rows", rows);
		config.addVariable("cols", cols);

		loadTestConfiguration(config);

		double[][] vector = getRandomMatrix(rows, 1, -1, 1, 1, -1);
		double[][] cosVector = new double[rows][1];
		for(int i = 0; i < rows; i++) {
			cosVector[i][0] = Math.cos(vector[i][0]);
		}
		writeInputMatrix("vector", vector);
		writeExpectedMatrix("vector", cosVector);

		double[][] matrix = getRandomMatrix(rows, cols, -1, 1, 1, -1);
		double[][] cosMatrix = new double[rows][cols];
		for(int i = 0; i < rows; i++) {
			for(int j = 0; j < cols; j++) {
				cosMatrix[i][j] = Math.cos(matrix[i][j]);
			}
		}
		writeInputMatrix("matrix", matrix);
		writeExpectedMatrix("matrix", cosMatrix);

		runTest();

		compareResults(EPS);
	}

}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using Autofac.CommandLine.Args;
using Autofac.CommandLine.Help;

namespace Autofac.CommandLine
{
    // working
    // -MyModule:foo=bar
    // -m:f=bar

    public class CommandLineAwareModule : Module
    {
        public static readonly string[] DefaultSetFlags = new[] {"set:", "s:"};
        private readonly IEnumerable<PropArg> props;
        private readonly List<SetArg> sets = new List<SetArg>();
        private bool enabled = true;

        protected CommandLineAwareModule()
            :this(new ParamList(Environment.GetCommandLineArgs()), DefaultSetFlags)
        {

        }

        protected CommandLineAwareModule(ParamList args)
            : this(args, DefaultSetFlags)
        {
        }

        protected CommandLineAwareModule(ParamList argsRaw, IEnumerable<string> setFlags)
        {
            var args = argsRaw.Args.AsCleanedArgs();

            foreach (var arg in args)
            {
                var setFlag = setFlags.FirstOrDefault(f => arg.StartsWith(f, StringComparison.InvariantCultureIgnoreCase));
                if (setFlag != null)
                {
                    string chomped = arg.Substring(setFlag.Length);
                    sets.Add(new SetArg(chomped));
                }
            }

            props = this.GetProps();

            var aliasAtt = this.GetModuleAlias();
            if (aliasAtt != null)
            {
                Alias = aliasAtt;
            }
        }

        [Alias("on")]
        public bool Enabled
        {
            get { return enabled; }
            set { enabled = value; }
        }

        [Alias("off")]
        public bool Disabled
        {
            get { return enabled; }
            set { enabled = !value; }
        }

        public AliasAttribute Alias { get; private set; }

        protected override sealed void Load(ContainerBuilder builder)
        {
            // TODO: register ModuleInfo so that it can be picked up later
            builder.RegisterInstance(new ModuleInfo(GetType(), Alias, props));

            IEnumerable<SetArg> matches = from s in sets
                                          where (Alias != null ? s.TargetName == Alias.Alias : false) || s.TargetName == GetType().Name
                                          select s;

            foreach (var m in matches)
            {
                foreach (var a in m.Args)
                {
                    IEnumerable<PropArg> toSet = from p in props
                                              where (p.Alias != null ? p.Alias.Alias == a.Key : false) || p.FullName == a.Key
                                              select p;
                    foreach (var p in toSet)
                    {
                        p.Set(a.Value);
                    }
                }
            }

            if (Enabled)
            {
                Load_(builder);
            }
        }

        protected virtual void Load_(ContainerBuilder builder)
        {
        }
    }
}


text:
{% extends "base.html" %}
{% block content %}

Welcome to the Skin vs. Food Web App!

Instructions

Click on the 4 Links at the top to navigate around

Click on "Show_Test_Data"

This shows 1 of 200 images (selected randomly) from our Test Data Set. Both "HOG" and "Blob" classifiers were trained on the same 300 image Training Data Set.

You select what you see in the image, hit the "analyze" button, and the HOG/Blob results are output.

To keep doing this for new images, hit the "yes" button at bottom

Click on "Upload_Local_Image"

Upload an image from you computer, select what you see in the image, hit "analyze" button

WAIT for ~ 10-20 sec, it runs the trained HOG and Blob classifiers on your image so takes a bit, then HOG and Blob results output, and additional info for how each classifier works

Next Steps

Add text describing the project, how the classifiers work, about us, links to github, etc.

Think of how turn into game. Maybe show histogram "live" of how many correct HOG classifier gets correct versus Blob classifier versus User

CSS files to make it look awesome

{% endblock %}


text:
var EditableGrid_check_lib = null;

EditableGrid.prototype.checkChartLib = function()
{
	try {
		$('dummy').highcharts();
	}
	catch (e) {
		alert('HighCharts library not loaded!');
		return false;
	}

	return true;
};

EditableGrid.prototype.hex2rgba = function(hexColor, alpha)
{
	if (typeof alpha == 'undefined') alpha = 1.0;
	var color = {red: parseInt(hexColor.substr(1,2),16), green: parseInt(hexColor.substr(3,2),16), blue:  parseInt(hexColor.substr(5,2),16)};
	return 'rgba(' + color.red + ',' + color.green + ',' + color.blue + ',' + alpha + ')';
};

EditableGrid.prototype.getFormattedValue = function(columnIndex, value)
{
	try {

		// let the renderer work on a dummy element
		var element = document.createElement('div');
		var renderer = this.getColumn(columnIndex).cellRenderer;
		renderer._render(0, columnIndex, element, value);
		return element.innerHTML;

	} catch (ex) {
		return value;
	}
};

EditableGrid.prototype.skipRow = function(rowIndex)
{
	// skip if set as an attribute
	if (this.getRowAttribute(rowIndex, "skip") == "1") return true;

	// skip if hidden or expanded
	var row = this.getRow(rowIndex);
	if (row && row.style && row.style.display == 'none') return true;
	if (row && typeof row.expanded != 'undefined' && row.expanded !== null) return row.expanded;

	return false;
};

/**
 * renderBarChart
 * Render Highcharts column chart for the data contained in the table model
 * @param divId
 * @param title
 * @param labelColumnIndexOrName
 * @param options:
 * - type: bar, column, spline, scatter [default = column]
 * - zoomType: x, y, xy [default = none]
 * - legend: text [default = label of column given by labelColumnIndexOrName]
 * - bgColor: css format #xxxxxx [default = null, meaning transparent]
 * - alpha: between 0 and 1 [default = 0.9]
 * - limit: max number of rows considered [default = 0, meaning all rows]
 * - bar3d: boolean [defaut = true]
 * - rotateXLabels: angle in degrees [default = 0]
 * @return
 */

EditableGrid.prototype.renderBarChart = function(divId, title, labelColumnIndexOrName, options)
{
	var self = this;

	// TODO: do not assign options local to this function on "this"... name conflicts
	this.autoHeight_fun = this.autoHeight;

	// default options
	this.legend = null;
	this.bgColor = null; // transparent
	this.alpha = 0.9;
	this.limit = 0;
	this.bar3d = false;
	this.rotateXLabels = 0;
	this.autoHeight = 0; // use for (horizontal) bar charts if you want height to be computed dyn. based on the number of bars: autoHeight = number of px for one bar

	// used to find the rowindex from the pointIndex for drawing horizontal reference lines
	var rowIndexByPoint = {};

	with (this) {

		if (EditableGrid_check_lib === null) EditableGrid_check_lib = checkChartLib();
		if (!EditableGrid_check_lib) return false;

		// override default options with the ones given
		if (options) for (var p in options) this[p] = options[p];

		// get useful values
		labelColumnIndexOrName = labelColumnIndexOrName || 0;
		var cLabel = getColumnIndex(labelColumnIndexOrName);
		var columnCount = getColumnCount();
		var rowCount = getRowCount() - (ignoreLastRow ? 1 : 0);
		if (limit > 0 && rowCount > limit) rowCount = limit;

		// base chart
		var type = options['type'] || 'column';
		var chart = {

				chart: {
					type: type,
					zoomType: options['zoomType'] || null,
					backgroundColor: bgColor,
					plotBackgroundColor: bgColor,
					height: null, // auto
					options3d: {
						enabled: bar3d
					}
				},

				plotOptions: {
					column: {
						stacking: options['stacking'] || '',
						groupPadding: 0.1,
						pointPadding: 0.1,
						borderWidth: 0
					},
					bar: {
						stacking: options['stacking'] || '',
						groupPadding: 0.1,
						pointPadding: 0.1,
						borderWidth: 0
					},
					line: {
						step: 'center',
						lineWidth: 4,
						zIndex: 1000,
						marker: { enabled: false, states: { hover: { enabled: false } } }
					},
					scatter: {
						zIndex: 1000,
						marker: { symbol: 'diamond', lineColor: null, lineWidth: 4, states: { hover: { enabled: false } } }
					}
				},

				legend: {
					align: 'center',
					verticalAlign: (type == 'bar' ? 'top' : 'bottom'),
					margin: (type == 'bar' ? 40 : 12),
					floating: false
				},

				credits: {
					enabled: false
				},

				title: {
					text: title
				},

				tooltip: {
					pointFormatter: function() { return this.series.name + ': ' + self.getFormattedValue(this.series.options.colIndex, this.y) + ''; }
				}
		};

		// xaxis with legend and rotation
		chart.xAxis = {
				title: { text:  legend || getColumnLabel(labelColumnIndexOrName) },
				labels: { rotation: rotateXLabels }
		};

		// one category for each row
		chart.xAxis.categories = [];
		for (var r = 0; r < rowCount; r++) {
			if (skipRow(r)) continue;
			var label = getRowAttribute(r, "barlabel"); // if there is a barlabel attribute, use it and ignore labelColumn
			chart.xAxis.categories.push(label ? label : getValueAt(r, cLabel));
		}

		// one serie for each bar column
		chart.series = [];
		chart.yAxis = [];

		for (var c = 0; c < columnCount; c++) {
			if (!isColumnBar(c)) continue;

			// get/create axis for column unit
			var yAxisIndex = -1;
			var unit = getColumnUnit(c);
			for (var cy = 0; cy < chart.yAxis.length; cy++) if (chart.yAxis[cy].unit == unit) yAxisIndex = cy;
			if (yAxisIndex < 0) {

				// not found: create new axis with no title and unit
				yAxisIndex = chart.yAxis.length;
				chart.yAxis.push({
					unit: unit,
					title: { text: "" },
					labels: { format: '{value} ' + (unit ? unit : '') },
					reversedStacks: (typeof options['reversedStacks'] == 'undefined' ? false : (!!options['reversedStacks']))
				});
			}

			// serie's name, stack and color
			var serie = {
					name: getColumnLabel(c),
					stack: getColumnStack(c),
					yAxis: yAxisIndex,
					colIndex: c, // for pointFormatter
					// let Highcharts handle smart colors
					// color: hex2rgba(smartColorsBar[chart.series.length % smartColorsBar.length], alpha),
					data: []
			};

			/*
			// test line serie combined with the bars or columns
			if (turn_this_column_into_a_line_serie) {
				serie.type = 'line';
				serie.dashStyle= "ShortDot";
				serie.color = 'gray';
			}
			 */

			// data: one value per row
			var maxValue = null;
			for (var r = 0; r < rowCount; r++) {
				if (skipRow(r)) continue;
				var value = getValueAt(r,c);
				rowIndexByPoint[serie.data.length] = r;
				serie.data.push(value);
			}

			chart.series.push(serie);
		}

		// auto height based on number of bars
		if (this.autoHeight > 0 && type == 'bar') {
			var stacks = {};
			chart.chart.height = 100; // margin
			for (var s = 0; s < chart.series.length; s++) {
				if (chart.series[s].stack in stacks) continue; // count height only once per stack
				stacks[chart.series[s].stack] = true;
				chart.chart.height += chart.series[s].data.length * this.autoHeight;
			}
		}

		// render chart
		$('#' + divId).highcharts(chart, function (chart) {

			var widthColumn = null;
			if (chart.series[0]) $.each(chart.series[0].points, function(pointIndex, p) {

				// check if reference_columns attribute is set on rows, otherwise break loop here
				var rowIndex = rowIndexByPoint[pointIndex];
				var reference_columns = self.getRowAttribute(rowIndex, 'reference_columns');
				if (!reference_columns) return false;

				// update y axis max in case some reference value exceeds it
				$.each(reference_columns, function(i, reference) {
					var reference_value = self.getValueAt(rowIndex, self.getColumnIndex(reference.column));
					if (chart.yAxis[0].max < reference_value) chart.yAxis[0].setExtremes(null,reference_value);
				});

			});

			if (chart.series[0]) $.each(chart.series[0].points, function(pointIndex, p) {

				// check if reference_columns attribute is set on rows, otherwise break loop here
				var rowIndex = rowIndexByPoint[pointIndex];
				var reference_columns = self.getRowAttribute(rowIndex, 'reference_columns');
				if (!reference_columns) return false;

				// determine width of columns (only once)
				if (widthColumn === null) {
					var lastX = null;
					widthColumn = 0;
					$.each(chart.series[0].points, function(i, p) {
						if (lastX) widthColumn = p.plotX - lastX;
						lastX = p.plotX;
					});
					if (widthColumn == 0) widthColumn = chart.plotWidth;
					widthColumn *= 0.9;
				}

				// for each reference column
				$.each(reference_columns, function(i, reference) {

					// get reference value
					var reference_value = self.getValueAt(rowIndex, self.getColumnIndex(reference.column));

					// get line style
					var attributes = { 'stroke-width': 2, stroke: 'black', zIndex: 3 };
					if (reference.style) for (var attr in reference.style) attributes[attr] = reference.style[attr];

					// draw a line at Y = reference value
					var yPosition = chart.yAxis[0].toPixels(reference_value);
					var xPosition = chart.plotLeft + p.plotX - widthColumn / 2;
					chart.renderer.path(['M', xPosition, yPosition, 'L', xPosition + widthColumn, yPosition]).attr(attributes).add();

				});
			});
		});

		if (options.noDataMessage) {
			var container = $('#' + divId).highcharts();
			if (chart.series.length == 0) container.showLoading(options.noDataMessage);
		}
	}

	// TODO: do not assign options local to this function on "this"... name conflicts
	this.autoHeight = this.autoHeight_fun;
};

/**
 * renderStackedBarChart
 * Render open flash stacked bar chart for the data contained in the table model
 * @param divId
 * @param title
 * @param labelColumnIndexOrName
 * @param options: same as renderBarChart
 * @return
 */
EditableGrid.prototype.renderStackedBarChart = function(divId, title, labelColumnIndexOrName, options)
{
	options = options || {};
	options.stacking = 'normal';
	return this.renderBarChart(divId, title, labelColumnIndexOrName, options);
};

/**
 * renderPieChart
 * @param divId
 * @param title
 * @param valueColumnIndexOrName
 * @param labelColumnIndexOrName: if same as valueColumnIndexOrName, the chart will display the frequency of values in this column
 * @param options: startAngle (0), bgColor (transparent), alpha (0.9), limit (0), gradientFill (true)
 * @return
 */
EditableGrid.prototype.renderPieChart = function(divId, title, valueColumnIndexOrName, labelColumnIndexOrName, options)
{
	// default options
	this.startAngle = 0;
	this.bgColor = null; // transparent
	this.alpha = 0.9;
	this.limit = 0;
	this.pie3d = false;
	this.gradientFill = true;

	// override default options with the ones given
	if (options) for (var p in options) this[p] = options[p];

	with (this) {

		if (EditableGrid_check_lib === null) EditableGrid_check_lib = checkChartLib();
		if (!EditableGrid_check_lib) return false;

		// useful values
		labelColumnIndexOrName = labelColumnIndexOrName || 0;
		title = (typeof title == 'undefined' || title === null) ? getColumnLabel(valueColumnIndexOrName) : title;
		var cValue = getColumnIndex(valueColumnIndexOrName);
		var cLabel = getColumnIndex(labelColumnIndexOrName);
		var rowCount = getRowCount() - (ignoreLastRow ? 1 : 0);
		if (limit > 0 && rowCount > limit) rowCount = limit;

		// check the column is numerical
		var type = getColumnType(valueColumnIndexOrName);
		if (type != "double" && type != "integer" && cValue != cLabel) return false;

		// base chart
		var chart = {

				chart: {
					type: 'pie',
					backgroundColor: bgColor,
					plotBackgroundColor: bgColor,
					plotBorderWidth: 0,
					options3d: {
						enabled: pie3d,
						alpha: 45
					}

				},

				credits: {
					enabled: false
				},

				title: {
					text: title
				},

				tooltip: {
					pointFormat: '{series.name}: {point.percentage:.1f}%'
				},

				plotOptions: {
					pie: {
						dataLabels: {
							enabled: true,
							format: cValue == cLabel ? '{point.name}' : '{point.name}
{point.formattedValue}'
						},
						startAngle: startAngle
					}
				}
		};

		chart.series = [];
		var serie = { name: title, data: [] };
		chart.series.push(serie);

		if (cValue == cLabel) {

			// frequency pie chart
			var distinctValues = {};
			for (var r = 0; r < rowCount; r++) {
				if (skipRow(r)) continue;
				var rowValue = getValueAt(r,cValue);
				if (rowValue in distinctValues) distinctValues[rowValue]++;
				else distinctValues[rowValue] = 1;
			}

			for (var value in distinctValues) {
				var occurences = distinctValues[value];
				serie.data.push({
					y : occurences,
					name: value,
					formattedValue: value
					// let Highcharts handle smart colors
					// color: hex2rgba(smartColorsBar[serie.data.length % smartColorsPie.length], alpha)
				});
			}
			chart.series.push(serie);
		}
		else {

			for (var r = 0; r < rowCount; r++) {
				if (skipRow(r)) continue;
				var value = getValueAt(r,cValue);
				var label = getRowAttribute(r, "barlabel"); // if there is a barlabel attribute, use it and ignore labelColumn
				if (value !== null && !isNaN(value)) serie.data.push({
					y : value,
					name: (label ? label : getValueAt(r,cLabel)),
					formattedValue: this.getFormattedValue(cValue, value)
					// let Highcharts handle smart colors
					// color: hex2rgba(smartColorsBar[serie.data.length % smartColorsPie.length], alpha)
				});
			}
		}

		$('#' + divId).highcharts(chart);
		return serie.data.length;
	}
};

/**
 * clearChart
 * @param divId
 * @return
 */
EditableGrid.prototype.clearChart = function(divId)
{
	$('#' + divId).html('');
};


text:
package com.itheima.mobilesafe.utils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.text.BreakIterator;
import java.util.List;

import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.content.Context;

/**
 * 系统信息
 * @author libo
 *
 */
public class SystemInfoUtils {

	/**
	 * 获取正在运行的进程数量
	 * @return
	 */
	public static int getRunningProcessCount(Context context) {

		ActivityManager  am = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
		List<RunningAppProcessInfo> infos = am.getRunningAppProcesses();
		return infos.size();
	}

	/**
	 * 剩余内存
	 */
	public static long getAvailMem(Context context) {
		ActivityManager  am = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
		MemoryInfo outInfo = new MemoryInfo();
		am.getMemoryInfo(outInfo);
		return outInfo.availMem;
	}

	/**
	 * 总内存
	 */
	public static long getTotalMem(Context context) {
//		ActivityManager  am = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
//		MemoryInfo outInfo = new MemoryInfo();
//		am.getMemoryInfo(outInfo);
//		return outInfo.totalMem;

		File file = new File("/proc/meminfo");
		try {
			FileInputStream fis = new FileInputStream(file);
			BufferedReader bf = new BufferedReader(new InputStreamReader(fis));
			String line = bf.readLine();
			StringBuilder sb = new StringBuilder();
			for(char c: line.toCharArray())
			{
				if (c >= '0' && c <='9') {
					sb.append(c);
				}
			}
			return Long.parseLong(sb.toString()) * 1024;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return 0;
		}
	}
}