text:
using System;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Diagnostics;

namespace DataFilterGenericLibrary
{
    public class LinearDataFilterLibrary
    {

        #region Public Methods

        #region Moving Average
        public static double[] movingAverage(int q, double[] input)
        {
            int inputLength = input.Length;

            double[] output = new double[inputLength];

            for (int _dataIndex = 0; _dataIndex < inputLength; _dataIndex ++)
            {

                Double _average = input[_dataIndex];

                for (int _shift = 1; _shift <= q / 2; _shift++)
                {
                    int _lIndex = _dataIndex - _shift;
                    int _rIndex = _dataIndex + _shift;

                    if (_rIndex > inputLength - 1)
                    {
                        _rIndex = 2 * (inputLength - 1) - _rIndex;
                    }

                    if (_lIndex < 0)
                    {
                        _lIndex = -_lIndex;
                    }

                    if ((q & 1) == 0 && _shift == q / 2)
                    {
                        _average += 0.5 * (input[_lIndex] + input[_rIndex]);
                    }
                    else
                    {
                        _average += input[_lIndex] + input[_rIndex];
                    }

                }

                _average /= q;
                output[_dataIndex] = _average;
            }
            return output;
        }
        #endregion

        #region Binomial Average
        public static double[] binomialAverage(int q, double[] input)
        {

            int inputLength = input.Length;
            double[] output = new double[inputLength];

            double[] coefficient = new double[q + 1];

            coefficient[0] = 1.0 / Math.Pow(2.0, 2 * q);

            for (int _coefIndex = 1; _coefIndex <= q; _coefIndex++)
            {
                coefficient[_coefIndex] = coefficient[_coefIndex - 1] * (2 * q - _coefIndex + 1) / (double)_coefIndex;
            }

            for (int _dataIndex = 0; _dataIndex < inputLength; _dataIndex++)
            {
                Double _average = input[_dataIndex] * coefficient[q];

                for (int _shift = 1; _shift <= q; _shift++)
                {
                    int _lIndex = _dataIndex - _shift;
                    int _rIndex = _dataIndex + _shift;

                    if (_rIndex > inputLength - 1)
                    {
                        _rIndex = 2 * (inputLength - 1) - _rIndex;
                    }

                    if (_lIndex < 0)
                    {
                        _lIndex = -_lIndex;
                    }

                    _average += coefficient[q - _shift] * (input[_lIndex] + input[_rIndex]);

                }

                output[_dataIndex] = _average;
            }

            return output;
        }
        #endregion

        #region Exponential Smooth
        public static double[] exponentialSmooth(double t, double[] input)
        {
            int inputLength = input.Length;
            double[] output = new double[inputLength];

            output[0] = input[0];

            for (int _dataIndex = 1; _dataIndex < inputLength; _dataIndex++)
            {
                output[_dataIndex] = (t * input[_dataIndex] + (1 - t) * output[_dataIndex - 1]);
            }

            return output;
        }
        #endregion

        #region Fourier Smooth
        public static double[] fourierSmooth(int bandWidth, double[] input)
        {
            int inputLength = input.Length;
            double[] output = new double[inputLength];

            Tuple<double[], double[]> freqOutput = fft(input, inputLength);

            int freqLength = freqOutput.Item1.Length;

            for (int _freqIndex = bandWidth + 1; _freqIndex < freqLength - bandWidth - 1; _freqIndex++)
            {
                freqOutput.Item1[_freqIndex] = 0.0;
                freqOutput.Item2[_freqIndex] = 0.0;
            }

            ifft(freqOutput.Item1, freqOutput.Item2, freqLength);

            for (int _dataIndex = 0; _dataIndex < inputLength; _dataIndex++ )
            {
                output[_dataIndex] = freqOutput.Item1[_dataIndex];
            }

            return output;

        }
        #endregion

        #region Savitzky-Golay Smooth
        public static double[] savgolSmooth(int nl, int nr, int m, double[] input)
        {
            double[] coeffs = savgolCoefficient(nl, nr, m);

            int inputLength = input.Length;

            double[] output = new double[inputLength];

            for (int _dataIndex = 0; _dataIndex < inputLength; _dataIndex++)
            {
                for (int _shift = -nl; _shift <= nr; _shift++)
                {
                    int _Index = _dataIndex + _shift;

                    if (_Index > inputLength - 1)
                    {
                        _Index = 2 * (inputLength - 1) - _Index;
                    }

                    if (_Index < 0)
                    {
                        _Index = -_Index;
                    }

                    output[_dataIndex] += coeffs[nl + _shift] * input[_Index];
                }
            }
            return output;

        }
        #endregion

        #region Local Regression
        public static double[] localRegression(int k, int m,  double[] input)
        {
            if ((k % 2) == 0)
            {
                // can workaround to plus 1.
                //throw new Exception(@"Bad Args.");
                k = k + 1;
            }

            int half = (k - 1)/2;
            int inputLength = input.Length;

            double[] output = new double[inputLength];
            double[] weights = new double[k];
            double[] coeffs = new double[k];

            int nr, nl;

            for (int _dataIndex = 0; _dataIndex <= half; _dataIndex++)
            {
                nl = _dataIndex;
                nr = k - 1 - nl;

                setLocalRegressionWeights(nl, nr, weights);
                localRegressionCoeffs(nl, nr, m, input, weights, coeffs);

                for (int _shift = -nl; _shift <= nr; _shift++)
                {
                    output[_dataIndex] += coeffs[nl + _shift] * input[_dataIndex + _shift];
                }
            }

            setLocalRegressionWeights(half, half, weights);
            localRegressionCoeffs(half, half, m, input, weights, coeffs);

            for (int _dataIndex = half + 1; _dataIndex < inputLength - half; _dataIndex++)
            {
                for (int _shift = -half; _shift <= half; _shift++)
                {
                    output[_dataIndex] += coeffs[half + _shift] * input[_dataIndex + _shift];
                }
            }

            for (int _dataIndex = inputLength - half; _dataIndex < inputLength; _dataIndex ++ )
            {
                nr = inputLength - 1 - _dataIndex;
                nl = k - 1 - nr;

                setLocalRegressionWeights(nl, nr, weights);
                localRegressionCoeffs(nl, nr, m, input, weights, coeffs);

                for (int _shift = -nl; _shift <= nr; _shift++)
                {
                    output[_dataIndex] += coeffs[nl + _shift] * input[_dataIndex + _shift];
                }

            }
            return output;
        }
        #endregion

