问:
VSCODE LARAVEL XDEBUG PHP DEBUG extension - not stopping on breakpoints
I'm trying to debug a laravel app using vscode. It seems that xdebug is connecting but I'm having no luck so far with the breakpoints. I have set a few but it is not stopping as intended.

Here is my config and logs.

I start listening in vscode with F5, and then I run php artisan serve on the terminal.

php.ini ->

```<code>[XDebug]
zend_extension=C:\xampp\php\ext\php_xdebug-2.9.2-7.3-vc15-x86_64.dll
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_port=9091
xdebug.remote_host=127.0.0.1
xdebug.remote_log=C:\xampp\xdebug.log
xdebug.idekey=VSCODE
</code>```

launch.json

```<code>{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9091,
            "log": true
        }
    ]
}
</code>```

C:\xampp\xdebug.log

```<code>[241672] Log opened at 2020-02-28 20:02:30
[241672] I: Connecting to configured address/port: 127.0.0.1:9091.
[241672] I: Connected to client. :-)
[241672] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/Development/Menuu/menuu_backend_dev/artisan" language="PHP" xdebug:language_version="7.3.13" protocol_version="1.0" appid="241672" idekey="VSCODE"><engine version="2.9.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>

[241672] <- breakpoint_list -i 1
[241672] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="1"></response>

[241672] <- breakpoint_set -i 2 -t line -f file:///c:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/Auth/LoginController.php -n 48
[241672] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="2" id="1106000001"></response>

[241672] <- breakpoint_list -i 3
[241672] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="3"><breakpoint type="line" filename="file:///C:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/Auth/LoginController.php" lineno="48" state="enabled" hit_count="0" hit_value="0" id="1106000001"></breakpoint></response>

[241672] <- breakpoint_set -i 4 -t line -f file:///c:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/API/Driver/UserAPIController.php -n 40
[241672] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="4" id="1106000002"></response>

[241672] <- breakpoint_list -i 5
[241672] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="5"><breakpoint type="line" filename="file:///C:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/API/Driver/UserAPIController.php" lineno="40" state="enabled" hit_count="0" hit_value="0" id="1106000002"></breakpoint><breakpoint type="line" filename="file:///C:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/Auth/LoginController.php" lineno="48" state="enabled" hit_count="0" hit_value="0" id="1106000001"></breakpoint></response>

[241672] <- breakpoint_list -i 6
[241672] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="6"><breakpoint type="line" filename="file:///C:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/API/Driver/UserAPIController.php" lineno="40" state="enabled" hit_count="0" hit_value="0" id="1106000002"></breakpoint><breakpoint type="line" filename="file:///C:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/Auth/LoginController.php" lineno="48" state="enabled" hit_count="0" hit_value="0" id="1106000001"></breakpoint></response>

[241672] <- run -i 7
</code>```

答:
Place your breakpoints on lines that have code.

If you place your breakpoints on BLANK LINES it will not work, it will just skip them.

Body:
I'm trying to debug a laravel app using vscode. It seems that xdebug is connecting but I'm having no luck so far with the breakpoints. I have set a few but it is not stopping as intended.

Here is my config and logs.

I start listening in vscode with F5, and then I run php artisan serve on the terminal.

php.ini ->

[XDebug]
zend_extension=C:\xampp\php\ext\php_xdebug-2.9.2-7.3-vc15-x86_64.dll
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_port=9091
xdebug.remote_host=127.0.0.1
xdebug.remote_log=C:\xampp\xdebug.log
xdebug.idekey=VSCODE

launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9091,
            "log": true
        }
    ]
}

C:\xampp\xdebug.log

[241672] Log opened at 2020-02-28 20:02:30
[241672] I: Connecting to configured address/port: 127.0.0.1:9091.
[241672] I: Connected to client. :-)
[241672] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/Development/Menuu/menuu_backend_dev/artisan" language="PHP" xdebug:language_version="7.3.13" protocol_version="1.0" appid="241672" idekey="VSCODE"><engine version="2.9.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>

[241672] <- breakpoint_list -i 1
[241672] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="1"></response>

[241672] <- breakpoint_set -i 2 -t line -f file:///c:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/Auth/LoginController.php -n 48
[241672] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="2" id="1106000001"></response>

[241672] <- breakpoint_list -i 3
[241672] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="3"><breakpoint type="line" filename="file:///C:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/Auth/LoginController.php" lineno="48" state="enabled" hit_count="0" hit_value="0" id="1106000001"></breakpoint></response>

[241672] <- breakpoint_set -i 4 -t line -f file:///c:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/API/Driver/UserAPIController.php -n 40
[241672] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="4" id="1106000002"></response>

[241672] <- breakpoint_list -i 5
[241672] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="5"><breakpoint type="line" filename="file:///C:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/API/Driver/UserAPIController.php" lineno="40" state="enabled" hit_count="0" hit_value="0" id="1106000002"></breakpoint><breakpoint type="line" filename="file:///C:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/Auth/LoginController.php" lineno="48" state="enabled" hit_count="0" hit_value="0" id="1106000001"></breakpoint></response>

[241672] <- breakpoint_list -i 6
[241672] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="6"><breakpoint type="line" filename="file:///C:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/API/Driver/UserAPIController.php" lineno="40" state="enabled" hit_count="0" hit_value="0" id="1106000002"></breakpoint><breakpoint type="line" filename="file:///C:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/Auth/LoginController.php" lineno="48" state="enabled" hit_count="0" hit_value="0" id="1106000001"></breakpoint></response>

[241672] <- run -i 7


来源: stackexchange

问:
Getting error whenever try to replace a column name
Whenever I try to replace column names using the below codes, I get an error.

```<code>colnames(all_lab_drug)<- str_replace_all(colnames(all_lab_drug),' |-','_')
</code>```

Error

```<code>Error in str_replace_all(colnames(all_lab_drug), " |-", "_"):
  could not find function "str_replace_all"
</code>```

答:
You need to load the stringr package before running the code.

```<code>library(stringr)

colnames(all_lab_drug) <- str_replace_all(colnames(all_lab_drug), ' \\|-', '_')
</code>```

Or you can call the package explicitly.

```<code>stringr::str_replace_all(colnames(all_lab_drug), ' \\|-', '_')

# [1] "drug_one"   "drug_two"   "drug_three"
</code>```

Data

```<code>all_lab_drug <-
  structure(
    list(
      `drug |-one` = c(1, 1),
      `drug |-two` = c(1, 1),
      `drug |-three` = c(1, 1)
    ),
    class = "data.frame",
    row.names = c(NA,-2L)
  )
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Whenever I try to replace column names using the below codes, I get an error.

colnames(all_lab_drug)<- str_replace_all(colnames(all_lab_drug),' |-','_')

Error

Error in str_replace_all(colnames(all_lab_drug), " |-", "_"):
  could not find function "str_replace_all"

Body:
You need to load the stringr package before running the code.

library(stringr)

colnames(all_lab_drug) <- str_replace_all(colnames(all_lab_drug), ' \\|-', '_')

Or you can call the package explicitly.

stringr::str_replace_all(colnames(all_lab_drug), ' \\|-', '_')

# [1] "drug_one"   "drug_two"   "drug_three"

Data

all_lab_drug <-
  structure(
    list(
      `drug |-one` = c(1, 1),
      `drug |-two` = c(1, 1),
      `drug |-three` = c(1, 1)
    ),
    class = "data.frame",
    row.names = c(NA,-2L)
  )


问:
How to set the data type for a route param in swagger?
I have a simple nest.js controller with a route param:

```<code>@Get(':id')
getHello(@Param('id', MyStringPipe) myString: MyString): string {
  return myString.toString();
}
</code>```

The data type of the param is transformed from string to MyString with a simple pipe:

```<code>export class MyStringPipe implements PipeTransform {
  transform(value: string, metadata: ArgumentMetadata) {
    return new MyString(value);
  }
}
</code>```

Now, when I want to try the route with swagger-ui, it rejects a string param:

How can I set the datatype of the param to string for swagger?

Try it out here:

答:
You can import ApiParam from Swagger:

nestjs v8.2.6

@nestjs/swagger v5.2.0

Code:

```<code>import { ApiParam } from '@nestjs/swagger';

@Get(':id')
@ApiParam({ name: 'id', type: String })
getHello(@Param('id', MyStringPipe) myString: MyString): string {
  return myString.toString();
}
</code>```

Body:
I have a simple nest.js controller with a route param:

@Get(':id')
getHello(@Param('id', MyStringPipe) myString: MyString): string {
  return myString.toString();
}

The data type of the param is transformed from string to MyString with a simple pipe:

export class MyStringPipe implements PipeTransform {
  transform(value: string, metadata: ArgumentMetadata) {
    return new MyString(value);
  }
}

Now, when I want to try the route with swagger-ui, it rejects a string param:

How can I set the datatype of the param to string for swagger?

Try it out here:

Body:
You can import ApiParam from Swagger:

nestjs v8.2.6

@nestjs/swagger v5.2.0

Code:

import { ApiParam } from '@nestjs/swagger';

@Get(':id')
@ApiParam({ name: 'id', type: String })
getHello(@Param('id', MyStringPipe) myString: MyString): string {
  return myString.toString();
}


问:
Is it possible to have multiple different pm2 instances running at the same time?
I am just wondering if I can seperate my pm2 instances. For example, let's say I have one ecosystem file that I start in one terminal, and then I go ahead and start another ecosystem file in another terminal. Both processes seem to merge and start outputting the same logs. Becomes real annoying real quick. Is there a way to have them seperate?</p>

答:
PM2 uses the .pm2 folder by default to place its logs and .pid file. PM2 uses the PM2_HOME environment variable to know where this folder is. I uncovered this when I was moving the folder to a larger drive and ended up with a new instance when I checked on the apps it was monitoring.  As stated in the docs about running multiple PM2 instances, you can run multiple PM2 instance simply by specifying a different folder for each:

```<code>PM2_HOME='.pm2' pm2 start echo.js --name="echo-node-1"
PM2_HOME='.pm3' pm2 start echo.js --name="echo-node-2"
</code>```

Keep in mind that to run any PM2 commands, you'll have to prefix with the proper PM2_HOME:

```<code>PM2_HOME='.pm2' pm2 list
PM2_HOME='.pm3' pm2 list
</code>```

Body:
PM2 uses the .pm2 folder by default to place its logs and .pid file. PM2 uses the PM2_HOME environment variable to know where this folder is. I uncovered this when I was moving the folder to a larger drive and ended up with a new instance when I checked on the apps it was monitoring.  As stated in the docs about running multiple PM2 instances, you can run multiple PM2 instance simply by specifying a different folder for each:

PM2_HOME='.pm2' pm2 start echo.js --name="echo-node-1"
PM2_HOME='.pm3' pm2 start echo.js --name="echo-node-2"

Keep in mind that to run any PM2 commands, you'll have to prefix with the proper PM2_HOME:

PM2_HOME='.pm2' pm2 list
PM2_HOME='.pm3' pm2 list


问:
Python Selenium: unable to reach particular image in a flyer to scrape text
I am trying to scrape this website: https://www.longos.com/flyers.

I've been able to enter the postal code (ex.M5B 0B7 for people who may not be familiar with postal codes in this area) , click on the closest store and have the flyer pop up.

However, I am having troubles clicking into the specific flyer page, get the particular product and get the text information. The code below is my attempt.

```<code>i = 1
while True:
    flyer_link = "/html/body/flipp-router/flipp-publication-page/div/flipp-sfml-component/sfml-storefront/div/sfml-linear-layout/sfml-flyer-image[{}]".format(i)
    print(flyer_link)
    flyer = WebDriverWait(driver, 30).until(EC.visibility_of_element_located((By.XPATH, flyer_link)))
    print(flyer)

    i+=1
