text:
(function($) {
    // Class: $.jqplot.LineRenderer
    // The default line renderer for jqPlot, this class has no options beyond the <Series> class.
    // Draws series as a line.
    $.jqplot.LineRenderer = function(){
        this.shapeRenderer = new $.jqplot.ShapeRenderer();
        this.shadowRenderer = new $.jqplot.ShadowRenderer();
    };

    // called with scope of series.
    $.jqplot.LineRenderer.prototype.init = function(options, plot) {
        // Group: Properties
        //
        options = options || {};
        this._type='line';
        this.renderer.animation = {
            show: false,
            direction: 'left',
            speed: 2500,
            _supported: true
        };
        // prop: smooth
        // True to draw a smoothed (interpolated) line through the data points
        // with automatically computed number of smoothing points.
        // Set to an integer number > 2 to specify number of smoothing points
        // to use between each data point.
        this.renderer.smooth = false;  // true or a number > 2 for smoothing.
        this.renderer.tension = null; // null to auto compute or a number typically > 6.  Fewer points requires higher tension.
        // prop: constrainSmoothing
        // True to use a more accurate smoothing algorithm that will
        // not overshoot any data points.  False to allow overshoot but
        // produce a smoother looking line.
        this.renderer.constrainSmoothing = true;
        // this is smoothed data in grid coordinates, like gridData
        this.renderer._smoothedData = [];
        // this is smoothed data in plot units (plot coordinates), like plotData.
        this.renderer._smoothedPlotData = [];
        this.renderer._hiBandGridData = [];
        this.renderer._lowBandGridData = [];
        this.renderer._hiBandSmoothedData = [];
        this.renderer._lowBandSmoothedData = [];

        // prop: bandData
        // Data used to draw error bands or confidence intervals above/below a line.
        //
        // bandData can be input in 3 forms.  jqPlot will figure out which is the
        // low band line and which is the high band line for all forms:
        //
        // A 2 dimensional array like [[yl1, yl2, ...], [yu1, yu2, ...]] where
        // [yl1, yl2, ...] are y values of the lower line and
        // [yu1, yu2, ...] are y values of the upper line.
        // In this case there must be the same number of y data points as data points
        // in the series and the bands will inherit the x values of the series.
        //
        // A 2 dimensional array like [[[xl1, yl1], [xl2, yl2], ...], [[xh1, yh1], [xh2, yh2], ...]]
        // where [xl1, yl1] are x,y data points for the lower line and
        // [xh1, yh1] are x,y data points for the high line.
        // x values do not have to correspond to the x values of the series and can
        // be of any arbitrary length.
        //
        // Can be of form [[yl1, yu1], [yl2, yu2], [yl3, yu3], ...] where
        // there must be 3 or more arrays and there must be the same number of arrays
        // as there are data points in the series.  In this case,
        // [yl1, yu1] specifies the lower and upper y values for the 1st
        // data point and so on.  The bands will inherit the x
        // values from the series.
        this.renderer.bandData = [];

        // Group: bands
        // Banding around line, e.g error bands or confidence intervals.
        this.renderer.bands = {
            // prop: show
            // true to show the bands.  If bandData or interval is
            // supplied, show will be set to true by default.
            show: false,
            hiData: [],
            lowData: [],
            // prop: color
            // color of lines at top and bottom of bands [default: series color].
            color: this.color,
            // prop: showLines
            // True to show lines at top and bottom of bands [default: false].
            showLines: false,
            // prop: fill
            // True to fill area between bands [default: true].
            fill: true,
            // prop: fillColor
            // css color spec for filled area.  [default: series color].
            fillColor: null,
            _min: null,
            _max: null,
            // prop: interval
            // User specified interval above and below line for bands [default: '3%''].
            // Can be a value like 3 or a string like '3%'
            // or an upper/lower array like [1, -2] or ['2%', '-1.5%']
            interval: '3%'
        };

        var lopts = {highlightMouseOver: options.highlightMouseOver, highlightMouseDown: options.highlightMouseDown, highlightColor: options.highlightColor};

        delete (options.highlightMouseOver);
        delete (options.highlightMouseDown);
        delete (options.highlightColor);

        $.extend(true, this.renderer, options);

        this.renderer.options = options;

        // if we are given some band data, and bands aren't explicity set to false in options, turn them on.
        if (this.renderer.bandData.length > 1 && (!options.bands || options.bands.show == null)) {
            this.renderer.bands.show = true;
        }

        // if we are given an interval, and bands aren't explicity set to false in options, turn them on.
        else if (options.bands && options.bands.show == null && options.bands.interval != null) {
            this.renderer.bands.show = true;
        }

        // if plot is filled, turn off bands.
        if (this.fill) {
            this.renderer.bands.show = false;
        }

        if (this.renderer.bands.show) {
            this.renderer.initBands.call(this, this.renderer.options, plot);
        }

        // smoothing is not compatible with stacked lines, disable
        if (this._stack) {
            this.renderer.smooth = false;
        }

        // set the shape renderer options
        var opts = {lineJoin:this.lineJoin, lineCap:this.lineCap, fill:this.fill, isarc:false, strokeStyle:this.color, fillStyle:this.fillColor, lineWidth:this.lineWidth, linePattern:this.linePattern, closePath:this.fill};
        this.renderer.shapeRenderer.init(opts);

        var shadow_offset = options.shadowOffset;
        // set the shadow renderer options
        if (shadow_offset == null) {
            // scale the shadowOffset to the width of the line.
            if (this.lineWidth > 2.5) {
                shadow_offset = 1.25 * (1 + (Math.atan((this.lineWidth/2.5))/0.785398163 - 1)*0.6);
                // var shadow_offset = this.shadowOffset;
            }
            // for skinny lines, don't make such a big shadow.
            else {
                shadow_offset = 1.25 * Math.atan((this.lineWidth/2.5))/0.785398163;
            }
        }

        var sopts = {lineJoin:this.lineJoin, lineCap:this.lineCap, fill:this.fill, isarc:false, angle:this.shadowAngle, offset:shadow_offset, alpha:this.shadowAlpha, depth:this.shadowDepth, lineWidth:this.lineWidth, linePattern:this.linePattern, closePath:this.fill};
        this.renderer.shadowRenderer.init(sopts);
        this._areaPoints = [];
        this._boundingBox = [[],[]];

        if (!this.isTrendline && this.fill || this.renderer.bands.show) {
            // Group: Properties
            //
            // prop: highlightMouseOver
            // True to highlight area on a filled plot when moused over.
            // This must be false to enable highlightMouseDown to highlight when clicking on an area on a filled plot.
            this.highlightMouseOver = true;
            // prop: highlightMouseDown
            // True to highlight when a mouse button is pressed over an area on a filled plot.
            // This will be disabled if highlightMouseOver is true.
            this.highlightMouseDown = false;
            // prop: highlightColor
            // color to use when highlighting an area on a filled plot.
            this.highlightColor = null;
            // if user has passed in highlightMouseDown option and not set highlightMouseOver, disable highlightMouseOver
            if (lopts.highlightMouseDown && lopts.highlightMouseOver == null) {
                lopts.highlightMouseOver = false;
            }

            $.extend(true, this, {highlightMouseOver: lopts.highlightMouseOver, highlightMouseDown: lopts.highlightMouseDown, highlightColor: lopts.highlightColor});

            if (!this.highlightColor) {
                var fc = (this.renderer.bands.show) ? this.renderer.bands.fillColor : this.fillColor;
                this.highlightColor = $.jqplot.computeHighlightColors(fc);
            }
            // turn off (disable) the highlighter plugin
            if (this.highlighter) {
                this.highlighter.show = false;
            }
        }

        if (!this.isTrendline && plot) {
            plot.plugins.lineRenderer = {};
            plot.postInitHooks.addOnce(postInit);
            plot.postDrawHooks.addOnce(postPlotDraw);
            plot.eventListenerHooks.addOnce('jqplotMouseMove', handleMove);
            plot.eventListenerHooks.addOnce('jqplotMouseDown', handleMouseDown);
            plot.eventListenerHooks.addOnce('jqplotMouseUp', handleMouseUp);
            plot.eventListenerHooks.addOnce('jqplotClick', handleClick);
            plot.eventListenerHooks.addOnce('jqplotRightClick', handleRightClick);
        }

    };

    $.jqplot.LineRenderer.prototype.initBands = function(options, plot) {
        // use bandData if no data specified in bands option
        //var bd = this.renderer.bandData;
        var bd = options.bandData || [];
        var bands = this.renderer.bands;
        bands.hiData = [];
        bands.lowData = [];
        var data = this.data;
        bands._max = null;
        bands._min = null;
        // If 2 arrays, and each array greater than 2 elements, assume it is hi and low data bands of y values.
        if (bd.length == 2) {
            // Do we have an array of x,y values?
            // like [[[1,1], [2,4], [3,3]], [[1,3], [2,6], [3,5]]]
            if ($.isArray(bd[0][0])) {
                // since an arbitrary array of points, spin through all of them to determine max and min lines.

                var p;
                var bdminidx = 0, bdmaxidx = 0;
                for (var i = 0, l = bd[0].length; i<l; i++) {
                    p = bd[0][i];
                    if ((p[1] != null && p[1] > bands._max) || bands._max == null) {
                        bands._max = p[1];
                    }
                    if ((p[1] != null && p[1] < bands._min) || bands._min == null) {
                        bands._min = p[1];
                    }
                }
                for (var i = 0, l = bd[1].length; i<l; i++) {
                    p = bd[1][i];
                    if ((p[1] != null && p[1] > bands._max) || bands._max == null) {
                        bands._max = p[1];
                        bdmaxidx = 1;
                    }
                    if ((p[1] != null && p[1] < bands._min) || bands._min == null) {
                        bands._min = p[1];
                        bdminidx = 1;
                    }
                }

                if (bdmaxidx === bdminidx) {
                    bands.show = false;
                }

                bands.hiData = bd[bdmaxidx];
                bands.lowData = bd[bdminidx];
            }
            // else data is arrays of y values
            // like [[1,4,3], [3,6,5]]
            // must have same number of band data points as points in series
            else if (bd[0].length === data.length && bd[1].length === data.length) {
                var hi = (bd[0][0] > bd[1][0]) ? 0 : 1;
                var low = (hi) ? 0 : 1;
                for (var i=0, l=data.length; i < l; i++) {
                    bands.hiData.push([data[i][0], bd[hi][i]]);
                    bands.lowData.push([data[i][0], bd[low][i]]);
                }
            }

            // we don't have proper data array, don't show bands.
            else {
                bands.show = false;
            }
        }

        // if more than 2 arrays, have arrays of [ylow, yhi] values.
        // note, can't distinguish case of [[ylow, yhi], [ylow, yhi]] from [[ylow, ylow], [yhi, yhi]]
        // this is assumed to be of the latter form.
        else if (bd.length > 2 && !$.isArray(bd[0][0])) {
            var hi = (bd[0][0] > bd[0][1]) ? 0 : 1;
            var low = (hi) ? 0 : 1;
            for (var i=0, l=bd.length; i<l; i++) {
                bands.hiData.push([data[i][0], bd[i][hi]]);
                bands.lowData.push([data[i][0], bd[i][low]]);
            }
        }

        // don't have proper data, auto calculate
        else {
            var intrv = bands.interval;
            var a = null;
            var b = null;
            var afunc = null;
            var bfunc = null;

            if ($.isArray(intrv)) {
                a = intrv[0];
                b = intrv[1];
            }
            else {
                a = intrv;
            }

            if (isNaN(a)) {
                // we have a string
                if (a.charAt(a.length - 1) === '%') {
                    afunc = 'multiply';
                    a = parseFloat(a)/100 + 1;
                }
            }

            else {
                a = parseFloat(a);
                afunc = 'add';
            }

            if (b !== null && isNaN(b)) {
                // we have a string
                if (b.charAt(b.length - 1) === '%') {
                    bfunc = 'multiply';
                    b = parseFloat(b)/100 + 1;
                }
            }

            else if (b !== null) {
                b = parseFloat(b);
                bfunc = 'add';
            }

            if (a !== null) {
                if (b === null) {
                    b = -a;
                    bfunc = afunc;
                    if (bfunc === 'multiply') {
                        b += 2;
                    }
                }

                // make sure a always applies to hi band.
                if (a < b) {
                    var temp = a;
                    a = b;
                    b = temp;
                    temp = afunc;
                    afunc = bfunc;
                    bfunc = temp;
                }

                for (var i=0, l = data.length; i < l; i++) {
                    switch (afunc) {
                        case 'add':
                            bands.hiData.push([data[i][0], data[i][1] + a]);
                            break;
                        case 'multiply':
                            bands.hiData.push([data[i][0], data[i][1] * a]);
                            break;
                    }
                    switch (bfunc) {
                        case 'add':
                            bands.lowData.push([data[i][0], data[i][1] + b]);
                            break;
                        case 'multiply':
                            bands.lowData.push([data[i][0], data[i][1] * b]);
                            break;
                    }
                }
            }

            else {
                bands.show = false;
            }
        }

        var hd = bands.hiData;
        var ld = bands.lowData;
        for (var i = 0, l = hd.length; i<l; i++) {
            if ((hd[i][1] != null && hd[i][1] > bands._max) || bands._max == null) {
                bands._max = hd[i][1];
            }
        }
        for (var i = 0, l = ld.length; i<l; i++) {
            if ((ld[i][1] != null && ld[i][1] < bands._min) || bands._min == null) {
                bands._min = ld[i][1];
            }
        }

        // one last check for proper data
        // these don't apply any more since allowing arbitrary x,y values
        // if (bands.hiData.length != bands.lowData.length) {
        //     bands.show = false;
        // }

        // if (bands.hiData.length != this.data.length) {
        //     bands.show = false;
        // }

        if (bands.fillColor === null) {
            var c = $.jqplot.getColorComponents(bands.color);
            // now adjust alpha to differentiate fill
            c[3] = c[3] * 0.5;
            bands.fillColor = 'rgba(' + c[0] +', '+ c[1] +', '+ c[2] +', '+ c[3] + ')';
        }
    };

    function getSteps (d, f) {
        return (3.4182054+f) * Math.pow(d, -0.3534992);
    }

    function computeSteps (d1, d2) {
        var s = Math.sqrt(Math.pow((d2[0]- d1[0]), 2) + Math.pow ((d2[1] - d1[1]), 2));
        return 5.7648 * Math.log(s) + 7.4456;
    }

    function tanh (x) {
        var a = (Math.exp(2*x) - 1) / (Math.exp(2*x) + 1);
        return a;
    }

    //////////
    // computeConstrainedSmoothedData
    // An implementation of the constrained cubic spline interpolation
    // method as presented in:
    //
    // Kruger, CJC, Constrained Cubic Spine Interpolation for Chemical Engineering Applications
    // http://www.korf.co.uk/spline.pdf
    //
    // The implementation below borrows heavily from the sample Visual Basic
    // implementation by CJC Kruger found in http://www.korf.co.uk/spline.xls
    //
    /////////

    // called with scope of series
    function computeConstrainedSmoothedData (gd) {
        var smooth = this.renderer.smooth;
        var dim = this.canvas.getWidth();
        var xp = this._xaxis.series_p2u;
        var yp = this._yaxis.series_p2u;
        var steps =null;
        var _steps = null;
        var dist = gd.length/dim;
        var _smoothedData = [];
        var _smoothedPlotData = [];

        if (!isNaN(parseFloat(smooth))) {
            steps = parseFloat(smooth);
        }
        else {
            steps = getSteps(dist, 0.5);
        }

        var yy = [];
        var xx = [];

        for (var i=0, l = gd.length; i<l; i++) {
            yy.push(gd[i][1]);
            xx.push(gd[i][0]);
        }

        function dxx(x1, x0) {
            if (x1 - x0 == 0) {
                return Math.pow(10,10);
            }
            else {
                return x1 - x0;
            }
        }

        var A, B, C, D;
        // loop through each line segment.  Have # points - 1 line segments.  Nmber segments starting at 1.
        var nmax = gd.length - 1;
        for (var num = 1, gdl = gd.length; num<gdl; num++) {
            var gxx = [];
            var ggxx = [];
            // point at each end of segment.
            for (var j = 0; j < 2; j++) {
                var i = num - 1 + j; // point number, 0 to # points.

                if (i == 0 || i == nmax) {
                    gxx[j] = Math.pow(10, 10);
                }
                else if (yy[i+1] - yy[i] == 0 || yy[i] - yy[i-1] == 0) {
                    gxx[j] = 0;
                }
                else if (((xx[i+1] - xx[i]) / (yy[i+1] - yy[i]) + (xx[i] - xx[i-1]) / (yy[i] - yy[i-1])) == 0 ) {
                    gxx[j] = 0;
                }
                else if ( (yy[i+1] - yy[i]) * (yy[i] - yy[i-1]) < 0 ) {
                    gxx[j] = 0;
                }

                else {
                    gxx[j] = 2 / (dxx(xx[i + 1], xx[i]) / (yy[i + 1] - yy[i]) + dxx(xx[i], xx[i - 1]) / (yy[i] - yy[i - 1]));
                }
            }

            // Reset first derivative (slope) at first and last point
            if (num == 1) {
                // First point has 0 2nd derivative
                gxx[0] = 3 / 2 * (yy[1] - yy[0]) / dxx(xx[1], xx[0]) - gxx[1] / 2;
            }
            else if (num == nmax) {
                // Last point has 0 2nd derivative
                gxx[1] = 3 / 2 * (yy[nmax] - yy[nmax - 1]) / dxx(xx[nmax], xx[nmax - 1]) - gxx[0] / 2;
            }

            // Calc second derivative at points
            ggxx[0] = -2 * (gxx[1] + 2 * gxx[0]) / dxx(xx[num], xx[num - 1]) + 6 * (yy[num] - yy[num - 1]) / Math.pow(dxx(xx[num], xx[num - 1]), 2);
            ggxx[1] = 2 * (2 * gxx[1] + gxx[0]) / dxx(xx[num], xx[num - 1]) - 6 * (yy[num] - yy[num - 1]) / Math.pow(dxx(xx[num], xx[num - 1]), 2);

            // Calc constants for cubic interpolation
            D = 1 / 6 * (ggxx[1] - ggxx[0]) / dxx(xx[num], xx[num - 1]);
            C = 1 / 2 * (xx[num] * ggxx[0] - xx[num - 1] * ggxx[1]) / dxx(xx[num], xx[num - 1]);
            B = (yy[num] - yy[num - 1] - C * (Math.pow(xx[num], 2) - Math.pow(xx[num - 1], 2)) - D * (Math.pow(xx[num], 3) - Math.pow(xx[num - 1], 3))) / dxx(xx[num], xx[num - 1]);
            A = yy[num - 1] - B * xx[num - 1] - C * Math.pow(xx[num - 1], 2) - D * Math.pow(xx[num - 1], 3);

            var increment = (xx[num] - xx[num - 1]) / steps;
            var temp, tempx;

            for (var j = 0, l = steps; j < l; j++) {
                temp = [];
                tempx = xx[num - 1] + j * increment;
                temp.push(tempx);
                temp.push(A + B * tempx + C * Math.pow(tempx, 2) + D * Math.pow(tempx, 3));
                _smoothedData.push(temp);
                _smoothedPlotData.push([xp(temp[0]), yp(temp[1])]);
            }
        }

        _smoothedData.push(gd[i]);
        _smoothedPlotData.push([xp(gd[i][0]), yp(gd[i][1])]);

        return [_smoothedData, _smoothedPlotData];
    }

    ///////
    // computeHermiteSmoothedData
    // A hermite spline smoothing of the plot data.
    // This implementation is derived from the one posted
    // by krypin on the jqplot-users mailing list:
    //
    // http://groups.google.com/group/jqplot-users/browse_thread/thread/748be6a445723cea?pli=1
    //
    // with a blog post:
    //
    // http://blog.statscollector.com/a-plugin-renderer-for-jqplot-to-draw-a-hermite-spline/
    //
    // and download of the original plugin:
    //
    // http://blog.statscollector.com/wp-content/uploads/2010/02/jqplot.hermiteSplineRenderer.js
    //////////

    // called with scope of series
    function computeHermiteSmoothedData (gd) {
        var smooth = this.renderer.smooth;
        var tension = this.renderer.tension;
        var dim = this.canvas.getWidth();
        var xp = this._xaxis.series_p2u;
        var yp = this._yaxis.series_p2u;
        var steps =null;
        var _steps = null;
        var a = null;
        var a1 = null;
        var a2 = null;
        var slope = null;
        var slope2 = null;
        var temp = null;
        var t, s, h1, h2, h3, h4;
        var TiX, TiY, Ti1X, Ti1Y;
        var pX, pY, p;
        var sd = [];
        var spd = [];
        var dist = gd.length/dim;
        var min, max, stretch, scale, shift;
        var _smoothedData = [];
        var _smoothedPlotData = [];
        if (!isNaN(parseFloat(smooth))) {
            steps = parseFloat(smooth);
        }
        else {
            steps = getSteps(dist, 0.5);
        }
        if (!isNaN(parseFloat(tension))) {
            tension = parseFloat(tension);
        }

        for (var i=0, l = gd.length-1; i < l; i++) {

            if (tension === null) {
                slope = Math.abs((gd[i+1][1] - gd[i][1]) / (gd[i+1][0] - gd[i][0]));

                min = 0.3;
                max = 0.6;
                stretch = (max - min)/2.0;
                scale = 2.5;
                shift = -1.4;

                temp = slope/scale + shift;

                a1 = stretch * tanh(temp) - stretch * tanh(shift) + min;

                // if have both left and right line segments, will use  minimum tension.
                if (i > 0) {
                    slope2 = Math.abs((gd[i][1] - gd[i-1][1]) / (gd[i][0] - gd[i-1][0]));
                }
                temp = slope2/scale + shift;

                a2 = stretch * tanh(temp) - stretch * tanh(shift) + min;

                a = (a1 + a2)/2.0;

            }
            else {
                a = tension;
            }
            for (t=0; t < steps; t++) {
                s = t / steps;
                h1 = (1 + 2*s)*Math.pow((1-s),2);
                h2 = s*Math.pow((1-s),2);
                h3 = Math.pow(s,2)*(3-2*s);
                h4 = Math.pow(s,2)*(s-1);

                if (gd[i-1]) {
                    TiX = a * (gd[i+1][0] - gd[i-1][0]);
                    TiY = a * (gd[i+1][1] - gd[i-1][1]);
                } else {
                    TiX = a * (gd[i+1][0] - gd[i][0]);
                    TiY = a * (gd[i+1][1] - gd[i][1]);
                }
                if (gd[i+2]) {
                    Ti1X = a * (gd[i+2][0] - gd[i][0]);
                    Ti1Y = a * (gd[i+2][1] - gd[i][1]);
                } else {
                    Ti1X = a * (gd[i+1][0] - gd[i][0]);
                    Ti1Y = a * (gd[i+1][1] - gd[i][1]);
                }

                pX = h1*gd[i][0] + h3*gd[i+1][0] + h2*TiX + h4*Ti1X;
                pY = h1*gd[i][1] + h3*gd[i+1][1] + h2*TiY + h4*Ti1Y;
                p = [pX, pY];

                _smoothedData.push(p);
                _smoothedPlotData.push([xp(pX), yp(pY)]);
            }
        }
        _smoothedData.push(gd[l]);
        _smoothedPlotData.push([xp(gd[l][0]), yp(gd[l][1])]);

        return [_smoothedData, _smoothedPlotData];
    }

    // setGridData
    // converts the user data values to grid coordinates and stores them
    // in the gridData array.
    // Called with scope of a series.
    $.jqplot.LineRenderer.prototype.setGridData = function(plot) {
        // recalculate the grid data
        var xp = this._xaxis.series_u2p;
        var yp = this._yaxis.series_u2p;
        var data = this._plotData;
        var pdata = this._prevPlotData;
        this.gridData = [];
        this._prevGridData = [];
        this.renderer._smoothedData = [];
        this.renderer._smoothedPlotData = [];
        this.renderer._hiBandGridData = [];
        this.renderer._lowBandGridData = [];
        this.renderer._hiBandSmoothedData = [];
        this.renderer._lowBandSmoothedData = [];
        var bands = this.renderer.bands;
        var hasNull = false;
        for (var i=0, l=data.length; i < l; i++) {
            // if not a line series or if no nulls in data, push the converted point onto the array.
            if (data[i][0] != null && data[i][1] != null) {
                this.gridData.push([xp.call(this._xaxis, data[i][0]), yp.call(this._yaxis, data[i][1])]);
            }
            // else if there is a null, preserve it.
            else if (data[i][0] == null) {
                hasNull = true;
                this.gridData.push([null, yp.call(this._yaxis, data[i][1])]);
            }
            else if (data[i][1] == null) {
                hasNull = true;
                this.gridData.push([xp.call(this._xaxis, data[i][0]), null]);
            }
            // if not a line series or if no nulls in data, push the converted point onto the array.
            if (pdata[i] != null && pdata[i][0] != null && pdata[i][1] != null) {
                this._prevGridData.push([xp.call(this._xaxis, pdata[i][0]), yp.call(this._yaxis, pdata[i][1])]);
            }
            // else if there is a null, preserve it.
            else if (pdata[i] != null && pdata[i][0] == null) {
                this._prevGridData.push([null, yp.call(this._yaxis, pdata[i][1])]);
            }
            else if (pdata[i] != null && pdata[i][0] != null && pdata[i][1] == null) {
                this._prevGridData.push([xp.call(this._xaxis, pdata[i][0]), null]);
            }
        }

        // don't do smoothing or bands on broken lines.
        if (hasNull) {
            this.renderer.smooth = false;
            if (this._type === 'line') {
                bands.show = false;
            }
        }

        if (this._type === 'line' && bands.show) {
            for (var i=0, l=bands.hiData.length; i<l; i++) {
                this.renderer._hiBandGridData.push([xp.call(this._xaxis, bands.hiData[i][0]), yp.call(this._yaxis, bands.hiData[i][1])]);
            }
            for (var i=0, l=bands.lowData.length; i<l; i++) {
                this.renderer._lowBandGridData.push([xp.call(this._xaxis, bands.lowData[i][0]), yp.call(this._yaxis, bands.lowData[i][1])]);
            }
        }

        // calculate smoothed data if enough points and no nulls
        if (this._type === 'line' && this.renderer.smooth && this.gridData.length > 2) {
            var ret;
            if (this.renderer.constrainSmoothing) {
                ret = computeConstrainedSmoothedData.call(this, this.gridData);
                this.renderer._smoothedData = ret[0];
                this.renderer._smoothedPlotData = ret[1];

                if (bands.show) {
                    ret = computeConstrainedSmoothedData.call(this, this.renderer._hiBandGridData);
                    this.renderer._hiBandSmoothedData = ret[0];
                    ret = computeConstrainedSmoothedData.call(this, this.renderer._lowBandGridData);
                    this.renderer._lowBandSmoothedData = ret[0];
                }

                ret = null;
            }
            else {
                ret = computeHermiteSmoothedData.call(this, this.gridData);
                this.renderer._smoothedData = ret[0];
                this.renderer._smoothedPlotData = ret[1];

                if (bands.show) {
                    ret = computeHermiteSmoothedData.call(this, this.renderer._hiBandGridData);
                    this.renderer._hiBandSmoothedData = ret[0];
                    ret = computeHermiteSmoothedData.call(this, this.renderer._lowBandGridData);
                    this.renderer._lowBandSmoothedData = ret[0];
                }

                ret = null;
            }
        }
    };

    // makeGridData
    // converts any arbitrary data values to grid coordinates and
    // returns them.  This method exists so that plugins can use a series'
    // linerenderer to generate grid data points without overwriting the
    // grid data associated with that series.
    // Called with scope of a series.
    $.jqplot.LineRenderer.prototype.makeGridData = function(data, plot) {
        // recalculate the grid data
        var xp = this._xaxis.series_u2p;
        var yp = this._yaxis.series_u2p;
        var gd = [];
        var pgd = [];
        this.renderer._smoothedData = [];
        this.renderer._smoothedPlotData = [];
        this.renderer._hiBandGridData = [];
        this.renderer._lowBandGridData = [];
        this.renderer._hiBandSmoothedData = [];
        this.renderer._lowBandSmoothedData = [];
        var bands = this.renderer.bands;
        var hasNull = false;
        for (var i=0; i<data.length; i++) {
            // if not a line series or if no nulls in data, push the converted point onto the array.
            if (data[i][0] != null && data[i][1] != null) {

                // svandecappelle
                if (this._xaxis.ticks !== undefined && typeof(data[i][0]) === "string"){
                    gd.push([xp.call(this._xaxis, this._xaxis.ticks.indexOf(data[i][0]) + 1), yp.call(this._yaxis, data[i][1])]);
                }else{
                    gd.push([xp.call(this._xaxis, data[i][0]), yp.call(this._yaxis, data[i][1])]);
                }

                // Temp fixes #816: gd.push([xp.call(this._xaxis, data[i][0]), yp.call(this._yaxis, data[i][1])]);
            }
            // else if there is a null, preserve it.
            else if (data[i][0] == null) {
                hasNull = true;
                gd.push([null, yp.call(this._yaxis, data[i][1])]);
            }
            else if (data[i][1] == null) {
                hasNull = true;
                gd.push([xp.call(this._xaxis, data[i][0]), null]);
            }
        }

        // don't do smoothing or bands on broken lines.
        if (hasNull) {
            this.renderer.smooth = false;
            if (this._type === 'line') {
                bands.show = false;
            }
        }

        if (this._type === 'line' && bands.show) {
            for (var i=0, l=bands.hiData.length; i<l; i++) {
                this.renderer._hiBandGridData.push([xp.call(this._xaxis, bands.hiData[i][0]), yp.call(this._yaxis, bands.hiData[i][1])]);
            }
            for (var i=0, l=bands.lowData.length; i<l; i++) {
                this.renderer._lowBandGridData.push([xp.call(this._xaxis, bands.lowData[i][0]), yp.call(this._yaxis, bands.lowData[i][1])]);
            }
        }

        if (this._type === 'line' && this.renderer.smooth && gd.length > 2) {
            var ret;
            if (this.renderer.constrainSmoothing) {
                ret = computeConstrainedSmoothedData.call(this, gd);
                this.renderer._smoothedData = ret[0];
                this.renderer._smoothedPlotData = ret[1];

                if (bands.show) {
                    ret = computeConstrainedSmoothedData.call(this, this.renderer._hiBandGridData);
                    this.renderer._hiBandSmoothedData = ret[0];
                    ret = computeConstrainedSmoothedData.call(this, this.renderer._lowBandGridData);
                    this.renderer._lowBandSmoothedData = ret[0];
                }

                ret = null;
            }
            else {
                ret = computeHermiteSmoothedData.call(this, gd);
                this.renderer._smoothedData = ret[0];
                this.renderer._smoothedPlotData = ret[1];

                if (bands.show) {
                    ret = computeHermiteSmoothedData.call(this, this.renderer._hiBandGridData);
                    this.renderer._hiBandSmoothedData = ret[0];
                    ret = computeHermiteSmoothedData.call(this, this.renderer._lowBandGridData);
                    this.renderer._lowBandSmoothedData = ret[0];
                }

                ret = null;
            }
        }
        return gd;
    };

    // called within scope of series.
    $.jqplot.LineRenderer.prototype.draw = function(ctx, gd, options, plot) {
        var i;
        // get a copy of the options, so we don't modify the original object.
        var opts = $.extend(true, {}, options);
        var shadow = (opts.shadow != undefined) ? opts.shadow : this.shadow;
        var showLine = (opts.showLine != undefined) ? opts.showLine : this.showLine;
        var fill = (opts.fill != undefined) ? opts.fill : this.fill;
        var fillAndStroke = (opts.fillAndStroke != undefined) ? opts.fillAndStroke : this.fillAndStroke;
        var xmin, ymin, xmax, ymax;
        ctx.save();
        if (gd.length) {
            if (showLine) {
                // if we fill, we'll have to add points to close the curve.
                if (fill) {
                    if (this.fillToZero) {
                        // have to break line up into shapes at axis crossings
                        var negativeColor = this.negativeColor;
                        if (! this.useNegativeColors) {
                            negativeColor = opts.fillStyle;
                        }
                        var isnegative = false;
                        var posfs = opts.fillStyle;

                        // if stoking line as well as filling, get a copy of line data.
                        if (fillAndStroke) {
                            var fasgd = gd.slice(0);
                        }
                        // if not stacked, fill down to axis
                        if (this.index == 0 || !this._stack) {

                            var tempgd = [];
                            var pd = (this.renderer.smooth) ? this.renderer._smoothedPlotData : this._plotData;
                            this._areaPoints = [];
                            var pyzero = this._yaxis.series_u2p(this.fillToValue);
                            var pxzero = this._xaxis.series_u2p(this.fillToValue);

                            opts.closePath = true;

                            if (this.fillAxis == 'y') {
                                tempgd.push([gd[0][0], pyzero]);
                                this._areaPoints.push([gd[0][0], pyzero]);

                                for (var i=0; i<gd.length-1; i++) {
                                    tempgd.push(gd[i]);
                                    this._areaPoints.push(gd[i]);
                                    // do we have an axis crossing?
                                    if (pd[i][1] * pd[i+1][1] <= 0) {
                                        if (pd[i][1] < 0) {
                                            isnegative = true;
                                            opts.fillStyle = negativeColor;
                                        }
                                        else {
                                            isnegative = false;
                                            opts.fillStyle = posfs;
                                        }

                                        var xintercept = gd[i][0] + (gd[i+1][0] - gd[i][0]) * (pyzero-gd[i][1])/(gd[i+1][1] - gd[i][1]);
                                        tempgd.push([xintercept, pyzero]);
                                        this._areaPoints.push([xintercept, pyzero]);
                                        // now draw this shape and shadow.
                                        if (shadow) {
                                            this.renderer.shadowRenderer.draw(ctx, tempgd, opts);
                                        }
                                        this.renderer.shapeRenderer.draw(ctx, tempgd, opts);
                                        // now empty temp array and continue
                                        tempgd = [[xintercept, pyzero]];
                                        // this._areaPoints = [[xintercept, pyzero]];
                                    }
                                }
                                if (pd[gd.length-1][1] < 0) {
                                    isnegative = true;
                                    opts.fillStyle = negativeColor;
                                }
                                else {
                                    isnegative = false;
                                    opts.fillStyle = posfs;
                                }
                                tempgd.push(gd[gd.length-1]);
                                this._areaPoints.push(gd[gd.length-1]);
                                tempgd.push([gd[gd.length-1][0], pyzero]);
                                this._areaPoints.push([gd[gd.length-1][0], pyzero]);
                            }
                            // now draw the last area.
                            if (shadow) {
                                this.renderer.shadowRenderer.draw(ctx, tempgd, opts);
                            }
                            this.renderer.shapeRenderer.draw(ctx, tempgd, opts);

                            // var gridymin = this._yaxis.series_u2p(0);
                            // // IE doesn't return new length on unshift
                            // gd.unshift([gd[0][0], gridymin]);
                            // len = gd.length;
                            // gd.push([gd[len - 1][0], gridymin]);
                        }
                        // if stacked, fill to line below
                        else {
                            var prev = this._prevGridData;
                            for (var i=prev.length; i>0; i--) {
                                gd.push(prev[i-1]);
                                // this._areaPoints.push(prev[i-1]);
                            }
                            if (shadow) {
                                this.renderer.shadowRenderer.draw(ctx, gd, opts);
                            }
                            this._areaPoints = gd;
                            this.renderer.shapeRenderer.draw(ctx, gd, opts);
                        }
                    }
                    /////////////////////////
                    // Not filled to zero
                    ////////////////////////
                    else {
                        // if stoking line as well as filling, get a copy of line data.
                        if (fillAndStroke) {
                            var fasgd = gd.slice(0);
                        }
                        // if not stacked, fill down to axis
                        if (this.index == 0 || !this._stack) {
                            // var gridymin = this._yaxis.series_u2p(this._yaxis.min) - this.gridBorderWidth / 2;
                            var gridymin = ctx.canvas.height;
                            // IE doesn't return new length on unshift
                            gd.unshift([gd[0][0], gridymin]);
                            var len = gd.length;
                            gd.push([gd[len - 1][0], gridymin]);
                        }
                        // if stacked, fill to line below
                        else {
                            var prev = this._prevGridData;
                            for (var i=prev.length; i>0; i--) {
                                gd.push(prev[i-1]);
                            }
                        }
                        this._areaPoints = gd;

                        if (shadow) {
                            this.renderer.shadowRenderer.draw(ctx, gd, opts);
                        }

                        this.renderer.shapeRenderer.draw(ctx, gd, opts);
                    }
                    if (fillAndStroke) {
                        var fasopts = $.extend(true, {}, opts, {fill:false, closePath:false});
                        this.renderer.shapeRenderer.draw(ctx, fasgd, fasopts);
                        //////////
                        // TODO: figure out some way to do shadows nicely
                        // if (shadow) {
                        //     this.renderer.shadowRenderer.draw(ctx, fasgd, fasopts);
                        // }
                        // now draw the markers
                        if (this.markerRenderer.show) {
                            if (this.renderer.smooth) {
                                fasgd = this.gridData;
                            }
                            for (i=0; i<fasgd.length; i++) {
                                this.markerRenderer.draw(fasgd[i][0], fasgd[i][1], ctx, opts.markerOptions);
                            }
                        }
                    }
                }
                else {

                    if (this.renderer.bands.show) {
                        var bdat;
                        var bopts = $.extend(true, {}, opts);
                        if (this.renderer.bands.showLines) {
                            bdat = (this.renderer.smooth) ? this.renderer._hiBandSmoothedData : this.renderer._hiBandGridData;
                            this.renderer.shapeRenderer.draw(ctx, bdat, opts);
                            bdat = (this.renderer.smooth) ? this.renderer._lowBandSmoothedData : this.renderer._lowBandGridData;
                            this.renderer.shapeRenderer.draw(ctx, bdat, bopts);
                        }

                        if (this.renderer.bands.fill) {
                            if (this.renderer.smooth) {
                                bdat = this.renderer._hiBandSmoothedData.concat(this.renderer._lowBandSmoothedData.reverse());
                            }
                            else {
                                bdat = this.renderer._hiBandGridData.concat(this.renderer._lowBandGridData.reverse());
                            }
                            this._areaPoints = bdat;
                            bopts.closePath = true;
                            bopts.fill = true;
                            bopts.fillStyle = this.renderer.bands.fillColor;
                            this.renderer.shapeRenderer.draw(ctx, bdat, bopts);
                        }
                    }

                    if (shadow) {
                        this.renderer.shadowRenderer.draw(ctx, gd, opts);
                    }

                    this.renderer.shapeRenderer.draw(ctx, gd, opts);
                }
            }
            // calculate the bounding box
            var xmin = xmax = ymin = ymax = null;
            for (i=0; i<this._areaPoints.length; i++) {
                var p = this._areaPoints[i];
                if (xmin > p[0] || xmin == null) {
                    xmin = p[0];
                }
                if (ymax < p[1] || ymax == null) {
                    ymax = p[1];
                }
                if (xmax < p[0] || xmax == null) {
                    xmax = p[0];
                }
                if (ymin > p[1] || ymin == null) {
                    ymin = p[1];
                }
            }

            if (this.type === 'line' && this.renderer.bands.show) {
                ymax = this._yaxis.series_u2p(this.renderer.bands._min);
                ymin = this._yaxis.series_u2p(this.renderer.bands._max);
            }

            this._boundingBox = [[xmin, ymax], [xmax, ymin]];

            // now draw the markers
            if (this.markerRenderer.show && !fill) {
                if (this.renderer.smooth) {
                    gd = this.gridData;
                }
                for (i=0; i<gd.length; i++) {
                    if (gd[i][0] != null && gd[i][1] != null) {
                        this.markerRenderer.draw(gd[i][0], gd[i][1], ctx, opts.markerOptions);
                    }
                }
            }
        }

        ctx.restore();
    };

    $.jqplot.LineRenderer.prototype.drawShadow = function(ctx, gd, options) {
        // This is a no-op, shadows drawn with lines.
    };

    // called with scope of plot.
    // make sure to not leave anything highlighted.
    function postInit(target, data, options) {
        for (var i=0; i<this.series.length; i++) {
            if (this.series[i].renderer.constructor == $.jqplot.LineRenderer) {
                // don't allow mouseover and mousedown at same time.
                if (this.series[i].highlightMouseOver) {
                    this.series[i].highlightMouseDown = false;
                }
            }
        }
    }

    // called within context of plot
    // create a canvas which we can draw on.
    // insert it before the eventCanvas, so eventCanvas will still capture events.
    function postPlotDraw() {
        // Memory Leaks patch
        if (this.plugins.lineRenderer && this.plugins.lineRenderer.highlightCanvas) {
          this.plugins.lineRenderer.highlightCanvas.resetCanvas();
          this.plugins.lineRenderer.highlightCanvas = null;
        }

        this.plugins.lineRenderer.highlightedSeriesIndex = null;
        this.plugins.lineRenderer.highlightCanvas = new $.jqplot.GenericCanvas();

        this.eventCanvas._elem.before(this.plugins.lineRenderer.highlightCanvas.createElement(this._gridPadding, 'jqplot-lineRenderer-highlight-canvas', this._plotDimensions, this));
        this.plugins.lineRenderer.highlightCanvas.setContext();
        this.eventCanvas._elem.bind('mouseleave', {plot:this}, function (ev) { unhighlight(ev.data.plot); });
    }

    function highlight (plot, sidx, pidx, points) {
        var s = plot.series[sidx];
        var canvas = plot.plugins.lineRenderer.highlightCanvas;
        canvas._ctx.clearRect(0,0,canvas._ctx.canvas.width, canvas._ctx.canvas.height);
        s._highlightedPoint = pidx;
        plot.plugins.lineRenderer.highlightedSeriesIndex = sidx;
        var opts = {fillStyle: s.highlightColor};
        if (s.type === 'line' && s.renderer.bands.show) {
            opts.fill = true;
            opts.closePath = true;
        }
        s.renderer.shapeRenderer.draw(canvas._ctx, points, opts);
        canvas = null;
    }

    function unhighlight (plot) {
        var canvas = plot.plugins.lineRenderer.highlightCanvas;
        canvas._ctx.clearRect(0,0, canvas._ctx.canvas.width, canvas._ctx.canvas.height);
        for (var i=0; i<plot.series.length; i++) {
            plot.series[i]._highlightedPoint = null;
        }
        plot.plugins.lineRenderer.highlightedSeriesIndex = null;
        plot.target.trigger('jqplotDataUnhighlight');
        canvas = null;
    }

    function handleMove(ev, gridpos, datapos, neighbor, plot) {
        if (neighbor) {
            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
            var evt1 = jQuery.Event('jqplotDataMouseOver');
            evt1.pageX = ev.pageX;
            evt1.pageY = ev.pageY;
            plot.target.trigger(evt1, ins);
            if (plot.series[ins[0]].highlightMouseOver && !(ins[0] == plot.plugins.lineRenderer.highlightedSeriesIndex)) {
                var evt = jQuery.Event('jqplotDataHighlight');
                evt.which = ev.which;
                evt.pageX = ev.pageX;
                evt.pageY = ev.pageY;
                plot.target.trigger(evt, ins);
                highlight (plot, neighbor.seriesIndex, neighbor.pointIndex, neighbor.points);
            }
        }
        else if (neighbor == null) {
            unhighlight (plot);
        }
    }

    function handleMouseDown(ev, gridpos, datapos, neighbor, plot) {
        if (neighbor) {
            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
            if (plot.series[ins[0]].highlightMouseDown && !(ins[0] == plot.plugins.lineRenderer.highlightedSeriesIndex)) {
                var evt = jQuery.Event('jqplotDataHighlight');
                evt.which = ev.which;
                evt.pageX = ev.pageX;
                evt.pageY = ev.pageY;
                plot.target.trigger(evt, ins);
                highlight (plot, neighbor.seriesIndex, neighbor.pointIndex, neighbor.points);
            }
        }
        else if (neighbor == null) {
            unhighlight (plot);
        }
    }

    function handleMouseUp(ev, gridpos, datapos, neighbor, plot) {
        var idx = plot.plugins.lineRenderer.highlightedSeriesIndex;
        if (idx != null && plot.series[idx].highlightMouseDown) {
            unhighlight(plot);
        }
    }

    function handleClick(ev, gridpos, datapos, neighbor, plot) {
        if (neighbor) {
            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
            var evt = jQuery.Event('jqplotDataClick');
            evt.which = ev.which;
            evt.pageX = ev.pageX;
            evt.pageY = ev.pageY;
            plot.target.trigger(evt, ins);
        }
    }

    function handleRightClick(ev, gridpos, datapos, neighbor, plot) {
        if (neighbor) {
            var ins = [neighbor.seriesIndex, neighbor.pointIndex, neighbor.data];
            var idx = plot.plugins.lineRenderer.highlightedSeriesIndex;
            if (idx != null && plot.series[idx].highlightMouseDown) {
                unhighlight(plot);
            }
            var evt = jQuery.Event('jqplotDataRightClick');
            evt.which = ev.which;
            evt.pageX = ev.pageX;
            evt.pageY = ev.pageY;
            plot.target.trigger(evt, ins);
        }
    }

})(jQuery);


