working on it ...

Filters

Explore Public Snippets

Sort by

Found 2,249 snippets matching: installed

    public by qxshower  135615  1  5  0

    IsSQLiteDbProviderInstalled

    check if SQLite DB Provider is installed
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.IO;
    using System.Reflection;
    using System.ServiceModel.Syndication;
    using System.Xml;
    using ErikEJ.SqlCeScripting;
    using Microsoft.VisualStudio.Data.Core;
    using Microsoft.VisualStudio.Data.Services;
    using Microsoft.Win32;
    using Exceptionless;
    using ErikEJ.SqlCeToolbox.Dialogs;
    using ErikEJ.SQLiteScripting;
    
    internal static bool IsSQLiteDbProviderInstalled()
    {
        try
        {
            System.Data.Common.DbProviderFactories.GetFactory("System.Data.SQLite.EF6");
        }
        catch (System.Configuration.ConfigurationException)
        {
            return false;
        }
        catch (ArgumentException)
        {
            return false;
        }
        return true;
    }            

    public by cghersi  1943  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 KevinR  1946  2  5  0

    Display Installed Products by Vendor

    //enter here the actual content of the snippet:
    //the stuff you want to copy-and-paste wherever you need.
    
    Get-WmiObject Win32_Product -Filter "Vendor='Microsoft Corporation'" | Sort-Object Vendor, Name | Format-Table Vendor, Name, Version -groupBy Vendor
    

    public by canering  944  0  3  0

    Hook up your Homebrew installed with curl to your Github fork

    Hook up your Homebrew installed with curl to your Github fork: hook_up_homebrew.sh
    # Install Homebrew
    #
    mkdir -p /usr/local
    mkdir -p /usr/local/bin
    sudo chown -R $USER /usr/local
    cd $HOME && mkdir -p homebrew
    curl -L https://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C homebrew
    ln -nfs $HOME/homebrew/bin/brew /usr/local/bin/
    brew update
    
    # Hook up Homebrew installation in `~/homebrew` to your fork
    #
    rm -rf /tmp/myhomebrew
    git clone git@github.com:$USER/homebrew.git /tmp/myhomebrew
    git --git-dir=/tmp/myhomebrew/.git remote rename origin $USER
    git --git-dir=/tmp/myhomebrew/.git remote add upstream git://github.com/mxcl/homebrew.git
    cp -r /tmp/myhomebrew/.git $HOME/homebrew/.git
    rm -rf /tmp/myhomebrew
    
    
    

    public by sjschmalfeld  327  1  4  0

    Get a list of installed printers

    get a list of the installed printers on machine
    private void PopulateInstalledPrintersCombo()
    {
        // Add list of installed printers found to the combo box.
        // The pkInstalledPrinters string will be used to provide the display string.
        String pkInstalledPrinters;
        for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++)
        {
            pkInstalledPrinters = PrinterSettings.InstalledPrinters[i];
            comboInstalledPrinters.Items.Add(pkInstalledPrinters);
        }
    }					
    

    public by cghersi  22014  168  9  4

    How to run unit tests created with MS Visual Studio without installing Visual Studio

    Do you want to run your unit tests on your staging server? Surely you don't want to make your staging environment "dirty" by installing Visual Studio. I'm also not comfortable with installing the Test Agent. And perhaps you don't have the resources to use Visual Studio Online Continuous Integration stuff... It's not a problem of licenses. We don
    1) From C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow (copy all content of the folder):
    Extensions (folder)
    ActivateApplication.exe
    EntityFramework.dll
    extension.vsixmanifest
    Microsoft.TeamFoundation.TestPlatform.Client.dll
    Microsoft.TestTools.Cpp.targets
    Microsoft.VisualStudio.MSTest.TestWindow.dll
    Microsoft.VisualStudio.TestPlatform.BuildTasks.dll
    Microsoft.VisualStudio.TestPlatform.Client.dll
    Microsoft.VisualStudio.TestPlatform.Common.dll
    Microsoft.VisualStudio.TestPlatform.Core.dll
    Microsoft.VisualStudio.TestPlatform.Fakes.dll
    Microsoft.VisualStudio.TestPlatform.ObjectModel.dll
    Microsoft.VisualStudio.TestPlatform.TestExecutor.Core.dll
    Microsoft.VisualStudio.TestPlatform.Utilities.AppContainer.dll
    Microsoft.VisualStudio.TestPlatform.Utilities.dll
    Microsoft.VisualStudio.TestPlatform.Utilities.PhoneAppContainer.dll
    Microsoft.VisualStudio.TestWindow.Core.dll
    Microsoft.VisualStudio.TestWindow.CppUnitTestExtension.dll
    Microsoft.VisualStudio.TestWindow.dll
    Microsoft.VisualStudio.TestWindow.Interfaces.dll
    Microsoft.VisualStudio.TestWindow.pkgdef
    Microsoft.VisualStudio.TestWindow.VSTest.dll
    msdia120typelib_clr0200.dll
    TestWindowProvideCodeBase.pkgdef
    vstest.console.exe
    vstest.console.exe.config
    vstest.discoveryengine.exe
    vstest.discoveryengine.exe.config
    vstest.discoveryengine.x86.exe
    vstest.discoveryengine.x86.exe.config
    vstest.executionengine.clr20.exe
    vstest.executionengine.clr20.exe.config
    vstest.executionengine.exe
    vstest.executionengine.exe.config
    vstest.executionengine.x86.clr20.exe
    vstest.executionengine.x86.clr20.exe.config
    vstest.executionengine.x86.exe
    vstest.executionengine.x86.exe.config
    
    2) From C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC:
    vcvarsall.bat (put this file into a sufolder named "vc")
    
    3) From C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies:
    Microsoft.VisualStudio.QualityTools.Sqm.dll
    
    4) From C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ReferenceAssemblies\v2.0:
    Microsoft.VisualStudio.QualityTools.ExecutionCommon.dll
    
    5) For these files you need to use copy command from a DOS prompt, and then copy from c:/tmp to your staging folder: 
    copy C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.Resource\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.Resource.dll c:\tmp
    copy C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.Common\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.Common.dll c:\tmp
    copy C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel\12.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.Tips.UnitTest.ObjectModel.dll c:\tmp
    copy C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.UnitTestFramework\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll c:\tmp
    

    public by gwarah  2756  3  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 gwarah  1193  2  8  0

    improved cd: <directory pattern> as parameter

    An improvement of cd Linux command. From a given directory pattern, the snippet finds directories matching it and output them as a menu. # 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
    #!/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  271  2  5  0

    Create a symbolic link with file dialogs

    This script provides an easy way to create file (or folder) symbolic link using zenity file dialogs. requisites: It won't run in case of any restriction related creating symlink command (ln -s ...) or if zenity package wouldn't be installed. The syntax is very simple: crsln.sh [-f|-d] [/path/to/file_or_directory [/path/to/link_name]] [
    #!/bin/bash
    # program     : crsln.sh
    # description : create a symlink with zenity file dialog
    # author      : lp (Luís Pessoa)
    # version     : 0.1.0b
    # syntax      : 
    # 	  crsln.sh [-f|-d] [/path/to/file_or_directory] [/path/to/link_name]] 
    # dependences : 
    #   1) shell: bash  
    #   2) package: zenity
    #   3) see restrictions to create a symlink, man ln
    # history     :
    #   lp; 09/02/2018; first release
    #   lp; 12/12/2017; begin of development
    
    
    # syntax get_file
    function syntax {
        local SINTAX=""
        SINTAX=$1
        SINTAX+="\n syntax: get_file [-t <title>] [ -f <file_or_dir_selected> ] [-l <filters>]"
        SYNTAX+="\n for <filters> rules see: zenity --help-file-selection"
        
        echo -e "Error: ${SINTAX} \n" >&2
        return 1
    }
    
    # syntax script
    function syntax_main {
        local SINTAX=""
        SINTAX=$1
        SINTAX+="\n syntax: create_symlink.sh [-d|-f] [file_or_directory [link_name]]"
        SYNTAX+="\n for <filters> rules see: zenity --help-file-selection"
        
        echo -e "Error: ${SINTAX} \n" >&2
        return 1
    }
    
    # catch a directory or file
    function dir_or_file {
        local opc
        local pkey=""
        RETORNO=0
        
        # 0: zenity; 1: dialog; 2: shell
        local dialog_type=${DIALOG_TYPE}
    
        if [ $dialog_type -eq 0 ]; then
            opc=$(zenity --list  \
                --text "Target is file or directory?" \
                --radiolist  --column "Check" --column "Options" \
                TRUE "file" FALSE "directory" --separator=" ")
            case $? in
            1)
                    echo "Opção deve ser selecionada" >&2
                    return 1
                    ;;
            -1)
                    echo "Ocorreu um erro na seleção de opções"
                    return 1
                    ;;
            esac
        else
            syntax "dialog type not implemented yet."
            return 1
        fi
        
        echo "${opc}"
        return $RETORNO
    }
    
    # catch a directory or file
    function get_file {
        local opt_found=0
        local list_opt=""
        local pkey=""
        
        local fun_text="Choose a file"
        local fun_filename=""
        local fun_filters=""
        local fun_result=""
        
        # 0: zenity; 1: dialog; 2: shell
        local dialog_type=${DIALOG_TYPE}
        local zenity_keys="--file-selection"
        
        # flags
        local flag_dir=0
        
        OPTIND=1
        while getopts ":t:l:f:ds" pkey; do
    
            # verifica se chave já foi chamada
            # excluir chaves que foram chamadas mais de uma vez
            echo "${list_opt}" | grep -q $pkey
            if [ $? -eq 0 ]; then
                syntax "Option -$pkey called twice or more times."
                return 1
            fi
    
            # stored invoked keys
            (( opt_found++ ))
            list_opt="${list_opt};${pkey}"
    
            if [ $opt_found -gt 5 ]; then
                syntax "too many keys"
                return 1
            fi
    
            case "${pkey}" in
                t)
                    fun_text="${OPTARG}"
                    ;;
                f)
                    fun_filename="${OPTARG}"
                    ;;
                l)
                    fun_filters="${OPTARG}"
                    ;;
                d)
                    [ -z "${fun_text}" ] && fun_text="Choose a directory"
                    zenity_keys+=" --directory"
                    flag_dir=1
                    ;;
                s)
                    zenity_keys+=" --save "    
                    ;;    
                \?)
                    syntax "inavalid option: -$OPTARG"
                    return 1
                    ;;
                :)
                    syntax "Option -$OPTARG require argument."
                    return 1
                    ;;
            esac
        done
            
        # zenity_keys+=" --title=\"${fun_text}\" "
        
        if [ -s "${fun_filters}" ]; then
            zenity_keys+=" --file_filter=${fun_filters} "
        fi
        
        if [ -s "${fun_filename}" ]; then
            zenity_keys+=" --filename=${fun_filename} "
        fi
        
        # dialog tool
        if [ $dialog_type -eq 0 ]; then
            fun_result=`zenity --title="${fun_text}" ${zenity_keys}`
            case $? in
            1)
                    echo "No one option selected" >&2
                    return 1
                    ;;
            -1)
                    echo "Error!"
                    return 1
                    ;;
            esac
        else
            syntax "dialog type not implemented."
        fi
        
        echo "${fun_result}"
        return 0
    }
    
    export FILEMAP=""
    export DIRLINK=""
    export LINKNAME=""
    export FLAGTYPE=0
    export TYPEMAP="file"
    export CUR_DIR=`pwd`
    export RETORNO=0
    
    # 
    OPTIND=1
    opt_found=0
    while getopts ":df" pkey; do
        # stored invoked keys
        (( opt_found++ ))
    
        if [ $opt_found -gt 1 ]; then
            syntax_main "too many keys"
            exit 1
        fi
    
        case "${pkey}" in
        d)
             FLAGTYPE=1
             TYPEMAP="directory"
             ;;
        f)
             FLAGTYPE=1
             TYPEMAP="file"
             ;;
        \?)
             syntax_main "invalid key: -$pkey"
             exit 1
             ;;
        esac
    done
    
    # due -d|-f key
    [ $FLAGTYPE -eq 1 ] && shift
    
    # don't change this value!!
    # 0: zenity; 1: dialog; 2: shell
    export DIALOG_TYPE=0
    
    #
    # parameters validation
    #
    [ $# -gt 2 ] && syntax_main "Too many parameters: $#"
    
    # getting file or directory to link
    if [ $# -eq 0 ]; then
        [ $FLAGTYPE -eq 0 ] && TYPEMAP=`dir_or_file` 
        if [ "${TYPEMAP}" = "file" ]; then
            FILEMAP=`get_file -t "Choose any file to link"`
        else
            FILEMAP=`get_file -d -t "Choose any directory to link"`
        fi
    else
        FILEMAP="$1"
    fi 
    
    
    if [ -d "${FILEMAP}" ]; then 
        if [ "${TYPEMAP}" = "file" ]; then
           syntax_main "key set to -f can't link direcory ${FILEMAP}"
        fi
    elif [ -f "${FILEMAP}" ]; then 
        if [ "${TYPEMAP}" = "directory" ]; then
            syntax_main "key set to -d can't link file ${FILEMAP}"
        fi
    else
        syntax_main "Not found or not type regular file or directory: ${FILEMAP}"
        exit 1
    fi
    
    # getting linkname
    if [ $# -lt 2 ]; then
        LINKNAME=`get_file -s -t "Choose the linkname"`
    else
        LINKNAME="${2}"
    fi
    
    # check if ${LINKNAME} already exists file
    if [ -e ${LINKNAME} ]; then  
        if [ -L ${LINKNAME} ]; then
            zenity --question --text="Link ${LINKNAME} already exist. Overwrite it?" --ok-label="Yes" --cancel-label="No"
            if [ $? -ne 0 ]; then
                exit 1 
            fi
        else
            zenity --error --title "error" --text="${LINKNAME} already exist as file or directory"
            exit 1 
        fi    
    fi
    # link
    echo ""
    echo "---------------"
    echo "${TYPEMAP} : ${FILEMAP} "
    echo "link : ${LINKNAME} "
    
    echo ""
    echo "Press a key to continue or [ctrl]+c to exit " ; read
    ln -s -r "${FILEMAP}" "${LINKNAME}"
    [ $? -gt 0 ] && echo "failure!" && exit 1
    
    echo "sucess!"
    exit $RETORNO
    																																																

    public by msdn  183606  0  6  0

    SelectManagementCertFile: Return a collection of installed X509Certificates from standard X509Certificate dialogue window

    Return a collection of installed X509Certificates from standard X509Certificate dialogue window
    using System;
    using System.IO;
    using System.Security.Cryptography.X509Certificates;
    using System.Security.Cryptography;
    using Microsoft.ComputeCluster.Management.Win32Helpers;
    using System.Collections.Generic;
    
    /// <summary>
    /// Return a collection of installed X509Certificates from standard X509Certificate dialogue window
    /// </summary>
    /// <returns></returns>
    public static X509Certificate2Collection SelectManagementCertFile()
    {
        X509Certificate2Collection certs = X509Certificate2UI.SelectFromCollection(GetValidCertificates(),
                                           "Select a Windows Azure Management Certificate",
                                           "",
                                           X509SelectionFlag.SingleSelection);
        return certs;
    }
    • Public Snippets
    • Channels Snippets