</code>```

It doesn't seem to be abble to recognize the XPATH

Here is a snapshot of the html code for reference:

```<code>j = 1

for i in prdcts:
    driver.execute_script("arguments[0].scrollIntoView();", i)
    i.click()
time.sleep(3)
print(i)
# print(driver.page_source)

i = 1
while True:

    try:
        button_link_to_text = '/html/body/flipp-router/flipp-publication-page/div/flipp-sfml-component/sfml-storefront/div/sfml-linear-layout/sfml-flyer-image[{}]/div/button[{}]'.format(j,i)
        button = driver.find_element_by_xpath(button_link_to_text)
        print(button.get_attribute("aria-label"))
        i+=1
    except:
        break
j+=1
</code>```

答:
Try this

```<code>from selenium.webdriver.common.action_chains import ActionChains
import time
from webdriver_manager.chrome import ChromeDriverManager
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome(ChromeDriverManager().install())
driver.maximize_window()
driver.get('https://www.longos.com/flyers')
time.sleep(5)

iframe = driver.find_element_by_xpath('//iframe[@class="flippiframe productframe"]')
driver.switch_to.frame(iframe)
eleme = driver.find_element_by_xpath('//input[@id="postal-input"]')
eleme.send_keys("M5B0B7")
eleme = driver.find_element_by_xpath('//button[@id="submit-postal-code"]').click()
time.sleep(2)
eleme = driver.find_element_by_xpath('//button [@aria-label="Select Elizabeth 111 Elizabeth Street Toronto ON, distance from store is <1 km"]').click()
driver.switch_to.default_content()
time.sleep(5)
iframe = driver.find_element_by_xpath('//iframe[@class="flippiframe mainframe"]')
driver.switch_to.frame(iframe)
prdcts = driver.find_elements_by_xpath('//sfml-flyer-image//button')
print (prdcts)
for i in prdcts:
    driver.execute_script("arguments[0].scrollIntoView();", i)
    print(i.get_attribute("aria-label"))

    time.sleep(3)
    print(I)