text:
{{'required' | translate}}
{{'value_must_be_number' | translate}}
{{'value_must_be_posInt' | translate}}
{{'value_must_be_negInt' | translate}}
{{'value_must_be_zeroPositiveInt' | translate}}
{{'value_must_be_int' | translate}}
{{'date_required' | translate}} ({{dhis2CalendarFormat.keyDateFormat}})
{{'future_date_not_allowed' | translate}}
{{'option_required' | translate}}
{{'latitude_required' | translate}}
{{'longitude_required' | translate}}
{{'latitude_longitude_required' | translate}}
{{'value_not_unique' | translate}}
{{'value_must_be_email' | translate}}
{{'url_error' | translate}}

redpajama_set_name: RedPajamaGithub


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

class SecretHandshake
{
  public static string[] Commands(int command)
  {
    var result = Convert.ToString(command, 2);
    var commands = new List<string>();
    for (var c = result.Length - 1; c >= 0; c--)
    {
      var current = char.GetNumericValue(result[c]).ToString().PadRight(result.Length - c, '0');
      switch (current)
      {
        case "1":
          commands.Add("wink");
          break;
        case "10":
          commands.Add("double blink");
          break;
        case "100":
          commands.Add("close your eyes");
          break;
        case "1000":
          commands.Add("jump");
          break;
        case "10000":
          commands.Reverse();
          break;
      }
    }
    return commands.ToArray();
  }
}