        #region Robust Local Regression
        public static double[] robustLocalRegression(int k, int m, double[] input)
        {
            int inputLength = input.Length;

            double[] residual = new double[inputLength];
            double[] output = localRegression(k, m, input);

            for (int _iter = 0; _iter < 5; _iter ++)
            {

                try
                {
                    robustLocalRegressionResidualAnalysis(k, m, input, output, residual);
                }
                catch
                {
                    return output;
                }
            }

            return output;

        }
        #endregion

        #region Spline Smooth
        public static void splineSmooth(double[] input)
        {

        }
        #endregion

        #region RDP method
        public static List<int> rdp(double epsilon, double[] input)
        {

            int inputLength = input.Length;

            List<int> indexList = new List<int>();

            indexList.Add(0);
            indexList.Add(inputLength - 1);

            recursiveRDP(epsilon, 0, inputLength, input, ref indexList);
            indexList.Sort();

            return indexList;

        }
        #endregion

        #endregion

        #region Private Methods

        #region Robust Local Regression Residual Analysis
        private static void robustLocalRegressionResidualAnalysis(int k, int m, double[] input,
            double[] output, double[] residual)
        {
            int inputLength = input.Length;

            if (inputLength != output.Length)
            {
                throw new Exception(@"Bad Args.");
            }

            if ((k % 2) == 0)
            {
                // can workaround to plus 1.
                //throw new Exception(@"Bad Args.");
                k += 1;
            }

            int half = (k - 1) / 2;

            for (int _dataIndex = 0; _dataIndex < inputLength; _dataIndex++)
            {
                residual[_dataIndex] = input[_dataIndex] - output[_dataIndex];
                output[_dataIndex] = 0;
            }

            for (int _dataIndex = 0; _dataIndex < inputLength; _dataIndex++)
            {
                int nr, nl;

                double[] _weights = new double[k];
                double[] _coeffs = new double[k];

                nl = _dataIndex <= half ? _dataIndex : half;
                if (_dataIndex >= inputLength - half)
                {
                    nl = k - inputLength + _dataIndex;
                }
                nr = k - 1 - nl;

                setRobustLocalRegressionWeights(nl, nr, _dataIndex, _weights, residual);
                localRegressionCoeffs(nl, nr, m, input, _weights, _coeffs);

                for (int _shift = -nl; _shift <= nr; _shift++)
                {
                    output[_dataIndex] += _coeffs[nl + _shift] * input[_dataIndex + _shift];
                }
            }

        }

        #endregion

        #region Check Power of Two
        private static bool isPowerOfTwo(int N)
        {
            return (N != 0) && ((N & (N - 1)) == 0);
        }
        #endregion

        #region Compute next Power of Two
        private static int nextPowerOfTwo(int N)
        {
            N--;
            N |= (N >> 1);
            N |= (N >> 2);
            N |= (N >> 4);
            N |= (N >> 8);
            N |= (N >> 16);
            return (N + 1);
        }
        #endregion

        #region FFT
        private static Tuple<double[], double[]> fft(double[] input, int N)
        {
            int inputLength = input.Length;

            if (inputLength != N)
            {
                throw new System.Exception(@"Bad Args.");
            }

            int Ntmp = isPowerOfTwo(N) ? N : nextPowerOfTwo(N);

            double[] realOutput = new double[2 * Ntmp];
            double[] imagOutput = new double[2 * Ntmp];

            for (int _dataIndex = inputLength; _dataIndex < Ntmp; _dataIndex++)
            {
                realOutput[_dataIndex] = input[N - 1];
                realOutput[2 * Ntmp - 1 - _dataIndex] = input[N - 1];
            }

            for (int _dataIndex = 0; _dataIndex < inputLength; _dataIndex++)
            {
                realOutput[_dataIndex] = input[_dataIndex];
                realOutput[2 * Ntmp - 1 - _dataIndex] = input[_dataIndex];
            }

            N = 2 * Ntmp;

            int half = N >> 1;

            // REVERSE BIT
            int _swapIndex = 0;
            for (int _dataIndex = 0; _dataIndex < N - 1; _dataIndex++)
            {

                if (_dataIndex < _swapIndex)
                {
                    Double tmp;
                    tmp = realOutput[_dataIndex];
                    realOutput[_dataIndex] = realOutput[_swapIndex];
                    realOutput[_swapIndex] = tmp;
                }

                int stepSize = half;
                while (stepSize <= _swapIndex)
                {
                    _swapIndex -= stepSize;
                    stepSize >>= 1;
                }
                _swapIndex += stepSize;
            }

            // FFT
            Double realPart = -1.0;
            Double imagPart = 0.0;

            int _nextLevelIncrement = 1;

            for (int _levelIndex = 1; _levelIndex < N; _levelIndex <<= 1)
            {
                int _currLevelIncrement = _nextLevelIncrement;
                _nextLevelIncrement <<= 1;

                Double realCoeff = 1.0;
                Double imagCoeff = 0.0;

                for (int _currLevelIncrementIndex = 0; _currLevelIncrementIndex < _currLevelIncrement; _currLevelIncrementIndex++)
                {
                    for (int _jumpIndex = _currLevelIncrementIndex; _jumpIndex < N; _jumpIndex += _nextLevelIncrement)
                    {
                        int _currPos = _jumpIndex + _currLevelIncrement;

                        Double realTmp = realCoeff * realOutput[_currPos] - imagCoeff * imagOutput[_currPos];
                        Double imagTmp = realCoeff * imagOutput[_currPos] + imagCoeff * realOutput[_currPos];

                        realOutput[_currPos] = realOutput[_jumpIndex] - realTmp;
                        imagOutput[_currPos] = imagOutput[_jumpIndex] - imagTmp;

                        realOutput[_jumpIndex] += realTmp;
                        imagOutput[_jumpIndex] += imagTmp;
                    }

                    Double tmp = realCoeff * realPart - imagCoeff * imagPart;
                    imagCoeff = realCoeff * imagPart + imagCoeff * realPart;
                    realCoeff = tmp;
                }
                imagPart = Math.Sqrt((1.0 - realPart) / 2.0);
                imagPart = -imagPart;
                realPart = Math.Sqrt((1.0 + realPart) / 2.0);
            }

            for (int i = 0; i < N; i++)
            {
                realOutput[i] /= N;
                imagOutput[i] /= N;
            }

            return Tuple.Create(realOutput, imagOutput);
        }
        #endregion