</code>```

and don't forget to switch back to class="flippiframe productframe"] this frame to get the product details.

the main thing is you need to switch the iframes and get into view to interact with that element

Body:
I am trying to scrape this website: https://www.longos.com/flyers.

I've been able to enter the postal code (ex.M5B 0B7 for people who may not be familiar with postal codes in this area) , click on the closest store and have the flyer pop up.

However, I am having troubles clicking into the specific flyer page, get the particular product and get the text information. The code below is my attempt.

i = 1
while True:
    flyer_link = "/html/body/flipp-router/flipp-publication-page/div/flipp-sfml-component/sfml-storefront/div/sfml-linear-layout/sfml-flyer-image[{}]".format(i)
    print(flyer_link)
    flyer = WebDriverWait(driver, 30).until(EC.visibility_of_element_located((By.XPATH, flyer_link)))
    print(flyer)

    i+=1

It doesn't seem to be abble to recognize the XPATH

Here is a snapshot of the html code for reference:

j = 1

for i in prdcts:
    driver.execute_script("arguments[0].scrollIntoView();", i)
    i.click()
time.sleep(3)
print(i)
# print(driver.page_source)

i = 1
while True:

    try:
        button_link_to_text = '/html/body/flipp-router/flipp-publication-page/div/flipp-sfml-component/sfml-storefront/div/sfml-linear-layout/sfml-flyer-image[{}]/div/button[{}]'.format(j,i)
        button = driver.find_element_by_xpath(button_link_to_text)
        print(button.get_attribute("aria-label"))
        i+=1
    except:
        break
j+=1

Body:
Try this

from selenium.webdriver.common.action_chains import ActionChains
import time
from webdriver_manager.chrome import ChromeDriverManager
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = webdriver.Chrome(ChromeDriverManager().install())
driver.maximize_window()
driver.get('https://www.longos.com/flyers')
time.sleep(5)

iframe = driver.find_element_by_xpath('//iframe[@class="flippiframe productframe"]')
driver.switch_to.frame(iframe)
eleme = driver.find_element_by_xpath('//input[@id="postal-input"]')
eleme.send_keys("M5B0B7")
eleme = driver.find_element_by_xpath('//button[@id="submit-postal-code"]').click()
time.sleep(2)
eleme = driver.find_element_by_xpath('//button [@aria-label="Select Elizabeth 111 Elizabeth Street Toronto ON, distance from store is <1 km"]').click()
driver.switch_to.default_content()
time.sleep(5)
iframe = driver.find_element_by_xpath('//iframe[@class="flippiframe mainframe"]')
driver.switch_to.frame(iframe)
prdcts = driver.find_elements_by_xpath('//sfml-flyer-image//button')
print (prdcts)
for i in prdcts:
    driver.execute_script("arguments[0].scrollIntoView();", i)
    print(i.get_attribute("aria-label"))

    time.sleep(3)
    print(I)

and don't forget to switch back to class="flippiframe productframe"] this frame to get the product details.

the main thing is you need to switch the iframes and get into view to interact with that element


问:
Annotate with an arrow in one facet for a ggplot
I want to annotate the black dashed line with an arrow and the text "training". But the annotate function annotates all the facets. I just want the arrow in the "remembered/cen" facet only.

Here's my dataset:

```<code>data10 <- structure(list(Group = c("Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Visible", "Visible", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Visible", "Visible", "Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered"), Condition = c("CEN",
"CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN",
"CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "IPS", "IPS", "IPS",
"IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS",
"IPS", "IPS", "IPS", "IPS", "CEN", "CEN", "CEN", "CEN", "CEN",
"CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN",
"CEN", "CEN", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS",
"IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS",
"CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN",
"CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "IPS", "IPS",
"IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS",
"IPS", "IPS", "IPS", "IPS", "IPS", "CEN", "CEN", "CEN", "CEN",
"CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN",
"CEN", "CEN", "CEN", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS",
"IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS",
"IPS"), test = c("Pre-test", "Pre-test", "Pre-test", "Pre-test",
"Pre-test", "Pre-test", "Pre-test", "Pre-test", "Post-test",
"Post-test", "Post-test", "Post-test", "Post-test", "Post-test",
"Post-test", "Post-test", "Pre-test", "Pre-test", "Pre-test",
"Pre-test", "Pre-test", "Pre-test", "Pre-test", "Pre-test", "Post-test",
"Post-test", "Post-test", "Post-test", "Post-test", "Post-test",
"Post-test", "Post-test", "Pre-test", "Pre-test", "Pre-test",
"Pre-test", "Pre-test", "Pre-test", "Pre-test", "Pre-test", "Post-test",
"Post-test", "Post-test", "Post-test", "Post-test", "Post-test",
"Post-test", "Post-test", "Pre-test", "Pre-test", "Pre-test",
"Pre-test", "Pre-test", "Pre-test", "Pre-test", "Pre-test", "Post-test",
"Post-test", "Post-test", "Post-test", "Post-test", "Post-test",
"Post-test", "Post-test", "Pre-test", "Pre-test", "Pre-test",
"Pre-test", "Pre-test", "Pre-test", "Pre-test", "Pre-test", "Post-test",
"Post-test", "Post-test", "Post-test", "Post-test", "Post-test",
"Post-test", "Post-test", "Pre-test", "Pre-test", "Pre-test",
"Pre-test", "Pre-test", "Pre-test", "Pre-test", "Pre-test", "Post-test",
"Post-test", "Post-test", "Post-test", "Post-test", "Post-test",
"Post-test", "Post-test", "Pre-test", "Pre-test", "Pre-test",
"Pre-test", "Pre-test", "Pre-test", "Pre-test", "Pre-test", "Post-test",
"Post-test", "Post-test", "Post-test", "Post-test", "Post-test",
"Post-test", "Post-test", "Pre-test", "Pre-test", "Pre-test",
"Pre-test", "Pre-test", "Pre-test", "Pre-test", "Pre-test", "Post-test",
"Post-test", "Post-test", "Post-test", "Post-test", "Post-test",
"Post-test", "Post-test"), trial = c(1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2,
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16), Variables = c("Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time"), Eye_Mx = c(1.150583333, 1.273916667, 1.213083333,
1.065166667, 1.2373, 1.19925, 0.93675, 0.950833333, 0.616916667,
0.440416667, 0.598083333, 0.618583333, 0.693545455, 0.667583333,
0.873666667, 0.51825, 1.220454545, 1.034583333, 0.874583333,
1.015166667, 0.532222222, 0.714454545, 0.905583333, 0.898333333,
0.641666667, 0.787666667, 0.609833333, 0.623583333, 0.69925,
0.7188, 0.61725, 0.661166667, 1.349, 1.585416667, 1.0145, 1.201090909,
0.810545455, 0.591090909, 1.1416, 0.697166667, 0.431166667, 0.804583333,
0.289666667, 0.63875, 0.46825, 0.633, 0.418833333, 0.691166667,
1.219125, 0.7033, 0.524666667, 0.724818182, 0.648583333, 0.639181818,
0.596583333, 0.509416667, 0.576272727, 0.483222222, 0.388222222,
0.647, 0.42575, 0.269818182, 0.488333333, 0.5903, 1.869083333,
2.066181818, 2.124166667, 2.31525, 2.0943, 1.93625, 1.786916667,
1.922583333, 1.470833333, 1.421454545, 1.519083333, 1.508833333,
1.575909091, 1.5135, 1.8025, 1.541, 1.800454545, 1.888666667,
1.85575, 2.201666667, 1.55725, 1.7781, 1.748, 1.767583333, 1.489333333,
1.4259, 1.436916667, 1.5855, 1.535666667, 1.4013, 1.3855, 1.356666667,
1.852888889, 2.463636364, 2.031, 2.195727273, 1.804454545, 1.709090909,
2.1938, 1.97625, 1.256833333, 1.704363636, 1.418083333, 1.371166667,
1.459166667, 1.46725, 1.183666667, 1.407, 2.348625, 1.8981, 1.973583333,
1.746727273, 1.6805, 1.963, 1.68075, 1.872583333, 1.345636364,
1.339222222, 1.311222222, 1.316833333, 1.215833333, 1.053636364,
1.415916667, 1.2292), sd = c(0.948671172, 0.678775831, 0.820965004,
0.771358286, 1.11350558, 0.598444974, 0.794668727, 0.824723627,
0.481933503, 0.314103185, 0.469586754, 0.576648697, 0.629203681,
0.528873667, 0.975212642, 0.406696922, 0.986302019, 0.821480975,
0.776634401, 0.804389643, 0.52690957, 0.881839936, 0.881676756,
0.842954149, 0.49820502, 0.551171205, 0.611370269, 0.630794947,
0.605911653, 0.612136659, 0.504005614, 0.478993231, 0.896792758,
1.545713396, 1.479810742, 1.481512366, 1.016337185, 0.827241616,
1.987092303, 0.874371549, 0.557526165, 1.312183015, 0.163762763,
1.081580084, 0.682258832, 0.99675364, 0.582176455, 1.069035235,
1.352635886, 1.003522136, 0.705413397, 0.93395362, 0.764277848,
0.989686599, 0.875251492, 0.582424316, 0.618786084, 0.971365119,
0.4453251, 1.057255968, 0.710771044, 0.157439397, 0.584064339,
0.966582301, 0.807429305, 0.578682092, 0.911954428, 1.146678771,
0.977409848, 0.7173858, 0.692368328, 0.84760684, 0.426626052,
0.392027133, 0.463031406, 0.346331904, 0.435984278, 0.625301164,
0.733525794, 0.468399014, 0.911551574, 0.845252338, 0.560227896,
1.191183013, 0.503701088, 0.686482249, 0.812501692, 0.649220856,
0.448065201, 0.520082782, 0.465629478, 0.601450142, 0.498518229,
0.432112652, 0.422273393, 0.374147354, 0.631002663, 1.659917846,
1.024954525, 1.202822771, 0.652806306, 0.768222032, 1.742846509,
0.782477781, 0.398411581, 0.98639944, 0.580826286, 0.781519247,
0.683742619, 0.717473487, 0.26632937, 0.748351886, 1.884740371,
0.875399141, 0.661320505, 0.703044393, 0.49535084, 0.954243365,
0.645801986, 1.293963499, 0.649359573, 0.623769945, 0.256283426,
0.8611224, 0.495113363, 0.158687285, 0.522609442, 0.635988959
), se = c(0.273857778, 0.195945704, 0.236992183, 0.222671957,
0.352121382, 0.172756183, 0.229401102, 0.238077204, 0.139122219,
0.090673779, 0.135558019, 0.16646414, 0.189712048, 0.152672677,
0.281519641, 0.117403289, 0.297381248, 0.237141131, 0.22419504,
0.232207288, 0.175636523, 0.265884745, 0.254518156, 0.243339902,
0.143819401, 0.159109422, 0.176487395, 0.182094816, 0.174911628,
0.193574608, 0.145493889, 0.138273435, 0.298930919, 0.446209023,
0.467957245, 0.446692786, 0.306437191, 0.249422732, 0.62837376,
0.252409325, 0.160943941, 0.378794609, 0.047274238, 0.312225276,
0.19695116, 0.287737991, 0.168059866, 0.30860389, 0.478229004,
0.317341563, 0.203635307, 0.281597612, 0.220628011, 0.298401737,
0.252663342, 0.168131418, 0.186571024, 0.323788373, 0.1484417,
0.305203509, 0.205181927, 0.047469764, 0.168604852, 0.305660162,
0.233084763, 0.174479216, 0.263258567, 0.331017649, 0.309084133,
0.207091442, 0.19986952, 0.244683019, 0.123156333, 0.118200628,
0.133665654, 0.099977409, 0.131454206, 0.180508898, 0.211750657,
0.135215148, 0.274843141, 0.244003332, 0.161723863, 0.343864917,
0.178085227, 0.217084748, 0.244978478, 0.187413918, 0.129345282,
0.164464616, 0.134415652, 0.173623701, 0.143909817, 0.136646019,
0.121899828, 0.108007038, 0.210334221, 0.500484062, 0.32411908,
0.362664711, 0.196828507, 0.231627658, 0.551136458, 0.225881879,
0.115011517, 0.297410621, 0.167670106, 0.225605174, 0.197379493,
0.207116755, 0.076882667, 0.216030581, 0.666356349, 0.276825515,
0.190906786, 0.21197586, 0.14299547, 0.2877152, 0.186426975,
0.373535087, 0.195789278, 0.207923315, 0.085427809, 0.248584625,
0.142926917, 0.047846017, 0.150864351, 0.201117368), ci = c(0.602756906,
0.431273588, 0.521616278, 0.490097673, 0.796553907, 0.380233796,
0.504908421, 0.524004393, 0.306205939, 0.199571642, 0.298361189,
0.366385102, 0.422704785, 0.336030297, 0.619620551, 0.258402896,
0.662606712, 0.52194411, 0.493449956, 0.511084796, 0.405018549,
0.59242813, 0.560190685, 0.535587514, 0.316544368, 0.350197476,
0.388446137, 0.400787988, 0.384977898, 0.437896186, 0.320229889,
0.304337779, 0.689335936, 0.982099437, 1.058592834, 0.99529355,
0.682784611, 0.555748479, 1.421480202, 0.555549178, 0.354235225,
0.833721312, 0.104049895, 0.6872032, 0.433486581, 0.633307048,
0.369897272, 0.679232583, 1.1308319, 0.71787649, 0.448198289,
0.627438579, 0.485598977, 0.664880504, 0.556108267, 0.370054755,
0.415706148, 0.746657327, 0.342307174, 0.671748394, 0.451602376,
0.105769226, 0.371096776, 0.691451324, 0.513016105, 0.388763919,
0.5794282, 0.728564932, 0.699196885, 0.455805192, 0.439909848,
0.538543693, 0.271065261, 0.263367411, 0.29419612, 0.220048794,
0.292898224, 0.397297405, 0.466060055, 0.297606535, 0.61238868,
0.537047714, 0.355951823, 0.756841578, 0.421104648, 0.491079817,
0.545846064, 0.412495252, 0.284687047, 0.37204481, 0.295846856,
0.382143188, 0.316743371, 0.30911477, 0.268299713, 0.237721887,
0.485031584, 1.115147982, 0.733208298, 0.808067333, 0.438561244,
0.516098584, 1.246757287, 0.497162663, 0.253138642, 0.66267216,
0.369039416, 0.49655364, 0.434429334, 0.455860905, 0.169217609,
0.475480104, 1.575682382, 0.626222821, 0.420183003, 0.47231165,
0.314730908, 0.641069416, 0.410323006, 0.822145184, 0.436245697,
0.479472024, 0.19699688, 0.54713107, 0.314580023, 0.106607569,
0.332050198, 0.454959094)), class = c("spec_tbl_df", "tbl_df",
"tbl", "data.frame"), row.names = c(NA, -128L), spec = structure(list(
    cols = list(Group = structure(list(), class = c("collector_character",
    "collector")), Condition = structure(list(), class = c("collector_character",
    "collector")), test = structure(list(), class = c("collector_character",
    "collector")), trial = structure(list(), class = c("collector_double",
    "collector")), Variables = structure(list(), class = c("collector_character",
    "collector")), Eye_Mx = structure(list(), class = c("collector_double",
    "collector")), sd = structure(list(), class = c("collector_double",
    "collector")), se = structure(list(), class = c("collector_double",
    "collector")), ci = structure(list(), class = c("collector_double",
    "collector"))), default = structure(list(), class = c("collector_guess",
    "collector")), skip = 1), class = "col_spec"))
</code>```

And here's my ggplot codes:

```<code>p <- ggplot(data10, aes(x = trial, y = Eye_Mx)) +
   geom_line(aes(color = Variables, linetype = Variables), lwd=1.2) +
   scale_color_manual(values = c("darkred", "steelblue")) + facet_grid(Condition ~ Group)+ theme_bw() + xlab("Trial Pre- / Post-test") + ylab("Hand and Eye Movement time (s)") +
   scale_x_continuous(limits = c(1,16), breaks = seq(1,16,1)) + theme(axis.text.x = element_text(size = 10,face="bold", angle = 90),#, angle = 10, hjust = .5, vjust = .5),
                                                                      axis.text.y = element_text(size = 10, face = "bold"),
                                                                      axis.title.y = element_text(vjust= 1.8, size = 16),
                                                                      axis.title.x = element_text(vjust= -0.5, size = 16),
                                                                      axis.title = element_text(face = "bold")) +  theme(legend.position="top")+
   geom_vline(xintercept=8.5, linetype="dashed", color = "black", size=1.5)

 p + guides(fill=guide_legend(title="Variables:")) + theme(legend.text=element_text(size=14),legend.title=element_text(size=14) ) +
   theme(strip.text = element_text(face="bold", size=12)) + annotate("segment", x = 11, xend = 9, y = 4, yend = 3, colour = "black", size=1, alpha=0.9, arrow=arrow())

</code>```

答:
You can create an additional dataframe (e.g. arrowdf) which includes the Condition and Group that you would like to annotate. I also grouped all of your theme() arguments so that they are more clear.

```<code>arrowdf <- tibble(Condition = "CEN", Group = "Remembered")