text:
import $ from 'jquery';

import {Base} from './Base';

export const RadioButtonGroupInput = Base.extend({
  values: function() {
    return this.$el.find('input').map(function() {
      return $(this).attr('value');
    }).get();
  },

  enabledValues: function() {
    return this.$el.find('input:not([disabled])').map(function() {
      return $(this).attr('value');
    }).get();
  }
});


text:
package com.clover.kitchenscreen;

import android.app.Notification;
import android.app.Service;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Binder;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.util.Log;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

public class PrintService extends Service {
  private static final Handler handler = new Handler(Looper.getMainLooper());

  public class PrintBinder extends Binder {
    PrintService getService() {
      return PrintService.this;
    }
  }

  public static interface Listener {
    void onBitmapReceived(Bitmap bitmap);
  }

  public static final String ACTION_START = "com.clover.kitchenscreen.START";
  public static final String ACTION_STOP = "com.clover.kitchenscreen.STOP";

  private static final String TAG = PrintService.class.getName();

  private final Executor exec = Executors.newSingleThreadExecutor();
  private final IBinder binder = new PrintBinder();
  private PrintServer server;
  private Listener listener;

  @Override
  public void onCreate() {
    super.onCreate();
  }

  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
    if (ACTION_START.equals(intent.getAction())) {
      startServer();
    } else if (ACTION_STOP.equals(intent.getAction())) {
      stopServer();
    }

