working on it ...

Filters

Explore Public Snippets

Sort by

Found 2.9M snippets

    public by Hlinh modified May 16, 2018  72  0  3  0

    Magento 2 Catalog Ajax Scroll extension

    Catalog Ajax Scroll extension helps to load the next pages of the catalog pages automatically. As soon users scroll to the last row of the current product list, the next page is loaded simultaneously with powerful AJAX. The extension is totally useful for both shop owner and customers shopping on the site. Particularly, this extension increases
    https://www.magesolution.com/catalog-ajax-scroll.html				

    public by kerid18 modified May 9, 2018  183  1  4  1

    Random 8 Character Password Generator Script

    #!/bin/bash
    #
    #
    #  Random password generator for Bash 2.x +
    #+ by Antek Sawicki <tenox@tenox.tc>,
    #+ who generously gave usage permission to the ABS Guide author.
    #
    # ==> Comments added by document author ==>
    
    
    MATRIX="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
    # ==> Password will consist of alphanumeric characters.
    LENGTH="8"
    # ==> May change 'LENGTH' for longer password.
    
    
    while [ "${n:=1}" -le "$LENGTH" ]
    # ==> Recall that := is "default substitution" operator.
    # ==> So, if 'n' has not been initialized, set it to 1.
    do
    	PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}"
    	# ==> Very clever, but tricky.
    
    	# ==> Starting from the innermost nesting...
    	# ==> ${#MATRIX} returns length of array MATRIX.
    
    	# ==> $RANDOM%${#MATRIX} returns random number between 1
    	# ==> and [length of MATRIX] - 1.
    
    	# ==> ${MATRIX:$(($RANDOM%${#MATRIX})):1}
    	# ==> returns expansion of MATRIX at random position, by length 1. 
    	# ==> See {var:pos:len} parameter substitution in Chapter 9.
    	# ==> and the associated examples.
    
    	# ==> PASS=... simply pastes this result onto previous PASS (concatenation).
    
    	# ==> To visualize this more clearly, uncomment the following line
    	#                 echo "$PASS"
    	# ==> to see PASS being built up,
    	# ==> one character at a time, each iteration of the loop.
    
    	let n+=1
    	# ==> Increment 'n' for next pass.
    done
    
    echo "$PASS"      # ==> Or, redirect to a file, as desired.
    
    exit 0
    +

    public by Hlinh modified May 5, 2018  140  0  3  0

    Mega Menu For Magento 2

    Magento Mega Menu is developed and optimized to allow both user and admin who don't need to be developers themselves to manage effortlessly all information which they want to show on main navigation of a Magento website such as: categories, products, text contents, images, video, forms...Get details: https://www.magesolution.com/mega-menu-magento-2
    https://www.magesolution.com/mega-menu-magento-2.html					

    public by gwarah modified May 3, 2018  214  0  7  0

    improved cd: <directory pattern> as parameter

    An improvement of cd Linux command. From a directory , the snippet shows a menu with the matching directories to user choose one. # Requisites: 1. SHELL=bash 2. locatedb available and up to date. It's necessary to select the directories (see: man (locate | locatedb | updatedb) for more information) # How to use: 1. put this script
    #!/bin/bash
    # /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    # * File       : rexcd.sh
    # * Goal       : improve cd linux command
    # * Requisites :
    # *     1. SHELL=bash
    # *     2. Locate service available and up to date. It's necessary to search directories
    # *        (see locate, locatedb and updatedb manual for more information)
    # * History    :
    # *   #version;date;description
    # *   0.1.1; 02/05/2018; tested in ubuntu 16.04/bash and minor code improvements
    # *   0.1.0; 30/04/2018; first release (tested in cygwin 2.10.x)
    # */
    
    # How to use
    #
    # 1. put this script into a directory (Ex: ~/scripts)
    #
    # 2. insert this code in your ~/.bashrc:
    # . ~/scripts/rexcd.sh
    #
    # 3. open a new shell session and test it:
    # cd ~
    # rexcd scripts
    #
    # 4. Example of output (cygwin 2.10.x)
    # Choose one directory
    # 
    # 1) /home/prpe/scripts
    # 2) /home/prpe/sintaxe/scripts_plone
    # 3) /home/prpe/sintaxe/scripts_plone/scripts
    # 4) /usr/share/doc/xorg-scripts-1.0.1
    # 5) /usr/x86_64-pc-cygwin/lib/ldscripts
    # Option [1] 2
    # 
    #  
    # prpe@DESK-00-090117 ~/sintaxe/scripts_plone
    # $
    
    
    #
    # ToDo:
    #
    # 1. switch:-i (ignore case)
    # 2. switch:-l limits of directories in menu (from m-th to n-th search matches)  (m,n|m,|,n default 1 to number of matches)
    # 3. switch:-d root directory -d <dir> (default /)
    # 4. switch:-u perform an update of db table
    #
    
    # syntax: rexcd_exit <msg>
    function rexcd_exit {
        local msg=$1
        echo "${msg}" >&2
        return 1
    }
    
    # syntax: 
    #  export rexcd_opt=""
    #  rexcd_menu opt1 opt2 ... optn
    #  echo $rexcd_opt
    function rexcd_menu {
        # return code + option
        local FN_RESULT=1
        rexcd_opt=""
    
        # variáveis de controle
        local num_options=$#
        local arr_options
        local num_choose=1
        local FN_DEFAULT=""
        local v_aux1 v_aux2
        local fl ind
    
        # menu message
        local FN_MSG="Choose one directory "
        local PS3="#"
    
        # checking number of options and creating list of them
        if [ $num_options -lt 2 ]; then
            rexcd_exit "At least 2 options required"
            return $?
        fi
    
        let ind=1
        for fl in $*; do
            arr_options[${ind}]="${fl}"
            let ind++
        done
    
        # menu
        FN_RESULT=1
        ind=1
        num_choose=""
        FN_DEFAULT=$ind
        PS3="Option [${FN_DEFAULT}] "
        
        echo "" ; echo "${FN_MSG}" ; echo ""
        select num_choose in `echo ${arr_options[@]}`; do
            case "${num_choose}" in
                *)
                    if [ -z "${num_choose}" ]; then
                        read -t 2 -p "Invalid option"
                        echo "" ; echo "${FN_MSG}" ; echo ""
                        continue
                    fi
                    FN_RESULT=0
                    break
                    ;;
            esac
        done
        echo ""
    
        rexcd_opt="${num_choose}"
        return ${FN_RESULT}
    }
    
    function rexcd {
        local contador fl
        local padrao=""
        local max_opc=15
        local lst_opc=""
        local retorno=0
        local v_aux=0
    
        # its necessary declare as export
        export rexcd_opt=""
    
        if [ $# -ne 1 ]; then
            rexcd_exit "Number of arguments invalid: $#. Must be exactly one."
            return $?
        fi
    
        padrao=$1
        contador=0
        cd /
        for fl in `locate -i "${padrao}"`; do
            # filter not directories elements
            [ ! -d "${fl}" ] && continue
    
            # search regards
            basename "${fl}" | grep -q -i "${padrao}"
            [ $? -ne 0 ] && continue
    
    
            # update array e var count
            let v_aux=contador+1
    
            if [ $contador -eq 1 ]; then
                lst_opc="${fl}"
            else
                lst_opc="${lst_opc} ${fl}"
            fi
    
            let contador++
            # verifica o máximo de entrada
            if [ $contador -ge $max_opc ]; then
                echo "WARNING: Maximum number of options $max_opc reached" >&2
                break
            fi
        done
    
        if [ ${contador} -eq 1 ]; then
            rexcd_opt="${lst_opc}"
        elif [ ${contador} -gt 1 ]; then
            export rexcd_opt=""
            rexcd_menu ${lst_opc}
            retorno=$?
        else
            rexcd_exit "No directory matches with ${padrao}."
            retorno=$?
        fi
    
        [ $retorno -eq 0 ] && cd ${rexcd_opt}
        return ${retorno}
    }
    																		

    public by gwarah modified May 2, 2018  1337  2  6  0

    List (and optionally run) snapped apps

    Show all installed snaped apps in a zenity menu. The user can choose one and run it. just run this script: ./mysnaps.sh
    #!/bin/bash
    # program     : mysnaps.sh
    # description : choose one snapped app and run it
    # author      : lp (Luís Pessoa)
    # version     : 0.1.0b
    # dependences : 
    #   1) shell: bash 
    #   2) packages awk, snap and zenity installed
    #   3) at least one snap app instaled
    # history     :
    #   lp; 07/02/2018; begin of development
    #   lp; 09/02/2018; first release
    
    ###############
    # functions
    ###############
    
    
    ###############
    # end functions
    ###############
    
    # building snap list header 
    snap_cols="$(snap list | \
    awk '{ if (NR == 1) { for (i = 1; i <= NF; i++)  printf "--column " $i " " }} ')"
    snap_cols="--column check ${snap_cols}"
    
    # building snap list options
    snap_ops=$(snap list | \
    awk '
    BEGIN { }
    {
    if (NR >= 2 ) {
        for (i = 1; i <= NF; i++) {
            
            if ( i == 1 ) {
                if ( $i == "core"  ) break;
                if (NR == 2) {printf "TRUE ";} 
                else {printf "FALSE ";}
            }
            printf $i;
            if ( i == NF ) { print "";}
            else { printf " "; }
       }
    }}')
    
    # snap app selection
    opc=$(zenity  --list  --text "Apps snaped " --radiolist  ${snap_cols} ${snap_ops})
    case $? in
             1)
                    echo "No snap app selected"
                    exit 1
                    ;;
            -1)
                    echo "Error!"
                    exit 1
                    ;;
    esac
    
    # run app selected
    app_opc=`echo $opc | awk '{print $1}'`
    ${app_opc}
    exit $?
    												

    public by simon_sourcecode modified May 2, 2018  131  0  1  0

    Konstanten durch neue Definition ersetzen

    PHP
    // Replace define with const
    [DEFINdefin]{6}[ ]*\(\'ARTRES_PROP_([A-Z_0-9]+)\',([\t 0-9]+)\)\;

    public by JKCPR modified Apr 25, 2018  164  0  4  0

    unit testing - mocking server responses with sinonjs

    {
        setUp: function () {
            this.server = sinon.fakeServer.create();
        },
    
        tearDown: function () {
            this.server.restore();
        },
    
        "test should fetch comments from server" : function () {
            this.server.respondWith("GET", "/some/article/comments.json",
                                    [200, { "Content-Type": "application/json" },
                                     '[{ "id": 12, "comment": "Hey there" }]']);
    
            var callback = sinon.spy();
            myLib.getCommentsFor("/some/article", callback);
            this.server.respond();
    
            sinon.assert.calledWith(callback, [{ id: 12, comment: "Hey there" }]));
        }
    }		

    public by Hlinh modified Apr 17, 2018  270  0  5  0

    Lookbook for Magento 2 by Magesolution

    Lookbook for Magento 2 is a magical tool which allows you to create multiple image collections for your products basing on the images you upload. What makes this extension so special and unique is that it offers a Pinning option for every image, i.e you can pin different images for products/ items onto the main image, which ultimately envisages a c
    https://www.magesolution.com/lookbook-for-magento-2.html						

    public by azazqadir modified Apr 11, 2018  292  1  5  0

    Using WooCommerce Rest API for Custom Dashboard

    Using WooCommerce Rest API (https://www.cloudways.com/blog/custom-dashboard-using-woocommerce-php-rest-api/ ) to create a Custom Dashboard
    <div class="container">
    
                                      <h2 class="sub-header">Customers List</h2>
    
                                      <div class='table-responsive'>
    
                                          <table id='myTable' class='table table-striped table-bordered'>
    
                                              <thead>
    
                                                  <tr>
    
                                                      <th>Email</th>
    
                                                      <th>Name</th>
    
                                                      <th>Billing Address</th>
    
                                                      <th>Total Orders</th>
    
                                                      <th>Total spent</th>
    
                                                      <th>Avatar</th>
    
                                                      <th>Actions</th>
    
                                                  </tr>
    
                                              </thead>
    
                                              <tbody>
    
                                                  <?php
    
                      foreach($customers as $customer){
    
    
    
                      echo "<tr><td>" . $customer["email"]."</td>
    
                                <td>" . $customer["first_name"].$customer["last_name"]."</td>
    
                                <td>" . $customer["billing"]["address_1"]."</td>
    
                                <td>" . $customer["orders_count"]."</td>
    
                                <td>" . $customer["total_spent"]."</td>
    
                                <td><img height='50px' width='50px' src='".$customer["avatar_url"]."'></td>
    
                                 <td><a class='open-AddBookDialog btn btn-primary' data-target='#myModal' data-id=".$customer['id']." data-toggle='modal'>Update</a>
    
                                 <a class='open-deleteDialog btn btn-danger' data-target='#myModal1' data-id=".$customer['id']." data-toggle='modal'>Delete</a></td></tr>";
    
                      }
    
    
    
                      ?>
    
                                              </tbody>
    
                                          </table>
    
                                      </div>
    
      </div>												

    public by engineerBry modified Apr 10, 2018  286  0  4  0

    sadh

    liasdas
    safasdfasdf
    • Public Snippets
    • Channels Snippets