        #region iFFT
        private static void ifft(double[] realInput, double[] imagInput, int N)
        {
            int half = N >> 1;

            // REVERSE BIT
            int _swapIndex = 0;
            for (int _dataIndex = 0; _dataIndex < N - 1; _dataIndex++)
            {

                if (_dataIndex < _swapIndex)
                {
                    Double tmp;
                    tmp = realInput[_dataIndex];
                    realInput[_dataIndex] = realInput[_swapIndex];
                    realInput[_swapIndex] = tmp;
                    tmp = imagInput[_dataIndex];
                    imagInput[_dataIndex] = imagInput[_swapIndex];
                    imagInput[_swapIndex] = tmp;
                }

                int stepSize = half;
                while (stepSize <= _swapIndex)
                {
                    _swapIndex -= stepSize;
                    stepSize >>= 1;
                }
                _swapIndex += stepSize;
            }

            // FFT
            Double realPart = -1.0;
            Double imagPart = 0.0;

            int _nextLevelIncrement = 1;

            for (int _levelIndex = 1; _levelIndex < N; _levelIndex <<= 1)
            {
                int _currLevelIncrement = _nextLevelIncrement;
                _nextLevelIncrement <<= 1;

                Double realCoeff = 1.0;
                Double imagCoeff = 0.0;

                for (int _currLevelIncrementIndex = 0; _currLevelIncrementIndex < _currLevelIncrement; _currLevelIncrementIndex++)
                {
                    for (int _jumpIndex = _currLevelIncrementIndex; _jumpIndex < N; _jumpIndex += _nextLevelIncrement)
                    {
                        int _currPos = _jumpIndex + _currLevelIncrement;

                        Double realTmp = realCoeff * realInput[_currPos] - imagCoeff * imagInput[_currPos];
                        Double imagTmp = realCoeff * imagInput[_currPos] + imagCoeff * realInput[_currPos];

                        realInput[_currPos] = realInput[_jumpIndex] - realTmp;
                        imagInput[_currPos] = imagInput[_jumpIndex] - imagTmp;

                        realInput[_jumpIndex] += realTmp;
                        imagInput[_jumpIndex] += imagTmp;
                    }

                    Double tmp = realCoeff * realPart - imagCoeff * imagPart;
                    imagCoeff = realCoeff * imagPart + imagCoeff * realPart;
                    realCoeff = tmp;
                }
                imagPart = Math.Sqrt((1.0 - realPart) / 2.0);
                realPart = Math.Sqrt((1.0 + realPart) / 2.0);
            }
        }
        #endregion

        #region LU Decomposition
        private static Tuple<double[][], int[]> ludcmp(double[][] A)
        {
            int n = A.Length - 1;

            int[] pi = new int[n + 1];

            double p = 0, aki = 0, akpi = 0;
            int kp = 0, pik = 0, pikp = 0;

            for (int j = 0; j <= n; j++)
            {
                pi[j] = j;
            }

            for (int k = 0; k <= n; k++)
            {
                p = 0;
                for (int i = k; i <= n; i++)
                {
                    if (Math.Abs(A[i][k]) > p)
                    {
                        p = Math.Abs(A[i][k]);
                        kp = i;
                    }
                }
                if (p == 0)
                {
                    throw new System.Exception(@"Singularity Detected.");
                }

                pik = pi[k];
                pikp = pi[kp];
                pi[k] = pikp;
                pi[kp] = pik;

                for (int i = 0; i <= n; i++)
                {
                    aki = A[k][i];
                    akpi = A[kp][i];
                    A[k][i] = akpi;
                    A[kp][i] = aki;
                }

                for (int i = k + 1; i <= n; i++)
                {
                    A[i][k] = A[i][k] / A[k][k];
                    for (int j = k + 1; j <= n; j++)
                    {
                        A[i][j] = A[i][j] - (A[i][k] * A[k][j]);
                    }
                }
            }
            return Tuple.Create(A, pi);
        }
        #endregion

        #region LU Backward Substitution
        private static double[] lubksb(double[][] A, int[] idx, double[] b)
        {
            int n = A.Length;

            double[] x = new double[n];

            for (int i = 0; i < n; i++)
            {
                x[i] = b[idx[i]];
            }

            for(int i = 1; i < n; i++)
            {
                double sum = x[i];
                for (int j = 0; j < i; j++)
                {
                    sum -= A[i][j] * x[j];
                }
                x[i] = sum;
            }

            x[n - 1] /= A[n - 1][n - 1];

            for (int i =  n - 2; i >=0; i--)
            {
                double sum = x[i];
                for (int j = i + 1; j < n; j++)
                {
                    sum -= A[i][j] * x[j];
                }
                x[i] = sum / A[i][i];
            }

            return x;
        }
        #endregion