    return START_NOT_STICKY;
  }

  public void setListener(Listener listener) {
    this.listener = listener;
  }

  public void removeListener() {
    listener = null;
  }

  private void startServer() {
    if (server == null) {
      server = new PrintServer(PrintServer.PORT) {
        @Override
        protected void onReceiptBitmapReceived(final Bitmap bitmap) {
          if (listener != null) {
            handler.post(new Runnable() {
              @Override
              public void run() {
                listener.onBitmapReceived(bitmap);
              }
            });
          }
        }
      };
      server.start();

      Notification n = new Notification.Builder(this)
          .setSmallIcon(android.R.drawable.stat_notify_sync)
          .setContentTitle("Clover Kitchen Screen Print Service")
          .setContentText("Waiting for print jobs ...")
          .build();

      startForeground(100, n);
      Log.i(TAG, "server started at address: " + server.getAddress());
    } else {
      Log.i(TAG, "server already started at address: " + server.getAddress());
    }
  }

  private void stopServer() {
    if (server != null) {
      try {
        server.stop();
        Log.i(TAG, "server stopped at address: " + server.getAddress());
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        server = null;
      }
    } else {
      Log.i(TAG, "server not running");
    }
    stopForeground(true);
  }

  @Override
  public IBinder onBind(Intent intent) {
    return binder;
  }

  @Override
  public void onDestroy() {
    stopServer();
    super.onDestroy();
  }
}