ggplot(data10, aes(x = trial, y = Eye_Mx)) +
  geom_line(aes(color = Variables, linetype = Variables), lwd=1.2) +
  scale_color_manual(values = c("darkred", "steelblue")) +
  facet_grid(Condition ~ Group)+
  theme_bw() +
  xlab("Trial Pre- / Post-test") +
  ylab("Hand and Eye Movement time (s)") +
  scale_x_continuous(limits = c(1,16), breaks = seq(1,16,1)) +
  theme(axis.text.x = element_text(size = 10,face="bold", angle = 90),
        axis.text.y = element_text(size = 10, face = "bold"),
        axis.title.y = element_text(vjust= 1.8, size = 16),
        axis.title.x = element_text(vjust= -0.5, size = 16),
        axis.title = element_text(face = "bold"),
        legend.text=element_text(size=14),
        legend.title=element_text(size=14),
        strip.text = element_text(face="bold", size=12),
        legend.position="top")+
  geom_vline(xintercept=8.5, linetype="dashed", color = "black", size=1.5) +
  guides(fill=guide_legend(title="Variables:")) +
  geom_segment(data = arrowdf,
               aes(x = 11, xend = 9, y = 4, yend = 3),
               colour = "black", size = 1, alpha=0.9, arrow = arrow())
</code>```

Body:
I want to annotate the black dashed line with an arrow and the text "training". But the annotate function annotates all the facets. I just want the arrow in the "remembered/cen" facet only.

Here's my dataset:

data10 <- structure(list(Group = c("Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Visible", "Visible", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Visible", "Visible", "Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Visible", "Visible", "Visible", "Visible",
"Visible", "Visible", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered", "Remembered",
"Remembered", "Remembered", "Remembered", "Remembered"), Condition = c("CEN",
"CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN",
"CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "IPS", "IPS", "IPS",
"IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS",
"IPS", "IPS", "IPS", "IPS", "CEN", "CEN", "CEN", "CEN", "CEN",
"CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN",
"CEN", "CEN", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS",
"IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS",
"CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN",
"CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "IPS", "IPS",
"IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS",
"IPS", "IPS", "IPS", "IPS", "IPS", "CEN", "CEN", "CEN", "CEN",
"CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN", "CEN",
"CEN", "CEN", "CEN", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS",
"IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS", "IPS",
"IPS"), test = c("Pre-test", "Pre-test", "Pre-test", "Pre-test",
"Pre-test", "Pre-test", "Pre-test", "Pre-test", "Post-test",
"Post-test", "Post-test", "Post-test", "Post-test", "Post-test",
"Post-test", "Post-test", "Pre-test", "Pre-test", "Pre-test",
"Pre-test", "Pre-test", "Pre-test", "Pre-test", "Pre-test", "Post-test",
"Post-test", "Post-test", "Post-test", "Post-test", "Post-test",
"Post-test", "Post-test", "Pre-test", "Pre-test", "Pre-test",
"Pre-test", "Pre-test", "Pre-test", "Pre-test", "Pre-test", "Post-test",
"Post-test", "Post-test", "Post-test", "Post-test", "Post-test",
"Post-test", "Post-test", "Pre-test", "Pre-test", "Pre-test",
"Pre-test", "Pre-test", "Pre-test", "Pre-test", "Pre-test", "Post-test",
"Post-test", "Post-test", "Post-test", "Post-test", "Post-test",
"Post-test", "Post-test", "Pre-test", "Pre-test", "Pre-test",
"Pre-test", "Pre-test", "Pre-test", "Pre-test", "Pre-test", "Post-test",
"Post-test", "Post-test", "Post-test", "Post-test", "Post-test",
"Post-test", "Post-test", "Pre-test", "Pre-test", "Pre-test",
"Pre-test", "Pre-test", "Pre-test", "Pre-test", "Pre-test", "Post-test",
"Post-test", "Post-test", "Post-test", "Post-test", "Post-test",
"Post-test", "Post-test", "Pre-test", "Pre-test", "Pre-test",
"Pre-test", "Pre-test", "Pre-test", "Pre-test", "Pre-test", "Post-test",
"Post-test", "Post-test", "Post-test", "Post-test", "Post-test",
"Post-test", "Post-test", "Pre-test", "Pre-test", "Pre-test",
"Pre-test", "Pre-test", "Pre-test", "Pre-test", "Pre-test", "Post-test",
"Post-test", "Post-test", "Post-test", "Post-test", "Post-test",
"Post-test", "Post-test"), trial = c(1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2,
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16), Variables = c("Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Eye movement time", "Eye movement time", "Eye movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time", "Hand movement time", "Hand movement time",
"Hand movement time"), Eye_Mx = c(1.150583333, 1.273916667, 1.213083333,
1.065166667, 1.2373, 1.19925, 0.93675, 0.950833333, 0.616916667,
0.440416667, 0.598083333, 0.618583333, 0.693545455, 0.667583333,
0.873666667, 0.51825, 1.220454545, 1.034583333, 0.874583333,
1.015166667, 0.532222222, 0.714454545, 0.905583333, 0.898333333,
0.641666667, 0.787666667, 0.609833333, 0.623583333, 0.69925,
0.7188, 0.61725, 0.661166667, 1.349, 1.585416667, 1.0145, 1.201090909,
0.810545455, 0.591090909, 1.1416, 0.697166667, 0.431166667, 0.804583333,
0.289666667, 0.63875, 0.46825, 0.633, 0.418833333, 0.691166667,
1.219125, 0.7033, 0.524666667, 0.724818182, 0.648583333, 0.639181818,
0.596583333, 0.509416667, 0.576272727, 0.483222222, 0.388222222,
0.647, 0.42575, 0.269818182, 0.488333333, 0.5903, 1.869083333,
2.066181818, 2.124166667, 2.31525, 2.0943, 1.93625, 1.786916667,
1.922583333, 1.470833333, 1.421454545, 1.519083333, 1.508833333,
1.575909091, 1.5135, 1.8025, 1.541, 1.800454545, 1.888666667,
1.85575, 2.201666667, 1.55725, 1.7781, 1.748, 1.767583333, 1.489333333,
1.4259, 1.436916667, 1.5855, 1.535666667, 1.4013, 1.3855, 1.356666667,
1.852888889, 2.463636364, 2.031, 2.195727273, 1.804454545, 1.709090909,
2.1938, 1.97625, 1.256833333, 1.704363636, 1.418083333, 1.371166667,
1.459166667, 1.46725, 1.183666667, 1.407, 2.348625, 1.8981, 1.973583333,
1.746727273, 1.6805, 1.963, 1.68075, 1.872583333, 1.345636364,
1.339222222, 1.311222222, 1.316833333, 1.215833333, 1.053636364,
1.415916667, 1.2292), sd = c(0.948671172, 0.678775831, 0.820965004,
0.771358286, 1.11350558, 0.598444974, 0.794668727, 0.824723627,
0.481933503, 0.314103185, 0.469586754, 0.576648697, 0.629203681,
0.528873667, 0.975212642, 0.406696922, 0.986302019, 0.821480975,
0.776634401, 0.804389643, 0.52690957, 0.881839936, 0.881676756,
0.842954149, 0.49820502, 0.551171205, 0.611370269, 0.630794947,
0.605911653, 0.612136659, 0.504005614, 0.478993231, 0.896792758,
1.545713396, 1.479810742, 1.481512366, 1.016337185, 0.827241616,
1.987092303, 0.874371549, 0.557526165, 1.312183015, 0.163762763,
1.081580084, 0.682258832, 0.99675364, 0.582176455, 1.069035235,
1.352635886, 1.003522136, 0.705413397, 0.93395362, 0.764277848,
0.989686599, 0.875251492, 0.582424316, 0.618786084, 0.971365119,
0.4453251, 1.057255968, 0.710771044, 0.157439397, 0.584064339,
0.966582301, 0.807429305, 0.578682092, 0.911954428, 1.146678771,
0.977409848, 0.7173858, 0.692368328, 0.84760684, 0.426626052,
0.392027133, 0.463031406, 0.346331904, 0.435984278, 0.625301164,
0.733525794, 0.468399014, 0.911551574, 0.845252338, 0.560227896,
1.191183013, 0.503701088, 0.686482249, 0.812501692, 0.649220856,
0.448065201, 0.520082782, 0.465629478, 0.601450142, 0.498518229,
0.432112652, 0.422273393, 0.374147354, 0.631002663, 1.659917846,
1.024954525, 1.202822771, 0.652806306, 0.768222032, 1.742846509,
0.782477781, 0.398411581, 0.98639944, 0.580826286, 0.781519247,
0.683742619, 0.717473487, 0.26632937, 0.748351886, 1.884740371,
0.875399141, 0.661320505, 0.703044393, 0.49535084, 0.954243365,
0.645801986, 1.293963499, 0.649359573, 0.623769945, 0.256283426,
0.8611224, 0.495113363, 0.158687285, 0.522609442, 0.635988959
), se = c(0.273857778, 0.195945704, 0.236992183, 0.222671957,
0.352121382, 0.172756183, 0.229401102, 0.238077204, 0.139122219,
0.090673779, 0.135558019, 0.16646414, 0.189712048, 0.152672677,
0.281519641, 0.117403289, 0.297381248, 0.237141131, 0.22419504,
0.232207288, 0.175636523, 0.265884745, 0.254518156, 0.243339902,
0.143819401, 0.159109422, 0.176487395, 0.182094816, 0.174911628,
0.193574608, 0.145493889, 0.138273435, 0.298930919, 0.446209023,
0.467957245, 0.446692786, 0.306437191, 0.249422732, 0.62837376,
0.252409325, 0.160943941, 0.378794609, 0.047274238, 0.312225276,
0.19695116, 0.287737991, 0.168059866, 0.30860389, 0.478229004,
0.317341563, 0.203635307, 0.281597612, 0.220628011, 0.298401737,
0.252663342, 0.168131418, 0.186571024, 0.323788373, 0.1484417,
0.305203509, 0.205181927, 0.047469764, 0.168604852, 0.305660162,
0.233084763, 0.174479216, 0.263258567, 0.331017649, 0.309084133,
0.207091442, 0.19986952, 0.244683019, 0.123156333, 0.118200628,
0.133665654, 0.099977409, 0.131454206, 0.180508898, 0.211750657,
0.135215148, 0.274843141, 0.244003332, 0.161723863, 0.343864917,
0.178085227, 0.217084748, 0.244978478, 0.187413918, 0.129345282,
0.164464616, 0.134415652, 0.173623701, 0.143909817, 0.136646019,
0.121899828, 0.108007038, 0.210334221, 0.500484062, 0.32411908,
0.362664711, 0.196828507, 0.231627658, 0.551136458, 0.225881879,
0.115011517, 0.297410621, 0.167670106, 0.225605174, 0.197379493,
0.207116755, 0.076882667, 0.216030581, 0.666356349, 0.276825515,
0.190906786, 0.21197586, 0.14299547, 0.2877152, 0.186426975,
0.373535087, 0.195789278, 0.207923315, 0.085427809, 0.248584625,
0.142926917, 0.047846017, 0.150864351, 0.201117368), ci = c(0.602756906,
0.431273588, 0.521616278, 0.490097673, 0.796553907, 0.380233796,
0.504908421, 0.524004393, 0.306205939, 0.199571642, 0.298361189,
0.366385102, 0.422704785, 0.336030297, 0.619620551, 0.258402896,
0.662606712, 0.52194411, 0.493449956, 0.511084796, 0.405018549,
0.59242813, 0.560190685, 0.535587514, 0.316544368, 0.350197476,
0.388446137, 0.400787988, 0.384977898, 0.437896186, 0.320229889,
0.304337779, 0.689335936, 0.982099437, 1.058592834, 0.99529355,
0.682784611, 0.555748479, 1.421480202, 0.555549178, 0.354235225,
0.833721312, 0.104049895, 0.6872032, 0.433486581, 0.633307048,
0.369897272, 0.679232583, 1.1308319, 0.71787649, 0.448198289,
0.627438579, 0.485598977, 0.664880504, 0.556108267, 0.370054755,
0.415706148, 0.746657327, 0.342307174, 0.671748394, 0.451602376,
0.105769226, 0.371096776, 0.691451324, 0.513016105, 0.388763919,
0.5794282, 0.728564932, 0.699196885, 0.455805192, 0.439909848,
0.538543693, 0.271065261, 0.263367411, 0.29419612, 0.220048794,
0.292898224, 0.397297405, 0.466060055, 0.297606535, 0.61238868,
0.537047714, 0.355951823, 0.756841578, 0.421104648, 0.491079817,
0.545846064, 0.412495252, 0.284687047, 0.37204481, 0.295846856,
0.382143188, 0.316743371, 0.30911477, 0.268299713, 0.237721887,
0.485031584, 1.115147982, 0.733208298, 0.808067333, 0.438561244,
0.516098584, 1.246757287, 0.497162663, 0.253138642, 0.66267216,
0.369039416, 0.49655364, 0.434429334, 0.455860905, 0.169217609,
0.475480104, 1.575682382, 0.626222821, 0.420183003, 0.47231165,
0.314730908, 0.641069416, 0.410323006, 0.822145184, 0.436245697,
0.479472024, 0.19699688, 0.54713107, 0.314580023, 0.106607569,
0.332050198, 0.454959094)), class = c("spec_tbl_df", "tbl_df",
"tbl", "data.frame"), row.names = c(NA, -128L), spec = structure(list(
    cols = list(Group = structure(list(), class = c("collector_character",
    "collector")), Condition = structure(list(), class = c("collector_character",
    "collector")), test = structure(list(), class = c("collector_character",
    "collector")), trial = structure(list(), class = c("collector_double",
    "collector")), Variables = structure(list(), class = c("collector_character",
    "collector")), Eye_Mx = structure(list(), class = c("collector_double",
    "collector")), sd = structure(list(), class = c("collector_double",
    "collector")), se = structure(list(), class = c("collector_double",
    "collector")), ci = structure(list(), class = c("collector_double",
    "collector"))), default = structure(list(), class = c("collector_guess",
    "collector")), skip = 1), class = "col_spec"))

And here's my ggplot codes:

p <- ggplot(data10, aes(x = trial, y = Eye_Mx)) +
   geom_line(aes(color = Variables, linetype = Variables), lwd=1.2) +
   scale_color_manual(values = c("darkred", "steelblue")) + facet_grid(Condition ~ Group)+ theme_bw() + xlab("Trial Pre- / Post-test") + ylab("Hand and Eye Movement time (s)") +
   scale_x_continuous(limits = c(1,16), breaks = seq(1,16,1)) + theme(axis.text.x = element_text(size = 10,face="bold", angle = 90),#, angle = 10, hjust = .5, vjust = .5),
                                                                      axis.text.y = element_text(size = 10, face = "bold"),
                                                                      axis.title.y = element_text(vjust= 1.8, size = 16),
                                                                      axis.title.x = element_text(vjust= -0.5, size = 16),
                                                                      axis.title = element_text(face = "bold")) +  theme(legend.position="top")+
   geom_vline(xintercept=8.5, linetype="dashed", color = "black", size=1.5)

 p + guides(fill=guide_legend(title="Variables:")) + theme(legend.text=element_text(size=14),legend.title=element_text(size=14) ) +
   theme(strip.text = element_text(face="bold", size=12)) + annotate("segment", x = 11, xend = 9, y = 4, yend = 3, colour = "black", size=1, alpha=0.9, arrow=arrow())

Body:
You can create an additional dataframe (e.g. arrowdf) which includes the Condition and Group that you would like to annotate. I also grouped all of your theme() arguments so that they are more clear.

arrowdf <- tibble(Condition = "CEN", Group = "Remembered")

ggplot(data10, aes(x = trial, y = Eye_Mx)) +
  geom_line(aes(color = Variables, linetype = Variables), lwd=1.2) +
  scale_color_manual(values = c("darkred", "steelblue")) +
  facet_grid(Condition ~ Group)+
  theme_bw() +
  xlab("Trial Pre- / Post-test") +
  ylab("Hand and Eye Movement time (s)") +
  scale_x_continuous(limits = c(1,16), breaks = seq(1,16,1)) +
  theme(axis.text.x = element_text(size = 10,face="bold", angle = 90),
        axis.text.y = element_text(size = 10, face = "bold"),
        axis.title.y = element_text(vjust= 1.8, size = 16),
        axis.title.x = element_text(vjust= -0.5, size = 16),
        axis.title = element_text(face = "bold"),
        legend.text=element_text(size=14),
        legend.title=element_text(size=14),
        strip.text = element_text(face="bold", size=12),
        legend.position="top")+
  geom_vline(xintercept=8.5, linetype="dashed", color = "black", size=1.5) +
  guides(fill=guide_legend(title="Variables:")) +
  geom_segment(data = arrowdf,
               aes(x = 11, xend = 9, y = 4, yend = 3),
               colour = "black", size = 1, alpha=0.9, arrow = arrow())


问:
View is not rerendering, not sure why
I have a ScoreView that keeps track of the current score, but I am having trouble getting it to re-render when a model attribute changes.
Here is what the view looks like:

```<code>  var ScoreView = Backbone.View.extend({

    initialize: function() {
      _.bindAll(this, 'render');

      this.model.bind("change", function() {
        if (this.hasChanged("score")) {
          alert("score has changed");
          this.render;
        }
      });
    },

    render: function() {
      alert("drawing new score");
      return this.model.get("score");
    },

  });