        #region Savitzky-Golay Coefficients
        private static double[] savgolCoefficient(int nl, int nr, int m)
        {
            if (nl < 0 || nr < 0 || nl + nr < m)
            {
                throw new System.Exception(@"Bad Args.");
            }

            double[][] A = new double[m + 1][];
            for (int i = 0; i < m + 1; i++)
            {
                A[i] = new double[m + 1];
            }

            double[] b = new double[m + 1];

            double sum;

            for (int i = 0; i <= m; i++)
            {
                for (int j = 0; j <= m; j++)
                {
                    sum = (i == 0 && j == 0) ? 1.0 : 0.0;
                    for (int k = 1; k <= nr; k++)
                    {
                        sum += Math.Pow(k, i + j);
                    }

                    for (int k = 1; k <= nl; k++)
                    {
                        sum += Math.Pow(-k, i + j);
                    }

                    A[i][j] = sum;
                }
            }

            Tuple<double[][], int[]> output = ludcmp(A);

            b[0] = 1;
            b = lubksb(A, output.Item2, b);

            double[] coeffs = new double[nl + nr + 1];

            for (int i = -nl; i <= nr; i++)
            {
                sum = b[0];
                for (int j = 1; j <= m; j++)
                {
                    sum += b[j] * Math.Pow(i, j);
                }
                coeffs[i + nl] = sum;
            }
            return coeffs;
        }
        #endregion

        #region Shortest Distance From A point to Segment
        private static double
            shortestDistanceToSegment(int currIndex, double currValue,
            int headIndex, double headValue, int tailIndex, double tailValue)
        {
            return Math.Abs((headValue - tailValue) * currIndex + (tailIndex - headIndex) *
                currValue + (headIndex * tailValue - headValue * tailIndex)) / Math.Sqrt(Math.Pow((headValue - tailValue), 2)
                + Math.Pow(tailIndex - headIndex, 2));
        }
        #endregion

        #region Recursive RDP sub-routine
        private static void recursiveRDP(double epsilon, int first, int last, double[] input, ref List<int> indexList)
        {
            double dmax = 0.0;
            int index = first;

            for (int _dataIndex = first; _dataIndex < last; _dataIndex++)
            {
                double d = shortestDistanceToSegment(_dataIndex, input[_dataIndex], first, input[first], last - 1, input[last - 1]);

                if (d > dmax)
                {
                    index = _dataIndex;
                    dmax = d;
                }
            }

            if (dmax > epsilon)
            {
                indexList.Add(index);
                recursiveRDP(epsilon, first, index, input, ref indexList);
                recursiveRDP(epsilon, index, last, input, ref indexList);
            }
        }
        #endregion

        #region Local Regression Coefficients
        private static void localRegressionCoeffs(int nl, int nr, int m, double[] input, double[] weights, double[] coeffs)
        {
            if (nl < 0 || nr < 0 || nl + nr < m)
            {
                Console.WriteLine("{0}, {1}, {2}", nl, nr, m);
                throw new Exception(@"Bad Args.");
            }

            double[][] A = new double[m + 1][];
            for (int i = 0; i < m + 1; i++)
            {
                A[i] = new double[m + 1];
            }

            double[] b = new double[m + 1];

            double sum;

            for (int i = 0; i <= m; i++)
            {
                for (int j = 0; j <= m; j++)
                {
                    sum = (i == 0 && j == 0) ? 1.0 : 0.0;
                    for (int k = 1; k <= nr; k++)
                    {
                        sum += weights[k + nl] * Math.Pow(k, i + j);
                    }

                    for (int k = 1; k <= nl; k++)
                    {
                        sum += weights[nl - k] * Math.Pow(-k, i + j);
                    }

                    A[i][j] = sum;
                }
            }

            Tuple<double[][], int[]> output = ludcmp(A);

            b[0] = 1;
            b = lubksb(A, output.Item2, b);

            for (int i = -nl; i <= nr; i++)
            {
                sum = b[0];
                for (int j = 1; j <= m; j++)
                {
                    sum += b[j] * Math.Pow(i, j);
                }
                coeffs[i + nl] = sum * weights[i + nl];
            }
        }
        #endregion

        #region Set Local Regression Weights
        private static void setLocalRegressionWeights(int nl, int nr, double[] weights)
        {
            double dmax = (double)Math.Max(nr, nl) + 1;

            for (int _wIndex = 0; _wIndex < nr + nl + 1; _wIndex++)
            {
                weights[_wIndex] = Math.Pow(1 - Math.Pow((Math.Abs(nl - _wIndex)) / dmax, 3), 3);
            }
        }
        #endregion

        #region set Robust Local Regression Weights
        private static void setRobustLocalRegressionWeights(int nl, int nr, int ind, double[] weights, double[] residual)
        {
            for (int _dataIndex = -nl; _dataIndex <= nr; _dataIndex++)
            {
                weights[nl + _dataIndex] = Math.Abs(residual[ind + _dataIndex]);
            }

            Array.Sort(weights);
            double median = weights[(weights.Length + 1)/ 2];

            for (int _dataIndex = -nl; _dataIndex <= nr; _dataIndex++)
            {
                weights[nl + _dataIndex] =
                    Math.Abs(residual[ind + _dataIndex]) < 6 * median ?
                    Math.Pow((1 - Math.Pow(Math.Abs(residual[nl + _dataIndex]) / (6 * median), 4)), 2) : 0;
            }
        }
        #endregion

        #endregion
    }

}


text:
using LinqToTwitter;
using System;
using System.Linq;

namespace LinqToTwitterDemo
{
    /// <summary>
    /// Shows related results demos
    /// </summary>
    public class RelatedResultsDemos
    {
        /// <summary>
        /// Run all related results demos
        /// </summary>
        /// <param name="twitterCtx">TwitterContext</param>
        public static void Run(TwitterContext twitterCtx)
        {
            ShowRelatedResultsDemo(twitterCtx);
        }