text:
module.exports = {
  searchDirectory: '.',
  filesToProcess: ['./Cakefile'],
  customNames: {
    './Cakefile': './Cakefile.js',
  },
  fileFilterFn: path => !path.includes('test/importing/') && !path.includes('documentation'),
  jscodeshiftScripts: [
    'top-level-this-to-exports.js',
  ],
  decaffeinateArgs: ['--use-cs2'],
};


text:
package org.hswebframework.web.authorization.simple;

import org.hswebframework.web.authorization.access.DataAccessType;
import org.hswebframework.web.authorization.access.DefaultDataAccessType;
import org.hswebframework.web.authorization.access.FieldFilterDataAccessConfig;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import static org.hswebframework.web.authorization.access.DataAccessConfig.DefaultType.DENY_FIELDS;

/**
 * 默认配置实现
 *
 * @author zhouhao
 * @see FieldFilterDataAccessConfig
 * @since 3.0
 */
public class SimpleFieldFilterDataAccessConfig extends AbstractDataAccessConfig implements FieldFilterDataAccessConfig {
    private static final long serialVersionUID = 8080660575093151866L;

    private Set<String> fields;

    public SimpleFieldFilterDataAccessConfig() {
    }

    public SimpleFieldFilterDataAccessConfig(String... fields) {
        this.fields = new HashSet<>(Arrays.asList(fields));
    }

    @Override
    public Set<String> getFields() {
        return fields;
    }

    public void setFields(Set<String> fields) {
        this.fields = fields;
    }

    @Override
    public DataAccessType getType() {
        return DefaultDataAccessType.FIELD_DENY;
    }
}


text:
r-viz-snippets
==============

Code snippets for visualising data using R.


text:
package com.yoghurt.crypto.transactions.client.widget;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.yoghurt.crypto.transactions.client.place.TransactionPlaceRouter;
import com.yoghurt.crypto.transactions.client.resources.R;
import com.yoghurt.crypto.transactions.shared.util.ArrayUtil;

public class TransactionViewer extends ValueViewer {
  private final ClickHandler mouseClickHandler = new ClickHandler() {
    @Override
    public void onClick(final ClickEvent event) {
      presenter.goToTransaction(value);
    }
  };
  private final TransactionPlaceRouter presenter;

  /**
   * Flag indicating whether or not the value is LE or BE, if it's BE, will convert to LE
   */
  private final boolean reverse;

  public TransactionViewer(final TransactionPlaceRouter presenter, final boolean coinbase) {
    this(presenter, true, coinbase);
  }

  public TransactionViewer(final TransactionPlaceRouter presenter, final boolean reverse, final boolean coinbase) {
    super(R.color().transactionHash(), new SimpleContextFactory<String>() {
      @Override
      protected String getTextValue(final String value) {
        if(coinbase) {
          return "This is a coinbase transaction, it has no inputs.";
        } else {
          return "View this transaction.";
        }
      }
    });

    this.presenter = presenter;
    this.reverse = reverse;

    if(!coinbase) {
      setMouseClickHandler(mouseClickHandler);
    }
  }

  @Override
  public void setValue(final byte[] hash) {
    if (reverse) {
      final byte[] hashCopy = ArrayUtil.arrayCopy(hash);
      ArrayUtil.reverse(hashCopy);

      super.setValue(hashCopy);
    } else {
      super.setValue(hash);
    }
  }
}