</code>```

When the score changes, the view does not re-render. I do get the alert, "score has changed", when the score changes. When I print out the contents of "this.render", the console says that the function is undefined. I think that the code thinks that the "this" in this context is the model, but I want the context to be the view. How would I fix this?

答:
I believe the problem is that you are using 'this' in the anonymous function inside of your bind.  You should maybe try this:</p>

```<code>  var self = this;
  this.model.bind("change", function() {
    if (this.hasChanged("score")) {
      alert("score has changed");
      self.render;
    }
  });
</code>```

ContentLicense: CC BY-SA 3.0

Title: View is not rerendering, not sure why

Body:
I have a ScoreView that keeps track of the current score, but I am having trouble getting it to re-render when a model attribute changes.
Here is what the view looks like:

  var ScoreView = Backbone.View.extend({

    initialize: function() {
      _.bindAll(this, 'render');

      this.model.bind("change", function() {
        if (this.hasChanged("score")) {
          alert("score has changed");
          this.render;
        }
      });
    },

    render: function() {
      alert("drawing new score");
      return this.model.get("score");
    },

  });

When the score changes, the view does not re-render. I do get the alert, "score has changed", when the score changes. When I print out the contents of "this.render", the console says that the function is undefined. I think that the code thinks that the "this" in this context is the model, but I want the context to be the view. How would I fix this?

Body:
I believe the problem is that you are using 'this' in the anonymous function inside of your bind.  You should maybe try this:

  var self = this;
  this.model.bind("change", function() {
    if (this.hasChanged("score")) {
      alert("score has changed");
      self.render;
    }
  });


问:
How to solve Avoided redundant navigation to current location error in vue?
I am new in vue and i got the error after user logged in and redirect to another route.
Basically i am a PHP developer and i use laravel with vue. Please help me to solve this error.

Uncaught (in promise) Error: Avoided redundant navigation to current location: "/admin".

Here is the screenshot too

Vue Code

```<code> methods: {
        loginUser() {
            var data = {
                email: this.userData.email,
                password: this.userData.password
            };
            this.app.req.post("api/auth/authenticate", data).then(res => {
                const token = res.data.token;
                sessionStorage.setItem("chatbot_token", token);
                this.$router.push("/admin");
            });
        }
    }
</code>```

Vue Routes

```<code>const routes = [
    {
        path: "/admin",
        component: Navbar,
        name: "navbar",
        meta: {
            authGuard: true
        },
        children: [
            {
                path: "",
                component: Dashboard,
                name: "dashboard"
            },
            {
                path: "users",
                component: Users,
                name: "user"
            }
        ]
    },
    {
        path: "/login",
        component: Login,
        name: "login"
    }
];

const router = new VueRouter({
    routes,
    mode: "history"
});

router.beforeEach((to, from, next) => {
    const loggedInUserDetail = !!sessionStorage.getItem("chatbot_token");
    if (to.matched.some(m => m.meta.authGuard) && !loggedInUserDetail)
        next({ name: "login" });
    else next();
});