        /// <summary>
        /// shows how to get related results of a tweet
        /// </summary>
        /// <param name="twitterCtx">TwitterContext</param>
        private static void ShowRelatedResultsDemo(TwitterContext twitterCtx)
        {
            var results =
                (from result in twitterCtx.RelatedResults
                 where result.Type == RelatedResultsType.Show &&
                       result.StatusID == 195992821411495936ul
                 select result)
                .ToList();

            results.ForEach(result =>
                Console.WriteLine("Name: {0}\nTweet: {1}\n", result.User.Identifier.ScreenName, result.Text));
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Input.Events;
using osu.Framework.MathUtils;
using osuTK;

namespace osu.Game.Screens.Edit.Compose.Components.Timeline
{
    public class ZoomableScrollContainer : ScrollContainer
    {
        /// <summary>
        /// The time to zoom into/out of a point.
        /// All user scroll input will be overwritten during the zoom transform.
        /// </summary>
        public double ZoomDuration;

        /// <summary>
        /// The easing with which to transform the zoom.
        /// </summary>
        public Easing ZoomEasing;

        private readonly Container zoomedContent;
        protected override Container<Drawable> Content => zoomedContent;

        private float currentZoom = 1;

        public ZoomableScrollContainer()
            : base(Direction.Horizontal)
        {
            base.Content.Add(zoomedContent = new Container { RelativeSizeAxes = Axes.Y });
        }

        private int minZoom = 1;

        /// <summary>
        /// The minimum zoom level allowed.
        /// </summary>
        public int MinZoom
        {
            get => minZoom;
            set
            {
                if (value < 1)
                    throw new ArgumentException($"{nameof(MinZoom)} must be >= 1.", nameof(value));

                minZoom = value;

                if (Zoom < value)
                    Zoom = value;
            }
        }

        private int maxZoom = 60;

        /// <summary>
        /// The maximum zoom level allowed.
        /// </summary>
        public int MaxZoom
        {
            get => maxZoom;
            set
            {
                if (value < 1)
                    throw new ArgumentException($"{nameof(MaxZoom)} must be >= 1.", nameof(value));

                maxZoom = value;

                if (Zoom > value)
                    Zoom = value;
            }
        }

        /// <summary>
        /// Gets or sets the content zoom level of this <see cref="ZoomableScrollContainer"/>.
        /// </summary>
        public float Zoom
        {
            get => zoomTarget;
            set
            {
                value = MathHelper.Clamp(value, MinZoom, MaxZoom);

                if (IsLoaded)
                    setZoomTarget(value, ToSpaceOfOtherDrawable(new Vector2(DrawWidth / 2, 0), zoomedContent).X);
                else
                    currentZoom = zoomTarget = value;
            }
        }

        protected override void Update()
        {
            base.Update();

            zoomedContent.Width = DrawWidth * currentZoom;
        }

        protected override bool OnScroll(ScrollEvent e)
        {
            if (e.IsPrecise)
                // for now, we don't support zoom when using a precision scroll device. this needs gesture support.
                return base.OnScroll(e);

            setZoomTarget(zoomTarget + e.ScrollDelta.Y, zoomedContent.ToLocalSpace(e.ScreenSpaceMousePosition).X);
            return true;
        }

        private float zoomTarget = 1;

        private void setZoomTarget(float newZoom, float focusPoint)
        {
            zoomTarget = MathHelper.Clamp(newZoom, MinZoom, MaxZoom);
            transformZoomTo(zoomTarget, focusPoint, ZoomDuration, ZoomEasing);
        }

        private void transformZoomTo(float newZoom, float focusPoint, double duration = 0, Easing easing = Easing.None)
            => this.TransformTo(this.PopulateTransform(new TransformZoom(focusPoint, zoomedContent.DrawWidth, Current), newZoom, duration, easing));

        private class TransformZoom : Transform<float, ZoomableScrollContainer>
        {
            /// <summary>
            /// The focus point in absolute coordinates local to the content.
            /// </summary>
            private readonly float focusPoint;

            /// <summary>
            /// The size of the content.
            /// </summary>
            private readonly float contentSize;

            /// <summary>
            /// The scroll offset at the start of the transform.
            /// </summary>
            private readonly float scrollOffset;

            /// <summary>
            /// Transforms <see cref="TimeTimelinem"/> to a new value.
            /// </summary>
            /// <param name="focusPoint">The focus point in absolute coordinates local to the content.</param>
            /// <param name="contentSize">The size of the content.</param>
            /// <param name="scrollOffset">The scroll offset at the start of the transform.</param>
            public TransformZoom(float focusPoint, float contentSize, float scrollOffset)
            {
                this.focusPoint = focusPoint;
                this.contentSize = contentSize;
                this.scrollOffset = scrollOffset;
            }

            public override string TargetMember => nameof(currentZoom);

            private float valueAt(double time)
            {
                if (time < StartTime) return StartValue;
                if (time >= EndTime) return EndValue;

                return Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing);
            }

            protected override void Apply(ZoomableScrollContainer d, double time)
            {
                float newZoom = valueAt(time);

                float focusOffset = focusPoint - scrollOffset;
                float expectedWidth = d.DrawWidth * newZoom;
                float targetOffset = expectedWidth * (focusPoint / contentSize) - focusOffset;

                d.currentZoom = newZoom;
                d.ScrollTo(targetOffset, false);
            }

            protected override void ReadIntoStartValue(ZoomableScrollContainer d) => StartValue = d.currentZoom;
        }
    }
}


text:
NS_ASSUME_NONNULL_BEGIN

@interface AVSignature : NSObject

@property (nonatomic, copy,   nullable) NSString *signature;
@property (nonatomic, assign)           int64_t   timestamp;
@property (nonatomic, copy,   nullable) NSString *nonce;
@property (nonatomic, copy,   nullable) NSString *action AV_DEPRECATED("2.6.4");
@property (nonatomic, strong, nullable) NSArray  *signedPeerIds;
@property (nonatomic, strong, nullable) NSError  *error;

@end

@protocol AVSignatureDelegate <NSObject>
@optional
- (AVSignature *)signatureForPeerWithPeerId:(NSString *)peerId watchedPeerIds:(NSArray *)watchedPeerIds action:(NSString *)action;
- (AVSignature *)signatureForGroupWithPeerId:(NSString *)peerId groupId:(NSString *)groupId groupPeerIds:(NSArray *)groupPeerIds action:(NSString *)action;

- (AVSignature *)createSignature:(NSString *)peerId watchedPeerIds:(NSArray *)watchedPeerIds AV_DEPRECATED("2.6.4");
- (AVSignature *)createSessionSignature:(NSString *)peerId watchedPeerIds:(NSArray *)watchedPeerIds action:(NSString *)action AV_DEPRECATED("2.6.4");
- (AVSignature *)createGroupSignature:(NSString *)peerId groupPeerIds:(NSArray *)groupPeerIds action:(NSString *)action AV_DEPRECATED("2.6.4");
- (AVSignature *)createGroupSignature:(NSString *)peerId groupId:(NSString *)groupId groupPeerIds:(NSArray *)groupPeerIds action:(NSString *)action AV_DEPRECATED("2.6.4");
@end

NS_ASSUME_NONNULL_END


text:
package crime

import (
	"time"
)

type rawCrime struct {
	IncidentID      int64
	OffenseID       int64
	Code            int64
	CodeExt         int64
	Type            string
	Category        string
	FirstOccurrence string
	LastOccurrence  string
	Reported        string
	Address         string
	X               int64
	Y               int64
	Latitude        float64
	Longitude       float64
	District        int64
	Precinct        int64
	Neighborhood    string
}

type Crime struct {
	IncidentID      int64      `json:"incident_id"`
	OffenseID       int64      `json:""`
	CodeID          string     `json:"code_id"`
	Code            int64      `json:"code"`
	CodeExt         int64      `json:"code_extension"`
	Type            string     `json:"type"`
	Category        string     `json:"category"`
	FirstOccurrence time.Time  `json:"first_occurrence"`
	LastOccurrence  *time.Time `json:"last_occurrence"`
	Reported        time.Time  `json:"reported"`
	Address         string     `json:"address"`
	Latitude        float64    `json:"latitude"`
	Longitude       float64    `json:"longitude"`
	District        int64      `json:"district"`
	Precinct        int64      `json:"precinct"`
	Neighborhood    string     `json:"neighborhood"`
}


text:
#ifndef _CNC_COMM_THREADEXECUTER_H_
#define _CNC_COMM_THREADEXECUTER_H_

#include <cnc/internal/tbbcompat.h>
#include <thread>
#include <string>

namespace CnC
{
    namespace Internal
    {
        /// Interface for a thread handle class. Needed to make separate actual
        /// communication from the rest of the CnCcomputation.
        /// Derived classes have to implement the runEventLoop() method
        /// which becomes the thread's "main" function.
        /// The thread is started by calling start(), and stopped by calling
        /// stop(). For ITAC tracing, you can define a name via defineThreadName.
        class ThreadExecuter
        {
        public:
            ThreadExecuter();
            virtual ~ThreadExecuter();