text:
describe("loginCtrl",function(){
  var $rootScope,
	  $scope,
	  controller;

	beforeEach(function(){
       module('gulpApp');

       inject(function($injector){
        $rootScope = $injector.get('$rootScope');
        $scope = $rootScope.$new();
        controller = $injector.get('$controller')("loginCtrl",{$scope: $scope});
       });

       describe("Action Handlers", function(){
           describe("eatSlice",function(){

               it("Should decrement the no",function(){
               	expect($scope.slices).toEqual(8);
               	$scope.eatSlice();
               	expect($scope.slices).toEqual(7);
               });
               it("should do nothing when slice is 0", function(){
                  $scope.slices = 0;
                  $scope.eatSlice();
                  expect($scope.slices).toEqual(0);
               });
           });
       });

	});

	 describe("Intializatio",function(){
          it("should instantiate slices to 8", function(){
             expect($scope.slices).toEqual(8);
          });
	 });

});


text:
// -----------------------------------------------------------------------
// <copyright file="BadTriangle.cs" company="">
// Original Triangle code by Jonathan Richard Shewchuk, http://www.cs.cmu.edu/~quake/triangle.html
// Triangle.NET code by Christian Woltering, http://triangle.codeplex.com/
// </copyright>
// -----------------------------------------------------------------------

namespace TriangleNet.Meshing.Data
{
    using System;
    using TriangleNet.Geometry;
    using TriangleNet.Topology;

    /// <summary>
    /// A queue used to store bad triangles.
    /// </summary>
    /// <remarks>
    /// The key is the square of the cosine of the smallest angle of the triangle.
    /// Each triangle's vertices are stored so that one can check whether a
    /// triangle is still the same.
    /// </remarks>
    class BadTriangle
    {
        public Otri poortri; // A skinny or too-large triangle.
        public double key; // cos^2 of smallest (apical) angle.
        public Vertex org, dest, apex; // Its three vertices.
        public BadTriangle next; // Pointer to next bad triangle.

        public override string ToString()
        {
            return String.Format("B-TID {0}", poortri.tri.hash);
        }
    }
}


text:
package com.joostvdoorn.glutenvrij.scanner;

import com.joostvdoorn.glutenvrij.TrackedActivity;
import com.joostvdoorn.glutenvrij.scanner.PreferencesActivity;
import com.joostvdoorn.glutenvrij.GlutenvrijActivity;
import com.joostvdoorn.glutenvrij.R;
import com.joostvdoorn.glutenvrij.Search;
import com.joostvdoorn.glutenvrij.SearchActivity;
import com.joostvdoorn.glutenvrij.SearchObserver;
import com.joostvdoorn.glutenvrij.SearchResult;
import com.joostvdoorn.glutenvrij.scanner.camera.CameraManager;
import com.joostvdoorn.glutenvrij.scanner.core.BarcodeFormat;
import com.joostvdoorn.glutenvrij.scanner.core.Result;
import com.joostvdoorn.glutenvrij.scanner.core.ResultMetadataType;
import com.joostvdoorn.glutenvrij.scanner.core.ResultPoint;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.Vector;

/**
 * The barcode reader activity itself. This is loosely based on the CameraPreview
 * example included in the Android SDK.
 *
 * @author dswitkin@google.com (Daniel Switkin)
 * @author Sean Owen
 */
public final class CaptureActivity extends TrackedActivity implements SurfaceHolder.Callback, SearchObserver {

  protected static final String NAME = "Barcode scanner";
  private static final String TAG = CaptureActivity.class.getSimpleName();

  private static final int SETTINGS_ID = Menu.FIRST;
  private static final int ABOUT_ID = Menu.FIRST + 1;

  private static final long BULK_MODE_SCAN_DELAY_MS = 1000L;

  private static final Set<ResultMetadataType> DISPLAYABLE_METADATA_TYPES;
  static {
    DISPLAYABLE_METADATA_TYPES = new HashSet<ResultMetadataType>(5);
    DISPLAYABLE_METADATA_TYPES.add(ResultMetadataType.ISSUE_NUMBER);
    DISPLAYABLE_METADATA_TYPES.add(ResultMetadataType.SUGGESTED_PRICE);
    DISPLAYABLE_METADATA_TYPES.add(ResultMetadataType.ERROR_CORRECTION_LEVEL);
    DISPLAYABLE_METADATA_TYPES.add(ResultMetadataType.POSSIBLE_COUNTRY);
  }

  private enum Source {
    NATIVE_APP_INTENT,
    PRODUCT_SEARCH_LINK,
    ZXING_LINK,
    NONE
  }

  private CaptureActivityHandler handler;
  private ViewfinderView viewfinderView;
  private TextView statusView;
  private Result lastResult;
  private boolean hasSurface;
  private Source source;
  private Vector<BarcodeFormat> decodeFormats;
  private String characterSet;
  private InactivityTimer inactivityTimer;
  private BeepManager beepManager;

  ViewfinderView getViewfinderView() {
    return viewfinderView;
  }

  public Handler getHandler() {
    return handler;
  }

  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle, this.NAME);

    Window window = getWindow();
    window.setFormat(PixelFormat.RGBA_8888);
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.capture);

    CameraManager.init(getApplication());
    viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view);
    statusView = (TextView) findViewById(R.id.status_view);
    handler = null;
    lastResult = null;
    hasSurface = false;
    inactivityTimer = new InactivityTimer(this);
    beepManager = new BeepManager(this);

  }

  @Override
  protected void onResume() {
    super.onResume();
    resetStatusView();

    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    if (hasSurface) {
      // The activity was paused but not stopped, so the surface still exists. Therefore
      // surfaceCreated() won't be called, so init the camera here.
      initCamera(surfaceHolder);
    } else {
      // Install the callback and wait for surfaceCreated() to init the camera.
      surfaceHolder.addCallback(this);
      surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }

	  source = Source.NONE;
	  decodeFormats = null;
	  characterSet = null;

    beepManager.updatePrefs();

    inactivityTimer.onResume();
  }

  @Override
  protected void onPause() {
    super.onPause();
    if (handler != null) {
      handler.quitSynchronously();
      handler = null;
    }
    inactivityTimer.onPause();
    CameraManager.get().closeDriver();
  }

  @Override
  protected void onDestroy() {
    inactivityTimer.shutdown();
    super.onDestroy();
  }

  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
      if (source == Source.NATIVE_APP_INTENT) {
        setResult(RESULT_CANCELED);
        finish();
        return true;
      } else if ((source == Source.NONE || source == Source.ZXING_LINK) && lastResult != null) {
        resetStatusView();
        if (handler != null) {
          handler.sendEmptyMessage(R.id.restart_preview);
        }
        return true;
      }
    } else if (keyCode == KeyEvent.KEYCODE_FOCUS || keyCode == KeyEvent.KEYCODE_CAMERA) {
      // Handle these events so they don't launch the Camera app
      return true;
    }
    return super.onKeyDown(keyCode, event);
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    menu.add(0, SETTINGS_ID, 0, R.string.menu_settings)
    .setIcon(android.R.drawable.ic_menu_preferences);
    menu.add(0, ABOUT_ID, 0, R.string.menu_about)
    .setIcon(android.R.drawable.ic_menu_info_details);
    return true;
  }

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
	  switch (item.getItemId()) {
	    case SETTINGS_ID: {
	      Intent intent = new Intent(Intent.ACTION_VIEW);
	      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
	      intent.setClassName(this, PreferencesActivity.class.getName());
	      startActivity(intent);
	      break;
	    }
	    case ABOUT_ID:
	      AlertDialog.Builder builder = new AlertDialog.Builder(this);
	      builder.setTitle(getString(R.string.title_about) + GlutenvrijActivity.VERSION_NAME);
	      builder.setMessage(getString(R.string.msg_about) + "\n" + getString(R.string.zxing_url));
	      builder.show();
	      break;
	  }
	  return super.onOptionsItemSelected(item);
	}

  public void surfaceCreated(SurfaceHolder holder) {
    if (!hasSurface) {
      hasSurface = true;
      initCamera(holder);
    }
  }

  public void surfaceDestroyed(SurfaceHolder holder) {
    hasSurface = false;
  }

  public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {

  }

  /**
   * A valid barcode has been found, so give an indication of success and show the results.
   *
   * @param rawResult The contents of the barcode.
   * @param barcode   A greyscale bitmap of the camera data which was decoded.
   */
  public void handleDecode(Result rawResult, Bitmap barcode) {
    inactivityTimer.onActivity();
    lastResult = rawResult;
    beepManager.playBeepSoundAndVibrate();
    this.trackEvent("scanner","search",""+rawResult.getText(), 0);
    Toast.makeText(this, ""+rawResult.getText(), Toast.LENGTH_SHORT).show();

    new Search().execute(1,rawResult.getText(),this);
    // Wait a moment or else it will scan the same barcode continuously about 3 times
    if (handler != null) {
      handler.sendEmptyMessageDelayed(R.id.restart_preview, BULK_MODE_SCAN_DELAY_MS);
    }
    drawResultPoints(barcode, rawResult);
    resetStatusView();

    }

  /**
   * Superimpose a line for 1D or dots for 2D to highlight the key features of the barcode.
   *
   * @param barcode   A bitmap of the captured image.
   * @param rawResult The decoded results which contains the points to draw.
   */
  private void drawResultPoints(Bitmap barcode, Result rawResult) {
    ResultPoint[] points = rawResult.getResultPoints();
    if (points != null && points.length > 0) {
      Canvas canvas = new Canvas(barcode);
      Paint paint = new Paint();
      paint.setColor(getResources().getColor(R.color.result_image_border));
      paint.setStrokeWidth(3.0f);
      paint.setStyle(Paint.Style.STROKE);
      Rect border = new Rect(2, 2, barcode.getWidth() - 2, barcode.getHeight() - 2);
      canvas.drawRect(border, paint);

      paint.setColor(getResources().getColor(R.color.result_points));
      if (points.length == 2) {
        paint.setStrokeWidth(4.0f);
        drawLine(canvas, paint, points[0], points[1]);
      } else if (points.length == 4 &&
                 (rawResult.getBarcodeFormat().equals(BarcodeFormat.UPC_A) ||
                  rawResult.getBarcodeFormat().equals(BarcodeFormat.EAN_13))) {
        // Hacky special case -- draw two lines, for the barcode and metadata
        drawLine(canvas, paint, points[0], points[1]);
        drawLine(canvas, paint, points[2], points[3]);
      } else {
        paint.setStrokeWidth(10.0f);
        for (ResultPoint point : points) {
          canvas.drawPoint(point.getX(), point.getY(), paint);
        }
      }
    }
  }

  private static void drawLine(Canvas canvas, Paint paint, ResultPoint a, ResultPoint b) {
    canvas.drawLine(a.getX(), a.getY(), b.getX(), b.getY(), paint);
  }

  private void initCamera(SurfaceHolder surfaceHolder) {
    try {
      CameraManager.get().openDriver(surfaceHolder);
      // Creating the handler starts the preview, which can also throw a RuntimeException.
      if (handler == null) {
        handler = new CaptureActivityHandler(this, decodeFormats, characterSet);
      }
    } catch (IOException ioe) {
      Log.w(TAG, ioe);
      displayFrameworkBugMessageAndExit();
    } catch (RuntimeException e) {
      // Barcode Scanner has seen crashes in the wild of this variety:
      // java.?lang.?RuntimeException: Fail to connect to camera service
      Log.w(TAG, "Unexpected error initializating camera", e);
      displayFrameworkBugMessageAndExit();
    }
  }

  private void displayFrameworkBugMessageAndExit() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(getString(R.string.app_name));
    builder.setMessage(getString(R.string.msg_camera_framework_bug));
    builder.setPositiveButton(R.string.button_ok, new FinishListener(this));
    builder.setOnCancelListener(new FinishListener(this));
    builder.show();
  }

  private void resetStatusView() {
    statusView.setText(R.string.msg_default_status);
    statusView.setVisibility(View.VISIBLE);
    viewfinderView.setVisibility(View.VISIBLE);
    lastResult = null;
  }

  public void drawViewfinder() {
    viewfinderView.drawViewfinder();
  }