</code>```

答:
you can add a random query parameter to push object like this:</p>
```<code> this.$router.push({path : "/admin", query : { time : Date.now()}  });
</code>```

Body:
I am new in vue and i got the error after user logged in and redirect to another route.
Basically i am a PHP developer and i use laravel with vue. Please help me to solve this error.

Uncaught (in promise) Error: Avoided redundant navigation to current location: "/admin".

Here is the screenshot too

Vue Code

 methods: {
        loginUser() {
            var data = {
                email: this.userData.email,
                password: this.userData.password
            };
            this.app.req.post("api/auth/authenticate", data).then(res => {
                const token = res.data.token;
                sessionStorage.setItem("chatbot_token", token);
                this.$router.push("/admin");
            });
        }
    }

Vue Routes

const routes = [
    {
        path: "/admin",
        component: Navbar,
        name: "navbar",
        meta: {
            authGuard: true
        },
        children: [
            {
                path: "",
                component: Dashboard,
                name: "dashboard"
            },
            {
                path: "users",
                component: Users,
                name: "user"
            }
        ]
    },
    {
        path: "/login",
        component: Login,
        name: "login"
    }
];

const router = new VueRouter({
    routes,
    mode: "history"
});

router.beforeEach((to, from, next) => {
    const loggedInUserDetail = !!sessionStorage.getItem("chatbot_token");
    if (to.matched.some(m => m.meta.authGuard) && !loggedInUserDetail)
        next({ name: "login" });
    else next();
});

Body:
you can add a random query parameter to push object like this:

 this.$router.push({path : "/admin", query : { time : Date.now()}  });


问:
AWS Quicksight - One graph/line for each ID and its values
My data set in Quicksight looks something like this, with the following columns:

Person

Account Balance

Date

Is there a way to plot the balance over time, for each person? I am looking for something like a line chart for each person.

I am not very keen on modifying my data set to contain a column for each person, e.g. create Person1Balance, Person2Balance as there are a lot of persons.

The filters in Quicksight does not seem very fitting either, since I would have to click through each person individually. Furthermore, I would not be able to see any number of values next to each other.

To me it seems as though Quicksight is built more for making aggregates and perform actions on the data. However, I am looking for a way to visualize and analyze my AWS data.

To get an idea of the visualization I am looking for I have attached is an image of a Grafana page containing Covid-19 statistics over time for some countries.
Thankful for any help, stay safe.

答:
I was able to create similar line graph by setting:

X axis as Date

Value as Sum(Balance)

Color as Person

and I get this nice graph.

Is this what you are looking for?

My datasource is a simple XLS with 3 columns as described in your question.


问:
PL/pgSQL How To Create Test Query To Test Function
I create a function that returns TEXT, end  I'm trying to create a simple query to test this function.
the query while looks like this:

```<code>CREATE  TEMP TABLE function_test(actuel TEXT,expected TEXT,t_result TEXT);
/* the t_result should be'passed' if function(actuel) = expected */
INSERT INTO
    function_test(actuel ,expected);
VALUES
    ('a','A'),/*function(`a`) return 'A'*/
    ('b','B'),/*function(`b`) return 'B'*/
    ('c','C');/*function(`c`) return 'C'*/
IF function(actuel)=expected THEN
    INSERT INTO
    function_test(t_result) VALUES 'passed' ;
ELSE
    INSERT INTO
    function_test(t_result) VALUES 'failed';
SELECT * FROM function_test;
DROP TABLE function_test;
</code>```

Output
It would be nice if I could do it better than this.
thinks.

答:
Not entirely sure I understand what you are asking, but could you not just do either

```<code>select MY_FUNCTION('a','A') from dual;
</code>```

or if you need a row on success and no row on failure

```<code>select 'PASS' from dual
where MY_FUNCTION('a','A') = 'YES'
</code>```

DUAL is a 1 one row table that exists in every Oracle database.

Body:
I create a function that returns TEXT, end  I'm trying to create a simple query to test this function.
the query while looks like this:

CREATE  TEMP TABLE function_test(actuel TEXT,expected TEXT,t_result TEXT);
/* the t_result should be'passed' if function(actuel) = expected */
INSERT INTO
    function_test(actuel ,expected);
VALUES
    ('a','A'),/*function(`a`) return 'A'*/
    ('b','B'),/*function(`b`) return 'B'*/
    ('c','C');/*function(`c`) return 'C'*/
IF function(actuel)=expected THEN
    INSERT INTO
    function_test(t_result) VALUES 'passed' ;
ELSE
    INSERT INTO
    function_test(t_result) VALUES 'failed';
SELECT * FROM function_test;
DROP TABLE function_test;

Output
It would be nice if I could do it better than this.
thinks.

Body:
Not entirely sure I understand what you are asking, but could you not just do either

select MY_FUNCTION('a','A') from dual;

or if you need a row on success and no row on failure

select 'PASS' from dual
where MY_FUNCTION('a','A') = 'YES'

DUAL is a 1 one row table that exists in every Oracle database.


问:
How to create the data into database using laravel
I want to do the registration form and insert the details into two tables which are the company table and the people table. I face the problems here:

How can I get the comp_id and add it into my master_id? The comp_id is AUTO_INCREMENT from PHPMYADMIN.

How to add the people_id into the company table after the people table is created?

company table
| comp_id| people_id| master_id|
|:---- |:------:| -----:|
| 7| 112| 7|
| 8| 113| 8|

people table
| people_id| office_id| username|
|:---- |:------:| -----:|
| 112| 7| person A|
| 113| 8| person B|

Here is my code, but there is an error and it is unable to create the database.

```<code>protected function create(array $data)
    {
  $company = Company::create([
        'people_id' => '["'.$people->person_id.'"]',
        'master_id' => $company->company_id,
    ]);

    $people = Person::create([
       'username' => $data['name'],
       'office_id' => $company->comp_id,
     ]);
}

</code>```

Does anyone know how to solve it?

答:
```<code>protected function create(array $data)
{
  $company = Company::create([
    'master_id' => $company->company_id,
  ]);

 $people = Person::create([
   'username' => $data['name'],
   'office_id' => $company->comp_id,
 ]);

 $company->people_id = $people->person_id;
 $company->save();
</code>```
<p>}</p>

Body:
I want to do the registration form and insert the details into two tables which are the company table and the people table. I face the problems here:

How can I get the comp_id and add it into my master_id? The comp_id is AUTO_INCREMENT from PHPMYADMIN.

How to add the people_id into the company table after the people table is created?

company table
| comp_id| people_id| master_id|
|:---- |:------:| -----:|
| 7| 112| 7|
| 8| 113| 8|

people table
| people_id| office_id| username|
|:---- |:------:| -----:|
| 112| 7| person A|
| 113| 8| person B|

Here is my code, but there is an error and it is unable to create the database.

protected function create(array $data)
    {
  $company = Company::create([
        'people_id' => '["'.$people->person_id.'"]',
        'master_id' => $company->company_id,
    ]);

    $people = Person::create([
       'username' => $data['name'],
       'office_id' => $company->comp_id,
     ]);
}

Does anyone know how to solve it?

Body:
protected function create(array $data)
{
  $company = Company::create([
    'master_id' => $company->company_id,
  ]);

 $people = Person::create([
   'username' => $data['name'],
   'office_id' => $company->comp_id,
 ]);

 $company->people_id = $people->person_id;
 $company->save();

}


问:
Apache server running on PHP ver. 8.0.1 won't load React/ZMQ extension on startup
I am trying to experiment web sockets with cakephp ver 4. My server is WAMP 3.2.6 x64 running on Win 10 and PHP 8.1.0 set as preferred engine version. It turns out that zmq-extension has to be enabled in php.ini file.
And there lies my problem: I've searched many stackoverflow solutions, that seem to have been usuful for older php and OS versions, but none seems to work for my configuration.
Is it possible that php_zmq is not fixed for running on php 8? Or, maybe WAMP 3.2.6 is to blame?
Thanks in advance for your prompt replies!</p>

答: Well, the solution for me was to downgrade php to version 7.2.34. All other attempted php versions, up to ver 8.0.1 at least, were futile.</p>


问:
ERROR when run wcf service vb on IIS express
An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior
contract: http://tempuri.org/:IService ----> System.InvalidOperationException: DataContract for type 'B2B_WCF.HttpResponse2' cannot be added to DataContractSet since type 'B2B_WCF.HttpResponse1' with the same data contract name 'HttpResponse' in namespace 'http://schemas.datacontract.org/2004/07/B2B_WCF' is already present and the contracts are not equivalent.
at System.Runtime.Serialization.DataContractSet.InternalAdd(XmlQualifiedName name, DataContract dataContract)
at System.Runtime.Serialization.DataContractSet.Add(Type type)
at System.Runtime.Serialization.XsdDataContractExporter.Export(Type type)
at System.ServiceModel.Description.MessageContractExporter.ExportType(Type type, String partName, String operationName, XmlSchemaType& xsdType)
at System.ServiceModel.Description.DataContractSerializerMessageContractExporter.ExportBody(Int32 messageIndex, Object state)
at System.ServiceModel.Description.MessageContractExporter.ExportMessage(Int32 messageIndex, Object state)
at System.ServiceModel.Description.MessageContractExporter.ExportMessageContract()
at System.ServiceModel.Description.DataContractSerializerOperationBehavior.System.ServiceModel.Description.IWsdlExportExtension.ExportContract(WsdlExporter exporter, WsdlContractConversionContext contractContext)
at System.ServiceModel.Description.WsdlExporter.CallExtension(WsdlContractConversionContext contractContext, IWsdlExportExtension extension)
--- End of inner ExceptionDetail stack trace ---
at System.ServiceModel.Description.ServiceMetadataBehavior.MetadataExtensionInitializer.GenerateMetadata()
at System.ServiceModel.Description.ServiceMetadataExtension.EnsureInitialized()
at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.InitializationData.InitializeFrom(ServiceMetadataExtension extension)
at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.GetInitData()
at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.TryHandleDocumentationRequest(Message httpGetRequest, String[] queries, Message& replyMessage)
at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.ProcessHttpRequest(Message httpGetRequest)
at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.Get(Message message)
at SyncInvokeGet(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</p>

答:
Based on the information you provided, the error is obvious.

```<code>System.InvalidOperationException: DataContract for type
'B2B_WCF.HttpResponse2' cannot be added to DataContractSet since type
'B2B_WCF.HttpResponse1' with the same data contract name 'HttpResponse' in
namespace 'http://schemas.datacontract.org/2004/07/B2B_WCF'
is already present and the contracts are not equivalent.
</code>```

As you can see from the error message, you may have two different contracts with the same name. You can try inspecting the code to merge them or change the name of one of them.

Body:
Based on the information you provided, the error is obvious.

System.InvalidOperationException: DataContract for type
'B2B_WCF.HttpResponse2' cannot be added to DataContractSet since type
'B2B_WCF.HttpResponse1' with the same data contract name 'HttpResponse' in
namespace 'http://schemas.datacontract.org/2004/07/B2B_WCF'
is already present and the contracts are not equivalent.

As you can see from the error message, you may have two different contracts with the same name. You can try inspecting the code to merge them or change the name of one of them.


问:
Auth0 - Couldn't retrieve remote JWK set: Read timed out
I'm suffering this one: Couldn't retrieve remote JWK set: Read timed out

I am using Java 11 with Spring boot 2.5.3,

for dependencies:

spring-security-oauth2-jose 5.5.1,

spring-boot-starter-oauth2-client

spring-boot-starter-security

Auth0 as users provider.

Any clue ?

```<code>...
Caused by: java.lang.IllegalStateException: com.nimbusds.jose.RemoteKeySourceException: Couldn't retrieve remote JWK set: Read timed out
    at org.springframework.security.oauth2.jwt.JwtDecoderProviderConfigurationUtils.getSignatureAlgorithms(JwtDecoderProviderConfigurationUtils.java:107) ~[spring-security-oauth2-jose-5.5.1.jar:5.5.1]
    at org.springframework.security.oauth2.jwt.ReactiveJwtDecoders.withProviderConfiguration(ReactiveJwtDecoders.java:120) ~[spring-security-oauth2-jose-5.5.1.jar:5.5.1]
    at org.springframework.security.oauth2.jwt.ReactiveJwtDecoders.fromIssuerLocation(ReactiveJwtDecoders.java:100) ~[spring-security-oauth2-jose-5.5.1.jar:5.5.1]
    at org.springframework.boot.autoconfigure.security.oauth2.resource.reactive.ReactiveOAuth2ResourceServerJwkConfiguration$JwtConfiguration.jwtDecoderByIssuerUri(ReactiveOAuth2ResourceServerJwkConfiguration.java:95) ~[spring-boot-autoconfigure-2.5.3.jar:2.5.3]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.9.jar:5.3.9]