            /// Define thread name (for ITAC)
            void defineThreadName( const char name[], int nameSuffix = -1 );

            /// Starts the thread
            virtual void start();

            /// Stops the thread and waits for its termination
            virtual void stop();

        protected:
            /// thread's "main" function, to be implemented by concrete subclasses
            virtual void runEventLoop() = 0;

        public:
            /// Special support for the case where the event loop is
            /// not performed by a separate thread but on the calling thread
            void execute() { runEventLoop(); }

        protected:
            class ThreadArgs;
            std::thread * m_thread;
            ThreadArgs      * m_threadArgs;
            std::string       m_threadName;
            int               m_threadNameSuffix;
        };

    } // namespace Internal
} // namespace CnC

#endif // _CNC_COMM_THREADEXECUTER_H_


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

namespace Shade.Helios.Entities
{
   public class RenderComponent : Component
   {
      public RenderComponent()
         : base(ComponentType.Renderable)
      {
      }
   }
}


text:
var uint64be = require('uint64be')
var flat = require('flat-tree')
var createCache = require('./cache')

module.exports = Storage

var noarr = []

function Storage (create, opts) {
  if (!(this instanceof Storage)) return new Storage(create, opts)

  const cache = createCache(opts)

  this.treeCache = cache.tree || null
  this.dataCache = cache.data || null
  this.key = null
  this.secretKey = null
  this.tree = null
  this.data = null
  this.bitfield = null
  this.signatures = null
  this.create = create
}

Storage.prototype.putData = function (index, data, nodes, cb) {
  if (!cb) cb = noop
  var self = this
  if (!data.length) return cb(null)
  this.dataOffset(index, nodes, function (err, offset, size) {
    if (err) return cb(err)
    if (size !== data.length) return cb(new Error('Unexpected data size'))
    self.data.write(offset, data, cb)
  })
}

Storage.prototype.getData = function (index, cb) {
  var self = this
  var cached = this.dataCache && this.dataCache.get(index)
  if (cached) return process.nextTick(cb, null, cached)
  this.dataOffset(index, noarr, function (err, offset, size) {
    if (err) return cb(err)
    self.data.read(offset, size, (err, data) => {
      if (err) return cb(err)
      if (self.dataCache) self.dataCache.set(index, data)
      return cb(null, data)
    })
  })
}

Storage.prototype.nextSignature = function (index, cb) {
  var self = this

  this._getSignature(index, function (err, signature) {
    if (err) return cb(err)
    if (isBlank(signature)) return self.nextSignature(index + 1, cb)
    cb(null, { index: index, signature: signature })
  })
}

Storage.prototype.getSignature = function (index, cb) {
  this._getSignature(index, function (err, signature) {
    if (err) return cb(err)
    if (isBlank(signature)) return cb(new Error('No signature found'))
    cb(null, signature)
  })
}

// Caching not enabled for signatures because they are rarely reused.
Storage.prototype._getSignature = function (index, cb) {
  this.signatures.read(32 + 64 * index, 64, cb)
}

Storage.prototype.putSignature = function (index, signature, cb) {
  this.signatures.write(32 + 64 * index, signature, cb)
}

Storage.prototype.deleteSignatures = function (start, end, cb) {
  this.signatures.del(32 + 64 * start, (end - start) * 64, cb)
}

Storage.prototype.dataOffset = function (index, cachedNodes, cb) {
  var roots = flat.fullRoots(2 * index)
  var self = this
  var offset = 0
  var pending = roots.length
  var error = null
  var blk = 2 * index

  if (!pending) {
    pending = 1
    onnode(null, null)
    return
  }

  for (var i = 0; i < roots.length; i++) {
    var node = findNode(cachedNodes, roots[i])
    if (node) onnode(null, node)
    else this.getNode(roots[i], onnode)
  }

  function onlast (err, node) {
    if (err) return cb(err)
    cb(null, offset, node.size)
  }

  function onnode (err, node) {
    if (err) error = err
    if (node) offset += node.size
    if (--pending) return

    if (error) return cb(error)

    var last = findNode(cachedNodes, blk)
    if (last) onlast(null, last)
    else self.getNode(blk, onlast)
  }
}

// Caching not enabled for batch reads because they'd be complicated to batch and they're rarely used.
Storage.prototype.getDataBatch = function (start, n, cb) {
  var result = new Array(n)
  var sizes = new Array(n)
  var self = this

  this.dataOffset(start, noarr, function (err, offset, size) {
    if (err) return cb(err)

    start++
    n--

    if (n <= 0) return ontree(null, null)
    self.tree.read(32 + 80 * start, 80 * n - 40, ontree)

    function ontree (err, buf) {
      if (err) return cb(err)

      var total = sizes[0] = size

      if (buf) {
        for (var i = 1; i < sizes.length; i++) {
          sizes[i] = uint64be.decode(buf, 32 + (i - 1) * 80)
          total += sizes[i]
        }
      }

      self.data.read(offset, total, ondata)
    }

    function ondata (err, buf) {
      if (err) return cb(err)
      var total = 0
      for (var i = 0; i < result.length; i++) {
        result[i] = buf.slice(total, total += sizes[i])
      }

      cb(null, result)
    }
  })
}

Storage.prototype.getNode = function (index, cb) {
  if (this.treeCache) {
    var cached = this.treeCache.get(index)
    if (cached) return cb(null, cached)
  }

  var self = this

  this.tree.read(32 + 40 * index, 40, function (err, buf) {
    if (err) return cb(err)

    var hash = buf.slice(0, 32)
    var size = uint64be.decode(buf, 32)

    if (!size && isBlank(hash)) return cb(new Error('No node found'))

    var val = new Node(index, self.treeCache ? copyMaybe(hash, 40) : hash, size, null)
    if (self.treeCache) self.treeCache.set(index, val)
    cb(null, val)
  })
}

Storage.prototype.putNodeBatch = function (index, nodes, cb) {
  if (!cb) cb = noop

  var buf = Buffer.alloc(nodes.length * 40)

  for (var i = 0; i < nodes.length; i++) {
    var offset = i * 40
    var node = nodes[i]
    if (!node) continue
    node.hash.copy(buf, offset)
    uint64be.encode(node.size, buf, 32 + offset)
  }

  this.tree.write(32 + 40 * index, buf, cb)
}

Storage.prototype.putNode = function (index, node, cb) {
  if (!cb) cb = noop

  // TODO: re-enable put cache. currently this causes a memleak
  // because node.hash is a slice of the big data buffer on replicate
  // if (this.cache) this.cache.set(index, node)

  var buf = Buffer.allocUnsafe(40)

  node.hash.copy(buf, 0)
  uint64be.encode(node.size, buf, 32)
  this.tree.write(32 + 40 * index, buf, cb)
}

Storage.prototype.putBitfield = function (offset, data, cb) {
  this.bitfield.write(32 + offset, data, cb)
}

Storage.prototype.close = function (cb) {
  if (!cb) cb = noop
  var missing = 6
  var error = null

  close(this.bitfield, done)
  close(this.tree, done)
  close(this.data, done)
  close(this.key, done)
  close(this.secretKey, done)
  close(this.signatures, done)

  function done (err) {
    if (err) error = err
    if (--missing) return
    cb(error)
  }
}

Storage.prototype.destroy = function (cb) {
  if (!cb) cb = noop
  var missing = 6
  var error = null

  destroy(this.bitfield, done)
  destroy(this.tree, done)
  destroy(this.data, done)
  destroy(this.key, done)
  destroy(this.secretKey, done)
  destroy(this.signatures, done)

  function done (err) {
    if (err) error = err
    if (--missing) return
    cb(error)
  }
}

Storage.prototype.openKey = function (opts, cb) {
  if (typeof opts === 'function') return this.openKey({}, opts)
  if (!this.key) this.key = this.create('key', opts)
  this.key.read(0, 32, cb)
}

Storage.prototype.open = function (opts, cb) {
  if (typeof opts === 'function') return this.open({}, opts)

  var self = this
  var error = null
  var missing = 5

  if (!this.key) this.key = this.create('key', opts)
  if (!this.secretKey) this.secretKey = this.create('secret_key', opts)
  if (!this.tree) this.tree = this.create('tree', opts)
  if (!this.data) this.data = this.create('data', opts)
  if (!this.bitfield) this.bitfield = this.create('bitfield', opts)
  if (!this.signatures) this.signatures = this.create('signatures', opts)

  var result = {
    bitfield: [],
    bitfieldPageSize: 3584, // we upgraded the page size to fix a bug
    secretKey: null,
    key: null
  }

  this.bitfield.read(0, 32, function (err, h) {
    if (err && err.code === 'ELOCKED') return cb(err)
    if (h) result.bitfieldPageSize = h.readUInt16BE(5)
    self.bitfield.write(0, header(0, result.bitfieldPageSize, null), function (err) {
      if (err) return cb(err)
      readAll(self.bitfield, 32, result.bitfieldPageSize, function (err, pages) {
        if (pages) result.bitfield = pages
        done(err)
      })
    })
  })

  this.signatures.write(0, header(1, 64, 'Ed25519'), done)
  this.tree.write(0, header(2, 40, 'BLAKE2b'), done)

  // TODO: Improve the error handling here.
  // I.e. if secretKey length === 64 and it fails, error

  this.secretKey.read(0, 64, function (_, data) {
    if (data) result.secretKey = data
    done(null)
  })

  this.key.read(0, 32, function (_, data) {
    if (data) result.key = data
    done(null)
  })

  function done (err) {
    if (err) error = err
    if (--missing) return
    if (error) cb(error)
    else cb(null, result)
  }
}

Storage.Node = Node

function noop () {}

function copyMaybe (buf, maxSize) {
  if (buf.buffer.byteLength <= maxSize) return buf
  const cpy = Buffer.alloc(buf.byteLength)
  buf.copy(cpy)
  return cpy
}

function header (type, size, name) {
  var buf = Buffer.alloc(32)

  // magic number
  buf[0] = 5
  buf[1] = 2
  buf[2] = 87
  buf[3] = type

  // version
  buf[4] = 0

  // block size
  buf.writeUInt16BE(size, 5)

  if (name) {
    // algo name
    buf[7] = name.length
    buf.write(name, 8)
  }

  return buf
}

function Node (index, hash, size) {
  this.index = index
  this.hash = hash
  this.size = size
}

function findNode (nodes, index) {
  for (var i = 0; i < nodes.length; i++) {
    if (nodes[i].index === index) return nodes[i]
  }
  return null
}

function isBlank (buf) {
  for (var i = 0; i < buf.length; i++) {
    if (buf[i]) return false
  }
  return true
}

function close (st, cb) {
  if (st.close) st.close(cb)
  else cb()
}

function destroy (st, cb) {
  if (st.destroy) st.destroy(cb)
  else cb()
}

function statAndReadAll (st, offset, pageSize, cb) {
  st.stat(function (err, stat) {
    if (err) return cb(null, [])

    var result = []

    loop(null, null)

    function loop (err, batch) {
      if (err) return cb(err)

      if (batch) {
        offset += batch.length
        for (var i = 0; i < batch.length; i += pageSize) {
          result.push(batch.slice(i, i + pageSize))
        }
      }

      var next = Math.min(stat.size - offset, 32 * pageSize)
      if (!next) return cb(null, result)

      st.read(offset, next, loop)
    }
  })
}

function readAll (st, offset, pageSize, cb) {
  if (st.statable === true) return statAndReadAll(st, offset, pageSize, cb)

  var bufs = []

  st.read(offset, pageSize, loop)

  function loop (err, buf) {
    if (err) return cb(null, bufs)
    bufs.push(buf)
    st.read(offset + bufs.length * pageSize, pageSize, loop)
  }
}


text:
In order to receive events from NurApi, NurApiListener must be defined.
All event handlers must be defined for all possible events NurApi may fired.

Set Event handlers:
````
mNurApi.setListener(mNurApiListener);
````

Add all event handlers in to you MainActivity.java

````
private NurApiListener mNurApiListener = new NurApiListener()
{
    @Override
  public void triggeredReadEvent(NurEventTriggeredRead event) { }
    @Override
  public void traceTagEvent(NurEventTraceTag event) { }
    @Override
  public void programmingProgressEvent(NurEventProgrammingProgress event) { }
    @Override
  public void nxpEasAlarmEvent(NurEventNxpAlarm event) { }
    @Override
  public void logEvent(int level, String txt) { }
    @Override
  public void inventoryStreamEvent(NurEventInventory event) { }
    @Override
  public void inventoryExtendedStreamEvent(NurEventInventory event) {}
    @Override
  public void frequencyHopEvent(NurEventFrequencyHop event) { }
    @Override
  public void epcEnumEvent(NurEventEpcEnum event) { }
    @Override
  public void disconnectedEvent() { }
    @Override
  public void deviceSearchEvent(NurEventDeviceInfo event) { }
    @Override
  public void debugMessageEvent(String event) { }
    @Override
  public void connectedEvent() { }
    @Override
  public void clientDisconnectedEvent(NurEventClientInfo event) { }
    @Override
  public void clientConnectedEvent(NurEventClientInfo event) { }
    @Override
  public void bootEvent(String event) {}
    @Override
  public void IOChangeEvent(NurEventIOChange event) { }
    @Override
  public void autotuneEvent(NurEventAutotune event) { }
    @Override
  public void tagTrackingScanEvent(NurEventTagTrackingData event) { }
    //@Override
  public void tagTrackingChangeEvent(NurEventTagTrackingChange event) { }
};
````
All NurApi events are called from NurApi thread, thus direct UI updates are not allowed.
If you need to access UI controls, you can use runOnUiThread(Runnable) or Handler.

Example
````
//Connection status string (global)
String mConnStatus;
````
````
private void showOnUI() {
    runOnUiThread(new Runnable() {
        @Override
  public void run() {
            helloNurText.setText(mConnStatus);
        }
    });
}
````
..when connection event occurs..
````
...
@Override
 public void disconnectedEvent() {
	mConnStatus="Disconnected";
	showOnUI();
}
...
@Override
 public void connectedEvent() {
	mConnStatus="Connected";
	showOnUI();
}
````
Next: [Device connection](3_Device_Connection.md) Connect reader into your application


text:
class Friends
        attr_reader :email, :family, :nb
        def initialize
                @email = Hash.new
                @members=0
                @nb = []
        end
        def add (first_name,family_name,mail)
                @email[mail] = family_name
                @nb[@members] = mail
                @members += 1
        end
end
# compute all permutation in a list
def permute(items, perms=[], res=[])
    unless items.length > 0
        res << perms
    else
        for i in items
            newitems = items.dup
            newperms = perms.dup
            newperms.unshift(newitems.delete(i))
            permute(newitems, newperms,res)
        end
    end
    return res
end

friends = Friends.new
while line = gets
        friends.add(*line.split(' '))
end
perms = permute(friends.email.keys)
perms.reject!{|tab|
        res = false
        for i in 0..tab.length-1
                if friends.email[tab[i]] == friends.email[friends.nb[i]]
                        # same family
                        res = true
                end
        end
        res
}
res = perms[rand(perms.length)]
for i in 0..res.length-1
        puts "#{friends.nb[i]} -> #{res[i]}"
end


text:
Python library for JPT3815 HD

This library implements full motor, video and 1 way audio control. It also tracks your face and moves the camera to keep it in its center.

I did not figure out yet how to send audio to the camera in order to e.g. respond to a question. So feel free to contribute!