@Override
public void notify(ArrayList<SearchResult> result) {
	if(result.size()>1) {
	    this.trackEvent("scanner","result-multi",result.get(0).getEan(), result.size());
		//Show an more advance interface for multiple results
    	Intent myIntent = new Intent(getBaseContext(), SearchActivity.class);
    	myIntent.putExtra("com.joostvdoorn.glutenvrij.SearchValue", result.get(0).getEan());
    	myIntent.putExtra("com.joostvdoorn.glutenvrij.SearchCategory", Integer.toString(1));
    	startActivity(myIntent);
	}
	else if(result.size()==1) {
		findViewById(R.id.scannerResultContainer).setVisibility(View.VISIBLE);
		if(result.get(0).allowed(PreferenceManager.getDefaultSharedPreferences(this)) == SearchResult.FREE_FROM) {
			findViewById(R.id.scannerResultContainer).setBackgroundResource(R.drawable.green_gradient);
		}
		else if(result.get(0).allowed(PreferenceManager.getDefaultSharedPreferences(this)) == SearchResult.CONTAINS) {
			findViewById(R.id.scannerResultContainer).setBackgroundResource(R.drawable.red_gradient);
		}
		else {
			findViewById(R.id.scannerResultContainer).setBackgroundResource(R.drawable.grey_gradient);
		}
	    this.trackEvent("scanner","result",""+result.get(0).getName(), 1);
		((TextView) findViewById(R.id.scannerResult)).setText(result.get(0).getName());
		String line = "";
		line += result.get(0).getStore() + " - ";
		line += result.get(0).getEan() + " - ";
		Resources res = getResources();
		switch(result.get(0).getLactoseInfo()) {
			case SearchResult.FREE_FROM:
				line += res.getString(R.string.lactosefree) + " - ";
				break;
			case SearchResult.CONTAINS:
				line += res.getString(R.string.lactose_contains) + " - ";
				break;
			case SearchResult.NO_DATA:
				line += res.getString(R.string.lactose_no_data) + " - ";
				break;
		}
		switch(result.get(0).getStarchInfo()) {
			case SearchResult.FREE_FROM:
				line += res.getString(R.string.starchfree);
				break;
			case SearchResult.CONTAINS:
				line += res.getString(R.string.starch_contains);
				break;
			case SearchResult.NO_DATA:
				line += res.getString(R.string.starch_no_data);
				break;
		}
        String bsmString = result.get(0).getBsmString();
        line +=  bsmString.length() > 0 ? " - " + bsmString : "";
		((TextView) findViewById(R.id.resultInfoLine)).setText(line);
	}
	else {
	    this.trackEvent("scanner","result-none","", 0);
		findViewById(R.id.scannerResultContainer).setVisibility(View.VISIBLE);
		findViewById(R.id.scannerResultContainer).setBackgroundResource(R.drawable.yellow_gradient);
		((TextView) findViewById(R.id.scannerResult)).setText(R.string.barcode_not_found);
		((TextView) findViewById(R.id.resultInfoLine)).setText("");
	}
}
}


text:
package com.google.javascript.jscomp.colors;

import static com.google.common.base.Preconditions.checkState;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Iterables;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hasher;
import com.google.common.hash.Hashing;
import com.google.errorprone.annotations.Immutable;
import com.google.javascript.jscomp.diagnostic.LogsGson;
import com.google.protobuf.ByteString;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Set;

/**
 * A probablistically unique ID for a Color.
 *
 *
This is a semantic wrapper around UUID bytes to provide better typing when passing those bytes
 * around. It also hosts some utility methods to ensure consistent byte handling and help with
 * testing/debugging.
 *
 *
If two Colors have the same ID, they should be considered to represent the same "logical"
 * Color, perhaps inferred in different libraries. Ideally, those instances would be reconciled
 * before either Color is instantiated.
 *
 *
IDs have an intentionally unspecified width so that it may expand if needed in the future. For
 * the purposes of comparison, serialization, and display, leading 0s are ignored.
 */
@Immutable
public final class ColorId implements Serializable, LogsGson.Able {

  // Assume for now that we have at most 8 bytes.
  private final long rightAligned;

  public static ColorId fromUnsigned(long x) {
    return new ColorId(x);
  }

  public static ColorId fromUnsigned(int x) {
    return new ColorId((long) x & 0xFFFFFFFFL);
  }

  public static ColorId fromUnsigned(byte x) {
    return new ColorId((long) x & 0xFFL);
  }

  public static ColorId fromBytes(ByteString bytes) {
    return fromBytesAt(bytes, bytes.size(), ByteString::byteAt);
  }

  public static ColorId fromBytes(byte[] bytes) {
    return fromBytesAt(bytes, bytes.length, (s, i) -> s[i]);
  }

  @VisibleForTesting
  public static ColorId fromAscii(String str) {
    return fromBytesAt(str, str.length(), ASCII_AT);
  }

  private static <T> ColorId fromBytesAt(T source, int length, ByteAt<T> byteAt) {
    checkState(length <= 8, length);

    long rightAligned = 0;
    for (int i = 0; i < length; i++) {
      rightAligned <<= 8;
      rightAligned |= ((long) byteAt.get(source, i)) & 0xFF;
    }

    return new ColorId(rightAligned);
  }

  /**
   * Defines how IDs for unions are combined.
   *
   *
Ideally, this function would preserve the algebraic properties of the union operation.
   * However, doing so is difficult (impossible?) while also providing good hashing. Those
   * properties are summarized below.
   *
   *
This method must never be passed IDs of existing unions. Lack of associativity means the
   * result will not be the same as unioning all the IDs simultaneously.
   *
   *

   * | name          | has   | example                       | note                        |
   * |---------------|-------|-------------------------------|-----------------------------|
   * | associativity | false | f(x, f(y, z)) = f(f(x, y), z) |                             |
   * | commutativity | true  |       f(x, y) = f(y, x)       |                             |
   * | idempotence   | true  |    f(x, x, y) = f(x, y)       | `ids` is a Set              |
   * | identity      | true  |          f(x) = x             | singleton unions are banned |
   *

   */
  public static ColorId union(Set<ColorId> ids) {
    if (ids.size() <= 1) {
      return Iterables.getOnlyElement(ids);
    }

    int index = 0;
    long[] sorted = new long[ids.size()];
    for (ColorId id : ids) {
      sorted[index++] = id.rightAligned;
    }
    Arrays.sort(sorted);

    Hasher hasher = FARM_64.newHasher();
    for (int i = 0; i < sorted.length; i++) {
      hasher.putLong(sorted[i]);
    }

    return new ColorId(hasher.hash().asLong());
  }

  private ColorId(long rightAligned) {
    this.rightAligned = rightAligned;
  }

  @Override
  public boolean equals(Object x) {
    if (!(x instanceof ColorId)) {
      return false;
    }

    ColorId that = (ColorId) x;
    return this.rightAligned == that.rightAligned;
  }

  @Override
  public int hashCode() {
    return (int) this.rightAligned;
  }

  public ByteString asByteString() {
    long copy = this.rightAligned;
    byte[] out = new byte[8];
    for (int i = 7; i >= 0; i--) {
      out[i] = (byte) copy;
      copy >>>= 8;
    }
    return ByteString.copyFrom(out);
  }

  @Override
  public String toString() {
    // Use hex encoding so there are no ambiguous trailing chars like Base64 would have.
    return Long.toHexString(this.rightAligned);
  }

  @Override
  public String toLogsGson() {
    return this.toString();
  }

  private static final HashFunction FARM_64 = Hashing.farmHashFingerprint64();

  private interface ByteAt<T> {
    byte get(T source, int index);
  }

  private static final ByteAt<String> ASCII_AT =
      (s, i) -> {
        int c = s.codePointAt(i);
        checkState(0 <= c && c < 128, c);
        return (byte) c;
      };
}


text:
class SetQueueAction < Action

# _Parameters_
# * +order+:: integer : The order of the action relative to other actions in Instruction.
# * +queue+::
# * +queue_id+:: integer : ID of the queue onto which the packet is to be queued.
  def initialize(order: nil, queue: nil, queue_id: nil)
    super(order: order)
    raise ArgumentError, "Queue (queue) required" unless queue
    raise ArgumentError, "Queue ID (queue_id) required" unless queue_id
    @queue = queue
    @queue_id = queue
  end

  def to_hash #:nodoc:
    {:order => @order, 'queue-action' => {:queue => @queue,
        'queue-id' => @queue_id}}
  end
end


text:
package com.github.snorkelapp.lfd.learning;

import weka.classifiers.Classifier;
import weka.core.Instances;

public interface ILearning {
     Classifier train(Instances TrainSet);

     void evaluator(Classifier classifier, Instances TrainSet, Instances TestSet);
}


text:
///////////////////////////////////////////////////////////////////////////
// Copyright © 2014 Esri. All Rights Reserved.
//
// Licensed under the Apache License Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
///////////////////////////////////////////////////////////////////////////