</code>```

答:
Main difference between this answer and Juan's is that rather than hack  RemoteJWKSet I'm using DefaultResourceRetriever.  I also had to copy and paste JwtDecoderProviderConfigurationUtils as JwtUtil to gain access to the helper functions that deal with the OAuth DOM.

What a pain.

```<code>
  @Value("${auth0.audience}")
  private String audience;

  @Value("${spring.security.oauth2.resourceserver.jwt.issuer-uri}")
  private String issuer;

  @Bean
  JwtDecoder jwtDecoder(RestTemplateBuilder builder, CacheManager cacheManager) throws MalformedURLException {

    RestOperations restOperations = builder
        .setConnectTimeout(Duration.ofSeconds(60))
        .setReadTimeout(Duration.ofSeconds(60))
        .build();

    // JwtUtil is a copy and paste of JwtDecoderProviderConfigurationUtils in order to be able to
    // call a couple of functions. The Spring class is inconveniently package protected.
    Map<String, Object> configuration = JwtUtil.getConfigurationForIssuerLocation(issuer);
    String jwkSetUri = configuration.get("jwks_uri").toString();
    RemoteJWKSet<SecurityContext> jwkSource = new RemoteJWKSet<>(new URL(jwkSetUri), new DefaultResourceRetriever());
    NimbusJwtDecoder nimbusDecoder = NimbusJwtDecoder.withJwkSetUri(jwkSetUri)
        .jwsAlgorithms((algos) -> algos.addAll(JwtUtil.getSignatureAlgorithms(jwkSource)))
        .restOperations(restOperations)
        .cache(Objects.requireNonNull(cacheManager.getCache("auth")))
        .build();

    OAuth2TokenValidator<Jwt> audienceValidator = new AudienceValidator(audience);
    OAuth2TokenValidator<Jwt> withAudience =
        new DelegatingOAuth2TokenValidator<>(JwtValidators.createDefaultWithIssuer(issuer), audienceValidator);

    nimbusDecoder.setJwtValidator(withAudience);

    return nimbusDecoder;
  }
</code>```

YAML

```<code>auth0:
  # Replace with the API Identifier for your Auth0 API.
  audience: https://myapp.eu.auth0.com/api/v2/

# The following is standard Spring Security OAuth2 configuration.
spring:
  security:
    oauth2:
      resourceserver:
        jwt:
          # Replace with the domain of your Auth0 tenant.
          # Note the trailing slash is important!
          issuer-uri: https://myapp.eu.auth0.com/

</code>```

Body:
I'm suffering this one: Couldn't retrieve remote JWK set: Read timed out

I am using Java 11 with Spring boot 2.5.3,

for dependencies:

spring-security-oauth2-jose 5.5.1,

spring-boot-starter-oauth2-client

spring-boot-starter-security

Auth0 as users provider.

Any clue ?

...
Caused by: java.lang.IllegalStateException: com.nimbusds.jose.RemoteKeySourceException: Couldn't retrieve remote JWK set: Read timed out
    at org.springframework.security.oauth2.jwt.JwtDecoderProviderConfigurationUtils.getSignatureAlgorithms(JwtDecoderProviderConfigurationUtils.java:107) ~[spring-security-oauth2-jose-5.5.1.jar:5.5.1]
    at org.springframework.security.oauth2.jwt.ReactiveJwtDecoders.withProviderConfiguration(ReactiveJwtDecoders.java:120) ~[spring-security-oauth2-jose-5.5.1.jar:5.5.1]
    at org.springframework.security.oauth2.jwt.ReactiveJwtDecoders.fromIssuerLocation(ReactiveJwtDecoders.java:100) ~[spring-security-oauth2-jose-5.5.1.jar:5.5.1]
    at org.springframework.boot.autoconfigure.security.oauth2.resource.reactive.ReactiveOAuth2ResourceServerJwkConfiguration$JwtConfiguration.jwtDecoderByIssuerUri(ReactiveOAuth2ResourceServerJwkConfiguration.java:95) ~[spring-boot-autoconfigure-2.5.3.jar:2.5.3]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.9.jar:5.3.9]

Body:
Main difference between this answer and Juan's is that rather than hack  RemoteJWKSet I'm using DefaultResourceRetriever.  I also had to copy and paste JwtDecoderProviderConfigurationUtils as JwtUtil to gain access to the helper functions that deal with the OAuth DOM.

What a pain.

  @Value("${auth0.audience}")
  private String audience;

  @Value("${spring.security.oauth2.resourceserver.jwt.issuer-uri}")
  private String issuer;

  @Bean
  JwtDecoder jwtDecoder(RestTemplateBuilder builder, CacheManager cacheManager) throws MalformedURLException {

    RestOperations restOperations = builder
        .setConnectTimeout(Duration.ofSeconds(60))
        .setReadTimeout(Duration.ofSeconds(60))
        .build();

    // JwtUtil is a copy and paste of JwtDecoderProviderConfigurationUtils in order to be able to
    // call a couple of functions. The Spring class is inconveniently package protected.
    Map<String, Object> configuration = JwtUtil.getConfigurationForIssuerLocation(issuer);
    String jwkSetUri = configuration.get("jwks_uri").toString();
    RemoteJWKSet<SecurityContext> jwkSource = new RemoteJWKSet<>(new URL(jwkSetUri), new DefaultResourceRetriever());
    NimbusJwtDecoder nimbusDecoder = NimbusJwtDecoder.withJwkSetUri(jwkSetUri)
        .jwsAlgorithms((algos) -> algos.addAll(JwtUtil.getSignatureAlgorithms(jwkSource)))
        .restOperations(restOperations)
        .cache(Objects.requireNonNull(cacheManager.getCache("auth")))
        .build();

    OAuth2TokenValidator<Jwt> audienceValidator = new AudienceValidator(audience);
    OAuth2TokenValidator<Jwt> withAudience =
        new DelegatingOAuth2TokenValidator<>(JwtValidators.createDefaultWithIssuer(issuer), audienceValidator);

    nimbusDecoder.setJwtValidator(withAudience);

    return nimbusDecoder;
  }

YAML

auth0:
  # Replace with the API Identifier for your Auth0 API.
  audience: https://myapp.eu.auth0.com/api/v2/

# The following is standard Spring Security OAuth2 configuration.
spring:
  security:
    oauth2:
      resourceserver:
        jwt:
          # Replace with the domain of your Auth0 tenant.
          # Note the trailing slash is important!
          issuer-uri: https://myapp.eu.auth0.com/


问:
How do I share user controls between web applications in ASP.NET?
This question is a follow up to my question about sharing resources between web applications, because I have not yet found a good solution.

I have a web application with user controls and resources that are shared by three other web applications.

```
Solution
|
+-CommonControlsWebApp
| +- resources
| |  +- images
| |  +- scripts
| |  +- stylesheets
| +- UserControls
|
+-WebApp1
|
+-WebApp2
|
+-WebApp3
```

This is what I know this far:

I can not compile CommonControlsWebApp into a single dll since I am creating user controls. This is only possible with custom server controls, where everything is in the code-behind file. So I need a way to share the ascx files between the four projects.

Copying the files from CommonControlsWebApp into the three other projects does not update their files in the solution explorer. I would have to 'add exting items' all in all three WebApps when a file is added or renamed in CommonControls.

Changing to the Web Site model would remedy this, but I am worried about the compile time for WebApp1-3 if I do this.

'Add as link' does not work for directories.

I could use Subversion to share the files between the projects, but i believe that this would require me to check the files in and out again all the time if I am developing a user control that I have to test through one of the WebApps.

Can it really be true that ASP.NET does not have a good solution for this? How are you guys organizing large web applications?

Edit: Thanks a lot for all the answers. I am going to copy my user controls with a build event for now, and then see if we have time to refactor them into server controls.

答:
hey this is not the best way to do things but i used to do this in my asp.net 1.1 days -  you can try this - shift your user controls into a seperate project, and publish this project as a virtual directory under iis

as long as you are not using codebehind - your updates would be cool (only update shared user control folder)

if you do use codebehinds - redeploy the user control dlls into different projects

once you are done with this - map these user controls into all projects using their virtual paths

check these links - http://aspadvice.com/blogs/ssmith/archive/2006/10/05/Tip_3A00_-Share-User-Controls-Between-Applications-in-ASP.NET.aspx

AND

http://www.123aspx.com/redir.aspx?res=30887

OwnerDisplayName: Jan Aagaard

ContentLicense: CC BY-SA 2.5

Body:
This question is a follow up to my question about sharing resources between web applications, because I have not yet found a good solution.

I have a web application with user controls and resources that are shared by three other web applications.

Solution
|
+-CommonControlsWebApp
| +- resources
| |  +- images
| |  +- scripts
| |  +- stylesheets
| +- UserControls
|
+-WebApp1
|
+-WebApp2
|
+-WebApp3

This is what I know this far:

I can not compile CommonControlsWebApp into a single dll since I am creating user controls. This is only possible with custom server controls, where everything is in the code-behind file. So I need a way to share the ascx files between the four projects.

Copying the files from CommonControlsWebApp into the three other projects does not update their files in the solution explorer. I would have to 'add exting items' all in all three WebApps when a file is added or renamed in CommonControls.

Changing to the Web Site model would remedy this, but I am worried about the compile time for WebApp1-3 if I do this.

'Add as link' does not work for directories.

I could use Subversion to share the files between the projects, but i believe that this would require me to check the files in and out again all the time if I am developing a user control that I have to test through one of the WebApps.

Can it really be true that ASP.NET does not have a good solution for this? How are you guys organizing large web applications?

Edit: Thanks a lot for all the answers. I am going to copy my user controls with a build event for now, and then see if we have time to refactor them into server controls.

LastEditorDisplayName: Jan Aagaard

OwnerDisplayName: Raj


问:
Obtaining current GCC exception model
g++ is built using either the DWARF2, sjlj or seh exception model.  MinGW-builds provide various builds of g++ that have different exception models.  I would like to be able to determine from the gcc toolchain what exception model is being used.  Is there a g++ argument that will dump the default exception model of the compiler?

答:
For me, finding corresponding DLL for each exception model works:

libgcc_s_dw2-1.dll (DWARF)

libgcc_s_seh-1.dll (SEH)

libgcc_s_sjlj-1.dll (SJLJ)

Reference: https://stackoverflow.com/a/19791995/16550663

Title: Obtaining current GCC exception model


问:
Microsoft teams deep link how to pass query parameters
I have created a custom bot, with yo teams generator, which is also registered in azure. In addition, I have a deeplink to this bot in order to display a task module, when clicked from teams, with html/javascript content. But I want this content to be dynamic and incject some values from my database into this content and to achieve this I must have the names of my database and my collection. Is it possible to add some query parameters into deeplink like we do in ordinary url links (e.g ?key=value), so I can query my database from the custom app?</p>

答:
deep link: teams.microsoft.com/l/task{APP_ID}?url=https://{DOMAIN}/story?name%3dhello%26last%3dworld.
So in order to be able to pass query parameters. Encode some symbols like = and & as above.Now you can grap for example the name and last variables from the above url.</p>


问:
Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' while attempting to activate
In Startup file, I am trying to inject the IHttpContextAccessor in constructor itself.

While running the API locally, IHttpContextAccessor is injected successfully in startup class. However when I am deploying the same to Azure kubernetes service, it fails and reported below exception. even pod state is crashloopbackoff.

Any suggestion how can I resolve this issue?

Here is the startup class.

```<code>public class Startup
{
    private readonly IConfiguration _configuration;
    private readonly ILogger _logger;
    private readonly IHttpContextAccessor _httpContextAccessor;

    public Startup(IConfiguration configuration, ILogger logger, IHttpContextAccessor httpContextAccessor)
    {
        _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
        _httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
        _logger.LogProcessStart();
    }
}
</code>```

Here is the exception from pod logs.

```<code>    Unhandled exception. System.InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' whileattempting to activate 'API.Startup'.
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetServiceOrCreateInstance(IServiceProvider provider, Type type)
   at Microsoft.AspNetCore.Hosting.StartupLoader.LoadMethods(IServiceProvider hostingServiceProvider, Type startupType, String environmentName)
   at Microsoft.AspNetCore.Hosting.WebHostBuilderExtensions.<>c__DisplayClass3_0.<UseStartup>b__1(IServiceProvider sp)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContextcontext, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
   at Microsoft.AspNetCore.Hosting.WebHost.EnsureStartup()
   at Microsoft.AspNetCore.Hosting.WebHost.EnsureApplicationServices()
   at Microsoft.AspNetCore.Hosting.WebHost.Initialize()
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
   at API.Program.Main(String[] args) in /__w/1/s/src/API/Program.cs:line 18
