working on it ...

Filters

Explore Public Snippets

Sort by

Found 2.9M snippets

    public by gwarah modified Sunday at 4:11:45 PM  589  3  6  0

    Is a file in a directory tree?

    This script is a shell function that performs exactly this check, even if the parameters are symbolic links and/or relative directories. See "How to Use" section to install this snippet
    #!/bin/bash
    # /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    # * File       : dircontains.sh
    # * Goal       : checks if <parent> direcory contains <file>
    # * Requisites :
    # *     1. SHELL=bash
    # * History    :
    # *   #version;date;description
    # *   0.2.0; 29/07/2018; now can check if any kind of file is in <parent>
    # *   0.1.0; 27/07/2018; first release (tested in bash environment)
    # */
    
    #
    # Tested in: ubuntu 16.04/bash
    #
    
    #
    # How to use
    #
    # 1. put this script into a directory (Ex: ~/scripts)
    #
    # 2. insert this code in your ~/.bashrc:
    # . ~/scripts/dircontains.sh
    #
    # 3. open a new shell session and test it:
    #
    # dircontains <dir_parent> <file>
    #
    # 4.
    # the result is in $? var
    # $?=0, <file> is in <dir_parent>
    # $?=1, <file> is not in <dir_parent>
    # $?=2, error
    #
    
    function dircontains_syntax {
        local msg=$1
        echo "${msg}" >&2
        echo "syntax: dircontains <parent> <file>" >&2
        return 1
    }
    
    function dircontains {
        local result=1
        local parent=""
        local parent_pwd=""
        local child=""
        local child_dir=""
        local child_pwd=""
        local curdir="$(pwd)"
        local v_aux=""
    
        # parameters checking
        if [ $# -ne 2 ]; then
            dircontains_syntax "exactly 2 parameters required"
            return 2
        fi
        parent="${1}"
        child="${2}"
        
        # exchange to absolute path
        parent="$(readlink -f "${parent}")"
        child="$(readlink -f "${child}")"
        dir_child="${child}"
    
        # file/directory checking
        if [ ! -d "${parent}" ];  then
            dircontains_syntax "parent dir ${parent} not a directory or doesn't exist"
            return 2
        elif [ ! -e "${child}" ];  then
            dircontains_syntax "file ${child} not found"
            return 2
        elif [ ! -d "${child}" ];  then
            # not directory? get the path of file
            dir_child=`dirname "${child}"`
        fi
    
        # get directories from $(pwd)
        cd "${parent}"
        parent_pwd="$(pwd)"
        cd "${curdir}"  # to avoid errors due relative paths
        cd "${dir_child}"
        child_pwd="$(pwd)"
    
        # checking if is parent
        [ "${child_pwd:0:${#parent_pwd}}" = "${parent_pwd}" ] && result=0
    
        # return to current directory
        cd "${curdir}"
        return $result
    }												

    public by simonwalker modified Jan 16, 2019  200  1  4  0

    Magento 2 Call For Price Extension By FME

    Magento 2 Call for price extension allows you to hide product prices from selected user groups or store views. You can replace the price option with ‘Get a quote’ popup, an image, or an alternative page. Subsequently, you can hide other Calls-to-action like ‘Add to Cart’, ‘Add to Wishlist’, and ‘Add to compare.’ Set conditions to restrict the price
    // code here 						

    public by PBMCube modified Jan 10, 2019  66  0  3  1

    Game Box Prototype

    command combinations Description: Quickly create operational games using simple box graphics from Phaser3 shapes (v3.13.x). This test game mechanics for enjoyment. Final Artwork added to game mechanisms, prototypes and mechanics as the final pipeline product phase.
    // ============
    //Example 4.1: Prototyping Graphics begins
    // ============
    //create a character avatar using the box prototype method 
    player = box({who: this, whereX: 150, whereY: 100,length:32, width:32, color: 0x0000FF,border: 0xFFFFFF});
    this.physics.add.existing(player);
    player.body.velocity.x = 10; //see update function
    player.body.velocity.y = 50;
    console.log("Stationary Blue character avatar created as 'player' variable.");
    // ------------  
    // OR the direct method using either rectangle or graphics
    //    and set movement velocities. 
    var avatar =  this.add.rectangle(100, 100, 32, 32, 0x0000FF).setStrokeStyle(5, 0x3399CC);
    console.log("Moving Blue character avatar created as 'player' variable.");
    var graphics = this.add.graphics({ fillStyle: { color: 0xFF0000 } });
    graphics.lineStyle(10,0xFF9900,0);
    graphics.strokeRect(100, 100, 32, 32);
    	
    //non-controlled movement (usage AI bot; see Chapter 6)
    graphics.fillRectShape(avatar);
    this.physics.add.existing(avatar);
    avatar.body.velocity.x = 50;
    avatar.body.velocity.y = 10;
    //non-controlled movement (usage AI bot; see Chapter 6)
    this.physics.add.existing(graphics);
    graphics.body.velocity.x = 50;
    graphics.body.velocity.y = 50;
    console.log("Moving Red avatar created as 'avatar' variable.\n Movement velocity set.");
    // ------------
    //create an opponent - direct method 
    var monster = this.add.rectangle(180, 60, 32, 32, 0x00FF00).setStrokeStyle(5, 0xFF9900);
    console.log("Green monster avatar created as 'monster' variable.");
    //Example 4.1: ends
    // ============
    

    public by PBMCube modified Jan 10, 2019  51  0  3  1

    Scene Preload an Image

    command format: Example:this.load.image("key", "path"); Description:Use this in the scene.preload function. .png are the default images. You can also set the "base URL"
    // ============
    // Example 3.4: Additional Phaser Properties begins
    // ============
    // remote URL to game assets
    // Cross-origin resource sharing (CORS)
    	this.load.setCORS = 'anonymous';
    // Setting base URL path
    	this.load.setBaseURL('http://makingbrowsergames.com/p3devcourse/_p3demos/imgages/');
    // Preload a gfx asset
    	this.load.image("face", "face.png");
    	

    public by PBMCube modified Jan 10, 2019  58  0  3  1

    Doors as Buttons

    Dungeon doorways should be both clickable and sense collisions.
    //Phaser III - clicking on a doorway  
    // ============
    // Example 4.6:  Doors as Buttons
    // ============
    // Creating door rectangles; review console in this experiment  
    //placed on a wall with 2px extended into the room
    doorN = this.add.rectangle(35,0,60,18,0x000000)  
            .setInteractive()  
            .setOrigin(0);  
    						

    public by PBMCube modified Jan 10, 2019  67  1  3  1

    Game Config File

    This is a config file example to pass into the Phaser.Game. It is a barebones Phaser3 configuration object
    var config = {
            type: graphics_mode,
            width: game_width,
            height: game_height,
            parent: 'div-tag-name',
            scene: [nameOfScene]
        };											

    public by PBMCube modified Jan 10, 2019  51  0  3  1

    Global Game Object

    Assigning a global namespace variable with delegation into Phaser.Game
    var game = new Phaser.Game(config);

    public by sjschmalfeld modified Dec 31, 2018  545  3  4  0

    SQL Duplicates

    WITH cte AS
    (SELECT *, ROW_NUMBER() OVER (PARTITION BY col1, col2, col3, col4 ORDER BY (SELECT 0)) AS DuplicateRowNumber
        FROM table
    )
    SELECT FROM cte WHERE DuplicateRowNumber > 1
    
    
    or----
    
    WITH cte as
    (SELECT PEOPLE.*, Loan.LoanID, ROW_NUMBER() OVER (PARTITION BY SocialSecurityNo ORDER BY SocialSecurityNo) AS DuplicateRowNumber
    FROM people INNER JOIN LOAN ON FK_PeopleID=PeopleID WHERE ISNULL(SocialSecurityNo,'') <> '' AND SocialSecurityNo <> '--' AND SocialSecurityNo <> '000-00-0000' AND loan.Status='active' )
    
    SELECT * INTO #TEMP99 FROM CTE WHERE cte.DuplicateRowNumber > 1
    
    SELECT *,b.SocialSecurityNo FROM dbo.Loan 
    	INNER JOIN (SELECT PeopleID,SocialSecurityNo FROM PEOPLE WHERE SocialSecurityNo	 
    							IN (SELECT SocialSecurityNo FROM #temp99)) b 
    	ON B.PeopleID=LOAN.FK_PeopleID
    	WHERE LOAN.Status='ACTIVE'
    
    DROP TABLE #TEMP99  
    
    
    -- Another way
    	--GET RID OF #NewAddressCandidates ADDESSES ALEADY IN THE ADDRESS TABLE
    	DELETE FROM #NewAddressCandidates WHERE EXISTS (
    	SELECT t.[Address1] 
    				,t.Address2
    				,t.City
    				,t.[State]
    				,SUBSTRING(t.Zip,1,5) AS ZIP, 
    				SUBSTRING(t.Zip,7,4) AS ZIP4 
    		FROM #NewAddressCandidates T 
    			INTERSECT  
    		SELECT [Address1] ,[Address2],[City],[State],[Zip],ZIP4 FROM dbo.[Address])				
    		
    		
    -- Another way
    	WITH NODUP AS 
    		(SELECT  A.ADDRESS1,A.ADDRESS2,A.CITY,A.STATE,A.ZIP,A.ZIP4
    			  , row_number() OVER ( PARTITION BY  A.ADDRESS1,A.ADDRESS2,A.CITY,A.STATE,A.ZIP,A.ZIP4 ORDER BY  A.ADDRESS1,A.ADDRESS2,A.CITY,A.STATE,A.ZIP,A.ZIP4 ) AS nr
    		FROM    #NewAddressCandidates A)
    	DELETE FROM NODUP WHERE NR > 1;	
    	
    	SELECT * INTO  #UniqueNewAddresses  FROM #NewAddressCandidates WHERE EXISTS (
    	SELECT t.[Address1] 
    				,t.Address2
    				,t.City
    				,t.[State]
    				,SUBSTRING(t.Zip,1,5) AS ZIP, 
    				SUBSTRING(t.Zip,7,4) AS ZIP4 			
    		FROM #NewAddressCandidates T 
    			EXCEPT 
    		SELECT [Address1] ,[Address2],[City],[State],[Zip],ZIP4 FROM dbo.[Address])
    	
    	// Now to remove the duplicate rows, use the same table and use EXCEPT operator with an 
    	// empty result set returned by the same table	
    	// USING except operator	
    	SELECT col1,col2
      FROM DuplicateRcordTable
      EXCEPT
      SELECT col1,col2
      FROM DuplicateRcordTable WHERE 1=0
    								

    public by DunyaBernardon modified Dec 31, 2018  61  0  3  0

    py4E

    Learning to code
    // Enter here the actual content of the snippet.						
    print("hello world")
    hello world
    
    
    
    
                

    public by Magesolution modified Dec 20, 2018  65  1  2  0

    Magento 2 Advanced Reports

    Magento 2 Advanced Reports bring 8 report options for you. With this Magento extension you can easily check current/ past reports of products, customers, orders... in the back-end of your Magento site. Its vivid and modern look combined with clean code surely help you generate perfect solutions for your reporting with visual charts and tables.
    https://www.magesolution.com/magento-advanced-reports-m2.html				
    • Public Snippets
    • Channels Snippets