define([
  'dojo/_base/declare',
  'dojo/_base/array',
  'dojo/_base/lang',
  'dojo/topic',
  'dojo/Deferred',
  'esri/graphicsUtils',
  'dojo/aspect',
  './LayerInfo',
  './LayerInfoForDefaultWMS',
  './LayerInfoFactory',
  'esri/layers/FeatureLayer',
  'esri/lang'
], function(declare, array, lang, topic, Deferred, graphicsUtils, aspect,
LayerInfo, LayerInfoForDefaultWMS, LayerInfoFactory, FeatureLayer, esriLang) {
  /*jshint unused: false*/
  return declare(LayerInfo, {

    constructor: function( operLayer, map, options) {
      this._layerOptions = options.layerOptions ? options.layerOptions: null;
      /*jshint unused: false*/
    },

    getExtent: function() {
      var extent = this.originOperLayer.layerObject.extent;
      return this._convertGeometryToMapSpatialRef(extent);
    },

    _resetLayerObjectVisiblityBeforeInit: function() {
      if(this._layerOptions) {
        //reste visibility fo parent layer.
        if(this._layerOption) {
          this.layerObject.setVisibility(this._layerOption.visible);
        }

        //reste visibles of sublayer.
        var visibleLayers = [];
        var haseConfiguredInLayerOptionsflag = false;
        array.forEach(this.layerObject.layerInfos, function(jsapiLayerInfo) {
          var absoluteSublayerId = this.id + '_' + jsapiLayerInfo.name;
          if(esriLang.isDefined(this._layerOptions[absoluteSublayerId])) {
            haseConfiguredInLayerOptionsflag = true;
            if(this._layerOptions[absoluteSublayerId].visible) {
              visibleLayers.push(jsapiLayerInfo.name);
            }
          }
        }, this);

        if(visibleLayers.length > 0 || haseConfiguredInLayerOptionsflag) {
          //recall setVisibleLayers()
          this.layerObject.setVisibleLayers(visibleLayers);
          this.traversal(function(layerInfo) {
            layerInfo.initVisible();
          });
        }
      }
    },

    initVisible: function() {
      this._visible = this.layerObject.visible;
    },

    _setTopLayerVisible: function(visible) {
      this.layerObject.setVisibility(visible);
      this._visible = visible;
    },

    setSubLayerVisible: function(layersVisible) {
      // summary:
      //   set seblayer visible
      // description:
      //   paramerter:
      //   {subLayerId: visble}
      var ary = [], index;
      ary = lang.clone(this.originOperLayer.layerObject.visibleLayers);

      for (var child in layersVisible) {
        if(layersVisible.hasOwnProperty(child) &&
           (typeof layersVisible[child] !== 'function') /*&&child !== 'config'*/) {
          var visible = layersVisible[child];
          var subLayerId = child.toString();
          index = array.indexOf(ary, subLayerId);
          if (visible) {
            if (index < 0) {
              ary.push(subLayerId);
            }
          } else {
            if (index >= 0) {
              ary.splice(index, 1);
            }
          }
        }
      }
      this.originOperLayer.layerObject.setVisibleLayers(ary);
    },
    //---------------new section-----------------------------------------

    obtainNewSubLayers: function() {
      var newSubLayerInfos = [];
      array.forEach(this.layerObject.layerInfos, function(layerInfo, index){
        var subLayerInfo;
        subLayerInfo = LayerInfoFactory.getInstance().create({
          layerObject: this.layerObject, //the subLayerObject is WMS layer also.
          title: layerInfo.label || layerInfo.title || layerInfo.name || " ",
          // WMS sub layer does not has id, set id to 'parentId' + name.
          id: this.id + '_' + (layerInfo.name || " "),
          wms: {"layerInfo": this, "subId": layerInfo.name, "wmsLayerInfo": layerInfo},
          selfType: 'wms',
          parentLayerInfo: this
        });

        newSubLayerInfos.push(subLayerInfo);
        subLayerInfo.init();
      }, this);

      return newSubLayerInfos;
    },

    /****************
     * Event
     ***************/
    _bindEvent: function() {
      this.inherited(arguments);
      if(this.layerObject && !this.layerObject.empty) {
        aspect.after(this.layerObject, "setVisibleLayers",
          lang.hitch(this, this._onVisibleLayersChanged));
      }
    },

    _onVisibleLayersChanged: function() {
      var changedLayerInfos = [];
      this.traversal(function(layerInfo) {
        // init visible for every sublayer.
        layerInfo.initVisible();
        changedLayerInfos.push(layerInfo);
      });
      // send event
      topic.publish('layerInfos/layerInfo/visibleChanged', changedLayerInfos);
      this._isShowInMapChanged2();
    }
  });
});


text:
module CrashingTheDance
  module RpiCalculator
    class RPI
      attr_reader :team,
                  :games, :games_conference, :games_nonconference,
                  :wins, :losses,
                  :rpi_wins, :rpi_losses,
                  :wins_conference, :losses_conference,
                  :rpi_wins_conference, :rpi_losses_conference,
                  :wins_nonconference, :losses_nonconference,
                  :rpi_wins_nonconference, :rpi_losses_nonconference

      def initialize(team, games)
        @team = team
        initialize_games(games)
        initialize_rpi
        calculate_record
      end

      def win_percentage
        if games.count > 0
          wins.to_f / (wins.to_f + losses.to_f)
        else
          0.0
        end
      end

      def rpi_win_percentage
        if games.count > 0
          rpi_wins / (rpi_wins + rpi_losses)
        else
          0.0
        end
      end

      def rpi_win_percentage_conference
        if games_conference.count > 0
          rpi_wins_conference / (rpi_wins_conference + rpi_losses_conference)
        else
          0.0
        end
      end

      def rpi_win_percentage_nonconference
        if games_nonconference.count > 0
          rpi_wins_nonconference / (rpi_wins_nonconference + rpi_losses_nonconference)
        else
          0.0
        end
      end

      def owp
        @owp
      end

      def oowp
        @oowp
      end

      def owp_conference
        @owp_conference
      end

      def oowp_conference
        @oowp_conference
      end

      def owp_nonconference
        @owp_nonconference
      end

      def oowp_nonconference
        @oowp_nonconference
      end

      def rpi
        @rpi ||= calculate_rpi
      end

      def rpi_conference
        @rpi_conference ||= calculate_rpi_conference
      end

      def rpi_nonconference
        @rpi_nonconference ||= calculate_rpi_nonconference
      end

      # To calculate opponent's winning percentage (OWP), you remove games against
      # the team in question.
      # However, for the purpose of calculating OWP and OOWP, use standard WP.
      def calculate_owp(games_by_team)
        if games.count > 0
          sum_owp = games.inject(0.0) do |sum, game|
            sked = opponent_schedule game.opponent, games_by_team
            ow = sked.inject(0) { |wins, og| wins + og.wins }
            sum + (sked.empty? ? 0.0 : (ow.to_f / sked.count.to_f))
          end
          @owp = sum_owp / games.count.to_f
        end
      end

      # Now to calculate the opponents' opponents winning percentage (OOWP),
      # you simply average the OWPs for each of their opponents.
      def calculate_oowp(all_teams)
        if games.count > 0
          sum_oowp = games.inject(0.0) do |sum, game|
            opponent = all_teams.find { |t| game.opponent.eql? t.team }
            sum + opponent.owp
          end
          @oowp = sum_oowp / games.count.to_f
        end
      end

      # hate this repitition but not yet sure how to consolidate
      # the logic is roughly the same, but they
      # set separate instance variables
      def calculate_conference_owp(games_by_team)
        if games_conference.count > 0
          sum_owp = games_conference.inject(0.0) do |sum, game|
            sked = opponent_schedule game.opponent, games_by_team
            ow = sked.inject(0) { |wins, og| wins + og.wins }
            sum + (sked.empty? ? 0.0 : (ow.to_f / sked.count.to_f))
          end
          @owp_conference = sum_owp / games_conference.count.to_f
        end
      end

      def calculate_conference_oowp(all_teams)
        if games_conference.count > 0
          sum_oowp = games_conference.inject(0.0) do |sum, game|
            opponent = all_teams.find { |t| game.opponent.eql? t.team }
            sum + opponent.owp
          end
          @oowp_conference = sum_oowp / games_conference.count.to_f
        end
      end

      def calculate_nonconference_owp(games_by_team)
        if games_nonconference.count > 0
          sum_owp = games_nonconference.inject(0.0) do |sum, game|
            sked = opponent_schedule game.opponent, games_by_team
            ow = sked.inject(0) { |wins, og| wins + og.wins }
            sum + (sked.empty? ? 0.0 : (ow.to_f / sked.count.to_f))
          end
          @owp_nonconference = sum_owp / games_nonconference.count.to_f
        end
      end

      def calculate_nonconference_oowp(all_teams)
        if games_nonconference.count > 0
          sum_oowp = games_nonconference.inject(0.0) do |sum, game|
            opponent = all_teams.find { |t| game.opponent.eql? t.team }
            sum + opponent.owp
          end
          @oowp_nonconference = sum_oowp / games_nonconference.count.to_f
        end
      end

      private

      def initialize_games(games)
        @games = games
        @games_conference = games.select { |game| game.conference? }
        @games_nonconference = games.reject { |game| game.conference? }
      end

      def initialize_rpi
        @owp = 0.0
        @oowp = 0.0
        @owp_conference = 0.0
        @oowp_conference = 0.0
        @owp_nonconference = 0.0
        @oowp_nonconference = 0.0
        @rpi = nil
        @rpi_conference = nil
        @rpi_nonconference = nil
      end

      def calculate_rpi
        0.25 * rpi_win_percentage + 0.5 * owp + 0.25 * oowp
      end

      # these are common, how can we consolidate?
      def calculate_rpi_conference
        0.25 * rpi_win_percentage_conference + 0.5 * owp_conference + 0.25 * oowp_conference
      end

      def calculate_rpi_nonconference
        0.25 * rpi_win_percentage_nonconference + 0.5 * owp_nonconference + 0.25 * oowp_nonconference
      end

      # filters out games against this team
      def opponent_schedule(opponent, games_by_team)
       all = games_by_team[opponent] || []
       all.reject { |game| game.opponent.eql? team }
      end

      # w/l is commonly used, so can we extract it to a module?
      def calculate_record
        initialize_wl
        initialize_wl_conference
        initialize_wl_nonconference
        games.each do |game|
          calculate_wl game
          calculate_wl_conference game
          calculate_wl_nonconference game
        end
      end

      def initialize_wl
        @wins = @rpi_wins = 0
        @losses = @rpi_losses = 0
      end

      def initialize_wl_conference
        @wins_conference = @rpi_wins_conference = 0
        @losses_conference = @rpi_losses_conference = 0
      end

      def initialize_wl_nonconference
        @wins_nonconference = @rpi_wins_nonconference = 0
        @losses_nonconference = @rpi_losses_nonconference = 0
      end

      def calculate_wl(game)
          @wins       += 1 if game.win?
          @losses     += 1 if game.loss?
          @rpi_wins   += game.rpi_wins
          @rpi_losses += game.rpi_losses
      end

      def calculate_wl_conference(game)
        if game.conference?
          @wins_conference       += 1 if game.win?
          @losses_conference     += 1 if game.loss?
          @rpi_wins_conference   += game.rpi_wins
          @rpi_losses_conference += game.rpi_losses
        end
      end

      def calculate_wl_nonconference(game)
        unless game.conference?
          @wins_nonconference       += 1 if game.win?
          @losses_nonconference     += 1 if game.loss?
          @rpi_wins_nonconference   += game.rpi_wins
          @rpi_losses_nonconference += game.rpi_losses
        end
      end
    end
  end
end