</code>```

答:
You need to register IHttpContextAccessor service manually.

.net 6

```<code>builder.Services.AddHttpContextAccessor();
</code>```

.net 3.1,5

```<code>services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
</code>```

Body:
In Startup file, I am trying to inject the IHttpContextAccessor in constructor itself.

While running the API locally, IHttpContextAccessor is injected successfully in startup class. However when I am deploying the same to Azure kubernetes service, it fails and reported below exception. even pod state is crashloopbackoff.

Any suggestion how can I resolve this issue?

Here is the startup class.

public class Startup
{
    private readonly IConfiguration _configuration;
    private readonly ILogger _logger;
    private readonly IHttpContextAccessor _httpContextAccessor;

    public Startup(IConfiguration configuration, ILogger logger, IHttpContextAccessor httpContextAccessor)
    {
        _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
        _logger = logger ?? throw new ArgumentNullException(nameof(logger));
        _httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
        _logger.LogProcessStart();
    }
}

Here is the exception from pod logs.

    Unhandled exception. System.InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' whileattempting to activate 'API.Startup'.
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetServiceOrCreateInstance(IServiceProvider provider, Type type)
   at Microsoft.AspNetCore.Hosting.StartupLoader.LoadMethods(IServiceProvider hostingServiceProvider, Type startupType, String environmentName)
   at Microsoft.AspNetCore.Hosting.WebHostBuilderExtensions.<>c__DisplayClass3_0.<UseStartup>b__1(IServiceProvider sp)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContextcontext, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
   at Microsoft.AspNetCore.Hosting.WebHost.EnsureStartup()
   at Microsoft.AspNetCore.Hosting.WebHost.EnsureApplicationServices()
   at Microsoft.AspNetCore.Hosting.WebHost.Initialize()
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
   at API.Program.Main(String[] args) in /__w/1/s/src/API/Program.cs:line 18

Body:
You need to register IHttpContextAccessor service manually.

.net 6

builder.Services.AddHttpContextAccessor();

.net 3.1,5

services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();


问:
How to get product id on Product Editing page in BackOffice Prestashop 1.7
I am trying to get the product id of the product that is being edited in BackOffice (products page). The controller used there is AdminProducts. I tried to get the value by using Tools class as we do to get the product id on the front office but that doesn't work here. This is the link that I get on that page and after analyzing you can see there is no product id here. Although 1 is the product id meaning not specified like is done in prestashop 1.6. I am using prestashop 1.7. Any idea how I can get the product id in prestashop 1.7 on the products editing page? Also everything else works like if you use Tools class to get the controller name it will give you AdminProducts, only the product id is not there that is being edited.

http://localhost/prestashop/admin14pm/index.php/product/form/1?_token=eVl4wEOMTc2Jo#tab-hooks

答:
If you want the product id in hooks like DisplayAdminProductsExtra, you need to pass $params as a parameter and then you can assign your id in any variable as,

$id_product = $params['id_product'];


问:
Pass a variable into a filter - R dplyr
Here is a sample of the dataset that I have. I am looking to find the state that has the maximum number of stores. In this case, CA and also see how many IDs come from that state

```<code>| ID | | State | | Stores|
| -- | |------ | | ----- |
|a11 | | CA    | | 16585 |
|a12 | | CA    | | 45552 |
|a13 | | AK    | | 7811  |
|a14 | | MA    | | 4221  |
</code>```

I have this code using dplyr

```<code>max_state <- df  %>%
    group_by(State)  %>%
    summarise(total_stores = sum(Stores))  %>%
    top_n(1)  %>%
    select(State)
</code>```

This gives me "CA"

Can I use this variable "max(state)" to pass through a filter and use summarise(n()) to count the number of Ids for CA?

答:
A few ways:</p>
```<code># this takes your max_state (CA) and brings in the parts of
# your original table that have the same State
max_state %>%
  left_join(df) %>%
  summarize(n = n())

# filter the State in df to match the State in max_state
df %>%
  filter(State == max_state$State) %>%
  summarize(n = n())

# Add Stores_total for each State, only keep the State rows which
# match that of the max State, and count the # of IDs therein
df %>%
  group_by(State) %>%
  mutate(Stores_total = sum(Stores)) %>%
  filter(Stores_total == max(Stores_total)) %>%
  count(ID)

</code>```

Title: Pass a variable into a filter - R dplyr

Body:
Here is a sample of the dataset that I have. I am looking to find the state that has the maximum number of stores. In this case, CA and also see how many IDs come from that state

| ID | | State | | Stores|
| -- | |------ | | ----- |
|a11 | | CA    | | 16585 |
|a12 | | CA    | | 45552 |
|a13 | | AK    | | 7811  |
|a14 | | MA    | | 4221  |

I have this code using dplyr

max_state <- df  %>%
    group_by(State)  %>%
    summarise(total_stores = sum(Stores))  %>%
    top_n(1)  %>%
    select(State)

This gives me "CA"

Can I use this variable "max(state)" to pass through a filter and use summarise(n()) to count the number of Ids for CA?

Body:
A few ways:

# this takes your max_state (CA) and brings in the parts of
# your original table that have the same State
max_state %>%
  left_join(df) %>%
  summarize(n = n())

# filter the State in df to match the State in max_state
df %>%
  filter(State == max_state$State) %>%
  summarize(n = n())

# Add Stores_total for each State, only keep the State rows which
# match that of the max State, and count the # of IDs therein
df %>%
  group_by(State) %>%
  mutate(Stores_total = sum(Stores)) %>%
  filter(Stores_total == max(Stores_total)) %>%
  count(ID)