问:
Getting all item in DB
I am trying to get an array of items from my DB using gorm it works fine and I am able to retrieve data but I am only getting one item in the array while there are more than that. here is my code to retrieve the array.

Model.go

```<code>type Address struct {
    ID        uuid.UUID  `json:"id" gorm:"primary_key;unique;not null"`
    Line      string     `gorm:"size:255;not null;column:line" json:"line"`
    Hostel    string     `gorm:"size:255;not null;column:hostel" json:"hostel"`
    CreatedAt time.Time  `gorm:"default:CURRENT_TIMESTAMP;column:createdAt" json:"createdAt"`
    UpdatedAt time.Time  `gorm:"default:CURRENT_TIMESTAMP;column:updatedAt" json:"updatedAt"`
    DeletedAt *time.Time `sql:"index;column:deletedAt" json:"deletedAt"`
}

type Addresses []Address
</code>```

Database.go

```<code>type DbAddress struct {
    *model.Address
}

func (address *DbAddress) Get(db *gorm.DB) ([]model.Address, *errors.Error) {
    var err error
    addr := []model.Address{}
    err = db.Debug().Model(model.Address{}).Limit(100).Take(&addr).Error
    if gorm.IsRecordNotFoundError(err) {
        return nil, errors.NewNotFoundError(fmt.Sprintf("Address not found: %s", err.Error()))
    }
    if err != nil {
        return nil, errors.NewBadRequestError(fmt.Sprintf("error when trying to get Address: %s", err.Error()))
    }
    return addr, nil
}
</code>```

Services.go

```<code>func GetAddress() (model.Addresses, *errors.Error) {
    result := database.DbAddress{Address: &model.Address{}}

    return result.Get(database.DB)
}
</code>```

Controller.go

```<code>func GetAddress(c *gin.Context) {

    address, getErr := services.GetAddress()
    if getErr != nil {
        res.ResponseJSON(c, getErr.Status, nil, true, getErr.Message)
        return
    }
    res.ResponseJSON(c, http.StatusFound, address, false, "successfully got address data")
}
</code>```

答:
Use Find instead of Take.

```<code>// Get first record, order by primary key
db.First(&user)
//// SELECT * FROM users ORDER BY id LIMIT 1;

// Get one record, no specified order
db.Take(&user)
//// SELECT * FROM users LIMIT 1;

// Get last record, order by primary key
db.Last(&user)
//// SELECT * FROM users ORDER BY id DESC LIMIT 1;

// Get all records
db.Find(&users)
//// SELECT * FROM users;

// Get record with primary key (only works for integer primary key)
db.First(&user, 10)
//// SELECT * FROM users WHERE id = 10;
</code>```

For more detials see: https://gorm.io/docs/query.html

Title: Getting all item in DB

Body:
I am trying to get an array of items from my DB using gorm it works fine and I am able to retrieve data but I am only getting one item in the array while there are more than that. here is my code to retrieve the array.

Model.go

type Address struct {
    ID        uuid.UUID  `json:"id" gorm:"primary_key;unique;not null"`
    Line      string     `gorm:"size:255;not null;column:line" json:"line"`
    Hostel    string     `gorm:"size:255;not null;column:hostel" json:"hostel"`
    CreatedAt time.Time  `gorm:"default:CURRENT_TIMESTAMP;column:createdAt" json:"createdAt"`
    UpdatedAt time.Time  `gorm:"default:CURRENT_TIMESTAMP;column:updatedAt" json:"updatedAt"`
    DeletedAt *time.Time `sql:"index;column:deletedAt" json:"deletedAt"`
}

type Addresses []Address

Database.go

type DbAddress struct {
    *model.Address
}

func (address *DbAddress) Get(db *gorm.DB) ([]model.Address, *errors.Error) {
    var err error
    addr := []model.Address{}
    err = db.Debug().Model(model.Address{}).Limit(100).Take(&addr).Error
    if gorm.IsRecordNotFoundError(err) {
        return nil, errors.NewNotFoundError(fmt.Sprintf("Address not found: %s", err.Error()))
    }
    if err != nil {
        return nil, errors.NewBadRequestError(fmt.Sprintf("error when trying to get Address: %s", err.Error()))
    }
    return addr, nil
}

Services.go

func GetAddress() (model.Addresses, *errors.Error) {
    result := database.DbAddress{Address: &model.Address{}}

    return result.Get(database.DB)
}

Controller.go

func GetAddress(c *gin.Context) {

    address, getErr := services.GetAddress()
    if getErr != nil {
        res.ResponseJSON(c, getErr.Status, nil, true, getErr.Message)
        return
    }
    res.ResponseJSON(c, http.StatusFound, address, false, "successfully got address data")
}

Body:
Use Find instead of Take.

// Get first record, order by primary key
db.First(&user)
//// SELECT * FROM users ORDER BY id LIMIT 1;

// Get one record, no specified order
db.Take(&user)
//// SELECT * FROM users LIMIT 1;

// Get last record, order by primary key
db.Last(&user)
//// SELECT * FROM users ORDER BY id DESC LIMIT 1;

// Get all records
db.Find(&users)
//// SELECT * FROM users;

// Get record with primary key (only works for integer primary key)
db.First(&user, 10)
//// SELECT * FROM users WHERE id = 10;

For more detials see: https://gorm.io/docs/query.html


来源: stackexchange

问:
Dockerfile build: FileNotFoundError: [Errno 2] No such file or directory
Why am I getting FileNotFoundError: [Errno 2] No such file or directory when, during my Dockerfile build, the file is clearly put on the filesystem. E.g. here's the latest output from Docker:

```<code>Step 8/9 : COPY https.py /tmp
 ---> Using cache
 ---> 685946ede218
Step 9/9 : RUN /usr/bin/python3 /tmp/https.py
 ---> Running in c1c2acba9483
Traceback (most recent call last):
  File "/tmp/https.py", line 16, in <module>
    certfile='/etc/nginx/certs/cert.pem', server_side=True)
  File "/usr/lib/python3.7/ssl.py", line 1216, in wrap_socket
    context.load_cert_chain(certfile, keyfile)
FileNotFoundError: [Errno 2] No such file or directory
</code>```

If I comment out Step 9, then re-build and exec into the container I can see the following files:

```<code>root@8eef51287e5b:/# ls -l /tmp/https.py
-rw-r--r-- 1 root root 504 Feb 17 15:53 /tmp/https.py
root@8eef51287e5b:/# ls -l /etc/nginx/certs/
total 8
-rw-r--r-- 1 root root 1903 Jan 21 16:23 cert.pem
-rw------- 1 root root 1704 Jan 21 16:23 privkey.pem
</code>```

Why am I getting a FileNotFoundError?

答:
This error happened to me while the Dockerfile was under a bad format (Windows, including carriage retrun + line feed) so that the code was not read properly after a docker-compose command.

It disappeared when I changed the file format with Notepad++ switcching from Windows (CR LF) to Unix (LF). This can be done in the lower banner next to the text format indicating UTF-8 for exemple.

ContentLicense: CC BY-SA 4.0

Body:
Why am I getting FileNotFoundError: [Errno 2] No such file or directory when, during my Dockerfile build, the file is clearly put on the filesystem. E.g. here's the latest output from Docker:

Step 8/9 : COPY https.py /tmp
 ---> Using cache
 ---> 685946ede218
Step 9/9 : RUN /usr/bin/python3 /tmp/https.py
 ---> Running in c1c2acba9483
Traceback (most recent call last):
  File "/tmp/https.py", line 16, in <module>
    certfile='/etc/nginx/certs/cert.pem', server_side=True)
  File "/usr/lib/python3.7/ssl.py", line 1216, in wrap_socket
    context.load_cert_chain(certfile, keyfile)
FileNotFoundError: [Errno 2] No such file or directory

If I comment out Step 9, then re-build and exec into the container I can see the following files:

root@8eef51287e5b:/# ls -l /tmp/https.py
-rw-r--r-- 1 root root 504 Feb 17 15:53 /tmp/https.py
root@8eef51287e5b:/# ls -l /etc/nginx/certs/
total 8
-rw-r--r-- 1 root root 1903 Jan 21 16:23 cert.pem
-rw------- 1 root root 1704 Jan 21 16:23 privkey.pem

Why am I getting a FileNotFoundError?


问:
Grep: How to only find the first price mentioned in a line of text
I have a bunch of variable text in Adobe Indesign and I'd like the first mentioned price in each line of text to have another color. I am completely new to regular expressions and got stuck.
I used the following grep to find the price but it find's all prices mentioned in the text.

€[0-9]+([.,][0-9]+)*

The text is like below and I need to get only the bold prices:

Spend €99,99, get €25 off

Spend €150, get €35 off

I tried lot's of things mentioned on stack overflow and online but just can't find the right solution. Adding ? at the end to make it lazy doesn't do the trick. I think I need to do some grouping on the grep-code but can't find the right way to do so. Any help would be great!

答:
create two character styles "Bold" and "Roman", the latter should be the same character style as in your paragraph style.

Create two GREP styles. The first one should apply character style "Bold" to text with the following pattern:

```<code>^.*?(€\d+(?:,\d+)*)
</code>```

the second one should apply character style "Roman" to text with the following pattern:

```<code>^.*?(?=€)
</code>```

Body:
create two character styles "Bold" and "Roman", the latter should be the same character style as in your paragraph style.

Create two GREP styles. The first one should apply character style "Bold" to text with the following pattern:

^.*?(€\d+(?:,\d+)*)

the second one should apply character style "Roman" to text with the following pattern:

^.*?(?=€)


问:
Pre load background images in jQuery
I'm having trouble pre loading background images. This is my attempt but still seems to not be working - ie. there is still a delay seeing the image when i call showAjaxLoader("#mytarget"). Does anybody have any suggestions?

CSS:

```<code>div.entryform-ajax-loader {
    background-image:url(../images/preloader-entry-form.gif);
}
</code>```

Script:

```<code>var ajax_loader = $('<div />').attr('class', 'entryform-ajax-loader');

function showAjaxLoader(target)
{
    $(target).append(ajax_loader);
}

function hideAjaxLoader(target)
{
    ajax_loader.remove();
</code>```

答:
```<code><div style="display:none">
<img src="../images/preloader-entry-form.gif">
</div>
</code>```

In the head of page body or if you need JQuery solution

```<code>http://engineeredweb.com/blog/09/12/preloading-images-jquery-and-javascript
</code>```

ContentLicense: CC BY-SA 3.0

Title: Pre load background images in jQuery

Body:
I'm having trouble pre loading background images. This is my attempt but still seems to not be working - ie. there is still a delay seeing the image when i call showAjaxLoader("#mytarget"). Does anybody have any suggestions?

CSS:

div.entryform-ajax-loader {
    background-image:url(../images/preloader-entry-form.gif);
}

Script:

var ajax_loader = $('
').attr('class', 'entryform-ajax-loader');

function showAjaxLoader(target)
{
    $(target).append(ajax_loader);
}

function hideAjaxLoader(target)
{
    ajax_loader.remove();

Body:
<div style="display:none">
<img src="../images/preloader-entry-form.gif">
</div>

In the head of page body or if you need JQuery solution

http://engineeredweb.com/blog/09/12/preloading-images-jquery-and-javascript


问:
Python "TypeError: 'bool' object is not callable" Error
I am writing a simple Tic-Tac-Toe game that is a player vs computer game, and I keep getting the "TypeError: 'bool' object is not callable" Error, and I do not understand why I am getting these errors. I have gone through both the formatting and the syntax multiple times and I can't see anything wrong with my code but I keep getting a few errors.  Here is my code. </p>

```<code>import random

def drawBoard(board):
    #This function prints out the board that it was passed.

    #board" is a list of 10 strings representing the board (ignore index 0).
    print(board[7] + '| ' + board[8] + '| ' + board[9])
    print('-+-+-')
    print(board[4] + '| ' + board[5] + '| ' + board[6])
    print('-+-+-')
    print(board[1] + '| ' + board[2] + '| ' + board[3])

def inputPlayerLetter():
    letter = ''
    while not (letter == 'X' or letter == '0'):
        print('Do you want to be X or O?')
        letter = input().upper()
    if letter == 'X':
        return ['X', '0']
    else:
        return ['0', 'X']

def whoGoesFirst():
    if random.randint(0,1) == 0:
        return ' computer'
    else:
        return ' player'

def makeMove(board, letter, move):
    board[move] = letter

def isWinner(bo, le):
    return ((bo[7] == le and bo[8] == le and bo [9] == le) or
    (bo[4] == le and bo[5] == le and bo [6] == le)
    (bo[1] == le and bo[2] == le and bo [3] == le)
    (bo[7] == le and bo[4] == le and bo [1] == le)
    (bo[8] == le and bo[5] == le and bo [2] == le)
    (bo[9] == le and bo[6] == le and bo [3] == le)
    (bo[7] == le and bo[5] == le and bo [3] == le)
    (bo[9] == le and bo[5] == le and bo [1] == le))

def getBoardCopy(board):
    boardCopy = []
    for i in board:
        boardCopy.append(i)
    return boardCopy

def isSpaceFree(board, move):
    return board[move] == ' '

def getPlayerMove(board):
    move = ' '
    while move not in '1 2 3 4 5 6 7 8 9'.split() or not isSpaceFree(board, int(move)):
        print('What is your next move? (1-9)')
        move = input()
    return int(move)

def chooseRandomMoveFromList(board, movesList):
    possibleMoves = []
    for i in movesList:
        if isSpaceFree(board, i):
            possibleMoves.append(i)

    if len(possibleMoves) !=0:
        return random.choice(possibleMoves)
    else:
        return None

def getComputerMove(board, computerLetter):
    if computerLetter == 'X':
        playerLetter = '0'
    else:
        playerLetter = 'X'

    for i in range(1, 10):
        boardCopy = getBoardCopy(board)
        if isSpaceFree (boardCopy, i):
            makeMove(boardCopy, computerLetter, i)
            if isWinner(boardCopy, computerLetter):
                return i

    for i in range(1,10):
        boardCopy = getBoardCopy(board)
        if isSpaceFree(boardCopy, i):
            makeMove(boardCopy, playerLetter, i)
            if isWinner(boardCopy, playerLetter):
                return i

    move = chooseRandomMoveFromList (board, [1, 3, 7, 9])
    if move !=None:
        return move

    if isSpaceFree(board, 5):
        return 5

    return chooseRandomMoveFromList(board, [2, 4, 6, 8])

def isBoardFull(board):
    for i in range(1,10):
        if isSpaceFree(board, i):
            return False
        return True

print('Welcome to Tic-Tac-Toe!')

while True:
    theBoard = [' '] * 10
    playerLetter, computerLetter = inputPlayerLetter()
    turn = whoGoesFirst()
    print('The' +turn+ ' will go first.')
    gameIsPlaying = True

    while gameIsPlaying:
        if turn == 'player':
            drawBoard(theBoard)
            move = getPlayerMove(theBoard)
            makeMove(theBoard, playerLetter, move)

            if isWinner(theBoard, playerLetter):
                drawBoard(theBoard)
                print('Horray! You have won the game!')
                gameIsPlaying = False
            else:
                if isBoardFull(theBoard):
                    drawBoard(theBoard)
                    print('The game is a tie!')
                    break
                else:
                    turn = 'computer'

        else:
            move = getComputerMove(theBoard, computerLetter)
            makeMove(theBoard, computerLetter, move)

            if isWinner(theBoard, computerLetter):
                drawBoard(theBoard)
                print('The computer has beaten you! You lose.')
                gameIsPlaying = False
            else:
                if isBoardFull(theBoard):
                    drawBoard(theBoard)
                    print('The game is a tie!')
                    break
                else:
                    turn = 'player'

    print('Do you want to play again? (yes or no)')
    if not input().lower().startswith('y'):
        break
</code>```

答:
The problem is in this function:

```<code>def isWinner(bo, le):
    return ((bo[7] == le and bo[8] == le and bo [9] == le) or
    (bo[4] == le and bo[5] == le and bo [6] == le)
    (bo[1] == le and bo[2] == le and bo [3] == le)
    (bo[7] == le and bo[4] == le and bo [1] == le)
    (bo[8] == le and bo[5] == le and bo [2] == le)
    (bo[9] == le and bo[6] == le and bo [3] == le)
    (bo[7] == le and bo[5] == le and bo [3] == le)
    (bo[9] == le and bo[5] == le and bo [1] == le))
</code>```

You have an or after the first line, but it's missing on all the other lines.

Body:
I am writing a simple Tic-Tac-Toe game that is a player vs computer game, and I keep getting the "TypeError: 'bool' object is not callable" Error, and I do not understand why I am getting these errors. I have gone through both the formatting and the syntax multiple times and I can't see anything wrong with my code but I keep getting a few errors.  Here is my code.

import random

def drawBoard(board):
    #This function prints out the board that it was passed.

    #board" is a list of 10 strings representing the board (ignore index 0).
    print(board[7] + '| ' + board[8] + '| ' + board[9])
    print('-+-+-')
    print(board[4] + '| ' + board[5] + '| ' + board[6])
    print('-+-+-')
    print(board[1] + '| ' + board[2] + '| ' + board[3])

def inputPlayerLetter():
    letter = ''
    while not (letter == 'X' or letter == '0'):
        print('Do you want to be X or O?')
        letter = input().upper()
    if letter == 'X':
        return ['X', '0']
    else:
        return ['0', 'X']

def whoGoesFirst():
    if random.randint(0,1) == 0:
        return ' computer'
    else:
        return ' player'

def makeMove(board, letter, move):
    board[move] = letter

def isWinner(bo, le):
    return ((bo[7] == le and bo[8] == le and bo [9] == le) or
    (bo[4] == le and bo[5] == le and bo [6] == le)
    (bo[1] == le and bo[2] == le and bo [3] == le)
    (bo[7] == le and bo[4] == le and bo [1] == le)
    (bo[8] == le and bo[5] == le and bo [2] == le)
    (bo[9] == le and bo[6] == le and bo [3] == le)
    (bo[7] == le and bo[5] == le and bo [3] == le)
    (bo[9] == le and bo[5] == le and bo [1] == le))

def getBoardCopy(board):
    boardCopy = []
    for i in board:
        boardCopy.append(i)
    return boardCopy

def isSpaceFree(board, move):
    return board[move] == ' '

def getPlayerMove(board):
    move = ' '
    while move not in '1 2 3 4 5 6 7 8 9'.split() or not isSpaceFree(board, int(move)):
        print('What is your next move? (1-9)')
        move = input()
    return int(move)

def chooseRandomMoveFromList(board, movesList):
    possibleMoves = []
    for i in movesList:
        if isSpaceFree(board, i):
            possibleMoves.append(i)

    if len(possibleMoves) !=0:
        return random.choice(possibleMoves)
    else:
        return None

def getComputerMove(board, computerLetter):
    if computerLetter == 'X':
        playerLetter = '0'
    else:
        playerLetter = 'X'

    for i in range(1, 10):
        boardCopy = getBoardCopy(board)
        if isSpaceFree (boardCopy, i):
            makeMove(boardCopy, computerLetter, i)
            if isWinner(boardCopy, computerLetter):
                return i

    for i in range(1,10):
        boardCopy = getBoardCopy(board)
        if isSpaceFree(boardCopy, i):
            makeMove(boardCopy, playerLetter, i)
            if isWinner(boardCopy, playerLetter):
                return i

    move = chooseRandomMoveFromList (board, [1, 3, 7, 9])
    if move !=None:
        return move

    if isSpaceFree(board, 5):
        return 5

    return chooseRandomMoveFromList(board, [2, 4, 6, 8])

def isBoardFull(board):
    for i in range(1,10):
        if isSpaceFree(board, i):
            return False
        return True

print('Welcome to Tic-Tac-Toe!')

while True:
    theBoard = [' '] * 10
    playerLetter, computerLetter = inputPlayerLetter()
    turn = whoGoesFirst()
    print('The' +turn+ ' will go first.')
    gameIsPlaying = True

    while gameIsPlaying:
        if turn == 'player':
            drawBoard(theBoard)
            move = getPlayerMove(theBoard)
            makeMove(theBoard, playerLetter, move)

            if isWinner(theBoard, playerLetter):
                drawBoard(theBoard)
                print('Horray! You have won the game!')
                gameIsPlaying = False
            else:
                if isBoardFull(theBoard):
                    drawBoard(theBoard)
                    print('The game is a tie!')
                    break
                else:
                    turn = 'computer'

        else:
            move = getComputerMove(theBoard, computerLetter)
            makeMove(theBoard, computerLetter, move)

            if isWinner(theBoard, computerLetter):
                drawBoard(theBoard)
                print('The computer has beaten you! You lose.')
                gameIsPlaying = False
            else:
                if isBoardFull(theBoard):
                    drawBoard(theBoard)
                    print('The game is a tie!')
                    break
                else:
                    turn = 'player'

    print('Do you want to play again? (yes or no)')
    if not input().lower().startswith('y'):
        break

Body:
The problem is in this function:

def isWinner(bo, le):
    return ((bo[7] == le and bo[8] == le and bo [9] == le) or
    (bo[4] == le and bo[5] == le and bo [6] == le)
    (bo[1] == le and bo[2] == le and bo [3] == le)
    (bo[7] == le and bo[4] == le and bo [1] == le)
    (bo[8] == le and bo[5] == le and bo [2] == le)
    (bo[9] == le and bo[6] == le and bo [3] == le)
    (bo[7] == le and bo[5] == le and bo [3] == le)
    (bo[9] == le and bo[5] == le and bo [1] == le))

You have an or after the first line, but it's missing on all the other lines.


问:
How to run wordpress on localhost and django on localhost/product?
I have developed a wordpress website for a product.And the product is made using django.So after the user logs in ,i have to redirect him to the django project.I have to achieve this on the same domain.I have nginx installed.</p>

答:
You can try this

www.egwordpress.com (your Wordpress)

egproduct.egwordpress.com (your Django app)

NGinx config

```<code>server {
    listen      80  default_server;

    server_name www.egwordpress.com;

    location / {
        root        /path/to/your/wordpress;
        index       index.html;
        try_files   $uri $uri/ /index.html;
    }
}
server {
    listen      80;

    server_name egproduct.egwordpress.com;

    location /api/ {    # your django product app
        proxy_pass  http://127.0.0.1:5000; # change port following your Django config
    }
}
</code>```

Body:
You can try this

www.egwordpress.com (your Wordpress)

egproduct.egwordpress.com (your Django app)

NGinx config

server {
    listen      80  default_server;

    server_name www.egwordpress.com;

    location / {
        root        /path/to/your/wordpress;
        index       index.html;
        try_files   $uri $uri/ /index.html;
    }
}
server {
    listen      80;

    server_name egproduct.egwordpress.com;

    location /api/ {    # your django product app
        proxy_pass  http://127.0.0.1:5000; # change port following your Django config
    }
}


问:
Error while installing Oracle Development Tools 18.3.0.0.0 for Visual Studio 2017
While Installing the Oracle Development Tools for VS 2017, I came upon this error message and I have not been able solve it so far.

Error Message pointing me to a log file

The error Message points me to a log file in which the following stacktrace is found:

1/9/2020 3:39:09 PM - System.AggregateException: One or more errors occurred. ---> System.OperationCanceledException: Pre-check verification failed with warning(s) :  AnotherInstallationRunning. ---> Microsoft.VisualStudio.Setup.CanceledByPrecheckException: Pre-check verification failed with warning(s) :  AnotherInstallationRunning.
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.Setup.PrecheckManager.RunPrechecks(PrecheckParameters precheckParameters, VariableCollection properties)
   at Microsoft.VisualStudio.Setup.Engine.RunPrecheck(String destination, Product product, ExecuteAction action, IWindowsRestartManager rmService, ITelemetryOperation installOperation, InstallOperation install)
   at Microsoft.VisualStudio.Setup.Engine.Install(Product product, String destination, CancellationToken token)
   at Microsoft.VisualStudio.ExtensionManager.SetupEngineService.<Install>b__14_0()
   at System.Threading.Tasks.Task1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.ExtensionManager.SetupEngineService.Install()
   at Microsoft.VisualStudio.ExtensionManager.ExtensionBatchEngine.Execute(List1 installableExtensions, Version targetVsVersion)
   at Microsoft.VisualStudio.ExtensionManager.ExtensionEngineImpl.BatchEngineInstall(List1 installableExtensions, InstallFlags installFlags, Version targetVsVersion)
   at VSIXInstaller.BatchSetupEngineInstaller.Install(SupportedVSSKU sku, List1 extensionsToInstall, InstallFlags installFlags)
   at VSIXInstaller.BatchSetupEngineInstaller.BatchInstall(IReadOnlyList1 targetSkus, IEnumerable1 extensionsToInstall)
   at VSIXInstaller.SilentEngine.Execute(ExtensionData data)
   at VSIXInstaller.App.OnStartup(StartupEventArgs e)
---> (Inner Exception #0) System.OperationCanceledException: Pre-check verification failed with warning(s) :  AnotherInstallationRunning. ---> Microsoft.VisualStudio.Setup.CanceledByPrecheckException: Pre-check verification failed with warning(s) :  AnotherInstallationRunning.
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.Setup.PrecheckManager.RunPrechecks(PrecheckParameters precheckParameters, VariableCollection properties)
   at Microsoft.VisualStudio.Setup.Engine.RunPrecheck(String destination, Product product, ExecuteAction action, IWindowsRestartManager rmService, ITelemetryOperation installOperation, InstallOperation install)
   at Microsoft.VisualStudio.Setup.Engine.Install(Product product, String destination, CancellationToken token)
   at Microsoft.VisualStudio.ExtensionManager.SetupEngineService.<Install>b__14_0()
   at System.Threading.Tasks.Task1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)<---

The gist of it in my understanding is that there is another installation running while it tries to install the Visual Studio extension. I didn't of course install something myself during the process, but I also checked the task manager if there is ein msiexec process running. Sometimes there was one running but I got the same error message while there was no msiexec process running.

The only way I can imagine two installers running is that the Oracle Development Tools installer starts the Visual Studio extension installer. Then there are two installers running. However I do not quite believe in that conclusion as this should have been occurred somewhere else before but I haven't found my error message anywhere.

The things I have tried:

Multiple Reinstall with restarts and running as admin.

I have tried to manuelly install the extension after the error occurs, which ends successfully, however when I try to use the custom tools in visual studio I get an error message.

Visual Studio 2017 Verison: 15.9.18

Oracle Development Tools Version: 18.3.0.0.0

答:
In my case the execution of the following file solved this issue:

Oracle.VsDevTools.15.0.vsix

Here you can find this file: C:\Program Files (x86)\Oracle Developer Tools for VS2017\odt


问:
list the file and its base directory
I have some files in my folder /home/sample/* * /*.pdf and *.doc and * .xls etc ('**' means some sub-sub directory.

I need the shell script or linux command to list the files in following manner.

```<code>pdf_docs/xx.pdf
documents/xx.doc
excel/xx.xls
</code>```

pdf_docs, documents and excel are directories, which is located in various depth in /home/sample. like

```<code>/home/sample/12091/pdf_docs/xx.pdf
/home/sample/documents/xx.doc
/home/excel/V2hm/1001/excel/xx.xls
</code>```

答:
You can try this:

```<code>for i in {*.pdf,*.doc,*.xls}; do find /home/sample/ -name "$i"; done | awk -F/ '{print $(NF-1) "/" $NF}'
</code>```

I ve added a line of awk which will print the last 2 fields (seperated by '/' ) of the result alone

Title: list the file and its base directory

Body:
I have some files in my folder /home/sample/* * /*.pdf and *.doc and * .xls etc ('**' means some sub-sub directory.

I need the shell script or linux command to list the files in following manner.

pdf_docs/xx.pdf
documents/xx.doc
excel/xx.xls

pdf_docs, documents and excel are directories, which is located in various depth in /home/sample. like

/home/sample/12091/pdf_docs/xx.pdf
/home/sample/documents/xx.doc
/home/excel/V2hm/1001/excel/xx.xls

Body:
You can try this:

for i in {*.pdf,*.doc,*.xls}; do find /home/sample/ -name "$i"; done | awk -F/ '{print $(NF-1) "/" $NF}'

I ve added a line of awk which will print the last 2 fields (seperated by '/' ) of the result alone


问:
Get the Sum of Lowest Values In 3 Columns Each added dynamically
i am having a trouble having the sum of 3 lowest values entered in columns added dynamically. it shows no value in the Total Cost Field, although if i changed the type from number to text of Total Cost Field. It gives NaN into it. I have tried a lot but did not get on the final step. Please look into, i really can use some help in this regard

//JS To Add Rows Dynamically
$(document).ready(function() {
  var i = 1;
  $("#Add_BDSP").click(function() {
    $('#BDSP' + i).html("<select class='form-control show-tick form-group form-float' name='RequiredServices[" + i + "]' id='Services'><optgroup label=' financial services'><option id='AccountingSoftware' value='ERP Systems'>ERP Systems</option> <option id='AccountingSystems' value='Accounting Book Keeping Systems'>Accounting / Book Keeping Systems</option><option id='ProductCosting' value='Product Costing'>Product Costing</option><option id='FinancialManagement' value='Financial Management Systems'>Financial Management Systems</option></optgroup><optgroup label='HR Services'><option id='HRPolicies' value='HR Policies and Procedures'>HR Policies and Procedures</option><option id='HR_System' value='HR_System'>HR Systems</option><option id='Appraisal' value='Appraisal'>Employee Internal Trainings Manuals</option><option id='SalesManagement' value='SalesManagement'>sEmployee Orientation Manuals.</option> </optgroup><optgroup label='General Management'><option id='Project' value='ProjectManagement'>Project Management System</option><option id='Inventory' value='Inventory Management Systems'>Inventory Management Systems</option><option id='Warehouse' value='Warehouse'>Procurement System</option><option id='SupplyChain' value='SupplyChain'>Supply Chain Systems</option><option id='FleetManagement' value='Fleet Management Systems'>Fleet Management Systems</option></optgroup><optgroup label='Regulatory Services'><option id='Sales_Income_Tax' value='Sales_Income_Tax'>sales / Income Tax Services</option><option id='TradeMark' value='TradeMark'>Intellectual Property Rights</option><option id='BusinessRegistration' value='BusinessRegistration'>Business Registration Services</option><option id='B2B' value='B2B'>B2B, B2C Contracting Services</option><option id='BusinessLicensing' value='BusinessLicensing'>Business Licensing Services</option></optgroup><optgroup label='Production Management'><option id='ProductionPlanning' value='ProductionPlanning'>Production Planning & Control Systems</option><option id='ProductionManagement' value='ProductionManagement'>Warehouse Management Information Systems (WMIS)</option> </optgroup></select>

<input type='text' name='Description[" + i + "]' >

	<input type='text' name='BDSPName1[" + i + "]' placeholder='BDSP Name'class='form-control' required /><input type='text' name='BDSPName2[" + i + "]' placeholder='BDSP Name'class='form-control'  /><input type='text' name='BDSPName3[" + i + "]' placeholder='BDSP Name'class='form-control'  />	 <input type='text' name='BDSP_NTN1[" + i + "]'placeholder='BDSP NTN Number' class='form-control'/><input type='text' name='BDSP_NTN2[" + i + "]'placeholder='BDSP NTN Number' class='form-control' /><input type='text' name='BDSP_NTN3[" + i + "]'placeholder='BDSP NTN Number' class='form-control' />	<input type='text' name='QuotedAmount1[" + i + "]' placeholder='Quoted Amount' class='form-control' /><input type='text' name='QuotedAmount2[" + i + "]'placeholder='Quoted Amount' class='form-control' /><input type='text' name='QuotedAmount3[" + i + "]' placeholder='Quoted Amount' class='form-control'/> 	<select class='form-group form-control' name='ExpectedDeliveryTime1[" + i + "]' id='ExpectedDeliveryTime1[0]'><option selected disabled>Select Days</option><option value='30' class='form-control input-md'>30</option><option value='60' class='form-control input-md'>60</option><option value='90' class='form-control input-md'>90</option><option value='120' class='form-control input-md'>120</option><option value='150' class='form-control input-md'>150</option><option value='180' class='form-control input-md'>180</option><option value='more180' class='form-control input-md'>More Than 180</option></select><select class='form-group form-control' name='ExpectedDeliveryTime2[" + i + "]' id='ExpectedDeliveryTime2[0]'><option selected disabled>Select Days</option><option value='30' class='form-control input-md'>30</option><option value='60' class='form-control input-md'>60</option><option value='90' class='form-control input-md'>90</option><option value='120' class='form-control input-md'>120</option><option value='150' class='form-control input-md'>150</option><option value='180' class='form-control input-md'>180</option><option value='more180' class='form-control input-md'>More Than 180</option></select><select class='form-group form-control' name='ExpectedDeliveryTime3[" + i + "]' id='ExpectedDeliveryTime3[0]'><option selected disabled>Select Days</option><option value='30' class='form-control input-md'>30</option><option value='60' class='form-control input-md'>60</option><option value='90' class='form-control input-md'>90</option><option value='120' class='form-control input-md'>120</option><option value='150' class='form-control input-md'>150</option><option value='180' class='form-control input-md'>180</option><option value='more180' class='form-control input-md'>More Than 180</option></select>	<input type='file' name='Quotation1[" + i + "]' class='form-control' /><input type='file' name='Quotation2[" + i + "]' class='form-control' /><input type='file' name='Quotation3[" + i + "]' class='form-control' />	");

    $('#Tab_BDSP').append('

');
    i++;
  });
  $("#Delete_BDSP").click(function() {
    if (i > 1) {
      $("#BDSP" + (i - 1)).html('');
      i--;
    }
  });

});

//JS To Add Lowest Value

$(document).on('change', '#Tab_BDSP tbody tr td input[type="text"]', function() {
  let result = 0;
  var MulRes = $('input#ServiceTotalCost');

  var QuotedAmount1 = $(this).parent().find('input[type="text"]').eq(0),
    QuotedAmount2 = $(this).parent().find('input[type="text"]').eq(1),
    QuotedAmount3 = $(this).parent().find('input[type="text"]').eq(2);

  var Qoute1 = (isNaN(parseInt(QuotedAmount1.val()))) ? 0 : parseInt(QuotedAmount1.val()),
    Qoute2 = (isNaN(parseInt(QuotedAmount2.val()))) ? 0 : parseInt(QuotedAmount2.val()),
    Qoute3 = (isNaN(parseInt(QuotedAmount3.val()))) ? 0 : parseInt(QuotedAmount3.val());

  var min = Math.min(Qoute1, Qoute2, Qoute3);
  $(this).parent().attr('data-lowest', min)

  $('#Tab_BDSP tbody tr td').each(function() {
    result += +$(this).attr('data-lowest')
  });

  MulRes.val(result)
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="col-md-12">
  <p>
    <b>Please Provide At Least 3 BDSPs Quotations Against Each Service</b> <span style="color: red">*</span>
  </p>
  <div class="form-group form-float">
    <table class="table table-bordered table-hover" id="Tab_BDSP">
      <thead>
        <tr>
          <td>Services Required</td>
          <td>Description</td>
          <td>BDSP Name</td>
          <td>NTN No.</td>
          <td>Amount</td>
          <td>Expected Delivery Time</td>
          <td>Attach Quotation</td>
        </tr>
      </thead>
      <tbody>
        <tr id='BDSP0'>
          <td>
            <select class="form-control show-tick form-group form-float" name="RequiredServices[0]" id="Services" required>
              <optgroup label="Financial Services">
                <option id="AccountingSoftware" value="ERP Systems">ERP Systems</option>
                <option id="AccountingSystems" value="Accounting Book Keeping Systems">Accounting / Book Keeping Systems</option>
                <option id="ProductCosting" value="Product Costing">Product Costing</option>
                <option id="FinancialManagement" value="Financial Management Systems">Financial Management Systems</option>

              </optgroup>

              <optgroup label="HR Services">
                <option id="HRPolicies" value="HR Policies and Procedures">HR Policies and Procedures</option>
                <option id="HR_System" value="HR_System">HR Systems</option>
                <option id="Appraisal" value="Appraisal">Employee Internal Trainings Manuals</option>
                <option id="SalesManagement" value="SalesManagement">sEmployee Orientation Manuals.</option>

              </optgroup>

              <optgroup label="General Management">
                <option id="Project" value="ProjectManagement">Project Management System</option>
                <option id="Inventory" value="Inventory Management Systems">Inventory Management Systems</option>
                <option id="Warehouse" value="Warehouse">Procurement System</option>
                <option id="SupplyChain" value="SupplyChain">Supply Chain Systems</option>
                <option id="FleetManagement" value="Fleet Management Systems">Fleet Management Systems</option>

              </optgroup>

              <optgroup label="Regulatory Services">
                <option id="Sales_Income_Tax" value="Sales_Income_Tax">sales / Income Tax Services</option>
                <option id="TradeMark" value="TradeMark">Intellectual Property Rights</option>
                <option id="BusinessRegistration" value="BusinessRegistration">Business Registration Services</option>
                <option id="B2B" value="B2B">B2B, B2C Contracting Services</option>
                <option id="BusinessLicensing" value="BusinessLicensing">Business Licensing Services</option>

              </optgroup>

              <optgroup label="Production Management">
                <option id="ProductionPlanning" value="ProductionPlanning">Production Planning & Control Systems</option>
                <option id="ProductionManagement" value="ProductionManagement">Warehouse Management Information Systems (WMIS)</option>

              </optgroup>
              <optgroup label="Other Services">
                <option id="Other" value="OtherServices">Mention Other Services</option>

              </optgroup>

            </select>
          </td>
          <td>
            <div class="input-group form-group">

              <div class="form-line">
                <input type="text" class="form-control" name="Description[0]" id="Description" required>
              </div>
            </div>

          </td>
          <td>
            <input type="text" name='BDSPName1[0]' placeholder='BDSP Name' class="form-control" required />
            <input type="text" name='BDSPName2[0]' placeholder='BDSP Name' class="form-control" required />
            <input type="text" name='BDSPName3[0]' placeholder='BDSP Name' class="form-control" required />
          </td>

          <td>
            <input type="text" name='BDSP_NTN1[0]' placeholder='BDSP NTN Number' class="form-control" required />
            <input type="text" name='BDSP_NTN2[0]' placeholder='BDSP NTN Number' class="form-control" required />
            <input type="text" name='BDSP_NTN3[0]' placeholder='BDSP NTN Number' class="form-control" required />
          </td>

          <td>
            <input type="text" name='QuotedAmount1[0]' placeholder='Quoted Amount' class="form-control" required />
            <input type="text" name='QuotedAmount2[0]' placeholder='Quoted Amount' class="form-control" required />
            <input type="text" name='QuotedAmount3[0]' placeholder='Quoted Amount' class="form-control" required />
          </td>
          <td>
            <select class="form-group form-control" name="ExpectedDeliveryTime1[0]" id="ExpectedDeliveryTime1[0]" required>
              <option selected disabled>Select Days</option>
              <option value="AJK" class='form-control input-md'>30</option>
              <option value="Balochistan" class='form-control input-md'>60</option>
              <option value="GB" class='form-control input-md'>90</option>
              <option value="ICT" class='form-control input-md'>120</option>
              <option value="KPK" class='form-control input-md'>150</option>
              <option value="Punjab" class='form-control input-md'>180</option>
              <option value="Sindh" class='form-control input-md'>More Than 180</option>
            </select>
            <select class="form-group form-control" name="ExpectedDeliveryTime2[0]" id="ExpectedDeliveryTime2[0]" required>
              <option selected disabled>Select Days</option>
              <option value="AJK" class='form-control input-md'>30</option>
              <option value="Balochistan" class='form-control input-md'>60</option>
              <option value="GB" class='form-control input-md'>90</option>
              <option value="ICT" class='form-control input-md'>120</option>
              <option value="KPK" class='form-control input-md'>150</option>
              <option value="Punjab" class='form-control input-md'>180</option>
              <option value="Sindh" class='form-control input-md'>More Than 180</option>
            </select>
            <select class="form-group form-control" name="ExpectedDeliveryTime3[0]" id="ExpectedDeliveryTime3[0]" required>
              <option selected disabled>Select Days</option>
              <option value="AJK" class='form-control input-md'>30</option>
              <option value="Balochistan" class='form-control input-md'>60</option>
              <option value="GB" class='form-control input-md'>90</option>
              <option value="ICT" class='form-control input-md'>120</option>
              <option value="KPK" class='form-control input-md'>150</option>
              <option value="Punjab" class='form-control input-md'>180</option>
              <option value="Sindh" class='form-control input-md'>More Than 180</option>
            </select>
          </td>
          <td>
            <input type="file" name="Quotation1[0]" class="form-control" required />
            <input type="file" name="Quotation2[0]" class="form-control" required />
            <input type="file" name="Quotation3[0]" class="form-control" required />
          </td>
        </tr>

        <tr id='BDSP1'></tr>
      </tbody>
    </table>
  </div>
  Add RowDelete Row
</div>
<div class="col-md-4">
  <p>
    <b>Total Cost Of The Service</b> <span style="color: red">*</span>
  </p>
  <div class="input-group form-group">
    <span class="input-group-addon">
 <i class="material-icons">business_center</i></span>
    <div class="form-line">
      <input type="number" class="form-control" name="ServiceTotalCost" id="ServiceTotalCost" required>
    </div>
  </div>
</div></code>```

答:
You are running the function and looping through textboxes in all columns, which is causing you to get bad values. You need to check only the amount textboxes.

Add a class and a starting value for data-lowest to the Amount td:

...

Add the class to the jQuery event:

```<code> jQuery( document ).on( 'change', '#Tab_BDSP tbody tr td.amountTD input[type="text"]', function ()
</code>```

And add it to the loop like so, and wrap result in parseInt:

```<code>  jQuery( '#Tab_BDSP tbody tr td.amountTD' ).each( function ()
  {
      result += parseInt( jQuery( this ).attr( 'data-lowest' ) );
  });
</code>```

Body:
i am having a trouble having the sum of 3 lowest values entered in columns added dynamically. it shows no value in the Total Cost Field, although if i changed the type from number to text of Total Cost Field. It gives NaN into it. I have tried a lot but did not get on the final step. Please look into, i really can use some help in this regard

//JS To Add Rows Dynamically
$(document).ready(function() {
  var i = 1;
  $("#Add_BDSP").click(function() {
    $('#BDSP' + i).html("<select class='form-control show-tick form-group form-float' name='RequiredServices[" + i + "]' id='Services'><optgroup label=' financial services'><option id='AccountingSoftware' value='ERP Systems'>ERP Systems</option> <option id='AccountingSystems' value='Accounting Book Keeping Systems'>Accounting / Book Keeping Systems</option><option id='ProductCosting' value='Product Costing'>Product Costing</option><option id='FinancialManagement' value='Financial Management Systems'>Financial Management Systems</option></optgroup><optgroup label='HR Services'><option id='HRPolicies' value='HR Policies and Procedures'>HR Policies and Procedures</option><option id='HR_System' value='HR_System'>HR Systems</option><option id='Appraisal' value='Appraisal'>Employee Internal Trainings Manuals</option><option id='SalesManagement' value='SalesManagement'>sEmployee Orientation Manuals.</option> </optgroup><optgroup label='General Management'><option id='Project' value='ProjectManagement'>Project Management System</option><option id='Inventory' value='Inventory Management Systems'>Inventory Management Systems</option><option id='Warehouse' value='Warehouse'>Procurement System</option><option id='SupplyChain' value='SupplyChain'>Supply Chain Systems</option><option id='FleetManagement' value='Fleet Management Systems'>Fleet Management Systems</option></optgroup><optgroup label='Regulatory Services'><option id='Sales_Income_Tax' value='Sales_Income_Tax'>sales / Income Tax Services</option><option id='TradeMark' value='TradeMark'>Intellectual Property Rights</option><option id='BusinessRegistration' value='BusinessRegistration'>Business Registration Services</option><option id='B2B' value='B2B'>B2B, B2C Contracting Services</option><option id='BusinessLicensing' value='BusinessLicensing'>Business Licensing Services</option></optgroup><optgroup label='Production Management'><option id='ProductionPlanning' value='ProductionPlanning'>Production Planning & Control Systems</option><option id='ProductionManagement' value='ProductionManagement'>Warehouse Management Information Systems (WMIS)</option> </optgroup></select>

<input type='text' name='Description[" + i + "]' >

	<input type='text' name='BDSPName1[" + i + "]' placeholder='BDSP Name'class='form-control' required /><input type='text' name='BDSPName2[" + i + "]' placeholder='BDSP Name'class='form-control'  /><input type='text' name='BDSPName3[" + i + "]' placeholder='BDSP Name'class='form-control'  />	 <input type='text' name='BDSP_NTN1[" + i + "]'placeholder='BDSP NTN Number' class='form-control'/><input type='text' name='BDSP_NTN2[" + i + "]'placeholder='BDSP NTN Number' class='form-control' /><input type='text' name='BDSP_NTN3[" + i + "]'placeholder='BDSP NTN Number' class='form-control' />	<input type='text' name='QuotedAmount1[" + i + "]' placeholder='Quoted Amount' class='form-control' /><input type='text' name='QuotedAmount2[" + i + "]'placeholder='Quoted Amount' class='form-control' /><input type='text' name='QuotedAmount3[" + i + "]' placeholder='Quoted Amount' class='form-control'/> 	<select class='form-group form-control' name='ExpectedDeliveryTime1[" + i + "]' id='ExpectedDeliveryTime1[0]'><option selected disabled>Select Days</option><option value='30' class='form-control input-md'>30</option><option value='60' class='form-control input-md'>60</option><option value='90' class='form-control input-md'>90</option><option value='120' class='form-control input-md'>120</option><option value='150' class='form-control input-md'>150</option><option value='180' class='form-control input-md'>180</option><option value='more180' class='form-control input-md'>More Than 180</option></select><select class='form-group form-control' name='ExpectedDeliveryTime2[" + i + "]' id='ExpectedDeliveryTime2[0]'><option selected disabled>Select Days</option><option value='30' class='form-control input-md'>30</option><option value='60' class='form-control input-md'>60</option><option value='90' class='form-control input-md'>90</option><option value='120' class='form-control input-md'>120</option><option value='150' class='form-control input-md'>150</option><option value='180' class='form-control input-md'>180</option><option value='more180' class='form-control input-md'>More Than 180</option></select><select class='form-group form-control' name='ExpectedDeliveryTime3[" + i + "]' id='ExpectedDeliveryTime3[0]'><option selected disabled>Select Days</option><option value='30' class='form-control input-md'>30</option><option value='60' class='form-control input-md'>60</option><option value='90' class='form-control input-md'>90</option><option value='120' class='form-control input-md'>120</option><option value='150' class='form-control input-md'>150</option><option value='180' class='form-control input-md'>180</option><option value='more180' class='form-control input-md'>More Than 180</option></select>	<input type='file' name='Quotation1[" + i + "]' class='form-control' /><input type='file' name='Quotation2[" + i + "]' class='form-control' /><input type='file' name='Quotation3[" + i + "]' class='form-control' />	");

    $('#Tab_BDSP').append('

');
    i++;
  });
  $("#Delete_BDSP").click(function() {
    if (i > 1) {
      $("#BDSP" + (i - 1)).html('');
      i--;
    }
  });

});

//JS To Add Lowest Value

$(document).on('change', '#Tab_BDSP tbody tr td input[type="text"]', function() {
  let result = 0;
  var MulRes = $('input#ServiceTotalCost');

  var QuotedAmount1 = $(this).parent().find('input[type="text"]').eq(0),
    QuotedAmount2 = $(this).parent().find('input[type="text"]').eq(1),
    QuotedAmount3 = $(this).parent().find('input[type="text"]').eq(2);

  var Qoute1 = (isNaN(parseInt(QuotedAmount1.val()))) ? 0 : parseInt(QuotedAmount1.val()),
    Qoute2 = (isNaN(parseInt(QuotedAmount2.val()))) ? 0 : parseInt(QuotedAmount2.val()),
    Qoute3 = (isNaN(parseInt(QuotedAmount3.val()))) ? 0 : parseInt(QuotedAmount3.val());

  var min = Math.min(Qoute1, Qoute2, Qoute3);
  $(this).parent().attr('data-lowest', min)

  $('#Tab_BDSP tbody tr td').each(function() {
    result += +$(this).attr('data-lowest')
  });

  MulRes.val(result)
});

    Please Provide At Least 3 BDSPs Quotations Against Each Service *

          Services Required
          Description
          BDSP Name
          NTN No.
          Amount
          Expected Delivery Time
          Attach Quotation

            <select class="form-control show-tick form-group form-float" name="RequiredServices[0]" id="Services" required>
              <optgroup label="Financial Services">
                <option id="AccountingSoftware" value="ERP Systems">ERP Systems</option>
                <option id="AccountingSystems" value="Accounting Book Keeping Systems">Accounting / Book Keeping Systems</option>
                <option id="ProductCosting" value="Product Costing">Product Costing</option>
                <option id="FinancialManagement" value="Financial Management Systems">Financial Management Systems</option>

              </optgroup>

              <optgroup label="HR Services">
                <option id="HRPolicies" value="HR Policies and Procedures">HR Policies and Procedures</option>
                <option id="HR_System" value="HR_System">HR Systems</option>
                <option id="Appraisal" value="Appraisal">Employee Internal Trainings Manuals</option>
                <option id="SalesManagement" value="SalesManagement">sEmployee Orientation Manuals.</option>

              </optgroup>

              <optgroup label="General Management">
                <option id="Project" value="ProjectManagement">Project Management System</option>
                <option id="Inventory" value="Inventory Management Systems">Inventory Management Systems</option>
                <option id="Warehouse" value="Warehouse">Procurement System</option>
                <option id="SupplyChain" value="SupplyChain">Supply Chain Systems</option>
                <option id="FleetManagement" value="Fleet Management Systems">Fleet Management Systems</option>

              </optgroup>

              <optgroup label="Regulatory Services">
                <option id="Sales_Income_Tax" value="Sales_Income_Tax">sales / Income Tax Services</option>
                <option id="TradeMark" value="TradeMark">Intellectual Property Rights</option>
                <option id="BusinessRegistration" value="BusinessRegistration">Business Registration Services</option>
                <option id="B2B" value="B2B">B2B, B2C Contracting Services</option>
                <option id="BusinessLicensing" value="BusinessLicensing">Business Licensing Services</option>

              </optgroup>

              <optgroup label="Production Management">
                <option id="ProductionPlanning" value="ProductionPlanning">Production Planning & Control Systems</option>
                <option id="ProductionManagement" value="ProductionManagement">Warehouse Management Information Systems (WMIS)</option>

              </optgroup>
              <optgroup label="Other Services">
                <option id="Other" value="OtherServices">Mention Other Services</option>

              </optgroup>

            </select>

                <input type="text" class="form-control" name="Description[0]" id="Description" required>

            <input type="text" name='BDSPName1[0]' placeholder='BDSP Name' class="form-control" required />
            <input type="text" name='BDSPName2[0]' placeholder='BDSP Name' class="form-control" required />
            <input type="text" name='BDSPName3[0]' placeholder='BDSP Name' class="form-control" required />

            <input type="text" name='BDSP_NTN1[0]' placeholder='BDSP NTN Number' class="form-control" required />
            <input type="text" name='BDSP_NTN2[0]' placeholder='BDSP NTN Number' class="form-control" required />
            <input type="text" name='BDSP_NTN3[0]' placeholder='BDSP NTN Number' class="form-control" required />

            <input type="text" name='QuotedAmount1[0]' placeholder='Quoted Amount' class="form-control" required />
            <input type="text" name='QuotedAmount2[0]' placeholder='Quoted Amount' class="form-control" required />
            <input type="text" name='QuotedAmount3[0]' placeholder='Quoted Amount' class="form-control" required />

            <select class="form-group form-control" name="ExpectedDeliveryTime1[0]" id="ExpectedDeliveryTime1[0]" required>
              <option selected disabled>Select Days</option>
              <option value="AJK" class='form-control input-md'>30</option>
              <option value="Balochistan" class='form-control input-md'>60</option>
              <option value="GB" class='form-control input-md'>90</option>
              <option value="ICT" class='form-control input-md'>120</option>
              <option value="KPK" class='form-control input-md'>150</option>
              <option value="Punjab" class='form-control input-md'>180</option>
              <option value="Sindh" class='form-control input-md'>More Than 180</option>
            </select>
            <select class="form-group form-control" name="ExpectedDeliveryTime2[0]" id="ExpectedDeliveryTime2[0]" required>
              <option selected disabled>Select Days</option>
              <option value="AJK" class='form-control input-md'>30</option>
              <option value="Balochistan" class='form-control input-md'>60</option>
              <option value="GB" class='form-control input-md'>90</option>
              <option value="ICT" class='form-control input-md'>120</option>
              <option value="KPK" class='form-control input-md'>150</option>
              <option value="Punjab" class='form-control input-md'>180</option>
              <option value="Sindh" class='form-control input-md'>More Than 180</option>
            </select>
            <select class="form-group form-control" name="ExpectedDeliveryTime3[0]" id="ExpectedDeliveryTime3[0]" required>
              <option selected disabled>Select Days</option>
              <option value="AJK" class='form-control input-md'>30</option>
              <option value="Balochistan" class='form-control input-md'>60</option>
              <option value="GB" class='form-control input-md'>90</option>
              <option value="ICT" class='form-control input-md'>120</option>
              <option value="KPK" class='form-control input-md'>150</option>
              <option value="Punjab" class='form-control input-md'>180</option>
              <option value="Sindh" class='form-control input-md'>More Than 180</option>
            </select>

            <input type="file" name="Quotation1[0]" class="form-control" required />
            <input type="file" name="Quotation2[0]" class="form-control" required />
            <input type="file" name="Quotation3[0]" class="form-control" required />

  Add RowDelete Row

    Total Cost Of The Service *

 business_center

      <input type="number" class="form-control" name="ServiceTotalCost" id="ServiceTotalCost" required>

Body:
You are running the function and looping through textboxes in all columns, which is causing you to get bad values. You need to check only the amount textboxes.

Add a class and a starting value for data-lowest to the Amount td:

<td data-lowest="0" class="amountTD">...</td>

Add the class to the jQuery event:

 jQuery( document ).on( 'change', '#Tab_BDSP tbody tr td.amountTD input[type="text"]', function ()

And add it to the loop like so, and wrap result in parseInt:

  jQuery( '#Tab_BDSP tbody tr td.amountTD' ).each( function ()
  {
      result += parseInt( jQuery( this ).attr( 'data-lowest' ) );
  });


问:
How to count total lines changed by a specific author in a Git repository?
Is there a command I can invoke which will count the lines changed by a specific author in a Git repository? I know that there must be ways to count the number of commits as Github does this for their Impact graph.</p>

答:
Here is a great repo that makes your life easier

git-quick-stats

On a mac with brew installed

brew install git-quick-stats

Run

git-quick-stats

Just choose which option you want from this list by typing in the number listed and hitting enter.

```<code> Generate:
    1) Contribution stats (by author)
    2) Contribution stats (by author) on a specific branch
    3) Git changelogs (last 10 days)
    4) Git changelogs by author
    5) My daily status
    6) Save git log output in JSON format

 List:
    7) Branch tree view (last 10)
    8) All branches (sorted by most recent commit)
    9) All contributors (sorted by name)
   10) Git commits per author
   11) Git commits per date
   12) Git commits per month
   13) Git commits per weekday
   14) Git commits per hour
   15) Git commits by author per hour

 Suggest:
   16) Code reviewers (based on git history)

</code>```

Body:
Here is a great repo that makes your life easier

git-quick-stats

On a mac with brew installed

brew install git-quick-stats

Run

git-quick-stats

Just choose which option you want from this list by typing in the number listed and hitting enter.

 Generate:
    1) Contribution stats (by author)
    2) Contribution stats (by author) on a specific branch
    3) Git changelogs (last 10 days)
    4) Git changelogs by author
    5) My daily status
    6) Save git log output in JSON format

 List:
    7) Branch tree view (last 10)
    8) All branches (sorted by most recent commit)
    9) All contributors (sorted by name)
   10) Git commits per author
   11) Git commits per date
   12) Git commits per month
   13) Git commits per weekday
   14) Git commits per hour
   15) Git commits by author per hour

 Suggest:
   16) Code reviewers (based on git history)


问:
How can I pass a value with a $ to a program run through su?
I need to run one of the script as below:

su - oracle -c 'cd /tmp/somepath; sh -x myscript.sh arg1 arg2 arg3
  obj$_jghd$:jhdbcdj:hshabsh'

where arg4(obj$_jghd$:jhdbcdj:hshabsh) should be treated as one argument and calling in for loop in myscript.sh
Below is the sample code

```<code>id1=$1
id2=$2
id3=$3
name=$4
S_Object=`echo ""${name}""|sed 's/:/ /g'`
</code>```

here I am reformating agr4 and removing the delimiter : with space and trying to nullify $. But when running the script all variables are not getting stored which contains $ and getting this error:

```<code>+ name='obj$:jhdbcdj:hshabsh'
++ echo 'obj$:jhdbcdj:hshabsh'
++ sed 's/:/ /g'
++ sed '/s/$/$/g'
sed: -e expression #1, char 4: unknown command: `$'
</code>```

Can you please help to get the right string stored in name variable.

I want the result should be like :

```<code>echo $S_Object

S_Object='obj$_jghd$ jhdbcdj hshabsh'
</code>```

but I am getting as below :

```<code>echo $S_Object
S_Object='obj$ jhdbcdj hshabsh'
</code>```

答:
Unfortunately, you'll need to fix the code that's starting your script -- the name variable is already corrupt before the script starts, because the shell that su invokes is replacing $_jghd with an empty string before the explicit sh -x script is invoked.

To generate code containing data, use printf %q, as follows:

```<code>#!/usr/bin/env bash
value='obj$_jghd$:jhdbcdj:hshabsh'
printf -v cmd '%q ' sh -x myscript.sh arg1 arg2 arg3 "$value"
su - oracle -c "cd /tmp/somepath && $cmd"
</code>```

Note the use of bash, not sh, as printf %q isn't present in POSIX-baseline shells, and further isn't guaranteed to generate POSIX-compliant output. (Consequently, for this to be reliable with all possible values, the oracle user should be configured with bash as its shell).

Alternately, you can pass values through the environment:

```<code>#!/bin/sh
value='obj$_jghd$:jhdbcdj:hshabsh'
value="$value" su - oracle -c 'cd /tmp/somepath && ./myscript.sh arg1 arg2 arg3 "$value"'
</code>```

Reassigning value on the same line as su puts it in su's environment, which is then inherited by the shell later expanding $value.

Body:
I need to run one of the script as below:

su - oracle -c 'cd /tmp/somepath; sh -x myscript.sh arg1 arg2 arg3
  obj$_jghd$:jhdbcdj:hshabsh'

where arg4(obj$_jghd$:jhdbcdj:hshabsh) should be treated as one argument and calling in for loop in myscript.sh
Below is the sample code

id1=$1
id2=$2
id3=$3
name=$4
S_Object=`echo ""${name}""|sed 's/:/ /g'`

here I am reformating agr4 and removing the delimiter : with space and trying to nullify $. But when running the script all variables are not getting stored which contains $ and getting this error:

+ name='obj$:jhdbcdj:hshabsh'
++ echo 'obj$:jhdbcdj:hshabsh'
++ sed 's/:/ /g'
++ sed '/s/$/$/g'
sed: -e expression #1, char 4: unknown command: `$'

Can you please help to get the right string stored in name variable.

I want the result should be like :

echo $S_Object

S_Object='obj$_jghd$ jhdbcdj hshabsh'

but I am getting as below :

echo $S_Object
S_Object='obj$ jhdbcdj hshabsh'

Body:
Unfortunately, you'll need to fix the code that's starting your script -- the name variable is already corrupt before the script starts, because the shell that su invokes is replacing $_jghd with an empty string before the explicit sh -x script is invoked.

To generate code containing data, use printf %q, as follows:

#!/usr/bin/env bash
value='obj$_jghd$:jhdbcdj:hshabsh'
printf -v cmd '%q ' sh -x myscript.sh arg1 arg2 arg3 "$value"
su - oracle -c "cd /tmp/somepath && $cmd"

Note the use of bash, not sh, as printf %q isn't present in POSIX-baseline shells, and further isn't guaranteed to generate POSIX-compliant output. (Consequently, for this to be reliable with all possible values, the oracle user should be configured with bash as its shell).

Alternately, you can pass values through the environment:

#!/bin/sh
value='obj$_jghd$:jhdbcdj:hshabsh'
value="$value" su - oracle -c 'cd /tmp/somepath && ./myscript.sh arg1 arg2 arg3 "$value"'

Reassigning value on the same line as su puts it in su's environment, which is then inherited by the shell later expanding $value.


问:
How to submit form data to backend?
Disclaimer: I’m a backend programmer and I would like to minimize javascript code in my webpages.

I’m considering using the login form given here as example. In this example we have this

```<code><form class="ui large form">
  <div class="ui stacked segment">
    <div class="field">
      <div class="ui left icon input">
        <i class="user icon"></i>
        <input type="text" name="email" placeholder="E-mail address">
      </div>
    </div>
    <div class="field">
      <div class="ui left icon input">
        <i class="lock icon"></i>
        <input type="password" name="password" placeholder="Password">
      </div>
     </div>
     <div class="ui fluid large teal submit button">Login</div>
  </div>
  <div class="ui error message"></div>
</form>
</code>```

The login button is just a div which does nothing. There is no action argument in the form tag and there is no submit type input tag.

How do I get the page to send the input field values back to the backend server ?

Note that there is some javascript code visible in the source page that checks the validity of the fields. But there is no hint on how to get send the email and password to the backend and load the logged in page.

答:
The login button is just a div which does nothing

Make it a <button>.

There is no action argument in the form tag

Add one if you want the data to be submitted to a different URL then that of the current page.

Your form should also be method="POST". Passwords do not belong in URLs (which are often logged in plain text).

How do I get the page to send the input field values back to the backend server ?

Use a <button> element to represent your submit button and not a
 element. The
 element is when you need a block element and HTML lacks an element with the semantics to describe your content. That isn't the case here, you want to submit a form and that is what submit buttons are for.

Title: How to submit form data to backend?

Body:
Disclaimer: I’m a backend programmer and I would like to minimize javascript code in my webpages.

I’m considering using the login form given here as example. In this example we have this

<form class="ui large form">

        <input type="text" name="email" placeholder="E-mail address">

        <input type="password" name="password" placeholder="Password">

Login

</form>

The login button is just a div which does nothing. There is no action argument in the form tag and there is no submit type input tag.

How do I get the page to send the input field values back to the backend server ?

Note that there is some javascript code visible in the source page that checks the validity of the fields. But there is no hint on how to get send the email and password to the backend and load the logged in page.

Body:
The login button is just a div which does nothing

Make it a <button>.

There is no action argument in the form tag

Add one if you want the data to be submitted to a different URL then that of the current page.

Your form should also be method="POST". Passwords do not belong in URLs (which are often logged in plain text).

How do I get the page to send the input field values back to the backend server ?

Use a <button> element to represent your submit button and not a <div> element. The <div> element is when you need a block element and HTML lacks an element with the semantics to describe your content. That isn't the case here, you want to submit a form and that is what submit buttons are for.


问:
How do you print out a string that has each element of an array four to a line
This is my code

```<code>public String toString() {
    String B = A[0] + " ";
    for (int w = 1; w < this.A.length; w-=-1) {
        B += A[w] + " ";
        if(w % 4 == 0)
            B += "\n";
    }
    return B;
}
</code>```

I am trying to make a string that has each element of my array in it and after every fourth element a new line is added. The output should be something like this:

```<code>AA BB CC DD
EE FF GG HH
II JJ KK LL
MM NN OO PP
</code>```

I am writing a toString method for a java class. The array has 52 elements
Instead I keep getting this as an output:

```<code>1S 4S 6S 2S 8S
8S 7S 3S 7S
6S 8S 5S 6S
3C 3C 1C 8C
8C 9C 4C
</code>```

答:
All you have to do is:

```<code>String B = A[0] + " ";
for (int w = 1; w < this.A.length; w-=-1) {
    if (w % 4 == 0) {
        B += "\n";
    }
    // this line is after the check because you already added the first
    // element to the string before the loop
    B += A[w] + " ";
}
</code>```

Also: Appending to a String in a loop is an expensive operation because Strings in java are immutable. Use StringBuilder instead. Read more here.

I do not understand w-=-1 over w++.

Body:
This is my code

public String toString() {
    String B = A[0] + " ";
    for (int w = 1; w < this.A.length; w-=-1) {
        B += A[w] + " ";
        if(w % 4 == 0)
            B += "\n";
    }
    return B;
}

I am trying to make a string that has each element of my array in it and after every fourth element a new line is added. The output should be something like this:

AA BB CC DD
EE FF GG HH
II JJ KK LL
MM NN OO PP

I am writing a toString method for a java class. The array has 52 elements
Instead I keep getting this as an output:

1S 4S 6S 2S 8S
8S 7S 3S 7S
6S 8S 5S 6S
3C 3C 1C 8C
8C 9C 4C

Body:
All you have to do is:

String B = A[0] + " ";
for (int w = 1; w < this.A.length; w-=-1) {
    if (w % 4 == 0) {
        B += "\n";
    }
    // this line is after the check because you already added the first
    // element to the string before the loop
    B += A[w] + " ";
}

Also: Appending to a String in a loop is an expensive operation because Strings in java are immutable. Use StringBuilder instead. Read more here.

I do not understand w-=-1 over w++.


答:
This is the proper way of writing isWinner:

```<code>def isWinner(bo, le):
    return ((bo[7] == le and bo[8] == le and bo[9] == le) or
            (bo[4] == le and bo[5] == le and bo[6] == le) or
            (bo[1] == le and bo[2] == le and bo[3] == le) or
            (bo[7] == le and bo[4] == le and bo[1] == le) or
            (bo[8] == le and bo[5] == le and bo[2] == le) or
            (bo[9] == le and bo[6] == le and bo[3] == le) or
            (bo[7] == le and bo[5] == le and bo[3] == le) or
            (bo[9] == le and bo[5] == le and bo[1] == le))
</code>```

Title: Python "TypeError: 'bool' object is not callable" Error

Body:
This is the proper way of writing isWinner:

def isWinner(bo, le):
    return ((bo[7] == le and bo[8] == le and bo[9] == le) or
            (bo[4] == le and bo[5] == le and bo[6] == le) or
            (bo[1] == le and bo[2] == le and bo[3] == le) or
            (bo[7] == le and bo[4] == le and bo[1] == le) or
            (bo[8] == le and bo[5] == le and bo[2] == le) or
            (bo[9] == le and bo[6] == le and bo[3] == le) or
            (bo[7] == le and bo[5] == le and bo[3] == le) or
            (bo[9] == le and bo[5] == le and bo[1] == le))


问:
Detecting length of overlap between two strings
```<code>int overlap(const char *s1, const char *s2){
    int i = 0;
    while (s1[i] && s2[i] && s1[i] == s2[i])
        i++;
    return i;
}
</code>```

This returns the length of the substring overlap between the two strings it takes as input. However, if the two strings are:

```<code>abcdefg
1234efg
</code>```

it returns an overlap of 0 because it can only read overlaps that start at the beginning of the strings, can someone modify or help me to make it so that it can read overlaps no mantter where they are in the strings?

答: The easy way to do this is to build a suffix-tree for the two strings(this is done using McCreght ). now just look for the longests common substring with origin in both strings.</p>

Body:
int overlap(const char *s1, const char *s2){
    int i = 0;
    while (s1[i] && s2[i] && s1[i] == s2[i])
        i++;
    return i;
}

This returns the length of the substring overlap between the two strings it takes as input. However, if the two strings are:

abcdefg
1234efg

it returns an overlap of 0 because it can only read overlaps that start at the beginning of the strings, can someone modify or help me to make it so that it can read overlaps no mantter where they are in the strings?


问:
Pandas how to count frequencies of patterns in dataframe
I have this sample dataframe:

```<code>ID,Action,Station
01,P,S1
01,R,S2
01,P,S1
01,R,S2
02,P,S2
02,R,S1
02,P,S2
02,R,S1
03,P,S2
03,R,S1
</code>```

My goal is to count patterns of occurrencies in Action and Station columns such as ordered couples like (P,R) and corresponding Station values. So that the resulting dataframe would appear as:

```<code>S1,S2,2
S2,S1,3
</code>```

So the pattern to find is the (P,R) tuple for each ID (ID values may be duplicated) and count their frequencies in Station.

My attemps so far went to groupby by Action and Station and get their value counts:

```<code>g = df.groupby(['Station','ID'])['Action'].size()
</code>```

and get:

```<code>Station  ID
S1       1     2
         2     2
         3     1
S2       1     2
         2     2
         3     1
Name: Action, dtype: int64
</code>```

but still I cannot take care of the (P,R) tuple and their frequencies.

答:
Define a counter for pairs of rows within each ID. Then merge the P and Rs together by merging with itself, but mapping P - > R and R -> P in one Frame. Drop duplicates as the second row is redundant, then get the size.

This only works because Each ID has P and R occurring in pairs, one row after the other

```<code>df['idx'] = df.groupby('ID').cumcount()//2
m = (df.merge(df.assign(Action=df.Action.map({'P': 'R', 'R': 'P'})),
              on=['ID', 'idx', 'Action'], suffixes=['_P', '_R'])
       .drop_duplicates(['ID', 'idx']))

m.groupby(['Station_P', 'Station_R']).size()
</code>```

```<code>Station_P  Station_R
S1         S2           2
S2         S1           3
dtype: int64
</code>```

For reference, m looks like

```<code>   ID Action Station_P  idx Station_R
0   1      P        S1    0        S2
2   1      P        S1    1        S2
4   2      P        S2    0        S1
6   2      P        S2    1        S1
8   3      P        S2    0        S1
</code>```

Body:
I have this sample dataframe:

ID,Action,Station
01,P,S1
01,R,S2
01,P,S1
01,R,S2
02,P,S2
02,R,S1
02,P,S2
02,R,S1
03,P,S2
03,R,S1

My goal is to count patterns of occurrencies in Action and Station columns such as ordered couples like (P,R) and corresponding Station values. So that the resulting dataframe would appear as:

S1,S2,2
S2,S1,3

So the pattern to find is the (P,R) tuple for each ID (ID values may be duplicated) and count their frequencies in Station.

My attemps so far went to groupby by Action and Station and get their value counts:

g = df.groupby(['Station','ID'])['Action'].size()

and get:

Station  ID
S1       1     2
         2     2
         3     1
S2       1     2
         2     2
         3     1
Name: Action, dtype: int64

but still I cannot take care of the (P,R) tuple and their frequencies.

Body:
Define a counter for pairs of rows within each ID. Then merge the P and Rs together by merging with itself, but mapping P - > R and R -> P in one Frame. Drop duplicates as the second row is redundant, then get the size.

This only works because Each ID has P and R occurring in pairs, one row after the other

df['idx'] = df.groupby('ID').cumcount()//2
m = (df.merge(df.assign(Action=df.Action.map({'P': 'R', 'R': 'P'})),
              on=['ID', 'idx', 'Action'], suffixes=['_P', '_R'])
       .drop_duplicates(['ID', 'idx']))

m.groupby(['Station_P', 'Station_R']).size()

Station_P  Station_R
S1         S2           2
S2         S1           3
dtype: int64

For reference, m looks like

   ID Action Station_P  idx Station_R
0   1      P        S1    0        S2
2   1      P        S1    1        S2
4   2      P        S2    0        S1
6   2      P        S2    1        S1
8   3      P        S2    0        S1


问:
Skip blank cells until value added in Google Sheets
I've created a budget sheet that includes a running balance in column E.

The problem that I've run into is my formula =IF(C140="","",(SUM($E139,C140))) works down the line after E140 (first day of the month that I started to implement this) until there is a blank. At the blank, the formula breaks for me. Now because this is a projected running total, it's preferred to have the blank spaces to allow for the days of the month.

I've tried a couple different ways to get the isblank or lookup formulas to work but I realize this is beyond my excel and google sheets knowledge. Is there a way to get the formula to skip the blank cells down column E and just use the last value, ie $598.66 in E143 when you get to the next cell that has a value in it, ie E151?

Photo added for reference....

答:
try:

```<code>=ARRAYFORMULA(IF(E2:E="",,MMULT(TRANSPOSE((ROW(E2:E)<=
 TRANSPOSE(ROW(E2:E)))*E2:E), SIGN(E2:E)^0)))
</code>```

Body:
try:

=ARRAYFORMULA(IF(E2:E="",,MMULT(TRANSPOSE((ROW(E2:E)<=
 TRANSPOSE(ROW(E2:E)))*E2:E), SIGN(E2:E)^0)))


问:
Piping into grep using cat returns error: no such file or directory
I am practicing on bash. When I try this command, I get an error: "grep: where: No such file or directory".</p>

```<code>cat file2.txt | tr " " "\n" | grep –i where | wc -l
</code>```

```<code>Content of file2.txt = 1 2 3 4 where 5 where 7 where

</code>```

答:
There is nothing wrong with your command. And it should work as is. Maybe you copy pasted some non visible chars that are messing it. Copy paste the below command and try again by changing for your real values.

```<code>cat script.sh | tr ' ' '\n' | grep -i echo | wc -l
</code>```

Let me know if it works.

Body:
I am practicing on bash. When I try this command, I get an error: "grep: where: No such file or directory".

cat file2.txt | tr " " "\n" | grep –i where | wc -l

Content of file2.txt = 1 2 3 4 where 5 where 7 where

Body:
There is nothing wrong with your command. And it should work as is. Maybe you copy pasted some non visible chars that are messing it. Copy paste the below command and try again by changing for your real values.

cat script.sh | tr ' ' '\n' | grep -i echo | wc -l

Let me know if it works.


问:
Unable to Call Function in Go debugger
I am following the "Little Go Book" by Karl Seguin, in order to learn Go.

My working environment is Visual Studio Code.

Upon debugging, when I try to call a function from the debug console, i get the following error:
"function calls not allowed without using 'call'", if I try using "call fib(10)", i get "Unable to eval expression: "1:6: expected 'EOF', found fib".
This is the function I am trying to evaluate:

```<code>//Fibonnaci
func fib(n int) int64 {
    if n == 0 {
        return 0
    } else if n == 1 {
        return 1
    } else {
        return fib(n-1) + fib(n-2)
    }
}
</code>```

If i try to call the function from the code itself ( from the main() for instance, it works perfectly).

However, if I set a breakpoint and try to call the same function from the debugger console, I get the below error:

```<code>Eval error: function calls not allowed without using 'call'
call fib(10)
Unable to eval expression: "1:6: expected 'EOF', found fib"
Failed to eval expression:  {
 "Expr": "call fib(10)",
 "Scope": {
  "goroutineID": 1,
  "frame": 0
 },
 "Cfg": {
  "followPointers": true,
  "maxVariableRecurse": 1,
  "maxStringLen": 64,
  "maxArrayValues": 64,
  "maxStructFields": -1
 }
}
</code>```

答: Looks like "Function calls via delve 'call' are not supported" yet github issue in microsoft/vscode-go repo :(</p>

Title: Unable to Call Function in Go debugger

Body:
I am following the "Little Go Book" by Karl Seguin, in order to learn Go.

My working environment is Visual Studio Code.

Upon debugging, when I try to call a function from the debug console, i get the following error:
"function calls not allowed without using 'call'", if I try using "call fib(10)", i get "Unable to eval expression: "1:6: expected 'EOF', found fib".
This is the function I am trying to evaluate:

//Fibonnaci
func fib(n int) int64 {
    if n == 0 {
        return 0
    } else if n == 1 {
        return 1
    } else {
        return fib(n-1) + fib(n-2)
    }
}

If i try to call the function from the code itself ( from the main() for instance, it works perfectly).

However, if I set a breakpoint and try to call the same function from the debugger console, I get the below error:

Eval error: function calls not allowed without using 'call'
call fib(10)
Unable to eval expression: "1:6: expected 'EOF', found fib"
Failed to eval expression:  {
 "Expr": "call fib(10)",
 "Scope": {
  "goroutineID": 1,
  "frame": 0
 },
 "Cfg": {
  "followPointers": true,
  "maxVariableRecurse": 1,
  "maxStringLen": 64,
  "maxArrayValues": 64,
  "maxStructFields": -1
 }
}


问:
Trouble consuming Wordpress data
I'm writing an application that uses the wordpress-java library to display each article in a ListView (much like the NYTimes app, and other similar news apps). Here is the full stack trace I get whenever I try to grab the data (both from the emulator and from my phone(Motorola Droid)):

```<code>05-16 23:00:45.800: WARN/System.err(1198): redstone.xmlrpc.XmlRpcException: The response could not be parsed.
05-16 23:00:45.839: WARN/System.err(1198):     at redstone.xmlrpc.XmlRpcClient.handleResponse(Unknown Source)
05-16 23:00:45.847: WARN/System.err(1198):     at redstone.xmlrpc.XmlRpcClient.endCall(Unknown Source)
05-16 23:00:45.847: WARN/System.err(1198):     at redstone.xmlrpc.XmlRpcClient.invoke(Unknown Source)
05-16 23:00:45.847: WARN/System.err(1198):     at redstone.xmlrpc.XmlRpcProxy.invoke(Unknown Source)
05-16 23:00:45.847: WARN/System.err(1198):     at net.bican.wordpress.$Proxy1.getRecentPosts(Native Method)
05-16 23:00:45.847: WARN/System.err(1198):     at net.bican.wordpress.Wordpress.getRecentPosts(Wordpress.java:497)
05-16 23:00:45.847: WARN/System.err(1198):     at namespace.onCreate(Test.java:28)
05-16 23:00:45.847: WARN/System.err(1198):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-16 23:00:45.847: WARN/System.err(1198):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-16 23:00:45.847: WARN/System.err(1198):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-16 23:00:45.847: WARN/System.err(1198):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-16 23:00:45.847: WARN/System.err(1198):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-16 23:00:45.847: WARN/System.err(1198):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-16 23:00:45.847: WARN/System.err(1198):     at android.os.Looper.loop(Looper.java:123)
05-16 23:00:45.847: WARN/System.err(1198):     at android.app.ActivityThread.main(ActivityThread.java:4627)
05-16 23:00:45.847: WARN/System.err(1198):     at java.lang.reflect.Method.invokeNative(Native Method)
05-16 23:00:45.847: WARN/System.err(1198):     at java.lang.reflect.Method.invoke(Method.java:521)
05-16 23:00:45.847: WARN/System.err(1198):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-16 23:00:45.847: WARN/System.err(1198):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-16 23:00:45.847: WARN/System.err(1198):     at dalvik.system.NativeStart.main(Native Method)
05-16 23:00:45.847: WARN/System.err(1198): Caused by: redstone.xmlrpc.XmlRpcException: Could not instantiate XMLReader parser
05-16 23:00:45.847: WARN/System.err(1198):     at redstone.xmlrpc.XmlRpcParser.parse(Unknown Source)
05-16 23:00:45.847: WARN/System.err(1198):     ... 20 more
05-16 23:00:45.847: WARN/System.err(1198): Caused by: org.xml.sax.SAXException: Can't create default XMLReader; is system property org.xml.sax.driver set?
05-16 23:00:45.847: WARN/System.err(1198):     at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:157)
05-16 23:00:45.847: WARN/System.err(1198):     ... 21 more
</code>```

However, when I throw the exact same code into a simple Java app, I am able to query all the data normally. In the Manifest I have enabled permission to android.permission.INTERNET. Is there anything else that I need to enable? I looked through the others and none of the others seem to refer to anything data-related (the only thing I need).

Here is the code from the Java app (the Android looks pretty much the same, plus the ListView code)

```<code>    String username = "username";
    String password = "password";
    String xmlRpcUrl = "http://www.example.com/xmlrpc.php";

    try
    {
        Wordpress wp = new Wordpress(username, password, xmlRpcUrl);
        List<Page> recentPosts = wp.getRecentPosts(10);

        for (Page p : recentPosts)
        {
            System.out.println(p.getTitle());
        }
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
</code>```

答:
That particular error happens in the Redstone XML-RPC library used by wordpress-java if either a socket error occured (so a bad connection), the XML returned by the web service was unparseable (so a server error), or a response other than HTTP 200 was received. Without a full stack trace its hard to tell which one it is, but I'd suspect if the exact same code worked on the desktop but not in the Android VM and you have the INTERNET permission that you have a connectivity issue (are you using an emulator or a device with a live connection)?

Include a full stack dump (use android.util.Log.v("WPJAVA", "Exception ["+e.getMessage()+"]", e); instead of just e.printStackTrace() on Android).

EDIT: And, you have your answer:

```<code>05-16 23:00:45.847: WARN/System.err(1198): Caused by: org.xml.sax.SAXException: Can't create default XMLReader; is system property org.xml.sax.driver set?
</code>```

Try executing this before you call the redstone functions:

```<code>System.setProperty("org.xml.sax.driver","org.xmlpull.v1.sax2.Driver");
</code>```

Title: Trouble consuming Wordpress data

Body:
I'm writing an application that uses the wordpress-java library to display each article in a ListView (much like the NYTimes app, and other similar news apps). Here is the full stack trace I get whenever I try to grab the data (both from the emulator and from my phone(Motorola Droid)):

05-16 23:00:45.800: WARN/System.err(1198): redstone.xmlrpc.XmlRpcException: The response could not be parsed.
05-16 23:00:45.839: WARN/System.err(1198):     at redstone.xmlrpc.XmlRpcClient.handleResponse(Unknown Source)
05-16 23:00:45.847: WARN/System.err(1198):     at redstone.xmlrpc.XmlRpcClient.endCall(Unknown Source)
05-16 23:00:45.847: WARN/System.err(1198):     at redstone.xmlrpc.XmlRpcClient.invoke(Unknown Source)
05-16 23:00:45.847: WARN/System.err(1198):     at redstone.xmlrpc.XmlRpcProxy.invoke(Unknown Source)
05-16 23:00:45.847: WARN/System.err(1198):     at net.bican.wordpress.$Proxy1.getRecentPosts(Native Method)
05-16 23:00:45.847: WARN/System.err(1198):     at net.bican.wordpress.Wordpress.getRecentPosts(Wordpress.java:497)
05-16 23:00:45.847: WARN/System.err(1198):     at namespace.onCreate(Test.java:28)
05-16 23:00:45.847: WARN/System.err(1198):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-16 23:00:45.847: WARN/System.err(1198):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-16 23:00:45.847: WARN/System.err(1198):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-16 23:00:45.847: WARN/System.err(1198):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-16 23:00:45.847: WARN/System.err(1198):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-16 23:00:45.847: WARN/System.err(1198):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-16 23:00:45.847: WARN/System.err(1198):     at android.os.Looper.loop(Looper.java:123)
05-16 23:00:45.847: WARN/System.err(1198):     at android.app.ActivityThread.main(ActivityThread.java:4627)
05-16 23:00:45.847: WARN/System.err(1198):     at java.lang.reflect.Method.invokeNative(Native Method)
05-16 23:00:45.847: WARN/System.err(1198):     at java.lang.reflect.Method.invoke(Method.java:521)
05-16 23:00:45.847: WARN/System.err(1198):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-16 23:00:45.847: WARN/System.err(1198):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-16 23:00:45.847: WARN/System.err(1198):     at dalvik.system.NativeStart.main(Native Method)
05-16 23:00:45.847: WARN/System.err(1198): Caused by: redstone.xmlrpc.XmlRpcException: Could not instantiate XMLReader parser
05-16 23:00:45.847: WARN/System.err(1198):     at redstone.xmlrpc.XmlRpcParser.parse(Unknown Source)
05-16 23:00:45.847: WARN/System.err(1198):     ... 20 more
05-16 23:00:45.847: WARN/System.err(1198): Caused by: org.xml.sax.SAXException: Can't create default XMLReader; is system property org.xml.sax.driver set?
05-16 23:00:45.847: WARN/System.err(1198):     at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(XMLReaderFactory.java:157)
05-16 23:00:45.847: WARN/System.err(1198):     ... 21 more

However, when I throw the exact same code into a simple Java app, I am able to query all the data normally. In the Manifest I have enabled permission to android.permission.INTERNET. Is there anything else that I need to enable? I looked through the others and none of the others seem to refer to anything data-related (the only thing I need).

Here is the code from the Java app (the Android looks pretty much the same, plus the ListView code)

    String username = "username";
    String password = "password";
    String xmlRpcUrl = "http://www.example.com/xmlrpc.php";

    try
    {
        Wordpress wp = new Wordpress(username, password, xmlRpcUrl);
        List<Page> recentPosts = wp.getRecentPosts(10);

        for (Page p : recentPosts)
        {
            System.out.println(p.getTitle());
        }
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }

Body:
That particular error happens in the Redstone XML-RPC library used by wordpress-java if either a socket error occured (so a bad connection), the XML returned by the web service was unparseable (so a server error), or a response other than HTTP 200 was received. Without a full stack trace its hard to tell which one it is, but I'd suspect if the exact same code worked on the desktop but not in the Android VM and you have the INTERNET permission that you have a connectivity issue (are you using an emulator or a device with a live connection)?

Include a full stack dump (use android.util.Log.v("WPJAVA", "Exception ["+e.getMessage()+"]", e); instead of just e.printStackTrace() on Android).

EDIT: And, you have your answer:

05-16 23:00:45.847: WARN/System.err(1198): Caused by: org.xml.sax.SAXException: Can't create default XMLReader; is system property org.xml.sax.driver set?

Try executing this before you call the redstone functions:

System.setProperty("org.xml.sax.driver","org.xmlpull.v1.sax2.Driver");


问:
Function maybe written wrong, doesn't toggle image
This code is supposed to toggle between the "like" and "unlike" images, except it doesn't. Can anybody tell me what i wrote wrong. And yes i am new to javascript.</p>

```<code><script>
        function imgclick(){
        var like = "like.png",
            unlike = "unlike.png";
        var liked = document.getElemendById("liked");

        liked.src = (liked.src === unlike)? like : unlike;
        }
</script>
    <img src="unlike.png" id="liked" width="200" height="200" onclick="imgclick();">
</code>```

答:
If you are new to JS I just want to recommend to you to use relative paths every time you can, because it is going to save you a headache in the future.

It goes like this: var like = "./like.png"


问:
Pass a param to my AppComponent at Bootstrap time
I'm working on a angular v7 app that is hosted on a asp.net application.
Basically I will have a dropdown on my .net app and I want to call the angular one with the selected value.
I did several attempts to pass a param at the bootstrap (app.module.ts) but am getting an error.

```<code>@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule
  ],
  providers: [],
  entryComponents: [AppComponent]
})
export class AppModule {

  ngDoBootstrap(app: ApplicationRef) {
    document.addEventListener('myAppA', function(e : CustomEvent) {
        app.bootstrap(AppComponent, [{provide:'MESSAGE', useValue: 'Hello Angular'}]);
    });
  }
}
</code>```

I believe there is a simple way to achieve it. Any ideas?

答:
I have found something. Pass default parameter values like this:

app.module.ts

```<code>ngDoBootstrap(app: ApplicationRef){
    let ref = app.bootstrap(AppComponent);
    ref['_component'].name= "updated name"
}
</code>```

app.component.ts

```<code>export class AppComponent  {
  name = 'Angular 4';
}
</code>```

Working link:

https://stackblitz.com/edit/angular-ngdobootstrap-8lygvr?embed=1&file=app/app.component.ts

Body:
I'm working on a angular v7 app that is hosted on a asp.net application.
Basically I will have a dropdown on my .net app and I want to call the angular one with the selected value.
I did several attempts to pass a param at the bootstrap (app.module.ts) but am getting an error.

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule
  ],
  providers: [],
  entryComponents: [AppComponent]
})
export class AppModule {

  ngDoBootstrap(app: ApplicationRef) {
    document.addEventListener('myAppA', function(e : CustomEvent) {
        app.bootstrap(AppComponent, [{provide:'MESSAGE', useValue: 'Hello Angular'}]);
    });
  }
}

I believe there is a simple way to achieve it. Any ideas?

Body:
I have found something. Pass default parameter values like this:

app.module.ts

ngDoBootstrap(app: ApplicationRef){
    let ref = app.bootstrap(AppComponent);
    ref['_component'].name= "updated name"
}

app.component.ts

export class AppComponent  {
  name = 'Angular 4';
}

Working link:

https://stackblitz.com/edit/angular-ngdobootstrap-8lygvr?embed=1&file=app/app.component.ts


问:
What is the point of using OpenAPI at all?
I didn't come from a background using OpenAPI or anything like it, even though I built and used REST APIs in my day job over and over again. In my current role, we always have OpenAPI specs defined, and it seems to be an assumed part of the process. The team treats it as very important.

However, I cannot for the life of me recognize a single benefit to it. I'm trying to understand better.

Of the things I know it can do, none of them appear to be beneficial, imho, but I have to be missing something.

OpenAPI specs can generate documentation, but documentation is for humans to read and should be written by human, in my opinion. Generated docs might include all the bits, but none of the context and nuance of using the API as a whole.

OpenAPI specs can generate client code in many languages for a single API. These are just going to map the REST URL structure to method names, usually. Is that really helpful? It means I might do client.books.get(title="Moby Dick") instead of client.get("/books", {'title': 'Moby Dick'}). All its doing is shifting around the same names, not making anything necessarily easier or more concise. So, again, what's the point? A generated client doesn't seem to actually add anything at all.

Can anyone enlighten me?

答:
Well I can put a couple of advantages here you can get

You get your API documented.

Any external client can easily go and read which is the contract you are specifying for your REST API and how they can integrate with your API without talking to your development group and scheduling meetings with your tech leads.

Generally, resources can have multiple presentations, mostly because there may be multiple different clients expecting different representations. If you use a visual tool to generate your
documentation based on your OpenAPI format, you can easily show for
the same resource, all models you use based on the content
negotiation(Content-Types/Accept headers for example)

If you have a valid OpenAPI(Swagger format) you can import the documentation and host it on an API Gateway, which can serve you as an entry point for all your external clients to search for the API they need to integrate with your organization. Also, you can
generate some API keys and identify which client is consuming your
API.

You don't need to use the postman to do some tests and get/post data to your API if you generate the UI for your documentation.

Visual studio has now a feature where you pass the URL for your API, it discovers for you the endpoints and creates an HttpClient to start consuming it.

Hope this helps