working on it ...

Filters

Explore Public Snippets

Sort by

Found 4,624 snippets matching: finding

    public by lbottaro  2743  2  6  1

    Parsing and finding symbolic links in multiple paths

    This bash script will list simbolic links in multiple path (using wildchar * for nested directories), at level 1 from main directory, parsing the result as well. The script will use awk to parse returned data, getting the 11th data, space separated.
    ls -l `find ABC*/code/target-*/TARGET -maxdepth 1 -type l -name "*"` | awk '{print $11}'
    

    public by cghersi  1942  0  6  0

    Finding actual number of physical cpu installed

    By Rahul Singh, 2013/01/14 The Sql Server always see Logical cpu it does not distinguish between Hyperthreaded logical cpu and physical processor using the below query we can find out actual number of physical cpu installed on the server The first column represent logical processor and second column represent actual physical processor insta
    SELECT cpu_count AS Logical_CPU_Count , cpu_count / hyperthread_ratio AS Physical_CPU_Count FROM sys.dm_os_sys_info ;

    public by fabior  804  0  3  0

    Some commands for finding and clearing infected PHP files

    Some commands for finding and clearing infected PHP files: infectedFiles.md
    # Finding infected files with following bash commands
    
    ** Command to list all infected files: 
    * ```grep -lr --include=*.php "eval(base64_decode" /path/to/webroot ```
    * ```grep -lr --include=*.php "eval" . ```
    * ```grep -lr --include=*.php "base64" . ```
    
    ## Command to remove malicious code: 
    * ```grep -lr --include=*.php "eval(base64_decode" /path/to/webroot | xargs sed -i.bak 's/<?php eval(base64_decode[^;]*;/<?php\n/g' ```
    
    * ```grep -lr --include=*.php "eval(base64_decode" /path/to/webroot | xargs sed -i.bak '/eval(base64_decode*/d' ```
    
    ## Trying to avoid re-appearance of this code injection 
    * ```find /path/to/webroot -name "wp-phpmyadmin" -type d | xargs rm -rf ```
    
    ## Missing ```<?php``` tag in the beginning: 
    * ```find /var/www/ -name "index.php" | grep "/htdocs/index.php" | xargs grep -L "<?php" | xargs sed -i "1s/^/<?php \n/" ```
    
    ## Extra Newlines at the top! 
    * ```find . -name '*.php' -exec sed -i -e :a -e '/^\n*$/{$d;N;ba' -e '}' '{}' \; ```
    
    * ```find -name '*_input*' | xargs rm -rf ```
    
    
    

    public by kastnerkyle  760  1  3  0

    Painless Q-Learning Tutorial implementation in Python http://mnemstudio.org/path-finding-q-learning-tutorial.htm

    Painless Q-Learning Tutorial implementation in Python http://mnemstudio.org/path-finding-q-learning-tutorial.htm: painless_q.py
    # Author: Kyle Kastner
    # License: BSD 3-Clause
    
    

    public by Geometry  988  0  3  0

    Solve: Returns the solution matrix if the matrix is square or the least squares solution otherwise.

    Returns the solution matrix if the matrix is square or the least squares solution otherwise. The matrix for the linear problem. The right side b. True to produce a solution even if the is singular; false otherwise. Default is false. Please note that this does not check if the matrix is non-singular before attempting to solve
    /// <summary>
    ///   Returns the solution matrix if the matrix is square or the least squares solution otherwise.
    /// </summary>
    /// 
    /// <param name="matrix">The matrix for the linear problem.</param>
    /// <param name="rightSide">The right side <c>b</c>.</param>
    /// <param name="leastSquares">True to produce a solution even if the 
    ///   <paramref name="matrix"/> is singular; false otherwise. Default is false.</param>
    /// 
    /// <remarks>
    ///   Please note that this does not check if the matrix is non-singular
    ///   before attempting to solve. If a least squares solution is desired
    ///   in case the matrix is singular, pass true to the <paramref name="leastSquares"/>
    ///   parameter when calling this function.
    /// </remarks>
    /// 
    /// <example>
    /// <code>
    /// // Create a matrix. Please note that this matrix
    /// // is singular (i.e. not invertible), so only a 
    /// // least squares solution would be feasible here.
    /// 
    /// double[,] matrix = 
    /// {
    ///     { 1, 2, 3 },
    ///     { 4, 5, 6 },
    ///     { 7, 8, 9 },
    /// };
    /// 
    /// // Define a right side vector b:
    /// double[] rightSide = { 1, 2, 3 };
    /// 
    /// // Solve the linear system Ax = b by finding x:
    /// double[] x = Matrix.Solve(matrix, rightSide, leastSquares: true);
    /// 
    /// // The answer should be { -1/18, 2/18, 5/18 }.
    /// </code>
    /// </example>
    /// 
    public static double[] Solve(this double[,] matrix, double[] rightSide, bool leastSquares = false)
    {
        if (matrix == null)
            throw new ArgumentNullException("matrix");
    
        if (rightSide == null)
            throw new ArgumentNullException("rightSide");
    
        int rows = matrix.GetLength(0);
        int cols = matrix.GetLength(1);
    
        if (rows != rightSide.Length)
            throw new DimensionMismatchException("rightSide",
                "The right hand side vector must have the same length"
                 + "as there are rows of the problem matrix.");
    
        if (leastSquares)
        {
            return new SingularValueDecomposition(matrix,
                  computeLeftSingularVectors: true,
                  computeRightSingularVectors: true,
                  autoTranspose: true).Solve(rightSide);
        }
    
    
        if (rows == cols)
        {
            // Solve by LU Decomposition if matrix is square.
            return new LuDecomposition(matrix).Solve(rightSide);
        }
        else
        {
            if (cols < rows)
            {
                // Solve by QR Decomposition if not.
                return new QrDecomposition(matrix).Solve(rightSide);
            }
            else
            {
                return new SingularValueDecomposition(matrix,
                    computeLeftSingularVectors: true,
                    computeRightSingularVectors: true,
                    autoTranspose: true).Solve(rightSide);
            }
        }
    }

    public by Geometry  791  0  3  0

    Solve: Returns the solution matrix if the matrix is square or the least squares solution otherwise.

    Returns the solution matrix if the matrix is square or the least squares solution otherwise. The matrix for the linear problem. The right side b. True to produce a solution even if the is singular; false otherwise. Default is false. Please note that this does not check if the matrix is non-singular before attempting to solve
    /// <summary>
    ///   Returns the solution matrix if the matrix is square or the least squares solution otherwise.
    /// </summary>
    /// 
    /// <param name="matrix">The matrix for the linear problem.</param>
    /// <param name="rightSide">The right side <c>b</c>.</param>
    /// <param name="leastSquares">True to produce a solution even if the 
    ///   <paramref name="matrix"/> is singular; false otherwise. Default is false.</param>
    /// 
    /// <remarks>
    ///   Please note that this does not check if the matrix is non-singular
    ///   before attempting to solve. If a least squares solution is desired
    ///   in case the matrix is singular, pass true to the <paramref name="leastSquares"/>
    ///   parameter when calling this function.
    /// </remarks>
    /// 
    /// <example>
    /// <code>
    /// // Create a matrix. Please note that this matrix
    /// // is singular (i.e. not invertible), so only a 
    /// // least squares solution would be feasible here.
    /// 
    /// double[,] matrix = 
    /// {
    ///     { 1, 2, 3 },
    ///     { 4, 5, 6 },
    ///     { 7, 8, 9 },
    /// };
    /// 
    /// // Define a right side vector b:
    /// double[] rightSide = { 1, 2, 3 };
    /// 
    /// // Solve the linear system Ax = b by finding x:
    /// double[] x = Matrix.Solve(matrix, rightSide, leastSquares: true);
    /// 
    /// // The answer should be { -1/18, 2/18, 5/18 }.
    /// </code>
    /// </example>
    /// 
    public static double[] Solve(this double[][] matrix, double[] rightSide, bool leastSquares = false)
    {
        if (matrix == null)
            throw new ArgumentNullException("matrix");
    
        if (rightSide == null)
            throw new ArgumentNullException("rightSide");
    
        int rows = matrix.Length;
        int cols = matrix[0].Length;
    
        if (rows != rightSide.Length)
            throw new DimensionMismatchException("rightSide",
                "The right hand side vector must have the same length"
                 + "as there are rows of the problem matrix.");
    
        if (leastSquares)
        {
            return new JaggedSingularValueDecomposition(matrix,
                  computeLeftSingularVectors: true,
                  computeRightSingularVectors: true,
                  autoTranspose: true).Solve(rightSide);
        }
    
    
        if (rows == cols)
        {
            // Solve by LU Decomposition if matrix is square.
            return new JaggedLuDecomposition(matrix).Solve(rightSide);
        }
        else
        {
            if (cols < rows)
            {
                // Solve by QR Decomposition if not.
                return new JaggedQrDecomposition(matrix).Solve(rightSide);
            }
            else
            {
                return new JaggedSingularValueDecomposition(matrix,
                    computeLeftSingularVectors: true,
                    computeRightSingularVectors: true,
                    autoTranspose: true).Solve(rightSide);
            }
        }
    }

    public by Zenitram.PRO  5022  15  6  1

    Linear search in an Array.

    Finding that Special Someone Let's say we're looking for someone in our address book with a specific last name. We can do this with a technique for searching arrays called "linear search". With it, we use a loop to check through all of the items in the array one-by-one until we see the item that we want. We can apply linear search to print
    var bob = {
        firstName: "Bob",
        lastName: "Jones",
        phoneNumber: "(650) 777-7777",
        email: "bob.jones@example.com"
    };
    
    var mary = {
        firstName: "Mary",
        lastName: "Johnson",
        phoneNumber: "(650) 888-8888",
        email: "mary.johnson@example.com"
    };
    
    var contacts = [bob, mary];
    
    function printPerson(person) {
        console.log(person.firstName + " " + person.lastName);
    }
    
    function list() {
    	var contactsLength = contacts.length;
    	for (var i = 0; i < contactsLength; i++) {
    		printPerson(contacts[i]);
    	}
    }
    
    /*Create a search function
    then call it passing "Jones"*/
    function search(lastName)
    {
        contactsLength = contacts.length;
    	for (var i = 0; i < contactsLength; i++) 
    	{
    	    if (lastName === contacts[i]["lastName"])
    	    {
    	        printPerson(contacts[i]);
    	    }
    	}
    }
    
    search("Jones");                                    

    public by qxshower  1890  2  5  0

    FindTreeViewItemRecursively

    Attempts to find a TreeViewItem recursively that is the container for the specified content to find. Source: http://blogs.msdn.com/b/wpfsdk/archive/2010/02/23/finding-an-object-treeviewitem.aspx.
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Interactivity;
    using System.Windows.Media;
    
    /// <summary>
    /// Attempts to find a TreeViewItem recursively that is the container for the specified
    /// content to find.
    /// </summary>
    /// <remarks>
    ///
    /// Source: http://blogs.msdn.com/b/wpfsdk/archive/2010/02/23/finding-an-object-treeviewitem.aspx.
    /// </remarks>
    /// <param name="itemsControl">The items control.</param>
    /// <param name="contentToFind">The content to find.</param>
    /// <returns>The matching TreeViewItem, otherwise null.</returns>
    private static TreeViewItem FindTreeViewItemRecursively(ItemsControl itemsControl, object contentToFind)
    {
        if (itemsControl == null)
        {
            return null;
        }
    
        if (itemsControl.DataContext == contentToFind)
        {
            return itemsControl as TreeViewItem;
        }
    
        ForceItemsControlToGenerateContainers(itemsControl);
    
        for (int i = 0; i < itemsControl.Items.Count; i++)
        {
            var childItemsControl = itemsControl.ItemContainerGenerator.ContainerFromIndex(i) as ItemsControl;
            var result = FindTreeViewItemRecursively(childItemsControl, contentToFind);
            if (result != null)
            {
                return result;
            }
        }
    
        return null;
    }            

    public by Magesolution  83  0  3  0

    Improve search quality & Speed up your store with Elastic Search Magento 2

    Searching a product in the Magento store can be a big pain for the customers specially when products are listed in a huge amount, this is a reason that most of the customers quit their online shopping. Hence, if you can help your customer search product fast also means you get more chances to gain customers’ sympathy. Thus, Elastic Search Magento 2
    https://www.magesolution.com/instant-search.html				

    public by msdn  110261  0  5  0

    OnProcessorFindCompleted: Done finding processors

    Done finding processors
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.ServiceModel;
    using System.ServiceModel.Discovery;
    using System.Threading;
    using System.Threading.Tasks;
    using BulkLoader.Network;
    using BulkLoader.Tools;
    using BulkLoader.Types;
    
    static bool _processorDiscoveryDone = false;
    static IBulkLoaderLogger _logger;
    static DiscoveryClient _processorDiscoveryClient;
    
    /// <summary>
    /// Done finding processors
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    static void OnProcessorFindCompleted(object sender, FindCompletedEventArgs e)
    {
        _processorDiscoveryDone = true;
        if (e.Cancelled)
        {
            _logger.LogMessage("Processor Discovery cancelled!");
        }
        else if (e.Error != null)
        {
            _processorDiscoveryClient.Close();
            _logger.LogError("Processor Discovery error", e.Error);
        }
        else
        {
            if (_processorDiscoveryClient.InnerChannel.State == System.ServiceModel.CommunicationState.Opened)
            {
                _processorDiscoveryClient.Close();
                _logger.LogMessage("Processor Discovery complete.");
            }
        }
    }
    • Public Snippets
    • Channels Snippets